pdf.combined.js 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956
  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.332';
  27. var pdfjsBuild = '8a1ed8a';
  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.pdfjsCoreBidi = {});
  413. }(this, function (exports) {
  414. var baseTypes = [
  415. 'BN',
  416. 'BN',
  417. 'BN',
  418. 'BN',
  419. 'BN',
  420. 'BN',
  421. 'BN',
  422. 'BN',
  423. 'BN',
  424. 'S',
  425. 'B',
  426. 'S',
  427. 'WS',
  428. 'B',
  429. 'BN',
  430. 'BN',
  431. 'BN',
  432. 'BN',
  433. 'BN',
  434. 'BN',
  435. 'BN',
  436. 'BN',
  437. 'BN',
  438. 'BN',
  439. 'BN',
  440. 'BN',
  441. 'BN',
  442. 'BN',
  443. 'B',
  444. 'B',
  445. 'B',
  446. 'S',
  447. 'WS',
  448. 'ON',
  449. 'ON',
  450. 'ET',
  451. 'ET',
  452. 'ET',
  453. 'ON',
  454. 'ON',
  455. 'ON',
  456. 'ON',
  457. 'ON',
  458. 'ON',
  459. 'CS',
  460. 'ON',
  461. 'CS',
  462. 'ON',
  463. 'EN',
  464. 'EN',
  465. 'EN',
  466. 'EN',
  467. 'EN',
  468. 'EN',
  469. 'EN',
  470. 'EN',
  471. 'EN',
  472. 'EN',
  473. 'ON',
  474. 'ON',
  475. 'ON',
  476. 'ON',
  477. 'ON',
  478. 'ON',
  479. 'ON',
  480. 'L',
  481. 'L',
  482. 'L',
  483. 'L',
  484. 'L',
  485. 'L',
  486. 'L',
  487. 'L',
  488. 'L',
  489. 'L',
  490. 'L',
  491. 'L',
  492. 'L',
  493. 'L',
  494. 'L',
  495. 'L',
  496. 'L',
  497. 'L',
  498. 'L',
  499. 'L',
  500. 'L',
  501. 'L',
  502. 'L',
  503. 'L',
  504. 'L',
  505. 'L',
  506. 'ON',
  507. 'ON',
  508. 'ON',
  509. 'ON',
  510. 'ON',
  511. 'ON',
  512. 'L',
  513. 'L',
  514. 'L',
  515. 'L',
  516. 'L',
  517. 'L',
  518. 'L',
  519. 'L',
  520. 'L',
  521. 'L',
  522. 'L',
  523. 'L',
  524. 'L',
  525. 'L',
  526. 'L',
  527. 'L',
  528. 'L',
  529. 'L',
  530. 'L',
  531. 'L',
  532. 'L',
  533. 'L',
  534. 'L',
  535. 'L',
  536. 'L',
  537. 'L',
  538. 'ON',
  539. 'ON',
  540. 'ON',
  541. 'ON',
  542. 'BN',
  543. 'BN',
  544. 'BN',
  545. 'BN',
  546. 'BN',
  547. 'BN',
  548. 'B',
  549. 'BN',
  550. 'BN',
  551. 'BN',
  552. 'BN',
  553. 'BN',
  554. 'BN',
  555. 'BN',
  556. 'BN',
  557. 'BN',
  558. 'BN',
  559. 'BN',
  560. 'BN',
  561. 'BN',
  562. 'BN',
  563. 'BN',
  564. 'BN',
  565. 'BN',
  566. 'BN',
  567. 'BN',
  568. 'BN',
  569. 'BN',
  570. 'BN',
  571. 'BN',
  572. 'BN',
  573. 'BN',
  574. 'BN',
  575. 'CS',
  576. 'ON',
  577. 'ET',
  578. 'ET',
  579. 'ET',
  580. 'ET',
  581. 'ON',
  582. 'ON',
  583. 'ON',
  584. 'ON',
  585. 'L',
  586. 'ON',
  587. 'ON',
  588. 'ON',
  589. 'ON',
  590. 'ON',
  591. 'ET',
  592. 'ET',
  593. 'EN',
  594. 'EN',
  595. 'ON',
  596. 'L',
  597. 'ON',
  598. 'ON',
  599. 'ON',
  600. 'EN',
  601. 'L',
  602. 'ON',
  603. 'ON',
  604. 'ON',
  605. 'ON',
  606. 'ON',
  607. 'L',
  608. 'L',
  609. 'L',
  610. 'L',
  611. 'L',
  612. 'L',
  613. 'L',
  614. 'L',
  615. 'L',
  616. 'L',
  617. 'L',
  618. 'L',
  619. 'L',
  620. 'L',
  621. 'L',
  622. 'L',
  623. 'L',
  624. 'L',
  625. 'L',
  626. 'L',
  627. 'L',
  628. 'L',
  629. 'L',
  630. 'ON',
  631. 'L',
  632. 'L',
  633. 'L',
  634. 'L',
  635. 'L',
  636. 'L',
  637. 'L',
  638. 'L',
  639. 'L',
  640. 'L',
  641. 'L',
  642. 'L',
  643. 'L',
  644. 'L',
  645. 'L',
  646. 'L',
  647. 'L',
  648. 'L',
  649. 'L',
  650. 'L',
  651. 'L',
  652. 'L',
  653. 'L',
  654. 'L',
  655. 'L',
  656. 'L',
  657. 'L',
  658. 'L',
  659. 'L',
  660. 'L',
  661. 'L',
  662. 'ON',
  663. 'L',
  664. 'L',
  665. 'L',
  666. 'L',
  667. 'L',
  668. 'L',
  669. 'L',
  670. 'L'
  671. ];
  672. var arabicTypes = [
  673. 'AL',
  674. 'AL',
  675. 'AL',
  676. 'AL',
  677. 'AL',
  678. 'AL',
  679. 'AL',
  680. 'AL',
  681. 'AL',
  682. 'AL',
  683. 'AL',
  684. 'AL',
  685. 'CS',
  686. 'AL',
  687. 'ON',
  688. 'ON',
  689. 'NSM',
  690. 'NSM',
  691. 'NSM',
  692. 'NSM',
  693. 'NSM',
  694. 'NSM',
  695. 'AL',
  696. 'AL',
  697. 'AL',
  698. 'AL',
  699. 'AL',
  700. 'AL',
  701. 'AL',
  702. 'AL',
  703. 'AL',
  704. 'AL',
  705. 'AL',
  706. 'AL',
  707. 'AL',
  708. 'AL',
  709. 'AL',
  710. 'AL',
  711. 'AL',
  712. 'AL',
  713. 'AL',
  714. 'AL',
  715. 'AL',
  716. 'AL',
  717. 'AL',
  718. 'AL',
  719. 'AL',
  720. 'AL',
  721. 'AL',
  722. 'AL',
  723. 'AL',
  724. 'AL',
  725. 'AL',
  726. 'AL',
  727. 'AL',
  728. 'AL',
  729. 'AL',
  730. 'AL',
  731. 'AL',
  732. 'AL',
  733. 'AL',
  734. 'AL',
  735. 'AL',
  736. 'AL',
  737. 'AL',
  738. 'AL',
  739. 'AL',
  740. 'AL',
  741. 'AL',
  742. 'AL',
  743. 'AL',
  744. 'AL',
  745. 'AL',
  746. 'AL',
  747. 'AL',
  748. 'NSM',
  749. 'NSM',
  750. 'NSM',
  751. 'NSM',
  752. 'NSM',
  753. 'NSM',
  754. 'NSM',
  755. 'NSM',
  756. 'NSM',
  757. 'NSM',
  758. 'NSM',
  759. 'NSM',
  760. 'NSM',
  761. 'NSM',
  762. 'AL',
  763. 'AL',
  764. 'AL',
  765. 'AL',
  766. 'AL',
  767. 'AL',
  768. 'AL',
  769. 'AN',
  770. 'AN',
  771. 'AN',
  772. 'AN',
  773. 'AN',
  774. 'AN',
  775. 'AN',
  776. 'AN',
  777. 'AN',
  778. 'AN',
  779. 'ET',
  780. 'AN',
  781. 'AN',
  782. 'AL',
  783. 'AL',
  784. 'AL',
  785. 'NSM',
  786. 'AL',
  787. 'AL',
  788. 'AL',
  789. 'AL',
  790. 'AL',
  791. 'AL',
  792. 'AL',
  793. 'AL',
  794. 'AL',
  795. 'AL',
  796. 'AL',
  797. 'AL',
  798. 'AL',
  799. 'AL',
  800. 'AL',
  801. 'AL',
  802. 'AL',
  803. 'AL',
  804. 'AL',
  805. 'AL',
  806. 'AL',
  807. 'AL',
  808. 'AL',
  809. 'AL',
  810. 'AL',
  811. 'AL',
  812. 'AL',
  813. 'AL',
  814. 'AL',
  815. 'AL',
  816. 'AL',
  817. 'AL',
  818. 'AL',
  819. 'AL',
  820. 'AL',
  821. 'AL',
  822. 'AL',
  823. 'AL',
  824. 'AL',
  825. 'AL',
  826. 'AL',
  827. 'AL',
  828. 'AL',
  829. 'AL',
  830. 'AL',
  831. 'AL',
  832. 'AL',
  833. 'AL',
  834. 'AL',
  835. 'AL',
  836. 'AL',
  837. 'AL',
  838. 'AL',
  839. 'AL',
  840. 'AL',
  841. 'AL',
  842. 'AL',
  843. 'AL',
  844. 'AL',
  845. 'AL',
  846. 'AL',
  847. 'AL',
  848. 'AL',
  849. 'AL',
  850. 'AL',
  851. 'AL',
  852. 'AL',
  853. 'AL',
  854. 'AL',
  855. 'AL',
  856. 'AL',
  857. 'AL',
  858. 'AL',
  859. 'AL',
  860. 'AL',
  861. 'AL',
  862. 'AL',
  863. 'AL',
  864. 'AL',
  865. 'AL',
  866. 'AL',
  867. 'AL',
  868. 'AL',
  869. 'AL',
  870. 'AL',
  871. 'AL',
  872. 'AL',
  873. 'AL',
  874. 'AL',
  875. 'AL',
  876. 'AL',
  877. 'AL',
  878. 'AL',
  879. 'AL',
  880. 'AL',
  881. 'AL',
  882. 'AL',
  883. 'AL',
  884. 'AL',
  885. 'AL',
  886. 'AL',
  887. 'NSM',
  888. 'NSM',
  889. 'NSM',
  890. 'NSM',
  891. 'NSM',
  892. 'NSM',
  893. 'NSM',
  894. 'NSM',
  895. 'NSM',
  896. 'NSM',
  897. 'NSM',
  898. 'NSM',
  899. 'NSM',
  900. 'NSM',
  901. 'NSM',
  902. 'NSM',
  903. 'NSM',
  904. 'NSM',
  905. 'NSM',
  906. 'ON',
  907. 'NSM',
  908. 'NSM',
  909. 'NSM',
  910. 'NSM',
  911. 'AL',
  912. 'AL',
  913. 'AL',
  914. 'AL',
  915. 'AL',
  916. 'AL',
  917. 'AL',
  918. 'AL',
  919. 'AL',
  920. 'AL',
  921. 'AL',
  922. 'AL',
  923. 'AL',
  924. 'AL',
  925. 'AL',
  926. 'AL',
  927. 'AL',
  928. 'AL'
  929. ];
  930. function isOdd(i) {
  931. return (i & 1) !== 0;
  932. }
  933. function isEven(i) {
  934. return (i & 1) === 0;
  935. }
  936. function findUnequal(arr, start, value) {
  937. for (var j = start, jj = arr.length; j < jj; ++j) {
  938. if (arr[j] !== value) {
  939. return j;
  940. }
  941. }
  942. return j;
  943. }
  944. function setValues(arr, start, end, value) {
  945. for (var j = start; j < end; ++j) {
  946. arr[j] = value;
  947. }
  948. }
  949. function reverseValues(arr, start, end) {
  950. for (var i = start, j = end - 1; i < j; ++i, --j) {
  951. var temp = arr[i];
  952. arr[i] = arr[j];
  953. arr[j] = temp;
  954. }
  955. }
  956. function createBidiText(str, isLTR, vertical) {
  957. return {
  958. str: str,
  959. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  960. };
  961. }
  962. var chars = [];
  963. var types = [];
  964. function bidi(str, startLevel, vertical) {
  965. var isLTR = true;
  966. var strLength = str.length;
  967. if (strLength === 0 || vertical) {
  968. return createBidiText(str, isLTR, vertical);
  969. }
  970. chars.length = strLength;
  971. types.length = strLength;
  972. var numBidi = 0;
  973. var i, ii;
  974. for (i = 0; i < strLength; ++i) {
  975. chars[i] = str.charAt(i);
  976. var charCode = str.charCodeAt(i);
  977. var charType = 'L';
  978. if (charCode <= 0x00ff) {
  979. charType = baseTypes[charCode];
  980. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  981. charType = 'R';
  982. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  983. charType = arabicTypes[charCode & 0xff];
  984. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  985. charType = 'AL';
  986. }
  987. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  988. numBidi++;
  989. }
  990. types[i] = charType;
  991. }
  992. if (numBidi === 0) {
  993. isLTR = true;
  994. return createBidiText(str, isLTR);
  995. }
  996. if (startLevel === -1) {
  997. if (strLength / numBidi < 0.3) {
  998. isLTR = true;
  999. startLevel = 0;
  1000. } else {
  1001. isLTR = false;
  1002. startLevel = 1;
  1003. }
  1004. }
  1005. var levels = [];
  1006. for (i = 0; i < strLength; ++i) {
  1007. levels[i] = startLevel;
  1008. }
  1009. var e = isOdd(startLevel) ? 'R' : 'L';
  1010. var sor = e;
  1011. var eor = sor;
  1012. var lastType = sor;
  1013. for (i = 0; i < strLength; ++i) {
  1014. if (types[i] === 'NSM') {
  1015. types[i] = lastType;
  1016. } else {
  1017. lastType = types[i];
  1018. }
  1019. }
  1020. lastType = sor;
  1021. var t;
  1022. for (i = 0; i < strLength; ++i) {
  1023. t = types[i];
  1024. if (t === 'EN') {
  1025. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  1026. } else if (t === 'R' || t === 'L' || t === 'AL') {
  1027. lastType = t;
  1028. }
  1029. }
  1030. for (i = 0; i < strLength; ++i) {
  1031. t = types[i];
  1032. if (t === 'AL') {
  1033. types[i] = 'R';
  1034. }
  1035. }
  1036. for (i = 1; i < strLength - 1; ++i) {
  1037. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  1038. types[i] = 'EN';
  1039. }
  1040. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  1041. types[i] = types[i - 1];
  1042. }
  1043. }
  1044. for (i = 0; i < strLength; ++i) {
  1045. if (types[i] === 'EN') {
  1046. var j;
  1047. for (j = i - 1; j >= 0; --j) {
  1048. if (types[j] !== 'ET') {
  1049. break;
  1050. }
  1051. types[j] = 'EN';
  1052. }
  1053. for (j = i + 1; j < strLength; ++j) {
  1054. if (types[j] !== 'ET') {
  1055. break;
  1056. }
  1057. types[j] = 'EN';
  1058. }
  1059. }
  1060. }
  1061. for (i = 0; i < strLength; ++i) {
  1062. t = types[i];
  1063. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  1064. types[i] = 'ON';
  1065. }
  1066. }
  1067. lastType = sor;
  1068. for (i = 0; i < strLength; ++i) {
  1069. t = types[i];
  1070. if (t === 'EN') {
  1071. types[i] = lastType === 'L' ? 'L' : 'EN';
  1072. } else if (t === 'R' || t === 'L') {
  1073. lastType = t;
  1074. }
  1075. }
  1076. for (i = 0; i < strLength; ++i) {
  1077. if (types[i] === 'ON') {
  1078. var end = findUnequal(types, i + 1, 'ON');
  1079. var before = sor;
  1080. if (i > 0) {
  1081. before = types[i - 1];
  1082. }
  1083. var after = eor;
  1084. if (end + 1 < strLength) {
  1085. after = types[end + 1];
  1086. }
  1087. if (before !== 'L') {
  1088. before = 'R';
  1089. }
  1090. if (after !== 'L') {
  1091. after = 'R';
  1092. }
  1093. if (before === after) {
  1094. setValues(types, i, end, before);
  1095. }
  1096. i = end - 1;
  1097. }
  1098. }
  1099. for (i = 0; i < strLength; ++i) {
  1100. if (types[i] === 'ON') {
  1101. types[i] = e;
  1102. }
  1103. }
  1104. for (i = 0; i < strLength; ++i) {
  1105. t = types[i];
  1106. if (isEven(levels[i])) {
  1107. if (t === 'R') {
  1108. levels[i] += 1;
  1109. } else if (t === 'AN' || t === 'EN') {
  1110. levels[i] += 2;
  1111. }
  1112. } else {
  1113. if (t === 'L' || t === 'AN' || t === 'EN') {
  1114. levels[i] += 1;
  1115. }
  1116. }
  1117. }
  1118. var highestLevel = -1;
  1119. var lowestOddLevel = 99;
  1120. var level;
  1121. for (i = 0, ii = levels.length; i < ii; ++i) {
  1122. level = levels[i];
  1123. if (highestLevel < level) {
  1124. highestLevel = level;
  1125. }
  1126. if (lowestOddLevel > level && isOdd(level)) {
  1127. lowestOddLevel = level;
  1128. }
  1129. }
  1130. for (level = highestLevel; level >= lowestOddLevel; --level) {
  1131. var start = -1;
  1132. for (i = 0, ii = levels.length; i < ii; ++i) {
  1133. if (levels[i] < level) {
  1134. if (start >= 0) {
  1135. reverseValues(chars, start, i);
  1136. start = -1;
  1137. }
  1138. } else if (start < 0) {
  1139. start = i;
  1140. }
  1141. }
  1142. if (start >= 0) {
  1143. reverseValues(chars, start, levels.length);
  1144. }
  1145. }
  1146. for (i = 0, ii = chars.length; i < ii; ++i) {
  1147. var ch = chars[i];
  1148. if (ch === '<' || ch === '>') {
  1149. chars[i] = '';
  1150. }
  1151. }
  1152. return createBidiText(chars.join(''), isLTR);
  1153. }
  1154. exports.bidi = bidi;
  1155. }));
  1156. (function (root, factory) {
  1157. factory(root.pdfjsCoreCharsets = {});
  1158. }(this, function (exports) {
  1159. var ISOAdobeCharset = [
  1160. '.notdef',
  1161. 'space',
  1162. 'exclam',
  1163. 'quotedbl',
  1164. 'numbersign',
  1165. 'dollar',
  1166. 'percent',
  1167. 'ampersand',
  1168. 'quoteright',
  1169. 'parenleft',
  1170. 'parenright',
  1171. 'asterisk',
  1172. 'plus',
  1173. 'comma',
  1174. 'hyphen',
  1175. 'period',
  1176. 'slash',
  1177. 'zero',
  1178. 'one',
  1179. 'two',
  1180. 'three',
  1181. 'four',
  1182. 'five',
  1183. 'six',
  1184. 'seven',
  1185. 'eight',
  1186. 'nine',
  1187. 'colon',
  1188. 'semicolon',
  1189. 'less',
  1190. 'equal',
  1191. 'greater',
  1192. 'question',
  1193. 'at',
  1194. 'A',
  1195. 'B',
  1196. 'C',
  1197. 'D',
  1198. 'E',
  1199. 'F',
  1200. 'G',
  1201. 'H',
  1202. 'I',
  1203. 'J',
  1204. 'K',
  1205. 'L',
  1206. 'M',
  1207. 'N',
  1208. 'O',
  1209. 'P',
  1210. 'Q',
  1211. 'R',
  1212. 'S',
  1213. 'T',
  1214. 'U',
  1215. 'V',
  1216. 'W',
  1217. 'X',
  1218. 'Y',
  1219. 'Z',
  1220. 'bracketleft',
  1221. 'backslash',
  1222. 'bracketright',
  1223. 'asciicircum',
  1224. 'underscore',
  1225. 'quoteleft',
  1226. 'a',
  1227. 'b',
  1228. 'c',
  1229. 'd',
  1230. 'e',
  1231. 'f',
  1232. 'g',
  1233. 'h',
  1234. 'i',
  1235. 'j',
  1236. 'k',
  1237. 'l',
  1238. 'm',
  1239. 'n',
  1240. 'o',
  1241. 'p',
  1242. 'q',
  1243. 'r',
  1244. 's',
  1245. 't',
  1246. 'u',
  1247. 'v',
  1248. 'w',
  1249. 'x',
  1250. 'y',
  1251. 'z',
  1252. 'braceleft',
  1253. 'bar',
  1254. 'braceright',
  1255. 'asciitilde',
  1256. 'exclamdown',
  1257. 'cent',
  1258. 'sterling',
  1259. 'fraction',
  1260. 'yen',
  1261. 'florin',
  1262. 'section',
  1263. 'currency',
  1264. 'quotesingle',
  1265. 'quotedblleft',
  1266. 'guillemotleft',
  1267. 'guilsinglleft',
  1268. 'guilsinglright',
  1269. 'fi',
  1270. 'fl',
  1271. 'endash',
  1272. 'dagger',
  1273. 'daggerdbl',
  1274. 'periodcentered',
  1275. 'paragraph',
  1276. 'bullet',
  1277. 'quotesinglbase',
  1278. 'quotedblbase',
  1279. 'quotedblright',
  1280. 'guillemotright',
  1281. 'ellipsis',
  1282. 'perthousand',
  1283. 'questiondown',
  1284. 'grave',
  1285. 'acute',
  1286. 'circumflex',
  1287. 'tilde',
  1288. 'macron',
  1289. 'breve',
  1290. 'dotaccent',
  1291. 'dieresis',
  1292. 'ring',
  1293. 'cedilla',
  1294. 'hungarumlaut',
  1295. 'ogonek',
  1296. 'caron',
  1297. 'emdash',
  1298. 'AE',
  1299. 'ordfeminine',
  1300. 'Lslash',
  1301. 'Oslash',
  1302. 'OE',
  1303. 'ordmasculine',
  1304. 'ae',
  1305. 'dotlessi',
  1306. 'lslash',
  1307. 'oslash',
  1308. 'oe',
  1309. 'germandbls',
  1310. 'onesuperior',
  1311. 'logicalnot',
  1312. 'mu',
  1313. 'trademark',
  1314. 'Eth',
  1315. 'onehalf',
  1316. 'plusminus',
  1317. 'Thorn',
  1318. 'onequarter',
  1319. 'divide',
  1320. 'brokenbar',
  1321. 'degree',
  1322. 'thorn',
  1323. 'threequarters',
  1324. 'twosuperior',
  1325. 'registered',
  1326. 'minus',
  1327. 'eth',
  1328. 'multiply',
  1329. 'threesuperior',
  1330. 'copyright',
  1331. 'Aacute',
  1332. 'Acircumflex',
  1333. 'Adieresis',
  1334. 'Agrave',
  1335. 'Aring',
  1336. 'Atilde',
  1337. 'Ccedilla',
  1338. 'Eacute',
  1339. 'Ecircumflex',
  1340. 'Edieresis',
  1341. 'Egrave',
  1342. 'Iacute',
  1343. 'Icircumflex',
  1344. 'Idieresis',
  1345. 'Igrave',
  1346. 'Ntilde',
  1347. 'Oacute',
  1348. 'Ocircumflex',
  1349. 'Odieresis',
  1350. 'Ograve',
  1351. 'Otilde',
  1352. 'Scaron',
  1353. 'Uacute',
  1354. 'Ucircumflex',
  1355. 'Udieresis',
  1356. 'Ugrave',
  1357. 'Yacute',
  1358. 'Ydieresis',
  1359. 'Zcaron',
  1360. 'aacute',
  1361. 'acircumflex',
  1362. 'adieresis',
  1363. 'agrave',
  1364. 'aring',
  1365. 'atilde',
  1366. 'ccedilla',
  1367. 'eacute',
  1368. 'ecircumflex',
  1369. 'edieresis',
  1370. 'egrave',
  1371. 'iacute',
  1372. 'icircumflex',
  1373. 'idieresis',
  1374. 'igrave',
  1375. 'ntilde',
  1376. 'oacute',
  1377. 'ocircumflex',
  1378. 'odieresis',
  1379. 'ograve',
  1380. 'otilde',
  1381. 'scaron',
  1382. 'uacute',
  1383. 'ucircumflex',
  1384. 'udieresis',
  1385. 'ugrave',
  1386. 'yacute',
  1387. 'ydieresis',
  1388. 'zcaron'
  1389. ];
  1390. var ExpertCharset = [
  1391. '.notdef',
  1392. 'space',
  1393. 'exclamsmall',
  1394. 'Hungarumlautsmall',
  1395. 'dollaroldstyle',
  1396. 'dollarsuperior',
  1397. 'ampersandsmall',
  1398. 'Acutesmall',
  1399. 'parenleftsuperior',
  1400. 'parenrightsuperior',
  1401. 'twodotenleader',
  1402. 'onedotenleader',
  1403. 'comma',
  1404. 'hyphen',
  1405. 'period',
  1406. 'fraction',
  1407. 'zerooldstyle',
  1408. 'oneoldstyle',
  1409. 'twooldstyle',
  1410. 'threeoldstyle',
  1411. 'fouroldstyle',
  1412. 'fiveoldstyle',
  1413. 'sixoldstyle',
  1414. 'sevenoldstyle',
  1415. 'eightoldstyle',
  1416. 'nineoldstyle',
  1417. 'colon',
  1418. 'semicolon',
  1419. 'commasuperior',
  1420. 'threequartersemdash',
  1421. 'periodsuperior',
  1422. 'questionsmall',
  1423. 'asuperior',
  1424. 'bsuperior',
  1425. 'centsuperior',
  1426. 'dsuperior',
  1427. 'esuperior',
  1428. 'isuperior',
  1429. 'lsuperior',
  1430. 'msuperior',
  1431. 'nsuperior',
  1432. 'osuperior',
  1433. 'rsuperior',
  1434. 'ssuperior',
  1435. 'tsuperior',
  1436. 'ff',
  1437. 'fi',
  1438. 'fl',
  1439. 'ffi',
  1440. 'ffl',
  1441. 'parenleftinferior',
  1442. 'parenrightinferior',
  1443. 'Circumflexsmall',
  1444. 'hyphensuperior',
  1445. 'Gravesmall',
  1446. 'Asmall',
  1447. 'Bsmall',
  1448. 'Csmall',
  1449. 'Dsmall',
  1450. 'Esmall',
  1451. 'Fsmall',
  1452. 'Gsmall',
  1453. 'Hsmall',
  1454. 'Ismall',
  1455. 'Jsmall',
  1456. 'Ksmall',
  1457. 'Lsmall',
  1458. 'Msmall',
  1459. 'Nsmall',
  1460. 'Osmall',
  1461. 'Psmall',
  1462. 'Qsmall',
  1463. 'Rsmall',
  1464. 'Ssmall',
  1465. 'Tsmall',
  1466. 'Usmall',
  1467. 'Vsmall',
  1468. 'Wsmall',
  1469. 'Xsmall',
  1470. 'Ysmall',
  1471. 'Zsmall',
  1472. 'colonmonetary',
  1473. 'onefitted',
  1474. 'rupiah',
  1475. 'Tildesmall',
  1476. 'exclamdownsmall',
  1477. 'centoldstyle',
  1478. 'Lslashsmall',
  1479. 'Scaronsmall',
  1480. 'Zcaronsmall',
  1481. 'Dieresissmall',
  1482. 'Brevesmall',
  1483. 'Caronsmall',
  1484. 'Dotaccentsmall',
  1485. 'Macronsmall',
  1486. 'figuredash',
  1487. 'hypheninferior',
  1488. 'Ogoneksmall',
  1489. 'Ringsmall',
  1490. 'Cedillasmall',
  1491. 'onequarter',
  1492. 'onehalf',
  1493. 'threequarters',
  1494. 'questiondownsmall',
  1495. 'oneeighth',
  1496. 'threeeighths',
  1497. 'fiveeighths',
  1498. 'seveneighths',
  1499. 'onethird',
  1500. 'twothirds',
  1501. 'zerosuperior',
  1502. 'onesuperior',
  1503. 'twosuperior',
  1504. 'threesuperior',
  1505. 'foursuperior',
  1506. 'fivesuperior',
  1507. 'sixsuperior',
  1508. 'sevensuperior',
  1509. 'eightsuperior',
  1510. 'ninesuperior',
  1511. 'zeroinferior',
  1512. 'oneinferior',
  1513. 'twoinferior',
  1514. 'threeinferior',
  1515. 'fourinferior',
  1516. 'fiveinferior',
  1517. 'sixinferior',
  1518. 'seveninferior',
  1519. 'eightinferior',
  1520. 'nineinferior',
  1521. 'centinferior',
  1522. 'dollarinferior',
  1523. 'periodinferior',
  1524. 'commainferior',
  1525. 'Agravesmall',
  1526. 'Aacutesmall',
  1527. 'Acircumflexsmall',
  1528. 'Atildesmall',
  1529. 'Adieresissmall',
  1530. 'Aringsmall',
  1531. 'AEsmall',
  1532. 'Ccedillasmall',
  1533. 'Egravesmall',
  1534. 'Eacutesmall',
  1535. 'Ecircumflexsmall',
  1536. 'Edieresissmall',
  1537. 'Igravesmall',
  1538. 'Iacutesmall',
  1539. 'Icircumflexsmall',
  1540. 'Idieresissmall',
  1541. 'Ethsmall',
  1542. 'Ntildesmall',
  1543. 'Ogravesmall',
  1544. 'Oacutesmall',
  1545. 'Ocircumflexsmall',
  1546. 'Otildesmall',
  1547. 'Odieresissmall',
  1548. 'OEsmall',
  1549. 'Oslashsmall',
  1550. 'Ugravesmall',
  1551. 'Uacutesmall',
  1552. 'Ucircumflexsmall',
  1553. 'Udieresissmall',
  1554. 'Yacutesmall',
  1555. 'Thornsmall',
  1556. 'Ydieresissmall'
  1557. ];
  1558. var ExpertSubsetCharset = [
  1559. '.notdef',
  1560. 'space',
  1561. 'dollaroldstyle',
  1562. 'dollarsuperior',
  1563. 'parenleftsuperior',
  1564. 'parenrightsuperior',
  1565. 'twodotenleader',
  1566. 'onedotenleader',
  1567. 'comma',
  1568. 'hyphen',
  1569. 'period',
  1570. 'fraction',
  1571. 'zerooldstyle',
  1572. 'oneoldstyle',
  1573. 'twooldstyle',
  1574. 'threeoldstyle',
  1575. 'fouroldstyle',
  1576. 'fiveoldstyle',
  1577. 'sixoldstyle',
  1578. 'sevenoldstyle',
  1579. 'eightoldstyle',
  1580. 'nineoldstyle',
  1581. 'colon',
  1582. 'semicolon',
  1583. 'commasuperior',
  1584. 'threequartersemdash',
  1585. 'periodsuperior',
  1586. 'asuperior',
  1587. 'bsuperior',
  1588. 'centsuperior',
  1589. 'dsuperior',
  1590. 'esuperior',
  1591. 'isuperior',
  1592. 'lsuperior',
  1593. 'msuperior',
  1594. 'nsuperior',
  1595. 'osuperior',
  1596. 'rsuperior',
  1597. 'ssuperior',
  1598. 'tsuperior',
  1599. 'ff',
  1600. 'fi',
  1601. 'fl',
  1602. 'ffi',
  1603. 'ffl',
  1604. 'parenleftinferior',
  1605. 'parenrightinferior',
  1606. 'hyphensuperior',
  1607. 'colonmonetary',
  1608. 'onefitted',
  1609. 'rupiah',
  1610. 'centoldstyle',
  1611. 'figuredash',
  1612. 'hypheninferior',
  1613. 'onequarter',
  1614. 'onehalf',
  1615. 'threequarters',
  1616. 'oneeighth',
  1617. 'threeeighths',
  1618. 'fiveeighths',
  1619. 'seveneighths',
  1620. 'onethird',
  1621. 'twothirds',
  1622. 'zerosuperior',
  1623. 'onesuperior',
  1624. 'twosuperior',
  1625. 'threesuperior',
  1626. 'foursuperior',
  1627. 'fivesuperior',
  1628. 'sixsuperior',
  1629. 'sevensuperior',
  1630. 'eightsuperior',
  1631. 'ninesuperior',
  1632. 'zeroinferior',
  1633. 'oneinferior',
  1634. 'twoinferior',
  1635. 'threeinferior',
  1636. 'fourinferior',
  1637. 'fiveinferior',
  1638. 'sixinferior',
  1639. 'seveninferior',
  1640. 'eightinferior',
  1641. 'nineinferior',
  1642. 'centinferior',
  1643. 'dollarinferior',
  1644. 'periodinferior',
  1645. 'commainferior'
  1646. ];
  1647. exports.ISOAdobeCharset = ISOAdobeCharset;
  1648. exports.ExpertCharset = ExpertCharset;
  1649. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  1650. }));
  1651. (function (root, factory) {
  1652. factory(root.pdfjsCoreEncodings = {});
  1653. }(this, function (exports) {
  1654. var ExpertEncoding = [
  1655. '',
  1656. '',
  1657. '',
  1658. '',
  1659. '',
  1660. '',
  1661. '',
  1662. '',
  1663. '',
  1664. '',
  1665. '',
  1666. '',
  1667. '',
  1668. '',
  1669. '',
  1670. '',
  1671. '',
  1672. '',
  1673. '',
  1674. '',
  1675. '',
  1676. '',
  1677. '',
  1678. '',
  1679. '',
  1680. '',
  1681. '',
  1682. '',
  1683. '',
  1684. '',
  1685. '',
  1686. '',
  1687. 'space',
  1688. 'exclamsmall',
  1689. 'Hungarumlautsmall',
  1690. '',
  1691. 'dollaroldstyle',
  1692. 'dollarsuperior',
  1693. 'ampersandsmall',
  1694. 'Acutesmall',
  1695. 'parenleftsuperior',
  1696. 'parenrightsuperior',
  1697. 'twodotenleader',
  1698. 'onedotenleader',
  1699. 'comma',
  1700. 'hyphen',
  1701. 'period',
  1702. 'fraction',
  1703. 'zerooldstyle',
  1704. 'oneoldstyle',
  1705. 'twooldstyle',
  1706. 'threeoldstyle',
  1707. 'fouroldstyle',
  1708. 'fiveoldstyle',
  1709. 'sixoldstyle',
  1710. 'sevenoldstyle',
  1711. 'eightoldstyle',
  1712. 'nineoldstyle',
  1713. 'colon',
  1714. 'semicolon',
  1715. 'commasuperior',
  1716. 'threequartersemdash',
  1717. 'periodsuperior',
  1718. 'questionsmall',
  1719. '',
  1720. 'asuperior',
  1721. 'bsuperior',
  1722. 'centsuperior',
  1723. 'dsuperior',
  1724. 'esuperior',
  1725. '',
  1726. '',
  1727. 'isuperior',
  1728. '',
  1729. '',
  1730. 'lsuperior',
  1731. 'msuperior',
  1732. 'nsuperior',
  1733. 'osuperior',
  1734. '',
  1735. '',
  1736. 'rsuperior',
  1737. 'ssuperior',
  1738. 'tsuperior',
  1739. '',
  1740. 'ff',
  1741. 'fi',
  1742. 'fl',
  1743. 'ffi',
  1744. 'ffl',
  1745. 'parenleftinferior',
  1746. '',
  1747. 'parenrightinferior',
  1748. 'Circumflexsmall',
  1749. 'hyphensuperior',
  1750. 'Gravesmall',
  1751. 'Asmall',
  1752. 'Bsmall',
  1753. 'Csmall',
  1754. 'Dsmall',
  1755. 'Esmall',
  1756. 'Fsmall',
  1757. 'Gsmall',
  1758. 'Hsmall',
  1759. 'Ismall',
  1760. 'Jsmall',
  1761. 'Ksmall',
  1762. 'Lsmall',
  1763. 'Msmall',
  1764. 'Nsmall',
  1765. 'Osmall',
  1766. 'Psmall',
  1767. 'Qsmall',
  1768. 'Rsmall',
  1769. 'Ssmall',
  1770. 'Tsmall',
  1771. 'Usmall',
  1772. 'Vsmall',
  1773. 'Wsmall',
  1774. 'Xsmall',
  1775. 'Ysmall',
  1776. 'Zsmall',
  1777. 'colonmonetary',
  1778. 'onefitted',
  1779. 'rupiah',
  1780. 'Tildesmall',
  1781. '',
  1782. '',
  1783. '',
  1784. '',
  1785. '',
  1786. '',
  1787. '',
  1788. '',
  1789. '',
  1790. '',
  1791. '',
  1792. '',
  1793. '',
  1794. '',
  1795. '',
  1796. '',
  1797. '',
  1798. '',
  1799. '',
  1800. '',
  1801. '',
  1802. '',
  1803. '',
  1804. '',
  1805. '',
  1806. '',
  1807. '',
  1808. '',
  1809. '',
  1810. '',
  1811. '',
  1812. '',
  1813. '',
  1814. '',
  1815. 'exclamdownsmall',
  1816. 'centoldstyle',
  1817. 'Lslashsmall',
  1818. '',
  1819. '',
  1820. 'Scaronsmall',
  1821. 'Zcaronsmall',
  1822. 'Dieresissmall',
  1823. 'Brevesmall',
  1824. 'Caronsmall',
  1825. '',
  1826. 'Dotaccentsmall',
  1827. '',
  1828. '',
  1829. 'Macronsmall',
  1830. '',
  1831. '',
  1832. 'figuredash',
  1833. 'hypheninferior',
  1834. '',
  1835. '',
  1836. 'Ogoneksmall',
  1837. 'Ringsmall',
  1838. 'Cedillasmall',
  1839. '',
  1840. '',
  1841. '',
  1842. 'onequarter',
  1843. 'onehalf',
  1844. 'threequarters',
  1845. 'questiondownsmall',
  1846. 'oneeighth',
  1847. 'threeeighths',
  1848. 'fiveeighths',
  1849. 'seveneighths',
  1850. 'onethird',
  1851. 'twothirds',
  1852. '',
  1853. '',
  1854. 'zerosuperior',
  1855. 'onesuperior',
  1856. 'twosuperior',
  1857. 'threesuperior',
  1858. 'foursuperior',
  1859. 'fivesuperior',
  1860. 'sixsuperior',
  1861. 'sevensuperior',
  1862. 'eightsuperior',
  1863. 'ninesuperior',
  1864. 'zeroinferior',
  1865. 'oneinferior',
  1866. 'twoinferior',
  1867. 'threeinferior',
  1868. 'fourinferior',
  1869. 'fiveinferior',
  1870. 'sixinferior',
  1871. 'seveninferior',
  1872. 'eightinferior',
  1873. 'nineinferior',
  1874. 'centinferior',
  1875. 'dollarinferior',
  1876. 'periodinferior',
  1877. 'commainferior',
  1878. 'Agravesmall',
  1879. 'Aacutesmall',
  1880. 'Acircumflexsmall',
  1881. 'Atildesmall',
  1882. 'Adieresissmall',
  1883. 'Aringsmall',
  1884. 'AEsmall',
  1885. 'Ccedillasmall',
  1886. 'Egravesmall',
  1887. 'Eacutesmall',
  1888. 'Ecircumflexsmall',
  1889. 'Edieresissmall',
  1890. 'Igravesmall',
  1891. 'Iacutesmall',
  1892. 'Icircumflexsmall',
  1893. 'Idieresissmall',
  1894. 'Ethsmall',
  1895. 'Ntildesmall',
  1896. 'Ogravesmall',
  1897. 'Oacutesmall',
  1898. 'Ocircumflexsmall',
  1899. 'Otildesmall',
  1900. 'Odieresissmall',
  1901. 'OEsmall',
  1902. 'Oslashsmall',
  1903. 'Ugravesmall',
  1904. 'Uacutesmall',
  1905. 'Ucircumflexsmall',
  1906. 'Udieresissmall',
  1907. 'Yacutesmall',
  1908. 'Thornsmall',
  1909. 'Ydieresissmall'
  1910. ];
  1911. var MacExpertEncoding = [
  1912. '',
  1913. '',
  1914. '',
  1915. '',
  1916. '',
  1917. '',
  1918. '',
  1919. '',
  1920. '',
  1921. '',
  1922. '',
  1923. '',
  1924. '',
  1925. '',
  1926. '',
  1927. '',
  1928. '',
  1929. '',
  1930. '',
  1931. '',
  1932. '',
  1933. '',
  1934. '',
  1935. '',
  1936. '',
  1937. '',
  1938. '',
  1939. '',
  1940. '',
  1941. '',
  1942. '',
  1943. '',
  1944. 'space',
  1945. 'exclamsmall',
  1946. 'Hungarumlautsmall',
  1947. 'centoldstyle',
  1948. 'dollaroldstyle',
  1949. 'dollarsuperior',
  1950. 'ampersandsmall',
  1951. 'Acutesmall',
  1952. 'parenleftsuperior',
  1953. 'parenrightsuperior',
  1954. 'twodotenleader',
  1955. 'onedotenleader',
  1956. 'comma',
  1957. 'hyphen',
  1958. 'period',
  1959. 'fraction',
  1960. 'zerooldstyle',
  1961. 'oneoldstyle',
  1962. 'twooldstyle',
  1963. 'threeoldstyle',
  1964. 'fouroldstyle',
  1965. 'fiveoldstyle',
  1966. 'sixoldstyle',
  1967. 'sevenoldstyle',
  1968. 'eightoldstyle',
  1969. 'nineoldstyle',
  1970. 'colon',
  1971. 'semicolon',
  1972. '',
  1973. 'threequartersemdash',
  1974. '',
  1975. 'questionsmall',
  1976. '',
  1977. '',
  1978. '',
  1979. '',
  1980. 'Ethsmall',
  1981. '',
  1982. '',
  1983. 'onequarter',
  1984. 'onehalf',
  1985. 'threequarters',
  1986. 'oneeighth',
  1987. 'threeeighths',
  1988. 'fiveeighths',
  1989. 'seveneighths',
  1990. 'onethird',
  1991. 'twothirds',
  1992. '',
  1993. '',
  1994. '',
  1995. '',
  1996. '',
  1997. '',
  1998. 'ff',
  1999. 'fi',
  2000. 'fl',
  2001. 'ffi',
  2002. 'ffl',
  2003. 'parenleftinferior',
  2004. '',
  2005. 'parenrightinferior',
  2006. 'Circumflexsmall',
  2007. 'hypheninferior',
  2008. 'Gravesmall',
  2009. 'Asmall',
  2010. 'Bsmall',
  2011. 'Csmall',
  2012. 'Dsmall',
  2013. 'Esmall',
  2014. 'Fsmall',
  2015. 'Gsmall',
  2016. 'Hsmall',
  2017. 'Ismall',
  2018. 'Jsmall',
  2019. 'Ksmall',
  2020. 'Lsmall',
  2021. 'Msmall',
  2022. 'Nsmall',
  2023. 'Osmall',
  2024. 'Psmall',
  2025. 'Qsmall',
  2026. 'Rsmall',
  2027. 'Ssmall',
  2028. 'Tsmall',
  2029. 'Usmall',
  2030. 'Vsmall',
  2031. 'Wsmall',
  2032. 'Xsmall',
  2033. 'Ysmall',
  2034. 'Zsmall',
  2035. 'colonmonetary',
  2036. 'onefitted',
  2037. 'rupiah',
  2038. 'Tildesmall',
  2039. '',
  2040. '',
  2041. 'asuperior',
  2042. 'centsuperior',
  2043. '',
  2044. '',
  2045. '',
  2046. '',
  2047. 'Aacutesmall',
  2048. 'Agravesmall',
  2049. 'Acircumflexsmall',
  2050. 'Adieresissmall',
  2051. 'Atildesmall',
  2052. 'Aringsmall',
  2053. 'Ccedillasmall',
  2054. 'Eacutesmall',
  2055. 'Egravesmall',
  2056. 'Ecircumflexsmall',
  2057. 'Edieresissmall',
  2058. 'Iacutesmall',
  2059. 'Igravesmall',
  2060. 'Icircumflexsmall',
  2061. 'Idieresissmall',
  2062. 'Ntildesmall',
  2063. 'Oacutesmall',
  2064. 'Ogravesmall',
  2065. 'Ocircumflexsmall',
  2066. 'Odieresissmall',
  2067. 'Otildesmall',
  2068. 'Uacutesmall',
  2069. 'Ugravesmall',
  2070. 'Ucircumflexsmall',
  2071. 'Udieresissmall',
  2072. '',
  2073. 'eightsuperior',
  2074. 'fourinferior',
  2075. 'threeinferior',
  2076. 'sixinferior',
  2077. 'eightinferior',
  2078. 'seveninferior',
  2079. 'Scaronsmall',
  2080. '',
  2081. 'centinferior',
  2082. 'twoinferior',
  2083. '',
  2084. 'Dieresissmall',
  2085. '',
  2086. 'Caronsmall',
  2087. 'osuperior',
  2088. 'fiveinferior',
  2089. '',
  2090. 'commainferior',
  2091. 'periodinferior',
  2092. 'Yacutesmall',
  2093. '',
  2094. 'dollarinferior',
  2095. '',
  2096. 'Thornsmall',
  2097. '',
  2098. 'nineinferior',
  2099. 'zeroinferior',
  2100. 'Zcaronsmall',
  2101. 'AEsmall',
  2102. 'Oslashsmall',
  2103. 'questiondownsmall',
  2104. 'oneinferior',
  2105. 'Lslashsmall',
  2106. '',
  2107. '',
  2108. '',
  2109. '',
  2110. '',
  2111. '',
  2112. 'Cedillasmall',
  2113. '',
  2114. '',
  2115. '',
  2116. '',
  2117. '',
  2118. 'OEsmall',
  2119. 'figuredash',
  2120. 'hyphensuperior',
  2121. '',
  2122. '',
  2123. '',
  2124. '',
  2125. 'exclamdownsmall',
  2126. '',
  2127. 'Ydieresissmall',
  2128. '',
  2129. 'onesuperior',
  2130. 'twosuperior',
  2131. 'threesuperior',
  2132. 'foursuperior',
  2133. 'fivesuperior',
  2134. 'sixsuperior',
  2135. 'sevensuperior',
  2136. 'ninesuperior',
  2137. 'zerosuperior',
  2138. '',
  2139. 'esuperior',
  2140. 'rsuperior',
  2141. 'tsuperior',
  2142. '',
  2143. '',
  2144. 'isuperior',
  2145. 'ssuperior',
  2146. 'dsuperior',
  2147. '',
  2148. '',
  2149. '',
  2150. '',
  2151. '',
  2152. 'lsuperior',
  2153. 'Ogoneksmall',
  2154. 'Brevesmall',
  2155. 'Macronsmall',
  2156. 'bsuperior',
  2157. 'nsuperior',
  2158. 'msuperior',
  2159. 'commasuperior',
  2160. 'periodsuperior',
  2161. 'Dotaccentsmall',
  2162. 'Ringsmall'
  2163. ];
  2164. var MacRomanEncoding = [
  2165. '',
  2166. '',
  2167. '',
  2168. '',
  2169. '',
  2170. '',
  2171. '',
  2172. '',
  2173. '',
  2174. '',
  2175. '',
  2176. '',
  2177. '',
  2178. '',
  2179. '',
  2180. '',
  2181. '',
  2182. '',
  2183. '',
  2184. '',
  2185. '',
  2186. '',
  2187. '',
  2188. '',
  2189. '',
  2190. '',
  2191. '',
  2192. '',
  2193. '',
  2194. '',
  2195. '',
  2196. '',
  2197. 'space',
  2198. 'exclam',
  2199. 'quotedbl',
  2200. 'numbersign',
  2201. 'dollar',
  2202. 'percent',
  2203. 'ampersand',
  2204. 'quotesingle',
  2205. 'parenleft',
  2206. 'parenright',
  2207. 'asterisk',
  2208. 'plus',
  2209. 'comma',
  2210. 'hyphen',
  2211. 'period',
  2212. 'slash',
  2213. 'zero',
  2214. 'one',
  2215. 'two',
  2216. 'three',
  2217. 'four',
  2218. 'five',
  2219. 'six',
  2220. 'seven',
  2221. 'eight',
  2222. 'nine',
  2223. 'colon',
  2224. 'semicolon',
  2225. 'less',
  2226. 'equal',
  2227. 'greater',
  2228. 'question',
  2229. 'at',
  2230. 'A',
  2231. 'B',
  2232. 'C',
  2233. 'D',
  2234. 'E',
  2235. 'F',
  2236. 'G',
  2237. 'H',
  2238. 'I',
  2239. 'J',
  2240. 'K',
  2241. 'L',
  2242. 'M',
  2243. 'N',
  2244. 'O',
  2245. 'P',
  2246. 'Q',
  2247. 'R',
  2248. 'S',
  2249. 'T',
  2250. 'U',
  2251. 'V',
  2252. 'W',
  2253. 'X',
  2254. 'Y',
  2255. 'Z',
  2256. 'bracketleft',
  2257. 'backslash',
  2258. 'bracketright',
  2259. 'asciicircum',
  2260. 'underscore',
  2261. 'grave',
  2262. 'a',
  2263. 'b',
  2264. 'c',
  2265. 'd',
  2266. 'e',
  2267. 'f',
  2268. 'g',
  2269. 'h',
  2270. 'i',
  2271. 'j',
  2272. 'k',
  2273. 'l',
  2274. 'm',
  2275. 'n',
  2276. 'o',
  2277. 'p',
  2278. 'q',
  2279. 'r',
  2280. 's',
  2281. 't',
  2282. 'u',
  2283. 'v',
  2284. 'w',
  2285. 'x',
  2286. 'y',
  2287. 'z',
  2288. 'braceleft',
  2289. 'bar',
  2290. 'braceright',
  2291. 'asciitilde',
  2292. '',
  2293. 'Adieresis',
  2294. 'Aring',
  2295. 'Ccedilla',
  2296. 'Eacute',
  2297. 'Ntilde',
  2298. 'Odieresis',
  2299. 'Udieresis',
  2300. 'aacute',
  2301. 'agrave',
  2302. 'acircumflex',
  2303. 'adieresis',
  2304. 'atilde',
  2305. 'aring',
  2306. 'ccedilla',
  2307. 'eacute',
  2308. 'egrave',
  2309. 'ecircumflex',
  2310. 'edieresis',
  2311. 'iacute',
  2312. 'igrave',
  2313. 'icircumflex',
  2314. 'idieresis',
  2315. 'ntilde',
  2316. 'oacute',
  2317. 'ograve',
  2318. 'ocircumflex',
  2319. 'odieresis',
  2320. 'otilde',
  2321. 'uacute',
  2322. 'ugrave',
  2323. 'ucircumflex',
  2324. 'udieresis',
  2325. 'dagger',
  2326. 'degree',
  2327. 'cent',
  2328. 'sterling',
  2329. 'section',
  2330. 'bullet',
  2331. 'paragraph',
  2332. 'germandbls',
  2333. 'registered',
  2334. 'copyright',
  2335. 'trademark',
  2336. 'acute',
  2337. 'dieresis',
  2338. 'notequal',
  2339. 'AE',
  2340. 'Oslash',
  2341. 'infinity',
  2342. 'plusminus',
  2343. 'lessequal',
  2344. 'greaterequal',
  2345. 'yen',
  2346. 'mu',
  2347. 'partialdiff',
  2348. 'summation',
  2349. 'product',
  2350. 'pi',
  2351. 'integral',
  2352. 'ordfeminine',
  2353. 'ordmasculine',
  2354. 'Omega',
  2355. 'ae',
  2356. 'oslash',
  2357. 'questiondown',
  2358. 'exclamdown',
  2359. 'logicalnot',
  2360. 'radical',
  2361. 'florin',
  2362. 'approxequal',
  2363. 'Delta',
  2364. 'guillemotleft',
  2365. 'guillemotright',
  2366. 'ellipsis',
  2367. 'space',
  2368. 'Agrave',
  2369. 'Atilde',
  2370. 'Otilde',
  2371. 'OE',
  2372. 'oe',
  2373. 'endash',
  2374. 'emdash',
  2375. 'quotedblleft',
  2376. 'quotedblright',
  2377. 'quoteleft',
  2378. 'quoteright',
  2379. 'divide',
  2380. 'lozenge',
  2381. 'ydieresis',
  2382. 'Ydieresis',
  2383. 'fraction',
  2384. 'currency',
  2385. 'guilsinglleft',
  2386. 'guilsinglright',
  2387. 'fi',
  2388. 'fl',
  2389. 'daggerdbl',
  2390. 'periodcentered',
  2391. 'quotesinglbase',
  2392. 'quotedblbase',
  2393. 'perthousand',
  2394. 'Acircumflex',
  2395. 'Ecircumflex',
  2396. 'Aacute',
  2397. 'Edieresis',
  2398. 'Egrave',
  2399. 'Iacute',
  2400. 'Icircumflex',
  2401. 'Idieresis',
  2402. 'Igrave',
  2403. 'Oacute',
  2404. 'Ocircumflex',
  2405. 'apple',
  2406. 'Ograve',
  2407. 'Uacute',
  2408. 'Ucircumflex',
  2409. 'Ugrave',
  2410. 'dotlessi',
  2411. 'circumflex',
  2412. 'tilde',
  2413. 'macron',
  2414. 'breve',
  2415. 'dotaccent',
  2416. 'ring',
  2417. 'cedilla',
  2418. 'hungarumlaut',
  2419. 'ogonek',
  2420. 'caron'
  2421. ];
  2422. var StandardEncoding = [
  2423. '',
  2424. '',
  2425. '',
  2426. '',
  2427. '',
  2428. '',
  2429. '',
  2430. '',
  2431. '',
  2432. '',
  2433. '',
  2434. '',
  2435. '',
  2436. '',
  2437. '',
  2438. '',
  2439. '',
  2440. '',
  2441. '',
  2442. '',
  2443. '',
  2444. '',
  2445. '',
  2446. '',
  2447. '',
  2448. '',
  2449. '',
  2450. '',
  2451. '',
  2452. '',
  2453. '',
  2454. '',
  2455. 'space',
  2456. 'exclam',
  2457. 'quotedbl',
  2458. 'numbersign',
  2459. 'dollar',
  2460. 'percent',
  2461. 'ampersand',
  2462. 'quoteright',
  2463. 'parenleft',
  2464. 'parenright',
  2465. 'asterisk',
  2466. 'plus',
  2467. 'comma',
  2468. 'hyphen',
  2469. 'period',
  2470. 'slash',
  2471. 'zero',
  2472. 'one',
  2473. 'two',
  2474. 'three',
  2475. 'four',
  2476. 'five',
  2477. 'six',
  2478. 'seven',
  2479. 'eight',
  2480. 'nine',
  2481. 'colon',
  2482. 'semicolon',
  2483. 'less',
  2484. 'equal',
  2485. 'greater',
  2486. 'question',
  2487. 'at',
  2488. 'A',
  2489. 'B',
  2490. 'C',
  2491. 'D',
  2492. 'E',
  2493. 'F',
  2494. 'G',
  2495. 'H',
  2496. 'I',
  2497. 'J',
  2498. 'K',
  2499. 'L',
  2500. 'M',
  2501. 'N',
  2502. 'O',
  2503. 'P',
  2504. 'Q',
  2505. 'R',
  2506. 'S',
  2507. 'T',
  2508. 'U',
  2509. 'V',
  2510. 'W',
  2511. 'X',
  2512. 'Y',
  2513. 'Z',
  2514. 'bracketleft',
  2515. 'backslash',
  2516. 'bracketright',
  2517. 'asciicircum',
  2518. 'underscore',
  2519. 'quoteleft',
  2520. 'a',
  2521. 'b',
  2522. 'c',
  2523. 'd',
  2524. 'e',
  2525. 'f',
  2526. 'g',
  2527. 'h',
  2528. 'i',
  2529. 'j',
  2530. 'k',
  2531. 'l',
  2532. 'm',
  2533. 'n',
  2534. 'o',
  2535. 'p',
  2536. 'q',
  2537. 'r',
  2538. 's',
  2539. 't',
  2540. 'u',
  2541. 'v',
  2542. 'w',
  2543. 'x',
  2544. 'y',
  2545. 'z',
  2546. 'braceleft',
  2547. 'bar',
  2548. 'braceright',
  2549. 'asciitilde',
  2550. '',
  2551. '',
  2552. '',
  2553. '',
  2554. '',
  2555. '',
  2556. '',
  2557. '',
  2558. '',
  2559. '',
  2560. '',
  2561. '',
  2562. '',
  2563. '',
  2564. '',
  2565. '',
  2566. '',
  2567. '',
  2568. '',
  2569. '',
  2570. '',
  2571. '',
  2572. '',
  2573. '',
  2574. '',
  2575. '',
  2576. '',
  2577. '',
  2578. '',
  2579. '',
  2580. '',
  2581. '',
  2582. '',
  2583. '',
  2584. 'exclamdown',
  2585. 'cent',
  2586. 'sterling',
  2587. 'fraction',
  2588. 'yen',
  2589. 'florin',
  2590. 'section',
  2591. 'currency',
  2592. 'quotesingle',
  2593. 'quotedblleft',
  2594. 'guillemotleft',
  2595. 'guilsinglleft',
  2596. 'guilsinglright',
  2597. 'fi',
  2598. 'fl',
  2599. '',
  2600. 'endash',
  2601. 'dagger',
  2602. 'daggerdbl',
  2603. 'periodcentered',
  2604. '',
  2605. 'paragraph',
  2606. 'bullet',
  2607. 'quotesinglbase',
  2608. 'quotedblbase',
  2609. 'quotedblright',
  2610. 'guillemotright',
  2611. 'ellipsis',
  2612. 'perthousand',
  2613. '',
  2614. 'questiondown',
  2615. '',
  2616. 'grave',
  2617. 'acute',
  2618. 'circumflex',
  2619. 'tilde',
  2620. 'macron',
  2621. 'breve',
  2622. 'dotaccent',
  2623. 'dieresis',
  2624. '',
  2625. 'ring',
  2626. 'cedilla',
  2627. '',
  2628. 'hungarumlaut',
  2629. 'ogonek',
  2630. 'caron',
  2631. 'emdash',
  2632. '',
  2633. '',
  2634. '',
  2635. '',
  2636. '',
  2637. '',
  2638. '',
  2639. '',
  2640. '',
  2641. '',
  2642. '',
  2643. '',
  2644. '',
  2645. '',
  2646. '',
  2647. '',
  2648. 'AE',
  2649. '',
  2650. 'ordfeminine',
  2651. '',
  2652. '',
  2653. '',
  2654. '',
  2655. 'Lslash',
  2656. 'Oslash',
  2657. 'OE',
  2658. 'ordmasculine',
  2659. '',
  2660. '',
  2661. '',
  2662. '',
  2663. '',
  2664. 'ae',
  2665. '',
  2666. '',
  2667. '',
  2668. 'dotlessi',
  2669. '',
  2670. '',
  2671. 'lslash',
  2672. 'oslash',
  2673. 'oe',
  2674. 'germandbls'
  2675. ];
  2676. var WinAnsiEncoding = [
  2677. '',
  2678. '',
  2679. '',
  2680. '',
  2681. '',
  2682. '',
  2683. '',
  2684. '',
  2685. '',
  2686. '',
  2687. '',
  2688. '',
  2689. '',
  2690. '',
  2691. '',
  2692. '',
  2693. '',
  2694. '',
  2695. '',
  2696. '',
  2697. '',
  2698. '',
  2699. '',
  2700. '',
  2701. '',
  2702. '',
  2703. '',
  2704. '',
  2705. '',
  2706. '',
  2707. '',
  2708. '',
  2709. 'space',
  2710. 'exclam',
  2711. 'quotedbl',
  2712. 'numbersign',
  2713. 'dollar',
  2714. 'percent',
  2715. 'ampersand',
  2716. 'quotesingle',
  2717. 'parenleft',
  2718. 'parenright',
  2719. 'asterisk',
  2720. 'plus',
  2721. 'comma',
  2722. 'hyphen',
  2723. 'period',
  2724. 'slash',
  2725. 'zero',
  2726. 'one',
  2727. 'two',
  2728. 'three',
  2729. 'four',
  2730. 'five',
  2731. 'six',
  2732. 'seven',
  2733. 'eight',
  2734. 'nine',
  2735. 'colon',
  2736. 'semicolon',
  2737. 'less',
  2738. 'equal',
  2739. 'greater',
  2740. 'question',
  2741. 'at',
  2742. 'A',
  2743. 'B',
  2744. 'C',
  2745. 'D',
  2746. 'E',
  2747. 'F',
  2748. 'G',
  2749. 'H',
  2750. 'I',
  2751. 'J',
  2752. 'K',
  2753. 'L',
  2754. 'M',
  2755. 'N',
  2756. 'O',
  2757. 'P',
  2758. 'Q',
  2759. 'R',
  2760. 'S',
  2761. 'T',
  2762. 'U',
  2763. 'V',
  2764. 'W',
  2765. 'X',
  2766. 'Y',
  2767. 'Z',
  2768. 'bracketleft',
  2769. 'backslash',
  2770. 'bracketright',
  2771. 'asciicircum',
  2772. 'underscore',
  2773. 'grave',
  2774. 'a',
  2775. 'b',
  2776. 'c',
  2777. 'd',
  2778. 'e',
  2779. 'f',
  2780. 'g',
  2781. 'h',
  2782. 'i',
  2783. 'j',
  2784. 'k',
  2785. 'l',
  2786. 'm',
  2787. 'n',
  2788. 'o',
  2789. 'p',
  2790. 'q',
  2791. 'r',
  2792. 's',
  2793. 't',
  2794. 'u',
  2795. 'v',
  2796. 'w',
  2797. 'x',
  2798. 'y',
  2799. 'z',
  2800. 'braceleft',
  2801. 'bar',
  2802. 'braceright',
  2803. 'asciitilde',
  2804. 'bullet',
  2805. 'Euro',
  2806. 'bullet',
  2807. 'quotesinglbase',
  2808. 'florin',
  2809. 'quotedblbase',
  2810. 'ellipsis',
  2811. 'dagger',
  2812. 'daggerdbl',
  2813. 'circumflex',
  2814. 'perthousand',
  2815. 'Scaron',
  2816. 'guilsinglleft',
  2817. 'OE',
  2818. 'bullet',
  2819. 'Zcaron',
  2820. 'bullet',
  2821. 'bullet',
  2822. 'quoteleft',
  2823. 'quoteright',
  2824. 'quotedblleft',
  2825. 'quotedblright',
  2826. 'bullet',
  2827. 'endash',
  2828. 'emdash',
  2829. 'tilde',
  2830. 'trademark',
  2831. 'scaron',
  2832. 'guilsinglright',
  2833. 'oe',
  2834. 'bullet',
  2835. 'zcaron',
  2836. 'Ydieresis',
  2837. 'space',
  2838. 'exclamdown',
  2839. 'cent',
  2840. 'sterling',
  2841. 'currency',
  2842. 'yen',
  2843. 'brokenbar',
  2844. 'section',
  2845. 'dieresis',
  2846. 'copyright',
  2847. 'ordfeminine',
  2848. 'guillemotleft',
  2849. 'logicalnot',
  2850. 'hyphen',
  2851. 'registered',
  2852. 'macron',
  2853. 'degree',
  2854. 'plusminus',
  2855. 'twosuperior',
  2856. 'threesuperior',
  2857. 'acute',
  2858. 'mu',
  2859. 'paragraph',
  2860. 'periodcentered',
  2861. 'cedilla',
  2862. 'onesuperior',
  2863. 'ordmasculine',
  2864. 'guillemotright',
  2865. 'onequarter',
  2866. 'onehalf',
  2867. 'threequarters',
  2868. 'questiondown',
  2869. 'Agrave',
  2870. 'Aacute',
  2871. 'Acircumflex',
  2872. 'Atilde',
  2873. 'Adieresis',
  2874. 'Aring',
  2875. 'AE',
  2876. 'Ccedilla',
  2877. 'Egrave',
  2878. 'Eacute',
  2879. 'Ecircumflex',
  2880. 'Edieresis',
  2881. 'Igrave',
  2882. 'Iacute',
  2883. 'Icircumflex',
  2884. 'Idieresis',
  2885. 'Eth',
  2886. 'Ntilde',
  2887. 'Ograve',
  2888. 'Oacute',
  2889. 'Ocircumflex',
  2890. 'Otilde',
  2891. 'Odieresis',
  2892. 'multiply',
  2893. 'Oslash',
  2894. 'Ugrave',
  2895. 'Uacute',
  2896. 'Ucircumflex',
  2897. 'Udieresis',
  2898. 'Yacute',
  2899. 'Thorn',
  2900. 'germandbls',
  2901. 'agrave',
  2902. 'aacute',
  2903. 'acircumflex',
  2904. 'atilde',
  2905. 'adieresis',
  2906. 'aring',
  2907. 'ae',
  2908. 'ccedilla',
  2909. 'egrave',
  2910. 'eacute',
  2911. 'ecircumflex',
  2912. 'edieresis',
  2913. 'igrave',
  2914. 'iacute',
  2915. 'icircumflex',
  2916. 'idieresis',
  2917. 'eth',
  2918. 'ntilde',
  2919. 'ograve',
  2920. 'oacute',
  2921. 'ocircumflex',
  2922. 'otilde',
  2923. 'odieresis',
  2924. 'divide',
  2925. 'oslash',
  2926. 'ugrave',
  2927. 'uacute',
  2928. 'ucircumflex',
  2929. 'udieresis',
  2930. 'yacute',
  2931. 'thorn',
  2932. 'ydieresis'
  2933. ];
  2934. var SymbolSetEncoding = [
  2935. '',
  2936. '',
  2937. '',
  2938. '',
  2939. '',
  2940. '',
  2941. '',
  2942. '',
  2943. '',
  2944. '',
  2945. '',
  2946. '',
  2947. '',
  2948. '',
  2949. '',
  2950. '',
  2951. '',
  2952. '',
  2953. '',
  2954. '',
  2955. '',
  2956. '',
  2957. '',
  2958. '',
  2959. '',
  2960. '',
  2961. '',
  2962. '',
  2963. '',
  2964. '',
  2965. '',
  2966. '',
  2967. 'space',
  2968. 'exclam',
  2969. 'universal',
  2970. 'numbersign',
  2971. 'existential',
  2972. 'percent',
  2973. 'ampersand',
  2974. 'suchthat',
  2975. 'parenleft',
  2976. 'parenright',
  2977. 'asteriskmath',
  2978. 'plus',
  2979. 'comma',
  2980. 'minus',
  2981. 'period',
  2982. 'slash',
  2983. 'zero',
  2984. 'one',
  2985. 'two',
  2986. 'three',
  2987. 'four',
  2988. 'five',
  2989. 'six',
  2990. 'seven',
  2991. 'eight',
  2992. 'nine',
  2993. 'colon',
  2994. 'semicolon',
  2995. 'less',
  2996. 'equal',
  2997. 'greater',
  2998. 'question',
  2999. 'congruent',
  3000. 'Alpha',
  3001. 'Beta',
  3002. 'Chi',
  3003. 'Delta',
  3004. 'Epsilon',
  3005. 'Phi',
  3006. 'Gamma',
  3007. 'Eta',
  3008. 'Iota',
  3009. 'theta1',
  3010. 'Kappa',
  3011. 'Lambda',
  3012. 'Mu',
  3013. 'Nu',
  3014. 'Omicron',
  3015. 'Pi',
  3016. 'Theta',
  3017. 'Rho',
  3018. 'Sigma',
  3019. 'Tau',
  3020. 'Upsilon',
  3021. 'sigma1',
  3022. 'Omega',
  3023. 'Xi',
  3024. 'Psi',
  3025. 'Zeta',
  3026. 'bracketleft',
  3027. 'therefore',
  3028. 'bracketright',
  3029. 'perpendicular',
  3030. 'underscore',
  3031. 'radicalex',
  3032. 'alpha',
  3033. 'beta',
  3034. 'chi',
  3035. 'delta',
  3036. 'epsilon',
  3037. 'phi',
  3038. 'gamma',
  3039. 'eta',
  3040. 'iota',
  3041. 'phi1',
  3042. 'kappa',
  3043. 'lambda',
  3044. 'mu',
  3045. 'nu',
  3046. 'omicron',
  3047. 'pi',
  3048. 'theta',
  3049. 'rho',
  3050. 'sigma',
  3051. 'tau',
  3052. 'upsilon',
  3053. 'omega1',
  3054. 'omega',
  3055. 'xi',
  3056. 'psi',
  3057. 'zeta',
  3058. 'braceleft',
  3059. 'bar',
  3060. 'braceright',
  3061. 'similar',
  3062. '',
  3063. '',
  3064. '',
  3065. '',
  3066. '',
  3067. '',
  3068. '',
  3069. '',
  3070. '',
  3071. '',
  3072. '',
  3073. '',
  3074. '',
  3075. '',
  3076. '',
  3077. '',
  3078. '',
  3079. '',
  3080. '',
  3081. '',
  3082. '',
  3083. '',
  3084. '',
  3085. '',
  3086. '',
  3087. '',
  3088. '',
  3089. '',
  3090. '',
  3091. '',
  3092. '',
  3093. '',
  3094. '',
  3095. 'Euro',
  3096. 'Upsilon1',
  3097. 'minute',
  3098. 'lessequal',
  3099. 'fraction',
  3100. 'infinity',
  3101. 'florin',
  3102. 'club',
  3103. 'diamond',
  3104. 'heart',
  3105. 'spade',
  3106. 'arrowboth',
  3107. 'arrowleft',
  3108. 'arrowup',
  3109. 'arrowright',
  3110. 'arrowdown',
  3111. 'degree',
  3112. 'plusminus',
  3113. 'second',
  3114. 'greaterequal',
  3115. 'multiply',
  3116. 'proportional',
  3117. 'partialdiff',
  3118. 'bullet',
  3119. 'divide',
  3120. 'notequal',
  3121. 'equivalence',
  3122. 'approxequal',
  3123. 'ellipsis',
  3124. 'arrowvertex',
  3125. 'arrowhorizex',
  3126. 'carriagereturn',
  3127. 'aleph',
  3128. 'Ifraktur',
  3129. 'Rfraktur',
  3130. 'weierstrass',
  3131. 'circlemultiply',
  3132. 'circleplus',
  3133. 'emptyset',
  3134. 'intersection',
  3135. 'union',
  3136. 'propersuperset',
  3137. 'reflexsuperset',
  3138. 'notsubset',
  3139. 'propersubset',
  3140. 'reflexsubset',
  3141. 'element',
  3142. 'notelement',
  3143. 'angle',
  3144. 'gradient',
  3145. 'registerserif',
  3146. 'copyrightserif',
  3147. 'trademarkserif',
  3148. 'product',
  3149. 'radical',
  3150. 'dotmath',
  3151. 'logicalnot',
  3152. 'logicaland',
  3153. 'logicalor',
  3154. 'arrowdblboth',
  3155. 'arrowdblleft',
  3156. 'arrowdblup',
  3157. 'arrowdblright',
  3158. 'arrowdbldown',
  3159. 'lozenge',
  3160. 'angleleft',
  3161. 'registersans',
  3162. 'copyrightsans',
  3163. 'trademarksans',
  3164. 'summation',
  3165. 'parenlefttp',
  3166. 'parenleftex',
  3167. 'parenleftbt',
  3168. 'bracketlefttp',
  3169. 'bracketleftex',
  3170. 'bracketleftbt',
  3171. 'bracelefttp',
  3172. 'braceleftmid',
  3173. 'braceleftbt',
  3174. 'braceex',
  3175. '',
  3176. 'angleright',
  3177. 'integral',
  3178. 'integraltp',
  3179. 'integralex',
  3180. 'integralbt',
  3181. 'parenrighttp',
  3182. 'parenrightex',
  3183. 'parenrightbt',
  3184. 'bracketrighttp',
  3185. 'bracketrightex',
  3186. 'bracketrightbt',
  3187. 'bracerighttp',
  3188. 'bracerightmid',
  3189. 'bracerightbt'
  3190. ];
  3191. var ZapfDingbatsEncoding = [
  3192. '',
  3193. '',
  3194. '',
  3195. '',
  3196. '',
  3197. '',
  3198. '',
  3199. '',
  3200. '',
  3201. '',
  3202. '',
  3203. '',
  3204. '',
  3205. '',
  3206. '',
  3207. '',
  3208. '',
  3209. '',
  3210. '',
  3211. '',
  3212. '',
  3213. '',
  3214. '',
  3215. '',
  3216. '',
  3217. '',
  3218. '',
  3219. '',
  3220. '',
  3221. '',
  3222. '',
  3223. '',
  3224. 'space',
  3225. 'a1',
  3226. 'a2',
  3227. 'a202',
  3228. 'a3',
  3229. 'a4',
  3230. 'a5',
  3231. 'a119',
  3232. 'a118',
  3233. 'a117',
  3234. 'a11',
  3235. 'a12',
  3236. 'a13',
  3237. 'a14',
  3238. 'a15',
  3239. 'a16',
  3240. 'a105',
  3241. 'a17',
  3242. 'a18',
  3243. 'a19',
  3244. 'a20',
  3245. 'a21',
  3246. 'a22',
  3247. 'a23',
  3248. 'a24',
  3249. 'a25',
  3250. 'a26',
  3251. 'a27',
  3252. 'a28',
  3253. 'a6',
  3254. 'a7',
  3255. 'a8',
  3256. 'a9',
  3257. 'a10',
  3258. 'a29',
  3259. 'a30',
  3260. 'a31',
  3261. 'a32',
  3262. 'a33',
  3263. 'a34',
  3264. 'a35',
  3265. 'a36',
  3266. 'a37',
  3267. 'a38',
  3268. 'a39',
  3269. 'a40',
  3270. 'a41',
  3271. 'a42',
  3272. 'a43',
  3273. 'a44',
  3274. 'a45',
  3275. 'a46',
  3276. 'a47',
  3277. 'a48',
  3278. 'a49',
  3279. 'a50',
  3280. 'a51',
  3281. 'a52',
  3282. 'a53',
  3283. 'a54',
  3284. 'a55',
  3285. 'a56',
  3286. 'a57',
  3287. 'a58',
  3288. 'a59',
  3289. 'a60',
  3290. 'a61',
  3291. 'a62',
  3292. 'a63',
  3293. 'a64',
  3294. 'a65',
  3295. 'a66',
  3296. 'a67',
  3297. 'a68',
  3298. 'a69',
  3299. 'a70',
  3300. 'a71',
  3301. 'a72',
  3302. 'a73',
  3303. 'a74',
  3304. 'a203',
  3305. 'a75',
  3306. 'a204',
  3307. 'a76',
  3308. 'a77',
  3309. 'a78',
  3310. 'a79',
  3311. 'a81',
  3312. 'a82',
  3313. 'a83',
  3314. 'a84',
  3315. 'a97',
  3316. 'a98',
  3317. 'a99',
  3318. 'a100',
  3319. '',
  3320. 'a89',
  3321. 'a90',
  3322. 'a93',
  3323. 'a94',
  3324. 'a91',
  3325. 'a92',
  3326. 'a205',
  3327. 'a85',
  3328. 'a206',
  3329. 'a86',
  3330. 'a87',
  3331. 'a88',
  3332. 'a95',
  3333. 'a96',
  3334. '',
  3335. '',
  3336. '',
  3337. '',
  3338. '',
  3339. '',
  3340. '',
  3341. '',
  3342. '',
  3343. '',
  3344. '',
  3345. '',
  3346. '',
  3347. '',
  3348. '',
  3349. '',
  3350. '',
  3351. '',
  3352. '',
  3353. 'a101',
  3354. 'a102',
  3355. 'a103',
  3356. 'a104',
  3357. 'a106',
  3358. 'a107',
  3359. 'a108',
  3360. 'a112',
  3361. 'a111',
  3362. 'a110',
  3363. 'a109',
  3364. 'a120',
  3365. 'a121',
  3366. 'a122',
  3367. 'a123',
  3368. 'a124',
  3369. 'a125',
  3370. 'a126',
  3371. 'a127',
  3372. 'a128',
  3373. 'a129',
  3374. 'a130',
  3375. 'a131',
  3376. 'a132',
  3377. 'a133',
  3378. 'a134',
  3379. 'a135',
  3380. 'a136',
  3381. 'a137',
  3382. 'a138',
  3383. 'a139',
  3384. 'a140',
  3385. 'a141',
  3386. 'a142',
  3387. 'a143',
  3388. 'a144',
  3389. 'a145',
  3390. 'a146',
  3391. 'a147',
  3392. 'a148',
  3393. 'a149',
  3394. 'a150',
  3395. 'a151',
  3396. 'a152',
  3397. 'a153',
  3398. 'a154',
  3399. 'a155',
  3400. 'a156',
  3401. 'a157',
  3402. 'a158',
  3403. 'a159',
  3404. 'a160',
  3405. 'a161',
  3406. 'a163',
  3407. 'a164',
  3408. 'a196',
  3409. 'a165',
  3410. 'a192',
  3411. 'a166',
  3412. 'a167',
  3413. 'a168',
  3414. 'a169',
  3415. 'a170',
  3416. 'a171',
  3417. 'a172',
  3418. 'a173',
  3419. 'a162',
  3420. 'a174',
  3421. 'a175',
  3422. 'a176',
  3423. 'a177',
  3424. 'a178',
  3425. 'a179',
  3426. 'a193',
  3427. 'a180',
  3428. 'a199',
  3429. 'a181',
  3430. 'a200',
  3431. 'a182',
  3432. '',
  3433. 'a201',
  3434. 'a183',
  3435. 'a184',
  3436. 'a197',
  3437. 'a185',
  3438. 'a194',
  3439. 'a198',
  3440. 'a186',
  3441. 'a195',
  3442. 'a187',
  3443. 'a188',
  3444. 'a189',
  3445. 'a190',
  3446. 'a191'
  3447. ];
  3448. function getEncoding(encodingName) {
  3449. switch (encodingName) {
  3450. case 'WinAnsiEncoding':
  3451. return WinAnsiEncoding;
  3452. case 'StandardEncoding':
  3453. return StandardEncoding;
  3454. case 'MacRomanEncoding':
  3455. return MacRomanEncoding;
  3456. case 'SymbolSetEncoding':
  3457. return SymbolSetEncoding;
  3458. case 'ZapfDingbatsEncoding':
  3459. return ZapfDingbatsEncoding;
  3460. case 'ExpertEncoding':
  3461. return ExpertEncoding;
  3462. case 'MacExpertEncoding':
  3463. return MacExpertEncoding;
  3464. default:
  3465. return null;
  3466. }
  3467. }
  3468. exports.WinAnsiEncoding = WinAnsiEncoding;
  3469. exports.StandardEncoding = StandardEncoding;
  3470. exports.MacRomanEncoding = MacRomanEncoding;
  3471. exports.SymbolSetEncoding = SymbolSetEncoding;
  3472. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  3473. exports.ExpertEncoding = ExpertEncoding;
  3474. exports.getEncoding = getEncoding;
  3475. }));
  3476. (function (root, factory) {
  3477. factory(root.pdfjsSharedUtil = {});
  3478. }(this, function (exports) {
  3479. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  3480. var FONT_IDENTITY_MATRIX = [
  3481. 0.001,
  3482. 0,
  3483. 0,
  3484. 0.001,
  3485. 0,
  3486. 0
  3487. ];
  3488. var TextRenderingMode = {
  3489. FILL: 0,
  3490. STROKE: 1,
  3491. FILL_STROKE: 2,
  3492. INVISIBLE: 3,
  3493. FILL_ADD_TO_PATH: 4,
  3494. STROKE_ADD_TO_PATH: 5,
  3495. FILL_STROKE_ADD_TO_PATH: 6,
  3496. ADD_TO_PATH: 7,
  3497. FILL_STROKE_MASK: 3,
  3498. ADD_TO_PATH_FLAG: 4
  3499. };
  3500. var ImageKind = {
  3501. GRAYSCALE_1BPP: 1,
  3502. RGB_24BPP: 2,
  3503. RGBA_32BPP: 3
  3504. };
  3505. var AnnotationType = {
  3506. TEXT: 1,
  3507. LINK: 2,
  3508. FREETEXT: 3,
  3509. LINE: 4,
  3510. SQUARE: 5,
  3511. CIRCLE: 6,
  3512. POLYGON: 7,
  3513. POLYLINE: 8,
  3514. HIGHLIGHT: 9,
  3515. UNDERLINE: 10,
  3516. SQUIGGLY: 11,
  3517. STRIKEOUT: 12,
  3518. STAMP: 13,
  3519. CARET: 14,
  3520. INK: 15,
  3521. POPUP: 16,
  3522. FILEATTACHMENT: 17,
  3523. SOUND: 18,
  3524. MOVIE: 19,
  3525. WIDGET: 20,
  3526. SCREEN: 21,
  3527. PRINTERMARK: 22,
  3528. TRAPNET: 23,
  3529. WATERMARK: 24,
  3530. THREED: 25,
  3531. REDACT: 26
  3532. };
  3533. var AnnotationFlag = {
  3534. INVISIBLE: 0x01,
  3535. HIDDEN: 0x02,
  3536. PRINT: 0x04,
  3537. NOZOOM: 0x08,
  3538. NOROTATE: 0x10,
  3539. NOVIEW: 0x20,
  3540. READONLY: 0x40,
  3541. LOCKED: 0x80,
  3542. TOGGLENOVIEW: 0x100,
  3543. LOCKEDCONTENTS: 0x200
  3544. };
  3545. var AnnotationFieldFlag = {
  3546. READONLY: 0x0000001,
  3547. REQUIRED: 0x0000002,
  3548. NOEXPORT: 0x0000004,
  3549. MULTILINE: 0x0001000,
  3550. PASSWORD: 0x0002000,
  3551. NOTOGGLETOOFF: 0x0004000,
  3552. RADIO: 0x0008000,
  3553. PUSHBUTTON: 0x0010000,
  3554. COMBO: 0x0020000,
  3555. EDIT: 0x0040000,
  3556. SORT: 0x0080000,
  3557. FILESELECT: 0x0100000,
  3558. MULTISELECT: 0x0200000,
  3559. DONOTSPELLCHECK: 0x0400000,
  3560. DONOTSCROLL: 0x0800000,
  3561. COMB: 0x1000000,
  3562. RICHTEXT: 0x2000000,
  3563. RADIOSINUNISON: 0x2000000,
  3564. COMMITONSELCHANGE: 0x4000000
  3565. };
  3566. var AnnotationBorderStyleType = {
  3567. SOLID: 1,
  3568. DASHED: 2,
  3569. BEVELED: 3,
  3570. INSET: 4,
  3571. UNDERLINE: 5
  3572. };
  3573. var StreamType = {
  3574. UNKNOWN: 0,
  3575. FLATE: 1,
  3576. LZW: 2,
  3577. DCT: 3,
  3578. JPX: 4,
  3579. JBIG: 5,
  3580. A85: 6,
  3581. AHX: 7,
  3582. CCF: 8,
  3583. RL: 9
  3584. };
  3585. var FontType = {
  3586. UNKNOWN: 0,
  3587. TYPE1: 1,
  3588. TYPE1C: 2,
  3589. CIDFONTTYPE0: 3,
  3590. CIDFONTTYPE0C: 4,
  3591. TRUETYPE: 5,
  3592. CIDFONTTYPE2: 6,
  3593. TYPE3: 7,
  3594. OPENTYPE: 8,
  3595. TYPE0: 9,
  3596. MMTYPE1: 10
  3597. };
  3598. var VERBOSITY_LEVELS = {
  3599. errors: 0,
  3600. warnings: 1,
  3601. infos: 5
  3602. };
  3603. var OPS = {
  3604. dependency: 1,
  3605. setLineWidth: 2,
  3606. setLineCap: 3,
  3607. setLineJoin: 4,
  3608. setMiterLimit: 5,
  3609. setDash: 6,
  3610. setRenderingIntent: 7,
  3611. setFlatness: 8,
  3612. setGState: 9,
  3613. save: 10,
  3614. restore: 11,
  3615. transform: 12,
  3616. moveTo: 13,
  3617. lineTo: 14,
  3618. curveTo: 15,
  3619. curveTo2: 16,
  3620. curveTo3: 17,
  3621. closePath: 18,
  3622. rectangle: 19,
  3623. stroke: 20,
  3624. closeStroke: 21,
  3625. fill: 22,
  3626. eoFill: 23,
  3627. fillStroke: 24,
  3628. eoFillStroke: 25,
  3629. closeFillStroke: 26,
  3630. closeEOFillStroke: 27,
  3631. endPath: 28,
  3632. clip: 29,
  3633. eoClip: 30,
  3634. beginText: 31,
  3635. endText: 32,
  3636. setCharSpacing: 33,
  3637. setWordSpacing: 34,
  3638. setHScale: 35,
  3639. setLeading: 36,
  3640. setFont: 37,
  3641. setTextRenderingMode: 38,
  3642. setTextRise: 39,
  3643. moveText: 40,
  3644. setLeadingMoveText: 41,
  3645. setTextMatrix: 42,
  3646. nextLine: 43,
  3647. showText: 44,
  3648. showSpacedText: 45,
  3649. nextLineShowText: 46,
  3650. nextLineSetSpacingShowText: 47,
  3651. setCharWidth: 48,
  3652. setCharWidthAndBounds: 49,
  3653. setStrokeColorSpace: 50,
  3654. setFillColorSpace: 51,
  3655. setStrokeColor: 52,
  3656. setStrokeColorN: 53,
  3657. setFillColor: 54,
  3658. setFillColorN: 55,
  3659. setStrokeGray: 56,
  3660. setFillGray: 57,
  3661. setStrokeRGBColor: 58,
  3662. setFillRGBColor: 59,
  3663. setStrokeCMYKColor: 60,
  3664. setFillCMYKColor: 61,
  3665. shadingFill: 62,
  3666. beginInlineImage: 63,
  3667. beginImageData: 64,
  3668. endInlineImage: 65,
  3669. paintXObject: 66,
  3670. markPoint: 67,
  3671. markPointProps: 68,
  3672. beginMarkedContent: 69,
  3673. beginMarkedContentProps: 70,
  3674. endMarkedContent: 71,
  3675. beginCompat: 72,
  3676. endCompat: 73,
  3677. paintFormXObjectBegin: 74,
  3678. paintFormXObjectEnd: 75,
  3679. beginGroup: 76,
  3680. endGroup: 77,
  3681. beginAnnotations: 78,
  3682. endAnnotations: 79,
  3683. beginAnnotation: 80,
  3684. endAnnotation: 81,
  3685. paintJpegXObject: 82,
  3686. paintImageMaskXObject: 83,
  3687. paintImageMaskXObjectGroup: 84,
  3688. paintImageXObject: 85,
  3689. paintInlineImageXObject: 86,
  3690. paintInlineImageXObjectGroup: 87,
  3691. paintImageXObjectRepeat: 88,
  3692. paintImageMaskXObjectRepeat: 89,
  3693. paintSolidColorImageMask: 90,
  3694. constructPath: 91
  3695. };
  3696. var verbosity = VERBOSITY_LEVELS.warnings;
  3697. function setVerbosityLevel(level) {
  3698. verbosity = level;
  3699. }
  3700. function getVerbosityLevel() {
  3701. return verbosity;
  3702. }
  3703. function info(msg) {
  3704. if (verbosity >= VERBOSITY_LEVELS.infos) {
  3705. console.log('Info: ' + msg);
  3706. }
  3707. }
  3708. function warn(msg) {
  3709. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  3710. console.log('Warning: ' + msg);
  3711. }
  3712. }
  3713. function deprecated(details) {
  3714. console.log('Deprecated API usage: ' + details);
  3715. }
  3716. function error(msg) {
  3717. if (verbosity >= VERBOSITY_LEVELS.errors) {
  3718. console.log('Error: ' + msg);
  3719. console.log(backtrace());
  3720. }
  3721. throw new Error(msg);
  3722. }
  3723. function backtrace() {
  3724. try {
  3725. throw new Error();
  3726. } catch (e) {
  3727. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  3728. }
  3729. }
  3730. function assert(cond, msg) {
  3731. if (!cond) {
  3732. error(msg);
  3733. }
  3734. }
  3735. var UNSUPPORTED_FEATURES = {
  3736. unknown: 'unknown',
  3737. forms: 'forms',
  3738. javaScript: 'javaScript',
  3739. smask: 'smask',
  3740. shadingPattern: 'shadingPattern',
  3741. font: 'font'
  3742. };
  3743. function isSameOrigin(baseUrl, otherUrl) {
  3744. try {
  3745. var base = new URL(baseUrl);
  3746. if (!base.origin || base.origin === 'null') {
  3747. return false;
  3748. }
  3749. } catch (e) {
  3750. return false;
  3751. }
  3752. var other = new URL(otherUrl, base);
  3753. return base.origin === other.origin;
  3754. }
  3755. function isValidProtocol(url) {
  3756. if (!url) {
  3757. return false;
  3758. }
  3759. switch (url.protocol) {
  3760. case 'http:':
  3761. case 'https:':
  3762. case 'ftp:':
  3763. case 'mailto:':
  3764. case 'tel:':
  3765. return true;
  3766. default:
  3767. return false;
  3768. }
  3769. }
  3770. function createValidAbsoluteUrl(url, baseUrl) {
  3771. if (!url) {
  3772. return null;
  3773. }
  3774. try {
  3775. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3776. if (isValidProtocol(absoluteUrl)) {
  3777. return absoluteUrl;
  3778. }
  3779. } catch (ex) {
  3780. }
  3781. return null;
  3782. }
  3783. function shadow(obj, prop, value) {
  3784. Object.defineProperty(obj, prop, {
  3785. value: value,
  3786. enumerable: true,
  3787. configurable: true,
  3788. writable: false
  3789. });
  3790. return value;
  3791. }
  3792. function getLookupTableFactory(initializer) {
  3793. var lookup;
  3794. return function () {
  3795. if (initializer) {
  3796. lookup = Object.create(null);
  3797. initializer(lookup);
  3798. initializer = null;
  3799. }
  3800. return lookup;
  3801. };
  3802. }
  3803. var PasswordResponses = {
  3804. NEED_PASSWORD: 1,
  3805. INCORRECT_PASSWORD: 2
  3806. };
  3807. var PasswordException = function PasswordExceptionClosure() {
  3808. function PasswordException(msg, code) {
  3809. this.name = 'PasswordException';
  3810. this.message = msg;
  3811. this.code = code;
  3812. }
  3813. PasswordException.prototype = new Error();
  3814. PasswordException.constructor = PasswordException;
  3815. return PasswordException;
  3816. }();
  3817. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  3818. function UnknownErrorException(msg, details) {
  3819. this.name = 'UnknownErrorException';
  3820. this.message = msg;
  3821. this.details = details;
  3822. }
  3823. UnknownErrorException.prototype = new Error();
  3824. UnknownErrorException.constructor = UnknownErrorException;
  3825. return UnknownErrorException;
  3826. }();
  3827. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  3828. function InvalidPDFException(msg) {
  3829. this.name = 'InvalidPDFException';
  3830. this.message = msg;
  3831. }
  3832. InvalidPDFException.prototype = new Error();
  3833. InvalidPDFException.constructor = InvalidPDFException;
  3834. return InvalidPDFException;
  3835. }();
  3836. var MissingPDFException = function MissingPDFExceptionClosure() {
  3837. function MissingPDFException(msg) {
  3838. this.name = 'MissingPDFException';
  3839. this.message = msg;
  3840. }
  3841. MissingPDFException.prototype = new Error();
  3842. MissingPDFException.constructor = MissingPDFException;
  3843. return MissingPDFException;
  3844. }();
  3845. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  3846. function UnexpectedResponseException(msg, status) {
  3847. this.name = 'UnexpectedResponseException';
  3848. this.message = msg;
  3849. this.status = status;
  3850. }
  3851. UnexpectedResponseException.prototype = new Error();
  3852. UnexpectedResponseException.constructor = UnexpectedResponseException;
  3853. return UnexpectedResponseException;
  3854. }();
  3855. var NotImplementedException = function NotImplementedExceptionClosure() {
  3856. function NotImplementedException(msg) {
  3857. this.message = msg;
  3858. }
  3859. NotImplementedException.prototype = new Error();
  3860. NotImplementedException.prototype.name = 'NotImplementedException';
  3861. NotImplementedException.constructor = NotImplementedException;
  3862. return NotImplementedException;
  3863. }();
  3864. var MissingDataException = function MissingDataExceptionClosure() {
  3865. function MissingDataException(begin, end) {
  3866. this.begin = begin;
  3867. this.end = end;
  3868. this.message = 'Missing data [' + begin + ', ' + end + ')';
  3869. }
  3870. MissingDataException.prototype = new Error();
  3871. MissingDataException.prototype.name = 'MissingDataException';
  3872. MissingDataException.constructor = MissingDataException;
  3873. return MissingDataException;
  3874. }();
  3875. var XRefParseException = function XRefParseExceptionClosure() {
  3876. function XRefParseException(msg) {
  3877. this.message = msg;
  3878. }
  3879. XRefParseException.prototype = new Error();
  3880. XRefParseException.prototype.name = 'XRefParseException';
  3881. XRefParseException.constructor = XRefParseException;
  3882. return XRefParseException;
  3883. }();
  3884. var NullCharactersRegExp = /\x00/g;
  3885. function removeNullCharacters(str) {
  3886. if (typeof str !== 'string') {
  3887. warn('The argument for removeNullCharacters must be a string.');
  3888. return str;
  3889. }
  3890. return str.replace(NullCharactersRegExp, '');
  3891. }
  3892. function bytesToString(bytes) {
  3893. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  3894. var length = bytes.length;
  3895. var MAX_ARGUMENT_COUNT = 8192;
  3896. if (length < MAX_ARGUMENT_COUNT) {
  3897. return String.fromCharCode.apply(null, bytes);
  3898. }
  3899. var strBuf = [];
  3900. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3901. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3902. var chunk = bytes.subarray(i, chunkEnd);
  3903. strBuf.push(String.fromCharCode.apply(null, chunk));
  3904. }
  3905. return strBuf.join('');
  3906. }
  3907. function stringToBytes(str) {
  3908. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  3909. var length = str.length;
  3910. var bytes = new Uint8Array(length);
  3911. for (var i = 0; i < length; ++i) {
  3912. bytes[i] = str.charCodeAt(i) & 0xFF;
  3913. }
  3914. return bytes;
  3915. }
  3916. function arrayByteLength(arr) {
  3917. if (arr.length !== undefined) {
  3918. return arr.length;
  3919. }
  3920. assert(arr.byteLength !== undefined);
  3921. return arr.byteLength;
  3922. }
  3923. function arraysToBytes(arr) {
  3924. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  3925. return arr[0];
  3926. }
  3927. var resultLength = 0;
  3928. var i, ii = arr.length;
  3929. var item, itemLength;
  3930. for (i = 0; i < ii; i++) {
  3931. item = arr[i];
  3932. itemLength = arrayByteLength(item);
  3933. resultLength += itemLength;
  3934. }
  3935. var pos = 0;
  3936. var data = new Uint8Array(resultLength);
  3937. for (i = 0; i < ii; i++) {
  3938. item = arr[i];
  3939. if (!(item instanceof Uint8Array)) {
  3940. if (typeof item === 'string') {
  3941. item = stringToBytes(item);
  3942. } else {
  3943. item = new Uint8Array(item);
  3944. }
  3945. }
  3946. itemLength = item.byteLength;
  3947. data.set(item, pos);
  3948. pos += itemLength;
  3949. }
  3950. return data;
  3951. }
  3952. function string32(value) {
  3953. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3954. }
  3955. function log2(x) {
  3956. var n = 1, i = 0;
  3957. while (x > n) {
  3958. n <<= 1;
  3959. i++;
  3960. }
  3961. return i;
  3962. }
  3963. function readInt8(data, start) {
  3964. return data[start] << 24 >> 24;
  3965. }
  3966. function readUint16(data, offset) {
  3967. return data[offset] << 8 | data[offset + 1];
  3968. }
  3969. function readUint32(data, offset) {
  3970. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  3971. }
  3972. function isLittleEndian() {
  3973. var buffer8 = new Uint8Array(2);
  3974. buffer8[0] = 1;
  3975. var buffer16 = new Uint16Array(buffer8.buffer);
  3976. return buffer16[0] === 1;
  3977. }
  3978. function isEvalSupported() {
  3979. try {
  3980. new Function('');
  3981. return true;
  3982. } catch (e) {
  3983. return false;
  3984. }
  3985. }
  3986. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  3987. function Uint32ArrayView(buffer, length) {
  3988. this.buffer = buffer;
  3989. this.byteLength = buffer.length;
  3990. this.length = length === undefined ? this.byteLength >> 2 : length;
  3991. ensureUint32ArrayViewProps(this.length);
  3992. }
  3993. Uint32ArrayView.prototype = Object.create(null);
  3994. var uint32ArrayViewSetters = 0;
  3995. function createUint32ArrayProp(index) {
  3996. return {
  3997. get: function () {
  3998. var buffer = this.buffer, offset = index << 2;
  3999. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  4000. },
  4001. set: function (value) {
  4002. var buffer = this.buffer, offset = index << 2;
  4003. buffer[offset] = value & 255;
  4004. buffer[offset + 1] = value >> 8 & 255;
  4005. buffer[offset + 2] = value >> 16 & 255;
  4006. buffer[offset + 3] = value >>> 24 & 255;
  4007. }
  4008. };
  4009. }
  4010. function ensureUint32ArrayViewProps(length) {
  4011. while (uint32ArrayViewSetters < length) {
  4012. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  4013. uint32ArrayViewSetters++;
  4014. }
  4015. }
  4016. return Uint32ArrayView;
  4017. }();
  4018. exports.Uint32ArrayView = Uint32ArrayView;
  4019. var IDENTITY_MATRIX = [
  4020. 1,
  4021. 0,
  4022. 0,
  4023. 1,
  4024. 0,
  4025. 0
  4026. ];
  4027. var Util = function UtilClosure() {
  4028. function Util() {
  4029. }
  4030. var rgbBuf = [
  4031. 'rgb(',
  4032. 0,
  4033. ',',
  4034. 0,
  4035. ',',
  4036. 0,
  4037. ')'
  4038. ];
  4039. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  4040. rgbBuf[1] = r;
  4041. rgbBuf[3] = g;
  4042. rgbBuf[5] = b;
  4043. return rgbBuf.join('');
  4044. };
  4045. Util.transform = function Util_transform(m1, m2) {
  4046. return [
  4047. m1[0] * m2[0] + m1[2] * m2[1],
  4048. m1[1] * m2[0] + m1[3] * m2[1],
  4049. m1[0] * m2[2] + m1[2] * m2[3],
  4050. m1[1] * m2[2] + m1[3] * m2[3],
  4051. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  4052. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  4053. ];
  4054. };
  4055. Util.applyTransform = function Util_applyTransform(p, m) {
  4056. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  4057. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  4058. return [
  4059. xt,
  4060. yt
  4061. ];
  4062. };
  4063. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  4064. var d = m[0] * m[3] - m[1] * m[2];
  4065. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  4066. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  4067. return [
  4068. xt,
  4069. yt
  4070. ];
  4071. };
  4072. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  4073. var p1 = Util.applyTransform(r, m);
  4074. var p2 = Util.applyTransform(r.slice(2, 4), m);
  4075. var p3 = Util.applyTransform([
  4076. r[0],
  4077. r[3]
  4078. ], m);
  4079. var p4 = Util.applyTransform([
  4080. r[2],
  4081. r[1]
  4082. ], m);
  4083. return [
  4084. Math.min(p1[0], p2[0], p3[0], p4[0]),
  4085. Math.min(p1[1], p2[1], p3[1], p4[1]),
  4086. Math.max(p1[0], p2[0], p3[0], p4[0]),
  4087. Math.max(p1[1], p2[1], p3[1], p4[1])
  4088. ];
  4089. };
  4090. Util.inverseTransform = function Util_inverseTransform(m) {
  4091. var d = m[0] * m[3] - m[1] * m[2];
  4092. return [
  4093. m[3] / d,
  4094. -m[1] / d,
  4095. -m[2] / d,
  4096. m[0] / d,
  4097. (m[2] * m[5] - m[4] * m[3]) / d,
  4098. (m[4] * m[1] - m[5] * m[0]) / d
  4099. ];
  4100. };
  4101. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  4102. return [
  4103. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  4104. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  4105. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  4106. ];
  4107. };
  4108. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  4109. var transpose = [
  4110. m[0],
  4111. m[2],
  4112. m[1],
  4113. m[3]
  4114. ];
  4115. var a = m[0] * transpose[0] + m[1] * transpose[2];
  4116. var b = m[0] * transpose[1] + m[1] * transpose[3];
  4117. var c = m[2] * transpose[0] + m[3] * transpose[2];
  4118. var d = m[2] * transpose[1] + m[3] * transpose[3];
  4119. var first = (a + d) / 2;
  4120. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  4121. var sx = first + second || 1;
  4122. var sy = first - second || 1;
  4123. return [
  4124. Math.sqrt(sx),
  4125. Math.sqrt(sy)
  4126. ];
  4127. };
  4128. Util.normalizeRect = function Util_normalizeRect(rect) {
  4129. var r = rect.slice(0);
  4130. if (rect[0] > rect[2]) {
  4131. r[0] = rect[2];
  4132. r[2] = rect[0];
  4133. }
  4134. if (rect[1] > rect[3]) {
  4135. r[1] = rect[3];
  4136. r[3] = rect[1];
  4137. }
  4138. return r;
  4139. };
  4140. Util.intersect = function Util_intersect(rect1, rect2) {
  4141. function compare(a, b) {
  4142. return a - b;
  4143. }
  4144. var orderedX = [
  4145. rect1[0],
  4146. rect1[2],
  4147. rect2[0],
  4148. rect2[2]
  4149. ].sort(compare), orderedY = [
  4150. rect1[1],
  4151. rect1[3],
  4152. rect2[1],
  4153. rect2[3]
  4154. ].sort(compare), result = [];
  4155. rect1 = Util.normalizeRect(rect1);
  4156. rect2 = Util.normalizeRect(rect2);
  4157. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  4158. result[0] = orderedX[1];
  4159. result[2] = orderedX[2];
  4160. } else {
  4161. return false;
  4162. }
  4163. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  4164. result[1] = orderedY[1];
  4165. result[3] = orderedY[2];
  4166. } else {
  4167. return false;
  4168. }
  4169. return result;
  4170. };
  4171. Util.sign = function Util_sign(num) {
  4172. return num < 0 ? -1 : 1;
  4173. };
  4174. var ROMAN_NUMBER_MAP = [
  4175. '',
  4176. 'C',
  4177. 'CC',
  4178. 'CCC',
  4179. 'CD',
  4180. 'D',
  4181. 'DC',
  4182. 'DCC',
  4183. 'DCCC',
  4184. 'CM',
  4185. '',
  4186. 'X',
  4187. 'XX',
  4188. 'XXX',
  4189. 'XL',
  4190. 'L',
  4191. 'LX',
  4192. 'LXX',
  4193. 'LXXX',
  4194. 'XC',
  4195. '',
  4196. 'I',
  4197. 'II',
  4198. 'III',
  4199. 'IV',
  4200. 'V',
  4201. 'VI',
  4202. 'VII',
  4203. 'VIII',
  4204. 'IX'
  4205. ];
  4206. Util.toRoman = function Util_toRoman(number, lowerCase) {
  4207. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  4208. var pos, romanBuf = [];
  4209. while (number >= 1000) {
  4210. number -= 1000;
  4211. romanBuf.push('M');
  4212. }
  4213. pos = number / 100 | 0;
  4214. number %= 100;
  4215. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  4216. pos = number / 10 | 0;
  4217. number %= 10;
  4218. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  4219. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  4220. var romanStr = romanBuf.join('');
  4221. return lowerCase ? romanStr.toLowerCase() : romanStr;
  4222. };
  4223. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  4224. Array.prototype.push.apply(arr1, arr2);
  4225. };
  4226. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  4227. Array.prototype.unshift.apply(arr1, arr2);
  4228. };
  4229. Util.extendObj = function extendObj(obj1, obj2) {
  4230. for (var key in obj2) {
  4231. obj1[key] = obj2[key];
  4232. }
  4233. };
  4234. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  4235. while (dict && !dict.has(name)) {
  4236. dict = dict.get('Parent');
  4237. }
  4238. if (!dict) {
  4239. return null;
  4240. }
  4241. return getArray ? dict.getArray(name) : dict.get(name);
  4242. };
  4243. Util.inherit = function Util_inherit(sub, base, prototype) {
  4244. sub.prototype = Object.create(base.prototype);
  4245. sub.prototype.constructor = sub;
  4246. for (var prop in prototype) {
  4247. sub.prototype[prop] = prototype[prop];
  4248. }
  4249. };
  4250. Util.loadScript = function Util_loadScript(src, callback) {
  4251. var script = document.createElement('script');
  4252. var loaded = false;
  4253. script.setAttribute('src', src);
  4254. if (callback) {
  4255. script.onload = function () {
  4256. if (!loaded) {
  4257. callback();
  4258. }
  4259. loaded = true;
  4260. };
  4261. }
  4262. document.getElementsByTagName('head')[0].appendChild(script);
  4263. };
  4264. return Util;
  4265. }();
  4266. var PageViewport = function PageViewportClosure() {
  4267. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  4268. this.viewBox = viewBox;
  4269. this.scale = scale;
  4270. this.rotation = rotation;
  4271. this.offsetX = offsetX;
  4272. this.offsetY = offsetY;
  4273. var centerX = (viewBox[2] + viewBox[0]) / 2;
  4274. var centerY = (viewBox[3] + viewBox[1]) / 2;
  4275. var rotateA, rotateB, rotateC, rotateD;
  4276. rotation = rotation % 360;
  4277. rotation = rotation < 0 ? rotation + 360 : rotation;
  4278. switch (rotation) {
  4279. case 180:
  4280. rotateA = -1;
  4281. rotateB = 0;
  4282. rotateC = 0;
  4283. rotateD = 1;
  4284. break;
  4285. case 90:
  4286. rotateA = 0;
  4287. rotateB = 1;
  4288. rotateC = 1;
  4289. rotateD = 0;
  4290. break;
  4291. case 270:
  4292. rotateA = 0;
  4293. rotateB = -1;
  4294. rotateC = -1;
  4295. rotateD = 0;
  4296. break;
  4297. default:
  4298. rotateA = 1;
  4299. rotateB = 0;
  4300. rotateC = 0;
  4301. rotateD = -1;
  4302. break;
  4303. }
  4304. if (dontFlip) {
  4305. rotateC = -rotateC;
  4306. rotateD = -rotateD;
  4307. }
  4308. var offsetCanvasX, offsetCanvasY;
  4309. var width, height;
  4310. if (rotateA === 0) {
  4311. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  4312. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  4313. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  4314. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  4315. } else {
  4316. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  4317. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  4318. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  4319. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  4320. }
  4321. this.transform = [
  4322. rotateA * scale,
  4323. rotateB * scale,
  4324. rotateC * scale,
  4325. rotateD * scale,
  4326. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  4327. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  4328. ];
  4329. this.width = width;
  4330. this.height = height;
  4331. this.fontScale = scale;
  4332. }
  4333. PageViewport.prototype = {
  4334. clone: function PageViewPort_clone(args) {
  4335. args = args || {};
  4336. var scale = 'scale' in args ? args.scale : this.scale;
  4337. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  4338. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  4339. },
  4340. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  4341. return Util.applyTransform([
  4342. x,
  4343. y
  4344. ], this.transform);
  4345. },
  4346. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  4347. var tl = Util.applyTransform([
  4348. rect[0],
  4349. rect[1]
  4350. ], this.transform);
  4351. var br = Util.applyTransform([
  4352. rect[2],
  4353. rect[3]
  4354. ], this.transform);
  4355. return [
  4356. tl[0],
  4357. tl[1],
  4358. br[0],
  4359. br[1]
  4360. ];
  4361. },
  4362. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  4363. return Util.applyInverseTransform([
  4364. x,
  4365. y
  4366. ], this.transform);
  4367. }
  4368. };
  4369. return PageViewport;
  4370. }();
  4371. var PDFStringTranslateTable = [
  4372. 0,
  4373. 0,
  4374. 0,
  4375. 0,
  4376. 0,
  4377. 0,
  4378. 0,
  4379. 0,
  4380. 0,
  4381. 0,
  4382. 0,
  4383. 0,
  4384. 0,
  4385. 0,
  4386. 0,
  4387. 0,
  4388. 0,
  4389. 0,
  4390. 0,
  4391. 0,
  4392. 0,
  4393. 0,
  4394. 0,
  4395. 0,
  4396. 0x2D8,
  4397. 0x2C7,
  4398. 0x2C6,
  4399. 0x2D9,
  4400. 0x2DD,
  4401. 0x2DB,
  4402. 0x2DA,
  4403. 0x2DC,
  4404. 0,
  4405. 0,
  4406. 0,
  4407. 0,
  4408. 0,
  4409. 0,
  4410. 0,
  4411. 0,
  4412. 0,
  4413. 0,
  4414. 0,
  4415. 0,
  4416. 0,
  4417. 0,
  4418. 0,
  4419. 0,
  4420. 0,
  4421. 0,
  4422. 0,
  4423. 0,
  4424. 0,
  4425. 0,
  4426. 0,
  4427. 0,
  4428. 0,
  4429. 0,
  4430. 0,
  4431. 0,
  4432. 0,
  4433. 0,
  4434. 0,
  4435. 0,
  4436. 0,
  4437. 0,
  4438. 0,
  4439. 0,
  4440. 0,
  4441. 0,
  4442. 0,
  4443. 0,
  4444. 0,
  4445. 0,
  4446. 0,
  4447. 0,
  4448. 0,
  4449. 0,
  4450. 0,
  4451. 0,
  4452. 0,
  4453. 0,
  4454. 0,
  4455. 0,
  4456. 0,
  4457. 0,
  4458. 0,
  4459. 0,
  4460. 0,
  4461. 0,
  4462. 0,
  4463. 0,
  4464. 0,
  4465. 0,
  4466. 0,
  4467. 0,
  4468. 0,
  4469. 0,
  4470. 0,
  4471. 0,
  4472. 0,
  4473. 0,
  4474. 0,
  4475. 0,
  4476. 0,
  4477. 0,
  4478. 0,
  4479. 0,
  4480. 0,
  4481. 0,
  4482. 0,
  4483. 0,
  4484. 0,
  4485. 0,
  4486. 0,
  4487. 0,
  4488. 0,
  4489. 0,
  4490. 0,
  4491. 0,
  4492. 0,
  4493. 0,
  4494. 0,
  4495. 0,
  4496. 0,
  4497. 0,
  4498. 0,
  4499. 0,
  4500. 0x2022,
  4501. 0x2020,
  4502. 0x2021,
  4503. 0x2026,
  4504. 0x2014,
  4505. 0x2013,
  4506. 0x192,
  4507. 0x2044,
  4508. 0x2039,
  4509. 0x203A,
  4510. 0x2212,
  4511. 0x2030,
  4512. 0x201E,
  4513. 0x201C,
  4514. 0x201D,
  4515. 0x2018,
  4516. 0x2019,
  4517. 0x201A,
  4518. 0x2122,
  4519. 0xFB01,
  4520. 0xFB02,
  4521. 0x141,
  4522. 0x152,
  4523. 0x160,
  4524. 0x178,
  4525. 0x17D,
  4526. 0x131,
  4527. 0x142,
  4528. 0x153,
  4529. 0x161,
  4530. 0x17E,
  4531. 0,
  4532. 0x20AC
  4533. ];
  4534. function stringToPDFString(str) {
  4535. var i, n = str.length, strBuf = [];
  4536. if (str[0] === '\xFE' && str[1] === '\xFF') {
  4537. for (i = 2; i < n; i += 2) {
  4538. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  4539. }
  4540. } else {
  4541. for (i = 0; i < n; ++i) {
  4542. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  4543. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  4544. }
  4545. }
  4546. return strBuf.join('');
  4547. }
  4548. function stringToUTF8String(str) {
  4549. return decodeURIComponent(escape(str));
  4550. }
  4551. function utf8StringToString(str) {
  4552. return unescape(encodeURIComponent(str));
  4553. }
  4554. function isEmptyObj(obj) {
  4555. for (var key in obj) {
  4556. return false;
  4557. }
  4558. return true;
  4559. }
  4560. function isBool(v) {
  4561. return typeof v === 'boolean';
  4562. }
  4563. function isInt(v) {
  4564. return typeof v === 'number' && (v | 0) === v;
  4565. }
  4566. function isNum(v) {
  4567. return typeof v === 'number';
  4568. }
  4569. function isString(v) {
  4570. return typeof v === 'string';
  4571. }
  4572. function isArray(v) {
  4573. return v instanceof Array;
  4574. }
  4575. function isArrayBuffer(v) {
  4576. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  4577. }
  4578. function isSpace(ch) {
  4579. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  4580. }
  4581. function createPromiseCapability() {
  4582. var capability = {};
  4583. capability.promise = new Promise(function (resolve, reject) {
  4584. capability.resolve = resolve;
  4585. capability.reject = reject;
  4586. });
  4587. return capability;
  4588. }
  4589. (function PromiseClosure() {
  4590. if (globalScope.Promise) {
  4591. if (typeof globalScope.Promise.all !== 'function') {
  4592. globalScope.Promise.all = function (iterable) {
  4593. var count = 0, results = [], resolve, reject;
  4594. var promise = new globalScope.Promise(function (resolve_, reject_) {
  4595. resolve = resolve_;
  4596. reject = reject_;
  4597. });
  4598. iterable.forEach(function (p, i) {
  4599. count++;
  4600. p.then(function (result) {
  4601. results[i] = result;
  4602. count--;
  4603. if (count === 0) {
  4604. resolve(results);
  4605. }
  4606. }, reject);
  4607. });
  4608. if (count === 0) {
  4609. resolve(results);
  4610. }
  4611. return promise;
  4612. };
  4613. }
  4614. if (typeof globalScope.Promise.resolve !== 'function') {
  4615. globalScope.Promise.resolve = function (value) {
  4616. return new globalScope.Promise(function (resolve) {
  4617. resolve(value);
  4618. });
  4619. };
  4620. }
  4621. if (typeof globalScope.Promise.reject !== 'function') {
  4622. globalScope.Promise.reject = function (reason) {
  4623. return new globalScope.Promise(function (resolve, reject) {
  4624. reject(reason);
  4625. });
  4626. };
  4627. }
  4628. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  4629. globalScope.Promise.prototype.catch = function (onReject) {
  4630. return globalScope.Promise.prototype.then(undefined, onReject);
  4631. };
  4632. }
  4633. return;
  4634. }
  4635. var STATUS_PENDING = 0;
  4636. var STATUS_RESOLVED = 1;
  4637. var STATUS_REJECTED = 2;
  4638. var REJECTION_TIMEOUT = 500;
  4639. var HandlerManager = {
  4640. handlers: [],
  4641. running: false,
  4642. unhandledRejections: [],
  4643. pendingRejectionCheck: false,
  4644. scheduleHandlers: function scheduleHandlers(promise) {
  4645. if (promise._status === STATUS_PENDING) {
  4646. return;
  4647. }
  4648. this.handlers = this.handlers.concat(promise._handlers);
  4649. promise._handlers = [];
  4650. if (this.running) {
  4651. return;
  4652. }
  4653. this.running = true;
  4654. setTimeout(this.runHandlers.bind(this), 0);
  4655. },
  4656. runHandlers: function runHandlers() {
  4657. var RUN_TIMEOUT = 1;
  4658. var timeoutAt = Date.now() + RUN_TIMEOUT;
  4659. while (this.handlers.length > 0) {
  4660. var handler = this.handlers.shift();
  4661. var nextStatus = handler.thisPromise._status;
  4662. var nextValue = handler.thisPromise._value;
  4663. try {
  4664. if (nextStatus === STATUS_RESOLVED) {
  4665. if (typeof handler.onResolve === 'function') {
  4666. nextValue = handler.onResolve(nextValue);
  4667. }
  4668. } else if (typeof handler.onReject === 'function') {
  4669. nextValue = handler.onReject(nextValue);
  4670. nextStatus = STATUS_RESOLVED;
  4671. if (handler.thisPromise._unhandledRejection) {
  4672. this.removeUnhandeledRejection(handler.thisPromise);
  4673. }
  4674. }
  4675. } catch (ex) {
  4676. nextStatus = STATUS_REJECTED;
  4677. nextValue = ex;
  4678. }
  4679. handler.nextPromise._updateStatus(nextStatus, nextValue);
  4680. if (Date.now() >= timeoutAt) {
  4681. break;
  4682. }
  4683. }
  4684. if (this.handlers.length > 0) {
  4685. setTimeout(this.runHandlers.bind(this), 0);
  4686. return;
  4687. }
  4688. this.running = false;
  4689. },
  4690. addUnhandledRejection: function addUnhandledRejection(promise) {
  4691. this.unhandledRejections.push({
  4692. promise: promise,
  4693. time: Date.now()
  4694. });
  4695. this.scheduleRejectionCheck();
  4696. },
  4697. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  4698. promise._unhandledRejection = false;
  4699. for (var i = 0; i < this.unhandledRejections.length; i++) {
  4700. if (this.unhandledRejections[i].promise === promise) {
  4701. this.unhandledRejections.splice(i);
  4702. i--;
  4703. }
  4704. }
  4705. },
  4706. scheduleRejectionCheck: function scheduleRejectionCheck() {
  4707. if (this.pendingRejectionCheck) {
  4708. return;
  4709. }
  4710. this.pendingRejectionCheck = true;
  4711. setTimeout(function rejectionCheck() {
  4712. this.pendingRejectionCheck = false;
  4713. var now = Date.now();
  4714. for (var i = 0; i < this.unhandledRejections.length; i++) {
  4715. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  4716. var unhandled = this.unhandledRejections[i].promise._value;
  4717. var msg = 'Unhandled rejection: ' + unhandled;
  4718. if (unhandled.stack) {
  4719. msg += '\n' + unhandled.stack;
  4720. }
  4721. warn(msg);
  4722. this.unhandledRejections.splice(i);
  4723. i--;
  4724. }
  4725. }
  4726. if (this.unhandledRejections.length) {
  4727. this.scheduleRejectionCheck();
  4728. }
  4729. }.bind(this), REJECTION_TIMEOUT);
  4730. }
  4731. };
  4732. var Promise = function Promise(resolver) {
  4733. this._status = STATUS_PENDING;
  4734. this._handlers = [];
  4735. try {
  4736. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  4737. } catch (e) {
  4738. this._reject(e);
  4739. }
  4740. };
  4741. Promise.all = function Promise_all(promises) {
  4742. var resolveAll, rejectAll;
  4743. var deferred = new Promise(function (resolve, reject) {
  4744. resolveAll = resolve;
  4745. rejectAll = reject;
  4746. });
  4747. var unresolved = promises.length;
  4748. var results = [];
  4749. if (unresolved === 0) {
  4750. resolveAll(results);
  4751. return deferred;
  4752. }
  4753. function reject(reason) {
  4754. if (deferred._status === STATUS_REJECTED) {
  4755. return;
  4756. }
  4757. results = [];
  4758. rejectAll(reason);
  4759. }
  4760. for (var i = 0, ii = promises.length; i < ii; ++i) {
  4761. var promise = promises[i];
  4762. var resolve = function (i) {
  4763. return function (value) {
  4764. if (deferred._status === STATUS_REJECTED) {
  4765. return;
  4766. }
  4767. results[i] = value;
  4768. unresolved--;
  4769. if (unresolved === 0) {
  4770. resolveAll(results);
  4771. }
  4772. };
  4773. }(i);
  4774. if (Promise.isPromise(promise)) {
  4775. promise.then(resolve, reject);
  4776. } else {
  4777. resolve(promise);
  4778. }
  4779. }
  4780. return deferred;
  4781. };
  4782. Promise.isPromise = function Promise_isPromise(value) {
  4783. return value && typeof value.then === 'function';
  4784. };
  4785. Promise.resolve = function Promise_resolve(value) {
  4786. return new Promise(function (resolve) {
  4787. resolve(value);
  4788. });
  4789. };
  4790. Promise.reject = function Promise_reject(reason) {
  4791. return new Promise(function (resolve, reject) {
  4792. reject(reason);
  4793. });
  4794. };
  4795. Promise.prototype = {
  4796. _status: null,
  4797. _value: null,
  4798. _handlers: null,
  4799. _unhandledRejection: null,
  4800. _updateStatus: function Promise__updateStatus(status, value) {
  4801. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  4802. return;
  4803. }
  4804. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  4805. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  4806. return;
  4807. }
  4808. this._status = status;
  4809. this._value = value;
  4810. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  4811. this._unhandledRejection = true;
  4812. HandlerManager.addUnhandledRejection(this);
  4813. }
  4814. HandlerManager.scheduleHandlers(this);
  4815. },
  4816. _resolve: function Promise_resolve(value) {
  4817. this._updateStatus(STATUS_RESOLVED, value);
  4818. },
  4819. _reject: function Promise_reject(reason) {
  4820. this._updateStatus(STATUS_REJECTED, reason);
  4821. },
  4822. then: function Promise_then(onResolve, onReject) {
  4823. var nextPromise = new Promise(function (resolve, reject) {
  4824. this.resolve = resolve;
  4825. this.reject = reject;
  4826. });
  4827. this._handlers.push({
  4828. thisPromise: this,
  4829. onResolve: onResolve,
  4830. onReject: onReject,
  4831. nextPromise: nextPromise
  4832. });
  4833. HandlerManager.scheduleHandlers(this);
  4834. return nextPromise;
  4835. },
  4836. catch: function Promise_catch(onReject) {
  4837. return this.then(undefined, onReject);
  4838. }
  4839. };
  4840. globalScope.Promise = Promise;
  4841. }());
  4842. (function WeakMapClosure() {
  4843. if (globalScope.WeakMap) {
  4844. return;
  4845. }
  4846. var id = 0;
  4847. function WeakMap() {
  4848. this.id = '$weakmap' + id++;
  4849. }
  4850. WeakMap.prototype = {
  4851. has: function (obj) {
  4852. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  4853. },
  4854. get: function (obj, defaultValue) {
  4855. return this.has(obj) ? obj[this.id] : defaultValue;
  4856. },
  4857. set: function (obj, value) {
  4858. Object.defineProperty(obj, this.id, {
  4859. value: value,
  4860. enumerable: false,
  4861. configurable: true
  4862. });
  4863. },
  4864. delete: function (obj) {
  4865. delete obj[this.id];
  4866. }
  4867. };
  4868. globalScope.WeakMap = WeakMap;
  4869. }());
  4870. var StatTimer = function StatTimerClosure() {
  4871. function rpad(str, pad, length) {
  4872. while (str.length < length) {
  4873. str += pad;
  4874. }
  4875. return str;
  4876. }
  4877. function StatTimer() {
  4878. this.started = Object.create(null);
  4879. this.times = [];
  4880. this.enabled = true;
  4881. }
  4882. StatTimer.prototype = {
  4883. time: function StatTimer_time(name) {
  4884. if (!this.enabled) {
  4885. return;
  4886. }
  4887. if (name in this.started) {
  4888. warn('Timer is already running for ' + name);
  4889. }
  4890. this.started[name] = Date.now();
  4891. },
  4892. timeEnd: function StatTimer_timeEnd(name) {
  4893. if (!this.enabled) {
  4894. return;
  4895. }
  4896. if (!(name in this.started)) {
  4897. warn('Timer has not been started for ' + name);
  4898. }
  4899. this.times.push({
  4900. 'name': name,
  4901. 'start': this.started[name],
  4902. 'end': Date.now()
  4903. });
  4904. delete this.started[name];
  4905. },
  4906. toString: function StatTimer_toString() {
  4907. var i, ii;
  4908. var times = this.times;
  4909. var out = '';
  4910. var longest = 0;
  4911. for (i = 0, ii = times.length; i < ii; ++i) {
  4912. var name = times[i]['name'];
  4913. if (name.length > longest) {
  4914. longest = name.length;
  4915. }
  4916. }
  4917. for (i = 0, ii = times.length; i < ii; ++i) {
  4918. var span = times[i];
  4919. var duration = span.end - span.start;
  4920. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  4921. }
  4922. return out;
  4923. }
  4924. };
  4925. return StatTimer;
  4926. }();
  4927. var createBlob = function createBlob(data, contentType) {
  4928. if (typeof Blob !== 'undefined') {
  4929. return new Blob([data], { type: contentType });
  4930. }
  4931. warn('The "Blob" constructor is not supported.');
  4932. };
  4933. var createObjectURL = function createObjectURLClosure() {
  4934. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  4935. return function createObjectURL(data, contentType, forceDataSchema) {
  4936. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  4937. var blob = createBlob(data, contentType);
  4938. return URL.createObjectURL(blob);
  4939. }
  4940. var buffer = 'data:' + contentType + ';base64,';
  4941. for (var i = 0, ii = data.length; i < ii; i += 3) {
  4942. var b1 = data[i] & 0xFF;
  4943. var b2 = data[i + 1] & 0xFF;
  4944. var b3 = data[i + 2] & 0xFF;
  4945. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  4946. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  4947. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  4948. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  4949. }
  4950. return buffer;
  4951. };
  4952. }();
  4953. function MessageHandler(sourceName, targetName, comObj) {
  4954. this.sourceName = sourceName;
  4955. this.targetName = targetName;
  4956. this.comObj = comObj;
  4957. this.callbackIndex = 1;
  4958. this.postMessageTransfers = true;
  4959. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  4960. var ah = this.actionHandler = Object.create(null);
  4961. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  4962. var data = event.data;
  4963. if (data.targetName !== this.sourceName) {
  4964. return;
  4965. }
  4966. if (data.isReply) {
  4967. var callbackId = data.callbackId;
  4968. if (data.callbackId in callbacksCapabilities) {
  4969. var callback = callbacksCapabilities[callbackId];
  4970. delete callbacksCapabilities[callbackId];
  4971. if ('error' in data) {
  4972. callback.reject(data.error);
  4973. } else {
  4974. callback.resolve(data.data);
  4975. }
  4976. } else {
  4977. error('Cannot resolve callback ' + callbackId);
  4978. }
  4979. } else if (data.action in ah) {
  4980. var action = ah[data.action];
  4981. if (data.callbackId) {
  4982. var sourceName = this.sourceName;
  4983. var targetName = data.sourceName;
  4984. Promise.resolve().then(function () {
  4985. return action[0].call(action[1], data.data);
  4986. }).then(function (result) {
  4987. comObj.postMessage({
  4988. sourceName: sourceName,
  4989. targetName: targetName,
  4990. isReply: true,
  4991. callbackId: data.callbackId,
  4992. data: result
  4993. });
  4994. }, function (reason) {
  4995. if (reason instanceof Error) {
  4996. reason = reason + '';
  4997. }
  4998. comObj.postMessage({
  4999. sourceName: sourceName,
  5000. targetName: targetName,
  5001. isReply: true,
  5002. callbackId: data.callbackId,
  5003. error: reason
  5004. });
  5005. });
  5006. } else {
  5007. action[0].call(action[1], data.data);
  5008. }
  5009. } else {
  5010. error('Unknown action from worker: ' + data.action);
  5011. }
  5012. }.bind(this);
  5013. comObj.addEventListener('message', this._onComObjOnMessage);
  5014. }
  5015. MessageHandler.prototype = {
  5016. on: function messageHandlerOn(actionName, handler, scope) {
  5017. var ah = this.actionHandler;
  5018. if (ah[actionName]) {
  5019. error('There is already an actionName called "' + actionName + '"');
  5020. }
  5021. ah[actionName] = [
  5022. handler,
  5023. scope
  5024. ];
  5025. },
  5026. send: function messageHandlerSend(actionName, data, transfers) {
  5027. var message = {
  5028. sourceName: this.sourceName,
  5029. targetName: this.targetName,
  5030. action: actionName,
  5031. data: data
  5032. };
  5033. this.postMessage(message, transfers);
  5034. },
  5035. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  5036. var callbackId = this.callbackIndex++;
  5037. var message = {
  5038. sourceName: this.sourceName,
  5039. targetName: this.targetName,
  5040. action: actionName,
  5041. data: data,
  5042. callbackId: callbackId
  5043. };
  5044. var capability = createPromiseCapability();
  5045. this.callbacksCapabilities[callbackId] = capability;
  5046. try {
  5047. this.postMessage(message, transfers);
  5048. } catch (e) {
  5049. capability.reject(e);
  5050. }
  5051. return capability.promise;
  5052. },
  5053. postMessage: function (message, transfers) {
  5054. if (transfers && this.postMessageTransfers) {
  5055. this.comObj.postMessage(message, transfers);
  5056. } else {
  5057. this.comObj.postMessage(message);
  5058. }
  5059. },
  5060. destroy: function () {
  5061. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  5062. }
  5063. };
  5064. function loadJpegStream(id, imageUrl, objs) {
  5065. var img = new Image();
  5066. img.onload = function loadJpegStream_onloadClosure() {
  5067. objs.resolve(id, img);
  5068. };
  5069. img.onerror = function loadJpegStream_onerrorClosure() {
  5070. objs.resolve(id, null);
  5071. warn('Error during JPEG image loading');
  5072. };
  5073. img.src = imageUrl;
  5074. }
  5075. /* Any copyright is dedicated to the Public Domain.
  5076. * http://creativecommons.org/publicdomain/zero/1.0/ */
  5077. (function checkURLConstructor(scope) {
  5078. var hasWorkingUrl = false;
  5079. try {
  5080. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  5081. var u = new URL('b', 'http://a');
  5082. u.pathname = 'c%20d';
  5083. hasWorkingUrl = u.href === 'http://a/c%20d';
  5084. }
  5085. } catch (e) {
  5086. }
  5087. if (hasWorkingUrl) {
  5088. return;
  5089. }
  5090. var relative = Object.create(null);
  5091. relative['ftp'] = 21;
  5092. relative['file'] = 0;
  5093. relative['gopher'] = 70;
  5094. relative['http'] = 80;
  5095. relative['https'] = 443;
  5096. relative['ws'] = 80;
  5097. relative['wss'] = 443;
  5098. var relativePathDotMapping = Object.create(null);
  5099. relativePathDotMapping['%2e'] = '.';
  5100. relativePathDotMapping['.%2e'] = '..';
  5101. relativePathDotMapping['%2e.'] = '..';
  5102. relativePathDotMapping['%2e%2e'] = '..';
  5103. function isRelativeScheme(scheme) {
  5104. return relative[scheme] !== undefined;
  5105. }
  5106. function invalid() {
  5107. clear.call(this);
  5108. this._isInvalid = true;
  5109. }
  5110. function IDNAToASCII(h) {
  5111. if ('' === h) {
  5112. invalid.call(this);
  5113. }
  5114. return h.toLowerCase();
  5115. }
  5116. function percentEscape(c) {
  5117. var unicode = c.charCodeAt(0);
  5118. if (unicode > 0x20 && unicode < 0x7F && [
  5119. 0x22,
  5120. 0x23,
  5121. 0x3C,
  5122. 0x3E,
  5123. 0x3F,
  5124. 0x60
  5125. ].indexOf(unicode) === -1) {
  5126. return c;
  5127. }
  5128. return encodeURIComponent(c);
  5129. }
  5130. function percentEscapeQuery(c) {
  5131. var unicode = c.charCodeAt(0);
  5132. if (unicode > 0x20 && unicode < 0x7F && [
  5133. 0x22,
  5134. 0x23,
  5135. 0x3C,
  5136. 0x3E,
  5137. 0x60
  5138. ].indexOf(unicode) === -1) {
  5139. return c;
  5140. }
  5141. return encodeURIComponent(c);
  5142. }
  5143. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  5144. function parse(input, stateOverride, base) {
  5145. function err(message) {
  5146. errors.push(message);
  5147. }
  5148. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  5149. loop:
  5150. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  5151. var c = input[cursor];
  5152. switch (state) {
  5153. case 'scheme start':
  5154. if (c && ALPHA.test(c)) {
  5155. buffer += c.toLowerCase();
  5156. state = 'scheme';
  5157. } else if (!stateOverride) {
  5158. buffer = '';
  5159. state = 'no scheme';
  5160. continue;
  5161. } else {
  5162. err('Invalid scheme.');
  5163. break loop;
  5164. }
  5165. break;
  5166. case 'scheme':
  5167. if (c && ALPHANUMERIC.test(c)) {
  5168. buffer += c.toLowerCase();
  5169. } else if (':' === c) {
  5170. this._scheme = buffer;
  5171. buffer = '';
  5172. if (stateOverride) {
  5173. break loop;
  5174. }
  5175. if (isRelativeScheme(this._scheme)) {
  5176. this._isRelative = true;
  5177. }
  5178. if ('file' === this._scheme) {
  5179. state = 'relative';
  5180. } else if (this._isRelative && base && base._scheme === this._scheme) {
  5181. state = 'relative or authority';
  5182. } else if (this._isRelative) {
  5183. state = 'authority first slash';
  5184. } else {
  5185. state = 'scheme data';
  5186. }
  5187. } else if (!stateOverride) {
  5188. buffer = '';
  5189. cursor = 0;
  5190. state = 'no scheme';
  5191. continue;
  5192. } else if (EOF === c) {
  5193. break loop;
  5194. } else {
  5195. err('Code point not allowed in scheme: ' + c);
  5196. break loop;
  5197. }
  5198. break;
  5199. case 'scheme data':
  5200. if ('?' === c) {
  5201. this._query = '?';
  5202. state = 'query';
  5203. } else if ('#' === c) {
  5204. this._fragment = '#';
  5205. state = 'fragment';
  5206. } else {
  5207. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  5208. this._schemeData += percentEscape(c);
  5209. }
  5210. }
  5211. break;
  5212. case 'no scheme':
  5213. if (!base || !isRelativeScheme(base._scheme)) {
  5214. err('Missing scheme.');
  5215. invalid.call(this);
  5216. } else {
  5217. state = 'relative';
  5218. continue;
  5219. }
  5220. break;
  5221. case 'relative or authority':
  5222. if ('/' === c && '/' === input[cursor + 1]) {
  5223. state = 'authority ignore slashes';
  5224. } else {
  5225. err('Expected /, got: ' + c);
  5226. state = 'relative';
  5227. continue;
  5228. }
  5229. break;
  5230. case 'relative':
  5231. this._isRelative = true;
  5232. if ('file' !== this._scheme) {
  5233. this._scheme = base._scheme;
  5234. }
  5235. if (EOF === c) {
  5236. this._host = base._host;
  5237. this._port = base._port;
  5238. this._path = base._path.slice();
  5239. this._query = base._query;
  5240. this._username = base._username;
  5241. this._password = base._password;
  5242. break loop;
  5243. } else if ('/' === c || '\\' === c) {
  5244. if ('\\' === c) {
  5245. err('\\ is an invalid code point.');
  5246. }
  5247. state = 'relative slash';
  5248. } else if ('?' === c) {
  5249. this._host = base._host;
  5250. this._port = base._port;
  5251. this._path = base._path.slice();
  5252. this._query = '?';
  5253. this._username = base._username;
  5254. this._password = base._password;
  5255. state = 'query';
  5256. } else if ('#' === c) {
  5257. this._host = base._host;
  5258. this._port = base._port;
  5259. this._path = base._path.slice();
  5260. this._query = base._query;
  5261. this._fragment = '#';
  5262. this._username = base._username;
  5263. this._password = base._password;
  5264. state = 'fragment';
  5265. } else {
  5266. var nextC = input[cursor + 1];
  5267. var nextNextC = input[cursor + 2];
  5268. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  5269. this._host = base._host;
  5270. this._port = base._port;
  5271. this._username = base._username;
  5272. this._password = base._password;
  5273. this._path = base._path.slice();
  5274. this._path.pop();
  5275. }
  5276. state = 'relative path';
  5277. continue;
  5278. }
  5279. break;
  5280. case 'relative slash':
  5281. if ('/' === c || '\\' === c) {
  5282. if ('\\' === c) {
  5283. err('\\ is an invalid code point.');
  5284. }
  5285. if ('file' === this._scheme) {
  5286. state = 'file host';
  5287. } else {
  5288. state = 'authority ignore slashes';
  5289. }
  5290. } else {
  5291. if ('file' !== this._scheme) {
  5292. this._host = base._host;
  5293. this._port = base._port;
  5294. this._username = base._username;
  5295. this._password = base._password;
  5296. }
  5297. state = 'relative path';
  5298. continue;
  5299. }
  5300. break;
  5301. case 'authority first slash':
  5302. if ('/' === c) {
  5303. state = 'authority second slash';
  5304. } else {
  5305. err('Expected \'/\', got: ' + c);
  5306. state = 'authority ignore slashes';
  5307. continue;
  5308. }
  5309. break;
  5310. case 'authority second slash':
  5311. state = 'authority ignore slashes';
  5312. if ('/' !== c) {
  5313. err('Expected \'/\', got: ' + c);
  5314. continue;
  5315. }
  5316. break;
  5317. case 'authority ignore slashes':
  5318. if ('/' !== c && '\\' !== c) {
  5319. state = 'authority';
  5320. continue;
  5321. } else {
  5322. err('Expected authority, got: ' + c);
  5323. }
  5324. break;
  5325. case 'authority':
  5326. if ('@' === c) {
  5327. if (seenAt) {
  5328. err('@ already seen.');
  5329. buffer += '%40';
  5330. }
  5331. seenAt = true;
  5332. for (var i = 0; i < buffer.length; i++) {
  5333. var cp = buffer[i];
  5334. if ('\t' === cp || '\n' === cp || '\r' === cp) {
  5335. err('Invalid whitespace in authority.');
  5336. continue;
  5337. }
  5338. if (':' === cp && null === this._password) {
  5339. this._password = '';
  5340. continue;
  5341. }
  5342. var tempC = percentEscape(cp);
  5343. if (null !== this._password) {
  5344. this._password += tempC;
  5345. } else {
  5346. this._username += tempC;
  5347. }
  5348. }
  5349. buffer = '';
  5350. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  5351. cursor -= buffer.length;
  5352. buffer = '';
  5353. state = 'host';
  5354. continue;
  5355. } else {
  5356. buffer += c;
  5357. }
  5358. break;
  5359. case 'file host':
  5360. if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  5361. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  5362. state = 'relative path';
  5363. } else if (buffer.length === 0) {
  5364. state = 'relative path start';
  5365. } else {
  5366. this._host = IDNAToASCII.call(this, buffer);
  5367. buffer = '';
  5368. state = 'relative path start';
  5369. }
  5370. continue;
  5371. } else if ('\t' === c || '\n' === c || '\r' === c) {
  5372. err('Invalid whitespace in file host.');
  5373. } else {
  5374. buffer += c;
  5375. }
  5376. break;
  5377. case 'host':
  5378. case 'hostname':
  5379. if (':' === c && !seenBracket) {
  5380. this._host = IDNAToASCII.call(this, buffer);
  5381. buffer = '';
  5382. state = 'port';
  5383. if ('hostname' === stateOverride) {
  5384. break loop;
  5385. }
  5386. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  5387. this._host = IDNAToASCII.call(this, buffer);
  5388. buffer = '';
  5389. state = 'relative path start';
  5390. if (stateOverride) {
  5391. break loop;
  5392. }
  5393. continue;
  5394. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  5395. if ('[' === c) {
  5396. seenBracket = true;
  5397. } else if (']' === c) {
  5398. seenBracket = false;
  5399. }
  5400. buffer += c;
  5401. } else {
  5402. err('Invalid code point in host/hostname: ' + c);
  5403. }
  5404. break;
  5405. case 'port':
  5406. if (/[0-9]/.test(c)) {
  5407. buffer += c;
  5408. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c || stateOverride) {
  5409. if ('' !== buffer) {
  5410. var temp = parseInt(buffer, 10);
  5411. if (temp !== relative[this._scheme]) {
  5412. this._port = temp + '';
  5413. }
  5414. buffer = '';
  5415. }
  5416. if (stateOverride) {
  5417. break loop;
  5418. }
  5419. state = 'relative path start';
  5420. continue;
  5421. } else if ('\t' === c || '\n' === c || '\r' === c) {
  5422. err('Invalid code point in port: ' + c);
  5423. } else {
  5424. invalid.call(this);
  5425. }
  5426. break;
  5427. case 'relative path start':
  5428. if ('\\' === c) {
  5429. err('\'\\\' not allowed in path.');
  5430. }
  5431. state = 'relative path';
  5432. if ('/' !== c && '\\' !== c) {
  5433. continue;
  5434. }
  5435. break;
  5436. case 'relative path':
  5437. if (EOF === c || '/' === c || '\\' === c || !stateOverride && ('?' === c || '#' === c)) {
  5438. if ('\\' === c) {
  5439. err('\\ not allowed in relative path.');
  5440. }
  5441. var tmp;
  5442. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  5443. buffer = tmp;
  5444. }
  5445. if ('..' === buffer) {
  5446. this._path.pop();
  5447. if ('/' !== c && '\\' !== c) {
  5448. this._path.push('');
  5449. }
  5450. } else if ('.' === buffer && '/' !== c && '\\' !== c) {
  5451. this._path.push('');
  5452. } else if ('.' !== buffer) {
  5453. if ('file' === this._scheme && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  5454. buffer = buffer[0] + ':';
  5455. }
  5456. this._path.push(buffer);
  5457. }
  5458. buffer = '';
  5459. if ('?' === c) {
  5460. this._query = '?';
  5461. state = 'query';
  5462. } else if ('#' === c) {
  5463. this._fragment = '#';
  5464. state = 'fragment';
  5465. }
  5466. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  5467. buffer += percentEscape(c);
  5468. }
  5469. break;
  5470. case 'query':
  5471. if (!stateOverride && '#' === c) {
  5472. this._fragment = '#';
  5473. state = 'fragment';
  5474. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  5475. this._query += percentEscapeQuery(c);
  5476. }
  5477. break;
  5478. case 'fragment':
  5479. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  5480. this._fragment += c;
  5481. }
  5482. break;
  5483. }
  5484. cursor++;
  5485. }
  5486. }
  5487. function clear() {
  5488. this._scheme = '';
  5489. this._schemeData = '';
  5490. this._username = '';
  5491. this._password = null;
  5492. this._host = '';
  5493. this._port = '';
  5494. this._path = [];
  5495. this._query = '';
  5496. this._fragment = '';
  5497. this._isInvalid = false;
  5498. this._isRelative = false;
  5499. }
  5500. function JURL(url, base)
  5501. {
  5502. if (base !== undefined && !(base instanceof JURL)) {
  5503. base = new JURL(String(base));
  5504. }
  5505. this._url = url;
  5506. clear.call(this);
  5507. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  5508. parse.call(this, input, null, base);
  5509. }
  5510. JURL.prototype = {
  5511. toString: function () {
  5512. return this.href;
  5513. },
  5514. get href() {
  5515. if (this._isInvalid) {
  5516. return this._url;
  5517. }
  5518. var authority = '';
  5519. if ('' !== this._username || null !== this._password) {
  5520. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  5521. }
  5522. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  5523. },
  5524. set href(href) {
  5525. clear.call(this);
  5526. parse.call(this, href);
  5527. },
  5528. get protocol() {
  5529. return this._scheme + ':';
  5530. },
  5531. set protocol(protocol) {
  5532. if (this._isInvalid) {
  5533. return;
  5534. }
  5535. parse.call(this, protocol + ':', 'scheme start');
  5536. },
  5537. get host() {
  5538. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  5539. },
  5540. set host(host) {
  5541. if (this._isInvalid || !this._isRelative) {
  5542. return;
  5543. }
  5544. parse.call(this, host, 'host');
  5545. },
  5546. get hostname() {
  5547. return this._host;
  5548. },
  5549. set hostname(hostname) {
  5550. if (this._isInvalid || !this._isRelative) {
  5551. return;
  5552. }
  5553. parse.call(this, hostname, 'hostname');
  5554. },
  5555. get port() {
  5556. return this._port;
  5557. },
  5558. set port(port) {
  5559. if (this._isInvalid || !this._isRelative) {
  5560. return;
  5561. }
  5562. parse.call(this, port, 'port');
  5563. },
  5564. get pathname() {
  5565. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  5566. },
  5567. set pathname(pathname) {
  5568. if (this._isInvalid || !this._isRelative) {
  5569. return;
  5570. }
  5571. this._path = [];
  5572. parse.call(this, pathname, 'relative path start');
  5573. },
  5574. get search() {
  5575. return this._isInvalid || !this._query || '?' === this._query ? '' : this._query;
  5576. },
  5577. set search(search) {
  5578. if (this._isInvalid || !this._isRelative) {
  5579. return;
  5580. }
  5581. this._query = '?';
  5582. if ('?' === search[0]) {
  5583. search = search.slice(1);
  5584. }
  5585. parse.call(this, search, 'query');
  5586. },
  5587. get hash() {
  5588. return this._isInvalid || !this._fragment || '#' === this._fragment ? '' : this._fragment;
  5589. },
  5590. set hash(hash) {
  5591. if (this._isInvalid) {
  5592. return;
  5593. }
  5594. this._fragment = '#';
  5595. if ('#' === hash[0]) {
  5596. hash = hash.slice(1);
  5597. }
  5598. parse.call(this, hash, 'fragment');
  5599. },
  5600. get origin() {
  5601. var host;
  5602. if (this._isInvalid || !this._scheme) {
  5603. return '';
  5604. }
  5605. switch (this._scheme) {
  5606. case 'data':
  5607. case 'file':
  5608. case 'javascript':
  5609. case 'mailto':
  5610. return 'null';
  5611. }
  5612. host = this.host;
  5613. if (!host) {
  5614. return '';
  5615. }
  5616. return this._scheme + '://' + host;
  5617. }
  5618. };
  5619. var OriginalURL = scope.URL;
  5620. if (OriginalURL) {
  5621. JURL.createObjectURL = function (blob) {
  5622. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  5623. };
  5624. JURL.revokeObjectURL = function (url) {
  5625. OriginalURL.revokeObjectURL(url);
  5626. };
  5627. }
  5628. scope.URL = JURL;
  5629. }(globalScope));
  5630. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  5631. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  5632. exports.OPS = OPS;
  5633. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  5634. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  5635. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  5636. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  5637. exports.AnnotationFlag = AnnotationFlag;
  5638. exports.AnnotationType = AnnotationType;
  5639. exports.FontType = FontType;
  5640. exports.ImageKind = ImageKind;
  5641. exports.InvalidPDFException = InvalidPDFException;
  5642. exports.MessageHandler = MessageHandler;
  5643. exports.MissingDataException = MissingDataException;
  5644. exports.MissingPDFException = MissingPDFException;
  5645. exports.NotImplementedException = NotImplementedException;
  5646. exports.PageViewport = PageViewport;
  5647. exports.PasswordException = PasswordException;
  5648. exports.PasswordResponses = PasswordResponses;
  5649. exports.StatTimer = StatTimer;
  5650. exports.StreamType = StreamType;
  5651. exports.TextRenderingMode = TextRenderingMode;
  5652. exports.UnexpectedResponseException = UnexpectedResponseException;
  5653. exports.UnknownErrorException = UnknownErrorException;
  5654. exports.Util = Util;
  5655. exports.XRefParseException = XRefParseException;
  5656. exports.arrayByteLength = arrayByteLength;
  5657. exports.arraysToBytes = arraysToBytes;
  5658. exports.assert = assert;
  5659. exports.bytesToString = bytesToString;
  5660. exports.createBlob = createBlob;
  5661. exports.createPromiseCapability = createPromiseCapability;
  5662. exports.createObjectURL = createObjectURL;
  5663. exports.deprecated = deprecated;
  5664. exports.error = error;
  5665. exports.getLookupTableFactory = getLookupTableFactory;
  5666. exports.getVerbosityLevel = getVerbosityLevel;
  5667. exports.globalScope = globalScope;
  5668. exports.info = info;
  5669. exports.isArray = isArray;
  5670. exports.isArrayBuffer = isArrayBuffer;
  5671. exports.isBool = isBool;
  5672. exports.isEmptyObj = isEmptyObj;
  5673. exports.isInt = isInt;
  5674. exports.isNum = isNum;
  5675. exports.isString = isString;
  5676. exports.isSpace = isSpace;
  5677. exports.isSameOrigin = isSameOrigin;
  5678. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  5679. exports.isLittleEndian = isLittleEndian;
  5680. exports.isEvalSupported = isEvalSupported;
  5681. exports.loadJpegStream = loadJpegStream;
  5682. exports.log2 = log2;
  5683. exports.readInt8 = readInt8;
  5684. exports.readUint16 = readUint16;
  5685. exports.readUint32 = readUint32;
  5686. exports.removeNullCharacters = removeNullCharacters;
  5687. exports.setVerbosityLevel = setVerbosityLevel;
  5688. exports.shadow = shadow;
  5689. exports.string32 = string32;
  5690. exports.stringToBytes = stringToBytes;
  5691. exports.stringToPDFString = stringToPDFString;
  5692. exports.stringToUTF8String = stringToUTF8String;
  5693. exports.utf8StringToString = utf8StringToString;
  5694. exports.warn = warn;
  5695. }));
  5696. (function (root, factory) {
  5697. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5698. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5699. var error = sharedUtil.error;
  5700. var info = sharedUtil.info;
  5701. var bytesToString = sharedUtil.bytesToString;
  5702. var warn = sharedUtil.warn;
  5703. var isArray = sharedUtil.isArray;
  5704. var Util = sharedUtil.Util;
  5705. var stringToBytes = sharedUtil.stringToBytes;
  5706. var assert = sharedUtil.assert;
  5707. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5708. var ExpertCharset = coreCharsets.ExpertCharset;
  5709. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5710. var StandardEncoding = coreEncodings.StandardEncoding;
  5711. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5712. var MAX_SUBR_NESTING = 10;
  5713. var CFFStandardStrings = [
  5714. '.notdef',
  5715. 'space',
  5716. 'exclam',
  5717. 'quotedbl',
  5718. 'numbersign',
  5719. 'dollar',
  5720. 'percent',
  5721. 'ampersand',
  5722. 'quoteright',
  5723. 'parenleft',
  5724. 'parenright',
  5725. 'asterisk',
  5726. 'plus',
  5727. 'comma',
  5728. 'hyphen',
  5729. 'period',
  5730. 'slash',
  5731. 'zero',
  5732. 'one',
  5733. 'two',
  5734. 'three',
  5735. 'four',
  5736. 'five',
  5737. 'six',
  5738. 'seven',
  5739. 'eight',
  5740. 'nine',
  5741. 'colon',
  5742. 'semicolon',
  5743. 'less',
  5744. 'equal',
  5745. 'greater',
  5746. 'question',
  5747. 'at',
  5748. 'A',
  5749. 'B',
  5750. 'C',
  5751. 'D',
  5752. 'E',
  5753. 'F',
  5754. 'G',
  5755. 'H',
  5756. 'I',
  5757. 'J',
  5758. 'K',
  5759. 'L',
  5760. 'M',
  5761. 'N',
  5762. 'O',
  5763. 'P',
  5764. 'Q',
  5765. 'R',
  5766. 'S',
  5767. 'T',
  5768. 'U',
  5769. 'V',
  5770. 'W',
  5771. 'X',
  5772. 'Y',
  5773. 'Z',
  5774. 'bracketleft',
  5775. 'backslash',
  5776. 'bracketright',
  5777. 'asciicircum',
  5778. 'underscore',
  5779. 'quoteleft',
  5780. 'a',
  5781. 'b',
  5782. 'c',
  5783. 'd',
  5784. 'e',
  5785. 'f',
  5786. 'g',
  5787. 'h',
  5788. 'i',
  5789. 'j',
  5790. 'k',
  5791. 'l',
  5792. 'm',
  5793. 'n',
  5794. 'o',
  5795. 'p',
  5796. 'q',
  5797. 'r',
  5798. 's',
  5799. 't',
  5800. 'u',
  5801. 'v',
  5802. 'w',
  5803. 'x',
  5804. 'y',
  5805. 'z',
  5806. 'braceleft',
  5807. 'bar',
  5808. 'braceright',
  5809. 'asciitilde',
  5810. 'exclamdown',
  5811. 'cent',
  5812. 'sterling',
  5813. 'fraction',
  5814. 'yen',
  5815. 'florin',
  5816. 'section',
  5817. 'currency',
  5818. 'quotesingle',
  5819. 'quotedblleft',
  5820. 'guillemotleft',
  5821. 'guilsinglleft',
  5822. 'guilsinglright',
  5823. 'fi',
  5824. 'fl',
  5825. 'endash',
  5826. 'dagger',
  5827. 'daggerdbl',
  5828. 'periodcentered',
  5829. 'paragraph',
  5830. 'bullet',
  5831. 'quotesinglbase',
  5832. 'quotedblbase',
  5833. 'quotedblright',
  5834. 'guillemotright',
  5835. 'ellipsis',
  5836. 'perthousand',
  5837. 'questiondown',
  5838. 'grave',
  5839. 'acute',
  5840. 'circumflex',
  5841. 'tilde',
  5842. 'macron',
  5843. 'breve',
  5844. 'dotaccent',
  5845. 'dieresis',
  5846. 'ring',
  5847. 'cedilla',
  5848. 'hungarumlaut',
  5849. 'ogonek',
  5850. 'caron',
  5851. 'emdash',
  5852. 'AE',
  5853. 'ordfeminine',
  5854. 'Lslash',
  5855. 'Oslash',
  5856. 'OE',
  5857. 'ordmasculine',
  5858. 'ae',
  5859. 'dotlessi',
  5860. 'lslash',
  5861. 'oslash',
  5862. 'oe',
  5863. 'germandbls',
  5864. 'onesuperior',
  5865. 'logicalnot',
  5866. 'mu',
  5867. 'trademark',
  5868. 'Eth',
  5869. 'onehalf',
  5870. 'plusminus',
  5871. 'Thorn',
  5872. 'onequarter',
  5873. 'divide',
  5874. 'brokenbar',
  5875. 'degree',
  5876. 'thorn',
  5877. 'threequarters',
  5878. 'twosuperior',
  5879. 'registered',
  5880. 'minus',
  5881. 'eth',
  5882. 'multiply',
  5883. 'threesuperior',
  5884. 'copyright',
  5885. 'Aacute',
  5886. 'Acircumflex',
  5887. 'Adieresis',
  5888. 'Agrave',
  5889. 'Aring',
  5890. 'Atilde',
  5891. 'Ccedilla',
  5892. 'Eacute',
  5893. 'Ecircumflex',
  5894. 'Edieresis',
  5895. 'Egrave',
  5896. 'Iacute',
  5897. 'Icircumflex',
  5898. 'Idieresis',
  5899. 'Igrave',
  5900. 'Ntilde',
  5901. 'Oacute',
  5902. 'Ocircumflex',
  5903. 'Odieresis',
  5904. 'Ograve',
  5905. 'Otilde',
  5906. 'Scaron',
  5907. 'Uacute',
  5908. 'Ucircumflex',
  5909. 'Udieresis',
  5910. 'Ugrave',
  5911. 'Yacute',
  5912. 'Ydieresis',
  5913. 'Zcaron',
  5914. 'aacute',
  5915. 'acircumflex',
  5916. 'adieresis',
  5917. 'agrave',
  5918. 'aring',
  5919. 'atilde',
  5920. 'ccedilla',
  5921. 'eacute',
  5922. 'ecircumflex',
  5923. 'edieresis',
  5924. 'egrave',
  5925. 'iacute',
  5926. 'icircumflex',
  5927. 'idieresis',
  5928. 'igrave',
  5929. 'ntilde',
  5930. 'oacute',
  5931. 'ocircumflex',
  5932. 'odieresis',
  5933. 'ograve',
  5934. 'otilde',
  5935. 'scaron',
  5936. 'uacute',
  5937. 'ucircumflex',
  5938. 'udieresis',
  5939. 'ugrave',
  5940. 'yacute',
  5941. 'ydieresis',
  5942. 'zcaron',
  5943. 'exclamsmall',
  5944. 'Hungarumlautsmall',
  5945. 'dollaroldstyle',
  5946. 'dollarsuperior',
  5947. 'ampersandsmall',
  5948. 'Acutesmall',
  5949. 'parenleftsuperior',
  5950. 'parenrightsuperior',
  5951. 'twodotenleader',
  5952. 'onedotenleader',
  5953. 'zerooldstyle',
  5954. 'oneoldstyle',
  5955. 'twooldstyle',
  5956. 'threeoldstyle',
  5957. 'fouroldstyle',
  5958. 'fiveoldstyle',
  5959. 'sixoldstyle',
  5960. 'sevenoldstyle',
  5961. 'eightoldstyle',
  5962. 'nineoldstyle',
  5963. 'commasuperior',
  5964. 'threequartersemdash',
  5965. 'periodsuperior',
  5966. 'questionsmall',
  5967. 'asuperior',
  5968. 'bsuperior',
  5969. 'centsuperior',
  5970. 'dsuperior',
  5971. 'esuperior',
  5972. 'isuperior',
  5973. 'lsuperior',
  5974. 'msuperior',
  5975. 'nsuperior',
  5976. 'osuperior',
  5977. 'rsuperior',
  5978. 'ssuperior',
  5979. 'tsuperior',
  5980. 'ff',
  5981. 'ffi',
  5982. 'ffl',
  5983. 'parenleftinferior',
  5984. 'parenrightinferior',
  5985. 'Circumflexsmall',
  5986. 'hyphensuperior',
  5987. 'Gravesmall',
  5988. 'Asmall',
  5989. 'Bsmall',
  5990. 'Csmall',
  5991. 'Dsmall',
  5992. 'Esmall',
  5993. 'Fsmall',
  5994. 'Gsmall',
  5995. 'Hsmall',
  5996. 'Ismall',
  5997. 'Jsmall',
  5998. 'Ksmall',
  5999. 'Lsmall',
  6000. 'Msmall',
  6001. 'Nsmall',
  6002. 'Osmall',
  6003. 'Psmall',
  6004. 'Qsmall',
  6005. 'Rsmall',
  6006. 'Ssmall',
  6007. 'Tsmall',
  6008. 'Usmall',
  6009. 'Vsmall',
  6010. 'Wsmall',
  6011. 'Xsmall',
  6012. 'Ysmall',
  6013. 'Zsmall',
  6014. 'colonmonetary',
  6015. 'onefitted',
  6016. 'rupiah',
  6017. 'Tildesmall',
  6018. 'exclamdownsmall',
  6019. 'centoldstyle',
  6020. 'Lslashsmall',
  6021. 'Scaronsmall',
  6022. 'Zcaronsmall',
  6023. 'Dieresissmall',
  6024. 'Brevesmall',
  6025. 'Caronsmall',
  6026. 'Dotaccentsmall',
  6027. 'Macronsmall',
  6028. 'figuredash',
  6029. 'hypheninferior',
  6030. 'Ogoneksmall',
  6031. 'Ringsmall',
  6032. 'Cedillasmall',
  6033. 'questiondownsmall',
  6034. 'oneeighth',
  6035. 'threeeighths',
  6036. 'fiveeighths',
  6037. 'seveneighths',
  6038. 'onethird',
  6039. 'twothirds',
  6040. 'zerosuperior',
  6041. 'foursuperior',
  6042. 'fivesuperior',
  6043. 'sixsuperior',
  6044. 'sevensuperior',
  6045. 'eightsuperior',
  6046. 'ninesuperior',
  6047. 'zeroinferior',
  6048. 'oneinferior',
  6049. 'twoinferior',
  6050. 'threeinferior',
  6051. 'fourinferior',
  6052. 'fiveinferior',
  6053. 'sixinferior',
  6054. 'seveninferior',
  6055. 'eightinferior',
  6056. 'nineinferior',
  6057. 'centinferior',
  6058. 'dollarinferior',
  6059. 'periodinferior',
  6060. 'commainferior',
  6061. 'Agravesmall',
  6062. 'Aacutesmall',
  6063. 'Acircumflexsmall',
  6064. 'Atildesmall',
  6065. 'Adieresissmall',
  6066. 'Aringsmall',
  6067. 'AEsmall',
  6068. 'Ccedillasmall',
  6069. 'Egravesmall',
  6070. 'Eacutesmall',
  6071. 'Ecircumflexsmall',
  6072. 'Edieresissmall',
  6073. 'Igravesmall',
  6074. 'Iacutesmall',
  6075. 'Icircumflexsmall',
  6076. 'Idieresissmall',
  6077. 'Ethsmall',
  6078. 'Ntildesmall',
  6079. 'Ogravesmall',
  6080. 'Oacutesmall',
  6081. 'Ocircumflexsmall',
  6082. 'Otildesmall',
  6083. 'Odieresissmall',
  6084. 'OEsmall',
  6085. 'Oslashsmall',
  6086. 'Ugravesmall',
  6087. 'Uacutesmall',
  6088. 'Ucircumflexsmall',
  6089. 'Udieresissmall',
  6090. 'Yacutesmall',
  6091. 'Thornsmall',
  6092. 'Ydieresissmall',
  6093. '001.000',
  6094. '001.001',
  6095. '001.002',
  6096. '001.003',
  6097. 'Black',
  6098. 'Bold',
  6099. 'Book',
  6100. 'Light',
  6101. 'Medium',
  6102. 'Regular',
  6103. 'Roman',
  6104. 'Semibold'
  6105. ];
  6106. var CFFParser = function CFFParserClosure() {
  6107. var CharstringValidationData = [
  6108. null,
  6109. {
  6110. id: 'hstem',
  6111. min: 2,
  6112. stackClearing: true,
  6113. stem: true
  6114. },
  6115. null,
  6116. {
  6117. id: 'vstem',
  6118. min: 2,
  6119. stackClearing: true,
  6120. stem: true
  6121. },
  6122. {
  6123. id: 'vmoveto',
  6124. min: 1,
  6125. stackClearing: true
  6126. },
  6127. {
  6128. id: 'rlineto',
  6129. min: 2,
  6130. resetStack: true
  6131. },
  6132. {
  6133. id: 'hlineto',
  6134. min: 1,
  6135. resetStack: true
  6136. },
  6137. {
  6138. id: 'vlineto',
  6139. min: 1,
  6140. resetStack: true
  6141. },
  6142. {
  6143. id: 'rrcurveto',
  6144. min: 6,
  6145. resetStack: true
  6146. },
  6147. null,
  6148. {
  6149. id: 'callsubr',
  6150. min: 1,
  6151. undefStack: true
  6152. },
  6153. {
  6154. id: 'return',
  6155. min: 0,
  6156. undefStack: true
  6157. },
  6158. null,
  6159. null,
  6160. {
  6161. id: 'endchar',
  6162. min: 0,
  6163. stackClearing: true
  6164. },
  6165. null,
  6166. null,
  6167. null,
  6168. {
  6169. id: 'hstemhm',
  6170. min: 2,
  6171. stackClearing: true,
  6172. stem: true
  6173. },
  6174. {
  6175. id: 'hintmask',
  6176. min: 0,
  6177. stackClearing: true
  6178. },
  6179. {
  6180. id: 'cntrmask',
  6181. min: 0,
  6182. stackClearing: true
  6183. },
  6184. {
  6185. id: 'rmoveto',
  6186. min: 2,
  6187. stackClearing: true
  6188. },
  6189. {
  6190. id: 'hmoveto',
  6191. min: 1,
  6192. stackClearing: true
  6193. },
  6194. {
  6195. id: 'vstemhm',
  6196. min: 2,
  6197. stackClearing: true,
  6198. stem: true
  6199. },
  6200. {
  6201. id: 'rcurveline',
  6202. min: 8,
  6203. resetStack: true
  6204. },
  6205. {
  6206. id: 'rlinecurve',
  6207. min: 8,
  6208. resetStack: true
  6209. },
  6210. {
  6211. id: 'vvcurveto',
  6212. min: 4,
  6213. resetStack: true
  6214. },
  6215. {
  6216. id: 'hhcurveto',
  6217. min: 4,
  6218. resetStack: true
  6219. },
  6220. null,
  6221. {
  6222. id: 'callgsubr',
  6223. min: 1,
  6224. undefStack: true
  6225. },
  6226. {
  6227. id: 'vhcurveto',
  6228. min: 4,
  6229. resetStack: true
  6230. },
  6231. {
  6232. id: 'hvcurveto',
  6233. min: 4,
  6234. resetStack: true
  6235. }
  6236. ];
  6237. var CharstringValidationData12 = [
  6238. null,
  6239. null,
  6240. null,
  6241. {
  6242. id: 'and',
  6243. min: 2,
  6244. stackDelta: -1
  6245. },
  6246. {
  6247. id: 'or',
  6248. min: 2,
  6249. stackDelta: -1
  6250. },
  6251. {
  6252. id: 'not',
  6253. min: 1,
  6254. stackDelta: 0
  6255. },
  6256. null,
  6257. null,
  6258. null,
  6259. {
  6260. id: 'abs',
  6261. min: 1,
  6262. stackDelta: 0
  6263. },
  6264. {
  6265. id: 'add',
  6266. min: 2,
  6267. stackDelta: -1,
  6268. stackFn: function stack_div(stack, index) {
  6269. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6270. }
  6271. },
  6272. {
  6273. id: 'sub',
  6274. min: 2,
  6275. stackDelta: -1,
  6276. stackFn: function stack_div(stack, index) {
  6277. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6278. }
  6279. },
  6280. {
  6281. id: 'div',
  6282. min: 2,
  6283. stackDelta: -1,
  6284. stackFn: function stack_div(stack, index) {
  6285. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6286. }
  6287. },
  6288. null,
  6289. {
  6290. id: 'neg',
  6291. min: 1,
  6292. stackDelta: 0,
  6293. stackFn: function stack_div(stack, index) {
  6294. stack[index - 1] = -stack[index - 1];
  6295. }
  6296. },
  6297. {
  6298. id: 'eq',
  6299. min: 2,
  6300. stackDelta: -1
  6301. },
  6302. null,
  6303. null,
  6304. {
  6305. id: 'drop',
  6306. min: 1,
  6307. stackDelta: -1
  6308. },
  6309. null,
  6310. {
  6311. id: 'put',
  6312. min: 2,
  6313. stackDelta: -2
  6314. },
  6315. {
  6316. id: 'get',
  6317. min: 1,
  6318. stackDelta: 0
  6319. },
  6320. {
  6321. id: 'ifelse',
  6322. min: 4,
  6323. stackDelta: -3
  6324. },
  6325. {
  6326. id: 'random',
  6327. min: 0,
  6328. stackDelta: 1
  6329. },
  6330. {
  6331. id: 'mul',
  6332. min: 2,
  6333. stackDelta: -1,
  6334. stackFn: function stack_div(stack, index) {
  6335. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6336. }
  6337. },
  6338. null,
  6339. {
  6340. id: 'sqrt',
  6341. min: 1,
  6342. stackDelta: 0
  6343. },
  6344. {
  6345. id: 'dup',
  6346. min: 1,
  6347. stackDelta: 1
  6348. },
  6349. {
  6350. id: 'exch',
  6351. min: 2,
  6352. stackDelta: 0
  6353. },
  6354. {
  6355. id: 'index',
  6356. min: 2,
  6357. stackDelta: 0
  6358. },
  6359. {
  6360. id: 'roll',
  6361. min: 3,
  6362. stackDelta: -2
  6363. },
  6364. null,
  6365. null,
  6366. null,
  6367. {
  6368. id: 'hflex',
  6369. min: 7,
  6370. resetStack: true
  6371. },
  6372. {
  6373. id: 'flex',
  6374. min: 13,
  6375. resetStack: true
  6376. },
  6377. {
  6378. id: 'hflex1',
  6379. min: 9,
  6380. resetStack: true
  6381. },
  6382. {
  6383. id: 'flex1',
  6384. min: 11,
  6385. resetStack: true
  6386. }
  6387. ];
  6388. function CFFParser(file, properties, seacAnalysisEnabled) {
  6389. this.bytes = file.getBytes();
  6390. this.properties = properties;
  6391. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6392. }
  6393. CFFParser.prototype = {
  6394. parse: function CFFParser_parse() {
  6395. var properties = this.properties;
  6396. var cff = new CFF();
  6397. this.cff = cff;
  6398. var header = this.parseHeader();
  6399. var nameIndex = this.parseIndex(header.endPos);
  6400. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6401. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6402. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6403. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6404. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6405. cff.header = header.obj;
  6406. cff.names = this.parseNameIndex(nameIndex.obj);
  6407. cff.strings = this.parseStringIndex(stringIndex.obj);
  6408. cff.topDict = topDict;
  6409. cff.globalSubrIndex = globalSubrIndex.obj;
  6410. this.parsePrivateDict(cff.topDict);
  6411. cff.isCIDFont = topDict.hasName('ROS');
  6412. var charStringOffset = topDict.getByName('CharStrings');
  6413. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6414. var fontMatrix = topDict.getByName('FontMatrix');
  6415. if (fontMatrix) {
  6416. properties.fontMatrix = fontMatrix;
  6417. }
  6418. var fontBBox = topDict.getByName('FontBBox');
  6419. if (fontBBox) {
  6420. properties.ascent = fontBBox[3];
  6421. properties.descent = fontBBox[1];
  6422. properties.ascentScaled = true;
  6423. }
  6424. var charset, encoding;
  6425. if (cff.isCIDFont) {
  6426. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6427. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6428. var dictRaw = fdArrayIndex.get(i);
  6429. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6430. this.parsePrivateDict(fontDict);
  6431. cff.fdArray.push(fontDict);
  6432. }
  6433. encoding = null;
  6434. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6435. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6436. } else {
  6437. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6438. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6439. }
  6440. cff.charset = charset;
  6441. cff.encoding = encoding;
  6442. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6443. cff.charStrings = charStringsAndSeacs.charStrings;
  6444. cff.seacs = charStringsAndSeacs.seacs;
  6445. cff.widths = charStringsAndSeacs.widths;
  6446. return cff;
  6447. },
  6448. parseHeader: function CFFParser_parseHeader() {
  6449. var bytes = this.bytes;
  6450. var bytesLength = bytes.length;
  6451. var offset = 0;
  6452. while (offset < bytesLength && bytes[offset] !== 1) {
  6453. ++offset;
  6454. }
  6455. if (offset >= bytesLength) {
  6456. error('Invalid CFF header');
  6457. } else if (offset !== 0) {
  6458. info('cff data is shifted');
  6459. bytes = bytes.subarray(offset);
  6460. this.bytes = bytes;
  6461. }
  6462. var major = bytes[0];
  6463. var minor = bytes[1];
  6464. var hdrSize = bytes[2];
  6465. var offSize = bytes[3];
  6466. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6467. return {
  6468. obj: header,
  6469. endPos: hdrSize
  6470. };
  6471. },
  6472. parseDict: function CFFParser_parseDict(dict) {
  6473. var pos = 0;
  6474. function parseOperand() {
  6475. var value = dict[pos++];
  6476. if (value === 30) {
  6477. return parseFloatOperand();
  6478. } else if (value === 28) {
  6479. value = dict[pos++];
  6480. value = (value << 24 | dict[pos++] << 16) >> 16;
  6481. return value;
  6482. } else if (value === 29) {
  6483. value = dict[pos++];
  6484. value = value << 8 | dict[pos++];
  6485. value = value << 8 | dict[pos++];
  6486. value = value << 8 | dict[pos++];
  6487. return value;
  6488. } else if (value >= 32 && value <= 246) {
  6489. return value - 139;
  6490. } else if (value >= 247 && value <= 250) {
  6491. return (value - 247) * 256 + dict[pos++] + 108;
  6492. } else if (value >= 251 && value <= 254) {
  6493. return -((value - 251) * 256) - dict[pos++] - 108;
  6494. } else {
  6495. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6496. return NaN;
  6497. }
  6498. }
  6499. function parseFloatOperand() {
  6500. var str = '';
  6501. var eof = 15;
  6502. var lookup = [
  6503. '0',
  6504. '1',
  6505. '2',
  6506. '3',
  6507. '4',
  6508. '5',
  6509. '6',
  6510. '7',
  6511. '8',
  6512. '9',
  6513. '.',
  6514. 'E',
  6515. 'E-',
  6516. null,
  6517. '-'
  6518. ];
  6519. var length = dict.length;
  6520. while (pos < length) {
  6521. var b = dict[pos++];
  6522. var b1 = b >> 4;
  6523. var b2 = b & 15;
  6524. if (b1 === eof) {
  6525. break;
  6526. }
  6527. str += lookup[b1];
  6528. if (b2 === eof) {
  6529. break;
  6530. }
  6531. str += lookup[b2];
  6532. }
  6533. return parseFloat(str);
  6534. }
  6535. var operands = [];
  6536. var entries = [];
  6537. pos = 0;
  6538. var end = dict.length;
  6539. while (pos < end) {
  6540. var b = dict[pos];
  6541. if (b <= 21) {
  6542. if (b === 12) {
  6543. b = b << 8 | dict[++pos];
  6544. }
  6545. entries.push([
  6546. b,
  6547. operands
  6548. ]);
  6549. operands = [];
  6550. ++pos;
  6551. } else {
  6552. operands.push(parseOperand());
  6553. }
  6554. }
  6555. return entries;
  6556. },
  6557. parseIndex: function CFFParser_parseIndex(pos) {
  6558. var cffIndex = new CFFIndex();
  6559. var bytes = this.bytes;
  6560. var count = bytes[pos++] << 8 | bytes[pos++];
  6561. var offsets = [];
  6562. var end = pos;
  6563. var i, ii;
  6564. if (count !== 0) {
  6565. var offsetSize = bytes[pos++];
  6566. var startPos = pos + (count + 1) * offsetSize - 1;
  6567. for (i = 0, ii = count + 1; i < ii; ++i) {
  6568. var offset = 0;
  6569. for (var j = 0; j < offsetSize; ++j) {
  6570. offset <<= 8;
  6571. offset += bytes[pos++];
  6572. }
  6573. offsets.push(startPos + offset);
  6574. }
  6575. end = offsets[count];
  6576. }
  6577. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6578. var offsetStart = offsets[i];
  6579. var offsetEnd = offsets[i + 1];
  6580. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6581. }
  6582. return {
  6583. obj: cffIndex,
  6584. endPos: end
  6585. };
  6586. },
  6587. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6588. var names = [];
  6589. for (var i = 0, ii = index.count; i < ii; ++i) {
  6590. var name = index.get(i);
  6591. var length = Math.min(name.length, 127);
  6592. var data = [];
  6593. for (var j = 0; j < length; ++j) {
  6594. var c = name[j];
  6595. if (j === 0 && c === 0) {
  6596. data[j] = c;
  6597. continue;
  6598. }
  6599. 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)
  6600. {
  6601. data[j] = 95;
  6602. continue;
  6603. }
  6604. data[j] = c;
  6605. }
  6606. names.push(bytesToString(data));
  6607. }
  6608. return names;
  6609. },
  6610. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6611. var strings = new CFFStrings();
  6612. for (var i = 0, ii = index.count; i < ii; ++i) {
  6613. var data = index.get(i);
  6614. strings.add(bytesToString(data));
  6615. }
  6616. return strings;
  6617. },
  6618. createDict: function CFFParser_createDict(Type, dict, strings) {
  6619. var cffDict = new Type(strings);
  6620. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6621. var pair = dict[i];
  6622. var key = pair[0];
  6623. var value = pair[1];
  6624. cffDict.setByKey(key, value);
  6625. }
  6626. return cffDict;
  6627. },
  6628. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6629. if (state.callDepth > MAX_SUBR_NESTING) {
  6630. return false;
  6631. }
  6632. var stackSize = state.stackSize;
  6633. var stack = state.stack;
  6634. var length = data.length;
  6635. for (var j = 0; j < length;) {
  6636. var value = data[j++];
  6637. var validationCommand = null;
  6638. if (value === 12) {
  6639. var q = data[j++];
  6640. if (q === 0) {
  6641. data[j - 2] = 139;
  6642. data[j - 1] = 22;
  6643. stackSize = 0;
  6644. } else {
  6645. validationCommand = CharstringValidationData12[q];
  6646. }
  6647. } else if (value === 28) {
  6648. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6649. j += 2;
  6650. stackSize++;
  6651. } else if (value === 14) {
  6652. if (stackSize >= 4) {
  6653. stackSize -= 4;
  6654. if (this.seacAnalysisEnabled) {
  6655. state.seac = stack.slice(stackSize, stackSize + 4);
  6656. return false;
  6657. }
  6658. }
  6659. validationCommand = CharstringValidationData[value];
  6660. } else if (value >= 32 && value <= 246) {
  6661. stack[stackSize] = value - 139;
  6662. stackSize++;
  6663. } else if (value >= 247 && value <= 254) {
  6664. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6665. j++;
  6666. stackSize++;
  6667. } else if (value === 255) {
  6668. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6669. j += 4;
  6670. stackSize++;
  6671. } else if (value === 19 || value === 20) {
  6672. state.hints += stackSize >> 1;
  6673. j += state.hints + 7 >> 3;
  6674. stackSize %= 2;
  6675. validationCommand = CharstringValidationData[value];
  6676. } else if (value === 10 || value === 29) {
  6677. var subrsIndex;
  6678. if (value === 10) {
  6679. subrsIndex = localSubrIndex;
  6680. } else {
  6681. subrsIndex = globalSubrIndex;
  6682. }
  6683. if (!subrsIndex) {
  6684. validationCommand = CharstringValidationData[value];
  6685. warn('Missing subrsIndex for ' + validationCommand.id);
  6686. return false;
  6687. }
  6688. var bias = 32768;
  6689. if (subrsIndex.count < 1240) {
  6690. bias = 107;
  6691. } else if (subrsIndex.count < 33900) {
  6692. bias = 1131;
  6693. }
  6694. var subrNumber = stack[--stackSize] + bias;
  6695. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6696. validationCommand = CharstringValidationData[value];
  6697. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6698. return false;
  6699. }
  6700. state.stackSize = stackSize;
  6701. state.callDepth++;
  6702. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6703. if (!valid) {
  6704. return false;
  6705. }
  6706. state.callDepth--;
  6707. stackSize = state.stackSize;
  6708. continue;
  6709. } else if (value === 11) {
  6710. state.stackSize = stackSize;
  6711. return true;
  6712. } else {
  6713. validationCommand = CharstringValidationData[value];
  6714. }
  6715. if (validationCommand) {
  6716. if (validationCommand.stem) {
  6717. state.hints += stackSize >> 1;
  6718. }
  6719. if ('min' in validationCommand) {
  6720. if (!state.undefStack && stackSize < validationCommand.min) {
  6721. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6722. return false;
  6723. }
  6724. }
  6725. if (state.firstStackClearing && validationCommand.stackClearing) {
  6726. state.firstStackClearing = false;
  6727. stackSize -= validationCommand.min;
  6728. if (stackSize >= 2 && validationCommand.stem) {
  6729. stackSize %= 2;
  6730. } else if (stackSize > 1) {
  6731. warn('Found too many parameters for stack-clearing command');
  6732. }
  6733. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6734. state.width = stack[stackSize - 1];
  6735. }
  6736. }
  6737. if ('stackDelta' in validationCommand) {
  6738. if ('stackFn' in validationCommand) {
  6739. validationCommand.stackFn(stack, stackSize);
  6740. }
  6741. stackSize += validationCommand.stackDelta;
  6742. } else if (validationCommand.stackClearing) {
  6743. stackSize = 0;
  6744. } else if (validationCommand.resetStack) {
  6745. stackSize = 0;
  6746. state.undefStack = false;
  6747. } else if (validationCommand.undefStack) {
  6748. stackSize = 0;
  6749. state.undefStack = true;
  6750. state.firstStackClearing = false;
  6751. }
  6752. }
  6753. }
  6754. state.stackSize = stackSize;
  6755. return true;
  6756. },
  6757. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6758. var seacs = [];
  6759. var widths = [];
  6760. var count = charStrings.count;
  6761. for (var i = 0; i < count; i++) {
  6762. var charstring = charStrings.get(i);
  6763. var state = {
  6764. callDepth: 0,
  6765. stackSize: 0,
  6766. stack: [],
  6767. undefStack: true,
  6768. hints: 0,
  6769. firstStackClearing: true,
  6770. seac: null,
  6771. width: null
  6772. };
  6773. var valid = true;
  6774. var localSubrToUse = null;
  6775. if (fdSelect && fdArray.length) {
  6776. var fdIndex = fdSelect.getFDIndex(i);
  6777. if (fdIndex === -1) {
  6778. warn('Glyph index is not in fd select.');
  6779. valid = false;
  6780. }
  6781. if (fdIndex >= fdArray.length) {
  6782. warn('Invalid fd index for glyph index.');
  6783. valid = false;
  6784. }
  6785. if (valid) {
  6786. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6787. }
  6788. } else if (localSubrIndex) {
  6789. localSubrToUse = localSubrIndex;
  6790. }
  6791. if (valid) {
  6792. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6793. }
  6794. if (state.width !== null) {
  6795. widths[i] = state.width;
  6796. }
  6797. if (state.seac !== null) {
  6798. seacs[i] = state.seac;
  6799. }
  6800. if (!valid) {
  6801. charStrings.set(i, new Uint8Array([14]));
  6802. }
  6803. }
  6804. return {
  6805. charStrings: charStrings,
  6806. seacs: seacs,
  6807. widths: widths
  6808. };
  6809. },
  6810. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6811. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6812. parentDict.setByKey(18, [
  6813. 0,
  6814. 0
  6815. ]);
  6816. parentDict.privateDict = privateDict;
  6817. },
  6818. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6819. if (!parentDict.hasName('Private')) {
  6820. this.emptyPrivateDictionary(parentDict);
  6821. return;
  6822. }
  6823. var privateOffset = parentDict.getByName('Private');
  6824. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6825. parentDict.removeByName('Private');
  6826. return;
  6827. }
  6828. var size = privateOffset[0];
  6829. var offset = privateOffset[1];
  6830. if (size === 0 || offset >= this.bytes.length) {
  6831. this.emptyPrivateDictionary(parentDict);
  6832. return;
  6833. }
  6834. var privateDictEnd = offset + size;
  6835. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6836. var dict = this.parseDict(dictData);
  6837. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6838. parentDict.privateDict = privateDict;
  6839. if (!privateDict.getByName('Subrs')) {
  6840. return;
  6841. }
  6842. var subrsOffset = privateDict.getByName('Subrs');
  6843. var relativeOffset = offset + subrsOffset;
  6844. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6845. this.emptyPrivateDictionary(parentDict);
  6846. return;
  6847. }
  6848. var subrsIndex = this.parseIndex(relativeOffset);
  6849. privateDict.subrsIndex = subrsIndex.obj;
  6850. },
  6851. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6852. if (pos === 0) {
  6853. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6854. } else if (pos === 1) {
  6855. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6856. } else if (pos === 2) {
  6857. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6858. }
  6859. var bytes = this.bytes;
  6860. var start = pos;
  6861. var format = bytes[pos++];
  6862. var charset = ['.notdef'];
  6863. var id, count, i;
  6864. length -= 1;
  6865. switch (format) {
  6866. case 0:
  6867. for (i = 0; i < length; i++) {
  6868. id = bytes[pos++] << 8 | bytes[pos++];
  6869. charset.push(cid ? id : strings.get(id));
  6870. }
  6871. break;
  6872. case 1:
  6873. while (charset.length <= length) {
  6874. id = bytes[pos++] << 8 | bytes[pos++];
  6875. count = bytes[pos++];
  6876. for (i = 0; i <= count; i++) {
  6877. charset.push(cid ? id++ : strings.get(id++));
  6878. }
  6879. }
  6880. break;
  6881. case 2:
  6882. while (charset.length <= length) {
  6883. id = bytes[pos++] << 8 | bytes[pos++];
  6884. count = bytes[pos++] << 8 | bytes[pos++];
  6885. for (i = 0; i <= count; i++) {
  6886. charset.push(cid ? id++ : strings.get(id++));
  6887. }
  6888. }
  6889. break;
  6890. default:
  6891. error('Unknown charset format');
  6892. }
  6893. var end = pos;
  6894. var raw = bytes.subarray(start, end);
  6895. return new CFFCharset(false, format, charset, raw);
  6896. },
  6897. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6898. var encoding = Object.create(null);
  6899. var bytes = this.bytes;
  6900. var predefined = false;
  6901. var hasSupplement = false;
  6902. var format, i, ii;
  6903. var raw = null;
  6904. function readSupplement() {
  6905. var supplementsCount = bytes[pos++];
  6906. for (i = 0; i < supplementsCount; i++) {
  6907. var code = bytes[pos++];
  6908. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6909. encoding[code] = charset.indexOf(strings.get(sid));
  6910. }
  6911. }
  6912. if (pos === 0 || pos === 1) {
  6913. predefined = true;
  6914. format = pos;
  6915. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6916. for (i = 0, ii = charset.length; i < ii; i++) {
  6917. var index = baseEncoding.indexOf(charset[i]);
  6918. if (index !== -1) {
  6919. encoding[index] = i;
  6920. }
  6921. }
  6922. } else {
  6923. var dataStart = pos;
  6924. format = bytes[pos++];
  6925. switch (format & 0x7f) {
  6926. case 0:
  6927. var glyphsCount = bytes[pos++];
  6928. for (i = 1; i <= glyphsCount; i++) {
  6929. encoding[bytes[pos++]] = i;
  6930. }
  6931. break;
  6932. case 1:
  6933. var rangesCount = bytes[pos++];
  6934. var gid = 1;
  6935. for (i = 0; i < rangesCount; i++) {
  6936. var start = bytes[pos++];
  6937. var left = bytes[pos++];
  6938. for (var j = start; j <= start + left; j++) {
  6939. encoding[j] = gid++;
  6940. }
  6941. }
  6942. break;
  6943. default:
  6944. error('Unknown encoding format: ' + format + ' in CFF');
  6945. break;
  6946. }
  6947. var dataEnd = pos;
  6948. if (format & 0x80) {
  6949. bytes[dataStart] &= 0x7f;
  6950. readSupplement();
  6951. hasSupplement = true;
  6952. }
  6953. raw = bytes.subarray(dataStart, dataEnd);
  6954. }
  6955. format = format & 0x7f;
  6956. return new CFFEncoding(predefined, format, encoding, raw);
  6957. },
  6958. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6959. var start = pos;
  6960. var bytes = this.bytes;
  6961. var format = bytes[pos++];
  6962. var fdSelect = [], rawBytes;
  6963. var i, invalidFirstGID = false;
  6964. switch (format) {
  6965. case 0:
  6966. for (i = 0; i < length; ++i) {
  6967. var id = bytes[pos++];
  6968. fdSelect.push(id);
  6969. }
  6970. rawBytes = bytes.subarray(start, pos);
  6971. break;
  6972. case 3:
  6973. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6974. for (i = 0; i < rangesCount; ++i) {
  6975. var first = bytes[pos++] << 8 | bytes[pos++];
  6976. if (i === 0 && first !== 0) {
  6977. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6978. invalidFirstGID = true;
  6979. first = 0;
  6980. }
  6981. var fdIndex = bytes[pos++];
  6982. var next = bytes[pos] << 8 | bytes[pos + 1];
  6983. for (var j = first; j < next; ++j) {
  6984. fdSelect.push(fdIndex);
  6985. }
  6986. }
  6987. pos += 2;
  6988. rawBytes = bytes.subarray(start, pos);
  6989. if (invalidFirstGID) {
  6990. rawBytes[3] = rawBytes[4] = 0;
  6991. }
  6992. break;
  6993. default:
  6994. error('parseFDSelect: Unknown format "' + format + '".');
  6995. break;
  6996. }
  6997. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  6998. return new CFFFDSelect(fdSelect, rawBytes);
  6999. }
  7000. };
  7001. return CFFParser;
  7002. }();
  7003. var CFF = function CFFClosure() {
  7004. function CFF() {
  7005. this.header = null;
  7006. this.names = [];
  7007. this.topDict = null;
  7008. this.strings = new CFFStrings();
  7009. this.globalSubrIndex = null;
  7010. this.encoding = null;
  7011. this.charset = null;
  7012. this.charStrings = null;
  7013. this.fdArray = [];
  7014. this.fdSelect = null;
  7015. this.isCIDFont = false;
  7016. }
  7017. return CFF;
  7018. }();
  7019. var CFFHeader = function CFFHeaderClosure() {
  7020. function CFFHeader(major, minor, hdrSize, offSize) {
  7021. this.major = major;
  7022. this.minor = minor;
  7023. this.hdrSize = hdrSize;
  7024. this.offSize = offSize;
  7025. }
  7026. return CFFHeader;
  7027. }();
  7028. var CFFStrings = function CFFStringsClosure() {
  7029. function CFFStrings() {
  7030. this.strings = [];
  7031. }
  7032. CFFStrings.prototype = {
  7033. get: function CFFStrings_get(index) {
  7034. if (index >= 0 && index <= 390) {
  7035. return CFFStandardStrings[index];
  7036. }
  7037. if (index - 391 <= this.strings.length) {
  7038. return this.strings[index - 391];
  7039. }
  7040. return CFFStandardStrings[0];
  7041. },
  7042. add: function CFFStrings_add(value) {
  7043. this.strings.push(value);
  7044. },
  7045. get count() {
  7046. return this.strings.length;
  7047. }
  7048. };
  7049. return CFFStrings;
  7050. }();
  7051. var CFFIndex = function CFFIndexClosure() {
  7052. function CFFIndex() {
  7053. this.objects = [];
  7054. this.length = 0;
  7055. }
  7056. CFFIndex.prototype = {
  7057. add: function CFFIndex_add(data) {
  7058. this.length += data.length;
  7059. this.objects.push(data);
  7060. },
  7061. set: function CFFIndex_set(index, data) {
  7062. this.length += data.length - this.objects[index].length;
  7063. this.objects[index] = data;
  7064. },
  7065. get: function CFFIndex_get(index) {
  7066. return this.objects[index];
  7067. },
  7068. get count() {
  7069. return this.objects.length;
  7070. }
  7071. };
  7072. return CFFIndex;
  7073. }();
  7074. var CFFDict = function CFFDictClosure() {
  7075. function CFFDict(tables, strings) {
  7076. this.keyToNameMap = tables.keyToNameMap;
  7077. this.nameToKeyMap = tables.nameToKeyMap;
  7078. this.defaults = tables.defaults;
  7079. this.types = tables.types;
  7080. this.opcodes = tables.opcodes;
  7081. this.order = tables.order;
  7082. this.strings = strings;
  7083. this.values = Object.create(null);
  7084. }
  7085. CFFDict.prototype = {
  7086. setByKey: function CFFDict_setByKey(key, value) {
  7087. if (!(key in this.keyToNameMap)) {
  7088. return false;
  7089. }
  7090. var valueLength = value.length;
  7091. if (valueLength === 0) {
  7092. return true;
  7093. }
  7094. for (var i = 0; i < valueLength; i++) {
  7095. if (isNaN(value[i])) {
  7096. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7097. return true;
  7098. }
  7099. }
  7100. var type = this.types[key];
  7101. if (type === 'num' || type === 'sid' || type === 'offset') {
  7102. value = value[0];
  7103. }
  7104. this.values[key] = value;
  7105. return true;
  7106. },
  7107. setByName: function CFFDict_setByName(name, value) {
  7108. if (!(name in this.nameToKeyMap)) {
  7109. error('Invalid dictionary name "' + name + '"');
  7110. }
  7111. this.values[this.nameToKeyMap[name]] = value;
  7112. },
  7113. hasName: function CFFDict_hasName(name) {
  7114. return this.nameToKeyMap[name] in this.values;
  7115. },
  7116. getByName: function CFFDict_getByName(name) {
  7117. if (!(name in this.nameToKeyMap)) {
  7118. error('Invalid dictionary name "' + name + '"');
  7119. }
  7120. var key = this.nameToKeyMap[name];
  7121. if (!(key in this.values)) {
  7122. return this.defaults[key];
  7123. }
  7124. return this.values[key];
  7125. },
  7126. removeByName: function CFFDict_removeByName(name) {
  7127. delete this.values[this.nameToKeyMap[name]];
  7128. }
  7129. };
  7130. CFFDict.createTables = function CFFDict_createTables(layout) {
  7131. var tables = {
  7132. keyToNameMap: {},
  7133. nameToKeyMap: {},
  7134. defaults: {},
  7135. types: {},
  7136. opcodes: {},
  7137. order: []
  7138. };
  7139. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7140. var entry = layout[i];
  7141. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7142. tables.keyToNameMap[key] = entry[1];
  7143. tables.nameToKeyMap[entry[1]] = key;
  7144. tables.types[key] = entry[2];
  7145. tables.defaults[key] = entry[3];
  7146. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7147. tables.order.push(key);
  7148. }
  7149. return tables;
  7150. };
  7151. return CFFDict;
  7152. }();
  7153. var CFFTopDict = function CFFTopDictClosure() {
  7154. var layout = [
  7155. [
  7156. [
  7157. 12,
  7158. 30
  7159. ],
  7160. 'ROS',
  7161. [
  7162. 'sid',
  7163. 'sid',
  7164. 'num'
  7165. ],
  7166. null
  7167. ],
  7168. [
  7169. [
  7170. 12,
  7171. 20
  7172. ],
  7173. 'SyntheticBase',
  7174. 'num',
  7175. null
  7176. ],
  7177. [
  7178. 0,
  7179. 'version',
  7180. 'sid',
  7181. null
  7182. ],
  7183. [
  7184. 1,
  7185. 'Notice',
  7186. 'sid',
  7187. null
  7188. ],
  7189. [
  7190. [
  7191. 12,
  7192. 0
  7193. ],
  7194. 'Copyright',
  7195. 'sid',
  7196. null
  7197. ],
  7198. [
  7199. 2,
  7200. 'FullName',
  7201. 'sid',
  7202. null
  7203. ],
  7204. [
  7205. 3,
  7206. 'FamilyName',
  7207. 'sid',
  7208. null
  7209. ],
  7210. [
  7211. 4,
  7212. 'Weight',
  7213. 'sid',
  7214. null
  7215. ],
  7216. [
  7217. [
  7218. 12,
  7219. 1
  7220. ],
  7221. 'isFixedPitch',
  7222. 'num',
  7223. 0
  7224. ],
  7225. [
  7226. [
  7227. 12,
  7228. 2
  7229. ],
  7230. 'ItalicAngle',
  7231. 'num',
  7232. 0
  7233. ],
  7234. [
  7235. [
  7236. 12,
  7237. 3
  7238. ],
  7239. 'UnderlinePosition',
  7240. 'num',
  7241. -100
  7242. ],
  7243. [
  7244. [
  7245. 12,
  7246. 4
  7247. ],
  7248. 'UnderlineThickness',
  7249. 'num',
  7250. 50
  7251. ],
  7252. [
  7253. [
  7254. 12,
  7255. 5
  7256. ],
  7257. 'PaintType',
  7258. 'num',
  7259. 0
  7260. ],
  7261. [
  7262. [
  7263. 12,
  7264. 6
  7265. ],
  7266. 'CharstringType',
  7267. 'num',
  7268. 2
  7269. ],
  7270. [
  7271. [
  7272. 12,
  7273. 7
  7274. ],
  7275. 'FontMatrix',
  7276. [
  7277. 'num',
  7278. 'num',
  7279. 'num',
  7280. 'num',
  7281. 'num',
  7282. 'num'
  7283. ],
  7284. [
  7285. 0.001,
  7286. 0,
  7287. 0,
  7288. 0.001,
  7289. 0,
  7290. 0
  7291. ]
  7292. ],
  7293. [
  7294. 13,
  7295. 'UniqueID',
  7296. 'num',
  7297. null
  7298. ],
  7299. [
  7300. 5,
  7301. 'FontBBox',
  7302. [
  7303. 'num',
  7304. 'num',
  7305. 'num',
  7306. 'num'
  7307. ],
  7308. [
  7309. 0,
  7310. 0,
  7311. 0,
  7312. 0
  7313. ]
  7314. ],
  7315. [
  7316. [
  7317. 12,
  7318. 8
  7319. ],
  7320. 'StrokeWidth',
  7321. 'num',
  7322. 0
  7323. ],
  7324. [
  7325. 14,
  7326. 'XUID',
  7327. 'array',
  7328. null
  7329. ],
  7330. [
  7331. 15,
  7332. 'charset',
  7333. 'offset',
  7334. 0
  7335. ],
  7336. [
  7337. 16,
  7338. 'Encoding',
  7339. 'offset',
  7340. 0
  7341. ],
  7342. [
  7343. 17,
  7344. 'CharStrings',
  7345. 'offset',
  7346. 0
  7347. ],
  7348. [
  7349. 18,
  7350. 'Private',
  7351. [
  7352. 'offset',
  7353. 'offset'
  7354. ],
  7355. null
  7356. ],
  7357. [
  7358. [
  7359. 12,
  7360. 21
  7361. ],
  7362. 'PostScript',
  7363. 'sid',
  7364. null
  7365. ],
  7366. [
  7367. [
  7368. 12,
  7369. 22
  7370. ],
  7371. 'BaseFontName',
  7372. 'sid',
  7373. null
  7374. ],
  7375. [
  7376. [
  7377. 12,
  7378. 23
  7379. ],
  7380. 'BaseFontBlend',
  7381. 'delta',
  7382. null
  7383. ],
  7384. [
  7385. [
  7386. 12,
  7387. 31
  7388. ],
  7389. 'CIDFontVersion',
  7390. 'num',
  7391. 0
  7392. ],
  7393. [
  7394. [
  7395. 12,
  7396. 32
  7397. ],
  7398. 'CIDFontRevision',
  7399. 'num',
  7400. 0
  7401. ],
  7402. [
  7403. [
  7404. 12,
  7405. 33
  7406. ],
  7407. 'CIDFontType',
  7408. 'num',
  7409. 0
  7410. ],
  7411. [
  7412. [
  7413. 12,
  7414. 34
  7415. ],
  7416. 'CIDCount',
  7417. 'num',
  7418. 8720
  7419. ],
  7420. [
  7421. [
  7422. 12,
  7423. 35
  7424. ],
  7425. 'UIDBase',
  7426. 'num',
  7427. null
  7428. ],
  7429. [
  7430. [
  7431. 12,
  7432. 37
  7433. ],
  7434. 'FDSelect',
  7435. 'offset',
  7436. null
  7437. ],
  7438. [
  7439. [
  7440. 12,
  7441. 36
  7442. ],
  7443. 'FDArray',
  7444. 'offset',
  7445. null
  7446. ],
  7447. [
  7448. [
  7449. 12,
  7450. 38
  7451. ],
  7452. 'FontName',
  7453. 'sid',
  7454. null
  7455. ]
  7456. ];
  7457. var tables = null;
  7458. function CFFTopDict(strings) {
  7459. if (tables === null) {
  7460. tables = CFFDict.createTables(layout);
  7461. }
  7462. CFFDict.call(this, tables, strings);
  7463. this.privateDict = null;
  7464. }
  7465. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7466. return CFFTopDict;
  7467. }();
  7468. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7469. var layout = [
  7470. [
  7471. 6,
  7472. 'BlueValues',
  7473. 'delta',
  7474. null
  7475. ],
  7476. [
  7477. 7,
  7478. 'OtherBlues',
  7479. 'delta',
  7480. null
  7481. ],
  7482. [
  7483. 8,
  7484. 'FamilyBlues',
  7485. 'delta',
  7486. null
  7487. ],
  7488. [
  7489. 9,
  7490. 'FamilyOtherBlues',
  7491. 'delta',
  7492. null
  7493. ],
  7494. [
  7495. [
  7496. 12,
  7497. 9
  7498. ],
  7499. 'BlueScale',
  7500. 'num',
  7501. 0.039625
  7502. ],
  7503. [
  7504. [
  7505. 12,
  7506. 10
  7507. ],
  7508. 'BlueShift',
  7509. 'num',
  7510. 7
  7511. ],
  7512. [
  7513. [
  7514. 12,
  7515. 11
  7516. ],
  7517. 'BlueFuzz',
  7518. 'num',
  7519. 1
  7520. ],
  7521. [
  7522. 10,
  7523. 'StdHW',
  7524. 'num',
  7525. null
  7526. ],
  7527. [
  7528. 11,
  7529. 'StdVW',
  7530. 'num',
  7531. null
  7532. ],
  7533. [
  7534. [
  7535. 12,
  7536. 12
  7537. ],
  7538. 'StemSnapH',
  7539. 'delta',
  7540. null
  7541. ],
  7542. [
  7543. [
  7544. 12,
  7545. 13
  7546. ],
  7547. 'StemSnapV',
  7548. 'delta',
  7549. null
  7550. ],
  7551. [
  7552. [
  7553. 12,
  7554. 14
  7555. ],
  7556. 'ForceBold',
  7557. 'num',
  7558. 0
  7559. ],
  7560. [
  7561. [
  7562. 12,
  7563. 17
  7564. ],
  7565. 'LanguageGroup',
  7566. 'num',
  7567. 0
  7568. ],
  7569. [
  7570. [
  7571. 12,
  7572. 18
  7573. ],
  7574. 'ExpansionFactor',
  7575. 'num',
  7576. 0.06
  7577. ],
  7578. [
  7579. [
  7580. 12,
  7581. 19
  7582. ],
  7583. 'initialRandomSeed',
  7584. 'num',
  7585. 0
  7586. ],
  7587. [
  7588. 20,
  7589. 'defaultWidthX',
  7590. 'num',
  7591. 0
  7592. ],
  7593. [
  7594. 21,
  7595. 'nominalWidthX',
  7596. 'num',
  7597. 0
  7598. ],
  7599. [
  7600. 19,
  7601. 'Subrs',
  7602. 'offset',
  7603. null
  7604. ]
  7605. ];
  7606. var tables = null;
  7607. function CFFPrivateDict(strings) {
  7608. if (tables === null) {
  7609. tables = CFFDict.createTables(layout);
  7610. }
  7611. CFFDict.call(this, tables, strings);
  7612. this.subrsIndex = null;
  7613. }
  7614. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7615. return CFFPrivateDict;
  7616. }();
  7617. var CFFCharsetPredefinedTypes = {
  7618. ISO_ADOBE: 0,
  7619. EXPERT: 1,
  7620. EXPERT_SUBSET: 2
  7621. };
  7622. var CFFCharset = function CFFCharsetClosure() {
  7623. function CFFCharset(predefined, format, charset, raw) {
  7624. this.predefined = predefined;
  7625. this.format = format;
  7626. this.charset = charset;
  7627. this.raw = raw;
  7628. }
  7629. return CFFCharset;
  7630. }();
  7631. var CFFEncoding = function CFFEncodingClosure() {
  7632. function CFFEncoding(predefined, format, encoding, raw) {
  7633. this.predefined = predefined;
  7634. this.format = format;
  7635. this.encoding = encoding;
  7636. this.raw = raw;
  7637. }
  7638. return CFFEncoding;
  7639. }();
  7640. var CFFFDSelect = function CFFFDSelectClosure() {
  7641. function CFFFDSelect(fdSelect, raw) {
  7642. this.fdSelect = fdSelect;
  7643. this.raw = raw;
  7644. }
  7645. CFFFDSelect.prototype = {
  7646. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7647. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7648. return -1;
  7649. }
  7650. return this.fdSelect[glyphIndex];
  7651. }
  7652. };
  7653. return CFFFDSelect;
  7654. }();
  7655. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7656. function CFFOffsetTracker() {
  7657. this.offsets = Object.create(null);
  7658. }
  7659. CFFOffsetTracker.prototype = {
  7660. isTracking: function CFFOffsetTracker_isTracking(key) {
  7661. return key in this.offsets;
  7662. },
  7663. track: function CFFOffsetTracker_track(key, location) {
  7664. if (key in this.offsets) {
  7665. error('Already tracking location of ' + key);
  7666. }
  7667. this.offsets[key] = location;
  7668. },
  7669. offset: function CFFOffsetTracker_offset(value) {
  7670. for (var key in this.offsets) {
  7671. this.offsets[key] += value;
  7672. }
  7673. },
  7674. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7675. if (!(key in this.offsets)) {
  7676. error('Not tracking location of ' + key);
  7677. }
  7678. var data = output.data;
  7679. var dataOffset = this.offsets[key];
  7680. var size = 5;
  7681. for (var i = 0, ii = values.length; i < ii; ++i) {
  7682. var offset0 = i * size + dataOffset;
  7683. var offset1 = offset0 + 1;
  7684. var offset2 = offset0 + 2;
  7685. var offset3 = offset0 + 3;
  7686. var offset4 = offset0 + 4;
  7687. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7688. error('writing to an offset that is not empty');
  7689. }
  7690. var value = values[i];
  7691. data[offset0] = 0x1d;
  7692. data[offset1] = value >> 24 & 0xFF;
  7693. data[offset2] = value >> 16 & 0xFF;
  7694. data[offset3] = value >> 8 & 0xFF;
  7695. data[offset4] = value & 0xFF;
  7696. }
  7697. }
  7698. };
  7699. return CFFOffsetTracker;
  7700. }();
  7701. var CFFCompiler = function CFFCompilerClosure() {
  7702. function CFFCompiler(cff) {
  7703. this.cff = cff;
  7704. }
  7705. CFFCompiler.prototype = {
  7706. compile: function CFFCompiler_compile() {
  7707. var cff = this.cff;
  7708. var output = {
  7709. data: [],
  7710. length: 0,
  7711. add: function CFFCompiler_add(data) {
  7712. this.data = this.data.concat(data);
  7713. this.length = this.data.length;
  7714. }
  7715. };
  7716. var header = this.compileHeader(cff.header);
  7717. output.add(header);
  7718. var nameIndex = this.compileNameIndex(cff.names);
  7719. output.add(nameIndex);
  7720. if (cff.isCIDFont) {
  7721. if (cff.topDict.hasName('FontMatrix')) {
  7722. var base = cff.topDict.getByName('FontMatrix');
  7723. cff.topDict.removeByName('FontMatrix');
  7724. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7725. var subDict = cff.fdArray[i];
  7726. var matrix = base.slice(0);
  7727. if (subDict.hasName('FontMatrix')) {
  7728. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7729. }
  7730. subDict.setByName('FontMatrix', matrix);
  7731. }
  7732. }
  7733. }
  7734. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7735. output.add(compiled.output);
  7736. var topDictTracker = compiled.trackers[0];
  7737. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7738. output.add(stringIndex);
  7739. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7740. output.add(globalSubrIndex);
  7741. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7742. if (cff.encoding.predefined) {
  7743. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7744. } else {
  7745. var encoding = this.compileEncoding(cff.encoding);
  7746. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7747. output.add(encoding);
  7748. }
  7749. }
  7750. if (cff.charset && cff.topDict.hasName('charset')) {
  7751. if (cff.charset.predefined) {
  7752. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7753. } else {
  7754. var charset = this.compileCharset(cff.charset);
  7755. topDictTracker.setEntryLocation('charset', [output.length], output);
  7756. output.add(charset);
  7757. }
  7758. }
  7759. var charStrings = this.compileCharStrings(cff.charStrings);
  7760. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7761. output.add(charStrings);
  7762. if (cff.isCIDFont) {
  7763. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7764. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7765. output.add(fdSelect);
  7766. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7767. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7768. output.add(compiled.output);
  7769. var fontDictTrackers = compiled.trackers;
  7770. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7771. }
  7772. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7773. output.add([0]);
  7774. return output.data;
  7775. },
  7776. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7777. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7778. return this.encodeInteger(value);
  7779. } else {
  7780. return this.encodeFloat(value);
  7781. }
  7782. },
  7783. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7784. var value = num.toString();
  7785. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7786. if (m) {
  7787. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7788. value = (Math.round(num * epsilon) / epsilon).toString();
  7789. }
  7790. var nibbles = '';
  7791. var i, ii;
  7792. for (i = 0, ii = value.length; i < ii; ++i) {
  7793. var a = value[i];
  7794. if (a === 'e') {
  7795. nibbles += value[++i] === '-' ? 'c' : 'b';
  7796. } else if (a === '.') {
  7797. nibbles += 'a';
  7798. } else if (a === '-') {
  7799. nibbles += 'e';
  7800. } else {
  7801. nibbles += a;
  7802. }
  7803. }
  7804. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7805. var out = [30];
  7806. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7807. out.push(parseInt(nibbles.substr(i, 2), 16));
  7808. }
  7809. return out;
  7810. },
  7811. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7812. var code;
  7813. if (value >= -107 && value <= 107) {
  7814. code = [value + 139];
  7815. } else if (value >= 108 && value <= 1131) {
  7816. value = value - 108;
  7817. code = [
  7818. (value >> 8) + 247,
  7819. value & 0xFF
  7820. ];
  7821. } else if (value >= -1131 && value <= -108) {
  7822. value = -value - 108;
  7823. code = [
  7824. (value >> 8) + 251,
  7825. value & 0xFF
  7826. ];
  7827. } else if (value >= -32768 && value <= 32767) {
  7828. code = [
  7829. 0x1c,
  7830. value >> 8 & 0xFF,
  7831. value & 0xFF
  7832. ];
  7833. } else {
  7834. code = [
  7835. 0x1d,
  7836. value >> 24 & 0xFF,
  7837. value >> 16 & 0xFF,
  7838. value >> 8 & 0xFF,
  7839. value & 0xFF
  7840. ];
  7841. }
  7842. return code;
  7843. },
  7844. compileHeader: function CFFCompiler_compileHeader(header) {
  7845. return [
  7846. header.major,
  7847. header.minor,
  7848. header.hdrSize,
  7849. header.offSize
  7850. ];
  7851. },
  7852. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7853. var nameIndex = new CFFIndex();
  7854. for (var i = 0, ii = names.length; i < ii; ++i) {
  7855. nameIndex.add(stringToBytes(names[i]));
  7856. }
  7857. return this.compileIndex(nameIndex);
  7858. },
  7859. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7860. var fontDictTrackers = [];
  7861. var fdArrayIndex = new CFFIndex();
  7862. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7863. var fontDict = dicts[i];
  7864. if (removeCidKeys) {
  7865. fontDict.removeByName('CIDFontVersion');
  7866. fontDict.removeByName('CIDFontRevision');
  7867. fontDict.removeByName('CIDFontType');
  7868. fontDict.removeByName('CIDCount');
  7869. fontDict.removeByName('UIDBase');
  7870. }
  7871. var fontDictTracker = new CFFOffsetTracker();
  7872. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7873. fontDictTrackers.push(fontDictTracker);
  7874. fdArrayIndex.add(fontDictData);
  7875. fontDictTracker.offset(length);
  7876. }
  7877. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7878. return {
  7879. trackers: fontDictTrackers,
  7880. output: fdArrayIndex
  7881. };
  7882. },
  7883. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7884. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7885. var fontDict = dicts[i];
  7886. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7887. var privateDict = fontDict.privateDict;
  7888. var privateDictTracker = new CFFOffsetTracker();
  7889. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7890. var outputLength = output.length;
  7891. privateDictTracker.offset(outputLength);
  7892. if (!privateDictData.length) {
  7893. outputLength = 0;
  7894. }
  7895. trackers[i].setEntryLocation('Private', [
  7896. privateDictData.length,
  7897. outputLength
  7898. ], output);
  7899. output.add(privateDictData);
  7900. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7901. var subrs = this.compileIndex(privateDict.subrsIndex);
  7902. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7903. output.add(subrs);
  7904. }
  7905. }
  7906. },
  7907. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7908. var out = [];
  7909. var order = dict.order;
  7910. for (var i = 0; i < order.length; ++i) {
  7911. var key = order[i];
  7912. if (!(key in dict.values)) {
  7913. continue;
  7914. }
  7915. var values = dict.values[key];
  7916. var types = dict.types[key];
  7917. if (!isArray(types)) {
  7918. types = [types];
  7919. }
  7920. if (!isArray(values)) {
  7921. values = [values];
  7922. }
  7923. if (values.length === 0) {
  7924. continue;
  7925. }
  7926. for (var j = 0, jj = types.length; j < jj; ++j) {
  7927. var type = types[j];
  7928. var value = values[j];
  7929. switch (type) {
  7930. case 'num':
  7931. case 'sid':
  7932. out = out.concat(this.encodeNumber(value));
  7933. break;
  7934. case 'offset':
  7935. var name = dict.keyToNameMap[key];
  7936. if (!offsetTracker.isTracking(name)) {
  7937. offsetTracker.track(name, out.length);
  7938. }
  7939. out = out.concat([
  7940. 0x1d,
  7941. 0,
  7942. 0,
  7943. 0,
  7944. 0
  7945. ]);
  7946. break;
  7947. case 'array':
  7948. case 'delta':
  7949. out = out.concat(this.encodeNumber(value));
  7950. for (var k = 1, kk = values.length; k < kk; ++k) {
  7951. out = out.concat(this.encodeNumber(values[k]));
  7952. }
  7953. break;
  7954. default:
  7955. error('Unknown data type of ' + type);
  7956. break;
  7957. }
  7958. }
  7959. out = out.concat(dict.opcodes[key]);
  7960. }
  7961. return out;
  7962. },
  7963. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7964. var stringIndex = new CFFIndex();
  7965. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7966. stringIndex.add(stringToBytes(strings[i]));
  7967. }
  7968. return this.compileIndex(stringIndex);
  7969. },
  7970. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7971. var globalSubrIndex = this.cff.globalSubrIndex;
  7972. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7973. },
  7974. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7975. return this.compileIndex(charStrings);
  7976. },
  7977. compileCharset: function CFFCompiler_compileCharset(charset) {
  7978. return this.compileTypedArray(charset.raw);
  7979. },
  7980. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7981. return this.compileTypedArray(encoding.raw);
  7982. },
  7983. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7984. return this.compileTypedArray(fdSelect);
  7985. },
  7986. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7987. var out = [];
  7988. for (var i = 0, ii = data.length; i < ii; ++i) {
  7989. out[i] = data[i];
  7990. }
  7991. return out;
  7992. },
  7993. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7994. trackers = trackers || [];
  7995. var objects = index.objects;
  7996. var count = objects.length;
  7997. if (count === 0) {
  7998. return [
  7999. 0,
  8000. 0,
  8001. 0
  8002. ];
  8003. }
  8004. var data = [
  8005. count >> 8 & 0xFF,
  8006. count & 0xff
  8007. ];
  8008. var lastOffset = 1, i;
  8009. for (i = 0; i < count; ++i) {
  8010. lastOffset += objects[i].length;
  8011. }
  8012. var offsetSize;
  8013. if (lastOffset < 0x100) {
  8014. offsetSize = 1;
  8015. } else if (lastOffset < 0x10000) {
  8016. offsetSize = 2;
  8017. } else if (lastOffset < 0x1000000) {
  8018. offsetSize = 3;
  8019. } else {
  8020. offsetSize = 4;
  8021. }
  8022. data.push(offsetSize);
  8023. var relativeOffset = 1;
  8024. for (i = 0; i < count + 1; i++) {
  8025. if (offsetSize === 1) {
  8026. data.push(relativeOffset & 0xFF);
  8027. } else if (offsetSize === 2) {
  8028. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8029. } else if (offsetSize === 3) {
  8030. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8031. } else {
  8032. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. }
  8034. if (objects[i]) {
  8035. relativeOffset += objects[i].length;
  8036. }
  8037. }
  8038. for (i = 0; i < count; i++) {
  8039. if (trackers[i]) {
  8040. trackers[i].offset(data.length);
  8041. }
  8042. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8043. data.push(objects[i][j]);
  8044. }
  8045. }
  8046. return data;
  8047. }
  8048. };
  8049. return CFFCompiler;
  8050. }();
  8051. exports.CFFStandardStrings = CFFStandardStrings;
  8052. exports.CFFParser = CFFParser;
  8053. exports.CFF = CFF;
  8054. exports.CFFHeader = CFFHeader;
  8055. exports.CFFStrings = CFFStrings;
  8056. exports.CFFIndex = CFFIndex;
  8057. exports.CFFCharset = CFFCharset;
  8058. exports.CFFTopDict = CFFTopDict;
  8059. exports.CFFPrivateDict = CFFPrivateDict;
  8060. exports.CFFCompiler = CFFCompiler;
  8061. }));
  8062. (function (root, factory) {
  8063. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8064. }(this, function (exports, sharedUtil) {
  8065. var MissingDataException = sharedUtil.MissingDataException;
  8066. var arrayByteLength = sharedUtil.arrayByteLength;
  8067. var arraysToBytes = sharedUtil.arraysToBytes;
  8068. var assert = sharedUtil.assert;
  8069. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8070. var isInt = sharedUtil.isInt;
  8071. var isEmptyObj = sharedUtil.isEmptyObj;
  8072. var ChunkedStream = function ChunkedStreamClosure() {
  8073. function ChunkedStream(length, chunkSize, manager) {
  8074. this.bytes = new Uint8Array(length);
  8075. this.start = 0;
  8076. this.pos = 0;
  8077. this.end = length;
  8078. this.chunkSize = chunkSize;
  8079. this.loadedChunks = [];
  8080. this.numChunksLoaded = 0;
  8081. this.numChunks = Math.ceil(length / chunkSize);
  8082. this.manager = manager;
  8083. this.progressiveDataLength = 0;
  8084. this.lastSuccessfulEnsureByteChunk = -1;
  8085. }
  8086. ChunkedStream.prototype = {
  8087. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8088. var chunks = [];
  8089. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8090. if (!this.loadedChunks[chunk]) {
  8091. chunks.push(chunk);
  8092. }
  8093. }
  8094. return chunks;
  8095. },
  8096. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8097. return [this];
  8098. },
  8099. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8100. return this.numChunksLoaded === this.numChunks;
  8101. },
  8102. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8103. var end = begin + chunk.byteLength;
  8104. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8105. var length = this.bytes.length;
  8106. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8107. this.bytes.set(new Uint8Array(chunk), begin);
  8108. var chunkSize = this.chunkSize;
  8109. var beginChunk = Math.floor(begin / chunkSize);
  8110. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8111. var curChunk;
  8112. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8113. if (!this.loadedChunks[curChunk]) {
  8114. this.loadedChunks[curChunk] = true;
  8115. ++this.numChunksLoaded;
  8116. }
  8117. }
  8118. },
  8119. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8120. var position = this.progressiveDataLength;
  8121. var beginChunk = Math.floor(position / this.chunkSize);
  8122. this.bytes.set(new Uint8Array(data), position);
  8123. position += data.byteLength;
  8124. this.progressiveDataLength = position;
  8125. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8126. var curChunk;
  8127. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8128. if (!this.loadedChunks[curChunk]) {
  8129. this.loadedChunks[curChunk] = true;
  8130. ++this.numChunksLoaded;
  8131. }
  8132. }
  8133. },
  8134. ensureByte: function ChunkedStream_ensureByte(pos) {
  8135. var chunk = Math.floor(pos / this.chunkSize);
  8136. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8137. return;
  8138. }
  8139. if (!this.loadedChunks[chunk]) {
  8140. throw new MissingDataException(pos, pos + 1);
  8141. }
  8142. this.lastSuccessfulEnsureByteChunk = chunk;
  8143. },
  8144. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8145. if (begin >= end) {
  8146. return;
  8147. }
  8148. if (end <= this.progressiveDataLength) {
  8149. return;
  8150. }
  8151. var chunkSize = this.chunkSize;
  8152. var beginChunk = Math.floor(begin / chunkSize);
  8153. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8154. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8155. if (!this.loadedChunks[chunk]) {
  8156. throw new MissingDataException(begin, end);
  8157. }
  8158. }
  8159. },
  8160. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8161. var chunk, numChunks = this.numChunks;
  8162. for (var i = 0; i < numChunks; ++i) {
  8163. chunk = (beginChunk + i) % numChunks;
  8164. if (!this.loadedChunks[chunk]) {
  8165. return chunk;
  8166. }
  8167. }
  8168. return null;
  8169. },
  8170. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8171. return !!this.loadedChunks[chunk];
  8172. },
  8173. get length() {
  8174. return this.end - this.start;
  8175. },
  8176. get isEmpty() {
  8177. return this.length === 0;
  8178. },
  8179. getByte: function ChunkedStream_getByte() {
  8180. var pos = this.pos;
  8181. if (pos >= this.end) {
  8182. return -1;
  8183. }
  8184. this.ensureByte(pos);
  8185. return this.bytes[this.pos++];
  8186. },
  8187. getUint16: function ChunkedStream_getUint16() {
  8188. var b0 = this.getByte();
  8189. var b1 = this.getByte();
  8190. if (b0 === -1 || b1 === -1) {
  8191. return -1;
  8192. }
  8193. return (b0 << 8) + b1;
  8194. },
  8195. getInt32: function ChunkedStream_getInt32() {
  8196. var b0 = this.getByte();
  8197. var b1 = this.getByte();
  8198. var b2 = this.getByte();
  8199. var b3 = this.getByte();
  8200. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8201. },
  8202. getBytes: function ChunkedStream_getBytes(length) {
  8203. var bytes = this.bytes;
  8204. var pos = this.pos;
  8205. var strEnd = this.end;
  8206. if (!length) {
  8207. this.ensureRange(pos, strEnd);
  8208. return bytes.subarray(pos, strEnd);
  8209. }
  8210. var end = pos + length;
  8211. if (end > strEnd) {
  8212. end = strEnd;
  8213. }
  8214. this.ensureRange(pos, end);
  8215. this.pos = end;
  8216. return bytes.subarray(pos, end);
  8217. },
  8218. peekByte: function ChunkedStream_peekByte() {
  8219. var peekedByte = this.getByte();
  8220. this.pos--;
  8221. return peekedByte;
  8222. },
  8223. peekBytes: function ChunkedStream_peekBytes(length) {
  8224. var bytes = this.getBytes(length);
  8225. this.pos -= bytes.length;
  8226. return bytes;
  8227. },
  8228. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8229. this.ensureRange(begin, end);
  8230. return this.bytes.subarray(begin, end);
  8231. },
  8232. skip: function ChunkedStream_skip(n) {
  8233. if (!n) {
  8234. n = 1;
  8235. }
  8236. this.pos += n;
  8237. },
  8238. reset: function ChunkedStream_reset() {
  8239. this.pos = this.start;
  8240. },
  8241. moveStart: function ChunkedStream_moveStart() {
  8242. this.start = this.pos;
  8243. },
  8244. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8245. this.ensureRange(start, start + length);
  8246. function ChunkedStreamSubstream() {
  8247. }
  8248. ChunkedStreamSubstream.prototype = Object.create(this);
  8249. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8250. var chunkSize = this.chunkSize;
  8251. var beginChunk = Math.floor(this.start / chunkSize);
  8252. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8253. var missingChunks = [];
  8254. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8255. if (!this.loadedChunks[chunk]) {
  8256. missingChunks.push(chunk);
  8257. }
  8258. }
  8259. return missingChunks;
  8260. };
  8261. var subStream = new ChunkedStreamSubstream();
  8262. subStream.pos = subStream.start = start;
  8263. subStream.end = start + length || this.end;
  8264. subStream.dict = dict;
  8265. return subStream;
  8266. },
  8267. isStream: true
  8268. };
  8269. return ChunkedStream;
  8270. }();
  8271. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8272. function ChunkedStreamManager(pdfNetworkStream, args) {
  8273. var chunkSize = args.rangeChunkSize;
  8274. var length = args.length;
  8275. this.stream = new ChunkedStream(length, chunkSize, this);
  8276. this.length = length;
  8277. this.chunkSize = chunkSize;
  8278. this.pdfNetworkStream = pdfNetworkStream;
  8279. this.url = args.url;
  8280. this.disableAutoFetch = args.disableAutoFetch;
  8281. this.msgHandler = args.msgHandler;
  8282. this.currRequestId = 0;
  8283. this.chunksNeededByRequest = Object.create(null);
  8284. this.requestsByChunk = Object.create(null);
  8285. this.promisesByRequest = Object.create(null);
  8286. this.progressiveDataLength = 0;
  8287. this.aborted = false;
  8288. this._loadedStreamCapability = createPromiseCapability();
  8289. }
  8290. ChunkedStreamManager.prototype = {
  8291. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8292. return this._loadedStreamCapability.promise;
  8293. },
  8294. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8295. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8296. if (!rangeReader.isStreamingSupported) {
  8297. rangeReader.onProgress = this.onProgress.bind(this);
  8298. }
  8299. var chunks = [], loaded = 0;
  8300. var manager = this;
  8301. var promise = new Promise(function (resolve, reject) {
  8302. var readChunk = function (chunk) {
  8303. try {
  8304. if (!chunk.done) {
  8305. var data = chunk.value;
  8306. chunks.push(data);
  8307. loaded += arrayByteLength(data);
  8308. if (rangeReader.isStreamingSupported) {
  8309. manager.onProgress({ loaded: loaded });
  8310. }
  8311. rangeReader.read().then(readChunk, reject);
  8312. return;
  8313. }
  8314. var chunkData = arraysToBytes(chunks);
  8315. chunks = null;
  8316. resolve(chunkData);
  8317. } catch (e) {
  8318. reject(e);
  8319. }
  8320. };
  8321. rangeReader.read().then(readChunk, reject);
  8322. });
  8323. promise.then(function (data) {
  8324. if (this.aborted) {
  8325. return;
  8326. }
  8327. this.onReceiveData({
  8328. chunk: data,
  8329. begin: begin
  8330. });
  8331. }.bind(this));
  8332. },
  8333. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8334. var missingChunks = this.stream.getMissingChunks();
  8335. this._requestChunks(missingChunks);
  8336. return this._loadedStreamCapability.promise;
  8337. },
  8338. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8339. var requestId = this.currRequestId++;
  8340. var i, ii;
  8341. var chunksNeeded = Object.create(null);
  8342. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8343. for (i = 0, ii = chunks.length; i < ii; i++) {
  8344. if (!this.stream.hasChunk(chunks[i])) {
  8345. chunksNeeded[chunks[i]] = true;
  8346. }
  8347. }
  8348. if (isEmptyObj(chunksNeeded)) {
  8349. return Promise.resolve();
  8350. }
  8351. var capability = createPromiseCapability();
  8352. this.promisesByRequest[requestId] = capability;
  8353. var chunksToRequest = [];
  8354. for (var chunk in chunksNeeded) {
  8355. chunk = chunk | 0;
  8356. if (!(chunk in this.requestsByChunk)) {
  8357. this.requestsByChunk[chunk] = [];
  8358. chunksToRequest.push(chunk);
  8359. }
  8360. this.requestsByChunk[chunk].push(requestId);
  8361. }
  8362. if (!chunksToRequest.length) {
  8363. return capability.promise;
  8364. }
  8365. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8366. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8367. var groupedChunk = groupedChunksToRequest[i];
  8368. var begin = groupedChunk.beginChunk * this.chunkSize;
  8369. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8370. this.sendRequest(begin, end);
  8371. }
  8372. return capability.promise;
  8373. },
  8374. getStream: function ChunkedStreamManager_getStream() {
  8375. return this.stream;
  8376. },
  8377. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8378. end = Math.min(end, this.length);
  8379. var beginChunk = this.getBeginChunk(begin);
  8380. var endChunk = this.getEndChunk(end);
  8381. var chunks = [];
  8382. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8383. chunks.push(chunk);
  8384. }
  8385. return this._requestChunks(chunks);
  8386. },
  8387. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8388. ranges = ranges || [];
  8389. var chunksToRequest = [];
  8390. for (var i = 0; i < ranges.length; i++) {
  8391. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8392. var endChunk = this.getEndChunk(ranges[i].end);
  8393. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8394. if (chunksToRequest.indexOf(chunk) < 0) {
  8395. chunksToRequest.push(chunk);
  8396. }
  8397. }
  8398. }
  8399. chunksToRequest.sort(function (a, b) {
  8400. return a - b;
  8401. });
  8402. return this._requestChunks(chunksToRequest);
  8403. },
  8404. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8405. var groupedChunks = [];
  8406. var beginChunk = -1;
  8407. var prevChunk = -1;
  8408. for (var i = 0; i < chunks.length; ++i) {
  8409. var chunk = chunks[i];
  8410. if (beginChunk < 0) {
  8411. beginChunk = chunk;
  8412. }
  8413. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8414. groupedChunks.push({
  8415. beginChunk: beginChunk,
  8416. endChunk: prevChunk + 1
  8417. });
  8418. beginChunk = chunk;
  8419. }
  8420. if (i + 1 === chunks.length) {
  8421. groupedChunks.push({
  8422. beginChunk: beginChunk,
  8423. endChunk: chunk + 1
  8424. });
  8425. }
  8426. prevChunk = chunk;
  8427. }
  8428. return groupedChunks;
  8429. },
  8430. onProgress: function ChunkedStreamManager_onProgress(args) {
  8431. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8432. this.msgHandler.send('DocProgress', {
  8433. loaded: bytesLoaded,
  8434. total: this.length
  8435. });
  8436. },
  8437. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8438. var chunk = args.chunk;
  8439. var isProgressive = args.begin === undefined;
  8440. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8441. var end = begin + chunk.byteLength;
  8442. var beginChunk = Math.floor(begin / this.chunkSize);
  8443. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8444. if (isProgressive) {
  8445. this.stream.onReceiveProgressiveData(chunk);
  8446. this.progressiveDataLength = end;
  8447. } else {
  8448. this.stream.onReceiveData(begin, chunk);
  8449. }
  8450. if (this.stream.allChunksLoaded()) {
  8451. this._loadedStreamCapability.resolve(this.stream);
  8452. }
  8453. var loadedRequests = [];
  8454. var i, requestId;
  8455. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8456. var requestIds = this.requestsByChunk[chunk] || [];
  8457. delete this.requestsByChunk[chunk];
  8458. for (i = 0; i < requestIds.length; ++i) {
  8459. requestId = requestIds[i];
  8460. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8461. if (chunk in chunksNeeded) {
  8462. delete chunksNeeded[chunk];
  8463. }
  8464. if (!isEmptyObj(chunksNeeded)) {
  8465. continue;
  8466. }
  8467. loadedRequests.push(requestId);
  8468. }
  8469. }
  8470. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8471. var nextEmptyChunk;
  8472. if (this.stream.numChunksLoaded === 1) {
  8473. var lastChunk = this.stream.numChunks - 1;
  8474. if (!this.stream.hasChunk(lastChunk)) {
  8475. nextEmptyChunk = lastChunk;
  8476. }
  8477. } else {
  8478. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8479. }
  8480. if (isInt(nextEmptyChunk)) {
  8481. this._requestChunks([nextEmptyChunk]);
  8482. }
  8483. }
  8484. for (i = 0; i < loadedRequests.length; ++i) {
  8485. requestId = loadedRequests[i];
  8486. var capability = this.promisesByRequest[requestId];
  8487. delete this.promisesByRequest[requestId];
  8488. capability.resolve();
  8489. }
  8490. this.msgHandler.send('DocProgress', {
  8491. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8492. total: this.length
  8493. });
  8494. },
  8495. onError: function ChunkedStreamManager_onError(err) {
  8496. this._loadedStreamCapability.reject(err);
  8497. },
  8498. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8499. var chunk = Math.floor(begin / this.chunkSize);
  8500. return chunk;
  8501. },
  8502. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8503. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8504. return chunk;
  8505. },
  8506. abort: function ChunkedStreamManager_abort() {
  8507. this.aborted = true;
  8508. if (this.pdfNetworkStream) {
  8509. this.pdfNetworkStream.cancelAllRequests('abort');
  8510. }
  8511. for (var requestId in this.promisesByRequest) {
  8512. var capability = this.promisesByRequest[requestId];
  8513. capability.reject(new Error('Request was aborted'));
  8514. }
  8515. }
  8516. };
  8517. return ChunkedStreamManager;
  8518. }();
  8519. exports.ChunkedStream = ChunkedStream;
  8520. exports.ChunkedStreamManager = ChunkedStreamManager;
  8521. }));
  8522. (function (root, factory) {
  8523. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8524. }(this, function (exports, sharedUtil) {
  8525. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8526. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8527. t['A'] = 0x0041;
  8528. t['AE'] = 0x00C6;
  8529. t['AEacute'] = 0x01FC;
  8530. t['AEmacron'] = 0x01E2;
  8531. t['AEsmall'] = 0xF7E6;
  8532. t['Aacute'] = 0x00C1;
  8533. t['Aacutesmall'] = 0xF7E1;
  8534. t['Abreve'] = 0x0102;
  8535. t['Abreveacute'] = 0x1EAE;
  8536. t['Abrevecyrillic'] = 0x04D0;
  8537. t['Abrevedotbelow'] = 0x1EB6;
  8538. t['Abrevegrave'] = 0x1EB0;
  8539. t['Abrevehookabove'] = 0x1EB2;
  8540. t['Abrevetilde'] = 0x1EB4;
  8541. t['Acaron'] = 0x01CD;
  8542. t['Acircle'] = 0x24B6;
  8543. t['Acircumflex'] = 0x00C2;
  8544. t['Acircumflexacute'] = 0x1EA4;
  8545. t['Acircumflexdotbelow'] = 0x1EAC;
  8546. t['Acircumflexgrave'] = 0x1EA6;
  8547. t['Acircumflexhookabove'] = 0x1EA8;
  8548. t['Acircumflexsmall'] = 0xF7E2;
  8549. t['Acircumflextilde'] = 0x1EAA;
  8550. t['Acute'] = 0xF6C9;
  8551. t['Acutesmall'] = 0xF7B4;
  8552. t['Acyrillic'] = 0x0410;
  8553. t['Adblgrave'] = 0x0200;
  8554. t['Adieresis'] = 0x00C4;
  8555. t['Adieresiscyrillic'] = 0x04D2;
  8556. t['Adieresismacron'] = 0x01DE;
  8557. t['Adieresissmall'] = 0xF7E4;
  8558. t['Adotbelow'] = 0x1EA0;
  8559. t['Adotmacron'] = 0x01E0;
  8560. t['Agrave'] = 0x00C0;
  8561. t['Agravesmall'] = 0xF7E0;
  8562. t['Ahookabove'] = 0x1EA2;
  8563. t['Aiecyrillic'] = 0x04D4;
  8564. t['Ainvertedbreve'] = 0x0202;
  8565. t['Alpha'] = 0x0391;
  8566. t['Alphatonos'] = 0x0386;
  8567. t['Amacron'] = 0x0100;
  8568. t['Amonospace'] = 0xFF21;
  8569. t['Aogonek'] = 0x0104;
  8570. t['Aring'] = 0x00C5;
  8571. t['Aringacute'] = 0x01FA;
  8572. t['Aringbelow'] = 0x1E00;
  8573. t['Aringsmall'] = 0xF7E5;
  8574. t['Asmall'] = 0xF761;
  8575. t['Atilde'] = 0x00C3;
  8576. t['Atildesmall'] = 0xF7E3;
  8577. t['Aybarmenian'] = 0x0531;
  8578. t['B'] = 0x0042;
  8579. t['Bcircle'] = 0x24B7;
  8580. t['Bdotaccent'] = 0x1E02;
  8581. t['Bdotbelow'] = 0x1E04;
  8582. t['Becyrillic'] = 0x0411;
  8583. t['Benarmenian'] = 0x0532;
  8584. t['Beta'] = 0x0392;
  8585. t['Bhook'] = 0x0181;
  8586. t['Blinebelow'] = 0x1E06;
  8587. t['Bmonospace'] = 0xFF22;
  8588. t['Brevesmall'] = 0xF6F4;
  8589. t['Bsmall'] = 0xF762;
  8590. t['Btopbar'] = 0x0182;
  8591. t['C'] = 0x0043;
  8592. t['Caarmenian'] = 0x053E;
  8593. t['Cacute'] = 0x0106;
  8594. t['Caron'] = 0xF6CA;
  8595. t['Caronsmall'] = 0xF6F5;
  8596. t['Ccaron'] = 0x010C;
  8597. t['Ccedilla'] = 0x00C7;
  8598. t['Ccedillaacute'] = 0x1E08;
  8599. t['Ccedillasmall'] = 0xF7E7;
  8600. t['Ccircle'] = 0x24B8;
  8601. t['Ccircumflex'] = 0x0108;
  8602. t['Cdot'] = 0x010A;
  8603. t['Cdotaccent'] = 0x010A;
  8604. t['Cedillasmall'] = 0xF7B8;
  8605. t['Chaarmenian'] = 0x0549;
  8606. t['Cheabkhasiancyrillic'] = 0x04BC;
  8607. t['Checyrillic'] = 0x0427;
  8608. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8609. t['Chedescendercyrillic'] = 0x04B6;
  8610. t['Chedieresiscyrillic'] = 0x04F4;
  8611. t['Cheharmenian'] = 0x0543;
  8612. t['Chekhakassiancyrillic'] = 0x04CB;
  8613. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8614. t['Chi'] = 0x03A7;
  8615. t['Chook'] = 0x0187;
  8616. t['Circumflexsmall'] = 0xF6F6;
  8617. t['Cmonospace'] = 0xFF23;
  8618. t['Coarmenian'] = 0x0551;
  8619. t['Csmall'] = 0xF763;
  8620. t['D'] = 0x0044;
  8621. t['DZ'] = 0x01F1;
  8622. t['DZcaron'] = 0x01C4;
  8623. t['Daarmenian'] = 0x0534;
  8624. t['Dafrican'] = 0x0189;
  8625. t['Dcaron'] = 0x010E;
  8626. t['Dcedilla'] = 0x1E10;
  8627. t['Dcircle'] = 0x24B9;
  8628. t['Dcircumflexbelow'] = 0x1E12;
  8629. t['Dcroat'] = 0x0110;
  8630. t['Ddotaccent'] = 0x1E0A;
  8631. t['Ddotbelow'] = 0x1E0C;
  8632. t['Decyrillic'] = 0x0414;
  8633. t['Deicoptic'] = 0x03EE;
  8634. t['Delta'] = 0x2206;
  8635. t['Deltagreek'] = 0x0394;
  8636. t['Dhook'] = 0x018A;
  8637. t['Dieresis'] = 0xF6CB;
  8638. t['DieresisAcute'] = 0xF6CC;
  8639. t['DieresisGrave'] = 0xF6CD;
  8640. t['Dieresissmall'] = 0xF7A8;
  8641. t['Digammagreek'] = 0x03DC;
  8642. t['Djecyrillic'] = 0x0402;
  8643. t['Dlinebelow'] = 0x1E0E;
  8644. t['Dmonospace'] = 0xFF24;
  8645. t['Dotaccentsmall'] = 0xF6F7;
  8646. t['Dslash'] = 0x0110;
  8647. t['Dsmall'] = 0xF764;
  8648. t['Dtopbar'] = 0x018B;
  8649. t['Dz'] = 0x01F2;
  8650. t['Dzcaron'] = 0x01C5;
  8651. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8652. t['Dzecyrillic'] = 0x0405;
  8653. t['Dzhecyrillic'] = 0x040F;
  8654. t['E'] = 0x0045;
  8655. t['Eacute'] = 0x00C9;
  8656. t['Eacutesmall'] = 0xF7E9;
  8657. t['Ebreve'] = 0x0114;
  8658. t['Ecaron'] = 0x011A;
  8659. t['Ecedillabreve'] = 0x1E1C;
  8660. t['Echarmenian'] = 0x0535;
  8661. t['Ecircle'] = 0x24BA;
  8662. t['Ecircumflex'] = 0x00CA;
  8663. t['Ecircumflexacute'] = 0x1EBE;
  8664. t['Ecircumflexbelow'] = 0x1E18;
  8665. t['Ecircumflexdotbelow'] = 0x1EC6;
  8666. t['Ecircumflexgrave'] = 0x1EC0;
  8667. t['Ecircumflexhookabove'] = 0x1EC2;
  8668. t['Ecircumflexsmall'] = 0xF7EA;
  8669. t['Ecircumflextilde'] = 0x1EC4;
  8670. t['Ecyrillic'] = 0x0404;
  8671. t['Edblgrave'] = 0x0204;
  8672. t['Edieresis'] = 0x00CB;
  8673. t['Edieresissmall'] = 0xF7EB;
  8674. t['Edot'] = 0x0116;
  8675. t['Edotaccent'] = 0x0116;
  8676. t['Edotbelow'] = 0x1EB8;
  8677. t['Efcyrillic'] = 0x0424;
  8678. t['Egrave'] = 0x00C8;
  8679. t['Egravesmall'] = 0xF7E8;
  8680. t['Eharmenian'] = 0x0537;
  8681. t['Ehookabove'] = 0x1EBA;
  8682. t['Eightroman'] = 0x2167;
  8683. t['Einvertedbreve'] = 0x0206;
  8684. t['Eiotifiedcyrillic'] = 0x0464;
  8685. t['Elcyrillic'] = 0x041B;
  8686. t['Elevenroman'] = 0x216A;
  8687. t['Emacron'] = 0x0112;
  8688. t['Emacronacute'] = 0x1E16;
  8689. t['Emacrongrave'] = 0x1E14;
  8690. t['Emcyrillic'] = 0x041C;
  8691. t['Emonospace'] = 0xFF25;
  8692. t['Encyrillic'] = 0x041D;
  8693. t['Endescendercyrillic'] = 0x04A2;
  8694. t['Eng'] = 0x014A;
  8695. t['Enghecyrillic'] = 0x04A4;
  8696. t['Enhookcyrillic'] = 0x04C7;
  8697. t['Eogonek'] = 0x0118;
  8698. t['Eopen'] = 0x0190;
  8699. t['Epsilon'] = 0x0395;
  8700. t['Epsilontonos'] = 0x0388;
  8701. t['Ercyrillic'] = 0x0420;
  8702. t['Ereversed'] = 0x018E;
  8703. t['Ereversedcyrillic'] = 0x042D;
  8704. t['Escyrillic'] = 0x0421;
  8705. t['Esdescendercyrillic'] = 0x04AA;
  8706. t['Esh'] = 0x01A9;
  8707. t['Esmall'] = 0xF765;
  8708. t['Eta'] = 0x0397;
  8709. t['Etarmenian'] = 0x0538;
  8710. t['Etatonos'] = 0x0389;
  8711. t['Eth'] = 0x00D0;
  8712. t['Ethsmall'] = 0xF7F0;
  8713. t['Etilde'] = 0x1EBC;
  8714. t['Etildebelow'] = 0x1E1A;
  8715. t['Euro'] = 0x20AC;
  8716. t['Ezh'] = 0x01B7;
  8717. t['Ezhcaron'] = 0x01EE;
  8718. t['Ezhreversed'] = 0x01B8;
  8719. t['F'] = 0x0046;
  8720. t['Fcircle'] = 0x24BB;
  8721. t['Fdotaccent'] = 0x1E1E;
  8722. t['Feharmenian'] = 0x0556;
  8723. t['Feicoptic'] = 0x03E4;
  8724. t['Fhook'] = 0x0191;
  8725. t['Fitacyrillic'] = 0x0472;
  8726. t['Fiveroman'] = 0x2164;
  8727. t['Fmonospace'] = 0xFF26;
  8728. t['Fourroman'] = 0x2163;
  8729. t['Fsmall'] = 0xF766;
  8730. t['G'] = 0x0047;
  8731. t['GBsquare'] = 0x3387;
  8732. t['Gacute'] = 0x01F4;
  8733. t['Gamma'] = 0x0393;
  8734. t['Gammaafrican'] = 0x0194;
  8735. t['Gangiacoptic'] = 0x03EA;
  8736. t['Gbreve'] = 0x011E;
  8737. t['Gcaron'] = 0x01E6;
  8738. t['Gcedilla'] = 0x0122;
  8739. t['Gcircle'] = 0x24BC;
  8740. t['Gcircumflex'] = 0x011C;
  8741. t['Gcommaaccent'] = 0x0122;
  8742. t['Gdot'] = 0x0120;
  8743. t['Gdotaccent'] = 0x0120;
  8744. t['Gecyrillic'] = 0x0413;
  8745. t['Ghadarmenian'] = 0x0542;
  8746. t['Ghemiddlehookcyrillic'] = 0x0494;
  8747. t['Ghestrokecyrillic'] = 0x0492;
  8748. t['Gheupturncyrillic'] = 0x0490;
  8749. t['Ghook'] = 0x0193;
  8750. t['Gimarmenian'] = 0x0533;
  8751. t['Gjecyrillic'] = 0x0403;
  8752. t['Gmacron'] = 0x1E20;
  8753. t['Gmonospace'] = 0xFF27;
  8754. t['Grave'] = 0xF6CE;
  8755. t['Gravesmall'] = 0xF760;
  8756. t['Gsmall'] = 0xF767;
  8757. t['Gsmallhook'] = 0x029B;
  8758. t['Gstroke'] = 0x01E4;
  8759. t['H'] = 0x0048;
  8760. t['H18533'] = 0x25CF;
  8761. t['H18543'] = 0x25AA;
  8762. t['H18551'] = 0x25AB;
  8763. t['H22073'] = 0x25A1;
  8764. t['HPsquare'] = 0x33CB;
  8765. t['Haabkhasiancyrillic'] = 0x04A8;
  8766. t['Hadescendercyrillic'] = 0x04B2;
  8767. t['Hardsigncyrillic'] = 0x042A;
  8768. t['Hbar'] = 0x0126;
  8769. t['Hbrevebelow'] = 0x1E2A;
  8770. t['Hcedilla'] = 0x1E28;
  8771. t['Hcircle'] = 0x24BD;
  8772. t['Hcircumflex'] = 0x0124;
  8773. t['Hdieresis'] = 0x1E26;
  8774. t['Hdotaccent'] = 0x1E22;
  8775. t['Hdotbelow'] = 0x1E24;
  8776. t['Hmonospace'] = 0xFF28;
  8777. t['Hoarmenian'] = 0x0540;
  8778. t['Horicoptic'] = 0x03E8;
  8779. t['Hsmall'] = 0xF768;
  8780. t['Hungarumlaut'] = 0xF6CF;
  8781. t['Hungarumlautsmall'] = 0xF6F8;
  8782. t['Hzsquare'] = 0x3390;
  8783. t['I'] = 0x0049;
  8784. t['IAcyrillic'] = 0x042F;
  8785. t['IJ'] = 0x0132;
  8786. t['IUcyrillic'] = 0x042E;
  8787. t['Iacute'] = 0x00CD;
  8788. t['Iacutesmall'] = 0xF7ED;
  8789. t['Ibreve'] = 0x012C;
  8790. t['Icaron'] = 0x01CF;
  8791. t['Icircle'] = 0x24BE;
  8792. t['Icircumflex'] = 0x00CE;
  8793. t['Icircumflexsmall'] = 0xF7EE;
  8794. t['Icyrillic'] = 0x0406;
  8795. t['Idblgrave'] = 0x0208;
  8796. t['Idieresis'] = 0x00CF;
  8797. t['Idieresisacute'] = 0x1E2E;
  8798. t['Idieresiscyrillic'] = 0x04E4;
  8799. t['Idieresissmall'] = 0xF7EF;
  8800. t['Idot'] = 0x0130;
  8801. t['Idotaccent'] = 0x0130;
  8802. t['Idotbelow'] = 0x1ECA;
  8803. t['Iebrevecyrillic'] = 0x04D6;
  8804. t['Iecyrillic'] = 0x0415;
  8805. t['Ifraktur'] = 0x2111;
  8806. t['Igrave'] = 0x00CC;
  8807. t['Igravesmall'] = 0xF7EC;
  8808. t['Ihookabove'] = 0x1EC8;
  8809. t['Iicyrillic'] = 0x0418;
  8810. t['Iinvertedbreve'] = 0x020A;
  8811. t['Iishortcyrillic'] = 0x0419;
  8812. t['Imacron'] = 0x012A;
  8813. t['Imacroncyrillic'] = 0x04E2;
  8814. t['Imonospace'] = 0xFF29;
  8815. t['Iniarmenian'] = 0x053B;
  8816. t['Iocyrillic'] = 0x0401;
  8817. t['Iogonek'] = 0x012E;
  8818. t['Iota'] = 0x0399;
  8819. t['Iotaafrican'] = 0x0196;
  8820. t['Iotadieresis'] = 0x03AA;
  8821. t['Iotatonos'] = 0x038A;
  8822. t['Ismall'] = 0xF769;
  8823. t['Istroke'] = 0x0197;
  8824. t['Itilde'] = 0x0128;
  8825. t['Itildebelow'] = 0x1E2C;
  8826. t['Izhitsacyrillic'] = 0x0474;
  8827. t['Izhitsadblgravecyrillic'] = 0x0476;
  8828. t['J'] = 0x004A;
  8829. t['Jaarmenian'] = 0x0541;
  8830. t['Jcircle'] = 0x24BF;
  8831. t['Jcircumflex'] = 0x0134;
  8832. t['Jecyrillic'] = 0x0408;
  8833. t['Jheharmenian'] = 0x054B;
  8834. t['Jmonospace'] = 0xFF2A;
  8835. t['Jsmall'] = 0xF76A;
  8836. t['K'] = 0x004B;
  8837. t['KBsquare'] = 0x3385;
  8838. t['KKsquare'] = 0x33CD;
  8839. t['Kabashkircyrillic'] = 0x04A0;
  8840. t['Kacute'] = 0x1E30;
  8841. t['Kacyrillic'] = 0x041A;
  8842. t['Kadescendercyrillic'] = 0x049A;
  8843. t['Kahookcyrillic'] = 0x04C3;
  8844. t['Kappa'] = 0x039A;
  8845. t['Kastrokecyrillic'] = 0x049E;
  8846. t['Kaverticalstrokecyrillic'] = 0x049C;
  8847. t['Kcaron'] = 0x01E8;
  8848. t['Kcedilla'] = 0x0136;
  8849. t['Kcircle'] = 0x24C0;
  8850. t['Kcommaaccent'] = 0x0136;
  8851. t['Kdotbelow'] = 0x1E32;
  8852. t['Keharmenian'] = 0x0554;
  8853. t['Kenarmenian'] = 0x053F;
  8854. t['Khacyrillic'] = 0x0425;
  8855. t['Kheicoptic'] = 0x03E6;
  8856. t['Khook'] = 0x0198;
  8857. t['Kjecyrillic'] = 0x040C;
  8858. t['Klinebelow'] = 0x1E34;
  8859. t['Kmonospace'] = 0xFF2B;
  8860. t['Koppacyrillic'] = 0x0480;
  8861. t['Koppagreek'] = 0x03DE;
  8862. t['Ksicyrillic'] = 0x046E;
  8863. t['Ksmall'] = 0xF76B;
  8864. t['L'] = 0x004C;
  8865. t['LJ'] = 0x01C7;
  8866. t['LL'] = 0xF6BF;
  8867. t['Lacute'] = 0x0139;
  8868. t['Lambda'] = 0x039B;
  8869. t['Lcaron'] = 0x013D;
  8870. t['Lcedilla'] = 0x013B;
  8871. t['Lcircle'] = 0x24C1;
  8872. t['Lcircumflexbelow'] = 0x1E3C;
  8873. t['Lcommaaccent'] = 0x013B;
  8874. t['Ldot'] = 0x013F;
  8875. t['Ldotaccent'] = 0x013F;
  8876. t['Ldotbelow'] = 0x1E36;
  8877. t['Ldotbelowmacron'] = 0x1E38;
  8878. t['Liwnarmenian'] = 0x053C;
  8879. t['Lj'] = 0x01C8;
  8880. t['Ljecyrillic'] = 0x0409;
  8881. t['Llinebelow'] = 0x1E3A;
  8882. t['Lmonospace'] = 0xFF2C;
  8883. t['Lslash'] = 0x0141;
  8884. t['Lslashsmall'] = 0xF6F9;
  8885. t['Lsmall'] = 0xF76C;
  8886. t['M'] = 0x004D;
  8887. t['MBsquare'] = 0x3386;
  8888. t['Macron'] = 0xF6D0;
  8889. t['Macronsmall'] = 0xF7AF;
  8890. t['Macute'] = 0x1E3E;
  8891. t['Mcircle'] = 0x24C2;
  8892. t['Mdotaccent'] = 0x1E40;
  8893. t['Mdotbelow'] = 0x1E42;
  8894. t['Menarmenian'] = 0x0544;
  8895. t['Mmonospace'] = 0xFF2D;
  8896. t['Msmall'] = 0xF76D;
  8897. t['Mturned'] = 0x019C;
  8898. t['Mu'] = 0x039C;
  8899. t['N'] = 0x004E;
  8900. t['NJ'] = 0x01CA;
  8901. t['Nacute'] = 0x0143;
  8902. t['Ncaron'] = 0x0147;
  8903. t['Ncedilla'] = 0x0145;
  8904. t['Ncircle'] = 0x24C3;
  8905. t['Ncircumflexbelow'] = 0x1E4A;
  8906. t['Ncommaaccent'] = 0x0145;
  8907. t['Ndotaccent'] = 0x1E44;
  8908. t['Ndotbelow'] = 0x1E46;
  8909. t['Nhookleft'] = 0x019D;
  8910. t['Nineroman'] = 0x2168;
  8911. t['Nj'] = 0x01CB;
  8912. t['Njecyrillic'] = 0x040A;
  8913. t['Nlinebelow'] = 0x1E48;
  8914. t['Nmonospace'] = 0xFF2E;
  8915. t['Nowarmenian'] = 0x0546;
  8916. t['Nsmall'] = 0xF76E;
  8917. t['Ntilde'] = 0x00D1;
  8918. t['Ntildesmall'] = 0xF7F1;
  8919. t['Nu'] = 0x039D;
  8920. t['O'] = 0x004F;
  8921. t['OE'] = 0x0152;
  8922. t['OEsmall'] = 0xF6FA;
  8923. t['Oacute'] = 0x00D3;
  8924. t['Oacutesmall'] = 0xF7F3;
  8925. t['Obarredcyrillic'] = 0x04E8;
  8926. t['Obarreddieresiscyrillic'] = 0x04EA;
  8927. t['Obreve'] = 0x014E;
  8928. t['Ocaron'] = 0x01D1;
  8929. t['Ocenteredtilde'] = 0x019F;
  8930. t['Ocircle'] = 0x24C4;
  8931. t['Ocircumflex'] = 0x00D4;
  8932. t['Ocircumflexacute'] = 0x1ED0;
  8933. t['Ocircumflexdotbelow'] = 0x1ED8;
  8934. t['Ocircumflexgrave'] = 0x1ED2;
  8935. t['Ocircumflexhookabove'] = 0x1ED4;
  8936. t['Ocircumflexsmall'] = 0xF7F4;
  8937. t['Ocircumflextilde'] = 0x1ED6;
  8938. t['Ocyrillic'] = 0x041E;
  8939. t['Odblacute'] = 0x0150;
  8940. t['Odblgrave'] = 0x020C;
  8941. t['Odieresis'] = 0x00D6;
  8942. t['Odieresiscyrillic'] = 0x04E6;
  8943. t['Odieresissmall'] = 0xF7F6;
  8944. t['Odotbelow'] = 0x1ECC;
  8945. t['Ogoneksmall'] = 0xF6FB;
  8946. t['Ograve'] = 0x00D2;
  8947. t['Ogravesmall'] = 0xF7F2;
  8948. t['Oharmenian'] = 0x0555;
  8949. t['Ohm'] = 0x2126;
  8950. t['Ohookabove'] = 0x1ECE;
  8951. t['Ohorn'] = 0x01A0;
  8952. t['Ohornacute'] = 0x1EDA;
  8953. t['Ohorndotbelow'] = 0x1EE2;
  8954. t['Ohorngrave'] = 0x1EDC;
  8955. t['Ohornhookabove'] = 0x1EDE;
  8956. t['Ohorntilde'] = 0x1EE0;
  8957. t['Ohungarumlaut'] = 0x0150;
  8958. t['Oi'] = 0x01A2;
  8959. t['Oinvertedbreve'] = 0x020E;
  8960. t['Omacron'] = 0x014C;
  8961. t['Omacronacute'] = 0x1E52;
  8962. t['Omacrongrave'] = 0x1E50;
  8963. t['Omega'] = 0x2126;
  8964. t['Omegacyrillic'] = 0x0460;
  8965. t['Omegagreek'] = 0x03A9;
  8966. t['Omegaroundcyrillic'] = 0x047A;
  8967. t['Omegatitlocyrillic'] = 0x047C;
  8968. t['Omegatonos'] = 0x038F;
  8969. t['Omicron'] = 0x039F;
  8970. t['Omicrontonos'] = 0x038C;
  8971. t['Omonospace'] = 0xFF2F;
  8972. t['Oneroman'] = 0x2160;
  8973. t['Oogonek'] = 0x01EA;
  8974. t['Oogonekmacron'] = 0x01EC;
  8975. t['Oopen'] = 0x0186;
  8976. t['Oslash'] = 0x00D8;
  8977. t['Oslashacute'] = 0x01FE;
  8978. t['Oslashsmall'] = 0xF7F8;
  8979. t['Osmall'] = 0xF76F;
  8980. t['Ostrokeacute'] = 0x01FE;
  8981. t['Otcyrillic'] = 0x047E;
  8982. t['Otilde'] = 0x00D5;
  8983. t['Otildeacute'] = 0x1E4C;
  8984. t['Otildedieresis'] = 0x1E4E;
  8985. t['Otildesmall'] = 0xF7F5;
  8986. t['P'] = 0x0050;
  8987. t['Pacute'] = 0x1E54;
  8988. t['Pcircle'] = 0x24C5;
  8989. t['Pdotaccent'] = 0x1E56;
  8990. t['Pecyrillic'] = 0x041F;
  8991. t['Peharmenian'] = 0x054A;
  8992. t['Pemiddlehookcyrillic'] = 0x04A6;
  8993. t['Phi'] = 0x03A6;
  8994. t['Phook'] = 0x01A4;
  8995. t['Pi'] = 0x03A0;
  8996. t['Piwrarmenian'] = 0x0553;
  8997. t['Pmonospace'] = 0xFF30;
  8998. t['Psi'] = 0x03A8;
  8999. t['Psicyrillic'] = 0x0470;
  9000. t['Psmall'] = 0xF770;
  9001. t['Q'] = 0x0051;
  9002. t['Qcircle'] = 0x24C6;
  9003. t['Qmonospace'] = 0xFF31;
  9004. t['Qsmall'] = 0xF771;
  9005. t['R'] = 0x0052;
  9006. t['Raarmenian'] = 0x054C;
  9007. t['Racute'] = 0x0154;
  9008. t['Rcaron'] = 0x0158;
  9009. t['Rcedilla'] = 0x0156;
  9010. t['Rcircle'] = 0x24C7;
  9011. t['Rcommaaccent'] = 0x0156;
  9012. t['Rdblgrave'] = 0x0210;
  9013. t['Rdotaccent'] = 0x1E58;
  9014. t['Rdotbelow'] = 0x1E5A;
  9015. t['Rdotbelowmacron'] = 0x1E5C;
  9016. t['Reharmenian'] = 0x0550;
  9017. t['Rfraktur'] = 0x211C;
  9018. t['Rho'] = 0x03A1;
  9019. t['Ringsmall'] = 0xF6FC;
  9020. t['Rinvertedbreve'] = 0x0212;
  9021. t['Rlinebelow'] = 0x1E5E;
  9022. t['Rmonospace'] = 0xFF32;
  9023. t['Rsmall'] = 0xF772;
  9024. t['Rsmallinverted'] = 0x0281;
  9025. t['Rsmallinvertedsuperior'] = 0x02B6;
  9026. t['S'] = 0x0053;
  9027. t['SF010000'] = 0x250C;
  9028. t['SF020000'] = 0x2514;
  9029. t['SF030000'] = 0x2510;
  9030. t['SF040000'] = 0x2518;
  9031. t['SF050000'] = 0x253C;
  9032. t['SF060000'] = 0x252C;
  9033. t['SF070000'] = 0x2534;
  9034. t['SF080000'] = 0x251C;
  9035. t['SF090000'] = 0x2524;
  9036. t['SF100000'] = 0x2500;
  9037. t['SF110000'] = 0x2502;
  9038. t['SF190000'] = 0x2561;
  9039. t['SF200000'] = 0x2562;
  9040. t['SF210000'] = 0x2556;
  9041. t['SF220000'] = 0x2555;
  9042. t['SF230000'] = 0x2563;
  9043. t['SF240000'] = 0x2551;
  9044. t['SF250000'] = 0x2557;
  9045. t['SF260000'] = 0x255D;
  9046. t['SF270000'] = 0x255C;
  9047. t['SF280000'] = 0x255B;
  9048. t['SF360000'] = 0x255E;
  9049. t['SF370000'] = 0x255F;
  9050. t['SF380000'] = 0x255A;
  9051. t['SF390000'] = 0x2554;
  9052. t['SF400000'] = 0x2569;
  9053. t['SF410000'] = 0x2566;
  9054. t['SF420000'] = 0x2560;
  9055. t['SF430000'] = 0x2550;
  9056. t['SF440000'] = 0x256C;
  9057. t['SF450000'] = 0x2567;
  9058. t['SF460000'] = 0x2568;
  9059. t['SF470000'] = 0x2564;
  9060. t['SF480000'] = 0x2565;
  9061. t['SF490000'] = 0x2559;
  9062. t['SF500000'] = 0x2558;
  9063. t['SF510000'] = 0x2552;
  9064. t['SF520000'] = 0x2553;
  9065. t['SF530000'] = 0x256B;
  9066. t['SF540000'] = 0x256A;
  9067. t['Sacute'] = 0x015A;
  9068. t['Sacutedotaccent'] = 0x1E64;
  9069. t['Sampigreek'] = 0x03E0;
  9070. t['Scaron'] = 0x0160;
  9071. t['Scarondotaccent'] = 0x1E66;
  9072. t['Scaronsmall'] = 0xF6FD;
  9073. t['Scedilla'] = 0x015E;
  9074. t['Schwa'] = 0x018F;
  9075. t['Schwacyrillic'] = 0x04D8;
  9076. t['Schwadieresiscyrillic'] = 0x04DA;
  9077. t['Scircle'] = 0x24C8;
  9078. t['Scircumflex'] = 0x015C;
  9079. t['Scommaaccent'] = 0x0218;
  9080. t['Sdotaccent'] = 0x1E60;
  9081. t['Sdotbelow'] = 0x1E62;
  9082. t['Sdotbelowdotaccent'] = 0x1E68;
  9083. t['Seharmenian'] = 0x054D;
  9084. t['Sevenroman'] = 0x2166;
  9085. t['Shaarmenian'] = 0x0547;
  9086. t['Shacyrillic'] = 0x0428;
  9087. t['Shchacyrillic'] = 0x0429;
  9088. t['Sheicoptic'] = 0x03E2;
  9089. t['Shhacyrillic'] = 0x04BA;
  9090. t['Shimacoptic'] = 0x03EC;
  9091. t['Sigma'] = 0x03A3;
  9092. t['Sixroman'] = 0x2165;
  9093. t['Smonospace'] = 0xFF33;
  9094. t['Softsigncyrillic'] = 0x042C;
  9095. t['Ssmall'] = 0xF773;
  9096. t['Stigmagreek'] = 0x03DA;
  9097. t['T'] = 0x0054;
  9098. t['Tau'] = 0x03A4;
  9099. t['Tbar'] = 0x0166;
  9100. t['Tcaron'] = 0x0164;
  9101. t['Tcedilla'] = 0x0162;
  9102. t['Tcircle'] = 0x24C9;
  9103. t['Tcircumflexbelow'] = 0x1E70;
  9104. t['Tcommaaccent'] = 0x0162;
  9105. t['Tdotaccent'] = 0x1E6A;
  9106. t['Tdotbelow'] = 0x1E6C;
  9107. t['Tecyrillic'] = 0x0422;
  9108. t['Tedescendercyrillic'] = 0x04AC;
  9109. t['Tenroman'] = 0x2169;
  9110. t['Tetsecyrillic'] = 0x04B4;
  9111. t['Theta'] = 0x0398;
  9112. t['Thook'] = 0x01AC;
  9113. t['Thorn'] = 0x00DE;
  9114. t['Thornsmall'] = 0xF7FE;
  9115. t['Threeroman'] = 0x2162;
  9116. t['Tildesmall'] = 0xF6FE;
  9117. t['Tiwnarmenian'] = 0x054F;
  9118. t['Tlinebelow'] = 0x1E6E;
  9119. t['Tmonospace'] = 0xFF34;
  9120. t['Toarmenian'] = 0x0539;
  9121. t['Tonefive'] = 0x01BC;
  9122. t['Tonesix'] = 0x0184;
  9123. t['Tonetwo'] = 0x01A7;
  9124. t['Tretroflexhook'] = 0x01AE;
  9125. t['Tsecyrillic'] = 0x0426;
  9126. t['Tshecyrillic'] = 0x040B;
  9127. t['Tsmall'] = 0xF774;
  9128. t['Twelveroman'] = 0x216B;
  9129. t['Tworoman'] = 0x2161;
  9130. t['U'] = 0x0055;
  9131. t['Uacute'] = 0x00DA;
  9132. t['Uacutesmall'] = 0xF7FA;
  9133. t['Ubreve'] = 0x016C;
  9134. t['Ucaron'] = 0x01D3;
  9135. t['Ucircle'] = 0x24CA;
  9136. t['Ucircumflex'] = 0x00DB;
  9137. t['Ucircumflexbelow'] = 0x1E76;
  9138. t['Ucircumflexsmall'] = 0xF7FB;
  9139. t['Ucyrillic'] = 0x0423;
  9140. t['Udblacute'] = 0x0170;
  9141. t['Udblgrave'] = 0x0214;
  9142. t['Udieresis'] = 0x00DC;
  9143. t['Udieresisacute'] = 0x01D7;
  9144. t['Udieresisbelow'] = 0x1E72;
  9145. t['Udieresiscaron'] = 0x01D9;
  9146. t['Udieresiscyrillic'] = 0x04F0;
  9147. t['Udieresisgrave'] = 0x01DB;
  9148. t['Udieresismacron'] = 0x01D5;
  9149. t['Udieresissmall'] = 0xF7FC;
  9150. t['Udotbelow'] = 0x1EE4;
  9151. t['Ugrave'] = 0x00D9;
  9152. t['Ugravesmall'] = 0xF7F9;
  9153. t['Uhookabove'] = 0x1EE6;
  9154. t['Uhorn'] = 0x01AF;
  9155. t['Uhornacute'] = 0x1EE8;
  9156. t['Uhorndotbelow'] = 0x1EF0;
  9157. t['Uhorngrave'] = 0x1EEA;
  9158. t['Uhornhookabove'] = 0x1EEC;
  9159. t['Uhorntilde'] = 0x1EEE;
  9160. t['Uhungarumlaut'] = 0x0170;
  9161. t['Uhungarumlautcyrillic'] = 0x04F2;
  9162. t['Uinvertedbreve'] = 0x0216;
  9163. t['Ukcyrillic'] = 0x0478;
  9164. t['Umacron'] = 0x016A;
  9165. t['Umacroncyrillic'] = 0x04EE;
  9166. t['Umacrondieresis'] = 0x1E7A;
  9167. t['Umonospace'] = 0xFF35;
  9168. t['Uogonek'] = 0x0172;
  9169. t['Upsilon'] = 0x03A5;
  9170. t['Upsilon1'] = 0x03D2;
  9171. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9172. t['Upsilonafrican'] = 0x01B1;
  9173. t['Upsilondieresis'] = 0x03AB;
  9174. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9175. t['Upsilonhooksymbol'] = 0x03D2;
  9176. t['Upsilontonos'] = 0x038E;
  9177. t['Uring'] = 0x016E;
  9178. t['Ushortcyrillic'] = 0x040E;
  9179. t['Usmall'] = 0xF775;
  9180. t['Ustraightcyrillic'] = 0x04AE;
  9181. t['Ustraightstrokecyrillic'] = 0x04B0;
  9182. t['Utilde'] = 0x0168;
  9183. t['Utildeacute'] = 0x1E78;
  9184. t['Utildebelow'] = 0x1E74;
  9185. t['V'] = 0x0056;
  9186. t['Vcircle'] = 0x24CB;
  9187. t['Vdotbelow'] = 0x1E7E;
  9188. t['Vecyrillic'] = 0x0412;
  9189. t['Vewarmenian'] = 0x054E;
  9190. t['Vhook'] = 0x01B2;
  9191. t['Vmonospace'] = 0xFF36;
  9192. t['Voarmenian'] = 0x0548;
  9193. t['Vsmall'] = 0xF776;
  9194. t['Vtilde'] = 0x1E7C;
  9195. t['W'] = 0x0057;
  9196. t['Wacute'] = 0x1E82;
  9197. t['Wcircle'] = 0x24CC;
  9198. t['Wcircumflex'] = 0x0174;
  9199. t['Wdieresis'] = 0x1E84;
  9200. t['Wdotaccent'] = 0x1E86;
  9201. t['Wdotbelow'] = 0x1E88;
  9202. t['Wgrave'] = 0x1E80;
  9203. t['Wmonospace'] = 0xFF37;
  9204. t['Wsmall'] = 0xF777;
  9205. t['X'] = 0x0058;
  9206. t['Xcircle'] = 0x24CD;
  9207. t['Xdieresis'] = 0x1E8C;
  9208. t['Xdotaccent'] = 0x1E8A;
  9209. t['Xeharmenian'] = 0x053D;
  9210. t['Xi'] = 0x039E;
  9211. t['Xmonospace'] = 0xFF38;
  9212. t['Xsmall'] = 0xF778;
  9213. t['Y'] = 0x0059;
  9214. t['Yacute'] = 0x00DD;
  9215. t['Yacutesmall'] = 0xF7FD;
  9216. t['Yatcyrillic'] = 0x0462;
  9217. t['Ycircle'] = 0x24CE;
  9218. t['Ycircumflex'] = 0x0176;
  9219. t['Ydieresis'] = 0x0178;
  9220. t['Ydieresissmall'] = 0xF7FF;
  9221. t['Ydotaccent'] = 0x1E8E;
  9222. t['Ydotbelow'] = 0x1EF4;
  9223. t['Yericyrillic'] = 0x042B;
  9224. t['Yerudieresiscyrillic'] = 0x04F8;
  9225. t['Ygrave'] = 0x1EF2;
  9226. t['Yhook'] = 0x01B3;
  9227. t['Yhookabove'] = 0x1EF6;
  9228. t['Yiarmenian'] = 0x0545;
  9229. t['Yicyrillic'] = 0x0407;
  9230. t['Yiwnarmenian'] = 0x0552;
  9231. t['Ymonospace'] = 0xFF39;
  9232. t['Ysmall'] = 0xF779;
  9233. t['Ytilde'] = 0x1EF8;
  9234. t['Yusbigcyrillic'] = 0x046A;
  9235. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9236. t['Yuslittlecyrillic'] = 0x0466;
  9237. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9238. t['Z'] = 0x005A;
  9239. t['Zaarmenian'] = 0x0536;
  9240. t['Zacute'] = 0x0179;
  9241. t['Zcaron'] = 0x017D;
  9242. t['Zcaronsmall'] = 0xF6FF;
  9243. t['Zcircle'] = 0x24CF;
  9244. t['Zcircumflex'] = 0x1E90;
  9245. t['Zdot'] = 0x017B;
  9246. t['Zdotaccent'] = 0x017B;
  9247. t['Zdotbelow'] = 0x1E92;
  9248. t['Zecyrillic'] = 0x0417;
  9249. t['Zedescendercyrillic'] = 0x0498;
  9250. t['Zedieresiscyrillic'] = 0x04DE;
  9251. t['Zeta'] = 0x0396;
  9252. t['Zhearmenian'] = 0x053A;
  9253. t['Zhebrevecyrillic'] = 0x04C1;
  9254. t['Zhecyrillic'] = 0x0416;
  9255. t['Zhedescendercyrillic'] = 0x0496;
  9256. t['Zhedieresiscyrillic'] = 0x04DC;
  9257. t['Zlinebelow'] = 0x1E94;
  9258. t['Zmonospace'] = 0xFF3A;
  9259. t['Zsmall'] = 0xF77A;
  9260. t['Zstroke'] = 0x01B5;
  9261. t['a'] = 0x0061;
  9262. t['aabengali'] = 0x0986;
  9263. t['aacute'] = 0x00E1;
  9264. t['aadeva'] = 0x0906;
  9265. t['aagujarati'] = 0x0A86;
  9266. t['aagurmukhi'] = 0x0A06;
  9267. t['aamatragurmukhi'] = 0x0A3E;
  9268. t['aarusquare'] = 0x3303;
  9269. t['aavowelsignbengali'] = 0x09BE;
  9270. t['aavowelsigndeva'] = 0x093E;
  9271. t['aavowelsigngujarati'] = 0x0ABE;
  9272. t['abbreviationmarkarmenian'] = 0x055F;
  9273. t['abbreviationsigndeva'] = 0x0970;
  9274. t['abengali'] = 0x0985;
  9275. t['abopomofo'] = 0x311A;
  9276. t['abreve'] = 0x0103;
  9277. t['abreveacute'] = 0x1EAF;
  9278. t['abrevecyrillic'] = 0x04D1;
  9279. t['abrevedotbelow'] = 0x1EB7;
  9280. t['abrevegrave'] = 0x1EB1;
  9281. t['abrevehookabove'] = 0x1EB3;
  9282. t['abrevetilde'] = 0x1EB5;
  9283. t['acaron'] = 0x01CE;
  9284. t['acircle'] = 0x24D0;
  9285. t['acircumflex'] = 0x00E2;
  9286. t['acircumflexacute'] = 0x1EA5;
  9287. t['acircumflexdotbelow'] = 0x1EAD;
  9288. t['acircumflexgrave'] = 0x1EA7;
  9289. t['acircumflexhookabove'] = 0x1EA9;
  9290. t['acircumflextilde'] = 0x1EAB;
  9291. t['acute'] = 0x00B4;
  9292. t['acutebelowcmb'] = 0x0317;
  9293. t['acutecmb'] = 0x0301;
  9294. t['acutecomb'] = 0x0301;
  9295. t['acutedeva'] = 0x0954;
  9296. t['acutelowmod'] = 0x02CF;
  9297. t['acutetonecmb'] = 0x0341;
  9298. t['acyrillic'] = 0x0430;
  9299. t['adblgrave'] = 0x0201;
  9300. t['addakgurmukhi'] = 0x0A71;
  9301. t['adeva'] = 0x0905;
  9302. t['adieresis'] = 0x00E4;
  9303. t['adieresiscyrillic'] = 0x04D3;
  9304. t['adieresismacron'] = 0x01DF;
  9305. t['adotbelow'] = 0x1EA1;
  9306. t['adotmacron'] = 0x01E1;
  9307. t['ae'] = 0x00E6;
  9308. t['aeacute'] = 0x01FD;
  9309. t['aekorean'] = 0x3150;
  9310. t['aemacron'] = 0x01E3;
  9311. t['afii00208'] = 0x2015;
  9312. t['afii08941'] = 0x20A4;
  9313. t['afii10017'] = 0x0410;
  9314. t['afii10018'] = 0x0411;
  9315. t['afii10019'] = 0x0412;
  9316. t['afii10020'] = 0x0413;
  9317. t['afii10021'] = 0x0414;
  9318. t['afii10022'] = 0x0415;
  9319. t['afii10023'] = 0x0401;
  9320. t['afii10024'] = 0x0416;
  9321. t['afii10025'] = 0x0417;
  9322. t['afii10026'] = 0x0418;
  9323. t['afii10027'] = 0x0419;
  9324. t['afii10028'] = 0x041A;
  9325. t['afii10029'] = 0x041B;
  9326. t['afii10030'] = 0x041C;
  9327. t['afii10031'] = 0x041D;
  9328. t['afii10032'] = 0x041E;
  9329. t['afii10033'] = 0x041F;
  9330. t['afii10034'] = 0x0420;
  9331. t['afii10035'] = 0x0421;
  9332. t['afii10036'] = 0x0422;
  9333. t['afii10037'] = 0x0423;
  9334. t['afii10038'] = 0x0424;
  9335. t['afii10039'] = 0x0425;
  9336. t['afii10040'] = 0x0426;
  9337. t['afii10041'] = 0x0427;
  9338. t['afii10042'] = 0x0428;
  9339. t['afii10043'] = 0x0429;
  9340. t['afii10044'] = 0x042A;
  9341. t['afii10045'] = 0x042B;
  9342. t['afii10046'] = 0x042C;
  9343. t['afii10047'] = 0x042D;
  9344. t['afii10048'] = 0x042E;
  9345. t['afii10049'] = 0x042F;
  9346. t['afii10050'] = 0x0490;
  9347. t['afii10051'] = 0x0402;
  9348. t['afii10052'] = 0x0403;
  9349. t['afii10053'] = 0x0404;
  9350. t['afii10054'] = 0x0405;
  9351. t['afii10055'] = 0x0406;
  9352. t['afii10056'] = 0x0407;
  9353. t['afii10057'] = 0x0408;
  9354. t['afii10058'] = 0x0409;
  9355. t['afii10059'] = 0x040A;
  9356. t['afii10060'] = 0x040B;
  9357. t['afii10061'] = 0x040C;
  9358. t['afii10062'] = 0x040E;
  9359. t['afii10063'] = 0xF6C4;
  9360. t['afii10064'] = 0xF6C5;
  9361. t['afii10065'] = 0x0430;
  9362. t['afii10066'] = 0x0431;
  9363. t['afii10067'] = 0x0432;
  9364. t['afii10068'] = 0x0433;
  9365. t['afii10069'] = 0x0434;
  9366. t['afii10070'] = 0x0435;
  9367. t['afii10071'] = 0x0451;
  9368. t['afii10072'] = 0x0436;
  9369. t['afii10073'] = 0x0437;
  9370. t['afii10074'] = 0x0438;
  9371. t['afii10075'] = 0x0439;
  9372. t['afii10076'] = 0x043A;
  9373. t['afii10077'] = 0x043B;
  9374. t['afii10078'] = 0x043C;
  9375. t['afii10079'] = 0x043D;
  9376. t['afii10080'] = 0x043E;
  9377. t['afii10081'] = 0x043F;
  9378. t['afii10082'] = 0x0440;
  9379. t['afii10083'] = 0x0441;
  9380. t['afii10084'] = 0x0442;
  9381. t['afii10085'] = 0x0443;
  9382. t['afii10086'] = 0x0444;
  9383. t['afii10087'] = 0x0445;
  9384. t['afii10088'] = 0x0446;
  9385. t['afii10089'] = 0x0447;
  9386. t['afii10090'] = 0x0448;
  9387. t['afii10091'] = 0x0449;
  9388. t['afii10092'] = 0x044A;
  9389. t['afii10093'] = 0x044B;
  9390. t['afii10094'] = 0x044C;
  9391. t['afii10095'] = 0x044D;
  9392. t['afii10096'] = 0x044E;
  9393. t['afii10097'] = 0x044F;
  9394. t['afii10098'] = 0x0491;
  9395. t['afii10099'] = 0x0452;
  9396. t['afii10100'] = 0x0453;
  9397. t['afii10101'] = 0x0454;
  9398. t['afii10102'] = 0x0455;
  9399. t['afii10103'] = 0x0456;
  9400. t['afii10104'] = 0x0457;
  9401. t['afii10105'] = 0x0458;
  9402. t['afii10106'] = 0x0459;
  9403. t['afii10107'] = 0x045A;
  9404. t['afii10108'] = 0x045B;
  9405. t['afii10109'] = 0x045C;
  9406. t['afii10110'] = 0x045E;
  9407. t['afii10145'] = 0x040F;
  9408. t['afii10146'] = 0x0462;
  9409. t['afii10147'] = 0x0472;
  9410. t['afii10148'] = 0x0474;
  9411. t['afii10192'] = 0xF6C6;
  9412. t['afii10193'] = 0x045F;
  9413. t['afii10194'] = 0x0463;
  9414. t['afii10195'] = 0x0473;
  9415. t['afii10196'] = 0x0475;
  9416. t['afii10831'] = 0xF6C7;
  9417. t['afii10832'] = 0xF6C8;
  9418. t['afii10846'] = 0x04D9;
  9419. t['afii299'] = 0x200E;
  9420. t['afii300'] = 0x200F;
  9421. t['afii301'] = 0x200D;
  9422. t['afii57381'] = 0x066A;
  9423. t['afii57388'] = 0x060C;
  9424. t['afii57392'] = 0x0660;
  9425. t['afii57393'] = 0x0661;
  9426. t['afii57394'] = 0x0662;
  9427. t['afii57395'] = 0x0663;
  9428. t['afii57396'] = 0x0664;
  9429. t['afii57397'] = 0x0665;
  9430. t['afii57398'] = 0x0666;
  9431. t['afii57399'] = 0x0667;
  9432. t['afii57400'] = 0x0668;
  9433. t['afii57401'] = 0x0669;
  9434. t['afii57403'] = 0x061B;
  9435. t['afii57407'] = 0x061F;
  9436. t['afii57409'] = 0x0621;
  9437. t['afii57410'] = 0x0622;
  9438. t['afii57411'] = 0x0623;
  9439. t['afii57412'] = 0x0624;
  9440. t['afii57413'] = 0x0625;
  9441. t['afii57414'] = 0x0626;
  9442. t['afii57415'] = 0x0627;
  9443. t['afii57416'] = 0x0628;
  9444. t['afii57417'] = 0x0629;
  9445. t['afii57418'] = 0x062A;
  9446. t['afii57419'] = 0x062B;
  9447. t['afii57420'] = 0x062C;
  9448. t['afii57421'] = 0x062D;
  9449. t['afii57422'] = 0x062E;
  9450. t['afii57423'] = 0x062F;
  9451. t['afii57424'] = 0x0630;
  9452. t['afii57425'] = 0x0631;
  9453. t['afii57426'] = 0x0632;
  9454. t['afii57427'] = 0x0633;
  9455. t['afii57428'] = 0x0634;
  9456. t['afii57429'] = 0x0635;
  9457. t['afii57430'] = 0x0636;
  9458. t['afii57431'] = 0x0637;
  9459. t['afii57432'] = 0x0638;
  9460. t['afii57433'] = 0x0639;
  9461. t['afii57434'] = 0x063A;
  9462. t['afii57440'] = 0x0640;
  9463. t['afii57441'] = 0x0641;
  9464. t['afii57442'] = 0x0642;
  9465. t['afii57443'] = 0x0643;
  9466. t['afii57444'] = 0x0644;
  9467. t['afii57445'] = 0x0645;
  9468. t['afii57446'] = 0x0646;
  9469. t['afii57448'] = 0x0648;
  9470. t['afii57449'] = 0x0649;
  9471. t['afii57450'] = 0x064A;
  9472. t['afii57451'] = 0x064B;
  9473. t['afii57452'] = 0x064C;
  9474. t['afii57453'] = 0x064D;
  9475. t['afii57454'] = 0x064E;
  9476. t['afii57455'] = 0x064F;
  9477. t['afii57456'] = 0x0650;
  9478. t['afii57457'] = 0x0651;
  9479. t['afii57458'] = 0x0652;
  9480. t['afii57470'] = 0x0647;
  9481. t['afii57505'] = 0x06A4;
  9482. t['afii57506'] = 0x067E;
  9483. t['afii57507'] = 0x0686;
  9484. t['afii57508'] = 0x0698;
  9485. t['afii57509'] = 0x06AF;
  9486. t['afii57511'] = 0x0679;
  9487. t['afii57512'] = 0x0688;
  9488. t['afii57513'] = 0x0691;
  9489. t['afii57514'] = 0x06BA;
  9490. t['afii57519'] = 0x06D2;
  9491. t['afii57534'] = 0x06D5;
  9492. t['afii57636'] = 0x20AA;
  9493. t['afii57645'] = 0x05BE;
  9494. t['afii57658'] = 0x05C3;
  9495. t['afii57664'] = 0x05D0;
  9496. t['afii57665'] = 0x05D1;
  9497. t['afii57666'] = 0x05D2;
  9498. t['afii57667'] = 0x05D3;
  9499. t['afii57668'] = 0x05D4;
  9500. t['afii57669'] = 0x05D5;
  9501. t['afii57670'] = 0x05D6;
  9502. t['afii57671'] = 0x05D7;
  9503. t['afii57672'] = 0x05D8;
  9504. t['afii57673'] = 0x05D9;
  9505. t['afii57674'] = 0x05DA;
  9506. t['afii57675'] = 0x05DB;
  9507. t['afii57676'] = 0x05DC;
  9508. t['afii57677'] = 0x05DD;
  9509. t['afii57678'] = 0x05DE;
  9510. t['afii57679'] = 0x05DF;
  9511. t['afii57680'] = 0x05E0;
  9512. t['afii57681'] = 0x05E1;
  9513. t['afii57682'] = 0x05E2;
  9514. t['afii57683'] = 0x05E3;
  9515. t['afii57684'] = 0x05E4;
  9516. t['afii57685'] = 0x05E5;
  9517. t['afii57686'] = 0x05E6;
  9518. t['afii57687'] = 0x05E7;
  9519. t['afii57688'] = 0x05E8;
  9520. t['afii57689'] = 0x05E9;
  9521. t['afii57690'] = 0x05EA;
  9522. t['afii57694'] = 0xFB2A;
  9523. t['afii57695'] = 0xFB2B;
  9524. t['afii57700'] = 0xFB4B;
  9525. t['afii57705'] = 0xFB1F;
  9526. t['afii57716'] = 0x05F0;
  9527. t['afii57717'] = 0x05F1;
  9528. t['afii57718'] = 0x05F2;
  9529. t['afii57723'] = 0xFB35;
  9530. t['afii57793'] = 0x05B4;
  9531. t['afii57794'] = 0x05B5;
  9532. t['afii57795'] = 0x05B6;
  9533. t['afii57796'] = 0x05BB;
  9534. t['afii57797'] = 0x05B8;
  9535. t['afii57798'] = 0x05B7;
  9536. t['afii57799'] = 0x05B0;
  9537. t['afii57800'] = 0x05B2;
  9538. t['afii57801'] = 0x05B1;
  9539. t['afii57802'] = 0x05B3;
  9540. t['afii57803'] = 0x05C2;
  9541. t['afii57804'] = 0x05C1;
  9542. t['afii57806'] = 0x05B9;
  9543. t['afii57807'] = 0x05BC;
  9544. t['afii57839'] = 0x05BD;
  9545. t['afii57841'] = 0x05BF;
  9546. t['afii57842'] = 0x05C0;
  9547. t['afii57929'] = 0x02BC;
  9548. t['afii61248'] = 0x2105;
  9549. t['afii61289'] = 0x2113;
  9550. t['afii61352'] = 0x2116;
  9551. t['afii61573'] = 0x202C;
  9552. t['afii61574'] = 0x202D;
  9553. t['afii61575'] = 0x202E;
  9554. t['afii61664'] = 0x200C;
  9555. t['afii63167'] = 0x066D;
  9556. t['afii64937'] = 0x02BD;
  9557. t['agrave'] = 0x00E0;
  9558. t['agujarati'] = 0x0A85;
  9559. t['agurmukhi'] = 0x0A05;
  9560. t['ahiragana'] = 0x3042;
  9561. t['ahookabove'] = 0x1EA3;
  9562. t['aibengali'] = 0x0990;
  9563. t['aibopomofo'] = 0x311E;
  9564. t['aideva'] = 0x0910;
  9565. t['aiecyrillic'] = 0x04D5;
  9566. t['aigujarati'] = 0x0A90;
  9567. t['aigurmukhi'] = 0x0A10;
  9568. t['aimatragurmukhi'] = 0x0A48;
  9569. t['ainarabic'] = 0x0639;
  9570. t['ainfinalarabic'] = 0xFECA;
  9571. t['aininitialarabic'] = 0xFECB;
  9572. t['ainmedialarabic'] = 0xFECC;
  9573. t['ainvertedbreve'] = 0x0203;
  9574. t['aivowelsignbengali'] = 0x09C8;
  9575. t['aivowelsigndeva'] = 0x0948;
  9576. t['aivowelsigngujarati'] = 0x0AC8;
  9577. t['akatakana'] = 0x30A2;
  9578. t['akatakanahalfwidth'] = 0xFF71;
  9579. t['akorean'] = 0x314F;
  9580. t['alef'] = 0x05D0;
  9581. t['alefarabic'] = 0x0627;
  9582. t['alefdageshhebrew'] = 0xFB30;
  9583. t['aleffinalarabic'] = 0xFE8E;
  9584. t['alefhamzaabovearabic'] = 0x0623;
  9585. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9586. t['alefhamzabelowarabic'] = 0x0625;
  9587. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9588. t['alefhebrew'] = 0x05D0;
  9589. t['aleflamedhebrew'] = 0xFB4F;
  9590. t['alefmaddaabovearabic'] = 0x0622;
  9591. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9592. t['alefmaksuraarabic'] = 0x0649;
  9593. t['alefmaksurafinalarabic'] = 0xFEF0;
  9594. t['alefmaksurainitialarabic'] = 0xFEF3;
  9595. t['alefmaksuramedialarabic'] = 0xFEF4;
  9596. t['alefpatahhebrew'] = 0xFB2E;
  9597. t['alefqamatshebrew'] = 0xFB2F;
  9598. t['aleph'] = 0x2135;
  9599. t['allequal'] = 0x224C;
  9600. t['alpha'] = 0x03B1;
  9601. t['alphatonos'] = 0x03AC;
  9602. t['amacron'] = 0x0101;
  9603. t['amonospace'] = 0xFF41;
  9604. t['ampersand'] = 0x0026;
  9605. t['ampersandmonospace'] = 0xFF06;
  9606. t['ampersandsmall'] = 0xF726;
  9607. t['amsquare'] = 0x33C2;
  9608. t['anbopomofo'] = 0x3122;
  9609. t['angbopomofo'] = 0x3124;
  9610. t['angbracketleft'] = 0x3008;
  9611. t['angbracketright'] = 0x3009;
  9612. t['angkhankhuthai'] = 0x0E5A;
  9613. t['angle'] = 0x2220;
  9614. t['anglebracketleft'] = 0x3008;
  9615. t['anglebracketleftvertical'] = 0xFE3F;
  9616. t['anglebracketright'] = 0x3009;
  9617. t['anglebracketrightvertical'] = 0xFE40;
  9618. t['angleleft'] = 0x2329;
  9619. t['angleright'] = 0x232A;
  9620. t['angstrom'] = 0x212B;
  9621. t['anoteleia'] = 0x0387;
  9622. t['anudattadeva'] = 0x0952;
  9623. t['anusvarabengali'] = 0x0982;
  9624. t['anusvaradeva'] = 0x0902;
  9625. t['anusvaragujarati'] = 0x0A82;
  9626. t['aogonek'] = 0x0105;
  9627. t['apaatosquare'] = 0x3300;
  9628. t['aparen'] = 0x249C;
  9629. t['apostrophearmenian'] = 0x055A;
  9630. t['apostrophemod'] = 0x02BC;
  9631. t['apple'] = 0xF8FF;
  9632. t['approaches'] = 0x2250;
  9633. t['approxequal'] = 0x2248;
  9634. t['approxequalorimage'] = 0x2252;
  9635. t['approximatelyequal'] = 0x2245;
  9636. t['araeaekorean'] = 0x318E;
  9637. t['araeakorean'] = 0x318D;
  9638. t['arc'] = 0x2312;
  9639. t['arighthalfring'] = 0x1E9A;
  9640. t['aring'] = 0x00E5;
  9641. t['aringacute'] = 0x01FB;
  9642. t['aringbelow'] = 0x1E01;
  9643. t['arrowboth'] = 0x2194;
  9644. t['arrowdashdown'] = 0x21E3;
  9645. t['arrowdashleft'] = 0x21E0;
  9646. t['arrowdashright'] = 0x21E2;
  9647. t['arrowdashup'] = 0x21E1;
  9648. t['arrowdblboth'] = 0x21D4;
  9649. t['arrowdbldown'] = 0x21D3;
  9650. t['arrowdblleft'] = 0x21D0;
  9651. t['arrowdblright'] = 0x21D2;
  9652. t['arrowdblup'] = 0x21D1;
  9653. t['arrowdown'] = 0x2193;
  9654. t['arrowdownleft'] = 0x2199;
  9655. t['arrowdownright'] = 0x2198;
  9656. t['arrowdownwhite'] = 0x21E9;
  9657. t['arrowheaddownmod'] = 0x02C5;
  9658. t['arrowheadleftmod'] = 0x02C2;
  9659. t['arrowheadrightmod'] = 0x02C3;
  9660. t['arrowheadupmod'] = 0x02C4;
  9661. t['arrowhorizex'] = 0xF8E7;
  9662. t['arrowleft'] = 0x2190;
  9663. t['arrowleftdbl'] = 0x21D0;
  9664. t['arrowleftdblstroke'] = 0x21CD;
  9665. t['arrowleftoverright'] = 0x21C6;
  9666. t['arrowleftwhite'] = 0x21E6;
  9667. t['arrowright'] = 0x2192;
  9668. t['arrowrightdblstroke'] = 0x21CF;
  9669. t['arrowrightheavy'] = 0x279E;
  9670. t['arrowrightoverleft'] = 0x21C4;
  9671. t['arrowrightwhite'] = 0x21E8;
  9672. t['arrowtableft'] = 0x21E4;
  9673. t['arrowtabright'] = 0x21E5;
  9674. t['arrowup'] = 0x2191;
  9675. t['arrowupdn'] = 0x2195;
  9676. t['arrowupdnbse'] = 0x21A8;
  9677. t['arrowupdownbase'] = 0x21A8;
  9678. t['arrowupleft'] = 0x2196;
  9679. t['arrowupleftofdown'] = 0x21C5;
  9680. t['arrowupright'] = 0x2197;
  9681. t['arrowupwhite'] = 0x21E7;
  9682. t['arrowvertex'] = 0xF8E6;
  9683. t['asciicircum'] = 0x005E;
  9684. t['asciicircummonospace'] = 0xFF3E;
  9685. t['asciitilde'] = 0x007E;
  9686. t['asciitildemonospace'] = 0xFF5E;
  9687. t['ascript'] = 0x0251;
  9688. t['ascriptturned'] = 0x0252;
  9689. t['asmallhiragana'] = 0x3041;
  9690. t['asmallkatakana'] = 0x30A1;
  9691. t['asmallkatakanahalfwidth'] = 0xFF67;
  9692. t['asterisk'] = 0x002A;
  9693. t['asteriskaltonearabic'] = 0x066D;
  9694. t['asteriskarabic'] = 0x066D;
  9695. t['asteriskmath'] = 0x2217;
  9696. t['asteriskmonospace'] = 0xFF0A;
  9697. t['asterisksmall'] = 0xFE61;
  9698. t['asterism'] = 0x2042;
  9699. t['asuperior'] = 0xF6E9;
  9700. t['asymptoticallyequal'] = 0x2243;
  9701. t['at'] = 0x0040;
  9702. t['atilde'] = 0x00E3;
  9703. t['atmonospace'] = 0xFF20;
  9704. t['atsmall'] = 0xFE6B;
  9705. t['aturned'] = 0x0250;
  9706. t['aubengali'] = 0x0994;
  9707. t['aubopomofo'] = 0x3120;
  9708. t['audeva'] = 0x0914;
  9709. t['augujarati'] = 0x0A94;
  9710. t['augurmukhi'] = 0x0A14;
  9711. t['aulengthmarkbengali'] = 0x09D7;
  9712. t['aumatragurmukhi'] = 0x0A4C;
  9713. t['auvowelsignbengali'] = 0x09CC;
  9714. t['auvowelsigndeva'] = 0x094C;
  9715. t['auvowelsigngujarati'] = 0x0ACC;
  9716. t['avagrahadeva'] = 0x093D;
  9717. t['aybarmenian'] = 0x0561;
  9718. t['ayin'] = 0x05E2;
  9719. t['ayinaltonehebrew'] = 0xFB20;
  9720. t['ayinhebrew'] = 0x05E2;
  9721. t['b'] = 0x0062;
  9722. t['babengali'] = 0x09AC;
  9723. t['backslash'] = 0x005C;
  9724. t['backslashmonospace'] = 0xFF3C;
  9725. t['badeva'] = 0x092C;
  9726. t['bagujarati'] = 0x0AAC;
  9727. t['bagurmukhi'] = 0x0A2C;
  9728. t['bahiragana'] = 0x3070;
  9729. t['bahtthai'] = 0x0E3F;
  9730. t['bakatakana'] = 0x30D0;
  9731. t['bar'] = 0x007C;
  9732. t['barmonospace'] = 0xFF5C;
  9733. t['bbopomofo'] = 0x3105;
  9734. t['bcircle'] = 0x24D1;
  9735. t['bdotaccent'] = 0x1E03;
  9736. t['bdotbelow'] = 0x1E05;
  9737. t['beamedsixteenthnotes'] = 0x266C;
  9738. t['because'] = 0x2235;
  9739. t['becyrillic'] = 0x0431;
  9740. t['beharabic'] = 0x0628;
  9741. t['behfinalarabic'] = 0xFE90;
  9742. t['behinitialarabic'] = 0xFE91;
  9743. t['behiragana'] = 0x3079;
  9744. t['behmedialarabic'] = 0xFE92;
  9745. t['behmeeminitialarabic'] = 0xFC9F;
  9746. t['behmeemisolatedarabic'] = 0xFC08;
  9747. t['behnoonfinalarabic'] = 0xFC6D;
  9748. t['bekatakana'] = 0x30D9;
  9749. t['benarmenian'] = 0x0562;
  9750. t['bet'] = 0x05D1;
  9751. t['beta'] = 0x03B2;
  9752. t['betasymbolgreek'] = 0x03D0;
  9753. t['betdagesh'] = 0xFB31;
  9754. t['betdageshhebrew'] = 0xFB31;
  9755. t['bethebrew'] = 0x05D1;
  9756. t['betrafehebrew'] = 0xFB4C;
  9757. t['bhabengali'] = 0x09AD;
  9758. t['bhadeva'] = 0x092D;
  9759. t['bhagujarati'] = 0x0AAD;
  9760. t['bhagurmukhi'] = 0x0A2D;
  9761. t['bhook'] = 0x0253;
  9762. t['bihiragana'] = 0x3073;
  9763. t['bikatakana'] = 0x30D3;
  9764. t['bilabialclick'] = 0x0298;
  9765. t['bindigurmukhi'] = 0x0A02;
  9766. t['birusquare'] = 0x3331;
  9767. t['blackcircle'] = 0x25CF;
  9768. t['blackdiamond'] = 0x25C6;
  9769. t['blackdownpointingtriangle'] = 0x25BC;
  9770. t['blackleftpointingpointer'] = 0x25C4;
  9771. t['blackleftpointingtriangle'] = 0x25C0;
  9772. t['blacklenticularbracketleft'] = 0x3010;
  9773. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9774. t['blacklenticularbracketright'] = 0x3011;
  9775. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9776. t['blacklowerlefttriangle'] = 0x25E3;
  9777. t['blacklowerrighttriangle'] = 0x25E2;
  9778. t['blackrectangle'] = 0x25AC;
  9779. t['blackrightpointingpointer'] = 0x25BA;
  9780. t['blackrightpointingtriangle'] = 0x25B6;
  9781. t['blacksmallsquare'] = 0x25AA;
  9782. t['blacksmilingface'] = 0x263B;
  9783. t['blacksquare'] = 0x25A0;
  9784. t['blackstar'] = 0x2605;
  9785. t['blackupperlefttriangle'] = 0x25E4;
  9786. t['blackupperrighttriangle'] = 0x25E5;
  9787. t['blackuppointingsmalltriangle'] = 0x25B4;
  9788. t['blackuppointingtriangle'] = 0x25B2;
  9789. t['blank'] = 0x2423;
  9790. t['blinebelow'] = 0x1E07;
  9791. t['block'] = 0x2588;
  9792. t['bmonospace'] = 0xFF42;
  9793. t['bobaimaithai'] = 0x0E1A;
  9794. t['bohiragana'] = 0x307C;
  9795. t['bokatakana'] = 0x30DC;
  9796. t['bparen'] = 0x249D;
  9797. t['bqsquare'] = 0x33C3;
  9798. t['braceex'] = 0xF8F4;
  9799. t['braceleft'] = 0x007B;
  9800. t['braceleftbt'] = 0xF8F3;
  9801. t['braceleftmid'] = 0xF8F2;
  9802. t['braceleftmonospace'] = 0xFF5B;
  9803. t['braceleftsmall'] = 0xFE5B;
  9804. t['bracelefttp'] = 0xF8F1;
  9805. t['braceleftvertical'] = 0xFE37;
  9806. t['braceright'] = 0x007D;
  9807. t['bracerightbt'] = 0xF8FE;
  9808. t['bracerightmid'] = 0xF8FD;
  9809. t['bracerightmonospace'] = 0xFF5D;
  9810. t['bracerightsmall'] = 0xFE5C;
  9811. t['bracerighttp'] = 0xF8FC;
  9812. t['bracerightvertical'] = 0xFE38;
  9813. t['bracketleft'] = 0x005B;
  9814. t['bracketleftbt'] = 0xF8F0;
  9815. t['bracketleftex'] = 0xF8EF;
  9816. t['bracketleftmonospace'] = 0xFF3B;
  9817. t['bracketlefttp'] = 0xF8EE;
  9818. t['bracketright'] = 0x005D;
  9819. t['bracketrightbt'] = 0xF8FB;
  9820. t['bracketrightex'] = 0xF8FA;
  9821. t['bracketrightmonospace'] = 0xFF3D;
  9822. t['bracketrighttp'] = 0xF8F9;
  9823. t['breve'] = 0x02D8;
  9824. t['brevebelowcmb'] = 0x032E;
  9825. t['brevecmb'] = 0x0306;
  9826. t['breveinvertedbelowcmb'] = 0x032F;
  9827. t['breveinvertedcmb'] = 0x0311;
  9828. t['breveinverteddoublecmb'] = 0x0361;
  9829. t['bridgebelowcmb'] = 0x032A;
  9830. t['bridgeinvertedbelowcmb'] = 0x033A;
  9831. t['brokenbar'] = 0x00A6;
  9832. t['bstroke'] = 0x0180;
  9833. t['bsuperior'] = 0xF6EA;
  9834. t['btopbar'] = 0x0183;
  9835. t['buhiragana'] = 0x3076;
  9836. t['bukatakana'] = 0x30D6;
  9837. t['bullet'] = 0x2022;
  9838. t['bulletinverse'] = 0x25D8;
  9839. t['bulletoperator'] = 0x2219;
  9840. t['bullseye'] = 0x25CE;
  9841. t['c'] = 0x0063;
  9842. t['caarmenian'] = 0x056E;
  9843. t['cabengali'] = 0x099A;
  9844. t['cacute'] = 0x0107;
  9845. t['cadeva'] = 0x091A;
  9846. t['cagujarati'] = 0x0A9A;
  9847. t['cagurmukhi'] = 0x0A1A;
  9848. t['calsquare'] = 0x3388;
  9849. t['candrabindubengali'] = 0x0981;
  9850. t['candrabinducmb'] = 0x0310;
  9851. t['candrabindudeva'] = 0x0901;
  9852. t['candrabindugujarati'] = 0x0A81;
  9853. t['capslock'] = 0x21EA;
  9854. t['careof'] = 0x2105;
  9855. t['caron'] = 0x02C7;
  9856. t['caronbelowcmb'] = 0x032C;
  9857. t['caroncmb'] = 0x030C;
  9858. t['carriagereturn'] = 0x21B5;
  9859. t['cbopomofo'] = 0x3118;
  9860. t['ccaron'] = 0x010D;
  9861. t['ccedilla'] = 0x00E7;
  9862. t['ccedillaacute'] = 0x1E09;
  9863. t['ccircle'] = 0x24D2;
  9864. t['ccircumflex'] = 0x0109;
  9865. t['ccurl'] = 0x0255;
  9866. t['cdot'] = 0x010B;
  9867. t['cdotaccent'] = 0x010B;
  9868. t['cdsquare'] = 0x33C5;
  9869. t['cedilla'] = 0x00B8;
  9870. t['cedillacmb'] = 0x0327;
  9871. t['cent'] = 0x00A2;
  9872. t['centigrade'] = 0x2103;
  9873. t['centinferior'] = 0xF6DF;
  9874. t['centmonospace'] = 0xFFE0;
  9875. t['centoldstyle'] = 0xF7A2;
  9876. t['centsuperior'] = 0xF6E0;
  9877. t['chaarmenian'] = 0x0579;
  9878. t['chabengali'] = 0x099B;
  9879. t['chadeva'] = 0x091B;
  9880. t['chagujarati'] = 0x0A9B;
  9881. t['chagurmukhi'] = 0x0A1B;
  9882. t['chbopomofo'] = 0x3114;
  9883. t['cheabkhasiancyrillic'] = 0x04BD;
  9884. t['checkmark'] = 0x2713;
  9885. t['checyrillic'] = 0x0447;
  9886. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9887. t['chedescendercyrillic'] = 0x04B7;
  9888. t['chedieresiscyrillic'] = 0x04F5;
  9889. t['cheharmenian'] = 0x0573;
  9890. t['chekhakassiancyrillic'] = 0x04CC;
  9891. t['cheverticalstrokecyrillic'] = 0x04B9;
  9892. t['chi'] = 0x03C7;
  9893. t['chieuchacirclekorean'] = 0x3277;
  9894. t['chieuchaparenkorean'] = 0x3217;
  9895. t['chieuchcirclekorean'] = 0x3269;
  9896. t['chieuchkorean'] = 0x314A;
  9897. t['chieuchparenkorean'] = 0x3209;
  9898. t['chochangthai'] = 0x0E0A;
  9899. t['chochanthai'] = 0x0E08;
  9900. t['chochingthai'] = 0x0E09;
  9901. t['chochoethai'] = 0x0E0C;
  9902. t['chook'] = 0x0188;
  9903. t['cieucacirclekorean'] = 0x3276;
  9904. t['cieucaparenkorean'] = 0x3216;
  9905. t['cieuccirclekorean'] = 0x3268;
  9906. t['cieuckorean'] = 0x3148;
  9907. t['cieucparenkorean'] = 0x3208;
  9908. t['cieucuparenkorean'] = 0x321C;
  9909. t['circle'] = 0x25CB;
  9910. t['circlecopyrt'] = 0x00A9;
  9911. t['circlemultiply'] = 0x2297;
  9912. t['circleot'] = 0x2299;
  9913. t['circleplus'] = 0x2295;
  9914. t['circlepostalmark'] = 0x3036;
  9915. t['circlewithlefthalfblack'] = 0x25D0;
  9916. t['circlewithrighthalfblack'] = 0x25D1;
  9917. t['circumflex'] = 0x02C6;
  9918. t['circumflexbelowcmb'] = 0x032D;
  9919. t['circumflexcmb'] = 0x0302;
  9920. t['clear'] = 0x2327;
  9921. t['clickalveolar'] = 0x01C2;
  9922. t['clickdental'] = 0x01C0;
  9923. t['clicklateral'] = 0x01C1;
  9924. t['clickretroflex'] = 0x01C3;
  9925. t['club'] = 0x2663;
  9926. t['clubsuitblack'] = 0x2663;
  9927. t['clubsuitwhite'] = 0x2667;
  9928. t['cmcubedsquare'] = 0x33A4;
  9929. t['cmonospace'] = 0xFF43;
  9930. t['cmsquaredsquare'] = 0x33A0;
  9931. t['coarmenian'] = 0x0581;
  9932. t['colon'] = 0x003A;
  9933. t['colonmonetary'] = 0x20A1;
  9934. t['colonmonospace'] = 0xFF1A;
  9935. t['colonsign'] = 0x20A1;
  9936. t['colonsmall'] = 0xFE55;
  9937. t['colontriangularhalfmod'] = 0x02D1;
  9938. t['colontriangularmod'] = 0x02D0;
  9939. t['comma'] = 0x002C;
  9940. t['commaabovecmb'] = 0x0313;
  9941. t['commaaboverightcmb'] = 0x0315;
  9942. t['commaaccent'] = 0xF6C3;
  9943. t['commaarabic'] = 0x060C;
  9944. t['commaarmenian'] = 0x055D;
  9945. t['commainferior'] = 0xF6E1;
  9946. t['commamonospace'] = 0xFF0C;
  9947. t['commareversedabovecmb'] = 0x0314;
  9948. t['commareversedmod'] = 0x02BD;
  9949. t['commasmall'] = 0xFE50;
  9950. t['commasuperior'] = 0xF6E2;
  9951. t['commaturnedabovecmb'] = 0x0312;
  9952. t['commaturnedmod'] = 0x02BB;
  9953. t['compass'] = 0x263C;
  9954. t['congruent'] = 0x2245;
  9955. t['contourintegral'] = 0x222E;
  9956. t['control'] = 0x2303;
  9957. t['controlACK'] = 0x0006;
  9958. t['controlBEL'] = 0x0007;
  9959. t['controlBS'] = 0x0008;
  9960. t['controlCAN'] = 0x0018;
  9961. t['controlCR'] = 0x000D;
  9962. t['controlDC1'] = 0x0011;
  9963. t['controlDC2'] = 0x0012;
  9964. t['controlDC3'] = 0x0013;
  9965. t['controlDC4'] = 0x0014;
  9966. t['controlDEL'] = 0x007F;
  9967. t['controlDLE'] = 0x0010;
  9968. t['controlEM'] = 0x0019;
  9969. t['controlENQ'] = 0x0005;
  9970. t['controlEOT'] = 0x0004;
  9971. t['controlESC'] = 0x001B;
  9972. t['controlETB'] = 0x0017;
  9973. t['controlETX'] = 0x0003;
  9974. t['controlFF'] = 0x000C;
  9975. t['controlFS'] = 0x001C;
  9976. t['controlGS'] = 0x001D;
  9977. t['controlHT'] = 0x0009;
  9978. t['controlLF'] = 0x000A;
  9979. t['controlNAK'] = 0x0015;
  9980. t['controlRS'] = 0x001E;
  9981. t['controlSI'] = 0x000F;
  9982. t['controlSO'] = 0x000E;
  9983. t['controlSOT'] = 0x0002;
  9984. t['controlSTX'] = 0x0001;
  9985. t['controlSUB'] = 0x001A;
  9986. t['controlSYN'] = 0x0016;
  9987. t['controlUS'] = 0x001F;
  9988. t['controlVT'] = 0x000B;
  9989. t['copyright'] = 0x00A9;
  9990. t['copyrightsans'] = 0xF8E9;
  9991. t['copyrightserif'] = 0xF6D9;
  9992. t['cornerbracketleft'] = 0x300C;
  9993. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9994. t['cornerbracketleftvertical'] = 0xFE41;
  9995. t['cornerbracketright'] = 0x300D;
  9996. t['cornerbracketrighthalfwidth'] = 0xFF63;
  9997. t['cornerbracketrightvertical'] = 0xFE42;
  9998. t['corporationsquare'] = 0x337F;
  9999. t['cosquare'] = 0x33C7;
  10000. t['coverkgsquare'] = 0x33C6;
  10001. t['cparen'] = 0x249E;
  10002. t['cruzeiro'] = 0x20A2;
  10003. t['cstretched'] = 0x0297;
  10004. t['curlyand'] = 0x22CF;
  10005. t['curlyor'] = 0x22CE;
  10006. t['currency'] = 0x00A4;
  10007. t['cyrBreve'] = 0xF6D1;
  10008. t['cyrFlex'] = 0xF6D2;
  10009. t['cyrbreve'] = 0xF6D4;
  10010. t['cyrflex'] = 0xF6D5;
  10011. t['d'] = 0x0064;
  10012. t['daarmenian'] = 0x0564;
  10013. t['dabengali'] = 0x09A6;
  10014. t['dadarabic'] = 0x0636;
  10015. t['dadeva'] = 0x0926;
  10016. t['dadfinalarabic'] = 0xFEBE;
  10017. t['dadinitialarabic'] = 0xFEBF;
  10018. t['dadmedialarabic'] = 0xFEC0;
  10019. t['dagesh'] = 0x05BC;
  10020. t['dageshhebrew'] = 0x05BC;
  10021. t['dagger'] = 0x2020;
  10022. t['daggerdbl'] = 0x2021;
  10023. t['dagujarati'] = 0x0AA6;
  10024. t['dagurmukhi'] = 0x0A26;
  10025. t['dahiragana'] = 0x3060;
  10026. t['dakatakana'] = 0x30C0;
  10027. t['dalarabic'] = 0x062F;
  10028. t['dalet'] = 0x05D3;
  10029. t['daletdagesh'] = 0xFB33;
  10030. t['daletdageshhebrew'] = 0xFB33;
  10031. t['dalethebrew'] = 0x05D3;
  10032. t['dalfinalarabic'] = 0xFEAA;
  10033. t['dammaarabic'] = 0x064F;
  10034. t['dammalowarabic'] = 0x064F;
  10035. t['dammatanaltonearabic'] = 0x064C;
  10036. t['dammatanarabic'] = 0x064C;
  10037. t['danda'] = 0x0964;
  10038. t['dargahebrew'] = 0x05A7;
  10039. t['dargalefthebrew'] = 0x05A7;
  10040. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10041. t['dblGrave'] = 0xF6D3;
  10042. t['dblanglebracketleft'] = 0x300A;
  10043. t['dblanglebracketleftvertical'] = 0xFE3D;
  10044. t['dblanglebracketright'] = 0x300B;
  10045. t['dblanglebracketrightvertical'] = 0xFE3E;
  10046. t['dblarchinvertedbelowcmb'] = 0x032B;
  10047. t['dblarrowleft'] = 0x21D4;
  10048. t['dblarrowright'] = 0x21D2;
  10049. t['dbldanda'] = 0x0965;
  10050. t['dblgrave'] = 0xF6D6;
  10051. t['dblgravecmb'] = 0x030F;
  10052. t['dblintegral'] = 0x222C;
  10053. t['dbllowline'] = 0x2017;
  10054. t['dbllowlinecmb'] = 0x0333;
  10055. t['dbloverlinecmb'] = 0x033F;
  10056. t['dblprimemod'] = 0x02BA;
  10057. t['dblverticalbar'] = 0x2016;
  10058. t['dblverticallineabovecmb'] = 0x030E;
  10059. t['dbopomofo'] = 0x3109;
  10060. t['dbsquare'] = 0x33C8;
  10061. t['dcaron'] = 0x010F;
  10062. t['dcedilla'] = 0x1E11;
  10063. t['dcircle'] = 0x24D3;
  10064. t['dcircumflexbelow'] = 0x1E13;
  10065. t['dcroat'] = 0x0111;
  10066. t['ddabengali'] = 0x09A1;
  10067. t['ddadeva'] = 0x0921;
  10068. t['ddagujarati'] = 0x0AA1;
  10069. t['ddagurmukhi'] = 0x0A21;
  10070. t['ddalarabic'] = 0x0688;
  10071. t['ddalfinalarabic'] = 0xFB89;
  10072. t['dddhadeva'] = 0x095C;
  10073. t['ddhabengali'] = 0x09A2;
  10074. t['ddhadeva'] = 0x0922;
  10075. t['ddhagujarati'] = 0x0AA2;
  10076. t['ddhagurmukhi'] = 0x0A22;
  10077. t['ddotaccent'] = 0x1E0B;
  10078. t['ddotbelow'] = 0x1E0D;
  10079. t['decimalseparatorarabic'] = 0x066B;
  10080. t['decimalseparatorpersian'] = 0x066B;
  10081. t['decyrillic'] = 0x0434;
  10082. t['degree'] = 0x00B0;
  10083. t['dehihebrew'] = 0x05AD;
  10084. t['dehiragana'] = 0x3067;
  10085. t['deicoptic'] = 0x03EF;
  10086. t['dekatakana'] = 0x30C7;
  10087. t['deleteleft'] = 0x232B;
  10088. t['deleteright'] = 0x2326;
  10089. t['delta'] = 0x03B4;
  10090. t['deltaturned'] = 0x018D;
  10091. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10092. t['dezh'] = 0x02A4;
  10093. t['dhabengali'] = 0x09A7;
  10094. t['dhadeva'] = 0x0927;
  10095. t['dhagujarati'] = 0x0AA7;
  10096. t['dhagurmukhi'] = 0x0A27;
  10097. t['dhook'] = 0x0257;
  10098. t['dialytikatonos'] = 0x0385;
  10099. t['dialytikatonoscmb'] = 0x0344;
  10100. t['diamond'] = 0x2666;
  10101. t['diamondsuitwhite'] = 0x2662;
  10102. t['dieresis'] = 0x00A8;
  10103. t['dieresisacute'] = 0xF6D7;
  10104. t['dieresisbelowcmb'] = 0x0324;
  10105. t['dieresiscmb'] = 0x0308;
  10106. t['dieresisgrave'] = 0xF6D8;
  10107. t['dieresistonos'] = 0x0385;
  10108. t['dihiragana'] = 0x3062;
  10109. t['dikatakana'] = 0x30C2;
  10110. t['dittomark'] = 0x3003;
  10111. t['divide'] = 0x00F7;
  10112. t['divides'] = 0x2223;
  10113. t['divisionslash'] = 0x2215;
  10114. t['djecyrillic'] = 0x0452;
  10115. t['dkshade'] = 0x2593;
  10116. t['dlinebelow'] = 0x1E0F;
  10117. t['dlsquare'] = 0x3397;
  10118. t['dmacron'] = 0x0111;
  10119. t['dmonospace'] = 0xFF44;
  10120. t['dnblock'] = 0x2584;
  10121. t['dochadathai'] = 0x0E0E;
  10122. t['dodekthai'] = 0x0E14;
  10123. t['dohiragana'] = 0x3069;
  10124. t['dokatakana'] = 0x30C9;
  10125. t['dollar'] = 0x0024;
  10126. t['dollarinferior'] = 0xF6E3;
  10127. t['dollarmonospace'] = 0xFF04;
  10128. t['dollaroldstyle'] = 0xF724;
  10129. t['dollarsmall'] = 0xFE69;
  10130. t['dollarsuperior'] = 0xF6E4;
  10131. t['dong'] = 0x20AB;
  10132. t['dorusquare'] = 0x3326;
  10133. t['dotaccent'] = 0x02D9;
  10134. t['dotaccentcmb'] = 0x0307;
  10135. t['dotbelowcmb'] = 0x0323;
  10136. t['dotbelowcomb'] = 0x0323;
  10137. t['dotkatakana'] = 0x30FB;
  10138. t['dotlessi'] = 0x0131;
  10139. t['dotlessj'] = 0xF6BE;
  10140. t['dotlessjstrokehook'] = 0x0284;
  10141. t['dotmath'] = 0x22C5;
  10142. t['dottedcircle'] = 0x25CC;
  10143. t['doubleyodpatah'] = 0xFB1F;
  10144. t['doubleyodpatahhebrew'] = 0xFB1F;
  10145. t['downtackbelowcmb'] = 0x031E;
  10146. t['downtackmod'] = 0x02D5;
  10147. t['dparen'] = 0x249F;
  10148. t['dsuperior'] = 0xF6EB;
  10149. t['dtail'] = 0x0256;
  10150. t['dtopbar'] = 0x018C;
  10151. t['duhiragana'] = 0x3065;
  10152. t['dukatakana'] = 0x30C5;
  10153. t['dz'] = 0x01F3;
  10154. t['dzaltone'] = 0x02A3;
  10155. t['dzcaron'] = 0x01C6;
  10156. t['dzcurl'] = 0x02A5;
  10157. t['dzeabkhasiancyrillic'] = 0x04E1;
  10158. t['dzecyrillic'] = 0x0455;
  10159. t['dzhecyrillic'] = 0x045F;
  10160. t['e'] = 0x0065;
  10161. t['eacute'] = 0x00E9;
  10162. t['earth'] = 0x2641;
  10163. t['ebengali'] = 0x098F;
  10164. t['ebopomofo'] = 0x311C;
  10165. t['ebreve'] = 0x0115;
  10166. t['ecandradeva'] = 0x090D;
  10167. t['ecandragujarati'] = 0x0A8D;
  10168. t['ecandravowelsigndeva'] = 0x0945;
  10169. t['ecandravowelsigngujarati'] = 0x0AC5;
  10170. t['ecaron'] = 0x011B;
  10171. t['ecedillabreve'] = 0x1E1D;
  10172. t['echarmenian'] = 0x0565;
  10173. t['echyiwnarmenian'] = 0x0587;
  10174. t['ecircle'] = 0x24D4;
  10175. t['ecircumflex'] = 0x00EA;
  10176. t['ecircumflexacute'] = 0x1EBF;
  10177. t['ecircumflexbelow'] = 0x1E19;
  10178. t['ecircumflexdotbelow'] = 0x1EC7;
  10179. t['ecircumflexgrave'] = 0x1EC1;
  10180. t['ecircumflexhookabove'] = 0x1EC3;
  10181. t['ecircumflextilde'] = 0x1EC5;
  10182. t['ecyrillic'] = 0x0454;
  10183. t['edblgrave'] = 0x0205;
  10184. t['edeva'] = 0x090F;
  10185. t['edieresis'] = 0x00EB;
  10186. t['edot'] = 0x0117;
  10187. t['edotaccent'] = 0x0117;
  10188. t['edotbelow'] = 0x1EB9;
  10189. t['eegurmukhi'] = 0x0A0F;
  10190. t['eematragurmukhi'] = 0x0A47;
  10191. t['efcyrillic'] = 0x0444;
  10192. t['egrave'] = 0x00E8;
  10193. t['egujarati'] = 0x0A8F;
  10194. t['eharmenian'] = 0x0567;
  10195. t['ehbopomofo'] = 0x311D;
  10196. t['ehiragana'] = 0x3048;
  10197. t['ehookabove'] = 0x1EBB;
  10198. t['eibopomofo'] = 0x311F;
  10199. t['eight'] = 0x0038;
  10200. t['eightarabic'] = 0x0668;
  10201. t['eightbengali'] = 0x09EE;
  10202. t['eightcircle'] = 0x2467;
  10203. t['eightcircleinversesansserif'] = 0x2791;
  10204. t['eightdeva'] = 0x096E;
  10205. t['eighteencircle'] = 0x2471;
  10206. t['eighteenparen'] = 0x2485;
  10207. t['eighteenperiod'] = 0x2499;
  10208. t['eightgujarati'] = 0x0AEE;
  10209. t['eightgurmukhi'] = 0x0A6E;
  10210. t['eighthackarabic'] = 0x0668;
  10211. t['eighthangzhou'] = 0x3028;
  10212. t['eighthnotebeamed'] = 0x266B;
  10213. t['eightideographicparen'] = 0x3227;
  10214. t['eightinferior'] = 0x2088;
  10215. t['eightmonospace'] = 0xFF18;
  10216. t['eightoldstyle'] = 0xF738;
  10217. t['eightparen'] = 0x247B;
  10218. t['eightperiod'] = 0x248F;
  10219. t['eightpersian'] = 0x06F8;
  10220. t['eightroman'] = 0x2177;
  10221. t['eightsuperior'] = 0x2078;
  10222. t['eightthai'] = 0x0E58;
  10223. t['einvertedbreve'] = 0x0207;
  10224. t['eiotifiedcyrillic'] = 0x0465;
  10225. t['ekatakana'] = 0x30A8;
  10226. t['ekatakanahalfwidth'] = 0xFF74;
  10227. t['ekonkargurmukhi'] = 0x0A74;
  10228. t['ekorean'] = 0x3154;
  10229. t['elcyrillic'] = 0x043B;
  10230. t['element'] = 0x2208;
  10231. t['elevencircle'] = 0x246A;
  10232. t['elevenparen'] = 0x247E;
  10233. t['elevenperiod'] = 0x2492;
  10234. t['elevenroman'] = 0x217A;
  10235. t['ellipsis'] = 0x2026;
  10236. t['ellipsisvertical'] = 0x22EE;
  10237. t['emacron'] = 0x0113;
  10238. t['emacronacute'] = 0x1E17;
  10239. t['emacrongrave'] = 0x1E15;
  10240. t['emcyrillic'] = 0x043C;
  10241. t['emdash'] = 0x2014;
  10242. t['emdashvertical'] = 0xFE31;
  10243. t['emonospace'] = 0xFF45;
  10244. t['emphasismarkarmenian'] = 0x055B;
  10245. t['emptyset'] = 0x2205;
  10246. t['enbopomofo'] = 0x3123;
  10247. t['encyrillic'] = 0x043D;
  10248. t['endash'] = 0x2013;
  10249. t['endashvertical'] = 0xFE32;
  10250. t['endescendercyrillic'] = 0x04A3;
  10251. t['eng'] = 0x014B;
  10252. t['engbopomofo'] = 0x3125;
  10253. t['enghecyrillic'] = 0x04A5;
  10254. t['enhookcyrillic'] = 0x04C8;
  10255. t['enspace'] = 0x2002;
  10256. t['eogonek'] = 0x0119;
  10257. t['eokorean'] = 0x3153;
  10258. t['eopen'] = 0x025B;
  10259. t['eopenclosed'] = 0x029A;
  10260. t['eopenreversed'] = 0x025C;
  10261. t['eopenreversedclosed'] = 0x025E;
  10262. t['eopenreversedhook'] = 0x025D;
  10263. t['eparen'] = 0x24A0;
  10264. t['epsilon'] = 0x03B5;
  10265. t['epsilontonos'] = 0x03AD;
  10266. t['equal'] = 0x003D;
  10267. t['equalmonospace'] = 0xFF1D;
  10268. t['equalsmall'] = 0xFE66;
  10269. t['equalsuperior'] = 0x207C;
  10270. t['equivalence'] = 0x2261;
  10271. t['erbopomofo'] = 0x3126;
  10272. t['ercyrillic'] = 0x0440;
  10273. t['ereversed'] = 0x0258;
  10274. t['ereversedcyrillic'] = 0x044D;
  10275. t['escyrillic'] = 0x0441;
  10276. t['esdescendercyrillic'] = 0x04AB;
  10277. t['esh'] = 0x0283;
  10278. t['eshcurl'] = 0x0286;
  10279. t['eshortdeva'] = 0x090E;
  10280. t['eshortvowelsigndeva'] = 0x0946;
  10281. t['eshreversedloop'] = 0x01AA;
  10282. t['eshsquatreversed'] = 0x0285;
  10283. t['esmallhiragana'] = 0x3047;
  10284. t['esmallkatakana'] = 0x30A7;
  10285. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10286. t['estimated'] = 0x212E;
  10287. t['esuperior'] = 0xF6EC;
  10288. t['eta'] = 0x03B7;
  10289. t['etarmenian'] = 0x0568;
  10290. t['etatonos'] = 0x03AE;
  10291. t['eth'] = 0x00F0;
  10292. t['etilde'] = 0x1EBD;
  10293. t['etildebelow'] = 0x1E1B;
  10294. t['etnahtafoukhhebrew'] = 0x0591;
  10295. t['etnahtafoukhlefthebrew'] = 0x0591;
  10296. t['etnahtahebrew'] = 0x0591;
  10297. t['etnahtalefthebrew'] = 0x0591;
  10298. t['eturned'] = 0x01DD;
  10299. t['eukorean'] = 0x3161;
  10300. t['euro'] = 0x20AC;
  10301. t['evowelsignbengali'] = 0x09C7;
  10302. t['evowelsigndeva'] = 0x0947;
  10303. t['evowelsigngujarati'] = 0x0AC7;
  10304. t['exclam'] = 0x0021;
  10305. t['exclamarmenian'] = 0x055C;
  10306. t['exclamdbl'] = 0x203C;
  10307. t['exclamdown'] = 0x00A1;
  10308. t['exclamdownsmall'] = 0xF7A1;
  10309. t['exclammonospace'] = 0xFF01;
  10310. t['exclamsmall'] = 0xF721;
  10311. t['existential'] = 0x2203;
  10312. t['ezh'] = 0x0292;
  10313. t['ezhcaron'] = 0x01EF;
  10314. t['ezhcurl'] = 0x0293;
  10315. t['ezhreversed'] = 0x01B9;
  10316. t['ezhtail'] = 0x01BA;
  10317. t['f'] = 0x0066;
  10318. t['fadeva'] = 0x095E;
  10319. t['fagurmukhi'] = 0x0A5E;
  10320. t['fahrenheit'] = 0x2109;
  10321. t['fathaarabic'] = 0x064E;
  10322. t['fathalowarabic'] = 0x064E;
  10323. t['fathatanarabic'] = 0x064B;
  10324. t['fbopomofo'] = 0x3108;
  10325. t['fcircle'] = 0x24D5;
  10326. t['fdotaccent'] = 0x1E1F;
  10327. t['feharabic'] = 0x0641;
  10328. t['feharmenian'] = 0x0586;
  10329. t['fehfinalarabic'] = 0xFED2;
  10330. t['fehinitialarabic'] = 0xFED3;
  10331. t['fehmedialarabic'] = 0xFED4;
  10332. t['feicoptic'] = 0x03E5;
  10333. t['female'] = 0x2640;
  10334. t['ff'] = 0xFB00;
  10335. t['ffi'] = 0xFB03;
  10336. t['ffl'] = 0xFB04;
  10337. t['fi'] = 0xFB01;
  10338. t['fifteencircle'] = 0x246E;
  10339. t['fifteenparen'] = 0x2482;
  10340. t['fifteenperiod'] = 0x2496;
  10341. t['figuredash'] = 0x2012;
  10342. t['filledbox'] = 0x25A0;
  10343. t['filledrect'] = 0x25AC;
  10344. t['finalkaf'] = 0x05DA;
  10345. t['finalkafdagesh'] = 0xFB3A;
  10346. t['finalkafdageshhebrew'] = 0xFB3A;
  10347. t['finalkafhebrew'] = 0x05DA;
  10348. t['finalmem'] = 0x05DD;
  10349. t['finalmemhebrew'] = 0x05DD;
  10350. t['finalnun'] = 0x05DF;
  10351. t['finalnunhebrew'] = 0x05DF;
  10352. t['finalpe'] = 0x05E3;
  10353. t['finalpehebrew'] = 0x05E3;
  10354. t['finaltsadi'] = 0x05E5;
  10355. t['finaltsadihebrew'] = 0x05E5;
  10356. t['firsttonechinese'] = 0x02C9;
  10357. t['fisheye'] = 0x25C9;
  10358. t['fitacyrillic'] = 0x0473;
  10359. t['five'] = 0x0035;
  10360. t['fivearabic'] = 0x0665;
  10361. t['fivebengali'] = 0x09EB;
  10362. t['fivecircle'] = 0x2464;
  10363. t['fivecircleinversesansserif'] = 0x278E;
  10364. t['fivedeva'] = 0x096B;
  10365. t['fiveeighths'] = 0x215D;
  10366. t['fivegujarati'] = 0x0AEB;
  10367. t['fivegurmukhi'] = 0x0A6B;
  10368. t['fivehackarabic'] = 0x0665;
  10369. t['fivehangzhou'] = 0x3025;
  10370. t['fiveideographicparen'] = 0x3224;
  10371. t['fiveinferior'] = 0x2085;
  10372. t['fivemonospace'] = 0xFF15;
  10373. t['fiveoldstyle'] = 0xF735;
  10374. t['fiveparen'] = 0x2478;
  10375. t['fiveperiod'] = 0x248C;
  10376. t['fivepersian'] = 0x06F5;
  10377. t['fiveroman'] = 0x2174;
  10378. t['fivesuperior'] = 0x2075;
  10379. t['fivethai'] = 0x0E55;
  10380. t['fl'] = 0xFB02;
  10381. t['florin'] = 0x0192;
  10382. t['fmonospace'] = 0xFF46;
  10383. t['fmsquare'] = 0x3399;
  10384. t['fofanthai'] = 0x0E1F;
  10385. t['fofathai'] = 0x0E1D;
  10386. t['fongmanthai'] = 0x0E4F;
  10387. t['forall'] = 0x2200;
  10388. t['four'] = 0x0034;
  10389. t['fourarabic'] = 0x0664;
  10390. t['fourbengali'] = 0x09EA;
  10391. t['fourcircle'] = 0x2463;
  10392. t['fourcircleinversesansserif'] = 0x278D;
  10393. t['fourdeva'] = 0x096A;
  10394. t['fourgujarati'] = 0x0AEA;
  10395. t['fourgurmukhi'] = 0x0A6A;
  10396. t['fourhackarabic'] = 0x0664;
  10397. t['fourhangzhou'] = 0x3024;
  10398. t['fourideographicparen'] = 0x3223;
  10399. t['fourinferior'] = 0x2084;
  10400. t['fourmonospace'] = 0xFF14;
  10401. t['fournumeratorbengali'] = 0x09F7;
  10402. t['fouroldstyle'] = 0xF734;
  10403. t['fourparen'] = 0x2477;
  10404. t['fourperiod'] = 0x248B;
  10405. t['fourpersian'] = 0x06F4;
  10406. t['fourroman'] = 0x2173;
  10407. t['foursuperior'] = 0x2074;
  10408. t['fourteencircle'] = 0x246D;
  10409. t['fourteenparen'] = 0x2481;
  10410. t['fourteenperiod'] = 0x2495;
  10411. t['fourthai'] = 0x0E54;
  10412. t['fourthtonechinese'] = 0x02CB;
  10413. t['fparen'] = 0x24A1;
  10414. t['fraction'] = 0x2044;
  10415. t['franc'] = 0x20A3;
  10416. t['g'] = 0x0067;
  10417. t['gabengali'] = 0x0997;
  10418. t['gacute'] = 0x01F5;
  10419. t['gadeva'] = 0x0917;
  10420. t['gafarabic'] = 0x06AF;
  10421. t['gaffinalarabic'] = 0xFB93;
  10422. t['gafinitialarabic'] = 0xFB94;
  10423. t['gafmedialarabic'] = 0xFB95;
  10424. t['gagujarati'] = 0x0A97;
  10425. t['gagurmukhi'] = 0x0A17;
  10426. t['gahiragana'] = 0x304C;
  10427. t['gakatakana'] = 0x30AC;
  10428. t['gamma'] = 0x03B3;
  10429. t['gammalatinsmall'] = 0x0263;
  10430. t['gammasuperior'] = 0x02E0;
  10431. t['gangiacoptic'] = 0x03EB;
  10432. t['gbopomofo'] = 0x310D;
  10433. t['gbreve'] = 0x011F;
  10434. t['gcaron'] = 0x01E7;
  10435. t['gcedilla'] = 0x0123;
  10436. t['gcircle'] = 0x24D6;
  10437. t['gcircumflex'] = 0x011D;
  10438. t['gcommaaccent'] = 0x0123;
  10439. t['gdot'] = 0x0121;
  10440. t['gdotaccent'] = 0x0121;
  10441. t['gecyrillic'] = 0x0433;
  10442. t['gehiragana'] = 0x3052;
  10443. t['gekatakana'] = 0x30B2;
  10444. t['geometricallyequal'] = 0x2251;
  10445. t['gereshaccenthebrew'] = 0x059C;
  10446. t['gereshhebrew'] = 0x05F3;
  10447. t['gereshmuqdamhebrew'] = 0x059D;
  10448. t['germandbls'] = 0x00DF;
  10449. t['gershayimaccenthebrew'] = 0x059E;
  10450. t['gershayimhebrew'] = 0x05F4;
  10451. t['getamark'] = 0x3013;
  10452. t['ghabengali'] = 0x0998;
  10453. t['ghadarmenian'] = 0x0572;
  10454. t['ghadeva'] = 0x0918;
  10455. t['ghagujarati'] = 0x0A98;
  10456. t['ghagurmukhi'] = 0x0A18;
  10457. t['ghainarabic'] = 0x063A;
  10458. t['ghainfinalarabic'] = 0xFECE;
  10459. t['ghaininitialarabic'] = 0xFECF;
  10460. t['ghainmedialarabic'] = 0xFED0;
  10461. t['ghemiddlehookcyrillic'] = 0x0495;
  10462. t['ghestrokecyrillic'] = 0x0493;
  10463. t['gheupturncyrillic'] = 0x0491;
  10464. t['ghhadeva'] = 0x095A;
  10465. t['ghhagurmukhi'] = 0x0A5A;
  10466. t['ghook'] = 0x0260;
  10467. t['ghzsquare'] = 0x3393;
  10468. t['gihiragana'] = 0x304E;
  10469. t['gikatakana'] = 0x30AE;
  10470. t['gimarmenian'] = 0x0563;
  10471. t['gimel'] = 0x05D2;
  10472. t['gimeldagesh'] = 0xFB32;
  10473. t['gimeldageshhebrew'] = 0xFB32;
  10474. t['gimelhebrew'] = 0x05D2;
  10475. t['gjecyrillic'] = 0x0453;
  10476. t['glottalinvertedstroke'] = 0x01BE;
  10477. t['glottalstop'] = 0x0294;
  10478. t['glottalstopinverted'] = 0x0296;
  10479. t['glottalstopmod'] = 0x02C0;
  10480. t['glottalstopreversed'] = 0x0295;
  10481. t['glottalstopreversedmod'] = 0x02C1;
  10482. t['glottalstopreversedsuperior'] = 0x02E4;
  10483. t['glottalstopstroke'] = 0x02A1;
  10484. t['glottalstopstrokereversed'] = 0x02A2;
  10485. t['gmacron'] = 0x1E21;
  10486. t['gmonospace'] = 0xFF47;
  10487. t['gohiragana'] = 0x3054;
  10488. t['gokatakana'] = 0x30B4;
  10489. t['gparen'] = 0x24A2;
  10490. t['gpasquare'] = 0x33AC;
  10491. t['gradient'] = 0x2207;
  10492. t['grave'] = 0x0060;
  10493. t['gravebelowcmb'] = 0x0316;
  10494. t['gravecmb'] = 0x0300;
  10495. t['gravecomb'] = 0x0300;
  10496. t['gravedeva'] = 0x0953;
  10497. t['gravelowmod'] = 0x02CE;
  10498. t['gravemonospace'] = 0xFF40;
  10499. t['gravetonecmb'] = 0x0340;
  10500. t['greater'] = 0x003E;
  10501. t['greaterequal'] = 0x2265;
  10502. t['greaterequalorless'] = 0x22DB;
  10503. t['greatermonospace'] = 0xFF1E;
  10504. t['greaterorequivalent'] = 0x2273;
  10505. t['greaterorless'] = 0x2277;
  10506. t['greateroverequal'] = 0x2267;
  10507. t['greatersmall'] = 0xFE65;
  10508. t['gscript'] = 0x0261;
  10509. t['gstroke'] = 0x01E5;
  10510. t['guhiragana'] = 0x3050;
  10511. t['guillemotleft'] = 0x00AB;
  10512. t['guillemotright'] = 0x00BB;
  10513. t['guilsinglleft'] = 0x2039;
  10514. t['guilsinglright'] = 0x203A;
  10515. t['gukatakana'] = 0x30B0;
  10516. t['guramusquare'] = 0x3318;
  10517. t['gysquare'] = 0x33C9;
  10518. t['h'] = 0x0068;
  10519. t['haabkhasiancyrillic'] = 0x04A9;
  10520. t['haaltonearabic'] = 0x06C1;
  10521. t['habengali'] = 0x09B9;
  10522. t['hadescendercyrillic'] = 0x04B3;
  10523. t['hadeva'] = 0x0939;
  10524. t['hagujarati'] = 0x0AB9;
  10525. t['hagurmukhi'] = 0x0A39;
  10526. t['haharabic'] = 0x062D;
  10527. t['hahfinalarabic'] = 0xFEA2;
  10528. t['hahinitialarabic'] = 0xFEA3;
  10529. t['hahiragana'] = 0x306F;
  10530. t['hahmedialarabic'] = 0xFEA4;
  10531. t['haitusquare'] = 0x332A;
  10532. t['hakatakana'] = 0x30CF;
  10533. t['hakatakanahalfwidth'] = 0xFF8A;
  10534. t['halantgurmukhi'] = 0x0A4D;
  10535. t['hamzaarabic'] = 0x0621;
  10536. t['hamzalowarabic'] = 0x0621;
  10537. t['hangulfiller'] = 0x3164;
  10538. t['hardsigncyrillic'] = 0x044A;
  10539. t['harpoonleftbarbup'] = 0x21BC;
  10540. t['harpoonrightbarbup'] = 0x21C0;
  10541. t['hasquare'] = 0x33CA;
  10542. t['hatafpatah'] = 0x05B2;
  10543. t['hatafpatah16'] = 0x05B2;
  10544. t['hatafpatah23'] = 0x05B2;
  10545. t['hatafpatah2f'] = 0x05B2;
  10546. t['hatafpatahhebrew'] = 0x05B2;
  10547. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10548. t['hatafpatahquarterhebrew'] = 0x05B2;
  10549. t['hatafpatahwidehebrew'] = 0x05B2;
  10550. t['hatafqamats'] = 0x05B3;
  10551. t['hatafqamats1b'] = 0x05B3;
  10552. t['hatafqamats28'] = 0x05B3;
  10553. t['hatafqamats34'] = 0x05B3;
  10554. t['hatafqamatshebrew'] = 0x05B3;
  10555. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10556. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10557. t['hatafqamatswidehebrew'] = 0x05B3;
  10558. t['hatafsegol'] = 0x05B1;
  10559. t['hatafsegol17'] = 0x05B1;
  10560. t['hatafsegol24'] = 0x05B1;
  10561. t['hatafsegol30'] = 0x05B1;
  10562. t['hatafsegolhebrew'] = 0x05B1;
  10563. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10564. t['hatafsegolquarterhebrew'] = 0x05B1;
  10565. t['hatafsegolwidehebrew'] = 0x05B1;
  10566. t['hbar'] = 0x0127;
  10567. t['hbopomofo'] = 0x310F;
  10568. t['hbrevebelow'] = 0x1E2B;
  10569. t['hcedilla'] = 0x1E29;
  10570. t['hcircle'] = 0x24D7;
  10571. t['hcircumflex'] = 0x0125;
  10572. t['hdieresis'] = 0x1E27;
  10573. t['hdotaccent'] = 0x1E23;
  10574. t['hdotbelow'] = 0x1E25;
  10575. t['he'] = 0x05D4;
  10576. t['heart'] = 0x2665;
  10577. t['heartsuitblack'] = 0x2665;
  10578. t['heartsuitwhite'] = 0x2661;
  10579. t['hedagesh'] = 0xFB34;
  10580. t['hedageshhebrew'] = 0xFB34;
  10581. t['hehaltonearabic'] = 0x06C1;
  10582. t['heharabic'] = 0x0647;
  10583. t['hehebrew'] = 0x05D4;
  10584. t['hehfinalaltonearabic'] = 0xFBA7;
  10585. t['hehfinalalttwoarabic'] = 0xFEEA;
  10586. t['hehfinalarabic'] = 0xFEEA;
  10587. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10588. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10589. t['hehinitialaltonearabic'] = 0xFBA8;
  10590. t['hehinitialarabic'] = 0xFEEB;
  10591. t['hehiragana'] = 0x3078;
  10592. t['hehmedialaltonearabic'] = 0xFBA9;
  10593. t['hehmedialarabic'] = 0xFEEC;
  10594. t['heiseierasquare'] = 0x337B;
  10595. t['hekatakana'] = 0x30D8;
  10596. t['hekatakanahalfwidth'] = 0xFF8D;
  10597. t['hekutaarusquare'] = 0x3336;
  10598. t['henghook'] = 0x0267;
  10599. t['herutusquare'] = 0x3339;
  10600. t['het'] = 0x05D7;
  10601. t['hethebrew'] = 0x05D7;
  10602. t['hhook'] = 0x0266;
  10603. t['hhooksuperior'] = 0x02B1;
  10604. t['hieuhacirclekorean'] = 0x327B;
  10605. t['hieuhaparenkorean'] = 0x321B;
  10606. t['hieuhcirclekorean'] = 0x326D;
  10607. t['hieuhkorean'] = 0x314E;
  10608. t['hieuhparenkorean'] = 0x320D;
  10609. t['hihiragana'] = 0x3072;
  10610. t['hikatakana'] = 0x30D2;
  10611. t['hikatakanahalfwidth'] = 0xFF8B;
  10612. t['hiriq'] = 0x05B4;
  10613. t['hiriq14'] = 0x05B4;
  10614. t['hiriq21'] = 0x05B4;
  10615. t['hiriq2d'] = 0x05B4;
  10616. t['hiriqhebrew'] = 0x05B4;
  10617. t['hiriqnarrowhebrew'] = 0x05B4;
  10618. t['hiriqquarterhebrew'] = 0x05B4;
  10619. t['hiriqwidehebrew'] = 0x05B4;
  10620. t['hlinebelow'] = 0x1E96;
  10621. t['hmonospace'] = 0xFF48;
  10622. t['hoarmenian'] = 0x0570;
  10623. t['hohipthai'] = 0x0E2B;
  10624. t['hohiragana'] = 0x307B;
  10625. t['hokatakana'] = 0x30DB;
  10626. t['hokatakanahalfwidth'] = 0xFF8E;
  10627. t['holam'] = 0x05B9;
  10628. t['holam19'] = 0x05B9;
  10629. t['holam26'] = 0x05B9;
  10630. t['holam32'] = 0x05B9;
  10631. t['holamhebrew'] = 0x05B9;
  10632. t['holamnarrowhebrew'] = 0x05B9;
  10633. t['holamquarterhebrew'] = 0x05B9;
  10634. t['holamwidehebrew'] = 0x05B9;
  10635. t['honokhukthai'] = 0x0E2E;
  10636. t['hookabovecomb'] = 0x0309;
  10637. t['hookcmb'] = 0x0309;
  10638. t['hookpalatalizedbelowcmb'] = 0x0321;
  10639. t['hookretroflexbelowcmb'] = 0x0322;
  10640. t['hoonsquare'] = 0x3342;
  10641. t['horicoptic'] = 0x03E9;
  10642. t['horizontalbar'] = 0x2015;
  10643. t['horncmb'] = 0x031B;
  10644. t['hotsprings'] = 0x2668;
  10645. t['house'] = 0x2302;
  10646. t['hparen'] = 0x24A3;
  10647. t['hsuperior'] = 0x02B0;
  10648. t['hturned'] = 0x0265;
  10649. t['huhiragana'] = 0x3075;
  10650. t['huiitosquare'] = 0x3333;
  10651. t['hukatakana'] = 0x30D5;
  10652. t['hukatakanahalfwidth'] = 0xFF8C;
  10653. t['hungarumlaut'] = 0x02DD;
  10654. t['hungarumlautcmb'] = 0x030B;
  10655. t['hv'] = 0x0195;
  10656. t['hyphen'] = 0x002D;
  10657. t['hypheninferior'] = 0xF6E5;
  10658. t['hyphenmonospace'] = 0xFF0D;
  10659. t['hyphensmall'] = 0xFE63;
  10660. t['hyphensuperior'] = 0xF6E6;
  10661. t['hyphentwo'] = 0x2010;
  10662. t['i'] = 0x0069;
  10663. t['iacute'] = 0x00ED;
  10664. t['iacyrillic'] = 0x044F;
  10665. t['ibengali'] = 0x0987;
  10666. t['ibopomofo'] = 0x3127;
  10667. t['ibreve'] = 0x012D;
  10668. t['icaron'] = 0x01D0;
  10669. t['icircle'] = 0x24D8;
  10670. t['icircumflex'] = 0x00EE;
  10671. t['icyrillic'] = 0x0456;
  10672. t['idblgrave'] = 0x0209;
  10673. t['ideographearthcircle'] = 0x328F;
  10674. t['ideographfirecircle'] = 0x328B;
  10675. t['ideographicallianceparen'] = 0x323F;
  10676. t['ideographiccallparen'] = 0x323A;
  10677. t['ideographiccentrecircle'] = 0x32A5;
  10678. t['ideographicclose'] = 0x3006;
  10679. t['ideographiccomma'] = 0x3001;
  10680. t['ideographiccommaleft'] = 0xFF64;
  10681. t['ideographiccongratulationparen'] = 0x3237;
  10682. t['ideographiccorrectcircle'] = 0x32A3;
  10683. t['ideographicearthparen'] = 0x322F;
  10684. t['ideographicenterpriseparen'] = 0x323D;
  10685. t['ideographicexcellentcircle'] = 0x329D;
  10686. t['ideographicfestivalparen'] = 0x3240;
  10687. t['ideographicfinancialcircle'] = 0x3296;
  10688. t['ideographicfinancialparen'] = 0x3236;
  10689. t['ideographicfireparen'] = 0x322B;
  10690. t['ideographichaveparen'] = 0x3232;
  10691. t['ideographichighcircle'] = 0x32A4;
  10692. t['ideographiciterationmark'] = 0x3005;
  10693. t['ideographiclaborcircle'] = 0x3298;
  10694. t['ideographiclaborparen'] = 0x3238;
  10695. t['ideographicleftcircle'] = 0x32A7;
  10696. t['ideographiclowcircle'] = 0x32A6;
  10697. t['ideographicmedicinecircle'] = 0x32A9;
  10698. t['ideographicmetalparen'] = 0x322E;
  10699. t['ideographicmoonparen'] = 0x322A;
  10700. t['ideographicnameparen'] = 0x3234;
  10701. t['ideographicperiod'] = 0x3002;
  10702. t['ideographicprintcircle'] = 0x329E;
  10703. t['ideographicreachparen'] = 0x3243;
  10704. t['ideographicrepresentparen'] = 0x3239;
  10705. t['ideographicresourceparen'] = 0x323E;
  10706. t['ideographicrightcircle'] = 0x32A8;
  10707. t['ideographicsecretcircle'] = 0x3299;
  10708. t['ideographicselfparen'] = 0x3242;
  10709. t['ideographicsocietyparen'] = 0x3233;
  10710. t['ideographicspace'] = 0x3000;
  10711. t['ideographicspecialparen'] = 0x3235;
  10712. t['ideographicstockparen'] = 0x3231;
  10713. t['ideographicstudyparen'] = 0x323B;
  10714. t['ideographicsunparen'] = 0x3230;
  10715. t['ideographicsuperviseparen'] = 0x323C;
  10716. t['ideographicwaterparen'] = 0x322C;
  10717. t['ideographicwoodparen'] = 0x322D;
  10718. t['ideographiczero'] = 0x3007;
  10719. t['ideographmetalcircle'] = 0x328E;
  10720. t['ideographmooncircle'] = 0x328A;
  10721. t['ideographnamecircle'] = 0x3294;
  10722. t['ideographsuncircle'] = 0x3290;
  10723. t['ideographwatercircle'] = 0x328C;
  10724. t['ideographwoodcircle'] = 0x328D;
  10725. t['ideva'] = 0x0907;
  10726. t['idieresis'] = 0x00EF;
  10727. t['idieresisacute'] = 0x1E2F;
  10728. t['idieresiscyrillic'] = 0x04E5;
  10729. t['idotbelow'] = 0x1ECB;
  10730. t['iebrevecyrillic'] = 0x04D7;
  10731. t['iecyrillic'] = 0x0435;
  10732. t['ieungacirclekorean'] = 0x3275;
  10733. t['ieungaparenkorean'] = 0x3215;
  10734. t['ieungcirclekorean'] = 0x3267;
  10735. t['ieungkorean'] = 0x3147;
  10736. t['ieungparenkorean'] = 0x3207;
  10737. t['igrave'] = 0x00EC;
  10738. t['igujarati'] = 0x0A87;
  10739. t['igurmukhi'] = 0x0A07;
  10740. t['ihiragana'] = 0x3044;
  10741. t['ihookabove'] = 0x1EC9;
  10742. t['iibengali'] = 0x0988;
  10743. t['iicyrillic'] = 0x0438;
  10744. t['iideva'] = 0x0908;
  10745. t['iigujarati'] = 0x0A88;
  10746. t['iigurmukhi'] = 0x0A08;
  10747. t['iimatragurmukhi'] = 0x0A40;
  10748. t['iinvertedbreve'] = 0x020B;
  10749. t['iishortcyrillic'] = 0x0439;
  10750. t['iivowelsignbengali'] = 0x09C0;
  10751. t['iivowelsigndeva'] = 0x0940;
  10752. t['iivowelsigngujarati'] = 0x0AC0;
  10753. t['ij'] = 0x0133;
  10754. t['ikatakana'] = 0x30A4;
  10755. t['ikatakanahalfwidth'] = 0xFF72;
  10756. t['ikorean'] = 0x3163;
  10757. t['ilde'] = 0x02DC;
  10758. t['iluyhebrew'] = 0x05AC;
  10759. t['imacron'] = 0x012B;
  10760. t['imacroncyrillic'] = 0x04E3;
  10761. t['imageorapproximatelyequal'] = 0x2253;
  10762. t['imatragurmukhi'] = 0x0A3F;
  10763. t['imonospace'] = 0xFF49;
  10764. t['increment'] = 0x2206;
  10765. t['infinity'] = 0x221E;
  10766. t['iniarmenian'] = 0x056B;
  10767. t['integral'] = 0x222B;
  10768. t['integralbottom'] = 0x2321;
  10769. t['integralbt'] = 0x2321;
  10770. t['integralex'] = 0xF8F5;
  10771. t['integraltop'] = 0x2320;
  10772. t['integraltp'] = 0x2320;
  10773. t['intersection'] = 0x2229;
  10774. t['intisquare'] = 0x3305;
  10775. t['invbullet'] = 0x25D8;
  10776. t['invcircle'] = 0x25D9;
  10777. t['invsmileface'] = 0x263B;
  10778. t['iocyrillic'] = 0x0451;
  10779. t['iogonek'] = 0x012F;
  10780. t['iota'] = 0x03B9;
  10781. t['iotadieresis'] = 0x03CA;
  10782. t['iotadieresistonos'] = 0x0390;
  10783. t['iotalatin'] = 0x0269;
  10784. t['iotatonos'] = 0x03AF;
  10785. t['iparen'] = 0x24A4;
  10786. t['irigurmukhi'] = 0x0A72;
  10787. t['ismallhiragana'] = 0x3043;
  10788. t['ismallkatakana'] = 0x30A3;
  10789. t['ismallkatakanahalfwidth'] = 0xFF68;
  10790. t['issharbengali'] = 0x09FA;
  10791. t['istroke'] = 0x0268;
  10792. t['isuperior'] = 0xF6ED;
  10793. t['iterationhiragana'] = 0x309D;
  10794. t['iterationkatakana'] = 0x30FD;
  10795. t['itilde'] = 0x0129;
  10796. t['itildebelow'] = 0x1E2D;
  10797. t['iubopomofo'] = 0x3129;
  10798. t['iucyrillic'] = 0x044E;
  10799. t['ivowelsignbengali'] = 0x09BF;
  10800. t['ivowelsigndeva'] = 0x093F;
  10801. t['ivowelsigngujarati'] = 0x0ABF;
  10802. t['izhitsacyrillic'] = 0x0475;
  10803. t['izhitsadblgravecyrillic'] = 0x0477;
  10804. t['j'] = 0x006A;
  10805. t['jaarmenian'] = 0x0571;
  10806. t['jabengali'] = 0x099C;
  10807. t['jadeva'] = 0x091C;
  10808. t['jagujarati'] = 0x0A9C;
  10809. t['jagurmukhi'] = 0x0A1C;
  10810. t['jbopomofo'] = 0x3110;
  10811. t['jcaron'] = 0x01F0;
  10812. t['jcircle'] = 0x24D9;
  10813. t['jcircumflex'] = 0x0135;
  10814. t['jcrossedtail'] = 0x029D;
  10815. t['jdotlessstroke'] = 0x025F;
  10816. t['jecyrillic'] = 0x0458;
  10817. t['jeemarabic'] = 0x062C;
  10818. t['jeemfinalarabic'] = 0xFE9E;
  10819. t['jeeminitialarabic'] = 0xFE9F;
  10820. t['jeemmedialarabic'] = 0xFEA0;
  10821. t['jeharabic'] = 0x0698;
  10822. t['jehfinalarabic'] = 0xFB8B;
  10823. t['jhabengali'] = 0x099D;
  10824. t['jhadeva'] = 0x091D;
  10825. t['jhagujarati'] = 0x0A9D;
  10826. t['jhagurmukhi'] = 0x0A1D;
  10827. t['jheharmenian'] = 0x057B;
  10828. t['jis'] = 0x3004;
  10829. t['jmonospace'] = 0xFF4A;
  10830. t['jparen'] = 0x24A5;
  10831. t['jsuperior'] = 0x02B2;
  10832. t['k'] = 0x006B;
  10833. t['kabashkircyrillic'] = 0x04A1;
  10834. t['kabengali'] = 0x0995;
  10835. t['kacute'] = 0x1E31;
  10836. t['kacyrillic'] = 0x043A;
  10837. t['kadescendercyrillic'] = 0x049B;
  10838. t['kadeva'] = 0x0915;
  10839. t['kaf'] = 0x05DB;
  10840. t['kafarabic'] = 0x0643;
  10841. t['kafdagesh'] = 0xFB3B;
  10842. t['kafdageshhebrew'] = 0xFB3B;
  10843. t['kaffinalarabic'] = 0xFEDA;
  10844. t['kafhebrew'] = 0x05DB;
  10845. t['kafinitialarabic'] = 0xFEDB;
  10846. t['kafmedialarabic'] = 0xFEDC;
  10847. t['kafrafehebrew'] = 0xFB4D;
  10848. t['kagujarati'] = 0x0A95;
  10849. t['kagurmukhi'] = 0x0A15;
  10850. t['kahiragana'] = 0x304B;
  10851. t['kahookcyrillic'] = 0x04C4;
  10852. t['kakatakana'] = 0x30AB;
  10853. t['kakatakanahalfwidth'] = 0xFF76;
  10854. t['kappa'] = 0x03BA;
  10855. t['kappasymbolgreek'] = 0x03F0;
  10856. t['kapyeounmieumkorean'] = 0x3171;
  10857. t['kapyeounphieuphkorean'] = 0x3184;
  10858. t['kapyeounpieupkorean'] = 0x3178;
  10859. t['kapyeounssangpieupkorean'] = 0x3179;
  10860. t['karoriisquare'] = 0x330D;
  10861. t['kashidaautoarabic'] = 0x0640;
  10862. t['kashidaautonosidebearingarabic'] = 0x0640;
  10863. t['kasmallkatakana'] = 0x30F5;
  10864. t['kasquare'] = 0x3384;
  10865. t['kasraarabic'] = 0x0650;
  10866. t['kasratanarabic'] = 0x064D;
  10867. t['kastrokecyrillic'] = 0x049F;
  10868. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10869. t['kaverticalstrokecyrillic'] = 0x049D;
  10870. t['kbopomofo'] = 0x310E;
  10871. t['kcalsquare'] = 0x3389;
  10872. t['kcaron'] = 0x01E9;
  10873. t['kcedilla'] = 0x0137;
  10874. t['kcircle'] = 0x24DA;
  10875. t['kcommaaccent'] = 0x0137;
  10876. t['kdotbelow'] = 0x1E33;
  10877. t['keharmenian'] = 0x0584;
  10878. t['kehiragana'] = 0x3051;
  10879. t['kekatakana'] = 0x30B1;
  10880. t['kekatakanahalfwidth'] = 0xFF79;
  10881. t['kenarmenian'] = 0x056F;
  10882. t['kesmallkatakana'] = 0x30F6;
  10883. t['kgreenlandic'] = 0x0138;
  10884. t['khabengali'] = 0x0996;
  10885. t['khacyrillic'] = 0x0445;
  10886. t['khadeva'] = 0x0916;
  10887. t['khagujarati'] = 0x0A96;
  10888. t['khagurmukhi'] = 0x0A16;
  10889. t['khaharabic'] = 0x062E;
  10890. t['khahfinalarabic'] = 0xFEA6;
  10891. t['khahinitialarabic'] = 0xFEA7;
  10892. t['khahmedialarabic'] = 0xFEA8;
  10893. t['kheicoptic'] = 0x03E7;
  10894. t['khhadeva'] = 0x0959;
  10895. t['khhagurmukhi'] = 0x0A59;
  10896. t['khieukhacirclekorean'] = 0x3278;
  10897. t['khieukhaparenkorean'] = 0x3218;
  10898. t['khieukhcirclekorean'] = 0x326A;
  10899. t['khieukhkorean'] = 0x314B;
  10900. t['khieukhparenkorean'] = 0x320A;
  10901. t['khokhaithai'] = 0x0E02;
  10902. t['khokhonthai'] = 0x0E05;
  10903. t['khokhuatthai'] = 0x0E03;
  10904. t['khokhwaithai'] = 0x0E04;
  10905. t['khomutthai'] = 0x0E5B;
  10906. t['khook'] = 0x0199;
  10907. t['khorakhangthai'] = 0x0E06;
  10908. t['khzsquare'] = 0x3391;
  10909. t['kihiragana'] = 0x304D;
  10910. t['kikatakana'] = 0x30AD;
  10911. t['kikatakanahalfwidth'] = 0xFF77;
  10912. t['kiroguramusquare'] = 0x3315;
  10913. t['kiromeetorusquare'] = 0x3316;
  10914. t['kirosquare'] = 0x3314;
  10915. t['kiyeokacirclekorean'] = 0x326E;
  10916. t['kiyeokaparenkorean'] = 0x320E;
  10917. t['kiyeokcirclekorean'] = 0x3260;
  10918. t['kiyeokkorean'] = 0x3131;
  10919. t['kiyeokparenkorean'] = 0x3200;
  10920. t['kiyeoksioskorean'] = 0x3133;
  10921. t['kjecyrillic'] = 0x045C;
  10922. t['klinebelow'] = 0x1E35;
  10923. t['klsquare'] = 0x3398;
  10924. t['kmcubedsquare'] = 0x33A6;
  10925. t['kmonospace'] = 0xFF4B;
  10926. t['kmsquaredsquare'] = 0x33A2;
  10927. t['kohiragana'] = 0x3053;
  10928. t['kohmsquare'] = 0x33C0;
  10929. t['kokaithai'] = 0x0E01;
  10930. t['kokatakana'] = 0x30B3;
  10931. t['kokatakanahalfwidth'] = 0xFF7A;
  10932. t['kooposquare'] = 0x331E;
  10933. t['koppacyrillic'] = 0x0481;
  10934. t['koreanstandardsymbol'] = 0x327F;
  10935. t['koroniscmb'] = 0x0343;
  10936. t['kparen'] = 0x24A6;
  10937. t['kpasquare'] = 0x33AA;
  10938. t['ksicyrillic'] = 0x046F;
  10939. t['ktsquare'] = 0x33CF;
  10940. t['kturned'] = 0x029E;
  10941. t['kuhiragana'] = 0x304F;
  10942. t['kukatakana'] = 0x30AF;
  10943. t['kukatakanahalfwidth'] = 0xFF78;
  10944. t['kvsquare'] = 0x33B8;
  10945. t['kwsquare'] = 0x33BE;
  10946. t['l'] = 0x006C;
  10947. t['labengali'] = 0x09B2;
  10948. t['lacute'] = 0x013A;
  10949. t['ladeva'] = 0x0932;
  10950. t['lagujarati'] = 0x0AB2;
  10951. t['lagurmukhi'] = 0x0A32;
  10952. t['lakkhangyaothai'] = 0x0E45;
  10953. t['lamaleffinalarabic'] = 0xFEFC;
  10954. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10955. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10956. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10957. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10958. t['lamalefisolatedarabic'] = 0xFEFB;
  10959. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10960. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10961. t['lamarabic'] = 0x0644;
  10962. t['lambda'] = 0x03BB;
  10963. t['lambdastroke'] = 0x019B;
  10964. t['lamed'] = 0x05DC;
  10965. t['lameddagesh'] = 0xFB3C;
  10966. t['lameddageshhebrew'] = 0xFB3C;
  10967. t['lamedhebrew'] = 0x05DC;
  10968. t['lamfinalarabic'] = 0xFEDE;
  10969. t['lamhahinitialarabic'] = 0xFCCA;
  10970. t['laminitialarabic'] = 0xFEDF;
  10971. t['lamjeeminitialarabic'] = 0xFCC9;
  10972. t['lamkhahinitialarabic'] = 0xFCCB;
  10973. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10974. t['lammedialarabic'] = 0xFEE0;
  10975. t['lammeemhahinitialarabic'] = 0xFD88;
  10976. t['lammeeminitialarabic'] = 0xFCCC;
  10977. t['largecircle'] = 0x25EF;
  10978. t['lbar'] = 0x019A;
  10979. t['lbelt'] = 0x026C;
  10980. t['lbopomofo'] = 0x310C;
  10981. t['lcaron'] = 0x013E;
  10982. t['lcedilla'] = 0x013C;
  10983. t['lcircle'] = 0x24DB;
  10984. t['lcircumflexbelow'] = 0x1E3D;
  10985. t['lcommaaccent'] = 0x013C;
  10986. t['ldot'] = 0x0140;
  10987. t['ldotaccent'] = 0x0140;
  10988. t['ldotbelow'] = 0x1E37;
  10989. t['ldotbelowmacron'] = 0x1E39;
  10990. t['leftangleabovecmb'] = 0x031A;
  10991. t['lefttackbelowcmb'] = 0x0318;
  10992. t['less'] = 0x003C;
  10993. t['lessequal'] = 0x2264;
  10994. t['lessequalorgreater'] = 0x22DA;
  10995. t['lessmonospace'] = 0xFF1C;
  10996. t['lessorequivalent'] = 0x2272;
  10997. t['lessorgreater'] = 0x2276;
  10998. t['lessoverequal'] = 0x2266;
  10999. t['lesssmall'] = 0xFE64;
  11000. t['lezh'] = 0x026E;
  11001. t['lfblock'] = 0x258C;
  11002. t['lhookretroflex'] = 0x026D;
  11003. t['lira'] = 0x20A4;
  11004. t['liwnarmenian'] = 0x056C;
  11005. t['lj'] = 0x01C9;
  11006. t['ljecyrillic'] = 0x0459;
  11007. t['ll'] = 0xF6C0;
  11008. t['lladeva'] = 0x0933;
  11009. t['llagujarati'] = 0x0AB3;
  11010. t['llinebelow'] = 0x1E3B;
  11011. t['llladeva'] = 0x0934;
  11012. t['llvocalicbengali'] = 0x09E1;
  11013. t['llvocalicdeva'] = 0x0961;
  11014. t['llvocalicvowelsignbengali'] = 0x09E3;
  11015. t['llvocalicvowelsigndeva'] = 0x0963;
  11016. t['lmiddletilde'] = 0x026B;
  11017. t['lmonospace'] = 0xFF4C;
  11018. t['lmsquare'] = 0x33D0;
  11019. t['lochulathai'] = 0x0E2C;
  11020. t['logicaland'] = 0x2227;
  11021. t['logicalnot'] = 0x00AC;
  11022. t['logicalnotreversed'] = 0x2310;
  11023. t['logicalor'] = 0x2228;
  11024. t['lolingthai'] = 0x0E25;
  11025. t['longs'] = 0x017F;
  11026. t['lowlinecenterline'] = 0xFE4E;
  11027. t['lowlinecmb'] = 0x0332;
  11028. t['lowlinedashed'] = 0xFE4D;
  11029. t['lozenge'] = 0x25CA;
  11030. t['lparen'] = 0x24A7;
  11031. t['lslash'] = 0x0142;
  11032. t['lsquare'] = 0x2113;
  11033. t['lsuperior'] = 0xF6EE;
  11034. t['ltshade'] = 0x2591;
  11035. t['luthai'] = 0x0E26;
  11036. t['lvocalicbengali'] = 0x098C;
  11037. t['lvocalicdeva'] = 0x090C;
  11038. t['lvocalicvowelsignbengali'] = 0x09E2;
  11039. t['lvocalicvowelsigndeva'] = 0x0962;
  11040. t['lxsquare'] = 0x33D3;
  11041. t['m'] = 0x006D;
  11042. t['mabengali'] = 0x09AE;
  11043. t['macron'] = 0x00AF;
  11044. t['macronbelowcmb'] = 0x0331;
  11045. t['macroncmb'] = 0x0304;
  11046. t['macronlowmod'] = 0x02CD;
  11047. t['macronmonospace'] = 0xFFE3;
  11048. t['macute'] = 0x1E3F;
  11049. t['madeva'] = 0x092E;
  11050. t['magujarati'] = 0x0AAE;
  11051. t['magurmukhi'] = 0x0A2E;
  11052. t['mahapakhhebrew'] = 0x05A4;
  11053. t['mahapakhlefthebrew'] = 0x05A4;
  11054. t['mahiragana'] = 0x307E;
  11055. t['maichattawalowleftthai'] = 0xF895;
  11056. t['maichattawalowrightthai'] = 0xF894;
  11057. t['maichattawathai'] = 0x0E4B;
  11058. t['maichattawaupperleftthai'] = 0xF893;
  11059. t['maieklowleftthai'] = 0xF88C;
  11060. t['maieklowrightthai'] = 0xF88B;
  11061. t['maiekthai'] = 0x0E48;
  11062. t['maiekupperleftthai'] = 0xF88A;
  11063. t['maihanakatleftthai'] = 0xF884;
  11064. t['maihanakatthai'] = 0x0E31;
  11065. t['maitaikhuleftthai'] = 0xF889;
  11066. t['maitaikhuthai'] = 0x0E47;
  11067. t['maitholowleftthai'] = 0xF88F;
  11068. t['maitholowrightthai'] = 0xF88E;
  11069. t['maithothai'] = 0x0E49;
  11070. t['maithoupperleftthai'] = 0xF88D;
  11071. t['maitrilowleftthai'] = 0xF892;
  11072. t['maitrilowrightthai'] = 0xF891;
  11073. t['maitrithai'] = 0x0E4A;
  11074. t['maitriupperleftthai'] = 0xF890;
  11075. t['maiyamokthai'] = 0x0E46;
  11076. t['makatakana'] = 0x30DE;
  11077. t['makatakanahalfwidth'] = 0xFF8F;
  11078. t['male'] = 0x2642;
  11079. t['mansyonsquare'] = 0x3347;
  11080. t['maqafhebrew'] = 0x05BE;
  11081. t['mars'] = 0x2642;
  11082. t['masoracirclehebrew'] = 0x05AF;
  11083. t['masquare'] = 0x3383;
  11084. t['mbopomofo'] = 0x3107;
  11085. t['mbsquare'] = 0x33D4;
  11086. t['mcircle'] = 0x24DC;
  11087. t['mcubedsquare'] = 0x33A5;
  11088. t['mdotaccent'] = 0x1E41;
  11089. t['mdotbelow'] = 0x1E43;
  11090. t['meemarabic'] = 0x0645;
  11091. t['meemfinalarabic'] = 0xFEE2;
  11092. t['meeminitialarabic'] = 0xFEE3;
  11093. t['meemmedialarabic'] = 0xFEE4;
  11094. t['meemmeeminitialarabic'] = 0xFCD1;
  11095. t['meemmeemisolatedarabic'] = 0xFC48;
  11096. t['meetorusquare'] = 0x334D;
  11097. t['mehiragana'] = 0x3081;
  11098. t['meizierasquare'] = 0x337E;
  11099. t['mekatakana'] = 0x30E1;
  11100. t['mekatakanahalfwidth'] = 0xFF92;
  11101. t['mem'] = 0x05DE;
  11102. t['memdagesh'] = 0xFB3E;
  11103. t['memdageshhebrew'] = 0xFB3E;
  11104. t['memhebrew'] = 0x05DE;
  11105. t['menarmenian'] = 0x0574;
  11106. t['merkhahebrew'] = 0x05A5;
  11107. t['merkhakefulahebrew'] = 0x05A6;
  11108. t['merkhakefulalefthebrew'] = 0x05A6;
  11109. t['merkhalefthebrew'] = 0x05A5;
  11110. t['mhook'] = 0x0271;
  11111. t['mhzsquare'] = 0x3392;
  11112. t['middledotkatakanahalfwidth'] = 0xFF65;
  11113. t['middot'] = 0x00B7;
  11114. t['mieumacirclekorean'] = 0x3272;
  11115. t['mieumaparenkorean'] = 0x3212;
  11116. t['mieumcirclekorean'] = 0x3264;
  11117. t['mieumkorean'] = 0x3141;
  11118. t['mieumpansioskorean'] = 0x3170;
  11119. t['mieumparenkorean'] = 0x3204;
  11120. t['mieumpieupkorean'] = 0x316E;
  11121. t['mieumsioskorean'] = 0x316F;
  11122. t['mihiragana'] = 0x307F;
  11123. t['mikatakana'] = 0x30DF;
  11124. t['mikatakanahalfwidth'] = 0xFF90;
  11125. t['minus'] = 0x2212;
  11126. t['minusbelowcmb'] = 0x0320;
  11127. t['minuscircle'] = 0x2296;
  11128. t['minusmod'] = 0x02D7;
  11129. t['minusplus'] = 0x2213;
  11130. t['minute'] = 0x2032;
  11131. t['miribaarusquare'] = 0x334A;
  11132. t['mirisquare'] = 0x3349;
  11133. t['mlonglegturned'] = 0x0270;
  11134. t['mlsquare'] = 0x3396;
  11135. t['mmcubedsquare'] = 0x33A3;
  11136. t['mmonospace'] = 0xFF4D;
  11137. t['mmsquaredsquare'] = 0x339F;
  11138. t['mohiragana'] = 0x3082;
  11139. t['mohmsquare'] = 0x33C1;
  11140. t['mokatakana'] = 0x30E2;
  11141. t['mokatakanahalfwidth'] = 0xFF93;
  11142. t['molsquare'] = 0x33D6;
  11143. t['momathai'] = 0x0E21;
  11144. t['moverssquare'] = 0x33A7;
  11145. t['moverssquaredsquare'] = 0x33A8;
  11146. t['mparen'] = 0x24A8;
  11147. t['mpasquare'] = 0x33AB;
  11148. t['mssquare'] = 0x33B3;
  11149. t['msuperior'] = 0xF6EF;
  11150. t['mturned'] = 0x026F;
  11151. t['mu'] = 0x00B5;
  11152. t['mu1'] = 0x00B5;
  11153. t['muasquare'] = 0x3382;
  11154. t['muchgreater'] = 0x226B;
  11155. t['muchless'] = 0x226A;
  11156. t['mufsquare'] = 0x338C;
  11157. t['mugreek'] = 0x03BC;
  11158. t['mugsquare'] = 0x338D;
  11159. t['muhiragana'] = 0x3080;
  11160. t['mukatakana'] = 0x30E0;
  11161. t['mukatakanahalfwidth'] = 0xFF91;
  11162. t['mulsquare'] = 0x3395;
  11163. t['multiply'] = 0x00D7;
  11164. t['mumsquare'] = 0x339B;
  11165. t['munahhebrew'] = 0x05A3;
  11166. t['munahlefthebrew'] = 0x05A3;
  11167. t['musicalnote'] = 0x266A;
  11168. t['musicalnotedbl'] = 0x266B;
  11169. t['musicflatsign'] = 0x266D;
  11170. t['musicsharpsign'] = 0x266F;
  11171. t['mussquare'] = 0x33B2;
  11172. t['muvsquare'] = 0x33B6;
  11173. t['muwsquare'] = 0x33BC;
  11174. t['mvmegasquare'] = 0x33B9;
  11175. t['mvsquare'] = 0x33B7;
  11176. t['mwmegasquare'] = 0x33BF;
  11177. t['mwsquare'] = 0x33BD;
  11178. t['n'] = 0x006E;
  11179. t['nabengali'] = 0x09A8;
  11180. t['nabla'] = 0x2207;
  11181. t['nacute'] = 0x0144;
  11182. t['nadeva'] = 0x0928;
  11183. t['nagujarati'] = 0x0AA8;
  11184. t['nagurmukhi'] = 0x0A28;
  11185. t['nahiragana'] = 0x306A;
  11186. t['nakatakana'] = 0x30CA;
  11187. t['nakatakanahalfwidth'] = 0xFF85;
  11188. t['napostrophe'] = 0x0149;
  11189. t['nasquare'] = 0x3381;
  11190. t['nbopomofo'] = 0x310B;
  11191. t['nbspace'] = 0x00A0;
  11192. t['ncaron'] = 0x0148;
  11193. t['ncedilla'] = 0x0146;
  11194. t['ncircle'] = 0x24DD;
  11195. t['ncircumflexbelow'] = 0x1E4B;
  11196. t['ncommaaccent'] = 0x0146;
  11197. t['ndotaccent'] = 0x1E45;
  11198. t['ndotbelow'] = 0x1E47;
  11199. t['nehiragana'] = 0x306D;
  11200. t['nekatakana'] = 0x30CD;
  11201. t['nekatakanahalfwidth'] = 0xFF88;
  11202. t['newsheqelsign'] = 0x20AA;
  11203. t['nfsquare'] = 0x338B;
  11204. t['ngabengali'] = 0x0999;
  11205. t['ngadeva'] = 0x0919;
  11206. t['ngagujarati'] = 0x0A99;
  11207. t['ngagurmukhi'] = 0x0A19;
  11208. t['ngonguthai'] = 0x0E07;
  11209. t['nhiragana'] = 0x3093;
  11210. t['nhookleft'] = 0x0272;
  11211. t['nhookretroflex'] = 0x0273;
  11212. t['nieunacirclekorean'] = 0x326F;
  11213. t['nieunaparenkorean'] = 0x320F;
  11214. t['nieuncieuckorean'] = 0x3135;
  11215. t['nieuncirclekorean'] = 0x3261;
  11216. t['nieunhieuhkorean'] = 0x3136;
  11217. t['nieunkorean'] = 0x3134;
  11218. t['nieunpansioskorean'] = 0x3168;
  11219. t['nieunparenkorean'] = 0x3201;
  11220. t['nieunsioskorean'] = 0x3167;
  11221. t['nieuntikeutkorean'] = 0x3166;
  11222. t['nihiragana'] = 0x306B;
  11223. t['nikatakana'] = 0x30CB;
  11224. t['nikatakanahalfwidth'] = 0xFF86;
  11225. t['nikhahitleftthai'] = 0xF899;
  11226. t['nikhahitthai'] = 0x0E4D;
  11227. t['nine'] = 0x0039;
  11228. t['ninearabic'] = 0x0669;
  11229. t['ninebengali'] = 0x09EF;
  11230. t['ninecircle'] = 0x2468;
  11231. t['ninecircleinversesansserif'] = 0x2792;
  11232. t['ninedeva'] = 0x096F;
  11233. t['ninegujarati'] = 0x0AEF;
  11234. t['ninegurmukhi'] = 0x0A6F;
  11235. t['ninehackarabic'] = 0x0669;
  11236. t['ninehangzhou'] = 0x3029;
  11237. t['nineideographicparen'] = 0x3228;
  11238. t['nineinferior'] = 0x2089;
  11239. t['ninemonospace'] = 0xFF19;
  11240. t['nineoldstyle'] = 0xF739;
  11241. t['nineparen'] = 0x247C;
  11242. t['nineperiod'] = 0x2490;
  11243. t['ninepersian'] = 0x06F9;
  11244. t['nineroman'] = 0x2178;
  11245. t['ninesuperior'] = 0x2079;
  11246. t['nineteencircle'] = 0x2472;
  11247. t['nineteenparen'] = 0x2486;
  11248. t['nineteenperiod'] = 0x249A;
  11249. t['ninethai'] = 0x0E59;
  11250. t['nj'] = 0x01CC;
  11251. t['njecyrillic'] = 0x045A;
  11252. t['nkatakana'] = 0x30F3;
  11253. t['nkatakanahalfwidth'] = 0xFF9D;
  11254. t['nlegrightlong'] = 0x019E;
  11255. t['nlinebelow'] = 0x1E49;
  11256. t['nmonospace'] = 0xFF4E;
  11257. t['nmsquare'] = 0x339A;
  11258. t['nnabengali'] = 0x09A3;
  11259. t['nnadeva'] = 0x0923;
  11260. t['nnagujarati'] = 0x0AA3;
  11261. t['nnagurmukhi'] = 0x0A23;
  11262. t['nnnadeva'] = 0x0929;
  11263. t['nohiragana'] = 0x306E;
  11264. t['nokatakana'] = 0x30CE;
  11265. t['nokatakanahalfwidth'] = 0xFF89;
  11266. t['nonbreakingspace'] = 0x00A0;
  11267. t['nonenthai'] = 0x0E13;
  11268. t['nonuthai'] = 0x0E19;
  11269. t['noonarabic'] = 0x0646;
  11270. t['noonfinalarabic'] = 0xFEE6;
  11271. t['noonghunnaarabic'] = 0x06BA;
  11272. t['noonghunnafinalarabic'] = 0xFB9F;
  11273. t['nooninitialarabic'] = 0xFEE7;
  11274. t['noonjeeminitialarabic'] = 0xFCD2;
  11275. t['noonjeemisolatedarabic'] = 0xFC4B;
  11276. t['noonmedialarabic'] = 0xFEE8;
  11277. t['noonmeeminitialarabic'] = 0xFCD5;
  11278. t['noonmeemisolatedarabic'] = 0xFC4E;
  11279. t['noonnoonfinalarabic'] = 0xFC8D;
  11280. t['notcontains'] = 0x220C;
  11281. t['notelement'] = 0x2209;
  11282. t['notelementof'] = 0x2209;
  11283. t['notequal'] = 0x2260;
  11284. t['notgreater'] = 0x226F;
  11285. t['notgreaternorequal'] = 0x2271;
  11286. t['notgreaternorless'] = 0x2279;
  11287. t['notidentical'] = 0x2262;
  11288. t['notless'] = 0x226E;
  11289. t['notlessnorequal'] = 0x2270;
  11290. t['notparallel'] = 0x2226;
  11291. t['notprecedes'] = 0x2280;
  11292. t['notsubset'] = 0x2284;
  11293. t['notsucceeds'] = 0x2281;
  11294. t['notsuperset'] = 0x2285;
  11295. t['nowarmenian'] = 0x0576;
  11296. t['nparen'] = 0x24A9;
  11297. t['nssquare'] = 0x33B1;
  11298. t['nsuperior'] = 0x207F;
  11299. t['ntilde'] = 0x00F1;
  11300. t['nu'] = 0x03BD;
  11301. t['nuhiragana'] = 0x306C;
  11302. t['nukatakana'] = 0x30CC;
  11303. t['nukatakanahalfwidth'] = 0xFF87;
  11304. t['nuktabengali'] = 0x09BC;
  11305. t['nuktadeva'] = 0x093C;
  11306. t['nuktagujarati'] = 0x0ABC;
  11307. t['nuktagurmukhi'] = 0x0A3C;
  11308. t['numbersign'] = 0x0023;
  11309. t['numbersignmonospace'] = 0xFF03;
  11310. t['numbersignsmall'] = 0xFE5F;
  11311. t['numeralsigngreek'] = 0x0374;
  11312. t['numeralsignlowergreek'] = 0x0375;
  11313. t['numero'] = 0x2116;
  11314. t['nun'] = 0x05E0;
  11315. t['nundagesh'] = 0xFB40;
  11316. t['nundageshhebrew'] = 0xFB40;
  11317. t['nunhebrew'] = 0x05E0;
  11318. t['nvsquare'] = 0x33B5;
  11319. t['nwsquare'] = 0x33BB;
  11320. t['nyabengali'] = 0x099E;
  11321. t['nyadeva'] = 0x091E;
  11322. t['nyagujarati'] = 0x0A9E;
  11323. t['nyagurmukhi'] = 0x0A1E;
  11324. t['o'] = 0x006F;
  11325. t['oacute'] = 0x00F3;
  11326. t['oangthai'] = 0x0E2D;
  11327. t['obarred'] = 0x0275;
  11328. t['obarredcyrillic'] = 0x04E9;
  11329. t['obarreddieresiscyrillic'] = 0x04EB;
  11330. t['obengali'] = 0x0993;
  11331. t['obopomofo'] = 0x311B;
  11332. t['obreve'] = 0x014F;
  11333. t['ocandradeva'] = 0x0911;
  11334. t['ocandragujarati'] = 0x0A91;
  11335. t['ocandravowelsigndeva'] = 0x0949;
  11336. t['ocandravowelsigngujarati'] = 0x0AC9;
  11337. t['ocaron'] = 0x01D2;
  11338. t['ocircle'] = 0x24DE;
  11339. t['ocircumflex'] = 0x00F4;
  11340. t['ocircumflexacute'] = 0x1ED1;
  11341. t['ocircumflexdotbelow'] = 0x1ED9;
  11342. t['ocircumflexgrave'] = 0x1ED3;
  11343. t['ocircumflexhookabove'] = 0x1ED5;
  11344. t['ocircumflextilde'] = 0x1ED7;
  11345. t['ocyrillic'] = 0x043E;
  11346. t['odblacute'] = 0x0151;
  11347. t['odblgrave'] = 0x020D;
  11348. t['odeva'] = 0x0913;
  11349. t['odieresis'] = 0x00F6;
  11350. t['odieresiscyrillic'] = 0x04E7;
  11351. t['odotbelow'] = 0x1ECD;
  11352. t['oe'] = 0x0153;
  11353. t['oekorean'] = 0x315A;
  11354. t['ogonek'] = 0x02DB;
  11355. t['ogonekcmb'] = 0x0328;
  11356. t['ograve'] = 0x00F2;
  11357. t['ogujarati'] = 0x0A93;
  11358. t['oharmenian'] = 0x0585;
  11359. t['ohiragana'] = 0x304A;
  11360. t['ohookabove'] = 0x1ECF;
  11361. t['ohorn'] = 0x01A1;
  11362. t['ohornacute'] = 0x1EDB;
  11363. t['ohorndotbelow'] = 0x1EE3;
  11364. t['ohorngrave'] = 0x1EDD;
  11365. t['ohornhookabove'] = 0x1EDF;
  11366. t['ohorntilde'] = 0x1EE1;
  11367. t['ohungarumlaut'] = 0x0151;
  11368. t['oi'] = 0x01A3;
  11369. t['oinvertedbreve'] = 0x020F;
  11370. t['okatakana'] = 0x30AA;
  11371. t['okatakanahalfwidth'] = 0xFF75;
  11372. t['okorean'] = 0x3157;
  11373. t['olehebrew'] = 0x05AB;
  11374. t['omacron'] = 0x014D;
  11375. t['omacronacute'] = 0x1E53;
  11376. t['omacrongrave'] = 0x1E51;
  11377. t['omdeva'] = 0x0950;
  11378. t['omega'] = 0x03C9;
  11379. t['omega1'] = 0x03D6;
  11380. t['omegacyrillic'] = 0x0461;
  11381. t['omegalatinclosed'] = 0x0277;
  11382. t['omegaroundcyrillic'] = 0x047B;
  11383. t['omegatitlocyrillic'] = 0x047D;
  11384. t['omegatonos'] = 0x03CE;
  11385. t['omgujarati'] = 0x0AD0;
  11386. t['omicron'] = 0x03BF;
  11387. t['omicrontonos'] = 0x03CC;
  11388. t['omonospace'] = 0xFF4F;
  11389. t['one'] = 0x0031;
  11390. t['onearabic'] = 0x0661;
  11391. t['onebengali'] = 0x09E7;
  11392. t['onecircle'] = 0x2460;
  11393. t['onecircleinversesansserif'] = 0x278A;
  11394. t['onedeva'] = 0x0967;
  11395. t['onedotenleader'] = 0x2024;
  11396. t['oneeighth'] = 0x215B;
  11397. t['onefitted'] = 0xF6DC;
  11398. t['onegujarati'] = 0x0AE7;
  11399. t['onegurmukhi'] = 0x0A67;
  11400. t['onehackarabic'] = 0x0661;
  11401. t['onehalf'] = 0x00BD;
  11402. t['onehangzhou'] = 0x3021;
  11403. t['oneideographicparen'] = 0x3220;
  11404. t['oneinferior'] = 0x2081;
  11405. t['onemonospace'] = 0xFF11;
  11406. t['onenumeratorbengali'] = 0x09F4;
  11407. t['oneoldstyle'] = 0xF731;
  11408. t['oneparen'] = 0x2474;
  11409. t['oneperiod'] = 0x2488;
  11410. t['onepersian'] = 0x06F1;
  11411. t['onequarter'] = 0x00BC;
  11412. t['oneroman'] = 0x2170;
  11413. t['onesuperior'] = 0x00B9;
  11414. t['onethai'] = 0x0E51;
  11415. t['onethird'] = 0x2153;
  11416. t['oogonek'] = 0x01EB;
  11417. t['oogonekmacron'] = 0x01ED;
  11418. t['oogurmukhi'] = 0x0A13;
  11419. t['oomatragurmukhi'] = 0x0A4B;
  11420. t['oopen'] = 0x0254;
  11421. t['oparen'] = 0x24AA;
  11422. t['openbullet'] = 0x25E6;
  11423. t['option'] = 0x2325;
  11424. t['ordfeminine'] = 0x00AA;
  11425. t['ordmasculine'] = 0x00BA;
  11426. t['orthogonal'] = 0x221F;
  11427. t['oshortdeva'] = 0x0912;
  11428. t['oshortvowelsigndeva'] = 0x094A;
  11429. t['oslash'] = 0x00F8;
  11430. t['oslashacute'] = 0x01FF;
  11431. t['osmallhiragana'] = 0x3049;
  11432. t['osmallkatakana'] = 0x30A9;
  11433. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11434. t['ostrokeacute'] = 0x01FF;
  11435. t['osuperior'] = 0xF6F0;
  11436. t['otcyrillic'] = 0x047F;
  11437. t['otilde'] = 0x00F5;
  11438. t['otildeacute'] = 0x1E4D;
  11439. t['otildedieresis'] = 0x1E4F;
  11440. t['oubopomofo'] = 0x3121;
  11441. t['overline'] = 0x203E;
  11442. t['overlinecenterline'] = 0xFE4A;
  11443. t['overlinecmb'] = 0x0305;
  11444. t['overlinedashed'] = 0xFE49;
  11445. t['overlinedblwavy'] = 0xFE4C;
  11446. t['overlinewavy'] = 0xFE4B;
  11447. t['overscore'] = 0x00AF;
  11448. t['ovowelsignbengali'] = 0x09CB;
  11449. t['ovowelsigndeva'] = 0x094B;
  11450. t['ovowelsigngujarati'] = 0x0ACB;
  11451. t['p'] = 0x0070;
  11452. t['paampssquare'] = 0x3380;
  11453. t['paasentosquare'] = 0x332B;
  11454. t['pabengali'] = 0x09AA;
  11455. t['pacute'] = 0x1E55;
  11456. t['padeva'] = 0x092A;
  11457. t['pagedown'] = 0x21DF;
  11458. t['pageup'] = 0x21DE;
  11459. t['pagujarati'] = 0x0AAA;
  11460. t['pagurmukhi'] = 0x0A2A;
  11461. t['pahiragana'] = 0x3071;
  11462. t['paiyannoithai'] = 0x0E2F;
  11463. t['pakatakana'] = 0x30D1;
  11464. t['palatalizationcyrilliccmb'] = 0x0484;
  11465. t['palochkacyrillic'] = 0x04C0;
  11466. t['pansioskorean'] = 0x317F;
  11467. t['paragraph'] = 0x00B6;
  11468. t['parallel'] = 0x2225;
  11469. t['parenleft'] = 0x0028;
  11470. t['parenleftaltonearabic'] = 0xFD3E;
  11471. t['parenleftbt'] = 0xF8ED;
  11472. t['parenleftex'] = 0xF8EC;
  11473. t['parenleftinferior'] = 0x208D;
  11474. t['parenleftmonospace'] = 0xFF08;
  11475. t['parenleftsmall'] = 0xFE59;
  11476. t['parenleftsuperior'] = 0x207D;
  11477. t['parenlefttp'] = 0xF8EB;
  11478. t['parenleftvertical'] = 0xFE35;
  11479. t['parenright'] = 0x0029;
  11480. t['parenrightaltonearabic'] = 0xFD3F;
  11481. t['parenrightbt'] = 0xF8F8;
  11482. t['parenrightex'] = 0xF8F7;
  11483. t['parenrightinferior'] = 0x208E;
  11484. t['parenrightmonospace'] = 0xFF09;
  11485. t['parenrightsmall'] = 0xFE5A;
  11486. t['parenrightsuperior'] = 0x207E;
  11487. t['parenrighttp'] = 0xF8F6;
  11488. t['parenrightvertical'] = 0xFE36;
  11489. t['partialdiff'] = 0x2202;
  11490. t['paseqhebrew'] = 0x05C0;
  11491. t['pashtahebrew'] = 0x0599;
  11492. t['pasquare'] = 0x33A9;
  11493. t['patah'] = 0x05B7;
  11494. t['patah11'] = 0x05B7;
  11495. t['patah1d'] = 0x05B7;
  11496. t['patah2a'] = 0x05B7;
  11497. t['patahhebrew'] = 0x05B7;
  11498. t['patahnarrowhebrew'] = 0x05B7;
  11499. t['patahquarterhebrew'] = 0x05B7;
  11500. t['patahwidehebrew'] = 0x05B7;
  11501. t['pazerhebrew'] = 0x05A1;
  11502. t['pbopomofo'] = 0x3106;
  11503. t['pcircle'] = 0x24DF;
  11504. t['pdotaccent'] = 0x1E57;
  11505. t['pe'] = 0x05E4;
  11506. t['pecyrillic'] = 0x043F;
  11507. t['pedagesh'] = 0xFB44;
  11508. t['pedageshhebrew'] = 0xFB44;
  11509. t['peezisquare'] = 0x333B;
  11510. t['pefinaldageshhebrew'] = 0xFB43;
  11511. t['peharabic'] = 0x067E;
  11512. t['peharmenian'] = 0x057A;
  11513. t['pehebrew'] = 0x05E4;
  11514. t['pehfinalarabic'] = 0xFB57;
  11515. t['pehinitialarabic'] = 0xFB58;
  11516. t['pehiragana'] = 0x307A;
  11517. t['pehmedialarabic'] = 0xFB59;
  11518. t['pekatakana'] = 0x30DA;
  11519. t['pemiddlehookcyrillic'] = 0x04A7;
  11520. t['perafehebrew'] = 0xFB4E;
  11521. t['percent'] = 0x0025;
  11522. t['percentarabic'] = 0x066A;
  11523. t['percentmonospace'] = 0xFF05;
  11524. t['percentsmall'] = 0xFE6A;
  11525. t['period'] = 0x002E;
  11526. t['periodarmenian'] = 0x0589;
  11527. t['periodcentered'] = 0x00B7;
  11528. t['periodhalfwidth'] = 0xFF61;
  11529. t['periodinferior'] = 0xF6E7;
  11530. t['periodmonospace'] = 0xFF0E;
  11531. t['periodsmall'] = 0xFE52;
  11532. t['periodsuperior'] = 0xF6E8;
  11533. t['perispomenigreekcmb'] = 0x0342;
  11534. t['perpendicular'] = 0x22A5;
  11535. t['perthousand'] = 0x2030;
  11536. t['peseta'] = 0x20A7;
  11537. t['pfsquare'] = 0x338A;
  11538. t['phabengali'] = 0x09AB;
  11539. t['phadeva'] = 0x092B;
  11540. t['phagujarati'] = 0x0AAB;
  11541. t['phagurmukhi'] = 0x0A2B;
  11542. t['phi'] = 0x03C6;
  11543. t['phi1'] = 0x03D5;
  11544. t['phieuphacirclekorean'] = 0x327A;
  11545. t['phieuphaparenkorean'] = 0x321A;
  11546. t['phieuphcirclekorean'] = 0x326C;
  11547. t['phieuphkorean'] = 0x314D;
  11548. t['phieuphparenkorean'] = 0x320C;
  11549. t['philatin'] = 0x0278;
  11550. t['phinthuthai'] = 0x0E3A;
  11551. t['phisymbolgreek'] = 0x03D5;
  11552. t['phook'] = 0x01A5;
  11553. t['phophanthai'] = 0x0E1E;
  11554. t['phophungthai'] = 0x0E1C;
  11555. t['phosamphaothai'] = 0x0E20;
  11556. t['pi'] = 0x03C0;
  11557. t['pieupacirclekorean'] = 0x3273;
  11558. t['pieupaparenkorean'] = 0x3213;
  11559. t['pieupcieuckorean'] = 0x3176;
  11560. t['pieupcirclekorean'] = 0x3265;
  11561. t['pieupkiyeokkorean'] = 0x3172;
  11562. t['pieupkorean'] = 0x3142;
  11563. t['pieupparenkorean'] = 0x3205;
  11564. t['pieupsioskiyeokkorean'] = 0x3174;
  11565. t['pieupsioskorean'] = 0x3144;
  11566. t['pieupsiostikeutkorean'] = 0x3175;
  11567. t['pieupthieuthkorean'] = 0x3177;
  11568. t['pieuptikeutkorean'] = 0x3173;
  11569. t['pihiragana'] = 0x3074;
  11570. t['pikatakana'] = 0x30D4;
  11571. t['pisymbolgreek'] = 0x03D6;
  11572. t['piwrarmenian'] = 0x0583;
  11573. t['plus'] = 0x002B;
  11574. t['plusbelowcmb'] = 0x031F;
  11575. t['pluscircle'] = 0x2295;
  11576. t['plusminus'] = 0x00B1;
  11577. t['plusmod'] = 0x02D6;
  11578. t['plusmonospace'] = 0xFF0B;
  11579. t['plussmall'] = 0xFE62;
  11580. t['plussuperior'] = 0x207A;
  11581. t['pmonospace'] = 0xFF50;
  11582. t['pmsquare'] = 0x33D8;
  11583. t['pohiragana'] = 0x307D;
  11584. t['pointingindexdownwhite'] = 0x261F;
  11585. t['pointingindexleftwhite'] = 0x261C;
  11586. t['pointingindexrightwhite'] = 0x261E;
  11587. t['pointingindexupwhite'] = 0x261D;
  11588. t['pokatakana'] = 0x30DD;
  11589. t['poplathai'] = 0x0E1B;
  11590. t['postalmark'] = 0x3012;
  11591. t['postalmarkface'] = 0x3020;
  11592. t['pparen'] = 0x24AB;
  11593. t['precedes'] = 0x227A;
  11594. t['prescription'] = 0x211E;
  11595. t['primemod'] = 0x02B9;
  11596. t['primereversed'] = 0x2035;
  11597. t['product'] = 0x220F;
  11598. t['projective'] = 0x2305;
  11599. t['prolongedkana'] = 0x30FC;
  11600. t['propellor'] = 0x2318;
  11601. t['propersubset'] = 0x2282;
  11602. t['propersuperset'] = 0x2283;
  11603. t['proportion'] = 0x2237;
  11604. t['proportional'] = 0x221D;
  11605. t['psi'] = 0x03C8;
  11606. t['psicyrillic'] = 0x0471;
  11607. t['psilipneumatacyrilliccmb'] = 0x0486;
  11608. t['pssquare'] = 0x33B0;
  11609. t['puhiragana'] = 0x3077;
  11610. t['pukatakana'] = 0x30D7;
  11611. t['pvsquare'] = 0x33B4;
  11612. t['pwsquare'] = 0x33BA;
  11613. t['q'] = 0x0071;
  11614. t['qadeva'] = 0x0958;
  11615. t['qadmahebrew'] = 0x05A8;
  11616. t['qafarabic'] = 0x0642;
  11617. t['qaffinalarabic'] = 0xFED6;
  11618. t['qafinitialarabic'] = 0xFED7;
  11619. t['qafmedialarabic'] = 0xFED8;
  11620. t['qamats'] = 0x05B8;
  11621. t['qamats10'] = 0x05B8;
  11622. t['qamats1a'] = 0x05B8;
  11623. t['qamats1c'] = 0x05B8;
  11624. t['qamats27'] = 0x05B8;
  11625. t['qamats29'] = 0x05B8;
  11626. t['qamats33'] = 0x05B8;
  11627. t['qamatsde'] = 0x05B8;
  11628. t['qamatshebrew'] = 0x05B8;
  11629. t['qamatsnarrowhebrew'] = 0x05B8;
  11630. t['qamatsqatanhebrew'] = 0x05B8;
  11631. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11632. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11633. t['qamatsqatanwidehebrew'] = 0x05B8;
  11634. t['qamatsquarterhebrew'] = 0x05B8;
  11635. t['qamatswidehebrew'] = 0x05B8;
  11636. t['qarneyparahebrew'] = 0x059F;
  11637. t['qbopomofo'] = 0x3111;
  11638. t['qcircle'] = 0x24E0;
  11639. t['qhook'] = 0x02A0;
  11640. t['qmonospace'] = 0xFF51;
  11641. t['qof'] = 0x05E7;
  11642. t['qofdagesh'] = 0xFB47;
  11643. t['qofdageshhebrew'] = 0xFB47;
  11644. t['qofhebrew'] = 0x05E7;
  11645. t['qparen'] = 0x24AC;
  11646. t['quarternote'] = 0x2669;
  11647. t['qubuts'] = 0x05BB;
  11648. t['qubuts18'] = 0x05BB;
  11649. t['qubuts25'] = 0x05BB;
  11650. t['qubuts31'] = 0x05BB;
  11651. t['qubutshebrew'] = 0x05BB;
  11652. t['qubutsnarrowhebrew'] = 0x05BB;
  11653. t['qubutsquarterhebrew'] = 0x05BB;
  11654. t['qubutswidehebrew'] = 0x05BB;
  11655. t['question'] = 0x003F;
  11656. t['questionarabic'] = 0x061F;
  11657. t['questionarmenian'] = 0x055E;
  11658. t['questiondown'] = 0x00BF;
  11659. t['questiondownsmall'] = 0xF7BF;
  11660. t['questiongreek'] = 0x037E;
  11661. t['questionmonospace'] = 0xFF1F;
  11662. t['questionsmall'] = 0xF73F;
  11663. t['quotedbl'] = 0x0022;
  11664. t['quotedblbase'] = 0x201E;
  11665. t['quotedblleft'] = 0x201C;
  11666. t['quotedblmonospace'] = 0xFF02;
  11667. t['quotedblprime'] = 0x301E;
  11668. t['quotedblprimereversed'] = 0x301D;
  11669. t['quotedblright'] = 0x201D;
  11670. t['quoteleft'] = 0x2018;
  11671. t['quoteleftreversed'] = 0x201B;
  11672. t['quotereversed'] = 0x201B;
  11673. t['quoteright'] = 0x2019;
  11674. t['quoterightn'] = 0x0149;
  11675. t['quotesinglbase'] = 0x201A;
  11676. t['quotesingle'] = 0x0027;
  11677. t['quotesinglemonospace'] = 0xFF07;
  11678. t['r'] = 0x0072;
  11679. t['raarmenian'] = 0x057C;
  11680. t['rabengali'] = 0x09B0;
  11681. t['racute'] = 0x0155;
  11682. t['radeva'] = 0x0930;
  11683. t['radical'] = 0x221A;
  11684. t['radicalex'] = 0xF8E5;
  11685. t['radoverssquare'] = 0x33AE;
  11686. t['radoverssquaredsquare'] = 0x33AF;
  11687. t['radsquare'] = 0x33AD;
  11688. t['rafe'] = 0x05BF;
  11689. t['rafehebrew'] = 0x05BF;
  11690. t['ragujarati'] = 0x0AB0;
  11691. t['ragurmukhi'] = 0x0A30;
  11692. t['rahiragana'] = 0x3089;
  11693. t['rakatakana'] = 0x30E9;
  11694. t['rakatakanahalfwidth'] = 0xFF97;
  11695. t['ralowerdiagonalbengali'] = 0x09F1;
  11696. t['ramiddlediagonalbengali'] = 0x09F0;
  11697. t['ramshorn'] = 0x0264;
  11698. t['ratio'] = 0x2236;
  11699. t['rbopomofo'] = 0x3116;
  11700. t['rcaron'] = 0x0159;
  11701. t['rcedilla'] = 0x0157;
  11702. t['rcircle'] = 0x24E1;
  11703. t['rcommaaccent'] = 0x0157;
  11704. t['rdblgrave'] = 0x0211;
  11705. t['rdotaccent'] = 0x1E59;
  11706. t['rdotbelow'] = 0x1E5B;
  11707. t['rdotbelowmacron'] = 0x1E5D;
  11708. t['referencemark'] = 0x203B;
  11709. t['reflexsubset'] = 0x2286;
  11710. t['reflexsuperset'] = 0x2287;
  11711. t['registered'] = 0x00AE;
  11712. t['registersans'] = 0xF8E8;
  11713. t['registerserif'] = 0xF6DA;
  11714. t['reharabic'] = 0x0631;
  11715. t['reharmenian'] = 0x0580;
  11716. t['rehfinalarabic'] = 0xFEAE;
  11717. t['rehiragana'] = 0x308C;
  11718. t['rekatakana'] = 0x30EC;
  11719. t['rekatakanahalfwidth'] = 0xFF9A;
  11720. t['resh'] = 0x05E8;
  11721. t['reshdageshhebrew'] = 0xFB48;
  11722. t['reshhebrew'] = 0x05E8;
  11723. t['reversedtilde'] = 0x223D;
  11724. t['reviahebrew'] = 0x0597;
  11725. t['reviamugrashhebrew'] = 0x0597;
  11726. t['revlogicalnot'] = 0x2310;
  11727. t['rfishhook'] = 0x027E;
  11728. t['rfishhookreversed'] = 0x027F;
  11729. t['rhabengali'] = 0x09DD;
  11730. t['rhadeva'] = 0x095D;
  11731. t['rho'] = 0x03C1;
  11732. t['rhook'] = 0x027D;
  11733. t['rhookturned'] = 0x027B;
  11734. t['rhookturnedsuperior'] = 0x02B5;
  11735. t['rhosymbolgreek'] = 0x03F1;
  11736. t['rhotichookmod'] = 0x02DE;
  11737. t['rieulacirclekorean'] = 0x3271;
  11738. t['rieulaparenkorean'] = 0x3211;
  11739. t['rieulcirclekorean'] = 0x3263;
  11740. t['rieulhieuhkorean'] = 0x3140;
  11741. t['rieulkiyeokkorean'] = 0x313A;
  11742. t['rieulkiyeoksioskorean'] = 0x3169;
  11743. t['rieulkorean'] = 0x3139;
  11744. t['rieulmieumkorean'] = 0x313B;
  11745. t['rieulpansioskorean'] = 0x316C;
  11746. t['rieulparenkorean'] = 0x3203;
  11747. t['rieulphieuphkorean'] = 0x313F;
  11748. t['rieulpieupkorean'] = 0x313C;
  11749. t['rieulpieupsioskorean'] = 0x316B;
  11750. t['rieulsioskorean'] = 0x313D;
  11751. t['rieulthieuthkorean'] = 0x313E;
  11752. t['rieultikeutkorean'] = 0x316A;
  11753. t['rieulyeorinhieuhkorean'] = 0x316D;
  11754. t['rightangle'] = 0x221F;
  11755. t['righttackbelowcmb'] = 0x0319;
  11756. t['righttriangle'] = 0x22BF;
  11757. t['rihiragana'] = 0x308A;
  11758. t['rikatakana'] = 0x30EA;
  11759. t['rikatakanahalfwidth'] = 0xFF98;
  11760. t['ring'] = 0x02DA;
  11761. t['ringbelowcmb'] = 0x0325;
  11762. t['ringcmb'] = 0x030A;
  11763. t['ringhalfleft'] = 0x02BF;
  11764. t['ringhalfleftarmenian'] = 0x0559;
  11765. t['ringhalfleftbelowcmb'] = 0x031C;
  11766. t['ringhalfleftcentered'] = 0x02D3;
  11767. t['ringhalfright'] = 0x02BE;
  11768. t['ringhalfrightbelowcmb'] = 0x0339;
  11769. t['ringhalfrightcentered'] = 0x02D2;
  11770. t['rinvertedbreve'] = 0x0213;
  11771. t['rittorusquare'] = 0x3351;
  11772. t['rlinebelow'] = 0x1E5F;
  11773. t['rlongleg'] = 0x027C;
  11774. t['rlonglegturned'] = 0x027A;
  11775. t['rmonospace'] = 0xFF52;
  11776. t['rohiragana'] = 0x308D;
  11777. t['rokatakana'] = 0x30ED;
  11778. t['rokatakanahalfwidth'] = 0xFF9B;
  11779. t['roruathai'] = 0x0E23;
  11780. t['rparen'] = 0x24AD;
  11781. t['rrabengali'] = 0x09DC;
  11782. t['rradeva'] = 0x0931;
  11783. t['rragurmukhi'] = 0x0A5C;
  11784. t['rreharabic'] = 0x0691;
  11785. t['rrehfinalarabic'] = 0xFB8D;
  11786. t['rrvocalicbengali'] = 0x09E0;
  11787. t['rrvocalicdeva'] = 0x0960;
  11788. t['rrvocalicgujarati'] = 0x0AE0;
  11789. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11790. t['rrvocalicvowelsigndeva'] = 0x0944;
  11791. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11792. t['rsuperior'] = 0xF6F1;
  11793. t['rtblock'] = 0x2590;
  11794. t['rturned'] = 0x0279;
  11795. t['rturnedsuperior'] = 0x02B4;
  11796. t['ruhiragana'] = 0x308B;
  11797. t['rukatakana'] = 0x30EB;
  11798. t['rukatakanahalfwidth'] = 0xFF99;
  11799. t['rupeemarkbengali'] = 0x09F2;
  11800. t['rupeesignbengali'] = 0x09F3;
  11801. t['rupiah'] = 0xF6DD;
  11802. t['ruthai'] = 0x0E24;
  11803. t['rvocalicbengali'] = 0x098B;
  11804. t['rvocalicdeva'] = 0x090B;
  11805. t['rvocalicgujarati'] = 0x0A8B;
  11806. t['rvocalicvowelsignbengali'] = 0x09C3;
  11807. t['rvocalicvowelsigndeva'] = 0x0943;
  11808. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11809. t['s'] = 0x0073;
  11810. t['sabengali'] = 0x09B8;
  11811. t['sacute'] = 0x015B;
  11812. t['sacutedotaccent'] = 0x1E65;
  11813. t['sadarabic'] = 0x0635;
  11814. t['sadeva'] = 0x0938;
  11815. t['sadfinalarabic'] = 0xFEBA;
  11816. t['sadinitialarabic'] = 0xFEBB;
  11817. t['sadmedialarabic'] = 0xFEBC;
  11818. t['sagujarati'] = 0x0AB8;
  11819. t['sagurmukhi'] = 0x0A38;
  11820. t['sahiragana'] = 0x3055;
  11821. t['sakatakana'] = 0x30B5;
  11822. t['sakatakanahalfwidth'] = 0xFF7B;
  11823. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11824. t['samekh'] = 0x05E1;
  11825. t['samekhdagesh'] = 0xFB41;
  11826. t['samekhdageshhebrew'] = 0xFB41;
  11827. t['samekhhebrew'] = 0x05E1;
  11828. t['saraaathai'] = 0x0E32;
  11829. t['saraaethai'] = 0x0E41;
  11830. t['saraaimaimalaithai'] = 0x0E44;
  11831. t['saraaimaimuanthai'] = 0x0E43;
  11832. t['saraamthai'] = 0x0E33;
  11833. t['saraathai'] = 0x0E30;
  11834. t['saraethai'] = 0x0E40;
  11835. t['saraiileftthai'] = 0xF886;
  11836. t['saraiithai'] = 0x0E35;
  11837. t['saraileftthai'] = 0xF885;
  11838. t['saraithai'] = 0x0E34;
  11839. t['saraothai'] = 0x0E42;
  11840. t['saraueeleftthai'] = 0xF888;
  11841. t['saraueethai'] = 0x0E37;
  11842. t['saraueleftthai'] = 0xF887;
  11843. t['sarauethai'] = 0x0E36;
  11844. t['sarauthai'] = 0x0E38;
  11845. t['sarauuthai'] = 0x0E39;
  11846. t['sbopomofo'] = 0x3119;
  11847. t['scaron'] = 0x0161;
  11848. t['scarondotaccent'] = 0x1E67;
  11849. t['scedilla'] = 0x015F;
  11850. t['schwa'] = 0x0259;
  11851. t['schwacyrillic'] = 0x04D9;
  11852. t['schwadieresiscyrillic'] = 0x04DB;
  11853. t['schwahook'] = 0x025A;
  11854. t['scircle'] = 0x24E2;
  11855. t['scircumflex'] = 0x015D;
  11856. t['scommaaccent'] = 0x0219;
  11857. t['sdotaccent'] = 0x1E61;
  11858. t['sdotbelow'] = 0x1E63;
  11859. t['sdotbelowdotaccent'] = 0x1E69;
  11860. t['seagullbelowcmb'] = 0x033C;
  11861. t['second'] = 0x2033;
  11862. t['secondtonechinese'] = 0x02CA;
  11863. t['section'] = 0x00A7;
  11864. t['seenarabic'] = 0x0633;
  11865. t['seenfinalarabic'] = 0xFEB2;
  11866. t['seeninitialarabic'] = 0xFEB3;
  11867. t['seenmedialarabic'] = 0xFEB4;
  11868. t['segol'] = 0x05B6;
  11869. t['segol13'] = 0x05B6;
  11870. t['segol1f'] = 0x05B6;
  11871. t['segol2c'] = 0x05B6;
  11872. t['segolhebrew'] = 0x05B6;
  11873. t['segolnarrowhebrew'] = 0x05B6;
  11874. t['segolquarterhebrew'] = 0x05B6;
  11875. t['segoltahebrew'] = 0x0592;
  11876. t['segolwidehebrew'] = 0x05B6;
  11877. t['seharmenian'] = 0x057D;
  11878. t['sehiragana'] = 0x305B;
  11879. t['sekatakana'] = 0x30BB;
  11880. t['sekatakanahalfwidth'] = 0xFF7E;
  11881. t['semicolon'] = 0x003B;
  11882. t['semicolonarabic'] = 0x061B;
  11883. t['semicolonmonospace'] = 0xFF1B;
  11884. t['semicolonsmall'] = 0xFE54;
  11885. t['semivoicedmarkkana'] = 0x309C;
  11886. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11887. t['sentisquare'] = 0x3322;
  11888. t['sentosquare'] = 0x3323;
  11889. t['seven'] = 0x0037;
  11890. t['sevenarabic'] = 0x0667;
  11891. t['sevenbengali'] = 0x09ED;
  11892. t['sevencircle'] = 0x2466;
  11893. t['sevencircleinversesansserif'] = 0x2790;
  11894. t['sevendeva'] = 0x096D;
  11895. t['seveneighths'] = 0x215E;
  11896. t['sevengujarati'] = 0x0AED;
  11897. t['sevengurmukhi'] = 0x0A6D;
  11898. t['sevenhackarabic'] = 0x0667;
  11899. t['sevenhangzhou'] = 0x3027;
  11900. t['sevenideographicparen'] = 0x3226;
  11901. t['seveninferior'] = 0x2087;
  11902. t['sevenmonospace'] = 0xFF17;
  11903. t['sevenoldstyle'] = 0xF737;
  11904. t['sevenparen'] = 0x247A;
  11905. t['sevenperiod'] = 0x248E;
  11906. t['sevenpersian'] = 0x06F7;
  11907. t['sevenroman'] = 0x2176;
  11908. t['sevensuperior'] = 0x2077;
  11909. t['seventeencircle'] = 0x2470;
  11910. t['seventeenparen'] = 0x2484;
  11911. t['seventeenperiod'] = 0x2498;
  11912. t['seventhai'] = 0x0E57;
  11913. t['sfthyphen'] = 0x00AD;
  11914. t['shaarmenian'] = 0x0577;
  11915. t['shabengali'] = 0x09B6;
  11916. t['shacyrillic'] = 0x0448;
  11917. t['shaddaarabic'] = 0x0651;
  11918. t['shaddadammaarabic'] = 0xFC61;
  11919. t['shaddadammatanarabic'] = 0xFC5E;
  11920. t['shaddafathaarabic'] = 0xFC60;
  11921. t['shaddakasraarabic'] = 0xFC62;
  11922. t['shaddakasratanarabic'] = 0xFC5F;
  11923. t['shade'] = 0x2592;
  11924. t['shadedark'] = 0x2593;
  11925. t['shadelight'] = 0x2591;
  11926. t['shademedium'] = 0x2592;
  11927. t['shadeva'] = 0x0936;
  11928. t['shagujarati'] = 0x0AB6;
  11929. t['shagurmukhi'] = 0x0A36;
  11930. t['shalshelethebrew'] = 0x0593;
  11931. t['shbopomofo'] = 0x3115;
  11932. t['shchacyrillic'] = 0x0449;
  11933. t['sheenarabic'] = 0x0634;
  11934. t['sheenfinalarabic'] = 0xFEB6;
  11935. t['sheeninitialarabic'] = 0xFEB7;
  11936. t['sheenmedialarabic'] = 0xFEB8;
  11937. t['sheicoptic'] = 0x03E3;
  11938. t['sheqel'] = 0x20AA;
  11939. t['sheqelhebrew'] = 0x20AA;
  11940. t['sheva'] = 0x05B0;
  11941. t['sheva115'] = 0x05B0;
  11942. t['sheva15'] = 0x05B0;
  11943. t['sheva22'] = 0x05B0;
  11944. t['sheva2e'] = 0x05B0;
  11945. t['shevahebrew'] = 0x05B0;
  11946. t['shevanarrowhebrew'] = 0x05B0;
  11947. t['shevaquarterhebrew'] = 0x05B0;
  11948. t['shevawidehebrew'] = 0x05B0;
  11949. t['shhacyrillic'] = 0x04BB;
  11950. t['shimacoptic'] = 0x03ED;
  11951. t['shin'] = 0x05E9;
  11952. t['shindagesh'] = 0xFB49;
  11953. t['shindageshhebrew'] = 0xFB49;
  11954. t['shindageshshindot'] = 0xFB2C;
  11955. t['shindageshshindothebrew'] = 0xFB2C;
  11956. t['shindageshsindot'] = 0xFB2D;
  11957. t['shindageshsindothebrew'] = 0xFB2D;
  11958. t['shindothebrew'] = 0x05C1;
  11959. t['shinhebrew'] = 0x05E9;
  11960. t['shinshindot'] = 0xFB2A;
  11961. t['shinshindothebrew'] = 0xFB2A;
  11962. t['shinsindot'] = 0xFB2B;
  11963. t['shinsindothebrew'] = 0xFB2B;
  11964. t['shook'] = 0x0282;
  11965. t['sigma'] = 0x03C3;
  11966. t['sigma1'] = 0x03C2;
  11967. t['sigmafinal'] = 0x03C2;
  11968. t['sigmalunatesymbolgreek'] = 0x03F2;
  11969. t['sihiragana'] = 0x3057;
  11970. t['sikatakana'] = 0x30B7;
  11971. t['sikatakanahalfwidth'] = 0xFF7C;
  11972. t['siluqhebrew'] = 0x05BD;
  11973. t['siluqlefthebrew'] = 0x05BD;
  11974. t['similar'] = 0x223C;
  11975. t['sindothebrew'] = 0x05C2;
  11976. t['siosacirclekorean'] = 0x3274;
  11977. t['siosaparenkorean'] = 0x3214;
  11978. t['sioscieuckorean'] = 0x317E;
  11979. t['sioscirclekorean'] = 0x3266;
  11980. t['sioskiyeokkorean'] = 0x317A;
  11981. t['sioskorean'] = 0x3145;
  11982. t['siosnieunkorean'] = 0x317B;
  11983. t['siosparenkorean'] = 0x3206;
  11984. t['siospieupkorean'] = 0x317D;
  11985. t['siostikeutkorean'] = 0x317C;
  11986. t['six'] = 0x0036;
  11987. t['sixarabic'] = 0x0666;
  11988. t['sixbengali'] = 0x09EC;
  11989. t['sixcircle'] = 0x2465;
  11990. t['sixcircleinversesansserif'] = 0x278F;
  11991. t['sixdeva'] = 0x096C;
  11992. t['sixgujarati'] = 0x0AEC;
  11993. t['sixgurmukhi'] = 0x0A6C;
  11994. t['sixhackarabic'] = 0x0666;
  11995. t['sixhangzhou'] = 0x3026;
  11996. t['sixideographicparen'] = 0x3225;
  11997. t['sixinferior'] = 0x2086;
  11998. t['sixmonospace'] = 0xFF16;
  11999. t['sixoldstyle'] = 0xF736;
  12000. t['sixparen'] = 0x2479;
  12001. t['sixperiod'] = 0x248D;
  12002. t['sixpersian'] = 0x06F6;
  12003. t['sixroman'] = 0x2175;
  12004. t['sixsuperior'] = 0x2076;
  12005. t['sixteencircle'] = 0x246F;
  12006. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12007. t['sixteenparen'] = 0x2483;
  12008. t['sixteenperiod'] = 0x2497;
  12009. t['sixthai'] = 0x0E56;
  12010. t['slash'] = 0x002F;
  12011. t['slashmonospace'] = 0xFF0F;
  12012. t['slong'] = 0x017F;
  12013. t['slongdotaccent'] = 0x1E9B;
  12014. t['smileface'] = 0x263A;
  12015. t['smonospace'] = 0xFF53;
  12016. t['sofpasuqhebrew'] = 0x05C3;
  12017. t['softhyphen'] = 0x00AD;
  12018. t['softsigncyrillic'] = 0x044C;
  12019. t['sohiragana'] = 0x305D;
  12020. t['sokatakana'] = 0x30BD;
  12021. t['sokatakanahalfwidth'] = 0xFF7F;
  12022. t['soliduslongoverlaycmb'] = 0x0338;
  12023. t['solidusshortoverlaycmb'] = 0x0337;
  12024. t['sorusithai'] = 0x0E29;
  12025. t['sosalathai'] = 0x0E28;
  12026. t['sosothai'] = 0x0E0B;
  12027. t['sosuathai'] = 0x0E2A;
  12028. t['space'] = 0x0020;
  12029. t['spacehackarabic'] = 0x0020;
  12030. t['spade'] = 0x2660;
  12031. t['spadesuitblack'] = 0x2660;
  12032. t['spadesuitwhite'] = 0x2664;
  12033. t['sparen'] = 0x24AE;
  12034. t['squarebelowcmb'] = 0x033B;
  12035. t['squarecc'] = 0x33C4;
  12036. t['squarecm'] = 0x339D;
  12037. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12038. t['squarehorizontalfill'] = 0x25A4;
  12039. t['squarekg'] = 0x338F;
  12040. t['squarekm'] = 0x339E;
  12041. t['squarekmcapital'] = 0x33CE;
  12042. t['squareln'] = 0x33D1;
  12043. t['squarelog'] = 0x33D2;
  12044. t['squaremg'] = 0x338E;
  12045. t['squaremil'] = 0x33D5;
  12046. t['squaremm'] = 0x339C;
  12047. t['squaremsquared'] = 0x33A1;
  12048. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12049. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12050. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12051. t['squareverticalfill'] = 0x25A5;
  12052. t['squarewhitewithsmallblack'] = 0x25A3;
  12053. t['srsquare'] = 0x33DB;
  12054. t['ssabengali'] = 0x09B7;
  12055. t['ssadeva'] = 0x0937;
  12056. t['ssagujarati'] = 0x0AB7;
  12057. t['ssangcieuckorean'] = 0x3149;
  12058. t['ssanghieuhkorean'] = 0x3185;
  12059. t['ssangieungkorean'] = 0x3180;
  12060. t['ssangkiyeokkorean'] = 0x3132;
  12061. t['ssangnieunkorean'] = 0x3165;
  12062. t['ssangpieupkorean'] = 0x3143;
  12063. t['ssangsioskorean'] = 0x3146;
  12064. t['ssangtikeutkorean'] = 0x3138;
  12065. t['ssuperior'] = 0xF6F2;
  12066. t['sterling'] = 0x00A3;
  12067. t['sterlingmonospace'] = 0xFFE1;
  12068. t['strokelongoverlaycmb'] = 0x0336;
  12069. t['strokeshortoverlaycmb'] = 0x0335;
  12070. t['subset'] = 0x2282;
  12071. t['subsetnotequal'] = 0x228A;
  12072. t['subsetorequal'] = 0x2286;
  12073. t['succeeds'] = 0x227B;
  12074. t['suchthat'] = 0x220B;
  12075. t['suhiragana'] = 0x3059;
  12076. t['sukatakana'] = 0x30B9;
  12077. t['sukatakanahalfwidth'] = 0xFF7D;
  12078. t['sukunarabic'] = 0x0652;
  12079. t['summation'] = 0x2211;
  12080. t['sun'] = 0x263C;
  12081. t['superset'] = 0x2283;
  12082. t['supersetnotequal'] = 0x228B;
  12083. t['supersetorequal'] = 0x2287;
  12084. t['svsquare'] = 0x33DC;
  12085. t['syouwaerasquare'] = 0x337C;
  12086. t['t'] = 0x0074;
  12087. t['tabengali'] = 0x09A4;
  12088. t['tackdown'] = 0x22A4;
  12089. t['tackleft'] = 0x22A3;
  12090. t['tadeva'] = 0x0924;
  12091. t['tagujarati'] = 0x0AA4;
  12092. t['tagurmukhi'] = 0x0A24;
  12093. t['taharabic'] = 0x0637;
  12094. t['tahfinalarabic'] = 0xFEC2;
  12095. t['tahinitialarabic'] = 0xFEC3;
  12096. t['tahiragana'] = 0x305F;
  12097. t['tahmedialarabic'] = 0xFEC4;
  12098. t['taisyouerasquare'] = 0x337D;
  12099. t['takatakana'] = 0x30BF;
  12100. t['takatakanahalfwidth'] = 0xFF80;
  12101. t['tatweelarabic'] = 0x0640;
  12102. t['tau'] = 0x03C4;
  12103. t['tav'] = 0x05EA;
  12104. t['tavdages'] = 0xFB4A;
  12105. t['tavdagesh'] = 0xFB4A;
  12106. t['tavdageshhebrew'] = 0xFB4A;
  12107. t['tavhebrew'] = 0x05EA;
  12108. t['tbar'] = 0x0167;
  12109. t['tbopomofo'] = 0x310A;
  12110. t['tcaron'] = 0x0165;
  12111. t['tccurl'] = 0x02A8;
  12112. t['tcedilla'] = 0x0163;
  12113. t['tcheharabic'] = 0x0686;
  12114. t['tchehfinalarabic'] = 0xFB7B;
  12115. t['tchehinitialarabic'] = 0xFB7C;
  12116. t['tchehmedialarabic'] = 0xFB7D;
  12117. t['tcircle'] = 0x24E3;
  12118. t['tcircumflexbelow'] = 0x1E71;
  12119. t['tcommaaccent'] = 0x0163;
  12120. t['tdieresis'] = 0x1E97;
  12121. t['tdotaccent'] = 0x1E6B;
  12122. t['tdotbelow'] = 0x1E6D;
  12123. t['tecyrillic'] = 0x0442;
  12124. t['tedescendercyrillic'] = 0x04AD;
  12125. t['teharabic'] = 0x062A;
  12126. t['tehfinalarabic'] = 0xFE96;
  12127. t['tehhahinitialarabic'] = 0xFCA2;
  12128. t['tehhahisolatedarabic'] = 0xFC0C;
  12129. t['tehinitialarabic'] = 0xFE97;
  12130. t['tehiragana'] = 0x3066;
  12131. t['tehjeeminitialarabic'] = 0xFCA1;
  12132. t['tehjeemisolatedarabic'] = 0xFC0B;
  12133. t['tehmarbutaarabic'] = 0x0629;
  12134. t['tehmarbutafinalarabic'] = 0xFE94;
  12135. t['tehmedialarabic'] = 0xFE98;
  12136. t['tehmeeminitialarabic'] = 0xFCA4;
  12137. t['tehmeemisolatedarabic'] = 0xFC0E;
  12138. t['tehnoonfinalarabic'] = 0xFC73;
  12139. t['tekatakana'] = 0x30C6;
  12140. t['tekatakanahalfwidth'] = 0xFF83;
  12141. t['telephone'] = 0x2121;
  12142. t['telephoneblack'] = 0x260E;
  12143. t['telishagedolahebrew'] = 0x05A0;
  12144. t['telishaqetanahebrew'] = 0x05A9;
  12145. t['tencircle'] = 0x2469;
  12146. t['tenideographicparen'] = 0x3229;
  12147. t['tenparen'] = 0x247D;
  12148. t['tenperiod'] = 0x2491;
  12149. t['tenroman'] = 0x2179;
  12150. t['tesh'] = 0x02A7;
  12151. t['tet'] = 0x05D8;
  12152. t['tetdagesh'] = 0xFB38;
  12153. t['tetdageshhebrew'] = 0xFB38;
  12154. t['tethebrew'] = 0x05D8;
  12155. t['tetsecyrillic'] = 0x04B5;
  12156. t['tevirhebrew'] = 0x059B;
  12157. t['tevirlefthebrew'] = 0x059B;
  12158. t['thabengali'] = 0x09A5;
  12159. t['thadeva'] = 0x0925;
  12160. t['thagujarati'] = 0x0AA5;
  12161. t['thagurmukhi'] = 0x0A25;
  12162. t['thalarabic'] = 0x0630;
  12163. t['thalfinalarabic'] = 0xFEAC;
  12164. t['thanthakhatlowleftthai'] = 0xF898;
  12165. t['thanthakhatlowrightthai'] = 0xF897;
  12166. t['thanthakhatthai'] = 0x0E4C;
  12167. t['thanthakhatupperleftthai'] = 0xF896;
  12168. t['theharabic'] = 0x062B;
  12169. t['thehfinalarabic'] = 0xFE9A;
  12170. t['thehinitialarabic'] = 0xFE9B;
  12171. t['thehmedialarabic'] = 0xFE9C;
  12172. t['thereexists'] = 0x2203;
  12173. t['therefore'] = 0x2234;
  12174. t['theta'] = 0x03B8;
  12175. t['theta1'] = 0x03D1;
  12176. t['thetasymbolgreek'] = 0x03D1;
  12177. t['thieuthacirclekorean'] = 0x3279;
  12178. t['thieuthaparenkorean'] = 0x3219;
  12179. t['thieuthcirclekorean'] = 0x326B;
  12180. t['thieuthkorean'] = 0x314C;
  12181. t['thieuthparenkorean'] = 0x320B;
  12182. t['thirteencircle'] = 0x246C;
  12183. t['thirteenparen'] = 0x2480;
  12184. t['thirteenperiod'] = 0x2494;
  12185. t['thonangmonthothai'] = 0x0E11;
  12186. t['thook'] = 0x01AD;
  12187. t['thophuthaothai'] = 0x0E12;
  12188. t['thorn'] = 0x00FE;
  12189. t['thothahanthai'] = 0x0E17;
  12190. t['thothanthai'] = 0x0E10;
  12191. t['thothongthai'] = 0x0E18;
  12192. t['thothungthai'] = 0x0E16;
  12193. t['thousandcyrillic'] = 0x0482;
  12194. t['thousandsseparatorarabic'] = 0x066C;
  12195. t['thousandsseparatorpersian'] = 0x066C;
  12196. t['three'] = 0x0033;
  12197. t['threearabic'] = 0x0663;
  12198. t['threebengali'] = 0x09E9;
  12199. t['threecircle'] = 0x2462;
  12200. t['threecircleinversesansserif'] = 0x278C;
  12201. t['threedeva'] = 0x0969;
  12202. t['threeeighths'] = 0x215C;
  12203. t['threegujarati'] = 0x0AE9;
  12204. t['threegurmukhi'] = 0x0A69;
  12205. t['threehackarabic'] = 0x0663;
  12206. t['threehangzhou'] = 0x3023;
  12207. t['threeideographicparen'] = 0x3222;
  12208. t['threeinferior'] = 0x2083;
  12209. t['threemonospace'] = 0xFF13;
  12210. t['threenumeratorbengali'] = 0x09F6;
  12211. t['threeoldstyle'] = 0xF733;
  12212. t['threeparen'] = 0x2476;
  12213. t['threeperiod'] = 0x248A;
  12214. t['threepersian'] = 0x06F3;
  12215. t['threequarters'] = 0x00BE;
  12216. t['threequartersemdash'] = 0xF6DE;
  12217. t['threeroman'] = 0x2172;
  12218. t['threesuperior'] = 0x00B3;
  12219. t['threethai'] = 0x0E53;
  12220. t['thzsquare'] = 0x3394;
  12221. t['tihiragana'] = 0x3061;
  12222. t['tikatakana'] = 0x30C1;
  12223. t['tikatakanahalfwidth'] = 0xFF81;
  12224. t['tikeutacirclekorean'] = 0x3270;
  12225. t['tikeutaparenkorean'] = 0x3210;
  12226. t['tikeutcirclekorean'] = 0x3262;
  12227. t['tikeutkorean'] = 0x3137;
  12228. t['tikeutparenkorean'] = 0x3202;
  12229. t['tilde'] = 0x02DC;
  12230. t['tildebelowcmb'] = 0x0330;
  12231. t['tildecmb'] = 0x0303;
  12232. t['tildecomb'] = 0x0303;
  12233. t['tildedoublecmb'] = 0x0360;
  12234. t['tildeoperator'] = 0x223C;
  12235. t['tildeoverlaycmb'] = 0x0334;
  12236. t['tildeverticalcmb'] = 0x033E;
  12237. t['timescircle'] = 0x2297;
  12238. t['tipehahebrew'] = 0x0596;
  12239. t['tipehalefthebrew'] = 0x0596;
  12240. t['tippigurmukhi'] = 0x0A70;
  12241. t['titlocyrilliccmb'] = 0x0483;
  12242. t['tiwnarmenian'] = 0x057F;
  12243. t['tlinebelow'] = 0x1E6F;
  12244. t['tmonospace'] = 0xFF54;
  12245. t['toarmenian'] = 0x0569;
  12246. t['tohiragana'] = 0x3068;
  12247. t['tokatakana'] = 0x30C8;
  12248. t['tokatakanahalfwidth'] = 0xFF84;
  12249. t['tonebarextrahighmod'] = 0x02E5;
  12250. t['tonebarextralowmod'] = 0x02E9;
  12251. t['tonebarhighmod'] = 0x02E6;
  12252. t['tonebarlowmod'] = 0x02E8;
  12253. t['tonebarmidmod'] = 0x02E7;
  12254. t['tonefive'] = 0x01BD;
  12255. t['tonesix'] = 0x0185;
  12256. t['tonetwo'] = 0x01A8;
  12257. t['tonos'] = 0x0384;
  12258. t['tonsquare'] = 0x3327;
  12259. t['topatakthai'] = 0x0E0F;
  12260. t['tortoiseshellbracketleft'] = 0x3014;
  12261. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12262. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12263. t['tortoiseshellbracketright'] = 0x3015;
  12264. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12265. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12266. t['totaothai'] = 0x0E15;
  12267. t['tpalatalhook'] = 0x01AB;
  12268. t['tparen'] = 0x24AF;
  12269. t['trademark'] = 0x2122;
  12270. t['trademarksans'] = 0xF8EA;
  12271. t['trademarkserif'] = 0xF6DB;
  12272. t['tretroflexhook'] = 0x0288;
  12273. t['triagdn'] = 0x25BC;
  12274. t['triaglf'] = 0x25C4;
  12275. t['triagrt'] = 0x25BA;
  12276. t['triagup'] = 0x25B2;
  12277. t['ts'] = 0x02A6;
  12278. t['tsadi'] = 0x05E6;
  12279. t['tsadidagesh'] = 0xFB46;
  12280. t['tsadidageshhebrew'] = 0xFB46;
  12281. t['tsadihebrew'] = 0x05E6;
  12282. t['tsecyrillic'] = 0x0446;
  12283. t['tsere'] = 0x05B5;
  12284. t['tsere12'] = 0x05B5;
  12285. t['tsere1e'] = 0x05B5;
  12286. t['tsere2b'] = 0x05B5;
  12287. t['tserehebrew'] = 0x05B5;
  12288. t['tserenarrowhebrew'] = 0x05B5;
  12289. t['tserequarterhebrew'] = 0x05B5;
  12290. t['tserewidehebrew'] = 0x05B5;
  12291. t['tshecyrillic'] = 0x045B;
  12292. t['tsuperior'] = 0xF6F3;
  12293. t['ttabengali'] = 0x099F;
  12294. t['ttadeva'] = 0x091F;
  12295. t['ttagujarati'] = 0x0A9F;
  12296. t['ttagurmukhi'] = 0x0A1F;
  12297. t['tteharabic'] = 0x0679;
  12298. t['ttehfinalarabic'] = 0xFB67;
  12299. t['ttehinitialarabic'] = 0xFB68;
  12300. t['ttehmedialarabic'] = 0xFB69;
  12301. t['tthabengali'] = 0x09A0;
  12302. t['tthadeva'] = 0x0920;
  12303. t['tthagujarati'] = 0x0AA0;
  12304. t['tthagurmukhi'] = 0x0A20;
  12305. t['tturned'] = 0x0287;
  12306. t['tuhiragana'] = 0x3064;
  12307. t['tukatakana'] = 0x30C4;
  12308. t['tukatakanahalfwidth'] = 0xFF82;
  12309. t['tusmallhiragana'] = 0x3063;
  12310. t['tusmallkatakana'] = 0x30C3;
  12311. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12312. t['twelvecircle'] = 0x246B;
  12313. t['twelveparen'] = 0x247F;
  12314. t['twelveperiod'] = 0x2493;
  12315. t['twelveroman'] = 0x217B;
  12316. t['twentycircle'] = 0x2473;
  12317. t['twentyhangzhou'] = 0x5344;
  12318. t['twentyparen'] = 0x2487;
  12319. t['twentyperiod'] = 0x249B;
  12320. t['two'] = 0x0032;
  12321. t['twoarabic'] = 0x0662;
  12322. t['twobengali'] = 0x09E8;
  12323. t['twocircle'] = 0x2461;
  12324. t['twocircleinversesansserif'] = 0x278B;
  12325. t['twodeva'] = 0x0968;
  12326. t['twodotenleader'] = 0x2025;
  12327. t['twodotleader'] = 0x2025;
  12328. t['twodotleadervertical'] = 0xFE30;
  12329. t['twogujarati'] = 0x0AE8;
  12330. t['twogurmukhi'] = 0x0A68;
  12331. t['twohackarabic'] = 0x0662;
  12332. t['twohangzhou'] = 0x3022;
  12333. t['twoideographicparen'] = 0x3221;
  12334. t['twoinferior'] = 0x2082;
  12335. t['twomonospace'] = 0xFF12;
  12336. t['twonumeratorbengali'] = 0x09F5;
  12337. t['twooldstyle'] = 0xF732;
  12338. t['twoparen'] = 0x2475;
  12339. t['twoperiod'] = 0x2489;
  12340. t['twopersian'] = 0x06F2;
  12341. t['tworoman'] = 0x2171;
  12342. t['twostroke'] = 0x01BB;
  12343. t['twosuperior'] = 0x00B2;
  12344. t['twothai'] = 0x0E52;
  12345. t['twothirds'] = 0x2154;
  12346. t['u'] = 0x0075;
  12347. t['uacute'] = 0x00FA;
  12348. t['ubar'] = 0x0289;
  12349. t['ubengali'] = 0x0989;
  12350. t['ubopomofo'] = 0x3128;
  12351. t['ubreve'] = 0x016D;
  12352. t['ucaron'] = 0x01D4;
  12353. t['ucircle'] = 0x24E4;
  12354. t['ucircumflex'] = 0x00FB;
  12355. t['ucircumflexbelow'] = 0x1E77;
  12356. t['ucyrillic'] = 0x0443;
  12357. t['udattadeva'] = 0x0951;
  12358. t['udblacute'] = 0x0171;
  12359. t['udblgrave'] = 0x0215;
  12360. t['udeva'] = 0x0909;
  12361. t['udieresis'] = 0x00FC;
  12362. t['udieresisacute'] = 0x01D8;
  12363. t['udieresisbelow'] = 0x1E73;
  12364. t['udieresiscaron'] = 0x01DA;
  12365. t['udieresiscyrillic'] = 0x04F1;
  12366. t['udieresisgrave'] = 0x01DC;
  12367. t['udieresismacron'] = 0x01D6;
  12368. t['udotbelow'] = 0x1EE5;
  12369. t['ugrave'] = 0x00F9;
  12370. t['ugujarati'] = 0x0A89;
  12371. t['ugurmukhi'] = 0x0A09;
  12372. t['uhiragana'] = 0x3046;
  12373. t['uhookabove'] = 0x1EE7;
  12374. t['uhorn'] = 0x01B0;
  12375. t['uhornacute'] = 0x1EE9;
  12376. t['uhorndotbelow'] = 0x1EF1;
  12377. t['uhorngrave'] = 0x1EEB;
  12378. t['uhornhookabove'] = 0x1EED;
  12379. t['uhorntilde'] = 0x1EEF;
  12380. t['uhungarumlaut'] = 0x0171;
  12381. t['uhungarumlautcyrillic'] = 0x04F3;
  12382. t['uinvertedbreve'] = 0x0217;
  12383. t['ukatakana'] = 0x30A6;
  12384. t['ukatakanahalfwidth'] = 0xFF73;
  12385. t['ukcyrillic'] = 0x0479;
  12386. t['ukorean'] = 0x315C;
  12387. t['umacron'] = 0x016B;
  12388. t['umacroncyrillic'] = 0x04EF;
  12389. t['umacrondieresis'] = 0x1E7B;
  12390. t['umatragurmukhi'] = 0x0A41;
  12391. t['umonospace'] = 0xFF55;
  12392. t['underscore'] = 0x005F;
  12393. t['underscoredbl'] = 0x2017;
  12394. t['underscoremonospace'] = 0xFF3F;
  12395. t['underscorevertical'] = 0xFE33;
  12396. t['underscorewavy'] = 0xFE4F;
  12397. t['union'] = 0x222A;
  12398. t['universal'] = 0x2200;
  12399. t['uogonek'] = 0x0173;
  12400. t['uparen'] = 0x24B0;
  12401. t['upblock'] = 0x2580;
  12402. t['upperdothebrew'] = 0x05C4;
  12403. t['upsilon'] = 0x03C5;
  12404. t['upsilondieresis'] = 0x03CB;
  12405. t['upsilondieresistonos'] = 0x03B0;
  12406. t['upsilonlatin'] = 0x028A;
  12407. t['upsilontonos'] = 0x03CD;
  12408. t['uptackbelowcmb'] = 0x031D;
  12409. t['uptackmod'] = 0x02D4;
  12410. t['uragurmukhi'] = 0x0A73;
  12411. t['uring'] = 0x016F;
  12412. t['ushortcyrillic'] = 0x045E;
  12413. t['usmallhiragana'] = 0x3045;
  12414. t['usmallkatakana'] = 0x30A5;
  12415. t['usmallkatakanahalfwidth'] = 0xFF69;
  12416. t['ustraightcyrillic'] = 0x04AF;
  12417. t['ustraightstrokecyrillic'] = 0x04B1;
  12418. t['utilde'] = 0x0169;
  12419. t['utildeacute'] = 0x1E79;
  12420. t['utildebelow'] = 0x1E75;
  12421. t['uubengali'] = 0x098A;
  12422. t['uudeva'] = 0x090A;
  12423. t['uugujarati'] = 0x0A8A;
  12424. t['uugurmukhi'] = 0x0A0A;
  12425. t['uumatragurmukhi'] = 0x0A42;
  12426. t['uuvowelsignbengali'] = 0x09C2;
  12427. t['uuvowelsigndeva'] = 0x0942;
  12428. t['uuvowelsigngujarati'] = 0x0AC2;
  12429. t['uvowelsignbengali'] = 0x09C1;
  12430. t['uvowelsigndeva'] = 0x0941;
  12431. t['uvowelsigngujarati'] = 0x0AC1;
  12432. t['v'] = 0x0076;
  12433. t['vadeva'] = 0x0935;
  12434. t['vagujarati'] = 0x0AB5;
  12435. t['vagurmukhi'] = 0x0A35;
  12436. t['vakatakana'] = 0x30F7;
  12437. t['vav'] = 0x05D5;
  12438. t['vavdagesh'] = 0xFB35;
  12439. t['vavdagesh65'] = 0xFB35;
  12440. t['vavdageshhebrew'] = 0xFB35;
  12441. t['vavhebrew'] = 0x05D5;
  12442. t['vavholam'] = 0xFB4B;
  12443. t['vavholamhebrew'] = 0xFB4B;
  12444. t['vavvavhebrew'] = 0x05F0;
  12445. t['vavyodhebrew'] = 0x05F1;
  12446. t['vcircle'] = 0x24E5;
  12447. t['vdotbelow'] = 0x1E7F;
  12448. t['vecyrillic'] = 0x0432;
  12449. t['veharabic'] = 0x06A4;
  12450. t['vehfinalarabic'] = 0xFB6B;
  12451. t['vehinitialarabic'] = 0xFB6C;
  12452. t['vehmedialarabic'] = 0xFB6D;
  12453. t['vekatakana'] = 0x30F9;
  12454. t['venus'] = 0x2640;
  12455. t['verticalbar'] = 0x007C;
  12456. t['verticallineabovecmb'] = 0x030D;
  12457. t['verticallinebelowcmb'] = 0x0329;
  12458. t['verticallinelowmod'] = 0x02CC;
  12459. t['verticallinemod'] = 0x02C8;
  12460. t['vewarmenian'] = 0x057E;
  12461. t['vhook'] = 0x028B;
  12462. t['vikatakana'] = 0x30F8;
  12463. t['viramabengali'] = 0x09CD;
  12464. t['viramadeva'] = 0x094D;
  12465. t['viramagujarati'] = 0x0ACD;
  12466. t['visargabengali'] = 0x0983;
  12467. t['visargadeva'] = 0x0903;
  12468. t['visargagujarati'] = 0x0A83;
  12469. t['vmonospace'] = 0xFF56;
  12470. t['voarmenian'] = 0x0578;
  12471. t['voicediterationhiragana'] = 0x309E;
  12472. t['voicediterationkatakana'] = 0x30FE;
  12473. t['voicedmarkkana'] = 0x309B;
  12474. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12475. t['vokatakana'] = 0x30FA;
  12476. t['vparen'] = 0x24B1;
  12477. t['vtilde'] = 0x1E7D;
  12478. t['vturned'] = 0x028C;
  12479. t['vuhiragana'] = 0x3094;
  12480. t['vukatakana'] = 0x30F4;
  12481. t['w'] = 0x0077;
  12482. t['wacute'] = 0x1E83;
  12483. t['waekorean'] = 0x3159;
  12484. t['wahiragana'] = 0x308F;
  12485. t['wakatakana'] = 0x30EF;
  12486. t['wakatakanahalfwidth'] = 0xFF9C;
  12487. t['wakorean'] = 0x3158;
  12488. t['wasmallhiragana'] = 0x308E;
  12489. t['wasmallkatakana'] = 0x30EE;
  12490. t['wattosquare'] = 0x3357;
  12491. t['wavedash'] = 0x301C;
  12492. t['wavyunderscorevertical'] = 0xFE34;
  12493. t['wawarabic'] = 0x0648;
  12494. t['wawfinalarabic'] = 0xFEEE;
  12495. t['wawhamzaabovearabic'] = 0x0624;
  12496. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12497. t['wbsquare'] = 0x33DD;
  12498. t['wcircle'] = 0x24E6;
  12499. t['wcircumflex'] = 0x0175;
  12500. t['wdieresis'] = 0x1E85;
  12501. t['wdotaccent'] = 0x1E87;
  12502. t['wdotbelow'] = 0x1E89;
  12503. t['wehiragana'] = 0x3091;
  12504. t['weierstrass'] = 0x2118;
  12505. t['wekatakana'] = 0x30F1;
  12506. t['wekorean'] = 0x315E;
  12507. t['weokorean'] = 0x315D;
  12508. t['wgrave'] = 0x1E81;
  12509. t['whitebullet'] = 0x25E6;
  12510. t['whitecircle'] = 0x25CB;
  12511. t['whitecircleinverse'] = 0x25D9;
  12512. t['whitecornerbracketleft'] = 0x300E;
  12513. t['whitecornerbracketleftvertical'] = 0xFE43;
  12514. t['whitecornerbracketright'] = 0x300F;
  12515. t['whitecornerbracketrightvertical'] = 0xFE44;
  12516. t['whitediamond'] = 0x25C7;
  12517. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12518. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12519. t['whitedownpointingtriangle'] = 0x25BD;
  12520. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12521. t['whiteleftpointingtriangle'] = 0x25C1;
  12522. t['whitelenticularbracketleft'] = 0x3016;
  12523. t['whitelenticularbracketright'] = 0x3017;
  12524. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12525. t['whiterightpointingtriangle'] = 0x25B7;
  12526. t['whitesmallsquare'] = 0x25AB;
  12527. t['whitesmilingface'] = 0x263A;
  12528. t['whitesquare'] = 0x25A1;
  12529. t['whitestar'] = 0x2606;
  12530. t['whitetelephone'] = 0x260F;
  12531. t['whitetortoiseshellbracketleft'] = 0x3018;
  12532. t['whitetortoiseshellbracketright'] = 0x3019;
  12533. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12534. t['whiteuppointingtriangle'] = 0x25B3;
  12535. t['wihiragana'] = 0x3090;
  12536. t['wikatakana'] = 0x30F0;
  12537. t['wikorean'] = 0x315F;
  12538. t['wmonospace'] = 0xFF57;
  12539. t['wohiragana'] = 0x3092;
  12540. t['wokatakana'] = 0x30F2;
  12541. t['wokatakanahalfwidth'] = 0xFF66;
  12542. t['won'] = 0x20A9;
  12543. t['wonmonospace'] = 0xFFE6;
  12544. t['wowaenthai'] = 0x0E27;
  12545. t['wparen'] = 0x24B2;
  12546. t['wring'] = 0x1E98;
  12547. t['wsuperior'] = 0x02B7;
  12548. t['wturned'] = 0x028D;
  12549. t['wynn'] = 0x01BF;
  12550. t['x'] = 0x0078;
  12551. t['xabovecmb'] = 0x033D;
  12552. t['xbopomofo'] = 0x3112;
  12553. t['xcircle'] = 0x24E7;
  12554. t['xdieresis'] = 0x1E8D;
  12555. t['xdotaccent'] = 0x1E8B;
  12556. t['xeharmenian'] = 0x056D;
  12557. t['xi'] = 0x03BE;
  12558. t['xmonospace'] = 0xFF58;
  12559. t['xparen'] = 0x24B3;
  12560. t['xsuperior'] = 0x02E3;
  12561. t['y'] = 0x0079;
  12562. t['yaadosquare'] = 0x334E;
  12563. t['yabengali'] = 0x09AF;
  12564. t['yacute'] = 0x00FD;
  12565. t['yadeva'] = 0x092F;
  12566. t['yaekorean'] = 0x3152;
  12567. t['yagujarati'] = 0x0AAF;
  12568. t['yagurmukhi'] = 0x0A2F;
  12569. t['yahiragana'] = 0x3084;
  12570. t['yakatakana'] = 0x30E4;
  12571. t['yakatakanahalfwidth'] = 0xFF94;
  12572. t['yakorean'] = 0x3151;
  12573. t['yamakkanthai'] = 0x0E4E;
  12574. t['yasmallhiragana'] = 0x3083;
  12575. t['yasmallkatakana'] = 0x30E3;
  12576. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12577. t['yatcyrillic'] = 0x0463;
  12578. t['ycircle'] = 0x24E8;
  12579. t['ycircumflex'] = 0x0177;
  12580. t['ydieresis'] = 0x00FF;
  12581. t['ydotaccent'] = 0x1E8F;
  12582. t['ydotbelow'] = 0x1EF5;
  12583. t['yeharabic'] = 0x064A;
  12584. t['yehbarreearabic'] = 0x06D2;
  12585. t['yehbarreefinalarabic'] = 0xFBAF;
  12586. t['yehfinalarabic'] = 0xFEF2;
  12587. t['yehhamzaabovearabic'] = 0x0626;
  12588. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12589. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12590. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12591. t['yehinitialarabic'] = 0xFEF3;
  12592. t['yehmedialarabic'] = 0xFEF4;
  12593. t['yehmeeminitialarabic'] = 0xFCDD;
  12594. t['yehmeemisolatedarabic'] = 0xFC58;
  12595. t['yehnoonfinalarabic'] = 0xFC94;
  12596. t['yehthreedotsbelowarabic'] = 0x06D1;
  12597. t['yekorean'] = 0x3156;
  12598. t['yen'] = 0x00A5;
  12599. t['yenmonospace'] = 0xFFE5;
  12600. t['yeokorean'] = 0x3155;
  12601. t['yeorinhieuhkorean'] = 0x3186;
  12602. t['yerahbenyomohebrew'] = 0x05AA;
  12603. t['yerahbenyomolefthebrew'] = 0x05AA;
  12604. t['yericyrillic'] = 0x044B;
  12605. t['yerudieresiscyrillic'] = 0x04F9;
  12606. t['yesieungkorean'] = 0x3181;
  12607. t['yesieungpansioskorean'] = 0x3183;
  12608. t['yesieungsioskorean'] = 0x3182;
  12609. t['yetivhebrew'] = 0x059A;
  12610. t['ygrave'] = 0x1EF3;
  12611. t['yhook'] = 0x01B4;
  12612. t['yhookabove'] = 0x1EF7;
  12613. t['yiarmenian'] = 0x0575;
  12614. t['yicyrillic'] = 0x0457;
  12615. t['yikorean'] = 0x3162;
  12616. t['yinyang'] = 0x262F;
  12617. t['yiwnarmenian'] = 0x0582;
  12618. t['ymonospace'] = 0xFF59;
  12619. t['yod'] = 0x05D9;
  12620. t['yoddagesh'] = 0xFB39;
  12621. t['yoddageshhebrew'] = 0xFB39;
  12622. t['yodhebrew'] = 0x05D9;
  12623. t['yodyodhebrew'] = 0x05F2;
  12624. t['yodyodpatahhebrew'] = 0xFB1F;
  12625. t['yohiragana'] = 0x3088;
  12626. t['yoikorean'] = 0x3189;
  12627. t['yokatakana'] = 0x30E8;
  12628. t['yokatakanahalfwidth'] = 0xFF96;
  12629. t['yokorean'] = 0x315B;
  12630. t['yosmallhiragana'] = 0x3087;
  12631. t['yosmallkatakana'] = 0x30E7;
  12632. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12633. t['yotgreek'] = 0x03F3;
  12634. t['yoyaekorean'] = 0x3188;
  12635. t['yoyakorean'] = 0x3187;
  12636. t['yoyakthai'] = 0x0E22;
  12637. t['yoyingthai'] = 0x0E0D;
  12638. t['yparen'] = 0x24B4;
  12639. t['ypogegrammeni'] = 0x037A;
  12640. t['ypogegrammenigreekcmb'] = 0x0345;
  12641. t['yr'] = 0x01A6;
  12642. t['yring'] = 0x1E99;
  12643. t['ysuperior'] = 0x02B8;
  12644. t['ytilde'] = 0x1EF9;
  12645. t['yturned'] = 0x028E;
  12646. t['yuhiragana'] = 0x3086;
  12647. t['yuikorean'] = 0x318C;
  12648. t['yukatakana'] = 0x30E6;
  12649. t['yukatakanahalfwidth'] = 0xFF95;
  12650. t['yukorean'] = 0x3160;
  12651. t['yusbigcyrillic'] = 0x046B;
  12652. t['yusbigiotifiedcyrillic'] = 0x046D;
  12653. t['yuslittlecyrillic'] = 0x0467;
  12654. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12655. t['yusmallhiragana'] = 0x3085;
  12656. t['yusmallkatakana'] = 0x30E5;
  12657. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12658. t['yuyekorean'] = 0x318B;
  12659. t['yuyeokorean'] = 0x318A;
  12660. t['yyabengali'] = 0x09DF;
  12661. t['yyadeva'] = 0x095F;
  12662. t['z'] = 0x007A;
  12663. t['zaarmenian'] = 0x0566;
  12664. t['zacute'] = 0x017A;
  12665. t['zadeva'] = 0x095B;
  12666. t['zagurmukhi'] = 0x0A5B;
  12667. t['zaharabic'] = 0x0638;
  12668. t['zahfinalarabic'] = 0xFEC6;
  12669. t['zahinitialarabic'] = 0xFEC7;
  12670. t['zahiragana'] = 0x3056;
  12671. t['zahmedialarabic'] = 0xFEC8;
  12672. t['zainarabic'] = 0x0632;
  12673. t['zainfinalarabic'] = 0xFEB0;
  12674. t['zakatakana'] = 0x30B6;
  12675. t['zaqefgadolhebrew'] = 0x0595;
  12676. t['zaqefqatanhebrew'] = 0x0594;
  12677. t['zarqahebrew'] = 0x0598;
  12678. t['zayin'] = 0x05D6;
  12679. t['zayindagesh'] = 0xFB36;
  12680. t['zayindageshhebrew'] = 0xFB36;
  12681. t['zayinhebrew'] = 0x05D6;
  12682. t['zbopomofo'] = 0x3117;
  12683. t['zcaron'] = 0x017E;
  12684. t['zcircle'] = 0x24E9;
  12685. t['zcircumflex'] = 0x1E91;
  12686. t['zcurl'] = 0x0291;
  12687. t['zdot'] = 0x017C;
  12688. t['zdotaccent'] = 0x017C;
  12689. t['zdotbelow'] = 0x1E93;
  12690. t['zecyrillic'] = 0x0437;
  12691. t['zedescendercyrillic'] = 0x0499;
  12692. t['zedieresiscyrillic'] = 0x04DF;
  12693. t['zehiragana'] = 0x305C;
  12694. t['zekatakana'] = 0x30BC;
  12695. t['zero'] = 0x0030;
  12696. t['zeroarabic'] = 0x0660;
  12697. t['zerobengali'] = 0x09E6;
  12698. t['zerodeva'] = 0x0966;
  12699. t['zerogujarati'] = 0x0AE6;
  12700. t['zerogurmukhi'] = 0x0A66;
  12701. t['zerohackarabic'] = 0x0660;
  12702. t['zeroinferior'] = 0x2080;
  12703. t['zeromonospace'] = 0xFF10;
  12704. t['zerooldstyle'] = 0xF730;
  12705. t['zeropersian'] = 0x06F0;
  12706. t['zerosuperior'] = 0x2070;
  12707. t['zerothai'] = 0x0E50;
  12708. t['zerowidthjoiner'] = 0xFEFF;
  12709. t['zerowidthnonjoiner'] = 0x200C;
  12710. t['zerowidthspace'] = 0x200B;
  12711. t['zeta'] = 0x03B6;
  12712. t['zhbopomofo'] = 0x3113;
  12713. t['zhearmenian'] = 0x056A;
  12714. t['zhebrevecyrillic'] = 0x04C2;
  12715. t['zhecyrillic'] = 0x0436;
  12716. t['zhedescendercyrillic'] = 0x0497;
  12717. t['zhedieresiscyrillic'] = 0x04DD;
  12718. t['zihiragana'] = 0x3058;
  12719. t['zikatakana'] = 0x30B8;
  12720. t['zinorhebrew'] = 0x05AE;
  12721. t['zlinebelow'] = 0x1E95;
  12722. t['zmonospace'] = 0xFF5A;
  12723. t['zohiragana'] = 0x305E;
  12724. t['zokatakana'] = 0x30BE;
  12725. t['zparen'] = 0x24B5;
  12726. t['zretroflexhook'] = 0x0290;
  12727. t['zstroke'] = 0x01B6;
  12728. t['zuhiragana'] = 0x305A;
  12729. t['zukatakana'] = 0x30BA;
  12730. t['.notdef'] = 0x0000;
  12731. });
  12732. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12733. t['space'] = 0x0020;
  12734. t['a1'] = 0x2701;
  12735. t['a2'] = 0x2702;
  12736. t['a202'] = 0x2703;
  12737. t['a3'] = 0x2704;
  12738. t['a4'] = 0x260E;
  12739. t['a5'] = 0x2706;
  12740. t['a119'] = 0x2707;
  12741. t['a118'] = 0x2708;
  12742. t['a117'] = 0x2709;
  12743. t['a11'] = 0x261B;
  12744. t['a12'] = 0x261E;
  12745. t['a13'] = 0x270C;
  12746. t['a14'] = 0x270D;
  12747. t['a15'] = 0x270E;
  12748. t['a16'] = 0x270F;
  12749. t['a105'] = 0x2710;
  12750. t['a17'] = 0x2711;
  12751. t['a18'] = 0x2712;
  12752. t['a19'] = 0x2713;
  12753. t['a20'] = 0x2714;
  12754. t['a21'] = 0x2715;
  12755. t['a22'] = 0x2716;
  12756. t['a23'] = 0x2717;
  12757. t['a24'] = 0x2718;
  12758. t['a25'] = 0x2719;
  12759. t['a26'] = 0x271A;
  12760. t['a27'] = 0x271B;
  12761. t['a28'] = 0x271C;
  12762. t['a6'] = 0x271D;
  12763. t['a7'] = 0x271E;
  12764. t['a8'] = 0x271F;
  12765. t['a9'] = 0x2720;
  12766. t['a10'] = 0x2721;
  12767. t['a29'] = 0x2722;
  12768. t['a30'] = 0x2723;
  12769. t['a31'] = 0x2724;
  12770. t['a32'] = 0x2725;
  12771. t['a33'] = 0x2726;
  12772. t['a34'] = 0x2727;
  12773. t['a35'] = 0x2605;
  12774. t['a36'] = 0x2729;
  12775. t['a37'] = 0x272A;
  12776. t['a38'] = 0x272B;
  12777. t['a39'] = 0x272C;
  12778. t['a40'] = 0x272D;
  12779. t['a41'] = 0x272E;
  12780. t['a42'] = 0x272F;
  12781. t['a43'] = 0x2730;
  12782. t['a44'] = 0x2731;
  12783. t['a45'] = 0x2732;
  12784. t['a46'] = 0x2733;
  12785. t['a47'] = 0x2734;
  12786. t['a48'] = 0x2735;
  12787. t['a49'] = 0x2736;
  12788. t['a50'] = 0x2737;
  12789. t['a51'] = 0x2738;
  12790. t['a52'] = 0x2739;
  12791. t['a53'] = 0x273A;
  12792. t['a54'] = 0x273B;
  12793. t['a55'] = 0x273C;
  12794. t['a56'] = 0x273D;
  12795. t['a57'] = 0x273E;
  12796. t['a58'] = 0x273F;
  12797. t['a59'] = 0x2740;
  12798. t['a60'] = 0x2741;
  12799. t['a61'] = 0x2742;
  12800. t['a62'] = 0x2743;
  12801. t['a63'] = 0x2744;
  12802. t['a64'] = 0x2745;
  12803. t['a65'] = 0x2746;
  12804. t['a66'] = 0x2747;
  12805. t['a67'] = 0x2748;
  12806. t['a68'] = 0x2749;
  12807. t['a69'] = 0x274A;
  12808. t['a70'] = 0x274B;
  12809. t['a71'] = 0x25CF;
  12810. t['a72'] = 0x274D;
  12811. t['a73'] = 0x25A0;
  12812. t['a74'] = 0x274F;
  12813. t['a203'] = 0x2750;
  12814. t['a75'] = 0x2751;
  12815. t['a204'] = 0x2752;
  12816. t['a76'] = 0x25B2;
  12817. t['a77'] = 0x25BC;
  12818. t['a78'] = 0x25C6;
  12819. t['a79'] = 0x2756;
  12820. t['a81'] = 0x25D7;
  12821. t['a82'] = 0x2758;
  12822. t['a83'] = 0x2759;
  12823. t['a84'] = 0x275A;
  12824. t['a97'] = 0x275B;
  12825. t['a98'] = 0x275C;
  12826. t['a99'] = 0x275D;
  12827. t['a100'] = 0x275E;
  12828. t['a101'] = 0x2761;
  12829. t['a102'] = 0x2762;
  12830. t['a103'] = 0x2763;
  12831. t['a104'] = 0x2764;
  12832. t['a106'] = 0x2765;
  12833. t['a107'] = 0x2766;
  12834. t['a108'] = 0x2767;
  12835. t['a112'] = 0x2663;
  12836. t['a111'] = 0x2666;
  12837. t['a110'] = 0x2665;
  12838. t['a109'] = 0x2660;
  12839. t['a120'] = 0x2460;
  12840. t['a121'] = 0x2461;
  12841. t['a122'] = 0x2462;
  12842. t['a123'] = 0x2463;
  12843. t['a124'] = 0x2464;
  12844. t['a125'] = 0x2465;
  12845. t['a126'] = 0x2466;
  12846. t['a127'] = 0x2467;
  12847. t['a128'] = 0x2468;
  12848. t['a129'] = 0x2469;
  12849. t['a130'] = 0x2776;
  12850. t['a131'] = 0x2777;
  12851. t['a132'] = 0x2778;
  12852. t['a133'] = 0x2779;
  12853. t['a134'] = 0x277A;
  12854. t['a135'] = 0x277B;
  12855. t['a136'] = 0x277C;
  12856. t['a137'] = 0x277D;
  12857. t['a138'] = 0x277E;
  12858. t['a139'] = 0x277F;
  12859. t['a140'] = 0x2780;
  12860. t['a141'] = 0x2781;
  12861. t['a142'] = 0x2782;
  12862. t['a143'] = 0x2783;
  12863. t['a144'] = 0x2784;
  12864. t['a145'] = 0x2785;
  12865. t['a146'] = 0x2786;
  12866. t['a147'] = 0x2787;
  12867. t['a148'] = 0x2788;
  12868. t['a149'] = 0x2789;
  12869. t['a150'] = 0x278A;
  12870. t['a151'] = 0x278B;
  12871. t['a152'] = 0x278C;
  12872. t['a153'] = 0x278D;
  12873. t['a154'] = 0x278E;
  12874. t['a155'] = 0x278F;
  12875. t['a156'] = 0x2790;
  12876. t['a157'] = 0x2791;
  12877. t['a158'] = 0x2792;
  12878. t['a159'] = 0x2793;
  12879. t['a160'] = 0x2794;
  12880. t['a161'] = 0x2192;
  12881. t['a163'] = 0x2194;
  12882. t['a164'] = 0x2195;
  12883. t['a196'] = 0x2798;
  12884. t['a165'] = 0x2799;
  12885. t['a192'] = 0x279A;
  12886. t['a166'] = 0x279B;
  12887. t['a167'] = 0x279C;
  12888. t['a168'] = 0x279D;
  12889. t['a169'] = 0x279E;
  12890. t['a170'] = 0x279F;
  12891. t['a171'] = 0x27A0;
  12892. t['a172'] = 0x27A1;
  12893. t['a173'] = 0x27A2;
  12894. t['a162'] = 0x27A3;
  12895. t['a174'] = 0x27A4;
  12896. t['a175'] = 0x27A5;
  12897. t['a176'] = 0x27A6;
  12898. t['a177'] = 0x27A7;
  12899. t['a178'] = 0x27A8;
  12900. t['a179'] = 0x27A9;
  12901. t['a193'] = 0x27AA;
  12902. t['a180'] = 0x27AB;
  12903. t['a199'] = 0x27AC;
  12904. t['a181'] = 0x27AD;
  12905. t['a200'] = 0x27AE;
  12906. t['a182'] = 0x27AF;
  12907. t['a201'] = 0x27B1;
  12908. t['a183'] = 0x27B2;
  12909. t['a184'] = 0x27B3;
  12910. t['a197'] = 0x27B4;
  12911. t['a185'] = 0x27B5;
  12912. t['a194'] = 0x27B6;
  12913. t['a198'] = 0x27B7;
  12914. t['a186'] = 0x27B8;
  12915. t['a195'] = 0x27B9;
  12916. t['a187'] = 0x27BA;
  12917. t['a188'] = 0x27BB;
  12918. t['a189'] = 0x27BC;
  12919. t['a190'] = 0x27BD;
  12920. t['a191'] = 0x27BE;
  12921. t['a89'] = 0x2768;
  12922. t['a90'] = 0x2769;
  12923. t['a93'] = 0x276A;
  12924. t['a94'] = 0x276B;
  12925. t['a91'] = 0x276C;
  12926. t['a92'] = 0x276D;
  12927. t['a205'] = 0x276E;
  12928. t['a85'] = 0x276F;
  12929. t['a206'] = 0x2770;
  12930. t['a86'] = 0x2771;
  12931. t['a87'] = 0x2772;
  12932. t['a88'] = 0x2773;
  12933. t['a95'] = 0x2774;
  12934. t['a96'] = 0x2775;
  12935. t['.notdef'] = 0x0000;
  12936. });
  12937. exports.getGlyphsUnicode = getGlyphsUnicode;
  12938. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  12939. }));
  12940. (function (root, factory) {
  12941. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  12942. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  12943. var error = sharedUtil.error;
  12944. var log2 = sharedUtil.log2;
  12945. var readInt8 = sharedUtil.readInt8;
  12946. var readUint16 = sharedUtil.readUint16;
  12947. var readUint32 = sharedUtil.readUint32;
  12948. var shadow = sharedUtil.shadow;
  12949. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  12950. var Jbig2Image = function Jbig2ImageClosure() {
  12951. function ContextCache() {
  12952. }
  12953. ContextCache.prototype = {
  12954. getContexts: function (id) {
  12955. if (id in this) {
  12956. return this[id];
  12957. }
  12958. return this[id] = new Int8Array(1 << 16);
  12959. }
  12960. };
  12961. function DecodingContext(data, start, end) {
  12962. this.data = data;
  12963. this.start = start;
  12964. this.end = end;
  12965. }
  12966. DecodingContext.prototype = {
  12967. get decoder() {
  12968. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  12969. return shadow(this, 'decoder', decoder);
  12970. },
  12971. get contextCache() {
  12972. var cache = new ContextCache();
  12973. return shadow(this, 'contextCache', cache);
  12974. }
  12975. };
  12976. function decodeInteger(contextCache, procedure, decoder) {
  12977. var contexts = contextCache.getContexts(procedure);
  12978. var prev = 1;
  12979. function readBits(length) {
  12980. var v = 0;
  12981. for (var i = 0; i < length; i++) {
  12982. var bit = decoder.readBit(contexts, prev);
  12983. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  12984. v = v << 1 | bit;
  12985. }
  12986. return v >>> 0;
  12987. }
  12988. var sign = readBits(1);
  12989. 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);
  12990. return sign === 0 ? value : value > 0 ? -value : null;
  12991. }
  12992. function decodeIAID(contextCache, decoder, codeLength) {
  12993. var contexts = contextCache.getContexts('IAID');
  12994. var prev = 1;
  12995. for (var i = 0; i < codeLength; i++) {
  12996. var bit = decoder.readBit(contexts, prev);
  12997. prev = prev << 1 | bit;
  12998. }
  12999. if (codeLength < 31) {
  13000. return prev & (1 << codeLength) - 1;
  13001. }
  13002. return prev & 0x7FFFFFFF;
  13003. }
  13004. var SegmentTypes = [
  13005. 'SymbolDictionary',
  13006. null,
  13007. null,
  13008. null,
  13009. 'IntermediateTextRegion',
  13010. null,
  13011. 'ImmediateTextRegion',
  13012. 'ImmediateLosslessTextRegion',
  13013. null,
  13014. null,
  13015. null,
  13016. null,
  13017. null,
  13018. null,
  13019. null,
  13020. null,
  13021. 'patternDictionary',
  13022. null,
  13023. null,
  13024. null,
  13025. 'IntermediateHalftoneRegion',
  13026. null,
  13027. 'ImmediateHalftoneRegion',
  13028. 'ImmediateLosslessHalftoneRegion',
  13029. null,
  13030. null,
  13031. null,
  13032. null,
  13033. null,
  13034. null,
  13035. null,
  13036. null,
  13037. null,
  13038. null,
  13039. null,
  13040. null,
  13041. 'IntermediateGenericRegion',
  13042. null,
  13043. 'ImmediateGenericRegion',
  13044. 'ImmediateLosslessGenericRegion',
  13045. 'IntermediateGenericRefinementRegion',
  13046. null,
  13047. 'ImmediateGenericRefinementRegion',
  13048. 'ImmediateLosslessGenericRefinementRegion',
  13049. null,
  13050. null,
  13051. null,
  13052. null,
  13053. 'PageInformation',
  13054. 'EndOfPage',
  13055. 'EndOfStripe',
  13056. 'EndOfFile',
  13057. 'Profiles',
  13058. 'Tables',
  13059. null,
  13060. null,
  13061. null,
  13062. null,
  13063. null,
  13064. null,
  13065. null,
  13066. null,
  13067. 'Extension'
  13068. ];
  13069. var CodingTemplates = [
  13070. [
  13071. {
  13072. x: -1,
  13073. y: -2
  13074. },
  13075. {
  13076. x: 0,
  13077. y: -2
  13078. },
  13079. {
  13080. x: 1,
  13081. y: -2
  13082. },
  13083. {
  13084. x: -2,
  13085. y: -1
  13086. },
  13087. {
  13088. x: -1,
  13089. y: -1
  13090. },
  13091. {
  13092. x: 0,
  13093. y: -1
  13094. },
  13095. {
  13096. x: 1,
  13097. y: -1
  13098. },
  13099. {
  13100. x: 2,
  13101. y: -1
  13102. },
  13103. {
  13104. x: -4,
  13105. y: 0
  13106. },
  13107. {
  13108. x: -3,
  13109. y: 0
  13110. },
  13111. {
  13112. x: -2,
  13113. y: 0
  13114. },
  13115. {
  13116. x: -1,
  13117. y: 0
  13118. }
  13119. ],
  13120. [
  13121. {
  13122. x: -1,
  13123. y: -2
  13124. },
  13125. {
  13126. x: 0,
  13127. y: -2
  13128. },
  13129. {
  13130. x: 1,
  13131. y: -2
  13132. },
  13133. {
  13134. x: 2,
  13135. y: -2
  13136. },
  13137. {
  13138. x: -2,
  13139. y: -1
  13140. },
  13141. {
  13142. x: -1,
  13143. y: -1
  13144. },
  13145. {
  13146. x: 0,
  13147. y: -1
  13148. },
  13149. {
  13150. x: 1,
  13151. y: -1
  13152. },
  13153. {
  13154. x: 2,
  13155. y: -1
  13156. },
  13157. {
  13158. x: -3,
  13159. y: 0
  13160. },
  13161. {
  13162. x: -2,
  13163. y: 0
  13164. },
  13165. {
  13166. x: -1,
  13167. y: 0
  13168. }
  13169. ],
  13170. [
  13171. {
  13172. x: -1,
  13173. y: -2
  13174. },
  13175. {
  13176. x: 0,
  13177. y: -2
  13178. },
  13179. {
  13180. x: 1,
  13181. y: -2
  13182. },
  13183. {
  13184. x: -2,
  13185. y: -1
  13186. },
  13187. {
  13188. x: -1,
  13189. y: -1
  13190. },
  13191. {
  13192. x: 0,
  13193. y: -1
  13194. },
  13195. {
  13196. x: 1,
  13197. y: -1
  13198. },
  13199. {
  13200. x: -2,
  13201. y: 0
  13202. },
  13203. {
  13204. x: -1,
  13205. y: 0
  13206. }
  13207. ],
  13208. [
  13209. {
  13210. x: -3,
  13211. y: -1
  13212. },
  13213. {
  13214. x: -2,
  13215. y: -1
  13216. },
  13217. {
  13218. x: -1,
  13219. y: -1
  13220. },
  13221. {
  13222. x: 0,
  13223. y: -1
  13224. },
  13225. {
  13226. x: 1,
  13227. y: -1
  13228. },
  13229. {
  13230. x: -4,
  13231. y: 0
  13232. },
  13233. {
  13234. x: -3,
  13235. y: 0
  13236. },
  13237. {
  13238. x: -2,
  13239. y: 0
  13240. },
  13241. {
  13242. x: -1,
  13243. y: 0
  13244. }
  13245. ]
  13246. ];
  13247. var RefinementTemplates = [
  13248. {
  13249. coding: [
  13250. {
  13251. x: 0,
  13252. y: -1
  13253. },
  13254. {
  13255. x: 1,
  13256. y: -1
  13257. },
  13258. {
  13259. x: -1,
  13260. y: 0
  13261. }
  13262. ],
  13263. reference: [
  13264. {
  13265. x: 0,
  13266. y: -1
  13267. },
  13268. {
  13269. x: 1,
  13270. y: -1
  13271. },
  13272. {
  13273. x: -1,
  13274. y: 0
  13275. },
  13276. {
  13277. x: 0,
  13278. y: 0
  13279. },
  13280. {
  13281. x: 1,
  13282. y: 0
  13283. },
  13284. {
  13285. x: -1,
  13286. y: 1
  13287. },
  13288. {
  13289. x: 0,
  13290. y: 1
  13291. },
  13292. {
  13293. x: 1,
  13294. y: 1
  13295. }
  13296. ]
  13297. },
  13298. {
  13299. coding: [
  13300. {
  13301. x: -1,
  13302. y: -1
  13303. },
  13304. {
  13305. x: 0,
  13306. y: -1
  13307. },
  13308. {
  13309. x: 1,
  13310. y: -1
  13311. },
  13312. {
  13313. x: -1,
  13314. y: 0
  13315. }
  13316. ],
  13317. reference: [
  13318. {
  13319. x: 0,
  13320. y: -1
  13321. },
  13322. {
  13323. x: -1,
  13324. y: 0
  13325. },
  13326. {
  13327. x: 0,
  13328. y: 0
  13329. },
  13330. {
  13331. x: 1,
  13332. y: 0
  13333. },
  13334. {
  13335. x: 0,
  13336. y: 1
  13337. },
  13338. {
  13339. x: 1,
  13340. y: 1
  13341. }
  13342. ]
  13343. }
  13344. ];
  13345. var ReusedContexts = [
  13346. 0x9B25,
  13347. 0x0795,
  13348. 0x00E5,
  13349. 0x0195
  13350. ];
  13351. var RefinementReusedContexts = [
  13352. 0x0020,
  13353. 0x0008
  13354. ];
  13355. function decodeBitmapTemplate0(width, height, decodingContext) {
  13356. var decoder = decodingContext.decoder;
  13357. var contexts = decodingContext.contextCache.getContexts('GB');
  13358. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13359. var OLD_PIXEL_MASK = 0x7BF7;
  13360. for (i = 0; i < height; i++) {
  13361. row = bitmap[i] = new Uint8Array(width);
  13362. row1 = i < 1 ? row : bitmap[i - 1];
  13363. row2 = i < 2 ? row : bitmap[i - 2];
  13364. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13365. for (j = 0; j < width; j++) {
  13366. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13367. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13368. }
  13369. }
  13370. return bitmap;
  13371. }
  13372. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13373. if (mmr) {
  13374. error('JBIG2 error: MMR encoding is not supported');
  13375. }
  13376. 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) {
  13377. return decodeBitmapTemplate0(width, height, decodingContext);
  13378. }
  13379. var useskip = !!skip;
  13380. var template = CodingTemplates[templateIndex].concat(at);
  13381. template.sort(function (a, b) {
  13382. return a.y - b.y || a.x - b.x;
  13383. });
  13384. var templateLength = template.length;
  13385. var templateX = new Int8Array(templateLength);
  13386. var templateY = new Int8Array(templateLength);
  13387. var changingTemplateEntries = [];
  13388. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13389. var c, k;
  13390. for (k = 0; k < templateLength; k++) {
  13391. templateX[k] = template[k].x;
  13392. templateY[k] = template[k].y;
  13393. minX = Math.min(minX, template[k].x);
  13394. maxX = Math.max(maxX, template[k].x);
  13395. minY = Math.min(minY, template[k].y);
  13396. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13397. reuseMask |= 1 << templateLength - 1 - k;
  13398. } else {
  13399. changingTemplateEntries.push(k);
  13400. }
  13401. }
  13402. var changingEntriesLength = changingTemplateEntries.length;
  13403. var changingTemplateX = new Int8Array(changingEntriesLength);
  13404. var changingTemplateY = new Int8Array(changingEntriesLength);
  13405. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13406. for (c = 0; c < changingEntriesLength; c++) {
  13407. k = changingTemplateEntries[c];
  13408. changingTemplateX[c] = template[k].x;
  13409. changingTemplateY[c] = template[k].y;
  13410. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13411. }
  13412. var sbb_left = -minX;
  13413. var sbb_top = -minY;
  13414. var sbb_right = width - maxX;
  13415. var pseudoPixelContext = ReusedContexts[templateIndex];
  13416. var row = new Uint8Array(width);
  13417. var bitmap = [];
  13418. var decoder = decodingContext.decoder;
  13419. var contexts = decodingContext.contextCache.getContexts('GB');
  13420. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13421. for (var i = 0; i < height; i++) {
  13422. if (prediction) {
  13423. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13424. ltp ^= sltp;
  13425. if (ltp) {
  13426. bitmap.push(row);
  13427. continue;
  13428. }
  13429. }
  13430. row = new Uint8Array(row);
  13431. bitmap.push(row);
  13432. for (j = 0; j < width; j++) {
  13433. if (useskip && skip[i][j]) {
  13434. row[j] = 0;
  13435. continue;
  13436. }
  13437. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13438. contextLabel = contextLabel << 1 & reuseMask;
  13439. for (k = 0; k < changingEntriesLength; k++) {
  13440. i0 = i + changingTemplateY[k];
  13441. j0 = j + changingTemplateX[k];
  13442. bit = bitmap[i0][j0];
  13443. if (bit) {
  13444. bit = changingTemplateBit[k];
  13445. contextLabel |= bit;
  13446. }
  13447. }
  13448. } else {
  13449. contextLabel = 0;
  13450. shift = templateLength - 1;
  13451. for (k = 0; k < templateLength; k++, shift--) {
  13452. j0 = j + templateX[k];
  13453. if (j0 >= 0 && j0 < width) {
  13454. i0 = i + templateY[k];
  13455. if (i0 >= 0) {
  13456. bit = bitmap[i0][j0];
  13457. if (bit) {
  13458. contextLabel |= bit << shift;
  13459. }
  13460. }
  13461. }
  13462. }
  13463. }
  13464. var pixel = decoder.readBit(contexts, contextLabel);
  13465. row[j] = pixel;
  13466. }
  13467. }
  13468. return bitmap;
  13469. }
  13470. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13471. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13472. if (templateIndex === 0) {
  13473. codingTemplate = codingTemplate.concat([at[0]]);
  13474. }
  13475. var codingTemplateLength = codingTemplate.length;
  13476. var codingTemplateX = new Int32Array(codingTemplateLength);
  13477. var codingTemplateY = new Int32Array(codingTemplateLength);
  13478. var k;
  13479. for (k = 0; k < codingTemplateLength; k++) {
  13480. codingTemplateX[k] = codingTemplate[k].x;
  13481. codingTemplateY[k] = codingTemplate[k].y;
  13482. }
  13483. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13484. if (templateIndex === 0) {
  13485. referenceTemplate = referenceTemplate.concat([at[1]]);
  13486. }
  13487. var referenceTemplateLength = referenceTemplate.length;
  13488. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13489. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13490. for (k = 0; k < referenceTemplateLength; k++) {
  13491. referenceTemplateX[k] = referenceTemplate[k].x;
  13492. referenceTemplateY[k] = referenceTemplate[k].y;
  13493. }
  13494. var referenceWidth = referenceBitmap[0].length;
  13495. var referenceHeight = referenceBitmap.length;
  13496. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13497. var bitmap = [];
  13498. var decoder = decodingContext.decoder;
  13499. var contexts = decodingContext.contextCache.getContexts('GR');
  13500. var ltp = 0;
  13501. for (var i = 0; i < height; i++) {
  13502. if (prediction) {
  13503. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13504. ltp ^= sltp;
  13505. if (ltp) {
  13506. error('JBIG2 error: prediction is not supported');
  13507. }
  13508. }
  13509. var row = new Uint8Array(width);
  13510. bitmap.push(row);
  13511. for (var j = 0; j < width; j++) {
  13512. var i0, j0;
  13513. var contextLabel = 0;
  13514. for (k = 0; k < codingTemplateLength; k++) {
  13515. i0 = i + codingTemplateY[k];
  13516. j0 = j + codingTemplateX[k];
  13517. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13518. contextLabel <<= 1;
  13519. } else
  13520. {
  13521. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13522. }
  13523. }
  13524. for (k = 0; k < referenceTemplateLength; k++) {
  13525. i0 = i + referenceTemplateY[k] + offsetY;
  13526. j0 = j + referenceTemplateX[k] + offsetX;
  13527. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13528. contextLabel <<= 1;
  13529. } else
  13530. {
  13531. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13532. }
  13533. }
  13534. var pixel = decoder.readBit(contexts, contextLabel);
  13535. row[j] = pixel;
  13536. }
  13537. }
  13538. return bitmap;
  13539. }
  13540. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13541. if (huffman) {
  13542. error('JBIG2 error: huffman is not supported');
  13543. }
  13544. var newSymbols = [];
  13545. var currentHeight = 0;
  13546. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13547. var decoder = decodingContext.decoder;
  13548. var contextCache = decodingContext.contextCache;
  13549. while (newSymbols.length < numberOfNewSymbols) {
  13550. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13551. currentHeight += deltaHeight;
  13552. var currentWidth = 0;
  13553. var totalWidth = 0;
  13554. while (true) {
  13555. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13556. if (deltaWidth === null) {
  13557. break;
  13558. }
  13559. currentWidth += deltaWidth;
  13560. totalWidth += currentWidth;
  13561. var bitmap;
  13562. if (refinement) {
  13563. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13564. if (numberOfInstances > 1) {
  13565. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13566. } else {
  13567. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13568. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13569. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13570. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13571. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13572. }
  13573. } else {
  13574. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13575. }
  13576. newSymbols.push(bitmap);
  13577. }
  13578. }
  13579. var exportedSymbols = [];
  13580. var flags = [], currentFlag = false;
  13581. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13582. while (flags.length < totalSymbolsLength) {
  13583. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13584. while (runLength--) {
  13585. flags.push(currentFlag);
  13586. }
  13587. currentFlag = !currentFlag;
  13588. }
  13589. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13590. if (flags[i]) {
  13591. exportedSymbols.push(symbols[i]);
  13592. }
  13593. }
  13594. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13595. if (flags[i]) {
  13596. exportedSymbols.push(newSymbols[j]);
  13597. }
  13598. }
  13599. return exportedSymbols;
  13600. }
  13601. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13602. if (huffman) {
  13603. error('JBIG2 error: huffman is not supported');
  13604. }
  13605. var bitmap = [];
  13606. var i, row;
  13607. for (i = 0; i < height; i++) {
  13608. row = new Uint8Array(width);
  13609. if (defaultPixelValue) {
  13610. for (var j = 0; j < width; j++) {
  13611. row[j] = defaultPixelValue;
  13612. }
  13613. }
  13614. bitmap.push(row);
  13615. }
  13616. var decoder = decodingContext.decoder;
  13617. var contextCache = decodingContext.contextCache;
  13618. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13619. var firstS = 0;
  13620. i = 0;
  13621. while (i < numberOfSymbolInstances) {
  13622. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13623. stripT += deltaT;
  13624. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13625. firstS += deltaFirstS;
  13626. var currentS = firstS;
  13627. do {
  13628. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13629. var t = stripSize * stripT + currentT;
  13630. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13631. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13632. var symbolBitmap = inputSymbols[symbolId];
  13633. var symbolWidth = symbolBitmap[0].length;
  13634. var symbolHeight = symbolBitmap.length;
  13635. if (applyRefinement) {
  13636. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13637. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13638. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13639. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13640. symbolWidth += rdw;
  13641. symbolHeight += rdh;
  13642. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13643. }
  13644. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13645. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13646. var s2, t2, symbolRow;
  13647. if (transposed) {
  13648. for (s2 = 0; s2 < symbolHeight; s2++) {
  13649. row = bitmap[offsetS + s2];
  13650. if (!row) {
  13651. continue;
  13652. }
  13653. symbolRow = symbolBitmap[s2];
  13654. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13655. switch (combinationOperator) {
  13656. case 0:
  13657. for (t2 = 0; t2 < maxWidth; t2++) {
  13658. row[offsetT + t2] |= symbolRow[t2];
  13659. }
  13660. break;
  13661. case 2:
  13662. for (t2 = 0; t2 < maxWidth; t2++) {
  13663. row[offsetT + t2] ^= symbolRow[t2];
  13664. }
  13665. break;
  13666. default:
  13667. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13668. }
  13669. }
  13670. currentS += symbolHeight - 1;
  13671. } else {
  13672. for (t2 = 0; t2 < symbolHeight; t2++) {
  13673. row = bitmap[offsetT + t2];
  13674. if (!row) {
  13675. continue;
  13676. }
  13677. symbolRow = symbolBitmap[t2];
  13678. switch (combinationOperator) {
  13679. case 0:
  13680. for (s2 = 0; s2 < symbolWidth; s2++) {
  13681. row[offsetS + s2] |= symbolRow[s2];
  13682. }
  13683. break;
  13684. case 2:
  13685. for (s2 = 0; s2 < symbolWidth; s2++) {
  13686. row[offsetS + s2] ^= symbolRow[s2];
  13687. }
  13688. break;
  13689. default:
  13690. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13691. }
  13692. }
  13693. currentS += symbolWidth - 1;
  13694. }
  13695. i++;
  13696. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13697. if (deltaS === null) {
  13698. break;
  13699. }
  13700. currentS += deltaS + dsOffset;
  13701. } while (true);
  13702. }
  13703. return bitmap;
  13704. }
  13705. function readSegmentHeader(data, start) {
  13706. var segmentHeader = {};
  13707. segmentHeader.number = readUint32(data, start);
  13708. var flags = data[start + 4];
  13709. var segmentType = flags & 0x3F;
  13710. if (!SegmentTypes[segmentType]) {
  13711. error('JBIG2 error: invalid segment type: ' + segmentType);
  13712. }
  13713. segmentHeader.type = segmentType;
  13714. segmentHeader.typeName = SegmentTypes[segmentType];
  13715. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13716. var pageAssociationFieldSize = !!(flags & 0x40);
  13717. var referredFlags = data[start + 5];
  13718. var referredToCount = referredFlags >> 5 & 7;
  13719. var retainBits = [referredFlags & 31];
  13720. var position = start + 6;
  13721. if (referredFlags === 7) {
  13722. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13723. position += 3;
  13724. var bytes = referredToCount + 7 >> 3;
  13725. retainBits[0] = data[position++];
  13726. while (--bytes > 0) {
  13727. retainBits.push(data[position++]);
  13728. }
  13729. } else if (referredFlags === 5 || referredFlags === 6) {
  13730. error('JBIG2 error: invalid referred-to flags');
  13731. }
  13732. segmentHeader.retainBits = retainBits;
  13733. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13734. var referredTo = [];
  13735. var i, ii;
  13736. for (i = 0; i < referredToCount; i++) {
  13737. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13738. referredTo.push(number);
  13739. position += referredToSegmentNumberSize;
  13740. }
  13741. segmentHeader.referredTo = referredTo;
  13742. if (!pageAssociationFieldSize) {
  13743. segmentHeader.pageAssociation = data[position++];
  13744. } else {
  13745. segmentHeader.pageAssociation = readUint32(data, position);
  13746. position += 4;
  13747. }
  13748. segmentHeader.length = readUint32(data, position);
  13749. position += 4;
  13750. if (segmentHeader.length === 0xFFFFFFFF) {
  13751. if (segmentType === 38) {
  13752. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13753. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13754. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13755. var searchPatternLength = 6;
  13756. var searchPattern = new Uint8Array(searchPatternLength);
  13757. if (!genericRegionMmr) {
  13758. searchPattern[0] = 0xFF;
  13759. searchPattern[1] = 0xAC;
  13760. }
  13761. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13762. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13763. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13764. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13765. for (i = position, ii = data.length; i < ii; i++) {
  13766. var j = 0;
  13767. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13768. j++;
  13769. }
  13770. if (j === searchPatternLength) {
  13771. segmentHeader.length = i + searchPatternLength;
  13772. break;
  13773. }
  13774. }
  13775. if (segmentHeader.length === 0xFFFFFFFF) {
  13776. error('JBIG2 error: segment end was not found');
  13777. }
  13778. } else {
  13779. error('JBIG2 error: invalid unknown segment length');
  13780. }
  13781. }
  13782. segmentHeader.headerEnd = position;
  13783. return segmentHeader;
  13784. }
  13785. function readSegments(header, data, start, end) {
  13786. var segments = [];
  13787. var position = start;
  13788. while (position < end) {
  13789. var segmentHeader = readSegmentHeader(data, position);
  13790. position = segmentHeader.headerEnd;
  13791. var segment = {
  13792. header: segmentHeader,
  13793. data: data
  13794. };
  13795. if (!header.randomAccess) {
  13796. segment.start = position;
  13797. position += segmentHeader.length;
  13798. segment.end = position;
  13799. }
  13800. segments.push(segment);
  13801. if (segmentHeader.type === 51) {
  13802. break;
  13803. }
  13804. }
  13805. if (header.randomAccess) {
  13806. for (var i = 0, ii = segments.length; i < ii; i++) {
  13807. segments[i].start = position;
  13808. position += segments[i].header.length;
  13809. segments[i].end = position;
  13810. }
  13811. }
  13812. return segments;
  13813. }
  13814. function readRegionSegmentInformation(data, start) {
  13815. return {
  13816. width: readUint32(data, start),
  13817. height: readUint32(data, start + 4),
  13818. x: readUint32(data, start + 8),
  13819. y: readUint32(data, start + 12),
  13820. combinationOperator: data[start + 16] & 7
  13821. };
  13822. }
  13823. var RegionSegmentInformationFieldLength = 17;
  13824. function processSegment(segment, visitor) {
  13825. var header = segment.header;
  13826. var data = segment.data, position = segment.start, end = segment.end;
  13827. var args, at, i, atLength;
  13828. switch (header.type) {
  13829. case 0:
  13830. var dictionary = {};
  13831. var dictionaryFlags = readUint16(data, position);
  13832. dictionary.huffman = !!(dictionaryFlags & 1);
  13833. dictionary.refinement = !!(dictionaryFlags & 2);
  13834. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13835. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13836. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13837. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13838. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13839. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13840. dictionary.template = dictionaryFlags >> 10 & 3;
  13841. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13842. position += 2;
  13843. if (!dictionary.huffman) {
  13844. atLength = dictionary.template === 0 ? 4 : 1;
  13845. at = [];
  13846. for (i = 0; i < atLength; i++) {
  13847. at.push({
  13848. x: readInt8(data, position),
  13849. y: readInt8(data, position + 1)
  13850. });
  13851. position += 2;
  13852. }
  13853. dictionary.at = at;
  13854. }
  13855. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13856. at = [];
  13857. for (i = 0; i < 2; i++) {
  13858. at.push({
  13859. x: readInt8(data, position),
  13860. y: readInt8(data, position + 1)
  13861. });
  13862. position += 2;
  13863. }
  13864. dictionary.refinementAt = at;
  13865. }
  13866. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13867. position += 4;
  13868. dictionary.numberOfNewSymbols = readUint32(data, position);
  13869. position += 4;
  13870. args = [
  13871. dictionary,
  13872. header.number,
  13873. header.referredTo,
  13874. data,
  13875. position,
  13876. end
  13877. ];
  13878. break;
  13879. case 6:
  13880. case 7:
  13881. var textRegion = {};
  13882. textRegion.info = readRegionSegmentInformation(data, position);
  13883. position += RegionSegmentInformationFieldLength;
  13884. var textRegionSegmentFlags = readUint16(data, position);
  13885. position += 2;
  13886. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  13887. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  13888. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  13889. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  13890. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  13891. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  13892. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  13893. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  13894. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  13895. if (textRegion.huffman) {
  13896. var textRegionHuffmanFlags = readUint16(data, position);
  13897. position += 2;
  13898. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  13899. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  13900. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  13901. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  13902. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  13903. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  13904. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  13905. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  13906. }
  13907. if (textRegion.refinement && !textRegion.refinementTemplate) {
  13908. at = [];
  13909. for (i = 0; i < 2; i++) {
  13910. at.push({
  13911. x: readInt8(data, position),
  13912. y: readInt8(data, position + 1)
  13913. });
  13914. position += 2;
  13915. }
  13916. textRegion.refinementAt = at;
  13917. }
  13918. textRegion.numberOfSymbolInstances = readUint32(data, position);
  13919. position += 4;
  13920. if (textRegion.huffman) {
  13921. error('JBIG2 error: huffman is not supported');
  13922. }
  13923. args = [
  13924. textRegion,
  13925. header.referredTo,
  13926. data,
  13927. position,
  13928. end
  13929. ];
  13930. break;
  13931. case 38:
  13932. case 39:
  13933. var genericRegion = {};
  13934. genericRegion.info = readRegionSegmentInformation(data, position);
  13935. position += RegionSegmentInformationFieldLength;
  13936. var genericRegionSegmentFlags = data[position++];
  13937. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  13938. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  13939. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  13940. if (!genericRegion.mmr) {
  13941. atLength = genericRegion.template === 0 ? 4 : 1;
  13942. at = [];
  13943. for (i = 0; i < atLength; i++) {
  13944. at.push({
  13945. x: readInt8(data, position),
  13946. y: readInt8(data, position + 1)
  13947. });
  13948. position += 2;
  13949. }
  13950. genericRegion.at = at;
  13951. }
  13952. args = [
  13953. genericRegion,
  13954. data,
  13955. position,
  13956. end
  13957. ];
  13958. break;
  13959. case 48:
  13960. var pageInfo = {
  13961. width: readUint32(data, position),
  13962. height: readUint32(data, position + 4),
  13963. resolutionX: readUint32(data, position + 8),
  13964. resolutionY: readUint32(data, position + 12)
  13965. };
  13966. if (pageInfo.height === 0xFFFFFFFF) {
  13967. delete pageInfo.height;
  13968. }
  13969. var pageSegmentFlags = data[position + 16];
  13970. var pageStripingInformation = readUint16(data, position + 17);
  13971. pageInfo.lossless = !!(pageSegmentFlags & 1);
  13972. pageInfo.refinement = !!(pageSegmentFlags & 2);
  13973. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  13974. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  13975. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  13976. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  13977. args = [pageInfo];
  13978. break;
  13979. case 49:
  13980. break;
  13981. case 50:
  13982. break;
  13983. case 51:
  13984. break;
  13985. case 62:
  13986. break;
  13987. default:
  13988. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  13989. }
  13990. var callbackName = 'on' + header.typeName;
  13991. if (callbackName in visitor) {
  13992. visitor[callbackName].apply(visitor, args);
  13993. }
  13994. }
  13995. function processSegments(segments, visitor) {
  13996. for (var i = 0, ii = segments.length; i < ii; i++) {
  13997. processSegment(segments[i], visitor);
  13998. }
  13999. }
  14000. function parseJbig2(data, start, end) {
  14001. var position = start;
  14002. 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) {
  14003. error('JBIG2 error: invalid header');
  14004. }
  14005. var header = {};
  14006. position += 8;
  14007. var flags = data[position++];
  14008. header.randomAccess = !(flags & 1);
  14009. if (!(flags & 2)) {
  14010. header.numberOfPages = readUint32(data, position);
  14011. position += 4;
  14012. }
  14013. var segments = readSegments(header, data, position, end);
  14014. error('Not implemented');
  14015. }
  14016. function parseJbig2Chunks(chunks) {
  14017. var visitor = new SimpleSegmentVisitor();
  14018. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14019. var chunk = chunks[i];
  14020. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14021. processSegments(segments, visitor);
  14022. }
  14023. return visitor.buffer;
  14024. }
  14025. function SimpleSegmentVisitor() {
  14026. }
  14027. SimpleSegmentVisitor.prototype = {
  14028. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14029. this.currentPageInfo = info;
  14030. var rowSize = info.width + 7 >> 3;
  14031. var buffer = new Uint8Array(rowSize * info.height);
  14032. if (info.defaultPixelValue) {
  14033. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14034. buffer[i] = 0xFF;
  14035. }
  14036. }
  14037. this.buffer = buffer;
  14038. },
  14039. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14040. var pageInfo = this.currentPageInfo;
  14041. var width = regionInfo.width, height = regionInfo.height;
  14042. var rowSize = pageInfo.width + 7 >> 3;
  14043. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14044. var buffer = this.buffer;
  14045. var mask0 = 128 >> (regionInfo.x & 7);
  14046. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14047. var i, j, mask, offset;
  14048. switch (combinationOperator) {
  14049. case 0:
  14050. for (i = 0; i < height; i++) {
  14051. mask = mask0;
  14052. offset = offset0;
  14053. for (j = 0; j < width; j++) {
  14054. if (bitmap[i][j]) {
  14055. buffer[offset] |= mask;
  14056. }
  14057. mask >>= 1;
  14058. if (!mask) {
  14059. mask = 128;
  14060. offset++;
  14061. }
  14062. }
  14063. offset0 += rowSize;
  14064. }
  14065. break;
  14066. case 2:
  14067. for (i = 0; i < height; i++) {
  14068. mask = mask0;
  14069. offset = offset0;
  14070. for (j = 0; j < width; j++) {
  14071. if (bitmap[i][j]) {
  14072. buffer[offset] ^= mask;
  14073. }
  14074. mask >>= 1;
  14075. if (!mask) {
  14076. mask = 128;
  14077. offset++;
  14078. }
  14079. }
  14080. offset0 += rowSize;
  14081. }
  14082. break;
  14083. default:
  14084. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14085. }
  14086. },
  14087. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14088. var regionInfo = region.info;
  14089. var decodingContext = new DecodingContext(data, start, end);
  14090. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14091. this.drawBitmap(regionInfo, bitmap);
  14092. },
  14093. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14094. this.onImmediateGenericRegion.apply(this, arguments);
  14095. },
  14096. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14097. var huffmanTables;
  14098. if (dictionary.huffman) {
  14099. error('JBIG2 error: huffman is not supported');
  14100. }
  14101. var symbols = this.symbols;
  14102. if (!symbols) {
  14103. this.symbols = symbols = {};
  14104. }
  14105. var inputSymbols = [];
  14106. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14107. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14108. }
  14109. var decodingContext = new DecodingContext(data, start, end);
  14110. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14111. },
  14112. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14113. var regionInfo = region.info;
  14114. var huffmanTables;
  14115. var symbols = this.symbols;
  14116. var inputSymbols = [];
  14117. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14118. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14119. }
  14120. var symbolCodeLength = log2(inputSymbols.length);
  14121. var decodingContext = new DecodingContext(data, start, end);
  14122. 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);
  14123. this.drawBitmap(regionInfo, bitmap);
  14124. },
  14125. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14126. this.onImmediateTextRegion.apply(this, arguments);
  14127. }
  14128. };
  14129. function Jbig2Image() {
  14130. }
  14131. Jbig2Image.prototype = {
  14132. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14133. return parseJbig2Chunks(chunks);
  14134. }
  14135. };
  14136. return Jbig2Image;
  14137. }();
  14138. exports.Jbig2Image = Jbig2Image;
  14139. }));
  14140. (function (root, factory) {
  14141. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14142. }(this, function (exports, sharedUtil) {
  14143. var error = sharedUtil.error;
  14144. var JpegImage = function JpegImageClosure() {
  14145. var dctZigZag = new Uint8Array([
  14146. 0,
  14147. 1,
  14148. 8,
  14149. 16,
  14150. 9,
  14151. 2,
  14152. 3,
  14153. 10,
  14154. 17,
  14155. 24,
  14156. 32,
  14157. 25,
  14158. 18,
  14159. 11,
  14160. 4,
  14161. 5,
  14162. 12,
  14163. 19,
  14164. 26,
  14165. 33,
  14166. 40,
  14167. 48,
  14168. 41,
  14169. 34,
  14170. 27,
  14171. 20,
  14172. 13,
  14173. 6,
  14174. 7,
  14175. 14,
  14176. 21,
  14177. 28,
  14178. 35,
  14179. 42,
  14180. 49,
  14181. 56,
  14182. 57,
  14183. 50,
  14184. 43,
  14185. 36,
  14186. 29,
  14187. 22,
  14188. 15,
  14189. 23,
  14190. 30,
  14191. 37,
  14192. 44,
  14193. 51,
  14194. 58,
  14195. 59,
  14196. 52,
  14197. 45,
  14198. 38,
  14199. 31,
  14200. 39,
  14201. 46,
  14202. 53,
  14203. 60,
  14204. 61,
  14205. 54,
  14206. 47,
  14207. 55,
  14208. 62,
  14209. 63
  14210. ]);
  14211. var dctCos1 = 4017;
  14212. var dctSin1 = 799;
  14213. var dctCos3 = 3406;
  14214. var dctSin3 = 2276;
  14215. var dctCos6 = 1567;
  14216. var dctSin6 = 3784;
  14217. var dctSqrt2 = 5793;
  14218. var dctSqrt1d2 = 2896;
  14219. function JpegImage() {
  14220. this.decodeTransform = null;
  14221. this.colorTransform = -1;
  14222. }
  14223. function buildHuffmanTable(codeLengths, values) {
  14224. var k = 0, code = [], i, j, length = 16;
  14225. while (length > 0 && !codeLengths[length - 1]) {
  14226. length--;
  14227. }
  14228. code.push({
  14229. children: [],
  14230. index: 0
  14231. });
  14232. var p = code[0], q;
  14233. for (i = 0; i < length; i++) {
  14234. for (j = 0; j < codeLengths[i]; j++) {
  14235. p = code.pop();
  14236. p.children[p.index] = values[k];
  14237. while (p.index > 0) {
  14238. p = code.pop();
  14239. }
  14240. p.index++;
  14241. code.push(p);
  14242. while (code.length <= i) {
  14243. code.push(q = {
  14244. children: [],
  14245. index: 0
  14246. });
  14247. p.children[p.index] = q.children;
  14248. p = q;
  14249. }
  14250. k++;
  14251. }
  14252. if (i + 1 < length) {
  14253. code.push(q = {
  14254. children: [],
  14255. index: 0
  14256. });
  14257. p.children[p.index] = q.children;
  14258. p = q;
  14259. }
  14260. }
  14261. return code[0].children;
  14262. }
  14263. function getBlockBufferOffset(component, row, col) {
  14264. return 64 * ((component.blocksPerLine + 1) * row + col);
  14265. }
  14266. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14267. var mcusPerLine = frame.mcusPerLine;
  14268. var progressive = frame.progressive;
  14269. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14270. function readBit() {
  14271. if (bitsCount > 0) {
  14272. bitsCount--;
  14273. return bitsData >> bitsCount & 1;
  14274. }
  14275. bitsData = data[offset++];
  14276. if (bitsData === 0xFF) {
  14277. var nextByte = data[offset++];
  14278. if (nextByte) {
  14279. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14280. }
  14281. }
  14282. bitsCount = 7;
  14283. return bitsData >>> 7;
  14284. }
  14285. function decodeHuffman(tree) {
  14286. var node = tree;
  14287. while (true) {
  14288. node = node[readBit()];
  14289. if (typeof node === 'number') {
  14290. return node;
  14291. }
  14292. if (typeof node !== 'object') {
  14293. error('JPEG error: invalid huffman sequence');
  14294. }
  14295. }
  14296. }
  14297. function receive(length) {
  14298. var n = 0;
  14299. while (length > 0) {
  14300. n = n << 1 | readBit();
  14301. length--;
  14302. }
  14303. return n;
  14304. }
  14305. function receiveAndExtend(length) {
  14306. if (length === 1) {
  14307. return readBit() === 1 ? 1 : -1;
  14308. }
  14309. var n = receive(length);
  14310. if (n >= 1 << length - 1) {
  14311. return n;
  14312. }
  14313. return n + (-1 << length) + 1;
  14314. }
  14315. function decodeBaseline(component, offset) {
  14316. var t = decodeHuffman(component.huffmanTableDC);
  14317. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14318. component.blockData[offset] = component.pred += diff;
  14319. var k = 1;
  14320. while (k < 64) {
  14321. var rs = decodeHuffman(component.huffmanTableAC);
  14322. var s = rs & 15, r = rs >> 4;
  14323. if (s === 0) {
  14324. if (r < 15) {
  14325. break;
  14326. }
  14327. k += 16;
  14328. continue;
  14329. }
  14330. k += r;
  14331. var z = dctZigZag[k];
  14332. component.blockData[offset + z] = receiveAndExtend(s);
  14333. k++;
  14334. }
  14335. }
  14336. function decodeDCFirst(component, offset) {
  14337. var t = decodeHuffman(component.huffmanTableDC);
  14338. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14339. component.blockData[offset] = component.pred += diff;
  14340. }
  14341. function decodeDCSuccessive(component, offset) {
  14342. component.blockData[offset] |= readBit() << successive;
  14343. }
  14344. var eobrun = 0;
  14345. function decodeACFirst(component, offset) {
  14346. if (eobrun > 0) {
  14347. eobrun--;
  14348. return;
  14349. }
  14350. var k = spectralStart, e = spectralEnd;
  14351. while (k <= e) {
  14352. var rs = decodeHuffman(component.huffmanTableAC);
  14353. var s = rs & 15, r = rs >> 4;
  14354. if (s === 0) {
  14355. if (r < 15) {
  14356. eobrun = receive(r) + (1 << r) - 1;
  14357. break;
  14358. }
  14359. k += 16;
  14360. continue;
  14361. }
  14362. k += r;
  14363. var z = dctZigZag[k];
  14364. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14365. k++;
  14366. }
  14367. }
  14368. var successiveACState = 0, successiveACNextValue;
  14369. function decodeACSuccessive(component, offset) {
  14370. var k = spectralStart;
  14371. var e = spectralEnd;
  14372. var r = 0;
  14373. var s;
  14374. var rs;
  14375. while (k <= e) {
  14376. var z = dctZigZag[k];
  14377. switch (successiveACState) {
  14378. case 0:
  14379. rs = decodeHuffman(component.huffmanTableAC);
  14380. s = rs & 15;
  14381. r = rs >> 4;
  14382. if (s === 0) {
  14383. if (r < 15) {
  14384. eobrun = receive(r) + (1 << r);
  14385. successiveACState = 4;
  14386. } else {
  14387. r = 16;
  14388. successiveACState = 1;
  14389. }
  14390. } else {
  14391. if (s !== 1) {
  14392. error('JPEG error: invalid ACn encoding');
  14393. }
  14394. successiveACNextValue = receiveAndExtend(s);
  14395. successiveACState = r ? 2 : 3;
  14396. }
  14397. continue;
  14398. case 1:
  14399. case 2:
  14400. if (component.blockData[offset + z]) {
  14401. component.blockData[offset + z] += readBit() << successive;
  14402. } else {
  14403. r--;
  14404. if (r === 0) {
  14405. successiveACState = successiveACState === 2 ? 3 : 0;
  14406. }
  14407. }
  14408. break;
  14409. case 3:
  14410. if (component.blockData[offset + z]) {
  14411. component.blockData[offset + z] += readBit() << successive;
  14412. } else {
  14413. component.blockData[offset + z] = successiveACNextValue << successive;
  14414. successiveACState = 0;
  14415. }
  14416. break;
  14417. case 4:
  14418. if (component.blockData[offset + z]) {
  14419. component.blockData[offset + z] += readBit() << successive;
  14420. }
  14421. break;
  14422. }
  14423. k++;
  14424. }
  14425. if (successiveACState === 4) {
  14426. eobrun--;
  14427. if (eobrun === 0) {
  14428. successiveACState = 0;
  14429. }
  14430. }
  14431. }
  14432. function decodeMcu(component, decode, mcu, row, col) {
  14433. var mcuRow = mcu / mcusPerLine | 0;
  14434. var mcuCol = mcu % mcusPerLine;
  14435. var blockRow = mcuRow * component.v + row;
  14436. var blockCol = mcuCol * component.h + col;
  14437. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14438. decode(component, offset);
  14439. }
  14440. function decodeBlock(component, decode, mcu) {
  14441. var blockRow = mcu / component.blocksPerLine | 0;
  14442. var blockCol = mcu % component.blocksPerLine;
  14443. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14444. decode(component, offset);
  14445. }
  14446. var componentsLength = components.length;
  14447. var component, i, j, k, n;
  14448. var decodeFn;
  14449. if (progressive) {
  14450. if (spectralStart === 0) {
  14451. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14452. } else {
  14453. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14454. }
  14455. } else {
  14456. decodeFn = decodeBaseline;
  14457. }
  14458. var mcu = 0, marker;
  14459. var mcuExpected;
  14460. if (componentsLength === 1) {
  14461. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14462. } else {
  14463. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14464. }
  14465. if (!resetInterval) {
  14466. resetInterval = mcuExpected;
  14467. }
  14468. var h, v;
  14469. while (mcu < mcuExpected) {
  14470. for (i = 0; i < componentsLength; i++) {
  14471. components[i].pred = 0;
  14472. }
  14473. eobrun = 0;
  14474. if (componentsLength === 1) {
  14475. component = components[0];
  14476. for (n = 0; n < resetInterval; n++) {
  14477. decodeBlock(component, decodeFn, mcu);
  14478. mcu++;
  14479. }
  14480. } else {
  14481. for (n = 0; n < resetInterval; n++) {
  14482. for (i = 0; i < componentsLength; i++) {
  14483. component = components[i];
  14484. h = component.h;
  14485. v = component.v;
  14486. for (j = 0; j < v; j++) {
  14487. for (k = 0; k < h; k++) {
  14488. decodeMcu(component, decodeFn, mcu, j, k);
  14489. }
  14490. }
  14491. }
  14492. mcu++;
  14493. }
  14494. }
  14495. bitsCount = 0;
  14496. marker = data[offset] << 8 | data[offset + 1];
  14497. while (data[offset] === 0x00 && offset < data.length - 1) {
  14498. offset++;
  14499. marker = data[offset] << 8 | data[offset + 1];
  14500. }
  14501. if (marker <= 0xFF00) {
  14502. error('JPEG error: marker was not found');
  14503. }
  14504. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14505. offset += 2;
  14506. } else {
  14507. break;
  14508. }
  14509. }
  14510. return offset - startOffset;
  14511. }
  14512. function quantizeAndInverse(component, blockBufferOffset, p) {
  14513. var qt = component.quantizationTable, blockData = component.blockData;
  14514. var v0, v1, v2, v3, v4, v5, v6, v7;
  14515. var p0, p1, p2, p3, p4, p5, p6, p7;
  14516. var t;
  14517. if (!qt) {
  14518. error('JPEG error: missing required Quantization Table.');
  14519. }
  14520. for (var row = 0; row < 64; row += 8) {
  14521. p0 = blockData[blockBufferOffset + row];
  14522. p1 = blockData[blockBufferOffset + row + 1];
  14523. p2 = blockData[blockBufferOffset + row + 2];
  14524. p3 = blockData[blockBufferOffset + row + 3];
  14525. p4 = blockData[blockBufferOffset + row + 4];
  14526. p5 = blockData[blockBufferOffset + row + 5];
  14527. p6 = blockData[blockBufferOffset + row + 6];
  14528. p7 = blockData[blockBufferOffset + row + 7];
  14529. p0 *= qt[row];
  14530. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14531. t = dctSqrt2 * p0 + 512 >> 10;
  14532. p[row] = t;
  14533. p[row + 1] = t;
  14534. p[row + 2] = t;
  14535. p[row + 3] = t;
  14536. p[row + 4] = t;
  14537. p[row + 5] = t;
  14538. p[row + 6] = t;
  14539. p[row + 7] = t;
  14540. continue;
  14541. }
  14542. p1 *= qt[row + 1];
  14543. p2 *= qt[row + 2];
  14544. p3 *= qt[row + 3];
  14545. p4 *= qt[row + 4];
  14546. p5 *= qt[row + 5];
  14547. p6 *= qt[row + 6];
  14548. p7 *= qt[row + 7];
  14549. v0 = dctSqrt2 * p0 + 128 >> 8;
  14550. v1 = dctSqrt2 * p4 + 128 >> 8;
  14551. v2 = p2;
  14552. v3 = p6;
  14553. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14554. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14555. v5 = p3 << 4;
  14556. v6 = p5 << 4;
  14557. v0 = v0 + v1 + 1 >> 1;
  14558. v1 = v0 - v1;
  14559. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14560. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14561. v3 = t;
  14562. v4 = v4 + v6 + 1 >> 1;
  14563. v6 = v4 - v6;
  14564. v7 = v7 + v5 + 1 >> 1;
  14565. v5 = v7 - v5;
  14566. v0 = v0 + v3 + 1 >> 1;
  14567. v3 = v0 - v3;
  14568. v1 = v1 + v2 + 1 >> 1;
  14569. v2 = v1 - v2;
  14570. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14571. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14572. v7 = t;
  14573. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14574. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14575. v6 = t;
  14576. p[row] = v0 + v7;
  14577. p[row + 7] = v0 - v7;
  14578. p[row + 1] = v1 + v6;
  14579. p[row + 6] = v1 - v6;
  14580. p[row + 2] = v2 + v5;
  14581. p[row + 5] = v2 - v5;
  14582. p[row + 3] = v3 + v4;
  14583. p[row + 4] = v3 - v4;
  14584. }
  14585. for (var col = 0; col < 8; ++col) {
  14586. p0 = p[col];
  14587. p1 = p[col + 8];
  14588. p2 = p[col + 16];
  14589. p3 = p[col + 24];
  14590. p4 = p[col + 32];
  14591. p5 = p[col + 40];
  14592. p6 = p[col + 48];
  14593. p7 = p[col + 56];
  14594. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14595. t = dctSqrt2 * p0 + 8192 >> 14;
  14596. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14597. blockData[blockBufferOffset + col] = t;
  14598. blockData[blockBufferOffset + col + 8] = t;
  14599. blockData[blockBufferOffset + col + 16] = t;
  14600. blockData[blockBufferOffset + col + 24] = t;
  14601. blockData[blockBufferOffset + col + 32] = t;
  14602. blockData[blockBufferOffset + col + 40] = t;
  14603. blockData[blockBufferOffset + col + 48] = t;
  14604. blockData[blockBufferOffset + col + 56] = t;
  14605. continue;
  14606. }
  14607. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14608. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14609. v2 = p2;
  14610. v3 = p6;
  14611. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14612. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14613. v5 = p3;
  14614. v6 = p5;
  14615. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14616. v1 = v0 - v1;
  14617. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14618. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14619. v3 = t;
  14620. v4 = v4 + v6 + 1 >> 1;
  14621. v6 = v4 - v6;
  14622. v7 = v7 + v5 + 1 >> 1;
  14623. v5 = v7 - v5;
  14624. v0 = v0 + v3 + 1 >> 1;
  14625. v3 = v0 - v3;
  14626. v1 = v1 + v2 + 1 >> 1;
  14627. v2 = v1 - v2;
  14628. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14629. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14630. v7 = t;
  14631. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14632. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14633. v6 = t;
  14634. p0 = v0 + v7;
  14635. p7 = v0 - v7;
  14636. p1 = v1 + v6;
  14637. p6 = v1 - v6;
  14638. p2 = v2 + v5;
  14639. p5 = v2 - v5;
  14640. p3 = v3 + v4;
  14641. p4 = v3 - v4;
  14642. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14643. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14644. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14645. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14646. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14647. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14648. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14649. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14650. blockData[blockBufferOffset + col] = p0;
  14651. blockData[blockBufferOffset + col + 8] = p1;
  14652. blockData[blockBufferOffset + col + 16] = p2;
  14653. blockData[blockBufferOffset + col + 24] = p3;
  14654. blockData[blockBufferOffset + col + 32] = p4;
  14655. blockData[blockBufferOffset + col + 40] = p5;
  14656. blockData[blockBufferOffset + col + 48] = p6;
  14657. blockData[blockBufferOffset + col + 56] = p7;
  14658. }
  14659. }
  14660. function buildComponentData(frame, component) {
  14661. var blocksPerLine = component.blocksPerLine;
  14662. var blocksPerColumn = component.blocksPerColumn;
  14663. var computationBuffer = new Int16Array(64);
  14664. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14665. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14666. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14667. quantizeAndInverse(component, offset, computationBuffer);
  14668. }
  14669. }
  14670. return component.blockData;
  14671. }
  14672. function clamp0to255(a) {
  14673. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14674. }
  14675. JpegImage.prototype = {
  14676. parse: function parse(data) {
  14677. function readUint16() {
  14678. var value = data[offset] << 8 | data[offset + 1];
  14679. offset += 2;
  14680. return value;
  14681. }
  14682. function readDataBlock() {
  14683. var length = readUint16();
  14684. var array = data.subarray(offset, offset + length - 2);
  14685. offset += array.length;
  14686. return array;
  14687. }
  14688. function prepareComponents(frame) {
  14689. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14690. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14691. for (var i = 0; i < frame.components.length; i++) {
  14692. component = frame.components[i];
  14693. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14694. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14695. var blocksPerLineForMcu = mcusPerLine * component.h;
  14696. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14697. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14698. component.blockData = new Int16Array(blocksBufferSize);
  14699. component.blocksPerLine = blocksPerLine;
  14700. component.blocksPerColumn = blocksPerColumn;
  14701. }
  14702. frame.mcusPerLine = mcusPerLine;
  14703. frame.mcusPerColumn = mcusPerColumn;
  14704. }
  14705. var offset = 0;
  14706. var jfif = null;
  14707. var adobe = null;
  14708. var frame, resetInterval;
  14709. var quantizationTables = [];
  14710. var huffmanTablesAC = [], huffmanTablesDC = [];
  14711. var fileMarker = readUint16();
  14712. if (fileMarker !== 0xFFD8) {
  14713. error('JPEG error: SOI not found');
  14714. }
  14715. fileMarker = readUint16();
  14716. while (fileMarker !== 0xFFD9) {
  14717. var i, j, l;
  14718. switch (fileMarker) {
  14719. case 0xFFE0:
  14720. case 0xFFE1:
  14721. case 0xFFE2:
  14722. case 0xFFE3:
  14723. case 0xFFE4:
  14724. case 0xFFE5:
  14725. case 0xFFE6:
  14726. case 0xFFE7:
  14727. case 0xFFE8:
  14728. case 0xFFE9:
  14729. case 0xFFEA:
  14730. case 0xFFEB:
  14731. case 0xFFEC:
  14732. case 0xFFED:
  14733. case 0xFFEE:
  14734. case 0xFFEF:
  14735. case 0xFFFE:
  14736. var appData = readDataBlock();
  14737. if (fileMarker === 0xFFE0) {
  14738. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14739. jfif = {
  14740. version: {
  14741. major: appData[5],
  14742. minor: appData[6]
  14743. },
  14744. densityUnits: appData[7],
  14745. xDensity: appData[8] << 8 | appData[9],
  14746. yDensity: appData[10] << 8 | appData[11],
  14747. thumbWidth: appData[12],
  14748. thumbHeight: appData[13],
  14749. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14750. };
  14751. }
  14752. }
  14753. if (fileMarker === 0xFFEE) {
  14754. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14755. adobe = {
  14756. version: appData[5] << 8 | appData[6],
  14757. flags0: appData[7] << 8 | appData[8],
  14758. flags1: appData[9] << 8 | appData[10],
  14759. transformCode: appData[11]
  14760. };
  14761. }
  14762. }
  14763. break;
  14764. case 0xFFDB:
  14765. var quantizationTablesLength = readUint16();
  14766. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14767. var z;
  14768. while (offset < quantizationTablesEnd) {
  14769. var quantizationTableSpec = data[offset++];
  14770. var tableData = new Uint16Array(64);
  14771. if (quantizationTableSpec >> 4 === 0) {
  14772. for (j = 0; j < 64; j++) {
  14773. z = dctZigZag[j];
  14774. tableData[z] = data[offset++];
  14775. }
  14776. } else if (quantizationTableSpec >> 4 === 1) {
  14777. for (j = 0; j < 64; j++) {
  14778. z = dctZigZag[j];
  14779. tableData[z] = readUint16();
  14780. }
  14781. } else {
  14782. error('JPEG error: DQT - invalid table spec');
  14783. }
  14784. quantizationTables[quantizationTableSpec & 15] = tableData;
  14785. }
  14786. break;
  14787. case 0xFFC0:
  14788. case 0xFFC1:
  14789. case 0xFFC2:
  14790. if (frame) {
  14791. error('JPEG error: Only single frame JPEGs supported');
  14792. }
  14793. readUint16();
  14794. frame = {};
  14795. frame.extended = fileMarker === 0xFFC1;
  14796. frame.progressive = fileMarker === 0xFFC2;
  14797. frame.precision = data[offset++];
  14798. frame.scanLines = readUint16();
  14799. frame.samplesPerLine = readUint16();
  14800. frame.components = [];
  14801. frame.componentIds = {};
  14802. var componentsCount = data[offset++], componentId;
  14803. var maxH = 0, maxV = 0;
  14804. for (i = 0; i < componentsCount; i++) {
  14805. componentId = data[offset];
  14806. var h = data[offset + 1] >> 4;
  14807. var v = data[offset + 1] & 15;
  14808. if (maxH < h) {
  14809. maxH = h;
  14810. }
  14811. if (maxV < v) {
  14812. maxV = v;
  14813. }
  14814. var qId = data[offset + 2];
  14815. l = frame.components.push({
  14816. h: h,
  14817. v: v,
  14818. quantizationId: qId,
  14819. quantizationTable: null
  14820. });
  14821. frame.componentIds[componentId] = l - 1;
  14822. offset += 3;
  14823. }
  14824. frame.maxH = maxH;
  14825. frame.maxV = maxV;
  14826. prepareComponents(frame);
  14827. break;
  14828. case 0xFFC4:
  14829. var huffmanLength = readUint16();
  14830. for (i = 2; i < huffmanLength;) {
  14831. var huffmanTableSpec = data[offset++];
  14832. var codeLengths = new Uint8Array(16);
  14833. var codeLengthSum = 0;
  14834. for (j = 0; j < 16; j++, offset++) {
  14835. codeLengthSum += codeLengths[j] = data[offset];
  14836. }
  14837. var huffmanValues = new Uint8Array(codeLengthSum);
  14838. for (j = 0; j < codeLengthSum; j++, offset++) {
  14839. huffmanValues[j] = data[offset];
  14840. }
  14841. i += 17 + codeLengthSum;
  14842. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14843. }
  14844. break;
  14845. case 0xFFDD:
  14846. readUint16();
  14847. resetInterval = readUint16();
  14848. break;
  14849. case 0xFFDA:
  14850. var scanLength = readUint16();
  14851. var selectorsCount = data[offset++];
  14852. var components = [], component;
  14853. for (i = 0; i < selectorsCount; i++) {
  14854. var componentIndex = frame.componentIds[data[offset++]];
  14855. component = frame.components[componentIndex];
  14856. var tableSpec = data[offset++];
  14857. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14858. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14859. components.push(component);
  14860. }
  14861. var spectralStart = data[offset++];
  14862. var spectralEnd = data[offset++];
  14863. var successiveApproximation = data[offset++];
  14864. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14865. offset += processed;
  14866. break;
  14867. case 0xFFFF:
  14868. if (data[offset] !== 0xFF) {
  14869. offset--;
  14870. }
  14871. break;
  14872. default:
  14873. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14874. offset -= 3;
  14875. break;
  14876. }
  14877. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14878. }
  14879. fileMarker = readUint16();
  14880. }
  14881. this.width = frame.samplesPerLine;
  14882. this.height = frame.scanLines;
  14883. this.jfif = jfif;
  14884. this.adobe = adobe;
  14885. this.components = [];
  14886. for (i = 0; i < frame.components.length; i++) {
  14887. component = frame.components[i];
  14888. var quantizationTable = quantizationTables[component.quantizationId];
  14889. if (quantizationTable) {
  14890. component.quantizationTable = quantizationTable;
  14891. }
  14892. this.components.push({
  14893. output: buildComponentData(frame, component),
  14894. scaleX: component.h / frame.maxH,
  14895. scaleY: component.v / frame.maxV,
  14896. blocksPerLine: component.blocksPerLine,
  14897. blocksPerColumn: component.blocksPerColumn
  14898. });
  14899. }
  14900. this.numComponents = this.components.length;
  14901. },
  14902. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  14903. var scaleX = this.width / width, scaleY = this.height / height;
  14904. var component, componentScaleX, componentScaleY, blocksPerScanline;
  14905. var x, y, i, j, k;
  14906. var index;
  14907. var offset = 0;
  14908. var output;
  14909. var numComponents = this.components.length;
  14910. var dataLength = width * height * numComponents;
  14911. var data = new Uint8Array(dataLength);
  14912. var xScaleBlockOffset = new Uint32Array(width);
  14913. var mask3LSB = 0xfffffff8;
  14914. for (i = 0; i < numComponents; i++) {
  14915. component = this.components[i];
  14916. componentScaleX = component.scaleX * scaleX;
  14917. componentScaleY = component.scaleY * scaleY;
  14918. offset = i;
  14919. output = component.output;
  14920. blocksPerScanline = component.blocksPerLine + 1 << 3;
  14921. for (x = 0; x < width; x++) {
  14922. j = 0 | x * componentScaleX;
  14923. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  14924. }
  14925. for (y = 0; y < height; y++) {
  14926. j = 0 | y * componentScaleY;
  14927. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  14928. for (x = 0; x < width; x++) {
  14929. data[offset] = output[index + xScaleBlockOffset[x]];
  14930. offset += numComponents;
  14931. }
  14932. }
  14933. }
  14934. var transform = this.decodeTransform;
  14935. if (transform) {
  14936. for (i = 0; i < dataLength;) {
  14937. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  14938. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  14939. }
  14940. }
  14941. }
  14942. return data;
  14943. },
  14944. _isColorConversionNeeded: function isColorConversionNeeded() {
  14945. if (this.adobe && this.adobe.transformCode) {
  14946. return true;
  14947. } else if (this.numComponents === 3) {
  14948. if (!this.adobe && this.colorTransform === 0) {
  14949. return false;
  14950. }
  14951. return true;
  14952. } else {
  14953. if (!this.adobe && this.colorTransform === 1) {
  14954. return true;
  14955. }
  14956. return false;
  14957. }
  14958. },
  14959. _convertYccToRgb: function convertYccToRgb(data) {
  14960. var Y, Cb, Cr;
  14961. for (var i = 0, length = data.length; i < length; i += 3) {
  14962. Y = data[i];
  14963. Cb = data[i + 1];
  14964. Cr = data[i + 2];
  14965. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  14966. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  14967. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  14968. }
  14969. return data;
  14970. },
  14971. _convertYcckToRgb: function convertYcckToRgb(data) {
  14972. var Y, Cb, Cr, k;
  14973. var offset = 0;
  14974. for (var i = 0, length = data.length; i < length; i += 4) {
  14975. Y = data[i];
  14976. Cb = data[i + 1];
  14977. Cr = data[i + 2];
  14978. k = data[i + 3];
  14979. 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);
  14980. 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);
  14981. 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);
  14982. data[offset++] = clamp0to255(r);
  14983. data[offset++] = clamp0to255(g);
  14984. data[offset++] = clamp0to255(b);
  14985. }
  14986. return data;
  14987. },
  14988. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  14989. var Y, Cb, Cr;
  14990. for (var i = 0, length = data.length; i < length; i += 4) {
  14991. Y = data[i];
  14992. Cb = data[i + 1];
  14993. Cr = data[i + 2];
  14994. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  14995. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  14996. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  14997. }
  14998. return data;
  14999. },
  15000. _convertCmykToRgb: function convertCmykToRgb(data) {
  15001. var c, m, y, k;
  15002. var offset = 0;
  15003. var min = -255 * 255 * 255;
  15004. var scale = 1 / 255 / 255;
  15005. for (var i = 0, length = data.length; i < length; i += 4) {
  15006. c = data[i];
  15007. m = data[i + 1];
  15008. y = data[i + 2];
  15009. k = data[i + 3];
  15010. 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);
  15011. 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);
  15012. 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);
  15013. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15014. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15015. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15016. }
  15017. return data;
  15018. },
  15019. getData: function getData(width, height, forceRGBoutput) {
  15020. if (this.numComponents > 4) {
  15021. error('JPEG error: Unsupported color mode');
  15022. }
  15023. var data = this._getLinearizedBlockData(width, height);
  15024. if (this.numComponents === 1 && forceRGBoutput) {
  15025. var dataLength = data.length;
  15026. var rgbData = new Uint8Array(dataLength * 3);
  15027. var offset = 0;
  15028. for (var i = 0; i < dataLength; i++) {
  15029. var grayColor = data[i];
  15030. rgbData[offset++] = grayColor;
  15031. rgbData[offset++] = grayColor;
  15032. rgbData[offset++] = grayColor;
  15033. }
  15034. return rgbData;
  15035. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15036. return this._convertYccToRgb(data);
  15037. } else if (this.numComponents === 4) {
  15038. if (this._isColorConversionNeeded()) {
  15039. if (forceRGBoutput) {
  15040. return this._convertYcckToRgb(data);
  15041. } else {
  15042. return this._convertYcckToCmyk(data);
  15043. }
  15044. } else if (forceRGBoutput) {
  15045. return this._convertCmykToRgb(data);
  15046. }
  15047. }
  15048. return data;
  15049. }
  15050. };
  15051. return JpegImage;
  15052. }();
  15053. exports.JpegImage = JpegImage;
  15054. }));
  15055. (function (root, factory) {
  15056. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15057. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15058. var info = sharedUtil.info;
  15059. var warn = sharedUtil.warn;
  15060. var error = sharedUtil.error;
  15061. var log2 = sharedUtil.log2;
  15062. var readUint16 = sharedUtil.readUint16;
  15063. var readUint32 = sharedUtil.readUint32;
  15064. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15065. var JpxImage = function JpxImageClosure() {
  15066. var SubbandsGainLog2 = {
  15067. 'LL': 0,
  15068. 'LH': 1,
  15069. 'HL': 1,
  15070. 'HH': 2
  15071. };
  15072. function JpxImage() {
  15073. this.failOnCorruptedImage = false;
  15074. }
  15075. JpxImage.prototype = {
  15076. parse: function JpxImage_parse(data) {
  15077. var head = readUint16(data, 0);
  15078. if (head === 0xFF4F) {
  15079. this.parseCodestream(data, 0, data.length);
  15080. return;
  15081. }
  15082. var position = 0, length = data.length;
  15083. while (position < length) {
  15084. var headerSize = 8;
  15085. var lbox = readUint32(data, position);
  15086. var tbox = readUint32(data, position + 4);
  15087. position += headerSize;
  15088. if (lbox === 1) {
  15089. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15090. position += 8;
  15091. headerSize += 8;
  15092. }
  15093. if (lbox === 0) {
  15094. lbox = length - position + headerSize;
  15095. }
  15096. if (lbox < headerSize) {
  15097. error('JPX Error: Invalid box field size');
  15098. }
  15099. var dataLength = lbox - headerSize;
  15100. var jumpDataLength = true;
  15101. switch (tbox) {
  15102. case 0x6A703268:
  15103. jumpDataLength = false;
  15104. break;
  15105. case 0x636F6C72:
  15106. var method = data[position];
  15107. if (method === 1) {
  15108. var colorspace = readUint32(data, position + 3);
  15109. switch (colorspace) {
  15110. case 16:
  15111. case 17:
  15112. case 18:
  15113. break;
  15114. default:
  15115. warn('Unknown colorspace ' + colorspace);
  15116. break;
  15117. }
  15118. } else if (method === 2) {
  15119. info('ICC profile not supported');
  15120. }
  15121. break;
  15122. case 0x6A703263:
  15123. this.parseCodestream(data, position, position + dataLength);
  15124. break;
  15125. case 0x6A502020:
  15126. if (0x0d0a870a !== readUint32(data, position)) {
  15127. warn('Invalid JP2 signature');
  15128. }
  15129. break;
  15130. case 0x6A501A1A:
  15131. case 0x66747970:
  15132. case 0x72726571:
  15133. case 0x72657320:
  15134. case 0x69686472:
  15135. break;
  15136. default:
  15137. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15138. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15139. break;
  15140. }
  15141. if (jumpDataLength) {
  15142. position += dataLength;
  15143. }
  15144. }
  15145. },
  15146. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15147. var newByte = stream.getByte();
  15148. while (newByte >= 0) {
  15149. var oldByte = newByte;
  15150. newByte = stream.getByte();
  15151. var code = oldByte << 8 | newByte;
  15152. if (code === 0xFF51) {
  15153. stream.skip(4);
  15154. var Xsiz = stream.getInt32() >>> 0;
  15155. var Ysiz = stream.getInt32() >>> 0;
  15156. var XOsiz = stream.getInt32() >>> 0;
  15157. var YOsiz = stream.getInt32() >>> 0;
  15158. stream.skip(16);
  15159. var Csiz = stream.getUint16();
  15160. this.width = Xsiz - XOsiz;
  15161. this.height = Ysiz - YOsiz;
  15162. this.componentsCount = Csiz;
  15163. this.bitsPerComponent = 8;
  15164. return;
  15165. }
  15166. }
  15167. error('JPX Error: No size marker found in JPX stream');
  15168. },
  15169. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15170. var context = {};
  15171. var doNotRecover = false;
  15172. try {
  15173. var position = start;
  15174. while (position + 1 < end) {
  15175. var code = readUint16(data, position);
  15176. position += 2;
  15177. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15178. switch (code) {
  15179. case 0xFF4F:
  15180. context.mainHeader = true;
  15181. break;
  15182. case 0xFFD9:
  15183. break;
  15184. case 0xFF51:
  15185. length = readUint16(data, position);
  15186. var siz = {};
  15187. siz.Xsiz = readUint32(data, position + 4);
  15188. siz.Ysiz = readUint32(data, position + 8);
  15189. siz.XOsiz = readUint32(data, position + 12);
  15190. siz.YOsiz = readUint32(data, position + 16);
  15191. siz.XTsiz = readUint32(data, position + 20);
  15192. siz.YTsiz = readUint32(data, position + 24);
  15193. siz.XTOsiz = readUint32(data, position + 28);
  15194. siz.YTOsiz = readUint32(data, position + 32);
  15195. var componentsCount = readUint16(data, position + 36);
  15196. siz.Csiz = componentsCount;
  15197. var components = [];
  15198. j = position + 38;
  15199. for (var i = 0; i < componentsCount; i++) {
  15200. var component = {
  15201. precision: (data[j] & 0x7F) + 1,
  15202. isSigned: !!(data[j] & 0x80),
  15203. XRsiz: data[j + 1],
  15204. YRsiz: data[j + 1]
  15205. };
  15206. calculateComponentDimensions(component, siz);
  15207. components.push(component);
  15208. }
  15209. context.SIZ = siz;
  15210. context.components = components;
  15211. calculateTileGrids(context, components);
  15212. context.QCC = [];
  15213. context.COC = [];
  15214. break;
  15215. case 0xFF5C:
  15216. length = readUint16(data, position);
  15217. var qcd = {};
  15218. j = position + 2;
  15219. sqcd = data[j++];
  15220. switch (sqcd & 0x1F) {
  15221. case 0:
  15222. spqcdSize = 8;
  15223. scalarExpounded = true;
  15224. break;
  15225. case 1:
  15226. spqcdSize = 16;
  15227. scalarExpounded = false;
  15228. break;
  15229. case 2:
  15230. spqcdSize = 16;
  15231. scalarExpounded = true;
  15232. break;
  15233. default:
  15234. throw new Error('Invalid SQcd value ' + sqcd);
  15235. }
  15236. qcd.noQuantization = spqcdSize === 8;
  15237. qcd.scalarExpounded = scalarExpounded;
  15238. qcd.guardBits = sqcd >> 5;
  15239. spqcds = [];
  15240. while (j < length + position) {
  15241. var spqcd = {};
  15242. if (spqcdSize === 8) {
  15243. spqcd.epsilon = data[j++] >> 3;
  15244. spqcd.mu = 0;
  15245. } else {
  15246. spqcd.epsilon = data[j] >> 3;
  15247. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15248. j += 2;
  15249. }
  15250. spqcds.push(spqcd);
  15251. }
  15252. qcd.SPqcds = spqcds;
  15253. if (context.mainHeader) {
  15254. context.QCD = qcd;
  15255. } else {
  15256. context.currentTile.QCD = qcd;
  15257. context.currentTile.QCC = [];
  15258. }
  15259. break;
  15260. case 0xFF5D:
  15261. length = readUint16(data, position);
  15262. var qcc = {};
  15263. j = position + 2;
  15264. var cqcc;
  15265. if (context.SIZ.Csiz < 257) {
  15266. cqcc = data[j++];
  15267. } else {
  15268. cqcc = readUint16(data, j);
  15269. j += 2;
  15270. }
  15271. sqcd = data[j++];
  15272. switch (sqcd & 0x1F) {
  15273. case 0:
  15274. spqcdSize = 8;
  15275. scalarExpounded = true;
  15276. break;
  15277. case 1:
  15278. spqcdSize = 16;
  15279. scalarExpounded = false;
  15280. break;
  15281. case 2:
  15282. spqcdSize = 16;
  15283. scalarExpounded = true;
  15284. break;
  15285. default:
  15286. throw new Error('Invalid SQcd value ' + sqcd);
  15287. }
  15288. qcc.noQuantization = spqcdSize === 8;
  15289. qcc.scalarExpounded = scalarExpounded;
  15290. qcc.guardBits = sqcd >> 5;
  15291. spqcds = [];
  15292. while (j < length + position) {
  15293. spqcd = {};
  15294. if (spqcdSize === 8) {
  15295. spqcd.epsilon = data[j++] >> 3;
  15296. spqcd.mu = 0;
  15297. } else {
  15298. spqcd.epsilon = data[j] >> 3;
  15299. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15300. j += 2;
  15301. }
  15302. spqcds.push(spqcd);
  15303. }
  15304. qcc.SPqcds = spqcds;
  15305. if (context.mainHeader) {
  15306. context.QCC[cqcc] = qcc;
  15307. } else {
  15308. context.currentTile.QCC[cqcc] = qcc;
  15309. }
  15310. break;
  15311. case 0xFF52:
  15312. length = readUint16(data, position);
  15313. var cod = {};
  15314. j = position + 2;
  15315. var scod = data[j++];
  15316. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15317. cod.sopMarkerUsed = !!(scod & 2);
  15318. cod.ephMarkerUsed = !!(scod & 4);
  15319. cod.progressionOrder = data[j++];
  15320. cod.layersCount = readUint16(data, j);
  15321. j += 2;
  15322. cod.multipleComponentTransform = data[j++];
  15323. cod.decompositionLevelsCount = data[j++];
  15324. cod.xcb = (data[j++] & 0xF) + 2;
  15325. cod.ycb = (data[j++] & 0xF) + 2;
  15326. var blockStyle = data[j++];
  15327. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15328. cod.resetContextProbabilities = !!(blockStyle & 2);
  15329. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15330. cod.verticalyStripe = !!(blockStyle & 8);
  15331. cod.predictableTermination = !!(blockStyle & 16);
  15332. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15333. cod.reversibleTransformation = data[j++];
  15334. if (cod.entropyCoderWithCustomPrecincts) {
  15335. var precinctsSizes = [];
  15336. while (j < length + position) {
  15337. var precinctsSize = data[j++];
  15338. precinctsSizes.push({
  15339. PPx: precinctsSize & 0xF,
  15340. PPy: precinctsSize >> 4
  15341. });
  15342. }
  15343. cod.precinctsSizes = precinctsSizes;
  15344. }
  15345. var unsupported = [];
  15346. if (cod.selectiveArithmeticCodingBypass) {
  15347. unsupported.push('selectiveArithmeticCodingBypass');
  15348. }
  15349. if (cod.resetContextProbabilities) {
  15350. unsupported.push('resetContextProbabilities');
  15351. }
  15352. if (cod.terminationOnEachCodingPass) {
  15353. unsupported.push('terminationOnEachCodingPass');
  15354. }
  15355. if (cod.verticalyStripe) {
  15356. unsupported.push('verticalyStripe');
  15357. }
  15358. if (cod.predictableTermination) {
  15359. unsupported.push('predictableTermination');
  15360. }
  15361. if (unsupported.length > 0) {
  15362. doNotRecover = true;
  15363. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15364. }
  15365. if (context.mainHeader) {
  15366. context.COD = cod;
  15367. } else {
  15368. context.currentTile.COD = cod;
  15369. context.currentTile.COC = [];
  15370. }
  15371. break;
  15372. case 0xFF90:
  15373. length = readUint16(data, position);
  15374. tile = {};
  15375. tile.index = readUint16(data, position + 2);
  15376. tile.length = readUint32(data, position + 4);
  15377. tile.dataEnd = tile.length + position - 2;
  15378. tile.partIndex = data[position + 8];
  15379. tile.partsCount = data[position + 9];
  15380. context.mainHeader = false;
  15381. if (tile.partIndex === 0) {
  15382. tile.COD = context.COD;
  15383. tile.COC = context.COC.slice(0);
  15384. tile.QCD = context.QCD;
  15385. tile.QCC = context.QCC.slice(0);
  15386. }
  15387. context.currentTile = tile;
  15388. break;
  15389. case 0xFF93:
  15390. tile = context.currentTile;
  15391. if (tile.partIndex === 0) {
  15392. initializeTile(context, tile.index);
  15393. buildPackets(context);
  15394. }
  15395. length = tile.dataEnd - position;
  15396. parseTilePackets(context, data, position, length);
  15397. break;
  15398. case 0xFF55:
  15399. case 0xFF57:
  15400. case 0xFF58:
  15401. case 0xFF64:
  15402. length = readUint16(data, position);
  15403. break;
  15404. case 0xFF53:
  15405. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15406. default:
  15407. throw new Error('Unknown codestream code: ' + code.toString(16));
  15408. }
  15409. position += length;
  15410. }
  15411. } catch (e) {
  15412. if (doNotRecover || this.failOnCorruptedImage) {
  15413. error('JPX Error: ' + e.message);
  15414. } else {
  15415. warn('JPX: Trying to recover from: ' + e.message);
  15416. }
  15417. }
  15418. this.tiles = transformComponents(context);
  15419. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15420. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15421. this.componentsCount = context.SIZ.Csiz;
  15422. }
  15423. };
  15424. function calculateComponentDimensions(component, siz) {
  15425. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15426. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15427. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15428. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15429. component.width = component.x1 - component.x0;
  15430. component.height = component.y1 - component.y0;
  15431. }
  15432. function calculateTileGrids(context, components) {
  15433. var siz = context.SIZ;
  15434. var tile, tiles = [];
  15435. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15436. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15437. for (var q = 0; q < numYtiles; q++) {
  15438. for (var p = 0; p < numXtiles; p++) {
  15439. tile = {};
  15440. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15441. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15442. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15443. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15444. tile.width = tile.tx1 - tile.tx0;
  15445. tile.height = tile.ty1 - tile.ty0;
  15446. tile.components = [];
  15447. tiles.push(tile);
  15448. }
  15449. }
  15450. context.tiles = tiles;
  15451. var componentsCount = siz.Csiz;
  15452. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15453. var component = components[i];
  15454. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15455. var tileComponent = {};
  15456. tile = tiles[j];
  15457. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15458. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15459. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15460. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15461. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15462. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15463. tile.components[i] = tileComponent;
  15464. }
  15465. }
  15466. }
  15467. function getBlocksDimensions(context, component, r) {
  15468. var codOrCoc = component.codingStyleParameters;
  15469. var result = {};
  15470. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15471. result.PPx = 15;
  15472. result.PPy = 15;
  15473. } else {
  15474. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15475. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15476. }
  15477. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15478. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15479. return result;
  15480. }
  15481. function buildPrecincts(context, resolution, dimensions) {
  15482. var precinctWidth = 1 << dimensions.PPx;
  15483. var precinctHeight = 1 << dimensions.PPy;
  15484. var isZeroRes = resolution.resLevel === 0;
  15485. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15486. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15487. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15488. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15489. var numprecincts = numprecinctswide * numprecinctshigh;
  15490. resolution.precinctParameters = {
  15491. precinctWidth: precinctWidth,
  15492. precinctHeight: precinctHeight,
  15493. numprecinctswide: numprecinctswide,
  15494. numprecinctshigh: numprecinctshigh,
  15495. numprecincts: numprecincts,
  15496. precinctWidthInSubband: precinctWidthInSubband,
  15497. precinctHeightInSubband: precinctHeightInSubband
  15498. };
  15499. }
  15500. function buildCodeblocks(context, subband, dimensions) {
  15501. var xcb_ = dimensions.xcb_;
  15502. var ycb_ = dimensions.ycb_;
  15503. var codeblockWidth = 1 << xcb_;
  15504. var codeblockHeight = 1 << ycb_;
  15505. var cbx0 = subband.tbx0 >> xcb_;
  15506. var cby0 = subband.tby0 >> ycb_;
  15507. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15508. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15509. var precinctParameters = subband.resolution.precinctParameters;
  15510. var codeblocks = [];
  15511. var precincts = [];
  15512. var i, j, codeblock, precinctNumber;
  15513. for (j = cby0; j < cby1; j++) {
  15514. for (i = cbx0; i < cbx1; i++) {
  15515. codeblock = {
  15516. cbx: i,
  15517. cby: j,
  15518. tbx0: codeblockWidth * i,
  15519. tby0: codeblockHeight * j,
  15520. tbx1: codeblockWidth * (i + 1),
  15521. tby1: codeblockHeight * (j + 1)
  15522. };
  15523. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15524. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15525. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15526. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15527. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15528. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15529. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15530. codeblock.precinctNumber = precinctNumber;
  15531. codeblock.subbandType = subband.type;
  15532. codeblock.Lblock = 3;
  15533. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15534. continue;
  15535. }
  15536. codeblocks.push(codeblock);
  15537. var precinct = precincts[precinctNumber];
  15538. if (precinct !== undefined) {
  15539. if (i < precinct.cbxMin) {
  15540. precinct.cbxMin = i;
  15541. } else if (i > precinct.cbxMax) {
  15542. precinct.cbxMax = i;
  15543. }
  15544. if (j < precinct.cbyMin) {
  15545. precinct.cbxMin = j;
  15546. } else if (j > precinct.cbyMax) {
  15547. precinct.cbyMax = j;
  15548. }
  15549. } else {
  15550. precincts[precinctNumber] = precinct = {
  15551. cbxMin: i,
  15552. cbyMin: j,
  15553. cbxMax: i,
  15554. cbyMax: j
  15555. };
  15556. }
  15557. codeblock.precinct = precinct;
  15558. }
  15559. }
  15560. subband.codeblockParameters = {
  15561. codeblockWidth: xcb_,
  15562. codeblockHeight: ycb_,
  15563. numcodeblockwide: cbx1 - cbx0 + 1,
  15564. numcodeblockhigh: cby1 - cby0 + 1
  15565. };
  15566. subband.codeblocks = codeblocks;
  15567. subband.precincts = precincts;
  15568. }
  15569. function createPacket(resolution, precinctNumber, layerNumber) {
  15570. var precinctCodeblocks = [];
  15571. var subbands = resolution.subbands;
  15572. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15573. var subband = subbands[i];
  15574. var codeblocks = subband.codeblocks;
  15575. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15576. var codeblock = codeblocks[j];
  15577. if (codeblock.precinctNumber !== precinctNumber) {
  15578. continue;
  15579. }
  15580. precinctCodeblocks.push(codeblock);
  15581. }
  15582. }
  15583. return {
  15584. layerNumber: layerNumber,
  15585. codeblocks: precinctCodeblocks
  15586. };
  15587. }
  15588. function LayerResolutionComponentPositionIterator(context) {
  15589. var siz = context.SIZ;
  15590. var tileIndex = context.currentTile.index;
  15591. var tile = context.tiles[tileIndex];
  15592. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15593. var componentsCount = siz.Csiz;
  15594. var maxDecompositionLevelsCount = 0;
  15595. for (var q = 0; q < componentsCount; q++) {
  15596. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15597. }
  15598. var l = 0, r = 0, i = 0, k = 0;
  15599. this.nextPacket = function JpxImage_nextPacket() {
  15600. for (; l < layersCount; l++) {
  15601. for (; r <= maxDecompositionLevelsCount; r++) {
  15602. for (; i < componentsCount; i++) {
  15603. var component = tile.components[i];
  15604. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15605. continue;
  15606. }
  15607. var resolution = component.resolutions[r];
  15608. var numprecincts = resolution.precinctParameters.numprecincts;
  15609. for (; k < numprecincts;) {
  15610. var packet = createPacket(resolution, k, l);
  15611. k++;
  15612. return packet;
  15613. }
  15614. k = 0;
  15615. }
  15616. i = 0;
  15617. }
  15618. r = 0;
  15619. }
  15620. error('JPX Error: Out of packets');
  15621. };
  15622. }
  15623. function ResolutionLayerComponentPositionIterator(context) {
  15624. var siz = context.SIZ;
  15625. var tileIndex = context.currentTile.index;
  15626. var tile = context.tiles[tileIndex];
  15627. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15628. var componentsCount = siz.Csiz;
  15629. var maxDecompositionLevelsCount = 0;
  15630. for (var q = 0; q < componentsCount; q++) {
  15631. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15632. }
  15633. var r = 0, l = 0, i = 0, k = 0;
  15634. this.nextPacket = function JpxImage_nextPacket() {
  15635. for (; r <= maxDecompositionLevelsCount; r++) {
  15636. for (; l < layersCount; l++) {
  15637. for (; i < componentsCount; i++) {
  15638. var component = tile.components[i];
  15639. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15640. continue;
  15641. }
  15642. var resolution = component.resolutions[r];
  15643. var numprecincts = resolution.precinctParameters.numprecincts;
  15644. for (; k < numprecincts;) {
  15645. var packet = createPacket(resolution, k, l);
  15646. k++;
  15647. return packet;
  15648. }
  15649. k = 0;
  15650. }
  15651. i = 0;
  15652. }
  15653. l = 0;
  15654. }
  15655. error('JPX Error: Out of packets');
  15656. };
  15657. }
  15658. function ResolutionPositionComponentLayerIterator(context) {
  15659. var siz = context.SIZ;
  15660. var tileIndex = context.currentTile.index;
  15661. var tile = context.tiles[tileIndex];
  15662. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15663. var componentsCount = siz.Csiz;
  15664. var l, r, c, p;
  15665. var maxDecompositionLevelsCount = 0;
  15666. for (c = 0; c < componentsCount; c++) {
  15667. var component = tile.components[c];
  15668. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15669. }
  15670. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15671. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15672. var maxNumPrecincts = 0;
  15673. for (c = 0; c < componentsCount; ++c) {
  15674. var resolutions = tile.components[c].resolutions;
  15675. if (r < resolutions.length) {
  15676. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15677. }
  15678. }
  15679. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15680. }
  15681. l = 0;
  15682. r = 0;
  15683. c = 0;
  15684. p = 0;
  15685. this.nextPacket = function JpxImage_nextPacket() {
  15686. for (; r <= maxDecompositionLevelsCount; r++) {
  15687. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15688. for (; c < componentsCount; c++) {
  15689. var component = tile.components[c];
  15690. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15691. continue;
  15692. }
  15693. var resolution = component.resolutions[r];
  15694. var numprecincts = resolution.precinctParameters.numprecincts;
  15695. if (p >= numprecincts) {
  15696. continue;
  15697. }
  15698. for (; l < layersCount;) {
  15699. var packet = createPacket(resolution, p, l);
  15700. l++;
  15701. return packet;
  15702. }
  15703. l = 0;
  15704. }
  15705. c = 0;
  15706. }
  15707. p = 0;
  15708. }
  15709. error('JPX Error: Out of packets');
  15710. };
  15711. }
  15712. function PositionComponentResolutionLayerIterator(context) {
  15713. var siz = context.SIZ;
  15714. var tileIndex = context.currentTile.index;
  15715. var tile = context.tiles[tileIndex];
  15716. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15717. var componentsCount = siz.Csiz;
  15718. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15719. var precinctsIterationSizes = precinctsSizes;
  15720. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15721. this.nextPacket = function JpxImage_nextPacket() {
  15722. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15723. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15724. for (; c < componentsCount; c++) {
  15725. var component = tile.components[c];
  15726. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15727. for (; r <= decompositionLevelsCount; r++) {
  15728. var resolution = component.resolutions[r];
  15729. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15730. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15731. if (k === null) {
  15732. continue;
  15733. }
  15734. for (; l < layersCount;) {
  15735. var packet = createPacket(resolution, k, l);
  15736. l++;
  15737. return packet;
  15738. }
  15739. l = 0;
  15740. }
  15741. r = 0;
  15742. }
  15743. c = 0;
  15744. }
  15745. px = 0;
  15746. }
  15747. error('JPX Error: Out of packets');
  15748. };
  15749. }
  15750. function ComponentPositionResolutionLayerIterator(context) {
  15751. var siz = context.SIZ;
  15752. var tileIndex = context.currentTile.index;
  15753. var tile = context.tiles[tileIndex];
  15754. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15755. var componentsCount = siz.Csiz;
  15756. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15757. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15758. this.nextPacket = function JpxImage_nextPacket() {
  15759. for (; c < componentsCount; ++c) {
  15760. var component = tile.components[c];
  15761. var precinctsIterationSizes = precinctsSizes.components[c];
  15762. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15763. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15764. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15765. for (; r <= decompositionLevelsCount; r++) {
  15766. var resolution = component.resolutions[r];
  15767. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15768. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15769. if (k === null) {
  15770. continue;
  15771. }
  15772. for (; l < layersCount;) {
  15773. var packet = createPacket(resolution, k, l);
  15774. l++;
  15775. return packet;
  15776. }
  15777. l = 0;
  15778. }
  15779. r = 0;
  15780. }
  15781. px = 0;
  15782. }
  15783. py = 0;
  15784. }
  15785. error('JPX Error: Out of packets');
  15786. };
  15787. }
  15788. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15789. var posX = pxIndex * precinctIterationSizes.minWidth;
  15790. var posY = pyIndex * precinctIterationSizes.minHeight;
  15791. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15792. return null;
  15793. }
  15794. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15795. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15796. }
  15797. function getPrecinctSizesInImageScale(tile) {
  15798. var componentsCount = tile.components.length;
  15799. var minWidth = Number.MAX_VALUE;
  15800. var minHeight = Number.MAX_VALUE;
  15801. var maxNumWide = 0;
  15802. var maxNumHigh = 0;
  15803. var sizePerComponent = new Array(componentsCount);
  15804. for (var c = 0; c < componentsCount; c++) {
  15805. var component = tile.components[c];
  15806. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15807. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15808. var minWidthCurrentComponent = Number.MAX_VALUE;
  15809. var minHeightCurrentComponent = Number.MAX_VALUE;
  15810. var maxNumWideCurrentComponent = 0;
  15811. var maxNumHighCurrentComponent = 0;
  15812. var scale = 1;
  15813. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15814. var resolution = component.resolutions[r];
  15815. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15816. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15817. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15818. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15819. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15820. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15821. sizePerResolution[r] = {
  15822. width: widthCurrentResolution,
  15823. height: heightCurrentResolution
  15824. };
  15825. scale <<= 1;
  15826. }
  15827. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15828. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15829. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15830. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15831. sizePerComponent[c] = {
  15832. resolutions: sizePerResolution,
  15833. minWidth: minWidthCurrentComponent,
  15834. minHeight: minHeightCurrentComponent,
  15835. maxNumWide: maxNumWideCurrentComponent,
  15836. maxNumHigh: maxNumHighCurrentComponent
  15837. };
  15838. }
  15839. return {
  15840. components: sizePerComponent,
  15841. minWidth: minWidth,
  15842. minHeight: minHeight,
  15843. maxNumWide: maxNumWide,
  15844. maxNumHigh: maxNumHigh
  15845. };
  15846. }
  15847. function buildPackets(context) {
  15848. var siz = context.SIZ;
  15849. var tileIndex = context.currentTile.index;
  15850. var tile = context.tiles[tileIndex];
  15851. var componentsCount = siz.Csiz;
  15852. for (var c = 0; c < componentsCount; c++) {
  15853. var component = tile.components[c];
  15854. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15855. var resolutions = [];
  15856. var subbands = [];
  15857. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15858. var blocksDimensions = getBlocksDimensions(context, component, r);
  15859. var resolution = {};
  15860. var scale = 1 << decompositionLevelsCount - r;
  15861. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15862. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15863. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15864. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15865. resolution.resLevel = r;
  15866. buildPrecincts(context, resolution, blocksDimensions);
  15867. resolutions.push(resolution);
  15868. var subband;
  15869. if (r === 0) {
  15870. subband = {};
  15871. subband.type = 'LL';
  15872. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15873. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15874. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15875. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15876. subband.resolution = resolution;
  15877. buildCodeblocks(context, subband, blocksDimensions);
  15878. subbands.push(subband);
  15879. resolution.subbands = [subband];
  15880. } else {
  15881. var bscale = 1 << decompositionLevelsCount - r + 1;
  15882. var resolutionSubbands = [];
  15883. subband = {};
  15884. subband.type = 'HL';
  15885. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15886. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  15887. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15888. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  15889. subband.resolution = resolution;
  15890. buildCodeblocks(context, subband, blocksDimensions);
  15891. subbands.push(subband);
  15892. resolutionSubbands.push(subband);
  15893. subband = {};
  15894. subband.type = 'LH';
  15895. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  15896. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15897. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  15898. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15899. subband.resolution = resolution;
  15900. buildCodeblocks(context, subband, blocksDimensions);
  15901. subbands.push(subband);
  15902. resolutionSubbands.push(subband);
  15903. subband = {};
  15904. subband.type = 'HH';
  15905. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15906. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15907. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15908. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15909. subband.resolution = resolution;
  15910. buildCodeblocks(context, subband, blocksDimensions);
  15911. subbands.push(subband);
  15912. resolutionSubbands.push(subband);
  15913. resolution.subbands = resolutionSubbands;
  15914. }
  15915. }
  15916. component.resolutions = resolutions;
  15917. component.subbands = subbands;
  15918. }
  15919. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  15920. switch (progressionOrder) {
  15921. case 0:
  15922. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  15923. break;
  15924. case 1:
  15925. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  15926. break;
  15927. case 2:
  15928. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  15929. break;
  15930. case 3:
  15931. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  15932. break;
  15933. case 4:
  15934. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  15935. break;
  15936. default:
  15937. error('JPX Error: Unsupported progression order ' + progressionOrder);
  15938. }
  15939. }
  15940. function parseTilePackets(context, data, offset, dataLength) {
  15941. var position = 0;
  15942. var buffer, bufferSize = 0, skipNextBit = false;
  15943. function readBits(count) {
  15944. while (bufferSize < count) {
  15945. var b = data[offset + position];
  15946. position++;
  15947. if (skipNextBit) {
  15948. buffer = buffer << 7 | b;
  15949. bufferSize += 7;
  15950. skipNextBit = false;
  15951. } else {
  15952. buffer = buffer << 8 | b;
  15953. bufferSize += 8;
  15954. }
  15955. if (b === 0xFF) {
  15956. skipNextBit = true;
  15957. }
  15958. }
  15959. bufferSize -= count;
  15960. return buffer >>> bufferSize & (1 << count) - 1;
  15961. }
  15962. function skipMarkerIfEqual(value) {
  15963. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  15964. skipBytes(1);
  15965. return true;
  15966. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  15967. skipBytes(2);
  15968. return true;
  15969. }
  15970. return false;
  15971. }
  15972. function skipBytes(count) {
  15973. position += count;
  15974. }
  15975. function alignToByte() {
  15976. bufferSize = 0;
  15977. if (skipNextBit) {
  15978. position++;
  15979. skipNextBit = false;
  15980. }
  15981. }
  15982. function readCodingpasses() {
  15983. if (readBits(1) === 0) {
  15984. return 1;
  15985. }
  15986. if (readBits(1) === 0) {
  15987. return 2;
  15988. }
  15989. var value = readBits(2);
  15990. if (value < 3) {
  15991. return value + 3;
  15992. }
  15993. value = readBits(5);
  15994. if (value < 31) {
  15995. return value + 6;
  15996. }
  15997. value = readBits(7);
  15998. return value + 37;
  15999. }
  16000. var tileIndex = context.currentTile.index;
  16001. var tile = context.tiles[tileIndex];
  16002. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16003. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16004. var packetsIterator = tile.packetsIterator;
  16005. while (position < dataLength) {
  16006. alignToByte();
  16007. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16008. skipBytes(4);
  16009. }
  16010. var packet = packetsIterator.nextPacket();
  16011. if (!readBits(1)) {
  16012. continue;
  16013. }
  16014. var layerNumber = packet.layerNumber;
  16015. var queue = [], codeblock;
  16016. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16017. codeblock = packet.codeblocks[i];
  16018. var precinct = codeblock.precinct;
  16019. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16020. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16021. var codeblockIncluded = false;
  16022. var firstTimeInclusion = false;
  16023. var valueReady;
  16024. if (codeblock['included'] !== undefined) {
  16025. codeblockIncluded = !!readBits(1);
  16026. } else {
  16027. precinct = codeblock.precinct;
  16028. var inclusionTree, zeroBitPlanesTree;
  16029. if (precinct['inclusionTree'] !== undefined) {
  16030. inclusionTree = precinct.inclusionTree;
  16031. } else {
  16032. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16033. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16034. inclusionTree = new InclusionTree(width, height, layerNumber);
  16035. zeroBitPlanesTree = new TagTree(width, height);
  16036. precinct.inclusionTree = inclusionTree;
  16037. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16038. }
  16039. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16040. while (true) {
  16041. if (readBits(1)) {
  16042. valueReady = !inclusionTree.nextLevel();
  16043. if (valueReady) {
  16044. codeblock.included = true;
  16045. codeblockIncluded = firstTimeInclusion = true;
  16046. break;
  16047. }
  16048. } else {
  16049. inclusionTree.incrementValue(layerNumber);
  16050. break;
  16051. }
  16052. }
  16053. }
  16054. }
  16055. if (!codeblockIncluded) {
  16056. continue;
  16057. }
  16058. if (firstTimeInclusion) {
  16059. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16060. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16061. while (true) {
  16062. if (readBits(1)) {
  16063. valueReady = !zeroBitPlanesTree.nextLevel();
  16064. if (valueReady) {
  16065. break;
  16066. }
  16067. } else {
  16068. zeroBitPlanesTree.incrementValue();
  16069. }
  16070. }
  16071. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16072. }
  16073. var codingpasses = readCodingpasses();
  16074. while (readBits(1)) {
  16075. codeblock.Lblock++;
  16076. }
  16077. var codingpassesLog2 = log2(codingpasses);
  16078. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16079. var codedDataLength = readBits(bits);
  16080. queue.push({
  16081. codeblock: codeblock,
  16082. codingpasses: codingpasses,
  16083. dataLength: codedDataLength
  16084. });
  16085. }
  16086. alignToByte();
  16087. if (ephMarkerUsed) {
  16088. skipMarkerIfEqual(0x92);
  16089. }
  16090. while (queue.length > 0) {
  16091. var packetItem = queue.shift();
  16092. codeblock = packetItem.codeblock;
  16093. if (codeblock['data'] === undefined) {
  16094. codeblock.data = [];
  16095. }
  16096. codeblock.data.push({
  16097. data: data,
  16098. start: offset + position,
  16099. end: offset + position + packetItem.dataLength,
  16100. codingpasses: packetItem.codingpasses
  16101. });
  16102. position += packetItem.dataLength;
  16103. }
  16104. }
  16105. return position;
  16106. }
  16107. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16108. var x0 = subband.tbx0;
  16109. var y0 = subband.tby0;
  16110. var width = subband.tbx1 - subband.tbx0;
  16111. var codeblocks = subband.codeblocks;
  16112. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16113. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16114. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16115. var codeblock = codeblocks[i];
  16116. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16117. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16118. if (blockWidth === 0 || blockHeight === 0) {
  16119. continue;
  16120. }
  16121. if (codeblock['data'] === undefined) {
  16122. continue;
  16123. }
  16124. var bitModel, currentCodingpassType;
  16125. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16126. currentCodingpassType = 2;
  16127. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16128. var j, jj, dataItem;
  16129. for (j = 0, jj = data.length; j < jj; j++) {
  16130. dataItem = data[j];
  16131. totalLength += dataItem.end - dataItem.start;
  16132. codingpasses += dataItem.codingpasses;
  16133. }
  16134. var encodedData = new Uint8Array(totalLength);
  16135. var position = 0;
  16136. for (j = 0, jj = data.length; j < jj; j++) {
  16137. dataItem = data[j];
  16138. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16139. encodedData.set(chunk, position);
  16140. position += chunk.length;
  16141. }
  16142. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16143. bitModel.setDecoder(decoder);
  16144. for (j = 0; j < codingpasses; j++) {
  16145. switch (currentCodingpassType) {
  16146. case 0:
  16147. bitModel.runSignificancePropagationPass();
  16148. break;
  16149. case 1:
  16150. bitModel.runMagnitudeRefinementPass();
  16151. break;
  16152. case 2:
  16153. bitModel.runCleanupPass();
  16154. if (segmentationSymbolUsed) {
  16155. bitModel.checkSegmentationSymbol();
  16156. }
  16157. break;
  16158. }
  16159. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16160. }
  16161. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16162. var sign = bitModel.coefficentsSign;
  16163. var magnitude = bitModel.coefficentsMagnitude;
  16164. var bitsDecoded = bitModel.bitsDecoded;
  16165. var magnitudeCorrection = reversible ? 0 : 0.5;
  16166. var k, n, nb;
  16167. position = 0;
  16168. var interleave = subband.type !== 'LL';
  16169. for (j = 0; j < blockHeight; j++) {
  16170. var row = offset / width | 0;
  16171. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16172. for (k = 0; k < blockWidth; k++) {
  16173. n = magnitude[position];
  16174. if (n !== 0) {
  16175. n = (n + magnitudeCorrection) * delta;
  16176. if (sign[position] !== 0) {
  16177. n = -n;
  16178. }
  16179. nb = bitsDecoded[position];
  16180. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16181. if (reversible && nb >= mb) {
  16182. coefficients[pos] = n;
  16183. } else {
  16184. coefficients[pos] = n * (1 << mb - nb);
  16185. }
  16186. }
  16187. offset++;
  16188. position++;
  16189. }
  16190. offset += width - blockWidth;
  16191. }
  16192. }
  16193. }
  16194. function transformTile(context, tile, c) {
  16195. var component = tile.components[c];
  16196. var codingStyleParameters = component.codingStyleParameters;
  16197. var quantizationParameters = component.quantizationParameters;
  16198. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16199. var spqcds = quantizationParameters.SPqcds;
  16200. var scalarExpounded = quantizationParameters.scalarExpounded;
  16201. var guardBits = quantizationParameters.guardBits;
  16202. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16203. var precision = context.components[c].precision;
  16204. var reversible = codingStyleParameters.reversibleTransformation;
  16205. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16206. var subbandCoefficients = [];
  16207. var b = 0;
  16208. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16209. var resolution = component.resolutions[i];
  16210. var width = resolution.trx1 - resolution.trx0;
  16211. var height = resolution.try1 - resolution.try0;
  16212. var coefficients = new Float32Array(width * height);
  16213. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16214. var mu, epsilon;
  16215. if (!scalarExpounded) {
  16216. mu = spqcds[0].mu;
  16217. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16218. } else {
  16219. mu = spqcds[b].mu;
  16220. epsilon = spqcds[b].epsilon;
  16221. b++;
  16222. }
  16223. var subband = resolution.subbands[j];
  16224. var gainLog2 = SubbandsGainLog2[subband.type];
  16225. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16226. var mb = guardBits + epsilon - 1;
  16227. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16228. }
  16229. subbandCoefficients.push({
  16230. width: width,
  16231. height: height,
  16232. items: coefficients
  16233. });
  16234. }
  16235. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16236. return {
  16237. left: component.tcx0,
  16238. top: component.tcy0,
  16239. width: result.width,
  16240. height: result.height,
  16241. items: result.items
  16242. };
  16243. }
  16244. function transformComponents(context) {
  16245. var siz = context.SIZ;
  16246. var components = context.components;
  16247. var componentsCount = siz.Csiz;
  16248. var resultImages = [];
  16249. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16250. var tile = context.tiles[i];
  16251. var transformedTiles = [];
  16252. var c;
  16253. for (c = 0; c < componentsCount; c++) {
  16254. transformedTiles[c] = transformTile(context, tile, c);
  16255. }
  16256. var tile0 = transformedTiles[0];
  16257. var out = new Uint8Array(tile0.items.length * componentsCount);
  16258. var result = {
  16259. left: tile0.left,
  16260. top: tile0.top,
  16261. width: tile0.width,
  16262. height: tile0.height,
  16263. items: out
  16264. };
  16265. var shift, offset, max, min, maxK;
  16266. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16267. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16268. var fourComponents = componentsCount === 4;
  16269. var y0items = transformedTiles[0].items;
  16270. var y1items = transformedTiles[1].items;
  16271. var y2items = transformedTiles[2].items;
  16272. var y3items = fourComponents ? transformedTiles[3].items : null;
  16273. shift = components[0].precision - 8;
  16274. offset = (128 << shift) + 0.5;
  16275. max = 255 * (1 << shift);
  16276. maxK = max * 0.5;
  16277. min = -maxK;
  16278. var component0 = tile.components[0];
  16279. var alpha01 = componentsCount - 3;
  16280. jj = y0items.length;
  16281. if (!component0.codingStyleParameters.reversibleTransformation) {
  16282. for (j = 0; j < jj; j++, pos += alpha01) {
  16283. y0 = y0items[j] + offset;
  16284. y1 = y1items[j];
  16285. y2 = y2items[j];
  16286. r = y0 + 1.402 * y2;
  16287. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16288. b = y0 + 1.772 * y1;
  16289. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16290. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16291. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16292. }
  16293. } else {
  16294. for (j = 0; j < jj; j++, pos += alpha01) {
  16295. y0 = y0items[j] + offset;
  16296. y1 = y1items[j];
  16297. y2 = y2items[j];
  16298. g = y0 - (y2 + y1 >> 2);
  16299. r = g + y2;
  16300. b = g + y1;
  16301. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16302. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16303. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16304. }
  16305. }
  16306. if (fourComponents) {
  16307. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16308. k = y3items[j];
  16309. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16310. }
  16311. }
  16312. } else {
  16313. for (c = 0; c < componentsCount; c++) {
  16314. var items = transformedTiles[c].items;
  16315. shift = components[c].precision - 8;
  16316. offset = (128 << shift) + 0.5;
  16317. max = 127.5 * (1 << shift);
  16318. min = -max;
  16319. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16320. val = items[j];
  16321. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16322. pos += componentsCount;
  16323. }
  16324. }
  16325. }
  16326. resultImages.push(result);
  16327. }
  16328. return resultImages;
  16329. }
  16330. function initializeTile(context, tileIndex) {
  16331. var siz = context.SIZ;
  16332. var componentsCount = siz.Csiz;
  16333. var tile = context.tiles[tileIndex];
  16334. for (var c = 0; c < componentsCount; c++) {
  16335. var component = tile.components[c];
  16336. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16337. component.quantizationParameters = qcdOrQcc;
  16338. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16339. component.codingStyleParameters = codOrCoc;
  16340. }
  16341. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16342. }
  16343. var TagTree = function TagTreeClosure() {
  16344. function TagTree(width, height) {
  16345. var levelsLength = log2(Math.max(width, height)) + 1;
  16346. this.levels = [];
  16347. for (var i = 0; i < levelsLength; i++) {
  16348. var level = {
  16349. width: width,
  16350. height: height,
  16351. items: []
  16352. };
  16353. this.levels.push(level);
  16354. width = Math.ceil(width / 2);
  16355. height = Math.ceil(height / 2);
  16356. }
  16357. }
  16358. TagTree.prototype = {
  16359. reset: function TagTree_reset(i, j) {
  16360. var currentLevel = 0, value = 0, level;
  16361. while (currentLevel < this.levels.length) {
  16362. level = this.levels[currentLevel];
  16363. var index = i + j * level.width;
  16364. if (level.items[index] !== undefined) {
  16365. value = level.items[index];
  16366. break;
  16367. }
  16368. level.index = index;
  16369. i >>= 1;
  16370. j >>= 1;
  16371. currentLevel++;
  16372. }
  16373. currentLevel--;
  16374. level = this.levels[currentLevel];
  16375. level.items[level.index] = value;
  16376. this.currentLevel = currentLevel;
  16377. delete this.value;
  16378. },
  16379. incrementValue: function TagTree_incrementValue() {
  16380. var level = this.levels[this.currentLevel];
  16381. level.items[level.index]++;
  16382. },
  16383. nextLevel: function TagTree_nextLevel() {
  16384. var currentLevel = this.currentLevel;
  16385. var level = this.levels[currentLevel];
  16386. var value = level.items[level.index];
  16387. currentLevel--;
  16388. if (currentLevel < 0) {
  16389. this.value = value;
  16390. return false;
  16391. }
  16392. this.currentLevel = currentLevel;
  16393. level = this.levels[currentLevel];
  16394. level.items[level.index] = value;
  16395. return true;
  16396. }
  16397. };
  16398. return TagTree;
  16399. }();
  16400. var InclusionTree = function InclusionTreeClosure() {
  16401. function InclusionTree(width, height, defaultValue) {
  16402. var levelsLength = log2(Math.max(width, height)) + 1;
  16403. this.levels = [];
  16404. for (var i = 0; i < levelsLength; i++) {
  16405. var items = new Uint8Array(width * height);
  16406. for (var j = 0, jj = items.length; j < jj; j++) {
  16407. items[j] = defaultValue;
  16408. }
  16409. var level = {
  16410. width: width,
  16411. height: height,
  16412. items: items
  16413. };
  16414. this.levels.push(level);
  16415. width = Math.ceil(width / 2);
  16416. height = Math.ceil(height / 2);
  16417. }
  16418. }
  16419. InclusionTree.prototype = {
  16420. reset: function InclusionTree_reset(i, j, stopValue) {
  16421. var currentLevel = 0;
  16422. while (currentLevel < this.levels.length) {
  16423. var level = this.levels[currentLevel];
  16424. var index = i + j * level.width;
  16425. level.index = index;
  16426. var value = level.items[index];
  16427. if (value === 0xFF) {
  16428. break;
  16429. }
  16430. if (value > stopValue) {
  16431. this.currentLevel = currentLevel;
  16432. this.propagateValues();
  16433. return false;
  16434. }
  16435. i >>= 1;
  16436. j >>= 1;
  16437. currentLevel++;
  16438. }
  16439. this.currentLevel = currentLevel - 1;
  16440. return true;
  16441. },
  16442. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16443. var level = this.levels[this.currentLevel];
  16444. level.items[level.index] = stopValue + 1;
  16445. this.propagateValues();
  16446. },
  16447. propagateValues: function InclusionTree_propagateValues() {
  16448. var levelIndex = this.currentLevel;
  16449. var level = this.levels[levelIndex];
  16450. var currentValue = level.items[level.index];
  16451. while (--levelIndex >= 0) {
  16452. level = this.levels[levelIndex];
  16453. level.items[level.index] = currentValue;
  16454. }
  16455. },
  16456. nextLevel: function InclusionTree_nextLevel() {
  16457. var currentLevel = this.currentLevel;
  16458. var level = this.levels[currentLevel];
  16459. var value = level.items[level.index];
  16460. level.items[level.index] = 0xFF;
  16461. currentLevel--;
  16462. if (currentLevel < 0) {
  16463. return false;
  16464. }
  16465. this.currentLevel = currentLevel;
  16466. level = this.levels[currentLevel];
  16467. level.items[level.index] = value;
  16468. return true;
  16469. }
  16470. };
  16471. return InclusionTree;
  16472. }();
  16473. var BitModel = function BitModelClosure() {
  16474. var UNIFORM_CONTEXT = 17;
  16475. var RUNLENGTH_CONTEXT = 18;
  16476. var LLAndLHContextsLabel = new Uint8Array([
  16477. 0,
  16478. 5,
  16479. 8,
  16480. 0,
  16481. 3,
  16482. 7,
  16483. 8,
  16484. 0,
  16485. 4,
  16486. 7,
  16487. 8,
  16488. 0,
  16489. 0,
  16490. 0,
  16491. 0,
  16492. 0,
  16493. 1,
  16494. 6,
  16495. 8,
  16496. 0,
  16497. 3,
  16498. 7,
  16499. 8,
  16500. 0,
  16501. 4,
  16502. 7,
  16503. 8,
  16504. 0,
  16505. 0,
  16506. 0,
  16507. 0,
  16508. 0,
  16509. 2,
  16510. 6,
  16511. 8,
  16512. 0,
  16513. 3,
  16514. 7,
  16515. 8,
  16516. 0,
  16517. 4,
  16518. 7,
  16519. 8,
  16520. 0,
  16521. 0,
  16522. 0,
  16523. 0,
  16524. 0,
  16525. 2,
  16526. 6,
  16527. 8,
  16528. 0,
  16529. 3,
  16530. 7,
  16531. 8,
  16532. 0,
  16533. 4,
  16534. 7,
  16535. 8,
  16536. 0,
  16537. 0,
  16538. 0,
  16539. 0,
  16540. 0,
  16541. 2,
  16542. 6,
  16543. 8,
  16544. 0,
  16545. 3,
  16546. 7,
  16547. 8,
  16548. 0,
  16549. 4,
  16550. 7,
  16551. 8
  16552. ]);
  16553. var HLContextLabel = new Uint8Array([
  16554. 0,
  16555. 3,
  16556. 4,
  16557. 0,
  16558. 5,
  16559. 7,
  16560. 7,
  16561. 0,
  16562. 8,
  16563. 8,
  16564. 8,
  16565. 0,
  16566. 0,
  16567. 0,
  16568. 0,
  16569. 0,
  16570. 1,
  16571. 3,
  16572. 4,
  16573. 0,
  16574. 6,
  16575. 7,
  16576. 7,
  16577. 0,
  16578. 8,
  16579. 8,
  16580. 8,
  16581. 0,
  16582. 0,
  16583. 0,
  16584. 0,
  16585. 0,
  16586. 2,
  16587. 3,
  16588. 4,
  16589. 0,
  16590. 6,
  16591. 7,
  16592. 7,
  16593. 0,
  16594. 8,
  16595. 8,
  16596. 8,
  16597. 0,
  16598. 0,
  16599. 0,
  16600. 0,
  16601. 0,
  16602. 2,
  16603. 3,
  16604. 4,
  16605. 0,
  16606. 6,
  16607. 7,
  16608. 7,
  16609. 0,
  16610. 8,
  16611. 8,
  16612. 8,
  16613. 0,
  16614. 0,
  16615. 0,
  16616. 0,
  16617. 0,
  16618. 2,
  16619. 3,
  16620. 4,
  16621. 0,
  16622. 6,
  16623. 7,
  16624. 7,
  16625. 0,
  16626. 8,
  16627. 8,
  16628. 8
  16629. ]);
  16630. var HHContextLabel = new Uint8Array([
  16631. 0,
  16632. 1,
  16633. 2,
  16634. 0,
  16635. 1,
  16636. 2,
  16637. 2,
  16638. 0,
  16639. 2,
  16640. 2,
  16641. 2,
  16642. 0,
  16643. 0,
  16644. 0,
  16645. 0,
  16646. 0,
  16647. 3,
  16648. 4,
  16649. 5,
  16650. 0,
  16651. 4,
  16652. 5,
  16653. 5,
  16654. 0,
  16655. 5,
  16656. 5,
  16657. 5,
  16658. 0,
  16659. 0,
  16660. 0,
  16661. 0,
  16662. 0,
  16663. 6,
  16664. 7,
  16665. 7,
  16666. 0,
  16667. 7,
  16668. 7,
  16669. 7,
  16670. 0,
  16671. 7,
  16672. 7,
  16673. 7,
  16674. 0,
  16675. 0,
  16676. 0,
  16677. 0,
  16678. 0,
  16679. 8,
  16680. 8,
  16681. 8,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 8,
  16688. 8,
  16689. 8,
  16690. 0,
  16691. 0,
  16692. 0,
  16693. 0,
  16694. 0,
  16695. 8,
  16696. 8,
  16697. 8,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 8,
  16704. 8,
  16705. 8
  16706. ]);
  16707. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16708. this.width = width;
  16709. this.height = height;
  16710. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16711. var coefficientCount = width * height;
  16712. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16713. this.coefficentsSign = new Uint8Array(coefficientCount);
  16714. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16715. this.processingFlags = new Uint8Array(coefficientCount);
  16716. var bitsDecoded = new Uint8Array(coefficientCount);
  16717. if (zeroBitPlanes !== 0) {
  16718. for (var i = 0; i < coefficientCount; i++) {
  16719. bitsDecoded[i] = zeroBitPlanes;
  16720. }
  16721. }
  16722. this.bitsDecoded = bitsDecoded;
  16723. this.reset();
  16724. }
  16725. BitModel.prototype = {
  16726. setDecoder: function BitModel_setDecoder(decoder) {
  16727. this.decoder = decoder;
  16728. },
  16729. reset: function BitModel_reset() {
  16730. this.contexts = new Int8Array(19);
  16731. this.contexts[0] = 4 << 1 | 0;
  16732. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16733. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16734. },
  16735. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16736. var neighborsSignificance = this.neighborsSignificance;
  16737. var width = this.width, height = this.height;
  16738. var left = column > 0;
  16739. var right = column + 1 < width;
  16740. var i;
  16741. if (row > 0) {
  16742. i = index - width;
  16743. if (left) {
  16744. neighborsSignificance[i - 1] += 0x10;
  16745. }
  16746. if (right) {
  16747. neighborsSignificance[i + 1] += 0x10;
  16748. }
  16749. neighborsSignificance[i] += 0x04;
  16750. }
  16751. if (row + 1 < height) {
  16752. i = index + width;
  16753. if (left) {
  16754. neighborsSignificance[i - 1] += 0x10;
  16755. }
  16756. if (right) {
  16757. neighborsSignificance[i + 1] += 0x10;
  16758. }
  16759. neighborsSignificance[i] += 0x04;
  16760. }
  16761. if (left) {
  16762. neighborsSignificance[index - 1] += 0x01;
  16763. }
  16764. if (right) {
  16765. neighborsSignificance[index + 1] += 0x01;
  16766. }
  16767. neighborsSignificance[index] |= 0x80;
  16768. },
  16769. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16770. var decoder = this.decoder;
  16771. var width = this.width, height = this.height;
  16772. var coefficentsMagnitude = this.coefficentsMagnitude;
  16773. var coefficentsSign = this.coefficentsSign;
  16774. var neighborsSignificance = this.neighborsSignificance;
  16775. var processingFlags = this.processingFlags;
  16776. var contexts = this.contexts;
  16777. var labels = this.contextLabelTable;
  16778. var bitsDecoded = this.bitsDecoded;
  16779. var processedInverseMask = ~1;
  16780. var processedMask = 1;
  16781. var firstMagnitudeBitMask = 2;
  16782. for (var i0 = 0; i0 < height; i0 += 4) {
  16783. for (var j = 0; j < width; j++) {
  16784. var index = i0 * width + j;
  16785. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16786. var i = i0 + i1;
  16787. if (i >= height) {
  16788. break;
  16789. }
  16790. processingFlags[index] &= processedInverseMask;
  16791. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16792. continue;
  16793. }
  16794. var contextLabel = labels[neighborsSignificance[index]];
  16795. var decision = decoder.readBit(contexts, contextLabel);
  16796. if (decision) {
  16797. var sign = this.decodeSignBit(i, j, index);
  16798. coefficentsSign[index] = sign;
  16799. coefficentsMagnitude[index] = 1;
  16800. this.setNeighborsSignificance(i, j, index);
  16801. processingFlags[index] |= firstMagnitudeBitMask;
  16802. }
  16803. bitsDecoded[index]++;
  16804. processingFlags[index] |= processedMask;
  16805. }
  16806. }
  16807. }
  16808. },
  16809. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16810. var width = this.width, height = this.height;
  16811. var coefficentsMagnitude = this.coefficentsMagnitude;
  16812. var coefficentsSign = this.coefficentsSign;
  16813. var contribution, sign0, sign1, significance1;
  16814. var contextLabel, decoded;
  16815. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16816. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16817. sign1 = coefficentsSign[index + 1];
  16818. if (significance1) {
  16819. sign0 = coefficentsSign[index - 1];
  16820. contribution = 1 - sign1 - sign0;
  16821. } else {
  16822. contribution = 1 - sign1 - sign1;
  16823. }
  16824. } else if (significance1) {
  16825. sign0 = coefficentsSign[index - 1];
  16826. contribution = 1 - sign0 - sign0;
  16827. } else {
  16828. contribution = 0;
  16829. }
  16830. var horizontalContribution = 3 * contribution;
  16831. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16832. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16833. sign1 = coefficentsSign[index + width];
  16834. if (significance1) {
  16835. sign0 = coefficentsSign[index - width];
  16836. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16837. } else {
  16838. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16839. }
  16840. } else if (significance1) {
  16841. sign0 = coefficentsSign[index - width];
  16842. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16843. } else {
  16844. contribution = horizontalContribution;
  16845. }
  16846. if (contribution >= 0) {
  16847. contextLabel = 9 + contribution;
  16848. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16849. } else {
  16850. contextLabel = 9 - contribution;
  16851. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16852. }
  16853. return decoded;
  16854. },
  16855. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16856. var decoder = this.decoder;
  16857. var width = this.width, height = this.height;
  16858. var coefficentsMagnitude = this.coefficentsMagnitude;
  16859. var neighborsSignificance = this.neighborsSignificance;
  16860. var contexts = this.contexts;
  16861. var bitsDecoded = this.bitsDecoded;
  16862. var processingFlags = this.processingFlags;
  16863. var processedMask = 1;
  16864. var firstMagnitudeBitMask = 2;
  16865. var length = width * height;
  16866. var width4 = width * 4;
  16867. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16868. indexNext = Math.min(length, index0 + width4);
  16869. for (var j = 0; j < width; j++) {
  16870. for (var index = index0 + j; index < indexNext; index += width) {
  16871. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16872. continue;
  16873. }
  16874. var contextLabel = 16;
  16875. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16876. processingFlags[index] ^= firstMagnitudeBitMask;
  16877. var significance = neighborsSignificance[index] & 127;
  16878. contextLabel = significance === 0 ? 15 : 14;
  16879. }
  16880. var bit = decoder.readBit(contexts, contextLabel);
  16881. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16882. bitsDecoded[index]++;
  16883. processingFlags[index] |= processedMask;
  16884. }
  16885. }
  16886. }
  16887. },
  16888. runCleanupPass: function BitModel_runCleanupPass() {
  16889. var decoder = this.decoder;
  16890. var width = this.width, height = this.height;
  16891. var neighborsSignificance = this.neighborsSignificance;
  16892. var coefficentsMagnitude = this.coefficentsMagnitude;
  16893. var coefficentsSign = this.coefficentsSign;
  16894. var contexts = this.contexts;
  16895. var labels = this.contextLabelTable;
  16896. var bitsDecoded = this.bitsDecoded;
  16897. var processingFlags = this.processingFlags;
  16898. var processedMask = 1;
  16899. var firstMagnitudeBitMask = 2;
  16900. var oneRowDown = width;
  16901. var twoRowsDown = width * 2;
  16902. var threeRowsDown = width * 3;
  16903. var iNext;
  16904. for (var i0 = 0; i0 < height; i0 = iNext) {
  16905. iNext = Math.min(i0 + 4, height);
  16906. var indexBase = i0 * width;
  16907. var checkAllEmpty = i0 + 3 < height;
  16908. for (var j = 0; j < width; j++) {
  16909. var index0 = indexBase + j;
  16910. 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;
  16911. var i1 = 0, index = index0;
  16912. var i = i0, sign;
  16913. if (allEmpty) {
  16914. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  16915. if (!hasSignificantCoefficent) {
  16916. bitsDecoded[index0]++;
  16917. bitsDecoded[index0 + oneRowDown]++;
  16918. bitsDecoded[index0 + twoRowsDown]++;
  16919. bitsDecoded[index0 + threeRowsDown]++;
  16920. continue;
  16921. }
  16922. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  16923. if (i1 !== 0) {
  16924. i = i0 + i1;
  16925. index += i1 * width;
  16926. }
  16927. sign = this.decodeSignBit(i, j, index);
  16928. coefficentsSign[index] = sign;
  16929. coefficentsMagnitude[index] = 1;
  16930. this.setNeighborsSignificance(i, j, index);
  16931. processingFlags[index] |= firstMagnitudeBitMask;
  16932. index = index0;
  16933. for (var i2 = i0; i2 <= i; i2++, index += width) {
  16934. bitsDecoded[index]++;
  16935. }
  16936. i1++;
  16937. }
  16938. for (i = i0 + i1; i < iNext; i++, index += width) {
  16939. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16940. continue;
  16941. }
  16942. var contextLabel = labels[neighborsSignificance[index]];
  16943. var decision = decoder.readBit(contexts, contextLabel);
  16944. if (decision === 1) {
  16945. sign = this.decodeSignBit(i, j, index);
  16946. coefficentsSign[index] = sign;
  16947. coefficentsMagnitude[index] = 1;
  16948. this.setNeighborsSignificance(i, j, index);
  16949. processingFlags[index] |= firstMagnitudeBitMask;
  16950. }
  16951. bitsDecoded[index]++;
  16952. }
  16953. }
  16954. }
  16955. },
  16956. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  16957. var decoder = this.decoder;
  16958. var contexts = this.contexts;
  16959. 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);
  16960. if (symbol !== 0xA) {
  16961. error('JPX Error: Invalid segmentation symbol');
  16962. }
  16963. }
  16964. };
  16965. return BitModel;
  16966. }();
  16967. var Transform = function TransformClosure() {
  16968. function Transform() {
  16969. }
  16970. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  16971. var ll = subbands[0];
  16972. for (var i = 1, ii = subbands.length; i < ii; i++) {
  16973. ll = this.iterate(ll, subbands[i], u0, v0);
  16974. }
  16975. return ll;
  16976. };
  16977. Transform.prototype.extend = function extend(buffer, offset, size) {
  16978. var i1 = offset - 1, j1 = offset + 1;
  16979. var i2 = offset + size - 2, j2 = offset + size;
  16980. buffer[i1--] = buffer[j1++];
  16981. buffer[j2++] = buffer[i2--];
  16982. buffer[i1--] = buffer[j1++];
  16983. buffer[j2++] = buffer[i2--];
  16984. buffer[i1--] = buffer[j1++];
  16985. buffer[j2++] = buffer[i2--];
  16986. buffer[i1] = buffer[j1];
  16987. buffer[j2] = buffer[i2];
  16988. };
  16989. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  16990. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  16991. var width = hl_lh_hh.width;
  16992. var height = hl_lh_hh.height;
  16993. var items = hl_lh_hh.items;
  16994. var i, j, k, l, u, v;
  16995. for (k = 0, i = 0; i < llHeight; i++) {
  16996. l = i * 2 * width;
  16997. for (j = 0; j < llWidth; j++, k++, l += 2) {
  16998. items[l] = llItems[k];
  16999. }
  17000. }
  17001. llItems = ll.items = null;
  17002. var bufferPadding = 4;
  17003. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17004. if (width === 1) {
  17005. if ((u0 & 1) !== 0) {
  17006. for (v = 0, k = 0; v < height; v++, k += width) {
  17007. items[k] *= 0.5;
  17008. }
  17009. }
  17010. } else {
  17011. for (v = 0, k = 0; v < height; v++, k += width) {
  17012. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17013. this.extend(rowBuffer, bufferPadding, width);
  17014. this.filter(rowBuffer, bufferPadding, width);
  17015. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17016. }
  17017. }
  17018. var numBuffers = 16;
  17019. var colBuffers = [];
  17020. for (i = 0; i < numBuffers; i++) {
  17021. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17022. }
  17023. var b, currentBuffer = 0;
  17024. ll = bufferPadding + height;
  17025. if (height === 1) {
  17026. if ((v0 & 1) !== 0) {
  17027. for (u = 0; u < width; u++) {
  17028. items[u] *= 0.5;
  17029. }
  17030. }
  17031. } else {
  17032. for (u = 0; u < width; u++) {
  17033. if (currentBuffer === 0) {
  17034. numBuffers = Math.min(width - u, numBuffers);
  17035. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17036. for (b = 0; b < numBuffers; b++) {
  17037. colBuffers[b][l] = items[k + b];
  17038. }
  17039. }
  17040. currentBuffer = numBuffers;
  17041. }
  17042. currentBuffer--;
  17043. var buffer = colBuffers[currentBuffer];
  17044. this.extend(buffer, bufferPadding, height);
  17045. this.filter(buffer, bufferPadding, height);
  17046. if (currentBuffer === 0) {
  17047. k = u - numBuffers + 1;
  17048. for (l = bufferPadding; l < ll; k += width, l++) {
  17049. for (b = 0; b < numBuffers; b++) {
  17050. items[k + b] = colBuffers[b][l];
  17051. }
  17052. }
  17053. }
  17054. }
  17055. }
  17056. return {
  17057. width: width,
  17058. height: height,
  17059. items: items
  17060. };
  17061. };
  17062. return Transform;
  17063. }();
  17064. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17065. function IrreversibleTransform() {
  17066. Transform.call(this);
  17067. }
  17068. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17069. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17070. var len = length >> 1;
  17071. offset = offset | 0;
  17072. var j, n, current, next;
  17073. var alpha = -1.586134342059924;
  17074. var beta = -0.052980118572961;
  17075. var gamma = 0.882911075530934;
  17076. var delta = 0.443506852043971;
  17077. var K = 1.230174104914001;
  17078. var K_ = 1 / K;
  17079. j = offset - 3;
  17080. for (n = len + 4; n--; j += 2) {
  17081. x[j] *= K_;
  17082. }
  17083. j = offset - 2;
  17084. current = delta * x[j - 1];
  17085. for (n = len + 3; n--; j += 2) {
  17086. next = delta * x[j + 1];
  17087. x[j] = K * x[j] - current - next;
  17088. if (n--) {
  17089. j += 2;
  17090. current = delta * x[j + 1];
  17091. x[j] = K * x[j] - current - next;
  17092. } else {
  17093. break;
  17094. }
  17095. }
  17096. j = offset - 1;
  17097. current = gamma * x[j - 1];
  17098. for (n = len + 2; n--; j += 2) {
  17099. next = gamma * x[j + 1];
  17100. x[j] -= current + next;
  17101. if (n--) {
  17102. j += 2;
  17103. current = gamma * x[j + 1];
  17104. x[j] -= current + next;
  17105. } else {
  17106. break;
  17107. }
  17108. }
  17109. j = offset;
  17110. current = beta * x[j - 1];
  17111. for (n = len + 1; n--; j += 2) {
  17112. next = beta * x[j + 1];
  17113. x[j] -= current + next;
  17114. if (n--) {
  17115. j += 2;
  17116. current = beta * x[j + 1];
  17117. x[j] -= current + next;
  17118. } else {
  17119. break;
  17120. }
  17121. }
  17122. if (len !== 0) {
  17123. j = offset + 1;
  17124. current = alpha * x[j - 1];
  17125. for (n = len; n--; j += 2) {
  17126. next = alpha * x[j + 1];
  17127. x[j] -= current + next;
  17128. if (n--) {
  17129. j += 2;
  17130. current = alpha * x[j + 1];
  17131. x[j] -= current + next;
  17132. } else {
  17133. break;
  17134. }
  17135. }
  17136. }
  17137. };
  17138. return IrreversibleTransform;
  17139. }();
  17140. var ReversibleTransform = function ReversibleTransformClosure() {
  17141. function ReversibleTransform() {
  17142. Transform.call(this);
  17143. }
  17144. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17145. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17146. var len = length >> 1;
  17147. offset = offset | 0;
  17148. var j, n;
  17149. for (j = offset, n = len + 1; n--; j += 2) {
  17150. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17151. }
  17152. for (j = offset + 1, n = len; n--; j += 2) {
  17153. x[j] += x[j - 1] + x[j + 1] >> 1;
  17154. }
  17155. };
  17156. return ReversibleTransform;
  17157. }();
  17158. return JpxImage;
  17159. }();
  17160. exports.JpxImage = JpxImage;
  17161. }));
  17162. (function (root, factory) {
  17163. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17164. }(this, function (exports, sharedUtil) {
  17165. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17166. var getMetrics = getLookupTableFactory(function (t) {
  17167. t['Courier'] = 600;
  17168. t['Courier-Bold'] = 600;
  17169. t['Courier-BoldOblique'] = 600;
  17170. t['Courier-Oblique'] = 600;
  17171. t['Helvetica'] = getLookupTableFactory(function (t) {
  17172. t['space'] = 278;
  17173. t['exclam'] = 278;
  17174. t['quotedbl'] = 355;
  17175. t['numbersign'] = 556;
  17176. t['dollar'] = 556;
  17177. t['percent'] = 889;
  17178. t['ampersand'] = 667;
  17179. t['quoteright'] = 222;
  17180. t['parenleft'] = 333;
  17181. t['parenright'] = 333;
  17182. t['asterisk'] = 389;
  17183. t['plus'] = 584;
  17184. t['comma'] = 278;
  17185. t['hyphen'] = 333;
  17186. t['period'] = 278;
  17187. t['slash'] = 278;
  17188. t['zero'] = 556;
  17189. t['one'] = 556;
  17190. t['two'] = 556;
  17191. t['three'] = 556;
  17192. t['four'] = 556;
  17193. t['five'] = 556;
  17194. t['six'] = 556;
  17195. t['seven'] = 556;
  17196. t['eight'] = 556;
  17197. t['nine'] = 556;
  17198. t['colon'] = 278;
  17199. t['semicolon'] = 278;
  17200. t['less'] = 584;
  17201. t['equal'] = 584;
  17202. t['greater'] = 584;
  17203. t['question'] = 556;
  17204. t['at'] = 1015;
  17205. t['A'] = 667;
  17206. t['B'] = 667;
  17207. t['C'] = 722;
  17208. t['D'] = 722;
  17209. t['E'] = 667;
  17210. t['F'] = 611;
  17211. t['G'] = 778;
  17212. t['H'] = 722;
  17213. t['I'] = 278;
  17214. t['J'] = 500;
  17215. t['K'] = 667;
  17216. t['L'] = 556;
  17217. t['M'] = 833;
  17218. t['N'] = 722;
  17219. t['O'] = 778;
  17220. t['P'] = 667;
  17221. t['Q'] = 778;
  17222. t['R'] = 722;
  17223. t['S'] = 667;
  17224. t['T'] = 611;
  17225. t['U'] = 722;
  17226. t['V'] = 667;
  17227. t['W'] = 944;
  17228. t['X'] = 667;
  17229. t['Y'] = 667;
  17230. t['Z'] = 611;
  17231. t['bracketleft'] = 278;
  17232. t['backslash'] = 278;
  17233. t['bracketright'] = 278;
  17234. t['asciicircum'] = 469;
  17235. t['underscore'] = 556;
  17236. t['quoteleft'] = 222;
  17237. t['a'] = 556;
  17238. t['b'] = 556;
  17239. t['c'] = 500;
  17240. t['d'] = 556;
  17241. t['e'] = 556;
  17242. t['f'] = 278;
  17243. t['g'] = 556;
  17244. t['h'] = 556;
  17245. t['i'] = 222;
  17246. t['j'] = 222;
  17247. t['k'] = 500;
  17248. t['l'] = 222;
  17249. t['m'] = 833;
  17250. t['n'] = 556;
  17251. t['o'] = 556;
  17252. t['p'] = 556;
  17253. t['q'] = 556;
  17254. t['r'] = 333;
  17255. t['s'] = 500;
  17256. t['t'] = 278;
  17257. t['u'] = 556;
  17258. t['v'] = 500;
  17259. t['w'] = 722;
  17260. t['x'] = 500;
  17261. t['y'] = 500;
  17262. t['z'] = 500;
  17263. t['braceleft'] = 334;
  17264. t['bar'] = 260;
  17265. t['braceright'] = 334;
  17266. t['asciitilde'] = 584;
  17267. t['exclamdown'] = 333;
  17268. t['cent'] = 556;
  17269. t['sterling'] = 556;
  17270. t['fraction'] = 167;
  17271. t['yen'] = 556;
  17272. t['florin'] = 556;
  17273. t['section'] = 556;
  17274. t['currency'] = 556;
  17275. t['quotesingle'] = 191;
  17276. t['quotedblleft'] = 333;
  17277. t['guillemotleft'] = 556;
  17278. t['guilsinglleft'] = 333;
  17279. t['guilsinglright'] = 333;
  17280. t['fi'] = 500;
  17281. t['fl'] = 500;
  17282. t['endash'] = 556;
  17283. t['dagger'] = 556;
  17284. t['daggerdbl'] = 556;
  17285. t['periodcentered'] = 278;
  17286. t['paragraph'] = 537;
  17287. t['bullet'] = 350;
  17288. t['quotesinglbase'] = 222;
  17289. t['quotedblbase'] = 333;
  17290. t['quotedblright'] = 333;
  17291. t['guillemotright'] = 556;
  17292. t['ellipsis'] = 1000;
  17293. t['perthousand'] = 1000;
  17294. t['questiondown'] = 611;
  17295. t['grave'] = 333;
  17296. t['acute'] = 333;
  17297. t['circumflex'] = 333;
  17298. t['tilde'] = 333;
  17299. t['macron'] = 333;
  17300. t['breve'] = 333;
  17301. t['dotaccent'] = 333;
  17302. t['dieresis'] = 333;
  17303. t['ring'] = 333;
  17304. t['cedilla'] = 333;
  17305. t['hungarumlaut'] = 333;
  17306. t['ogonek'] = 333;
  17307. t['caron'] = 333;
  17308. t['emdash'] = 1000;
  17309. t['AE'] = 1000;
  17310. t['ordfeminine'] = 370;
  17311. t['Lslash'] = 556;
  17312. t['Oslash'] = 778;
  17313. t['OE'] = 1000;
  17314. t['ordmasculine'] = 365;
  17315. t['ae'] = 889;
  17316. t['dotlessi'] = 278;
  17317. t['lslash'] = 222;
  17318. t['oslash'] = 611;
  17319. t['oe'] = 944;
  17320. t['germandbls'] = 611;
  17321. t['Idieresis'] = 278;
  17322. t['eacute'] = 556;
  17323. t['abreve'] = 556;
  17324. t['uhungarumlaut'] = 556;
  17325. t['ecaron'] = 556;
  17326. t['Ydieresis'] = 667;
  17327. t['divide'] = 584;
  17328. t['Yacute'] = 667;
  17329. t['Acircumflex'] = 667;
  17330. t['aacute'] = 556;
  17331. t['Ucircumflex'] = 722;
  17332. t['yacute'] = 500;
  17333. t['scommaaccent'] = 500;
  17334. t['ecircumflex'] = 556;
  17335. t['Uring'] = 722;
  17336. t['Udieresis'] = 722;
  17337. t['aogonek'] = 556;
  17338. t['Uacute'] = 722;
  17339. t['uogonek'] = 556;
  17340. t['Edieresis'] = 667;
  17341. t['Dcroat'] = 722;
  17342. t['commaaccent'] = 250;
  17343. t['copyright'] = 737;
  17344. t['Emacron'] = 667;
  17345. t['ccaron'] = 500;
  17346. t['aring'] = 556;
  17347. t['Ncommaaccent'] = 722;
  17348. t['lacute'] = 222;
  17349. t['agrave'] = 556;
  17350. t['Tcommaaccent'] = 611;
  17351. t['Cacute'] = 722;
  17352. t['atilde'] = 556;
  17353. t['Edotaccent'] = 667;
  17354. t['scaron'] = 500;
  17355. t['scedilla'] = 500;
  17356. t['iacute'] = 278;
  17357. t['lozenge'] = 471;
  17358. t['Rcaron'] = 722;
  17359. t['Gcommaaccent'] = 778;
  17360. t['ucircumflex'] = 556;
  17361. t['acircumflex'] = 556;
  17362. t['Amacron'] = 667;
  17363. t['rcaron'] = 333;
  17364. t['ccedilla'] = 500;
  17365. t['Zdotaccent'] = 611;
  17366. t['Thorn'] = 667;
  17367. t['Omacron'] = 778;
  17368. t['Racute'] = 722;
  17369. t['Sacute'] = 667;
  17370. t['dcaron'] = 643;
  17371. t['Umacron'] = 722;
  17372. t['uring'] = 556;
  17373. t['threesuperior'] = 333;
  17374. t['Ograve'] = 778;
  17375. t['Agrave'] = 667;
  17376. t['Abreve'] = 667;
  17377. t['multiply'] = 584;
  17378. t['uacute'] = 556;
  17379. t['Tcaron'] = 611;
  17380. t['partialdiff'] = 476;
  17381. t['ydieresis'] = 500;
  17382. t['Nacute'] = 722;
  17383. t['icircumflex'] = 278;
  17384. t['Ecircumflex'] = 667;
  17385. t['adieresis'] = 556;
  17386. t['edieresis'] = 556;
  17387. t['cacute'] = 500;
  17388. t['nacute'] = 556;
  17389. t['umacron'] = 556;
  17390. t['Ncaron'] = 722;
  17391. t['Iacute'] = 278;
  17392. t['plusminus'] = 584;
  17393. t['brokenbar'] = 260;
  17394. t['registered'] = 737;
  17395. t['Gbreve'] = 778;
  17396. t['Idotaccent'] = 278;
  17397. t['summation'] = 600;
  17398. t['Egrave'] = 667;
  17399. t['racute'] = 333;
  17400. t['omacron'] = 556;
  17401. t['Zacute'] = 611;
  17402. t['Zcaron'] = 611;
  17403. t['greaterequal'] = 549;
  17404. t['Eth'] = 722;
  17405. t['Ccedilla'] = 722;
  17406. t['lcommaaccent'] = 222;
  17407. t['tcaron'] = 317;
  17408. t['eogonek'] = 556;
  17409. t['Uogonek'] = 722;
  17410. t['Aacute'] = 667;
  17411. t['Adieresis'] = 667;
  17412. t['egrave'] = 556;
  17413. t['zacute'] = 500;
  17414. t['iogonek'] = 222;
  17415. t['Oacute'] = 778;
  17416. t['oacute'] = 556;
  17417. t['amacron'] = 556;
  17418. t['sacute'] = 500;
  17419. t['idieresis'] = 278;
  17420. t['Ocircumflex'] = 778;
  17421. t['Ugrave'] = 722;
  17422. t['Delta'] = 612;
  17423. t['thorn'] = 556;
  17424. t['twosuperior'] = 333;
  17425. t['Odieresis'] = 778;
  17426. t['mu'] = 556;
  17427. t['igrave'] = 278;
  17428. t['ohungarumlaut'] = 556;
  17429. t['Eogonek'] = 667;
  17430. t['dcroat'] = 556;
  17431. t['threequarters'] = 834;
  17432. t['Scedilla'] = 667;
  17433. t['lcaron'] = 299;
  17434. t['Kcommaaccent'] = 667;
  17435. t['Lacute'] = 556;
  17436. t['trademark'] = 1000;
  17437. t['edotaccent'] = 556;
  17438. t['Igrave'] = 278;
  17439. t['Imacron'] = 278;
  17440. t['Lcaron'] = 556;
  17441. t['onehalf'] = 834;
  17442. t['lessequal'] = 549;
  17443. t['ocircumflex'] = 556;
  17444. t['ntilde'] = 556;
  17445. t['Uhungarumlaut'] = 722;
  17446. t['Eacute'] = 667;
  17447. t['emacron'] = 556;
  17448. t['gbreve'] = 556;
  17449. t['onequarter'] = 834;
  17450. t['Scaron'] = 667;
  17451. t['Scommaaccent'] = 667;
  17452. t['Ohungarumlaut'] = 778;
  17453. t['degree'] = 400;
  17454. t['ograve'] = 556;
  17455. t['Ccaron'] = 722;
  17456. t['ugrave'] = 556;
  17457. t['radical'] = 453;
  17458. t['Dcaron'] = 722;
  17459. t['rcommaaccent'] = 333;
  17460. t['Ntilde'] = 722;
  17461. t['otilde'] = 556;
  17462. t['Rcommaaccent'] = 722;
  17463. t['Lcommaaccent'] = 556;
  17464. t['Atilde'] = 667;
  17465. t['Aogonek'] = 667;
  17466. t['Aring'] = 667;
  17467. t['Otilde'] = 778;
  17468. t['zdotaccent'] = 500;
  17469. t['Ecaron'] = 667;
  17470. t['Iogonek'] = 278;
  17471. t['kcommaaccent'] = 500;
  17472. t['minus'] = 584;
  17473. t['Icircumflex'] = 278;
  17474. t['ncaron'] = 556;
  17475. t['tcommaaccent'] = 278;
  17476. t['logicalnot'] = 584;
  17477. t['odieresis'] = 556;
  17478. t['udieresis'] = 556;
  17479. t['notequal'] = 549;
  17480. t['gcommaaccent'] = 556;
  17481. t['eth'] = 556;
  17482. t['zcaron'] = 500;
  17483. t['ncommaaccent'] = 556;
  17484. t['onesuperior'] = 333;
  17485. t['imacron'] = 278;
  17486. t['Euro'] = 556;
  17487. });
  17488. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17489. t['space'] = 278;
  17490. t['exclam'] = 333;
  17491. t['quotedbl'] = 474;
  17492. t['numbersign'] = 556;
  17493. t['dollar'] = 556;
  17494. t['percent'] = 889;
  17495. t['ampersand'] = 722;
  17496. t['quoteright'] = 278;
  17497. t['parenleft'] = 333;
  17498. t['parenright'] = 333;
  17499. t['asterisk'] = 389;
  17500. t['plus'] = 584;
  17501. t['comma'] = 278;
  17502. t['hyphen'] = 333;
  17503. t['period'] = 278;
  17504. t['slash'] = 278;
  17505. t['zero'] = 556;
  17506. t['one'] = 556;
  17507. t['two'] = 556;
  17508. t['three'] = 556;
  17509. t['four'] = 556;
  17510. t['five'] = 556;
  17511. t['six'] = 556;
  17512. t['seven'] = 556;
  17513. t['eight'] = 556;
  17514. t['nine'] = 556;
  17515. t['colon'] = 333;
  17516. t['semicolon'] = 333;
  17517. t['less'] = 584;
  17518. t['equal'] = 584;
  17519. t['greater'] = 584;
  17520. t['question'] = 611;
  17521. t['at'] = 975;
  17522. t['A'] = 722;
  17523. t['B'] = 722;
  17524. t['C'] = 722;
  17525. t['D'] = 722;
  17526. t['E'] = 667;
  17527. t['F'] = 611;
  17528. t['G'] = 778;
  17529. t['H'] = 722;
  17530. t['I'] = 278;
  17531. t['J'] = 556;
  17532. t['K'] = 722;
  17533. t['L'] = 611;
  17534. t['M'] = 833;
  17535. t['N'] = 722;
  17536. t['O'] = 778;
  17537. t['P'] = 667;
  17538. t['Q'] = 778;
  17539. t['R'] = 722;
  17540. t['S'] = 667;
  17541. t['T'] = 611;
  17542. t['U'] = 722;
  17543. t['V'] = 667;
  17544. t['W'] = 944;
  17545. t['X'] = 667;
  17546. t['Y'] = 667;
  17547. t['Z'] = 611;
  17548. t['bracketleft'] = 333;
  17549. t['backslash'] = 278;
  17550. t['bracketright'] = 333;
  17551. t['asciicircum'] = 584;
  17552. t['underscore'] = 556;
  17553. t['quoteleft'] = 278;
  17554. t['a'] = 556;
  17555. t['b'] = 611;
  17556. t['c'] = 556;
  17557. t['d'] = 611;
  17558. t['e'] = 556;
  17559. t['f'] = 333;
  17560. t['g'] = 611;
  17561. t['h'] = 611;
  17562. t['i'] = 278;
  17563. t['j'] = 278;
  17564. t['k'] = 556;
  17565. t['l'] = 278;
  17566. t['m'] = 889;
  17567. t['n'] = 611;
  17568. t['o'] = 611;
  17569. t['p'] = 611;
  17570. t['q'] = 611;
  17571. t['r'] = 389;
  17572. t['s'] = 556;
  17573. t['t'] = 333;
  17574. t['u'] = 611;
  17575. t['v'] = 556;
  17576. t['w'] = 778;
  17577. t['x'] = 556;
  17578. t['y'] = 556;
  17579. t['z'] = 500;
  17580. t['braceleft'] = 389;
  17581. t['bar'] = 280;
  17582. t['braceright'] = 389;
  17583. t['asciitilde'] = 584;
  17584. t['exclamdown'] = 333;
  17585. t['cent'] = 556;
  17586. t['sterling'] = 556;
  17587. t['fraction'] = 167;
  17588. t['yen'] = 556;
  17589. t['florin'] = 556;
  17590. t['section'] = 556;
  17591. t['currency'] = 556;
  17592. t['quotesingle'] = 238;
  17593. t['quotedblleft'] = 500;
  17594. t['guillemotleft'] = 556;
  17595. t['guilsinglleft'] = 333;
  17596. t['guilsinglright'] = 333;
  17597. t['fi'] = 611;
  17598. t['fl'] = 611;
  17599. t['endash'] = 556;
  17600. t['dagger'] = 556;
  17601. t['daggerdbl'] = 556;
  17602. t['periodcentered'] = 278;
  17603. t['paragraph'] = 556;
  17604. t['bullet'] = 350;
  17605. t['quotesinglbase'] = 278;
  17606. t['quotedblbase'] = 500;
  17607. t['quotedblright'] = 500;
  17608. t['guillemotright'] = 556;
  17609. t['ellipsis'] = 1000;
  17610. t['perthousand'] = 1000;
  17611. t['questiondown'] = 611;
  17612. t['grave'] = 333;
  17613. t['acute'] = 333;
  17614. t['circumflex'] = 333;
  17615. t['tilde'] = 333;
  17616. t['macron'] = 333;
  17617. t['breve'] = 333;
  17618. t['dotaccent'] = 333;
  17619. t['dieresis'] = 333;
  17620. t['ring'] = 333;
  17621. t['cedilla'] = 333;
  17622. t['hungarumlaut'] = 333;
  17623. t['ogonek'] = 333;
  17624. t['caron'] = 333;
  17625. t['emdash'] = 1000;
  17626. t['AE'] = 1000;
  17627. t['ordfeminine'] = 370;
  17628. t['Lslash'] = 611;
  17629. t['Oslash'] = 778;
  17630. t['OE'] = 1000;
  17631. t['ordmasculine'] = 365;
  17632. t['ae'] = 889;
  17633. t['dotlessi'] = 278;
  17634. t['lslash'] = 278;
  17635. t['oslash'] = 611;
  17636. t['oe'] = 944;
  17637. t['germandbls'] = 611;
  17638. t['Idieresis'] = 278;
  17639. t['eacute'] = 556;
  17640. t['abreve'] = 556;
  17641. t['uhungarumlaut'] = 611;
  17642. t['ecaron'] = 556;
  17643. t['Ydieresis'] = 667;
  17644. t['divide'] = 584;
  17645. t['Yacute'] = 667;
  17646. t['Acircumflex'] = 722;
  17647. t['aacute'] = 556;
  17648. t['Ucircumflex'] = 722;
  17649. t['yacute'] = 556;
  17650. t['scommaaccent'] = 556;
  17651. t['ecircumflex'] = 556;
  17652. t['Uring'] = 722;
  17653. t['Udieresis'] = 722;
  17654. t['aogonek'] = 556;
  17655. t['Uacute'] = 722;
  17656. t['uogonek'] = 611;
  17657. t['Edieresis'] = 667;
  17658. t['Dcroat'] = 722;
  17659. t['commaaccent'] = 250;
  17660. t['copyright'] = 737;
  17661. t['Emacron'] = 667;
  17662. t['ccaron'] = 556;
  17663. t['aring'] = 556;
  17664. t['Ncommaaccent'] = 722;
  17665. t['lacute'] = 278;
  17666. t['agrave'] = 556;
  17667. t['Tcommaaccent'] = 611;
  17668. t['Cacute'] = 722;
  17669. t['atilde'] = 556;
  17670. t['Edotaccent'] = 667;
  17671. t['scaron'] = 556;
  17672. t['scedilla'] = 556;
  17673. t['iacute'] = 278;
  17674. t['lozenge'] = 494;
  17675. t['Rcaron'] = 722;
  17676. t['Gcommaaccent'] = 778;
  17677. t['ucircumflex'] = 611;
  17678. t['acircumflex'] = 556;
  17679. t['Amacron'] = 722;
  17680. t['rcaron'] = 389;
  17681. t['ccedilla'] = 556;
  17682. t['Zdotaccent'] = 611;
  17683. t['Thorn'] = 667;
  17684. t['Omacron'] = 778;
  17685. t['Racute'] = 722;
  17686. t['Sacute'] = 667;
  17687. t['dcaron'] = 743;
  17688. t['Umacron'] = 722;
  17689. t['uring'] = 611;
  17690. t['threesuperior'] = 333;
  17691. t['Ograve'] = 778;
  17692. t['Agrave'] = 722;
  17693. t['Abreve'] = 722;
  17694. t['multiply'] = 584;
  17695. t['uacute'] = 611;
  17696. t['Tcaron'] = 611;
  17697. t['partialdiff'] = 494;
  17698. t['ydieresis'] = 556;
  17699. t['Nacute'] = 722;
  17700. t['icircumflex'] = 278;
  17701. t['Ecircumflex'] = 667;
  17702. t['adieresis'] = 556;
  17703. t['edieresis'] = 556;
  17704. t['cacute'] = 556;
  17705. t['nacute'] = 611;
  17706. t['umacron'] = 611;
  17707. t['Ncaron'] = 722;
  17708. t['Iacute'] = 278;
  17709. t['plusminus'] = 584;
  17710. t['brokenbar'] = 280;
  17711. t['registered'] = 737;
  17712. t['Gbreve'] = 778;
  17713. t['Idotaccent'] = 278;
  17714. t['summation'] = 600;
  17715. t['Egrave'] = 667;
  17716. t['racute'] = 389;
  17717. t['omacron'] = 611;
  17718. t['Zacute'] = 611;
  17719. t['Zcaron'] = 611;
  17720. t['greaterequal'] = 549;
  17721. t['Eth'] = 722;
  17722. t['Ccedilla'] = 722;
  17723. t['lcommaaccent'] = 278;
  17724. t['tcaron'] = 389;
  17725. t['eogonek'] = 556;
  17726. t['Uogonek'] = 722;
  17727. t['Aacute'] = 722;
  17728. t['Adieresis'] = 722;
  17729. t['egrave'] = 556;
  17730. t['zacute'] = 500;
  17731. t['iogonek'] = 278;
  17732. t['Oacute'] = 778;
  17733. t['oacute'] = 611;
  17734. t['amacron'] = 556;
  17735. t['sacute'] = 556;
  17736. t['idieresis'] = 278;
  17737. t['Ocircumflex'] = 778;
  17738. t['Ugrave'] = 722;
  17739. t['Delta'] = 612;
  17740. t['thorn'] = 611;
  17741. t['twosuperior'] = 333;
  17742. t['Odieresis'] = 778;
  17743. t['mu'] = 611;
  17744. t['igrave'] = 278;
  17745. t['ohungarumlaut'] = 611;
  17746. t['Eogonek'] = 667;
  17747. t['dcroat'] = 611;
  17748. t['threequarters'] = 834;
  17749. t['Scedilla'] = 667;
  17750. t['lcaron'] = 400;
  17751. t['Kcommaaccent'] = 722;
  17752. t['Lacute'] = 611;
  17753. t['trademark'] = 1000;
  17754. t['edotaccent'] = 556;
  17755. t['Igrave'] = 278;
  17756. t['Imacron'] = 278;
  17757. t['Lcaron'] = 611;
  17758. t['onehalf'] = 834;
  17759. t['lessequal'] = 549;
  17760. t['ocircumflex'] = 611;
  17761. t['ntilde'] = 611;
  17762. t['Uhungarumlaut'] = 722;
  17763. t['Eacute'] = 667;
  17764. t['emacron'] = 556;
  17765. t['gbreve'] = 611;
  17766. t['onequarter'] = 834;
  17767. t['Scaron'] = 667;
  17768. t['Scommaaccent'] = 667;
  17769. t['Ohungarumlaut'] = 778;
  17770. t['degree'] = 400;
  17771. t['ograve'] = 611;
  17772. t['Ccaron'] = 722;
  17773. t['ugrave'] = 611;
  17774. t['radical'] = 549;
  17775. t['Dcaron'] = 722;
  17776. t['rcommaaccent'] = 389;
  17777. t['Ntilde'] = 722;
  17778. t['otilde'] = 611;
  17779. t['Rcommaaccent'] = 722;
  17780. t['Lcommaaccent'] = 611;
  17781. t['Atilde'] = 722;
  17782. t['Aogonek'] = 722;
  17783. t['Aring'] = 722;
  17784. t['Otilde'] = 778;
  17785. t['zdotaccent'] = 500;
  17786. t['Ecaron'] = 667;
  17787. t['Iogonek'] = 278;
  17788. t['kcommaaccent'] = 556;
  17789. t['minus'] = 584;
  17790. t['Icircumflex'] = 278;
  17791. t['ncaron'] = 611;
  17792. t['tcommaaccent'] = 333;
  17793. t['logicalnot'] = 584;
  17794. t['odieresis'] = 611;
  17795. t['udieresis'] = 611;
  17796. t['notequal'] = 549;
  17797. t['gcommaaccent'] = 611;
  17798. t['eth'] = 611;
  17799. t['zcaron'] = 500;
  17800. t['ncommaaccent'] = 611;
  17801. t['onesuperior'] = 333;
  17802. t['imacron'] = 278;
  17803. t['Euro'] = 556;
  17804. });
  17805. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17806. t['space'] = 278;
  17807. t['exclam'] = 333;
  17808. t['quotedbl'] = 474;
  17809. t['numbersign'] = 556;
  17810. t['dollar'] = 556;
  17811. t['percent'] = 889;
  17812. t['ampersand'] = 722;
  17813. t['quoteright'] = 278;
  17814. t['parenleft'] = 333;
  17815. t['parenright'] = 333;
  17816. t['asterisk'] = 389;
  17817. t['plus'] = 584;
  17818. t['comma'] = 278;
  17819. t['hyphen'] = 333;
  17820. t['period'] = 278;
  17821. t['slash'] = 278;
  17822. t['zero'] = 556;
  17823. t['one'] = 556;
  17824. t['two'] = 556;
  17825. t['three'] = 556;
  17826. t['four'] = 556;
  17827. t['five'] = 556;
  17828. t['six'] = 556;
  17829. t['seven'] = 556;
  17830. t['eight'] = 556;
  17831. t['nine'] = 556;
  17832. t['colon'] = 333;
  17833. t['semicolon'] = 333;
  17834. t['less'] = 584;
  17835. t['equal'] = 584;
  17836. t['greater'] = 584;
  17837. t['question'] = 611;
  17838. t['at'] = 975;
  17839. t['A'] = 722;
  17840. t['B'] = 722;
  17841. t['C'] = 722;
  17842. t['D'] = 722;
  17843. t['E'] = 667;
  17844. t['F'] = 611;
  17845. t['G'] = 778;
  17846. t['H'] = 722;
  17847. t['I'] = 278;
  17848. t['J'] = 556;
  17849. t['K'] = 722;
  17850. t['L'] = 611;
  17851. t['M'] = 833;
  17852. t['N'] = 722;
  17853. t['O'] = 778;
  17854. t['P'] = 667;
  17855. t['Q'] = 778;
  17856. t['R'] = 722;
  17857. t['S'] = 667;
  17858. t['T'] = 611;
  17859. t['U'] = 722;
  17860. t['V'] = 667;
  17861. t['W'] = 944;
  17862. t['X'] = 667;
  17863. t['Y'] = 667;
  17864. t['Z'] = 611;
  17865. t['bracketleft'] = 333;
  17866. t['backslash'] = 278;
  17867. t['bracketright'] = 333;
  17868. t['asciicircum'] = 584;
  17869. t['underscore'] = 556;
  17870. t['quoteleft'] = 278;
  17871. t['a'] = 556;
  17872. t['b'] = 611;
  17873. t['c'] = 556;
  17874. t['d'] = 611;
  17875. t['e'] = 556;
  17876. t['f'] = 333;
  17877. t['g'] = 611;
  17878. t['h'] = 611;
  17879. t['i'] = 278;
  17880. t['j'] = 278;
  17881. t['k'] = 556;
  17882. t['l'] = 278;
  17883. t['m'] = 889;
  17884. t['n'] = 611;
  17885. t['o'] = 611;
  17886. t['p'] = 611;
  17887. t['q'] = 611;
  17888. t['r'] = 389;
  17889. t['s'] = 556;
  17890. t['t'] = 333;
  17891. t['u'] = 611;
  17892. t['v'] = 556;
  17893. t['w'] = 778;
  17894. t['x'] = 556;
  17895. t['y'] = 556;
  17896. t['z'] = 500;
  17897. t['braceleft'] = 389;
  17898. t['bar'] = 280;
  17899. t['braceright'] = 389;
  17900. t['asciitilde'] = 584;
  17901. t['exclamdown'] = 333;
  17902. t['cent'] = 556;
  17903. t['sterling'] = 556;
  17904. t['fraction'] = 167;
  17905. t['yen'] = 556;
  17906. t['florin'] = 556;
  17907. t['section'] = 556;
  17908. t['currency'] = 556;
  17909. t['quotesingle'] = 238;
  17910. t['quotedblleft'] = 500;
  17911. t['guillemotleft'] = 556;
  17912. t['guilsinglleft'] = 333;
  17913. t['guilsinglright'] = 333;
  17914. t['fi'] = 611;
  17915. t['fl'] = 611;
  17916. t['endash'] = 556;
  17917. t['dagger'] = 556;
  17918. t['daggerdbl'] = 556;
  17919. t['periodcentered'] = 278;
  17920. t['paragraph'] = 556;
  17921. t['bullet'] = 350;
  17922. t['quotesinglbase'] = 278;
  17923. t['quotedblbase'] = 500;
  17924. t['quotedblright'] = 500;
  17925. t['guillemotright'] = 556;
  17926. t['ellipsis'] = 1000;
  17927. t['perthousand'] = 1000;
  17928. t['questiondown'] = 611;
  17929. t['grave'] = 333;
  17930. t['acute'] = 333;
  17931. t['circumflex'] = 333;
  17932. t['tilde'] = 333;
  17933. t['macron'] = 333;
  17934. t['breve'] = 333;
  17935. t['dotaccent'] = 333;
  17936. t['dieresis'] = 333;
  17937. t['ring'] = 333;
  17938. t['cedilla'] = 333;
  17939. t['hungarumlaut'] = 333;
  17940. t['ogonek'] = 333;
  17941. t['caron'] = 333;
  17942. t['emdash'] = 1000;
  17943. t['AE'] = 1000;
  17944. t['ordfeminine'] = 370;
  17945. t['Lslash'] = 611;
  17946. t['Oslash'] = 778;
  17947. t['OE'] = 1000;
  17948. t['ordmasculine'] = 365;
  17949. t['ae'] = 889;
  17950. t['dotlessi'] = 278;
  17951. t['lslash'] = 278;
  17952. t['oslash'] = 611;
  17953. t['oe'] = 944;
  17954. t['germandbls'] = 611;
  17955. t['Idieresis'] = 278;
  17956. t['eacute'] = 556;
  17957. t['abreve'] = 556;
  17958. t['uhungarumlaut'] = 611;
  17959. t['ecaron'] = 556;
  17960. t['Ydieresis'] = 667;
  17961. t['divide'] = 584;
  17962. t['Yacute'] = 667;
  17963. t['Acircumflex'] = 722;
  17964. t['aacute'] = 556;
  17965. t['Ucircumflex'] = 722;
  17966. t['yacute'] = 556;
  17967. t['scommaaccent'] = 556;
  17968. t['ecircumflex'] = 556;
  17969. t['Uring'] = 722;
  17970. t['Udieresis'] = 722;
  17971. t['aogonek'] = 556;
  17972. t['Uacute'] = 722;
  17973. t['uogonek'] = 611;
  17974. t['Edieresis'] = 667;
  17975. t['Dcroat'] = 722;
  17976. t['commaaccent'] = 250;
  17977. t['copyright'] = 737;
  17978. t['Emacron'] = 667;
  17979. t['ccaron'] = 556;
  17980. t['aring'] = 556;
  17981. t['Ncommaaccent'] = 722;
  17982. t['lacute'] = 278;
  17983. t['agrave'] = 556;
  17984. t['Tcommaaccent'] = 611;
  17985. t['Cacute'] = 722;
  17986. t['atilde'] = 556;
  17987. t['Edotaccent'] = 667;
  17988. t['scaron'] = 556;
  17989. t['scedilla'] = 556;
  17990. t['iacute'] = 278;
  17991. t['lozenge'] = 494;
  17992. t['Rcaron'] = 722;
  17993. t['Gcommaaccent'] = 778;
  17994. t['ucircumflex'] = 611;
  17995. t['acircumflex'] = 556;
  17996. t['Amacron'] = 722;
  17997. t['rcaron'] = 389;
  17998. t['ccedilla'] = 556;
  17999. t['Zdotaccent'] = 611;
  18000. t['Thorn'] = 667;
  18001. t['Omacron'] = 778;
  18002. t['Racute'] = 722;
  18003. t['Sacute'] = 667;
  18004. t['dcaron'] = 743;
  18005. t['Umacron'] = 722;
  18006. t['uring'] = 611;
  18007. t['threesuperior'] = 333;
  18008. t['Ograve'] = 778;
  18009. t['Agrave'] = 722;
  18010. t['Abreve'] = 722;
  18011. t['multiply'] = 584;
  18012. t['uacute'] = 611;
  18013. t['Tcaron'] = 611;
  18014. t['partialdiff'] = 494;
  18015. t['ydieresis'] = 556;
  18016. t['Nacute'] = 722;
  18017. t['icircumflex'] = 278;
  18018. t['Ecircumflex'] = 667;
  18019. t['adieresis'] = 556;
  18020. t['edieresis'] = 556;
  18021. t['cacute'] = 556;
  18022. t['nacute'] = 611;
  18023. t['umacron'] = 611;
  18024. t['Ncaron'] = 722;
  18025. t['Iacute'] = 278;
  18026. t['plusminus'] = 584;
  18027. t['brokenbar'] = 280;
  18028. t['registered'] = 737;
  18029. t['Gbreve'] = 778;
  18030. t['Idotaccent'] = 278;
  18031. t['summation'] = 600;
  18032. t['Egrave'] = 667;
  18033. t['racute'] = 389;
  18034. t['omacron'] = 611;
  18035. t['Zacute'] = 611;
  18036. t['Zcaron'] = 611;
  18037. t['greaterequal'] = 549;
  18038. t['Eth'] = 722;
  18039. t['Ccedilla'] = 722;
  18040. t['lcommaaccent'] = 278;
  18041. t['tcaron'] = 389;
  18042. t['eogonek'] = 556;
  18043. t['Uogonek'] = 722;
  18044. t['Aacute'] = 722;
  18045. t['Adieresis'] = 722;
  18046. t['egrave'] = 556;
  18047. t['zacute'] = 500;
  18048. t['iogonek'] = 278;
  18049. t['Oacute'] = 778;
  18050. t['oacute'] = 611;
  18051. t['amacron'] = 556;
  18052. t['sacute'] = 556;
  18053. t['idieresis'] = 278;
  18054. t['Ocircumflex'] = 778;
  18055. t['Ugrave'] = 722;
  18056. t['Delta'] = 612;
  18057. t['thorn'] = 611;
  18058. t['twosuperior'] = 333;
  18059. t['Odieresis'] = 778;
  18060. t['mu'] = 611;
  18061. t['igrave'] = 278;
  18062. t['ohungarumlaut'] = 611;
  18063. t['Eogonek'] = 667;
  18064. t['dcroat'] = 611;
  18065. t['threequarters'] = 834;
  18066. t['Scedilla'] = 667;
  18067. t['lcaron'] = 400;
  18068. t['Kcommaaccent'] = 722;
  18069. t['Lacute'] = 611;
  18070. t['trademark'] = 1000;
  18071. t['edotaccent'] = 556;
  18072. t['Igrave'] = 278;
  18073. t['Imacron'] = 278;
  18074. t['Lcaron'] = 611;
  18075. t['onehalf'] = 834;
  18076. t['lessequal'] = 549;
  18077. t['ocircumflex'] = 611;
  18078. t['ntilde'] = 611;
  18079. t['Uhungarumlaut'] = 722;
  18080. t['Eacute'] = 667;
  18081. t['emacron'] = 556;
  18082. t['gbreve'] = 611;
  18083. t['onequarter'] = 834;
  18084. t['Scaron'] = 667;
  18085. t['Scommaaccent'] = 667;
  18086. t['Ohungarumlaut'] = 778;
  18087. t['degree'] = 400;
  18088. t['ograve'] = 611;
  18089. t['Ccaron'] = 722;
  18090. t['ugrave'] = 611;
  18091. t['radical'] = 549;
  18092. t['Dcaron'] = 722;
  18093. t['rcommaaccent'] = 389;
  18094. t['Ntilde'] = 722;
  18095. t['otilde'] = 611;
  18096. t['Rcommaaccent'] = 722;
  18097. t['Lcommaaccent'] = 611;
  18098. t['Atilde'] = 722;
  18099. t['Aogonek'] = 722;
  18100. t['Aring'] = 722;
  18101. t['Otilde'] = 778;
  18102. t['zdotaccent'] = 500;
  18103. t['Ecaron'] = 667;
  18104. t['Iogonek'] = 278;
  18105. t['kcommaaccent'] = 556;
  18106. t['minus'] = 584;
  18107. t['Icircumflex'] = 278;
  18108. t['ncaron'] = 611;
  18109. t['tcommaaccent'] = 333;
  18110. t['logicalnot'] = 584;
  18111. t['odieresis'] = 611;
  18112. t['udieresis'] = 611;
  18113. t['notequal'] = 549;
  18114. t['gcommaaccent'] = 611;
  18115. t['eth'] = 611;
  18116. t['zcaron'] = 500;
  18117. t['ncommaaccent'] = 611;
  18118. t['onesuperior'] = 333;
  18119. t['imacron'] = 278;
  18120. t['Euro'] = 556;
  18121. });
  18122. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18123. t['space'] = 278;
  18124. t['exclam'] = 278;
  18125. t['quotedbl'] = 355;
  18126. t['numbersign'] = 556;
  18127. t['dollar'] = 556;
  18128. t['percent'] = 889;
  18129. t['ampersand'] = 667;
  18130. t['quoteright'] = 222;
  18131. t['parenleft'] = 333;
  18132. t['parenright'] = 333;
  18133. t['asterisk'] = 389;
  18134. t['plus'] = 584;
  18135. t['comma'] = 278;
  18136. t['hyphen'] = 333;
  18137. t['period'] = 278;
  18138. t['slash'] = 278;
  18139. t['zero'] = 556;
  18140. t['one'] = 556;
  18141. t['two'] = 556;
  18142. t['three'] = 556;
  18143. t['four'] = 556;
  18144. t['five'] = 556;
  18145. t['six'] = 556;
  18146. t['seven'] = 556;
  18147. t['eight'] = 556;
  18148. t['nine'] = 556;
  18149. t['colon'] = 278;
  18150. t['semicolon'] = 278;
  18151. t['less'] = 584;
  18152. t['equal'] = 584;
  18153. t['greater'] = 584;
  18154. t['question'] = 556;
  18155. t['at'] = 1015;
  18156. t['A'] = 667;
  18157. t['B'] = 667;
  18158. t['C'] = 722;
  18159. t['D'] = 722;
  18160. t['E'] = 667;
  18161. t['F'] = 611;
  18162. t['G'] = 778;
  18163. t['H'] = 722;
  18164. t['I'] = 278;
  18165. t['J'] = 500;
  18166. t['K'] = 667;
  18167. t['L'] = 556;
  18168. t['M'] = 833;
  18169. t['N'] = 722;
  18170. t['O'] = 778;
  18171. t['P'] = 667;
  18172. t['Q'] = 778;
  18173. t['R'] = 722;
  18174. t['S'] = 667;
  18175. t['T'] = 611;
  18176. t['U'] = 722;
  18177. t['V'] = 667;
  18178. t['W'] = 944;
  18179. t['X'] = 667;
  18180. t['Y'] = 667;
  18181. t['Z'] = 611;
  18182. t['bracketleft'] = 278;
  18183. t['backslash'] = 278;
  18184. t['bracketright'] = 278;
  18185. t['asciicircum'] = 469;
  18186. t['underscore'] = 556;
  18187. t['quoteleft'] = 222;
  18188. t['a'] = 556;
  18189. t['b'] = 556;
  18190. t['c'] = 500;
  18191. t['d'] = 556;
  18192. t['e'] = 556;
  18193. t['f'] = 278;
  18194. t['g'] = 556;
  18195. t['h'] = 556;
  18196. t['i'] = 222;
  18197. t['j'] = 222;
  18198. t['k'] = 500;
  18199. t['l'] = 222;
  18200. t['m'] = 833;
  18201. t['n'] = 556;
  18202. t['o'] = 556;
  18203. t['p'] = 556;
  18204. t['q'] = 556;
  18205. t['r'] = 333;
  18206. t['s'] = 500;
  18207. t['t'] = 278;
  18208. t['u'] = 556;
  18209. t['v'] = 500;
  18210. t['w'] = 722;
  18211. t['x'] = 500;
  18212. t['y'] = 500;
  18213. t['z'] = 500;
  18214. t['braceleft'] = 334;
  18215. t['bar'] = 260;
  18216. t['braceright'] = 334;
  18217. t['asciitilde'] = 584;
  18218. t['exclamdown'] = 333;
  18219. t['cent'] = 556;
  18220. t['sterling'] = 556;
  18221. t['fraction'] = 167;
  18222. t['yen'] = 556;
  18223. t['florin'] = 556;
  18224. t['section'] = 556;
  18225. t['currency'] = 556;
  18226. t['quotesingle'] = 191;
  18227. t['quotedblleft'] = 333;
  18228. t['guillemotleft'] = 556;
  18229. t['guilsinglleft'] = 333;
  18230. t['guilsinglright'] = 333;
  18231. t['fi'] = 500;
  18232. t['fl'] = 500;
  18233. t['endash'] = 556;
  18234. t['dagger'] = 556;
  18235. t['daggerdbl'] = 556;
  18236. t['periodcentered'] = 278;
  18237. t['paragraph'] = 537;
  18238. t['bullet'] = 350;
  18239. t['quotesinglbase'] = 222;
  18240. t['quotedblbase'] = 333;
  18241. t['quotedblright'] = 333;
  18242. t['guillemotright'] = 556;
  18243. t['ellipsis'] = 1000;
  18244. t['perthousand'] = 1000;
  18245. t['questiondown'] = 611;
  18246. t['grave'] = 333;
  18247. t['acute'] = 333;
  18248. t['circumflex'] = 333;
  18249. t['tilde'] = 333;
  18250. t['macron'] = 333;
  18251. t['breve'] = 333;
  18252. t['dotaccent'] = 333;
  18253. t['dieresis'] = 333;
  18254. t['ring'] = 333;
  18255. t['cedilla'] = 333;
  18256. t['hungarumlaut'] = 333;
  18257. t['ogonek'] = 333;
  18258. t['caron'] = 333;
  18259. t['emdash'] = 1000;
  18260. t['AE'] = 1000;
  18261. t['ordfeminine'] = 370;
  18262. t['Lslash'] = 556;
  18263. t['Oslash'] = 778;
  18264. t['OE'] = 1000;
  18265. t['ordmasculine'] = 365;
  18266. t['ae'] = 889;
  18267. t['dotlessi'] = 278;
  18268. t['lslash'] = 222;
  18269. t['oslash'] = 611;
  18270. t['oe'] = 944;
  18271. t['germandbls'] = 611;
  18272. t['Idieresis'] = 278;
  18273. t['eacute'] = 556;
  18274. t['abreve'] = 556;
  18275. t['uhungarumlaut'] = 556;
  18276. t['ecaron'] = 556;
  18277. t['Ydieresis'] = 667;
  18278. t['divide'] = 584;
  18279. t['Yacute'] = 667;
  18280. t['Acircumflex'] = 667;
  18281. t['aacute'] = 556;
  18282. t['Ucircumflex'] = 722;
  18283. t['yacute'] = 500;
  18284. t['scommaaccent'] = 500;
  18285. t['ecircumflex'] = 556;
  18286. t['Uring'] = 722;
  18287. t['Udieresis'] = 722;
  18288. t['aogonek'] = 556;
  18289. t['Uacute'] = 722;
  18290. t['uogonek'] = 556;
  18291. t['Edieresis'] = 667;
  18292. t['Dcroat'] = 722;
  18293. t['commaaccent'] = 250;
  18294. t['copyright'] = 737;
  18295. t['Emacron'] = 667;
  18296. t['ccaron'] = 500;
  18297. t['aring'] = 556;
  18298. t['Ncommaaccent'] = 722;
  18299. t['lacute'] = 222;
  18300. t['agrave'] = 556;
  18301. t['Tcommaaccent'] = 611;
  18302. t['Cacute'] = 722;
  18303. t['atilde'] = 556;
  18304. t['Edotaccent'] = 667;
  18305. t['scaron'] = 500;
  18306. t['scedilla'] = 500;
  18307. t['iacute'] = 278;
  18308. t['lozenge'] = 471;
  18309. t['Rcaron'] = 722;
  18310. t['Gcommaaccent'] = 778;
  18311. t['ucircumflex'] = 556;
  18312. t['acircumflex'] = 556;
  18313. t['Amacron'] = 667;
  18314. t['rcaron'] = 333;
  18315. t['ccedilla'] = 500;
  18316. t['Zdotaccent'] = 611;
  18317. t['Thorn'] = 667;
  18318. t['Omacron'] = 778;
  18319. t['Racute'] = 722;
  18320. t['Sacute'] = 667;
  18321. t['dcaron'] = 643;
  18322. t['Umacron'] = 722;
  18323. t['uring'] = 556;
  18324. t['threesuperior'] = 333;
  18325. t['Ograve'] = 778;
  18326. t['Agrave'] = 667;
  18327. t['Abreve'] = 667;
  18328. t['multiply'] = 584;
  18329. t['uacute'] = 556;
  18330. t['Tcaron'] = 611;
  18331. t['partialdiff'] = 476;
  18332. t['ydieresis'] = 500;
  18333. t['Nacute'] = 722;
  18334. t['icircumflex'] = 278;
  18335. t['Ecircumflex'] = 667;
  18336. t['adieresis'] = 556;
  18337. t['edieresis'] = 556;
  18338. t['cacute'] = 500;
  18339. t['nacute'] = 556;
  18340. t['umacron'] = 556;
  18341. t['Ncaron'] = 722;
  18342. t['Iacute'] = 278;
  18343. t['plusminus'] = 584;
  18344. t['brokenbar'] = 260;
  18345. t['registered'] = 737;
  18346. t['Gbreve'] = 778;
  18347. t['Idotaccent'] = 278;
  18348. t['summation'] = 600;
  18349. t['Egrave'] = 667;
  18350. t['racute'] = 333;
  18351. t['omacron'] = 556;
  18352. t['Zacute'] = 611;
  18353. t['Zcaron'] = 611;
  18354. t['greaterequal'] = 549;
  18355. t['Eth'] = 722;
  18356. t['Ccedilla'] = 722;
  18357. t['lcommaaccent'] = 222;
  18358. t['tcaron'] = 317;
  18359. t['eogonek'] = 556;
  18360. t['Uogonek'] = 722;
  18361. t['Aacute'] = 667;
  18362. t['Adieresis'] = 667;
  18363. t['egrave'] = 556;
  18364. t['zacute'] = 500;
  18365. t['iogonek'] = 222;
  18366. t['Oacute'] = 778;
  18367. t['oacute'] = 556;
  18368. t['amacron'] = 556;
  18369. t['sacute'] = 500;
  18370. t['idieresis'] = 278;
  18371. t['Ocircumflex'] = 778;
  18372. t['Ugrave'] = 722;
  18373. t['Delta'] = 612;
  18374. t['thorn'] = 556;
  18375. t['twosuperior'] = 333;
  18376. t['Odieresis'] = 778;
  18377. t['mu'] = 556;
  18378. t['igrave'] = 278;
  18379. t['ohungarumlaut'] = 556;
  18380. t['Eogonek'] = 667;
  18381. t['dcroat'] = 556;
  18382. t['threequarters'] = 834;
  18383. t['Scedilla'] = 667;
  18384. t['lcaron'] = 299;
  18385. t['Kcommaaccent'] = 667;
  18386. t['Lacute'] = 556;
  18387. t['trademark'] = 1000;
  18388. t['edotaccent'] = 556;
  18389. t['Igrave'] = 278;
  18390. t['Imacron'] = 278;
  18391. t['Lcaron'] = 556;
  18392. t['onehalf'] = 834;
  18393. t['lessequal'] = 549;
  18394. t['ocircumflex'] = 556;
  18395. t['ntilde'] = 556;
  18396. t['Uhungarumlaut'] = 722;
  18397. t['Eacute'] = 667;
  18398. t['emacron'] = 556;
  18399. t['gbreve'] = 556;
  18400. t['onequarter'] = 834;
  18401. t['Scaron'] = 667;
  18402. t['Scommaaccent'] = 667;
  18403. t['Ohungarumlaut'] = 778;
  18404. t['degree'] = 400;
  18405. t['ograve'] = 556;
  18406. t['Ccaron'] = 722;
  18407. t['ugrave'] = 556;
  18408. t['radical'] = 453;
  18409. t['Dcaron'] = 722;
  18410. t['rcommaaccent'] = 333;
  18411. t['Ntilde'] = 722;
  18412. t['otilde'] = 556;
  18413. t['Rcommaaccent'] = 722;
  18414. t['Lcommaaccent'] = 556;
  18415. t['Atilde'] = 667;
  18416. t['Aogonek'] = 667;
  18417. t['Aring'] = 667;
  18418. t['Otilde'] = 778;
  18419. t['zdotaccent'] = 500;
  18420. t['Ecaron'] = 667;
  18421. t['Iogonek'] = 278;
  18422. t['kcommaaccent'] = 500;
  18423. t['minus'] = 584;
  18424. t['Icircumflex'] = 278;
  18425. t['ncaron'] = 556;
  18426. t['tcommaaccent'] = 278;
  18427. t['logicalnot'] = 584;
  18428. t['odieresis'] = 556;
  18429. t['udieresis'] = 556;
  18430. t['notequal'] = 549;
  18431. t['gcommaaccent'] = 556;
  18432. t['eth'] = 556;
  18433. t['zcaron'] = 500;
  18434. t['ncommaaccent'] = 556;
  18435. t['onesuperior'] = 333;
  18436. t['imacron'] = 278;
  18437. t['Euro'] = 556;
  18438. });
  18439. t['Symbol'] = getLookupTableFactory(function (t) {
  18440. t['space'] = 250;
  18441. t['exclam'] = 333;
  18442. t['universal'] = 713;
  18443. t['numbersign'] = 500;
  18444. t['existential'] = 549;
  18445. t['percent'] = 833;
  18446. t['ampersand'] = 778;
  18447. t['suchthat'] = 439;
  18448. t['parenleft'] = 333;
  18449. t['parenright'] = 333;
  18450. t['asteriskmath'] = 500;
  18451. t['plus'] = 549;
  18452. t['comma'] = 250;
  18453. t['minus'] = 549;
  18454. t['period'] = 250;
  18455. t['slash'] = 278;
  18456. t['zero'] = 500;
  18457. t['one'] = 500;
  18458. t['two'] = 500;
  18459. t['three'] = 500;
  18460. t['four'] = 500;
  18461. t['five'] = 500;
  18462. t['six'] = 500;
  18463. t['seven'] = 500;
  18464. t['eight'] = 500;
  18465. t['nine'] = 500;
  18466. t['colon'] = 278;
  18467. t['semicolon'] = 278;
  18468. t['less'] = 549;
  18469. t['equal'] = 549;
  18470. t['greater'] = 549;
  18471. t['question'] = 444;
  18472. t['congruent'] = 549;
  18473. t['Alpha'] = 722;
  18474. t['Beta'] = 667;
  18475. t['Chi'] = 722;
  18476. t['Delta'] = 612;
  18477. t['Epsilon'] = 611;
  18478. t['Phi'] = 763;
  18479. t['Gamma'] = 603;
  18480. t['Eta'] = 722;
  18481. t['Iota'] = 333;
  18482. t['theta1'] = 631;
  18483. t['Kappa'] = 722;
  18484. t['Lambda'] = 686;
  18485. t['Mu'] = 889;
  18486. t['Nu'] = 722;
  18487. t['Omicron'] = 722;
  18488. t['Pi'] = 768;
  18489. t['Theta'] = 741;
  18490. t['Rho'] = 556;
  18491. t['Sigma'] = 592;
  18492. t['Tau'] = 611;
  18493. t['Upsilon'] = 690;
  18494. t['sigma1'] = 439;
  18495. t['Omega'] = 768;
  18496. t['Xi'] = 645;
  18497. t['Psi'] = 795;
  18498. t['Zeta'] = 611;
  18499. t['bracketleft'] = 333;
  18500. t['therefore'] = 863;
  18501. t['bracketright'] = 333;
  18502. t['perpendicular'] = 658;
  18503. t['underscore'] = 500;
  18504. t['radicalex'] = 500;
  18505. t['alpha'] = 631;
  18506. t['beta'] = 549;
  18507. t['chi'] = 549;
  18508. t['delta'] = 494;
  18509. t['epsilon'] = 439;
  18510. t['phi'] = 521;
  18511. t['gamma'] = 411;
  18512. t['eta'] = 603;
  18513. t['iota'] = 329;
  18514. t['phi1'] = 603;
  18515. t['kappa'] = 549;
  18516. t['lambda'] = 549;
  18517. t['mu'] = 576;
  18518. t['nu'] = 521;
  18519. t['omicron'] = 549;
  18520. t['pi'] = 549;
  18521. t['theta'] = 521;
  18522. t['rho'] = 549;
  18523. t['sigma'] = 603;
  18524. t['tau'] = 439;
  18525. t['upsilon'] = 576;
  18526. t['omega1'] = 713;
  18527. t['omega'] = 686;
  18528. t['xi'] = 493;
  18529. t['psi'] = 686;
  18530. t['zeta'] = 494;
  18531. t['braceleft'] = 480;
  18532. t['bar'] = 200;
  18533. t['braceright'] = 480;
  18534. t['similar'] = 549;
  18535. t['Euro'] = 750;
  18536. t['Upsilon1'] = 620;
  18537. t['minute'] = 247;
  18538. t['lessequal'] = 549;
  18539. t['fraction'] = 167;
  18540. t['infinity'] = 713;
  18541. t['florin'] = 500;
  18542. t['club'] = 753;
  18543. t['diamond'] = 753;
  18544. t['heart'] = 753;
  18545. t['spade'] = 753;
  18546. t['arrowboth'] = 1042;
  18547. t['arrowleft'] = 987;
  18548. t['arrowup'] = 603;
  18549. t['arrowright'] = 987;
  18550. t['arrowdown'] = 603;
  18551. t['degree'] = 400;
  18552. t['plusminus'] = 549;
  18553. t['second'] = 411;
  18554. t['greaterequal'] = 549;
  18555. t['multiply'] = 549;
  18556. t['proportional'] = 713;
  18557. t['partialdiff'] = 494;
  18558. t['bullet'] = 460;
  18559. t['divide'] = 549;
  18560. t['notequal'] = 549;
  18561. t['equivalence'] = 549;
  18562. t['approxequal'] = 549;
  18563. t['ellipsis'] = 1000;
  18564. t['arrowvertex'] = 603;
  18565. t['arrowhorizex'] = 1000;
  18566. t['carriagereturn'] = 658;
  18567. t['aleph'] = 823;
  18568. t['Ifraktur'] = 686;
  18569. t['Rfraktur'] = 795;
  18570. t['weierstrass'] = 987;
  18571. t['circlemultiply'] = 768;
  18572. t['circleplus'] = 768;
  18573. t['emptyset'] = 823;
  18574. t['intersection'] = 768;
  18575. t['union'] = 768;
  18576. t['propersuperset'] = 713;
  18577. t['reflexsuperset'] = 713;
  18578. t['notsubset'] = 713;
  18579. t['propersubset'] = 713;
  18580. t['reflexsubset'] = 713;
  18581. t['element'] = 713;
  18582. t['notelement'] = 713;
  18583. t['angle'] = 768;
  18584. t['gradient'] = 713;
  18585. t['registerserif'] = 790;
  18586. t['copyrightserif'] = 790;
  18587. t['trademarkserif'] = 890;
  18588. t['product'] = 823;
  18589. t['radical'] = 549;
  18590. t['dotmath'] = 250;
  18591. t['logicalnot'] = 713;
  18592. t['logicaland'] = 603;
  18593. t['logicalor'] = 603;
  18594. t['arrowdblboth'] = 1042;
  18595. t['arrowdblleft'] = 987;
  18596. t['arrowdblup'] = 603;
  18597. t['arrowdblright'] = 987;
  18598. t['arrowdbldown'] = 603;
  18599. t['lozenge'] = 494;
  18600. t['angleleft'] = 329;
  18601. t['registersans'] = 790;
  18602. t['copyrightsans'] = 790;
  18603. t['trademarksans'] = 786;
  18604. t['summation'] = 713;
  18605. t['parenlefttp'] = 384;
  18606. t['parenleftex'] = 384;
  18607. t['parenleftbt'] = 384;
  18608. t['bracketlefttp'] = 384;
  18609. t['bracketleftex'] = 384;
  18610. t['bracketleftbt'] = 384;
  18611. t['bracelefttp'] = 494;
  18612. t['braceleftmid'] = 494;
  18613. t['braceleftbt'] = 494;
  18614. t['braceex'] = 494;
  18615. t['angleright'] = 329;
  18616. t['integral'] = 274;
  18617. t['integraltp'] = 686;
  18618. t['integralex'] = 686;
  18619. t['integralbt'] = 686;
  18620. t['parenrighttp'] = 384;
  18621. t['parenrightex'] = 384;
  18622. t['parenrightbt'] = 384;
  18623. t['bracketrighttp'] = 384;
  18624. t['bracketrightex'] = 384;
  18625. t['bracketrightbt'] = 384;
  18626. t['bracerighttp'] = 494;
  18627. t['bracerightmid'] = 494;
  18628. t['bracerightbt'] = 494;
  18629. t['apple'] = 790;
  18630. });
  18631. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18632. t['space'] = 250;
  18633. t['exclam'] = 333;
  18634. t['quotedbl'] = 408;
  18635. t['numbersign'] = 500;
  18636. t['dollar'] = 500;
  18637. t['percent'] = 833;
  18638. t['ampersand'] = 778;
  18639. t['quoteright'] = 333;
  18640. t['parenleft'] = 333;
  18641. t['parenright'] = 333;
  18642. t['asterisk'] = 500;
  18643. t['plus'] = 564;
  18644. t['comma'] = 250;
  18645. t['hyphen'] = 333;
  18646. t['period'] = 250;
  18647. t['slash'] = 278;
  18648. t['zero'] = 500;
  18649. t['one'] = 500;
  18650. t['two'] = 500;
  18651. t['three'] = 500;
  18652. t['four'] = 500;
  18653. t['five'] = 500;
  18654. t['six'] = 500;
  18655. t['seven'] = 500;
  18656. t['eight'] = 500;
  18657. t['nine'] = 500;
  18658. t['colon'] = 278;
  18659. t['semicolon'] = 278;
  18660. t['less'] = 564;
  18661. t['equal'] = 564;
  18662. t['greater'] = 564;
  18663. t['question'] = 444;
  18664. t['at'] = 921;
  18665. t['A'] = 722;
  18666. t['B'] = 667;
  18667. t['C'] = 667;
  18668. t['D'] = 722;
  18669. t['E'] = 611;
  18670. t['F'] = 556;
  18671. t['G'] = 722;
  18672. t['H'] = 722;
  18673. t['I'] = 333;
  18674. t['J'] = 389;
  18675. t['K'] = 722;
  18676. t['L'] = 611;
  18677. t['M'] = 889;
  18678. t['N'] = 722;
  18679. t['O'] = 722;
  18680. t['P'] = 556;
  18681. t['Q'] = 722;
  18682. t['R'] = 667;
  18683. t['S'] = 556;
  18684. t['T'] = 611;
  18685. t['U'] = 722;
  18686. t['V'] = 722;
  18687. t['W'] = 944;
  18688. t['X'] = 722;
  18689. t['Y'] = 722;
  18690. t['Z'] = 611;
  18691. t['bracketleft'] = 333;
  18692. t['backslash'] = 278;
  18693. t['bracketright'] = 333;
  18694. t['asciicircum'] = 469;
  18695. t['underscore'] = 500;
  18696. t['quoteleft'] = 333;
  18697. t['a'] = 444;
  18698. t['b'] = 500;
  18699. t['c'] = 444;
  18700. t['d'] = 500;
  18701. t['e'] = 444;
  18702. t['f'] = 333;
  18703. t['g'] = 500;
  18704. t['h'] = 500;
  18705. t['i'] = 278;
  18706. t['j'] = 278;
  18707. t['k'] = 500;
  18708. t['l'] = 278;
  18709. t['m'] = 778;
  18710. t['n'] = 500;
  18711. t['o'] = 500;
  18712. t['p'] = 500;
  18713. t['q'] = 500;
  18714. t['r'] = 333;
  18715. t['s'] = 389;
  18716. t['t'] = 278;
  18717. t['u'] = 500;
  18718. t['v'] = 500;
  18719. t['w'] = 722;
  18720. t['x'] = 500;
  18721. t['y'] = 500;
  18722. t['z'] = 444;
  18723. t['braceleft'] = 480;
  18724. t['bar'] = 200;
  18725. t['braceright'] = 480;
  18726. t['asciitilde'] = 541;
  18727. t['exclamdown'] = 333;
  18728. t['cent'] = 500;
  18729. t['sterling'] = 500;
  18730. t['fraction'] = 167;
  18731. t['yen'] = 500;
  18732. t['florin'] = 500;
  18733. t['section'] = 500;
  18734. t['currency'] = 500;
  18735. t['quotesingle'] = 180;
  18736. t['quotedblleft'] = 444;
  18737. t['guillemotleft'] = 500;
  18738. t['guilsinglleft'] = 333;
  18739. t['guilsinglright'] = 333;
  18740. t['fi'] = 556;
  18741. t['fl'] = 556;
  18742. t['endash'] = 500;
  18743. t['dagger'] = 500;
  18744. t['daggerdbl'] = 500;
  18745. t['periodcentered'] = 250;
  18746. t['paragraph'] = 453;
  18747. t['bullet'] = 350;
  18748. t['quotesinglbase'] = 333;
  18749. t['quotedblbase'] = 444;
  18750. t['quotedblright'] = 444;
  18751. t['guillemotright'] = 500;
  18752. t['ellipsis'] = 1000;
  18753. t['perthousand'] = 1000;
  18754. t['questiondown'] = 444;
  18755. t['grave'] = 333;
  18756. t['acute'] = 333;
  18757. t['circumflex'] = 333;
  18758. t['tilde'] = 333;
  18759. t['macron'] = 333;
  18760. t['breve'] = 333;
  18761. t['dotaccent'] = 333;
  18762. t['dieresis'] = 333;
  18763. t['ring'] = 333;
  18764. t['cedilla'] = 333;
  18765. t['hungarumlaut'] = 333;
  18766. t['ogonek'] = 333;
  18767. t['caron'] = 333;
  18768. t['emdash'] = 1000;
  18769. t['AE'] = 889;
  18770. t['ordfeminine'] = 276;
  18771. t['Lslash'] = 611;
  18772. t['Oslash'] = 722;
  18773. t['OE'] = 889;
  18774. t['ordmasculine'] = 310;
  18775. t['ae'] = 667;
  18776. t['dotlessi'] = 278;
  18777. t['lslash'] = 278;
  18778. t['oslash'] = 500;
  18779. t['oe'] = 722;
  18780. t['germandbls'] = 500;
  18781. t['Idieresis'] = 333;
  18782. t['eacute'] = 444;
  18783. t['abreve'] = 444;
  18784. t['uhungarumlaut'] = 500;
  18785. t['ecaron'] = 444;
  18786. t['Ydieresis'] = 722;
  18787. t['divide'] = 564;
  18788. t['Yacute'] = 722;
  18789. t['Acircumflex'] = 722;
  18790. t['aacute'] = 444;
  18791. t['Ucircumflex'] = 722;
  18792. t['yacute'] = 500;
  18793. t['scommaaccent'] = 389;
  18794. t['ecircumflex'] = 444;
  18795. t['Uring'] = 722;
  18796. t['Udieresis'] = 722;
  18797. t['aogonek'] = 444;
  18798. t['Uacute'] = 722;
  18799. t['uogonek'] = 500;
  18800. t['Edieresis'] = 611;
  18801. t['Dcroat'] = 722;
  18802. t['commaaccent'] = 250;
  18803. t['copyright'] = 760;
  18804. t['Emacron'] = 611;
  18805. t['ccaron'] = 444;
  18806. t['aring'] = 444;
  18807. t['Ncommaaccent'] = 722;
  18808. t['lacute'] = 278;
  18809. t['agrave'] = 444;
  18810. t['Tcommaaccent'] = 611;
  18811. t['Cacute'] = 667;
  18812. t['atilde'] = 444;
  18813. t['Edotaccent'] = 611;
  18814. t['scaron'] = 389;
  18815. t['scedilla'] = 389;
  18816. t['iacute'] = 278;
  18817. t['lozenge'] = 471;
  18818. t['Rcaron'] = 667;
  18819. t['Gcommaaccent'] = 722;
  18820. t['ucircumflex'] = 500;
  18821. t['acircumflex'] = 444;
  18822. t['Amacron'] = 722;
  18823. t['rcaron'] = 333;
  18824. t['ccedilla'] = 444;
  18825. t['Zdotaccent'] = 611;
  18826. t['Thorn'] = 556;
  18827. t['Omacron'] = 722;
  18828. t['Racute'] = 667;
  18829. t['Sacute'] = 556;
  18830. t['dcaron'] = 588;
  18831. t['Umacron'] = 722;
  18832. t['uring'] = 500;
  18833. t['threesuperior'] = 300;
  18834. t['Ograve'] = 722;
  18835. t['Agrave'] = 722;
  18836. t['Abreve'] = 722;
  18837. t['multiply'] = 564;
  18838. t['uacute'] = 500;
  18839. t['Tcaron'] = 611;
  18840. t['partialdiff'] = 476;
  18841. t['ydieresis'] = 500;
  18842. t['Nacute'] = 722;
  18843. t['icircumflex'] = 278;
  18844. t['Ecircumflex'] = 611;
  18845. t['adieresis'] = 444;
  18846. t['edieresis'] = 444;
  18847. t['cacute'] = 444;
  18848. t['nacute'] = 500;
  18849. t['umacron'] = 500;
  18850. t['Ncaron'] = 722;
  18851. t['Iacute'] = 333;
  18852. t['plusminus'] = 564;
  18853. t['brokenbar'] = 200;
  18854. t['registered'] = 760;
  18855. t['Gbreve'] = 722;
  18856. t['Idotaccent'] = 333;
  18857. t['summation'] = 600;
  18858. t['Egrave'] = 611;
  18859. t['racute'] = 333;
  18860. t['omacron'] = 500;
  18861. t['Zacute'] = 611;
  18862. t['Zcaron'] = 611;
  18863. t['greaterequal'] = 549;
  18864. t['Eth'] = 722;
  18865. t['Ccedilla'] = 667;
  18866. t['lcommaaccent'] = 278;
  18867. t['tcaron'] = 326;
  18868. t['eogonek'] = 444;
  18869. t['Uogonek'] = 722;
  18870. t['Aacute'] = 722;
  18871. t['Adieresis'] = 722;
  18872. t['egrave'] = 444;
  18873. t['zacute'] = 444;
  18874. t['iogonek'] = 278;
  18875. t['Oacute'] = 722;
  18876. t['oacute'] = 500;
  18877. t['amacron'] = 444;
  18878. t['sacute'] = 389;
  18879. t['idieresis'] = 278;
  18880. t['Ocircumflex'] = 722;
  18881. t['Ugrave'] = 722;
  18882. t['Delta'] = 612;
  18883. t['thorn'] = 500;
  18884. t['twosuperior'] = 300;
  18885. t['Odieresis'] = 722;
  18886. t['mu'] = 500;
  18887. t['igrave'] = 278;
  18888. t['ohungarumlaut'] = 500;
  18889. t['Eogonek'] = 611;
  18890. t['dcroat'] = 500;
  18891. t['threequarters'] = 750;
  18892. t['Scedilla'] = 556;
  18893. t['lcaron'] = 344;
  18894. t['Kcommaaccent'] = 722;
  18895. t['Lacute'] = 611;
  18896. t['trademark'] = 980;
  18897. t['edotaccent'] = 444;
  18898. t['Igrave'] = 333;
  18899. t['Imacron'] = 333;
  18900. t['Lcaron'] = 611;
  18901. t['onehalf'] = 750;
  18902. t['lessequal'] = 549;
  18903. t['ocircumflex'] = 500;
  18904. t['ntilde'] = 500;
  18905. t['Uhungarumlaut'] = 722;
  18906. t['Eacute'] = 611;
  18907. t['emacron'] = 444;
  18908. t['gbreve'] = 500;
  18909. t['onequarter'] = 750;
  18910. t['Scaron'] = 556;
  18911. t['Scommaaccent'] = 556;
  18912. t['Ohungarumlaut'] = 722;
  18913. t['degree'] = 400;
  18914. t['ograve'] = 500;
  18915. t['Ccaron'] = 667;
  18916. t['ugrave'] = 500;
  18917. t['radical'] = 453;
  18918. t['Dcaron'] = 722;
  18919. t['rcommaaccent'] = 333;
  18920. t['Ntilde'] = 722;
  18921. t['otilde'] = 500;
  18922. t['Rcommaaccent'] = 667;
  18923. t['Lcommaaccent'] = 611;
  18924. t['Atilde'] = 722;
  18925. t['Aogonek'] = 722;
  18926. t['Aring'] = 722;
  18927. t['Otilde'] = 722;
  18928. t['zdotaccent'] = 444;
  18929. t['Ecaron'] = 611;
  18930. t['Iogonek'] = 333;
  18931. t['kcommaaccent'] = 500;
  18932. t['minus'] = 564;
  18933. t['Icircumflex'] = 333;
  18934. t['ncaron'] = 500;
  18935. t['tcommaaccent'] = 278;
  18936. t['logicalnot'] = 564;
  18937. t['odieresis'] = 500;
  18938. t['udieresis'] = 500;
  18939. t['notequal'] = 549;
  18940. t['gcommaaccent'] = 500;
  18941. t['eth'] = 500;
  18942. t['zcaron'] = 444;
  18943. t['ncommaaccent'] = 500;
  18944. t['onesuperior'] = 300;
  18945. t['imacron'] = 278;
  18946. t['Euro'] = 500;
  18947. });
  18948. t['Times-Bold'] = getLookupTableFactory(function (t) {
  18949. t['space'] = 250;
  18950. t['exclam'] = 333;
  18951. t['quotedbl'] = 555;
  18952. t['numbersign'] = 500;
  18953. t['dollar'] = 500;
  18954. t['percent'] = 1000;
  18955. t['ampersand'] = 833;
  18956. t['quoteright'] = 333;
  18957. t['parenleft'] = 333;
  18958. t['parenright'] = 333;
  18959. t['asterisk'] = 500;
  18960. t['plus'] = 570;
  18961. t['comma'] = 250;
  18962. t['hyphen'] = 333;
  18963. t['period'] = 250;
  18964. t['slash'] = 278;
  18965. t['zero'] = 500;
  18966. t['one'] = 500;
  18967. t['two'] = 500;
  18968. t['three'] = 500;
  18969. t['four'] = 500;
  18970. t['five'] = 500;
  18971. t['six'] = 500;
  18972. t['seven'] = 500;
  18973. t['eight'] = 500;
  18974. t['nine'] = 500;
  18975. t['colon'] = 333;
  18976. t['semicolon'] = 333;
  18977. t['less'] = 570;
  18978. t['equal'] = 570;
  18979. t['greater'] = 570;
  18980. t['question'] = 500;
  18981. t['at'] = 930;
  18982. t['A'] = 722;
  18983. t['B'] = 667;
  18984. t['C'] = 722;
  18985. t['D'] = 722;
  18986. t['E'] = 667;
  18987. t['F'] = 611;
  18988. t['G'] = 778;
  18989. t['H'] = 778;
  18990. t['I'] = 389;
  18991. t['J'] = 500;
  18992. t['K'] = 778;
  18993. t['L'] = 667;
  18994. t['M'] = 944;
  18995. t['N'] = 722;
  18996. t['O'] = 778;
  18997. t['P'] = 611;
  18998. t['Q'] = 778;
  18999. t['R'] = 722;
  19000. t['S'] = 556;
  19001. t['T'] = 667;
  19002. t['U'] = 722;
  19003. t['V'] = 722;
  19004. t['W'] = 1000;
  19005. t['X'] = 722;
  19006. t['Y'] = 722;
  19007. t['Z'] = 667;
  19008. t['bracketleft'] = 333;
  19009. t['backslash'] = 278;
  19010. t['bracketright'] = 333;
  19011. t['asciicircum'] = 581;
  19012. t['underscore'] = 500;
  19013. t['quoteleft'] = 333;
  19014. t['a'] = 500;
  19015. t['b'] = 556;
  19016. t['c'] = 444;
  19017. t['d'] = 556;
  19018. t['e'] = 444;
  19019. t['f'] = 333;
  19020. t['g'] = 500;
  19021. t['h'] = 556;
  19022. t['i'] = 278;
  19023. t['j'] = 333;
  19024. t['k'] = 556;
  19025. t['l'] = 278;
  19026. t['m'] = 833;
  19027. t['n'] = 556;
  19028. t['o'] = 500;
  19029. t['p'] = 556;
  19030. t['q'] = 556;
  19031. t['r'] = 444;
  19032. t['s'] = 389;
  19033. t['t'] = 333;
  19034. t['u'] = 556;
  19035. t['v'] = 500;
  19036. t['w'] = 722;
  19037. t['x'] = 500;
  19038. t['y'] = 500;
  19039. t['z'] = 444;
  19040. t['braceleft'] = 394;
  19041. t['bar'] = 220;
  19042. t['braceright'] = 394;
  19043. t['asciitilde'] = 520;
  19044. t['exclamdown'] = 333;
  19045. t['cent'] = 500;
  19046. t['sterling'] = 500;
  19047. t['fraction'] = 167;
  19048. t['yen'] = 500;
  19049. t['florin'] = 500;
  19050. t['section'] = 500;
  19051. t['currency'] = 500;
  19052. t['quotesingle'] = 278;
  19053. t['quotedblleft'] = 500;
  19054. t['guillemotleft'] = 500;
  19055. t['guilsinglleft'] = 333;
  19056. t['guilsinglright'] = 333;
  19057. t['fi'] = 556;
  19058. t['fl'] = 556;
  19059. t['endash'] = 500;
  19060. t['dagger'] = 500;
  19061. t['daggerdbl'] = 500;
  19062. t['periodcentered'] = 250;
  19063. t['paragraph'] = 540;
  19064. t['bullet'] = 350;
  19065. t['quotesinglbase'] = 333;
  19066. t['quotedblbase'] = 500;
  19067. t['quotedblright'] = 500;
  19068. t['guillemotright'] = 500;
  19069. t['ellipsis'] = 1000;
  19070. t['perthousand'] = 1000;
  19071. t['questiondown'] = 500;
  19072. t['grave'] = 333;
  19073. t['acute'] = 333;
  19074. t['circumflex'] = 333;
  19075. t['tilde'] = 333;
  19076. t['macron'] = 333;
  19077. t['breve'] = 333;
  19078. t['dotaccent'] = 333;
  19079. t['dieresis'] = 333;
  19080. t['ring'] = 333;
  19081. t['cedilla'] = 333;
  19082. t['hungarumlaut'] = 333;
  19083. t['ogonek'] = 333;
  19084. t['caron'] = 333;
  19085. t['emdash'] = 1000;
  19086. t['AE'] = 1000;
  19087. t['ordfeminine'] = 300;
  19088. t['Lslash'] = 667;
  19089. t['Oslash'] = 778;
  19090. t['OE'] = 1000;
  19091. t['ordmasculine'] = 330;
  19092. t['ae'] = 722;
  19093. t['dotlessi'] = 278;
  19094. t['lslash'] = 278;
  19095. t['oslash'] = 500;
  19096. t['oe'] = 722;
  19097. t['germandbls'] = 556;
  19098. t['Idieresis'] = 389;
  19099. t['eacute'] = 444;
  19100. t['abreve'] = 500;
  19101. t['uhungarumlaut'] = 556;
  19102. t['ecaron'] = 444;
  19103. t['Ydieresis'] = 722;
  19104. t['divide'] = 570;
  19105. t['Yacute'] = 722;
  19106. t['Acircumflex'] = 722;
  19107. t['aacute'] = 500;
  19108. t['Ucircumflex'] = 722;
  19109. t['yacute'] = 500;
  19110. t['scommaaccent'] = 389;
  19111. t['ecircumflex'] = 444;
  19112. t['Uring'] = 722;
  19113. t['Udieresis'] = 722;
  19114. t['aogonek'] = 500;
  19115. t['Uacute'] = 722;
  19116. t['uogonek'] = 556;
  19117. t['Edieresis'] = 667;
  19118. t['Dcroat'] = 722;
  19119. t['commaaccent'] = 250;
  19120. t['copyright'] = 747;
  19121. t['Emacron'] = 667;
  19122. t['ccaron'] = 444;
  19123. t['aring'] = 500;
  19124. t['Ncommaaccent'] = 722;
  19125. t['lacute'] = 278;
  19126. t['agrave'] = 500;
  19127. t['Tcommaaccent'] = 667;
  19128. t['Cacute'] = 722;
  19129. t['atilde'] = 500;
  19130. t['Edotaccent'] = 667;
  19131. t['scaron'] = 389;
  19132. t['scedilla'] = 389;
  19133. t['iacute'] = 278;
  19134. t['lozenge'] = 494;
  19135. t['Rcaron'] = 722;
  19136. t['Gcommaaccent'] = 778;
  19137. t['ucircumflex'] = 556;
  19138. t['acircumflex'] = 500;
  19139. t['Amacron'] = 722;
  19140. t['rcaron'] = 444;
  19141. t['ccedilla'] = 444;
  19142. t['Zdotaccent'] = 667;
  19143. t['Thorn'] = 611;
  19144. t['Omacron'] = 778;
  19145. t['Racute'] = 722;
  19146. t['Sacute'] = 556;
  19147. t['dcaron'] = 672;
  19148. t['Umacron'] = 722;
  19149. t['uring'] = 556;
  19150. t['threesuperior'] = 300;
  19151. t['Ograve'] = 778;
  19152. t['Agrave'] = 722;
  19153. t['Abreve'] = 722;
  19154. t['multiply'] = 570;
  19155. t['uacute'] = 556;
  19156. t['Tcaron'] = 667;
  19157. t['partialdiff'] = 494;
  19158. t['ydieresis'] = 500;
  19159. t['Nacute'] = 722;
  19160. t['icircumflex'] = 278;
  19161. t['Ecircumflex'] = 667;
  19162. t['adieresis'] = 500;
  19163. t['edieresis'] = 444;
  19164. t['cacute'] = 444;
  19165. t['nacute'] = 556;
  19166. t['umacron'] = 556;
  19167. t['Ncaron'] = 722;
  19168. t['Iacute'] = 389;
  19169. t['plusminus'] = 570;
  19170. t['brokenbar'] = 220;
  19171. t['registered'] = 747;
  19172. t['Gbreve'] = 778;
  19173. t['Idotaccent'] = 389;
  19174. t['summation'] = 600;
  19175. t['Egrave'] = 667;
  19176. t['racute'] = 444;
  19177. t['omacron'] = 500;
  19178. t['Zacute'] = 667;
  19179. t['Zcaron'] = 667;
  19180. t['greaterequal'] = 549;
  19181. t['Eth'] = 722;
  19182. t['Ccedilla'] = 722;
  19183. t['lcommaaccent'] = 278;
  19184. t['tcaron'] = 416;
  19185. t['eogonek'] = 444;
  19186. t['Uogonek'] = 722;
  19187. t['Aacute'] = 722;
  19188. t['Adieresis'] = 722;
  19189. t['egrave'] = 444;
  19190. t['zacute'] = 444;
  19191. t['iogonek'] = 278;
  19192. t['Oacute'] = 778;
  19193. t['oacute'] = 500;
  19194. t['amacron'] = 500;
  19195. t['sacute'] = 389;
  19196. t['idieresis'] = 278;
  19197. t['Ocircumflex'] = 778;
  19198. t['Ugrave'] = 722;
  19199. t['Delta'] = 612;
  19200. t['thorn'] = 556;
  19201. t['twosuperior'] = 300;
  19202. t['Odieresis'] = 778;
  19203. t['mu'] = 556;
  19204. t['igrave'] = 278;
  19205. t['ohungarumlaut'] = 500;
  19206. t['Eogonek'] = 667;
  19207. t['dcroat'] = 556;
  19208. t['threequarters'] = 750;
  19209. t['Scedilla'] = 556;
  19210. t['lcaron'] = 394;
  19211. t['Kcommaaccent'] = 778;
  19212. t['Lacute'] = 667;
  19213. t['trademark'] = 1000;
  19214. t['edotaccent'] = 444;
  19215. t['Igrave'] = 389;
  19216. t['Imacron'] = 389;
  19217. t['Lcaron'] = 667;
  19218. t['onehalf'] = 750;
  19219. t['lessequal'] = 549;
  19220. t['ocircumflex'] = 500;
  19221. t['ntilde'] = 556;
  19222. t['Uhungarumlaut'] = 722;
  19223. t['Eacute'] = 667;
  19224. t['emacron'] = 444;
  19225. t['gbreve'] = 500;
  19226. t['onequarter'] = 750;
  19227. t['Scaron'] = 556;
  19228. t['Scommaaccent'] = 556;
  19229. t['Ohungarumlaut'] = 778;
  19230. t['degree'] = 400;
  19231. t['ograve'] = 500;
  19232. t['Ccaron'] = 722;
  19233. t['ugrave'] = 556;
  19234. t['radical'] = 549;
  19235. t['Dcaron'] = 722;
  19236. t['rcommaaccent'] = 444;
  19237. t['Ntilde'] = 722;
  19238. t['otilde'] = 500;
  19239. t['Rcommaaccent'] = 722;
  19240. t['Lcommaaccent'] = 667;
  19241. t['Atilde'] = 722;
  19242. t['Aogonek'] = 722;
  19243. t['Aring'] = 722;
  19244. t['Otilde'] = 778;
  19245. t['zdotaccent'] = 444;
  19246. t['Ecaron'] = 667;
  19247. t['Iogonek'] = 389;
  19248. t['kcommaaccent'] = 556;
  19249. t['minus'] = 570;
  19250. t['Icircumflex'] = 389;
  19251. t['ncaron'] = 556;
  19252. t['tcommaaccent'] = 333;
  19253. t['logicalnot'] = 570;
  19254. t['odieresis'] = 500;
  19255. t['udieresis'] = 556;
  19256. t['notequal'] = 549;
  19257. t['gcommaaccent'] = 500;
  19258. t['eth'] = 500;
  19259. t['zcaron'] = 444;
  19260. t['ncommaaccent'] = 556;
  19261. t['onesuperior'] = 300;
  19262. t['imacron'] = 278;
  19263. t['Euro'] = 500;
  19264. });
  19265. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19266. t['space'] = 250;
  19267. t['exclam'] = 389;
  19268. t['quotedbl'] = 555;
  19269. t['numbersign'] = 500;
  19270. t['dollar'] = 500;
  19271. t['percent'] = 833;
  19272. t['ampersand'] = 778;
  19273. t['quoteright'] = 333;
  19274. t['parenleft'] = 333;
  19275. t['parenright'] = 333;
  19276. t['asterisk'] = 500;
  19277. t['plus'] = 570;
  19278. t['comma'] = 250;
  19279. t['hyphen'] = 333;
  19280. t['period'] = 250;
  19281. t['slash'] = 278;
  19282. t['zero'] = 500;
  19283. t['one'] = 500;
  19284. t['two'] = 500;
  19285. t['three'] = 500;
  19286. t['four'] = 500;
  19287. t['five'] = 500;
  19288. t['six'] = 500;
  19289. t['seven'] = 500;
  19290. t['eight'] = 500;
  19291. t['nine'] = 500;
  19292. t['colon'] = 333;
  19293. t['semicolon'] = 333;
  19294. t['less'] = 570;
  19295. t['equal'] = 570;
  19296. t['greater'] = 570;
  19297. t['question'] = 500;
  19298. t['at'] = 832;
  19299. t['A'] = 667;
  19300. t['B'] = 667;
  19301. t['C'] = 667;
  19302. t['D'] = 722;
  19303. t['E'] = 667;
  19304. t['F'] = 667;
  19305. t['G'] = 722;
  19306. t['H'] = 778;
  19307. t['I'] = 389;
  19308. t['J'] = 500;
  19309. t['K'] = 667;
  19310. t['L'] = 611;
  19311. t['M'] = 889;
  19312. t['N'] = 722;
  19313. t['O'] = 722;
  19314. t['P'] = 611;
  19315. t['Q'] = 722;
  19316. t['R'] = 667;
  19317. t['S'] = 556;
  19318. t['T'] = 611;
  19319. t['U'] = 722;
  19320. t['V'] = 667;
  19321. t['W'] = 889;
  19322. t['X'] = 667;
  19323. t['Y'] = 611;
  19324. t['Z'] = 611;
  19325. t['bracketleft'] = 333;
  19326. t['backslash'] = 278;
  19327. t['bracketright'] = 333;
  19328. t['asciicircum'] = 570;
  19329. t['underscore'] = 500;
  19330. t['quoteleft'] = 333;
  19331. t['a'] = 500;
  19332. t['b'] = 500;
  19333. t['c'] = 444;
  19334. t['d'] = 500;
  19335. t['e'] = 444;
  19336. t['f'] = 333;
  19337. t['g'] = 500;
  19338. t['h'] = 556;
  19339. t['i'] = 278;
  19340. t['j'] = 278;
  19341. t['k'] = 500;
  19342. t['l'] = 278;
  19343. t['m'] = 778;
  19344. t['n'] = 556;
  19345. t['o'] = 500;
  19346. t['p'] = 500;
  19347. t['q'] = 500;
  19348. t['r'] = 389;
  19349. t['s'] = 389;
  19350. t['t'] = 278;
  19351. t['u'] = 556;
  19352. t['v'] = 444;
  19353. t['w'] = 667;
  19354. t['x'] = 500;
  19355. t['y'] = 444;
  19356. t['z'] = 389;
  19357. t['braceleft'] = 348;
  19358. t['bar'] = 220;
  19359. t['braceright'] = 348;
  19360. t['asciitilde'] = 570;
  19361. t['exclamdown'] = 389;
  19362. t['cent'] = 500;
  19363. t['sterling'] = 500;
  19364. t['fraction'] = 167;
  19365. t['yen'] = 500;
  19366. t['florin'] = 500;
  19367. t['section'] = 500;
  19368. t['currency'] = 500;
  19369. t['quotesingle'] = 278;
  19370. t['quotedblleft'] = 500;
  19371. t['guillemotleft'] = 500;
  19372. t['guilsinglleft'] = 333;
  19373. t['guilsinglright'] = 333;
  19374. t['fi'] = 556;
  19375. t['fl'] = 556;
  19376. t['endash'] = 500;
  19377. t['dagger'] = 500;
  19378. t['daggerdbl'] = 500;
  19379. t['periodcentered'] = 250;
  19380. t['paragraph'] = 500;
  19381. t['bullet'] = 350;
  19382. t['quotesinglbase'] = 333;
  19383. t['quotedblbase'] = 500;
  19384. t['quotedblright'] = 500;
  19385. t['guillemotright'] = 500;
  19386. t['ellipsis'] = 1000;
  19387. t['perthousand'] = 1000;
  19388. t['questiondown'] = 500;
  19389. t['grave'] = 333;
  19390. t['acute'] = 333;
  19391. t['circumflex'] = 333;
  19392. t['tilde'] = 333;
  19393. t['macron'] = 333;
  19394. t['breve'] = 333;
  19395. t['dotaccent'] = 333;
  19396. t['dieresis'] = 333;
  19397. t['ring'] = 333;
  19398. t['cedilla'] = 333;
  19399. t['hungarumlaut'] = 333;
  19400. t['ogonek'] = 333;
  19401. t['caron'] = 333;
  19402. t['emdash'] = 1000;
  19403. t['AE'] = 944;
  19404. t['ordfeminine'] = 266;
  19405. t['Lslash'] = 611;
  19406. t['Oslash'] = 722;
  19407. t['OE'] = 944;
  19408. t['ordmasculine'] = 300;
  19409. t['ae'] = 722;
  19410. t['dotlessi'] = 278;
  19411. t['lslash'] = 278;
  19412. t['oslash'] = 500;
  19413. t['oe'] = 722;
  19414. t['germandbls'] = 500;
  19415. t['Idieresis'] = 389;
  19416. t['eacute'] = 444;
  19417. t['abreve'] = 500;
  19418. t['uhungarumlaut'] = 556;
  19419. t['ecaron'] = 444;
  19420. t['Ydieresis'] = 611;
  19421. t['divide'] = 570;
  19422. t['Yacute'] = 611;
  19423. t['Acircumflex'] = 667;
  19424. t['aacute'] = 500;
  19425. t['Ucircumflex'] = 722;
  19426. t['yacute'] = 444;
  19427. t['scommaaccent'] = 389;
  19428. t['ecircumflex'] = 444;
  19429. t['Uring'] = 722;
  19430. t['Udieresis'] = 722;
  19431. t['aogonek'] = 500;
  19432. t['Uacute'] = 722;
  19433. t['uogonek'] = 556;
  19434. t['Edieresis'] = 667;
  19435. t['Dcroat'] = 722;
  19436. t['commaaccent'] = 250;
  19437. t['copyright'] = 747;
  19438. t['Emacron'] = 667;
  19439. t['ccaron'] = 444;
  19440. t['aring'] = 500;
  19441. t['Ncommaaccent'] = 722;
  19442. t['lacute'] = 278;
  19443. t['agrave'] = 500;
  19444. t['Tcommaaccent'] = 611;
  19445. t['Cacute'] = 667;
  19446. t['atilde'] = 500;
  19447. t['Edotaccent'] = 667;
  19448. t['scaron'] = 389;
  19449. t['scedilla'] = 389;
  19450. t['iacute'] = 278;
  19451. t['lozenge'] = 494;
  19452. t['Rcaron'] = 667;
  19453. t['Gcommaaccent'] = 722;
  19454. t['ucircumflex'] = 556;
  19455. t['acircumflex'] = 500;
  19456. t['Amacron'] = 667;
  19457. t['rcaron'] = 389;
  19458. t['ccedilla'] = 444;
  19459. t['Zdotaccent'] = 611;
  19460. t['Thorn'] = 611;
  19461. t['Omacron'] = 722;
  19462. t['Racute'] = 667;
  19463. t['Sacute'] = 556;
  19464. t['dcaron'] = 608;
  19465. t['Umacron'] = 722;
  19466. t['uring'] = 556;
  19467. t['threesuperior'] = 300;
  19468. t['Ograve'] = 722;
  19469. t['Agrave'] = 667;
  19470. t['Abreve'] = 667;
  19471. t['multiply'] = 570;
  19472. t['uacute'] = 556;
  19473. t['Tcaron'] = 611;
  19474. t['partialdiff'] = 494;
  19475. t['ydieresis'] = 444;
  19476. t['Nacute'] = 722;
  19477. t['icircumflex'] = 278;
  19478. t['Ecircumflex'] = 667;
  19479. t['adieresis'] = 500;
  19480. t['edieresis'] = 444;
  19481. t['cacute'] = 444;
  19482. t['nacute'] = 556;
  19483. t['umacron'] = 556;
  19484. t['Ncaron'] = 722;
  19485. t['Iacute'] = 389;
  19486. t['plusminus'] = 570;
  19487. t['brokenbar'] = 220;
  19488. t['registered'] = 747;
  19489. t['Gbreve'] = 722;
  19490. t['Idotaccent'] = 389;
  19491. t['summation'] = 600;
  19492. t['Egrave'] = 667;
  19493. t['racute'] = 389;
  19494. t['omacron'] = 500;
  19495. t['Zacute'] = 611;
  19496. t['Zcaron'] = 611;
  19497. t['greaterequal'] = 549;
  19498. t['Eth'] = 722;
  19499. t['Ccedilla'] = 667;
  19500. t['lcommaaccent'] = 278;
  19501. t['tcaron'] = 366;
  19502. t['eogonek'] = 444;
  19503. t['Uogonek'] = 722;
  19504. t['Aacute'] = 667;
  19505. t['Adieresis'] = 667;
  19506. t['egrave'] = 444;
  19507. t['zacute'] = 389;
  19508. t['iogonek'] = 278;
  19509. t['Oacute'] = 722;
  19510. t['oacute'] = 500;
  19511. t['amacron'] = 500;
  19512. t['sacute'] = 389;
  19513. t['idieresis'] = 278;
  19514. t['Ocircumflex'] = 722;
  19515. t['Ugrave'] = 722;
  19516. t['Delta'] = 612;
  19517. t['thorn'] = 500;
  19518. t['twosuperior'] = 300;
  19519. t['Odieresis'] = 722;
  19520. t['mu'] = 576;
  19521. t['igrave'] = 278;
  19522. t['ohungarumlaut'] = 500;
  19523. t['Eogonek'] = 667;
  19524. t['dcroat'] = 500;
  19525. t['threequarters'] = 750;
  19526. t['Scedilla'] = 556;
  19527. t['lcaron'] = 382;
  19528. t['Kcommaaccent'] = 667;
  19529. t['Lacute'] = 611;
  19530. t['trademark'] = 1000;
  19531. t['edotaccent'] = 444;
  19532. t['Igrave'] = 389;
  19533. t['Imacron'] = 389;
  19534. t['Lcaron'] = 611;
  19535. t['onehalf'] = 750;
  19536. t['lessequal'] = 549;
  19537. t['ocircumflex'] = 500;
  19538. t['ntilde'] = 556;
  19539. t['Uhungarumlaut'] = 722;
  19540. t['Eacute'] = 667;
  19541. t['emacron'] = 444;
  19542. t['gbreve'] = 500;
  19543. t['onequarter'] = 750;
  19544. t['Scaron'] = 556;
  19545. t['Scommaaccent'] = 556;
  19546. t['Ohungarumlaut'] = 722;
  19547. t['degree'] = 400;
  19548. t['ograve'] = 500;
  19549. t['Ccaron'] = 667;
  19550. t['ugrave'] = 556;
  19551. t['radical'] = 549;
  19552. t['Dcaron'] = 722;
  19553. t['rcommaaccent'] = 389;
  19554. t['Ntilde'] = 722;
  19555. t['otilde'] = 500;
  19556. t['Rcommaaccent'] = 667;
  19557. t['Lcommaaccent'] = 611;
  19558. t['Atilde'] = 667;
  19559. t['Aogonek'] = 667;
  19560. t['Aring'] = 667;
  19561. t['Otilde'] = 722;
  19562. t['zdotaccent'] = 389;
  19563. t['Ecaron'] = 667;
  19564. t['Iogonek'] = 389;
  19565. t['kcommaaccent'] = 500;
  19566. t['minus'] = 606;
  19567. t['Icircumflex'] = 389;
  19568. t['ncaron'] = 556;
  19569. t['tcommaaccent'] = 278;
  19570. t['logicalnot'] = 606;
  19571. t['odieresis'] = 500;
  19572. t['udieresis'] = 556;
  19573. t['notequal'] = 549;
  19574. t['gcommaaccent'] = 500;
  19575. t['eth'] = 500;
  19576. t['zcaron'] = 389;
  19577. t['ncommaaccent'] = 556;
  19578. t['onesuperior'] = 300;
  19579. t['imacron'] = 278;
  19580. t['Euro'] = 500;
  19581. });
  19582. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19583. t['space'] = 250;
  19584. t['exclam'] = 333;
  19585. t['quotedbl'] = 420;
  19586. t['numbersign'] = 500;
  19587. t['dollar'] = 500;
  19588. t['percent'] = 833;
  19589. t['ampersand'] = 778;
  19590. t['quoteright'] = 333;
  19591. t['parenleft'] = 333;
  19592. t['parenright'] = 333;
  19593. t['asterisk'] = 500;
  19594. t['plus'] = 675;
  19595. t['comma'] = 250;
  19596. t['hyphen'] = 333;
  19597. t['period'] = 250;
  19598. t['slash'] = 278;
  19599. t['zero'] = 500;
  19600. t['one'] = 500;
  19601. t['two'] = 500;
  19602. t['three'] = 500;
  19603. t['four'] = 500;
  19604. t['five'] = 500;
  19605. t['six'] = 500;
  19606. t['seven'] = 500;
  19607. t['eight'] = 500;
  19608. t['nine'] = 500;
  19609. t['colon'] = 333;
  19610. t['semicolon'] = 333;
  19611. t['less'] = 675;
  19612. t['equal'] = 675;
  19613. t['greater'] = 675;
  19614. t['question'] = 500;
  19615. t['at'] = 920;
  19616. t['A'] = 611;
  19617. t['B'] = 611;
  19618. t['C'] = 667;
  19619. t['D'] = 722;
  19620. t['E'] = 611;
  19621. t['F'] = 611;
  19622. t['G'] = 722;
  19623. t['H'] = 722;
  19624. t['I'] = 333;
  19625. t['J'] = 444;
  19626. t['K'] = 667;
  19627. t['L'] = 556;
  19628. t['M'] = 833;
  19629. t['N'] = 667;
  19630. t['O'] = 722;
  19631. t['P'] = 611;
  19632. t['Q'] = 722;
  19633. t['R'] = 611;
  19634. t['S'] = 500;
  19635. t['T'] = 556;
  19636. t['U'] = 722;
  19637. t['V'] = 611;
  19638. t['W'] = 833;
  19639. t['X'] = 611;
  19640. t['Y'] = 556;
  19641. t['Z'] = 556;
  19642. t['bracketleft'] = 389;
  19643. t['backslash'] = 278;
  19644. t['bracketright'] = 389;
  19645. t['asciicircum'] = 422;
  19646. t['underscore'] = 500;
  19647. t['quoteleft'] = 333;
  19648. t['a'] = 500;
  19649. t['b'] = 500;
  19650. t['c'] = 444;
  19651. t['d'] = 500;
  19652. t['e'] = 444;
  19653. t['f'] = 278;
  19654. t['g'] = 500;
  19655. t['h'] = 500;
  19656. t['i'] = 278;
  19657. t['j'] = 278;
  19658. t['k'] = 444;
  19659. t['l'] = 278;
  19660. t['m'] = 722;
  19661. t['n'] = 500;
  19662. t['o'] = 500;
  19663. t['p'] = 500;
  19664. t['q'] = 500;
  19665. t['r'] = 389;
  19666. t['s'] = 389;
  19667. t['t'] = 278;
  19668. t['u'] = 500;
  19669. t['v'] = 444;
  19670. t['w'] = 667;
  19671. t['x'] = 444;
  19672. t['y'] = 444;
  19673. t['z'] = 389;
  19674. t['braceleft'] = 400;
  19675. t['bar'] = 275;
  19676. t['braceright'] = 400;
  19677. t['asciitilde'] = 541;
  19678. t['exclamdown'] = 389;
  19679. t['cent'] = 500;
  19680. t['sterling'] = 500;
  19681. t['fraction'] = 167;
  19682. t['yen'] = 500;
  19683. t['florin'] = 500;
  19684. t['section'] = 500;
  19685. t['currency'] = 500;
  19686. t['quotesingle'] = 214;
  19687. t['quotedblleft'] = 556;
  19688. t['guillemotleft'] = 500;
  19689. t['guilsinglleft'] = 333;
  19690. t['guilsinglright'] = 333;
  19691. t['fi'] = 500;
  19692. t['fl'] = 500;
  19693. t['endash'] = 500;
  19694. t['dagger'] = 500;
  19695. t['daggerdbl'] = 500;
  19696. t['periodcentered'] = 250;
  19697. t['paragraph'] = 523;
  19698. t['bullet'] = 350;
  19699. t['quotesinglbase'] = 333;
  19700. t['quotedblbase'] = 556;
  19701. t['quotedblright'] = 556;
  19702. t['guillemotright'] = 500;
  19703. t['ellipsis'] = 889;
  19704. t['perthousand'] = 1000;
  19705. t['questiondown'] = 500;
  19706. t['grave'] = 333;
  19707. t['acute'] = 333;
  19708. t['circumflex'] = 333;
  19709. t['tilde'] = 333;
  19710. t['macron'] = 333;
  19711. t['breve'] = 333;
  19712. t['dotaccent'] = 333;
  19713. t['dieresis'] = 333;
  19714. t['ring'] = 333;
  19715. t['cedilla'] = 333;
  19716. t['hungarumlaut'] = 333;
  19717. t['ogonek'] = 333;
  19718. t['caron'] = 333;
  19719. t['emdash'] = 889;
  19720. t['AE'] = 889;
  19721. t['ordfeminine'] = 276;
  19722. t['Lslash'] = 556;
  19723. t['Oslash'] = 722;
  19724. t['OE'] = 944;
  19725. t['ordmasculine'] = 310;
  19726. t['ae'] = 667;
  19727. t['dotlessi'] = 278;
  19728. t['lslash'] = 278;
  19729. t['oslash'] = 500;
  19730. t['oe'] = 667;
  19731. t['germandbls'] = 500;
  19732. t['Idieresis'] = 333;
  19733. t['eacute'] = 444;
  19734. t['abreve'] = 500;
  19735. t['uhungarumlaut'] = 500;
  19736. t['ecaron'] = 444;
  19737. t['Ydieresis'] = 556;
  19738. t['divide'] = 675;
  19739. t['Yacute'] = 556;
  19740. t['Acircumflex'] = 611;
  19741. t['aacute'] = 500;
  19742. t['Ucircumflex'] = 722;
  19743. t['yacute'] = 444;
  19744. t['scommaaccent'] = 389;
  19745. t['ecircumflex'] = 444;
  19746. t['Uring'] = 722;
  19747. t['Udieresis'] = 722;
  19748. t['aogonek'] = 500;
  19749. t['Uacute'] = 722;
  19750. t['uogonek'] = 500;
  19751. t['Edieresis'] = 611;
  19752. t['Dcroat'] = 722;
  19753. t['commaaccent'] = 250;
  19754. t['copyright'] = 760;
  19755. t['Emacron'] = 611;
  19756. t['ccaron'] = 444;
  19757. t['aring'] = 500;
  19758. t['Ncommaaccent'] = 667;
  19759. t['lacute'] = 278;
  19760. t['agrave'] = 500;
  19761. t['Tcommaaccent'] = 556;
  19762. t['Cacute'] = 667;
  19763. t['atilde'] = 500;
  19764. t['Edotaccent'] = 611;
  19765. t['scaron'] = 389;
  19766. t['scedilla'] = 389;
  19767. t['iacute'] = 278;
  19768. t['lozenge'] = 471;
  19769. t['Rcaron'] = 611;
  19770. t['Gcommaaccent'] = 722;
  19771. t['ucircumflex'] = 500;
  19772. t['acircumflex'] = 500;
  19773. t['Amacron'] = 611;
  19774. t['rcaron'] = 389;
  19775. t['ccedilla'] = 444;
  19776. t['Zdotaccent'] = 556;
  19777. t['Thorn'] = 611;
  19778. t['Omacron'] = 722;
  19779. t['Racute'] = 611;
  19780. t['Sacute'] = 500;
  19781. t['dcaron'] = 544;
  19782. t['Umacron'] = 722;
  19783. t['uring'] = 500;
  19784. t['threesuperior'] = 300;
  19785. t['Ograve'] = 722;
  19786. t['Agrave'] = 611;
  19787. t['Abreve'] = 611;
  19788. t['multiply'] = 675;
  19789. t['uacute'] = 500;
  19790. t['Tcaron'] = 556;
  19791. t['partialdiff'] = 476;
  19792. t['ydieresis'] = 444;
  19793. t['Nacute'] = 667;
  19794. t['icircumflex'] = 278;
  19795. t['Ecircumflex'] = 611;
  19796. t['adieresis'] = 500;
  19797. t['edieresis'] = 444;
  19798. t['cacute'] = 444;
  19799. t['nacute'] = 500;
  19800. t['umacron'] = 500;
  19801. t['Ncaron'] = 667;
  19802. t['Iacute'] = 333;
  19803. t['plusminus'] = 675;
  19804. t['brokenbar'] = 275;
  19805. t['registered'] = 760;
  19806. t['Gbreve'] = 722;
  19807. t['Idotaccent'] = 333;
  19808. t['summation'] = 600;
  19809. t['Egrave'] = 611;
  19810. t['racute'] = 389;
  19811. t['omacron'] = 500;
  19812. t['Zacute'] = 556;
  19813. t['Zcaron'] = 556;
  19814. t['greaterequal'] = 549;
  19815. t['Eth'] = 722;
  19816. t['Ccedilla'] = 667;
  19817. t['lcommaaccent'] = 278;
  19818. t['tcaron'] = 300;
  19819. t['eogonek'] = 444;
  19820. t['Uogonek'] = 722;
  19821. t['Aacute'] = 611;
  19822. t['Adieresis'] = 611;
  19823. t['egrave'] = 444;
  19824. t['zacute'] = 389;
  19825. t['iogonek'] = 278;
  19826. t['Oacute'] = 722;
  19827. t['oacute'] = 500;
  19828. t['amacron'] = 500;
  19829. t['sacute'] = 389;
  19830. t['idieresis'] = 278;
  19831. t['Ocircumflex'] = 722;
  19832. t['Ugrave'] = 722;
  19833. t['Delta'] = 612;
  19834. t['thorn'] = 500;
  19835. t['twosuperior'] = 300;
  19836. t['Odieresis'] = 722;
  19837. t['mu'] = 500;
  19838. t['igrave'] = 278;
  19839. t['ohungarumlaut'] = 500;
  19840. t['Eogonek'] = 611;
  19841. t['dcroat'] = 500;
  19842. t['threequarters'] = 750;
  19843. t['Scedilla'] = 500;
  19844. t['lcaron'] = 300;
  19845. t['Kcommaaccent'] = 667;
  19846. t['Lacute'] = 556;
  19847. t['trademark'] = 980;
  19848. t['edotaccent'] = 444;
  19849. t['Igrave'] = 333;
  19850. t['Imacron'] = 333;
  19851. t['Lcaron'] = 611;
  19852. t['onehalf'] = 750;
  19853. t['lessequal'] = 549;
  19854. t['ocircumflex'] = 500;
  19855. t['ntilde'] = 500;
  19856. t['Uhungarumlaut'] = 722;
  19857. t['Eacute'] = 611;
  19858. t['emacron'] = 444;
  19859. t['gbreve'] = 500;
  19860. t['onequarter'] = 750;
  19861. t['Scaron'] = 500;
  19862. t['Scommaaccent'] = 500;
  19863. t['Ohungarumlaut'] = 722;
  19864. t['degree'] = 400;
  19865. t['ograve'] = 500;
  19866. t['Ccaron'] = 667;
  19867. t['ugrave'] = 500;
  19868. t['radical'] = 453;
  19869. t['Dcaron'] = 722;
  19870. t['rcommaaccent'] = 389;
  19871. t['Ntilde'] = 667;
  19872. t['otilde'] = 500;
  19873. t['Rcommaaccent'] = 611;
  19874. t['Lcommaaccent'] = 556;
  19875. t['Atilde'] = 611;
  19876. t['Aogonek'] = 611;
  19877. t['Aring'] = 611;
  19878. t['Otilde'] = 722;
  19879. t['zdotaccent'] = 389;
  19880. t['Ecaron'] = 611;
  19881. t['Iogonek'] = 333;
  19882. t['kcommaaccent'] = 444;
  19883. t['minus'] = 675;
  19884. t['Icircumflex'] = 333;
  19885. t['ncaron'] = 500;
  19886. t['tcommaaccent'] = 278;
  19887. t['logicalnot'] = 675;
  19888. t['odieresis'] = 500;
  19889. t['udieresis'] = 500;
  19890. t['notequal'] = 549;
  19891. t['gcommaaccent'] = 500;
  19892. t['eth'] = 500;
  19893. t['zcaron'] = 389;
  19894. t['ncommaaccent'] = 500;
  19895. t['onesuperior'] = 300;
  19896. t['imacron'] = 278;
  19897. t['Euro'] = 500;
  19898. });
  19899. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  19900. t['space'] = 278;
  19901. t['a1'] = 974;
  19902. t['a2'] = 961;
  19903. t['a202'] = 974;
  19904. t['a3'] = 980;
  19905. t['a4'] = 719;
  19906. t['a5'] = 789;
  19907. t['a119'] = 790;
  19908. t['a118'] = 791;
  19909. t['a117'] = 690;
  19910. t['a11'] = 960;
  19911. t['a12'] = 939;
  19912. t['a13'] = 549;
  19913. t['a14'] = 855;
  19914. t['a15'] = 911;
  19915. t['a16'] = 933;
  19916. t['a105'] = 911;
  19917. t['a17'] = 945;
  19918. t['a18'] = 974;
  19919. t['a19'] = 755;
  19920. t['a20'] = 846;
  19921. t['a21'] = 762;
  19922. t['a22'] = 761;
  19923. t['a23'] = 571;
  19924. t['a24'] = 677;
  19925. t['a25'] = 763;
  19926. t['a26'] = 760;
  19927. t['a27'] = 759;
  19928. t['a28'] = 754;
  19929. t['a6'] = 494;
  19930. t['a7'] = 552;
  19931. t['a8'] = 537;
  19932. t['a9'] = 577;
  19933. t['a10'] = 692;
  19934. t['a29'] = 786;
  19935. t['a30'] = 788;
  19936. t['a31'] = 788;
  19937. t['a32'] = 790;
  19938. t['a33'] = 793;
  19939. t['a34'] = 794;
  19940. t['a35'] = 816;
  19941. t['a36'] = 823;
  19942. t['a37'] = 789;
  19943. t['a38'] = 841;
  19944. t['a39'] = 823;
  19945. t['a40'] = 833;
  19946. t['a41'] = 816;
  19947. t['a42'] = 831;
  19948. t['a43'] = 923;
  19949. t['a44'] = 744;
  19950. t['a45'] = 723;
  19951. t['a46'] = 749;
  19952. t['a47'] = 790;
  19953. t['a48'] = 792;
  19954. t['a49'] = 695;
  19955. t['a50'] = 776;
  19956. t['a51'] = 768;
  19957. t['a52'] = 792;
  19958. t['a53'] = 759;
  19959. t['a54'] = 707;
  19960. t['a55'] = 708;
  19961. t['a56'] = 682;
  19962. t['a57'] = 701;
  19963. t['a58'] = 826;
  19964. t['a59'] = 815;
  19965. t['a60'] = 789;
  19966. t['a61'] = 789;
  19967. t['a62'] = 707;
  19968. t['a63'] = 687;
  19969. t['a64'] = 696;
  19970. t['a65'] = 689;
  19971. t['a66'] = 786;
  19972. t['a67'] = 787;
  19973. t['a68'] = 713;
  19974. t['a69'] = 791;
  19975. t['a70'] = 785;
  19976. t['a71'] = 791;
  19977. t['a72'] = 873;
  19978. t['a73'] = 761;
  19979. t['a74'] = 762;
  19980. t['a203'] = 762;
  19981. t['a75'] = 759;
  19982. t['a204'] = 759;
  19983. t['a76'] = 892;
  19984. t['a77'] = 892;
  19985. t['a78'] = 788;
  19986. t['a79'] = 784;
  19987. t['a81'] = 438;
  19988. t['a82'] = 138;
  19989. t['a83'] = 277;
  19990. t['a84'] = 415;
  19991. t['a97'] = 392;
  19992. t['a98'] = 392;
  19993. t['a99'] = 668;
  19994. t['a100'] = 668;
  19995. t['a89'] = 390;
  19996. t['a90'] = 390;
  19997. t['a93'] = 317;
  19998. t['a94'] = 317;
  19999. t['a91'] = 276;
  20000. t['a92'] = 276;
  20001. t['a205'] = 509;
  20002. t['a85'] = 509;
  20003. t['a206'] = 410;
  20004. t['a86'] = 410;
  20005. t['a87'] = 234;
  20006. t['a88'] = 234;
  20007. t['a95'] = 334;
  20008. t['a96'] = 334;
  20009. t['a101'] = 732;
  20010. t['a102'] = 544;
  20011. t['a103'] = 544;
  20012. t['a104'] = 910;
  20013. t['a106'] = 667;
  20014. t['a107'] = 760;
  20015. t['a108'] = 760;
  20016. t['a112'] = 776;
  20017. t['a111'] = 595;
  20018. t['a110'] = 694;
  20019. t['a109'] = 626;
  20020. t['a120'] = 788;
  20021. t['a121'] = 788;
  20022. t['a122'] = 788;
  20023. t['a123'] = 788;
  20024. t['a124'] = 788;
  20025. t['a125'] = 788;
  20026. t['a126'] = 788;
  20027. t['a127'] = 788;
  20028. t['a128'] = 788;
  20029. t['a129'] = 788;
  20030. t['a130'] = 788;
  20031. t['a131'] = 788;
  20032. t['a132'] = 788;
  20033. t['a133'] = 788;
  20034. t['a134'] = 788;
  20035. t['a135'] = 788;
  20036. t['a136'] = 788;
  20037. t['a137'] = 788;
  20038. t['a138'] = 788;
  20039. t['a139'] = 788;
  20040. t['a140'] = 788;
  20041. t['a141'] = 788;
  20042. t['a142'] = 788;
  20043. t['a143'] = 788;
  20044. t['a144'] = 788;
  20045. t['a145'] = 788;
  20046. t['a146'] = 788;
  20047. t['a147'] = 788;
  20048. t['a148'] = 788;
  20049. t['a149'] = 788;
  20050. t['a150'] = 788;
  20051. t['a151'] = 788;
  20052. t['a152'] = 788;
  20053. t['a153'] = 788;
  20054. t['a154'] = 788;
  20055. t['a155'] = 788;
  20056. t['a156'] = 788;
  20057. t['a157'] = 788;
  20058. t['a158'] = 788;
  20059. t['a159'] = 788;
  20060. t['a160'] = 894;
  20061. t['a161'] = 838;
  20062. t['a163'] = 1016;
  20063. t['a164'] = 458;
  20064. t['a196'] = 748;
  20065. t['a165'] = 924;
  20066. t['a192'] = 748;
  20067. t['a166'] = 918;
  20068. t['a167'] = 927;
  20069. t['a168'] = 928;
  20070. t['a169'] = 928;
  20071. t['a170'] = 834;
  20072. t['a171'] = 873;
  20073. t['a172'] = 828;
  20074. t['a173'] = 924;
  20075. t['a162'] = 924;
  20076. t['a174'] = 917;
  20077. t['a175'] = 930;
  20078. t['a176'] = 931;
  20079. t['a177'] = 463;
  20080. t['a178'] = 883;
  20081. t['a179'] = 836;
  20082. t['a193'] = 836;
  20083. t['a180'] = 867;
  20084. t['a199'] = 867;
  20085. t['a181'] = 696;
  20086. t['a200'] = 696;
  20087. t['a182'] = 874;
  20088. t['a201'] = 874;
  20089. t['a183'] = 760;
  20090. t['a184'] = 946;
  20091. t['a197'] = 771;
  20092. t['a185'] = 865;
  20093. t['a194'] = 771;
  20094. t['a198'] = 888;
  20095. t['a186'] = 967;
  20096. t['a195'] = 888;
  20097. t['a187'] = 831;
  20098. t['a188'] = 873;
  20099. t['a189'] = 927;
  20100. t['a190'] = 970;
  20101. t['a191'] = 918;
  20102. });
  20103. });
  20104. exports.getMetrics = getMetrics;
  20105. }));
  20106. (function (root, factory) {
  20107. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20108. }(this, function (exports, sharedUtil) {
  20109. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20110. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20111. var MASK_HIGH = 0xffff0000;
  20112. var MASK_LOW = 0xffff;
  20113. function MurmurHash3_64(seed) {
  20114. var SEED = 0xc3d2e1f0;
  20115. this.h1 = seed ? seed & 0xffffffff : SEED;
  20116. this.h2 = seed ? seed & 0xffffffff : SEED;
  20117. }
  20118. var alwaysUseUint32ArrayView = false;
  20119. try {
  20120. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20121. } catch (e) {
  20122. alwaysUseUint32ArrayView = true;
  20123. }
  20124. MurmurHash3_64.prototype = {
  20125. update: function MurmurHash3_64_update(input) {
  20126. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20127. var i;
  20128. if (typeof input === 'string') {
  20129. var data = new Uint8Array(input.length * 2);
  20130. var length = 0;
  20131. for (i = 0; i < input.length; i++) {
  20132. var code = input.charCodeAt(i);
  20133. if (code <= 0xff) {
  20134. data[length++] = code;
  20135. } else {
  20136. data[length++] = code >>> 8;
  20137. data[length++] = code & 0xff;
  20138. }
  20139. }
  20140. } else if (input instanceof Uint8Array) {
  20141. data = input;
  20142. length = data.length;
  20143. } else if (typeof input === 'object' && 'length' in input) {
  20144. data = input;
  20145. length = data.length;
  20146. useUint32ArrayView = true;
  20147. } else {
  20148. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20149. }
  20150. var blockCounts = length >> 2;
  20151. var tailLength = length - blockCounts * 4;
  20152. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20153. var k1 = 0;
  20154. var k2 = 0;
  20155. var h1 = this.h1;
  20156. var h2 = this.h2;
  20157. var C1 = 0xcc9e2d51;
  20158. var C2 = 0x1b873593;
  20159. var C1_LOW = C1 & MASK_LOW;
  20160. var C2_LOW = C2 & MASK_LOW;
  20161. for (i = 0; i < blockCounts; i++) {
  20162. if (i & 1) {
  20163. k1 = dataUint32[i];
  20164. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20165. k1 = k1 << 15 | k1 >>> 17;
  20166. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20167. h1 ^= k1;
  20168. h1 = h1 << 13 | h1 >>> 19;
  20169. h1 = h1 * 5 + 0xe6546b64;
  20170. } else {
  20171. k2 = dataUint32[i];
  20172. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20173. k2 = k2 << 15 | k2 >>> 17;
  20174. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20175. h2 ^= k2;
  20176. h2 = h2 << 13 | h2 >>> 19;
  20177. h2 = h2 * 5 + 0xe6546b64;
  20178. }
  20179. }
  20180. k1 = 0;
  20181. switch (tailLength) {
  20182. case 3:
  20183. k1 ^= data[blockCounts * 4 + 2] << 16;
  20184. case 2:
  20185. k1 ^= data[blockCounts * 4 + 1] << 8;
  20186. case 1:
  20187. k1 ^= data[blockCounts * 4];
  20188. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20189. k1 = k1 << 15 | k1 >>> 17;
  20190. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20191. if (blockCounts & 1) {
  20192. h1 ^= k1;
  20193. } else {
  20194. h2 ^= k1;
  20195. }
  20196. }
  20197. this.h1 = h1;
  20198. this.h2 = h2;
  20199. return this;
  20200. },
  20201. hexdigest: function MurmurHash3_64_hexdigest() {
  20202. var h1 = this.h1;
  20203. var h2 = this.h2;
  20204. h1 ^= h2 >>> 1;
  20205. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20206. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20207. h1 ^= h2 >>> 1;
  20208. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20209. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20210. h1 ^= h2 >>> 1;
  20211. for (var i = 0, arr = [
  20212. h1,
  20213. h2
  20214. ], str = ''; i < arr.length; i++) {
  20215. var hex = (arr[i] >>> 0).toString(16);
  20216. while (hex.length < 8) {
  20217. hex = '0' + hex;
  20218. }
  20219. str += hex;
  20220. }
  20221. return str;
  20222. }
  20223. };
  20224. return MurmurHash3_64;
  20225. }();
  20226. exports.MurmurHash3_64 = MurmurHash3_64;
  20227. }));
  20228. (function (root, factory) {
  20229. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20230. }(this, function (exports, sharedUtil) {
  20231. var isArray = sharedUtil.isArray;
  20232. var Name = function NameClosure() {
  20233. function Name(name) {
  20234. this.name = name;
  20235. }
  20236. Name.prototype = {};
  20237. var nameCache = Object.create(null);
  20238. Name.get = function Name_get(name) {
  20239. var nameValue = nameCache[name];
  20240. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20241. };
  20242. return Name;
  20243. }();
  20244. var Cmd = function CmdClosure() {
  20245. function Cmd(cmd) {
  20246. this.cmd = cmd;
  20247. }
  20248. Cmd.prototype = {};
  20249. var cmdCache = Object.create(null);
  20250. Cmd.get = function Cmd_get(cmd) {
  20251. var cmdValue = cmdCache[cmd];
  20252. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20253. };
  20254. return Cmd;
  20255. }();
  20256. var Dict = function DictClosure() {
  20257. var nonSerializable = function nonSerializableClosure() {
  20258. return nonSerializable;
  20259. };
  20260. function Dict(xref) {
  20261. this.map = Object.create(null);
  20262. this.xref = xref;
  20263. this.objId = null;
  20264. this.suppressEncryption = false;
  20265. this.__nonSerializable__ = nonSerializable;
  20266. }
  20267. Dict.prototype = {
  20268. assignXref: function Dict_assignXref(newXref) {
  20269. this.xref = newXref;
  20270. },
  20271. get: function Dict_get(key1, key2, key3) {
  20272. var value;
  20273. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20274. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20275. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20276. }
  20277. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20278. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20279. }
  20280. value = this.map[key3] || null;
  20281. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20282. },
  20283. getAsync: function Dict_getAsync(key1, key2, key3) {
  20284. var value;
  20285. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20286. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20287. if (xref) {
  20288. return xref.fetchIfRefAsync(value, suppressEncryption);
  20289. }
  20290. return Promise.resolve(value);
  20291. }
  20292. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20293. if (xref) {
  20294. return xref.fetchIfRefAsync(value, suppressEncryption);
  20295. }
  20296. return Promise.resolve(value);
  20297. }
  20298. value = this.map[key3] || null;
  20299. if (xref) {
  20300. return xref.fetchIfRefAsync(value, suppressEncryption);
  20301. }
  20302. return Promise.resolve(value);
  20303. },
  20304. getArray: function Dict_getArray(key1, key2, key3) {
  20305. var value = this.get(key1, key2, key3);
  20306. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20307. if (!isArray(value) || !xref) {
  20308. return value;
  20309. }
  20310. value = value.slice();
  20311. for (var i = 0, ii = value.length; i < ii; i++) {
  20312. if (!isRef(value[i])) {
  20313. continue;
  20314. }
  20315. value[i] = xref.fetch(value[i], suppressEncryption);
  20316. }
  20317. return value;
  20318. },
  20319. getRaw: function Dict_getRaw(key) {
  20320. return this.map[key];
  20321. },
  20322. getKeys: function Dict_getKeys() {
  20323. return Object.keys(this.map);
  20324. },
  20325. set: function Dict_set(key, value) {
  20326. this.map[key] = value;
  20327. },
  20328. has: function Dict_has(key) {
  20329. return key in this.map;
  20330. },
  20331. forEach: function Dict_forEach(callback) {
  20332. for (var key in this.map) {
  20333. callback(key, this.get(key));
  20334. }
  20335. }
  20336. };
  20337. Dict.empty = new Dict(null);
  20338. Dict.merge = function Dict_merge(xref, dictArray) {
  20339. var mergedDict = new Dict(xref);
  20340. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20341. var dict = dictArray[i];
  20342. if (!isDict(dict)) {
  20343. continue;
  20344. }
  20345. for (var keyName in dict.map) {
  20346. if (mergedDict.map[keyName]) {
  20347. continue;
  20348. }
  20349. mergedDict.map[keyName] = dict.map[keyName];
  20350. }
  20351. }
  20352. return mergedDict;
  20353. };
  20354. return Dict;
  20355. }();
  20356. var Ref = function RefClosure() {
  20357. function Ref(num, gen) {
  20358. this.num = num;
  20359. this.gen = gen;
  20360. }
  20361. Ref.prototype = {
  20362. toString: function Ref_toString() {
  20363. var str = this.num + 'R';
  20364. if (this.gen !== 0) {
  20365. str += this.gen;
  20366. }
  20367. return str;
  20368. }
  20369. };
  20370. return Ref;
  20371. }();
  20372. var RefSet = function RefSetClosure() {
  20373. function RefSet() {
  20374. this.dict = Object.create(null);
  20375. }
  20376. RefSet.prototype = {
  20377. has: function RefSet_has(ref) {
  20378. return ref.toString() in this.dict;
  20379. },
  20380. put: function RefSet_put(ref) {
  20381. this.dict[ref.toString()] = true;
  20382. },
  20383. remove: function RefSet_remove(ref) {
  20384. delete this.dict[ref.toString()];
  20385. }
  20386. };
  20387. return RefSet;
  20388. }();
  20389. var RefSetCache = function RefSetCacheClosure() {
  20390. function RefSetCache() {
  20391. this.dict = Object.create(null);
  20392. }
  20393. RefSetCache.prototype = {
  20394. get: function RefSetCache_get(ref) {
  20395. return this.dict[ref.toString()];
  20396. },
  20397. has: function RefSetCache_has(ref) {
  20398. return ref.toString() in this.dict;
  20399. },
  20400. put: function RefSetCache_put(ref, obj) {
  20401. this.dict[ref.toString()] = obj;
  20402. },
  20403. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20404. this.dict[ref.toString()] = this.get(aliasRef);
  20405. },
  20406. forEach: function RefSetCache_forEach(fn, thisArg) {
  20407. for (var i in this.dict) {
  20408. fn.call(thisArg, this.dict[i]);
  20409. }
  20410. },
  20411. clear: function RefSetCache_clear() {
  20412. this.dict = Object.create(null);
  20413. }
  20414. };
  20415. return RefSetCache;
  20416. }();
  20417. function isName(v, name) {
  20418. return v instanceof Name && (name === undefined || v.name === name);
  20419. }
  20420. function isCmd(v, cmd) {
  20421. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20422. }
  20423. function isDict(v, type) {
  20424. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20425. }
  20426. function isRef(v) {
  20427. return v instanceof Ref;
  20428. }
  20429. function isRefsEqual(v1, v2) {
  20430. return v1.num === v2.num && v1.gen === v2.gen;
  20431. }
  20432. function isStream(v) {
  20433. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20434. }
  20435. exports.Cmd = Cmd;
  20436. exports.Dict = Dict;
  20437. exports.Name = Name;
  20438. exports.Ref = Ref;
  20439. exports.RefSet = RefSet;
  20440. exports.RefSetCache = RefSetCache;
  20441. exports.isCmd = isCmd;
  20442. exports.isDict = isDict;
  20443. exports.isName = isName;
  20444. exports.isRef = isRef;
  20445. exports.isRefsEqual = isRefsEqual;
  20446. exports.isStream = isStream;
  20447. }));
  20448. (function (root, factory) {
  20449. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20450. }(this, function (exports, sharedUtil) {
  20451. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20452. var getStdFontMap = getLookupTableFactory(function (t) {
  20453. t['ArialNarrow'] = 'Helvetica';
  20454. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20455. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20456. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20457. t['ArialBlack'] = 'Helvetica';
  20458. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20459. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20460. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20461. t['Arial'] = 'Helvetica';
  20462. t['Arial-Bold'] = 'Helvetica-Bold';
  20463. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20464. t['Arial-Italic'] = 'Helvetica-Oblique';
  20465. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20466. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20467. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20468. t['ArialMT'] = 'Helvetica';
  20469. t['Courier-Bold'] = 'Courier-Bold';
  20470. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20471. t['Courier-Italic'] = 'Courier-Oblique';
  20472. t['CourierNew'] = 'Courier';
  20473. t['CourierNew-Bold'] = 'Courier-Bold';
  20474. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20475. t['CourierNew-Italic'] = 'Courier-Oblique';
  20476. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20477. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20478. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20479. t['CourierNewPSMT'] = 'Courier';
  20480. t['Helvetica'] = 'Helvetica';
  20481. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20482. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20483. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20484. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20485. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20486. t['Symbol-Bold'] = 'Symbol';
  20487. t['Symbol-BoldItalic'] = 'Symbol';
  20488. t['Symbol-Italic'] = 'Symbol';
  20489. t['TimesNewRoman'] = 'Times-Roman';
  20490. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20491. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20492. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20493. t['TimesNewRomanPS'] = 'Times-Roman';
  20494. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20495. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20496. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20497. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20498. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20499. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20500. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20501. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20502. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20503. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20504. });
  20505. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20506. t['CenturyGothic'] = 'Helvetica';
  20507. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20508. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20509. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20510. t['ComicSansMS'] = 'Comic Sans MS';
  20511. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20512. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20513. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20514. t['LucidaConsole'] = 'Courier';
  20515. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20516. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20517. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20518. t['MS-Gothic'] = 'MS Gothic';
  20519. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20520. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20521. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20522. t['MS-Mincho'] = 'MS Mincho';
  20523. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20524. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20525. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20526. t['MS-PGothic'] = 'MS PGothic';
  20527. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20528. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20529. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20530. t['MS-PMincho'] = 'MS PMincho';
  20531. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20532. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20533. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20534. t['Wingdings'] = 'ZapfDingbats';
  20535. });
  20536. var getSerifFonts = getLookupTableFactory(function (t) {
  20537. t['Adobe Jenson'] = true;
  20538. t['Adobe Text'] = true;
  20539. t['Albertus'] = true;
  20540. t['Aldus'] = true;
  20541. t['Alexandria'] = true;
  20542. t['Algerian'] = true;
  20543. t['American Typewriter'] = true;
  20544. t['Antiqua'] = true;
  20545. t['Apex'] = true;
  20546. t['Arno'] = true;
  20547. t['Aster'] = true;
  20548. t['Aurora'] = true;
  20549. t['Baskerville'] = true;
  20550. t['Bell'] = true;
  20551. t['Bembo'] = true;
  20552. t['Bembo Schoolbook'] = true;
  20553. t['Benguiat'] = true;
  20554. t['Berkeley Old Style'] = true;
  20555. t['Bernhard Modern'] = true;
  20556. t['Berthold City'] = true;
  20557. t['Bodoni'] = true;
  20558. t['Bauer Bodoni'] = true;
  20559. t['Book Antiqua'] = true;
  20560. t['Bookman'] = true;
  20561. t['Bordeaux Roman'] = true;
  20562. t['Californian FB'] = true;
  20563. t['Calisto'] = true;
  20564. t['Calvert'] = true;
  20565. t['Capitals'] = true;
  20566. t['Cambria'] = true;
  20567. t['Cartier'] = true;
  20568. t['Caslon'] = true;
  20569. t['Catull'] = true;
  20570. t['Centaur'] = true;
  20571. t['Century Old Style'] = true;
  20572. t['Century Schoolbook'] = true;
  20573. t['Chaparral'] = true;
  20574. t['Charis SIL'] = true;
  20575. t['Cheltenham'] = true;
  20576. t['Cholla Slab'] = true;
  20577. t['Clarendon'] = true;
  20578. t['Clearface'] = true;
  20579. t['Cochin'] = true;
  20580. t['Colonna'] = true;
  20581. t['Computer Modern'] = true;
  20582. t['Concrete Roman'] = true;
  20583. t['Constantia'] = true;
  20584. t['Cooper Black'] = true;
  20585. t['Corona'] = true;
  20586. t['Ecotype'] = true;
  20587. t['Egyptienne'] = true;
  20588. t['Elephant'] = true;
  20589. t['Excelsior'] = true;
  20590. t['Fairfield'] = true;
  20591. t['FF Scala'] = true;
  20592. t['Folkard'] = true;
  20593. t['Footlight'] = true;
  20594. t['FreeSerif'] = true;
  20595. t['Friz Quadrata'] = true;
  20596. t['Garamond'] = true;
  20597. t['Gentium'] = true;
  20598. t['Georgia'] = true;
  20599. t['Gloucester'] = true;
  20600. t['Goudy Old Style'] = true;
  20601. t['Goudy Schoolbook'] = true;
  20602. t['Goudy Pro Font'] = true;
  20603. t['Granjon'] = true;
  20604. t['Guardian Egyptian'] = true;
  20605. t['Heather'] = true;
  20606. t['Hercules'] = true;
  20607. t['High Tower Text'] = true;
  20608. t['Hiroshige'] = true;
  20609. t['Hoefler Text'] = true;
  20610. t['Humana Serif'] = true;
  20611. t['Imprint'] = true;
  20612. t['Ionic No. 5'] = true;
  20613. t['Janson'] = true;
  20614. t['Joanna'] = true;
  20615. t['Korinna'] = true;
  20616. t['Lexicon'] = true;
  20617. t['Liberation Serif'] = true;
  20618. t['Linux Libertine'] = true;
  20619. t['Literaturnaya'] = true;
  20620. t['Lucida'] = true;
  20621. t['Lucida Bright'] = true;
  20622. t['Melior'] = true;
  20623. t['Memphis'] = true;
  20624. t['Miller'] = true;
  20625. t['Minion'] = true;
  20626. t['Modern'] = true;
  20627. t['Mona Lisa'] = true;
  20628. t['Mrs Eaves'] = true;
  20629. t['MS Serif'] = true;
  20630. t['Museo Slab'] = true;
  20631. t['New York'] = true;
  20632. t['Nimbus Roman'] = true;
  20633. t['NPS Rawlinson Roadway'] = true;
  20634. t['Palatino'] = true;
  20635. t['Perpetua'] = true;
  20636. t['Plantin'] = true;
  20637. t['Plantin Schoolbook'] = true;
  20638. t['Playbill'] = true;
  20639. t['Poor Richard'] = true;
  20640. t['Rawlinson Roadway'] = true;
  20641. t['Renault'] = true;
  20642. t['Requiem'] = true;
  20643. t['Rockwell'] = true;
  20644. t['Roman'] = true;
  20645. t['Rotis Serif'] = true;
  20646. t['Sabon'] = true;
  20647. t['Scala'] = true;
  20648. t['Seagull'] = true;
  20649. t['Sistina'] = true;
  20650. t['Souvenir'] = true;
  20651. t['STIX'] = true;
  20652. t['Stone Informal'] = true;
  20653. t['Stone Serif'] = true;
  20654. t['Sylfaen'] = true;
  20655. t['Times'] = true;
  20656. t['Trajan'] = true;
  20657. t['Trinité'] = true;
  20658. t['Trump Mediaeval'] = true;
  20659. t['Utopia'] = true;
  20660. t['Vale Type'] = true;
  20661. t['Bitstream Vera'] = true;
  20662. t['Vera Serif'] = true;
  20663. t['Versailles'] = true;
  20664. t['Wanted'] = true;
  20665. t['Weiss'] = true;
  20666. t['Wide Latin'] = true;
  20667. t['Windsor'] = true;
  20668. t['XITS'] = true;
  20669. });
  20670. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20671. t['Dingbats'] = true;
  20672. t['Symbol'] = true;
  20673. t['ZapfDingbats'] = true;
  20674. });
  20675. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20676. t[2] = 10;
  20677. t[3] = 32;
  20678. t[4] = 33;
  20679. t[5] = 34;
  20680. t[6] = 35;
  20681. t[7] = 36;
  20682. t[8] = 37;
  20683. t[9] = 38;
  20684. t[10] = 39;
  20685. t[11] = 40;
  20686. t[12] = 41;
  20687. t[13] = 42;
  20688. t[14] = 43;
  20689. t[15] = 44;
  20690. t[16] = 45;
  20691. t[17] = 46;
  20692. t[18] = 47;
  20693. t[19] = 48;
  20694. t[20] = 49;
  20695. t[21] = 50;
  20696. t[22] = 51;
  20697. t[23] = 52;
  20698. t[24] = 53;
  20699. t[25] = 54;
  20700. t[26] = 55;
  20701. t[27] = 56;
  20702. t[28] = 57;
  20703. t[29] = 58;
  20704. t[30] = 894;
  20705. t[31] = 60;
  20706. t[32] = 61;
  20707. t[33] = 62;
  20708. t[34] = 63;
  20709. t[35] = 64;
  20710. t[36] = 65;
  20711. t[37] = 66;
  20712. t[38] = 67;
  20713. t[39] = 68;
  20714. t[40] = 69;
  20715. t[41] = 70;
  20716. t[42] = 71;
  20717. t[43] = 72;
  20718. t[44] = 73;
  20719. t[45] = 74;
  20720. t[46] = 75;
  20721. t[47] = 76;
  20722. t[48] = 77;
  20723. t[49] = 78;
  20724. t[50] = 79;
  20725. t[51] = 80;
  20726. t[52] = 81;
  20727. t[53] = 82;
  20728. t[54] = 83;
  20729. t[55] = 84;
  20730. t[56] = 85;
  20731. t[57] = 86;
  20732. t[58] = 87;
  20733. t[59] = 88;
  20734. t[60] = 89;
  20735. t[61] = 90;
  20736. t[62] = 91;
  20737. t[63] = 92;
  20738. t[64] = 93;
  20739. t[65] = 94;
  20740. t[66] = 95;
  20741. t[67] = 96;
  20742. t[68] = 97;
  20743. t[69] = 98;
  20744. t[70] = 99;
  20745. t[71] = 100;
  20746. t[72] = 101;
  20747. t[73] = 102;
  20748. t[74] = 103;
  20749. t[75] = 104;
  20750. t[76] = 105;
  20751. t[77] = 106;
  20752. t[78] = 107;
  20753. t[79] = 108;
  20754. t[80] = 109;
  20755. t[81] = 110;
  20756. t[82] = 111;
  20757. t[83] = 112;
  20758. t[84] = 113;
  20759. t[85] = 114;
  20760. t[86] = 115;
  20761. t[87] = 116;
  20762. t[88] = 117;
  20763. t[89] = 118;
  20764. t[90] = 119;
  20765. t[91] = 120;
  20766. t[92] = 121;
  20767. t[93] = 122;
  20768. t[94] = 123;
  20769. t[95] = 124;
  20770. t[96] = 125;
  20771. t[97] = 126;
  20772. t[98] = 196;
  20773. t[99] = 197;
  20774. t[100] = 199;
  20775. t[101] = 201;
  20776. t[102] = 209;
  20777. t[103] = 214;
  20778. t[104] = 220;
  20779. t[105] = 225;
  20780. t[106] = 224;
  20781. t[107] = 226;
  20782. t[108] = 228;
  20783. t[109] = 227;
  20784. t[110] = 229;
  20785. t[111] = 231;
  20786. t[112] = 233;
  20787. t[113] = 232;
  20788. t[114] = 234;
  20789. t[115] = 235;
  20790. t[116] = 237;
  20791. t[117] = 236;
  20792. t[118] = 238;
  20793. t[119] = 239;
  20794. t[120] = 241;
  20795. t[121] = 243;
  20796. t[122] = 242;
  20797. t[123] = 244;
  20798. t[124] = 246;
  20799. t[125] = 245;
  20800. t[126] = 250;
  20801. t[127] = 249;
  20802. t[128] = 251;
  20803. t[129] = 252;
  20804. t[130] = 8224;
  20805. t[131] = 176;
  20806. t[132] = 162;
  20807. t[133] = 163;
  20808. t[134] = 167;
  20809. t[135] = 8226;
  20810. t[136] = 182;
  20811. t[137] = 223;
  20812. t[138] = 174;
  20813. t[139] = 169;
  20814. t[140] = 8482;
  20815. t[141] = 180;
  20816. t[142] = 168;
  20817. t[143] = 8800;
  20818. t[144] = 198;
  20819. t[145] = 216;
  20820. t[146] = 8734;
  20821. t[147] = 177;
  20822. t[148] = 8804;
  20823. t[149] = 8805;
  20824. t[150] = 165;
  20825. t[151] = 181;
  20826. t[152] = 8706;
  20827. t[153] = 8721;
  20828. t[154] = 8719;
  20829. t[156] = 8747;
  20830. t[157] = 170;
  20831. t[158] = 186;
  20832. t[159] = 8486;
  20833. t[160] = 230;
  20834. t[161] = 248;
  20835. t[162] = 191;
  20836. t[163] = 161;
  20837. t[164] = 172;
  20838. t[165] = 8730;
  20839. t[166] = 402;
  20840. t[167] = 8776;
  20841. t[168] = 8710;
  20842. t[169] = 171;
  20843. t[170] = 187;
  20844. t[171] = 8230;
  20845. t[210] = 218;
  20846. t[223] = 711;
  20847. t[224] = 321;
  20848. t[225] = 322;
  20849. t[227] = 353;
  20850. t[229] = 382;
  20851. t[234] = 253;
  20852. t[252] = 263;
  20853. t[253] = 268;
  20854. t[254] = 269;
  20855. t[258] = 258;
  20856. t[260] = 260;
  20857. t[261] = 261;
  20858. t[265] = 280;
  20859. t[266] = 281;
  20860. t[268] = 283;
  20861. t[269] = 313;
  20862. t[275] = 323;
  20863. t[276] = 324;
  20864. t[278] = 328;
  20865. t[284] = 345;
  20866. t[285] = 346;
  20867. t[286] = 347;
  20868. t[292] = 367;
  20869. t[295] = 377;
  20870. t[296] = 378;
  20871. t[298] = 380;
  20872. t[305] = 963;
  20873. t[306] = 964;
  20874. t[307] = 966;
  20875. t[308] = 8215;
  20876. t[309] = 8252;
  20877. t[310] = 8319;
  20878. t[311] = 8359;
  20879. t[312] = 8592;
  20880. t[313] = 8593;
  20881. t[337] = 9552;
  20882. t[493] = 1039;
  20883. t[494] = 1040;
  20884. t[705] = 1524;
  20885. t[706] = 8362;
  20886. t[710] = 64288;
  20887. t[711] = 64298;
  20888. t[759] = 1617;
  20889. t[761] = 1776;
  20890. t[763] = 1778;
  20891. t[775] = 1652;
  20892. t[777] = 1764;
  20893. t[778] = 1780;
  20894. t[779] = 1781;
  20895. t[780] = 1782;
  20896. t[782] = 771;
  20897. t[783] = 64726;
  20898. t[786] = 8363;
  20899. t[788] = 8532;
  20900. t[790] = 768;
  20901. t[791] = 769;
  20902. t[792] = 768;
  20903. t[795] = 803;
  20904. t[797] = 64336;
  20905. t[798] = 64337;
  20906. t[799] = 64342;
  20907. t[800] = 64343;
  20908. t[801] = 64344;
  20909. t[802] = 64345;
  20910. t[803] = 64362;
  20911. t[804] = 64363;
  20912. t[805] = 64364;
  20913. t[2424] = 7821;
  20914. t[2425] = 7822;
  20915. t[2426] = 7823;
  20916. t[2427] = 7824;
  20917. t[2428] = 7825;
  20918. t[2429] = 7826;
  20919. t[2430] = 7827;
  20920. t[2433] = 7682;
  20921. t[2678] = 8045;
  20922. t[2679] = 8046;
  20923. t[2830] = 1552;
  20924. t[2838] = 686;
  20925. t[2840] = 751;
  20926. t[2842] = 753;
  20927. t[2843] = 754;
  20928. t[2844] = 755;
  20929. t[2846] = 757;
  20930. t[2856] = 767;
  20931. t[2857] = 848;
  20932. t[2858] = 849;
  20933. t[2862] = 853;
  20934. t[2863] = 854;
  20935. t[2864] = 855;
  20936. t[2865] = 861;
  20937. t[2866] = 862;
  20938. t[2906] = 7460;
  20939. t[2908] = 7462;
  20940. t[2909] = 7463;
  20941. t[2910] = 7464;
  20942. t[2912] = 7466;
  20943. t[2913] = 7467;
  20944. t[2914] = 7468;
  20945. t[2916] = 7470;
  20946. t[2917] = 7471;
  20947. t[2918] = 7472;
  20948. t[2920] = 7474;
  20949. t[2921] = 7475;
  20950. t[2922] = 7476;
  20951. t[2924] = 7478;
  20952. t[2925] = 7479;
  20953. t[2926] = 7480;
  20954. t[2928] = 7482;
  20955. t[2929] = 7483;
  20956. t[2930] = 7484;
  20957. t[2932] = 7486;
  20958. t[2933] = 7487;
  20959. t[2934] = 7488;
  20960. t[2936] = 7490;
  20961. t[2937] = 7491;
  20962. t[2938] = 7492;
  20963. t[2940] = 7494;
  20964. t[2941] = 7495;
  20965. t[2942] = 7496;
  20966. t[2944] = 7498;
  20967. t[2946] = 7500;
  20968. t[2948] = 7502;
  20969. t[2950] = 7504;
  20970. t[2951] = 7505;
  20971. t[2952] = 7506;
  20972. t[2954] = 7508;
  20973. t[2955] = 7509;
  20974. t[2956] = 7510;
  20975. t[2958] = 7512;
  20976. t[2959] = 7513;
  20977. t[2960] = 7514;
  20978. t[2962] = 7516;
  20979. t[2963] = 7517;
  20980. t[2964] = 7518;
  20981. t[2966] = 7520;
  20982. t[2967] = 7521;
  20983. t[2968] = 7522;
  20984. t[2970] = 7524;
  20985. t[2971] = 7525;
  20986. t[2972] = 7526;
  20987. t[2974] = 7528;
  20988. t[2975] = 7529;
  20989. t[2976] = 7530;
  20990. t[2978] = 1537;
  20991. t[2979] = 1538;
  20992. t[2980] = 1539;
  20993. t[2982] = 1549;
  20994. t[2983] = 1551;
  20995. t[2984] = 1552;
  20996. t[2986] = 1554;
  20997. t[2987] = 1555;
  20998. t[2988] = 1556;
  20999. t[2990] = 1623;
  21000. t[2991] = 1624;
  21001. t[2995] = 1775;
  21002. t[2999] = 1791;
  21003. t[3002] = 64290;
  21004. t[3003] = 64291;
  21005. t[3004] = 64292;
  21006. t[3006] = 64294;
  21007. t[3007] = 64295;
  21008. t[3008] = 64296;
  21009. t[3011] = 1900;
  21010. t[3014] = 8223;
  21011. t[3015] = 8244;
  21012. t[3017] = 7532;
  21013. t[3018] = 7533;
  21014. t[3019] = 7534;
  21015. t[3075] = 7590;
  21016. t[3076] = 7591;
  21017. t[3079] = 7594;
  21018. t[3080] = 7595;
  21019. t[3083] = 7598;
  21020. t[3084] = 7599;
  21021. t[3087] = 7602;
  21022. t[3088] = 7603;
  21023. t[3091] = 7606;
  21024. t[3092] = 7607;
  21025. t[3095] = 7610;
  21026. t[3096] = 7611;
  21027. t[3099] = 7614;
  21028. t[3100] = 7615;
  21029. t[3103] = 7618;
  21030. t[3104] = 7619;
  21031. t[3107] = 8337;
  21032. t[3108] = 8338;
  21033. t[3116] = 1884;
  21034. t[3119] = 1885;
  21035. t[3120] = 1885;
  21036. t[3123] = 1886;
  21037. t[3124] = 1886;
  21038. t[3127] = 1887;
  21039. t[3128] = 1887;
  21040. t[3131] = 1888;
  21041. t[3132] = 1888;
  21042. t[3135] = 1889;
  21043. t[3136] = 1889;
  21044. t[3139] = 1890;
  21045. t[3140] = 1890;
  21046. t[3143] = 1891;
  21047. t[3144] = 1891;
  21048. t[3147] = 1892;
  21049. t[3148] = 1892;
  21050. t[3153] = 580;
  21051. t[3154] = 581;
  21052. t[3157] = 584;
  21053. t[3158] = 585;
  21054. t[3161] = 588;
  21055. t[3162] = 589;
  21056. t[3165] = 891;
  21057. t[3166] = 892;
  21058. t[3169] = 1274;
  21059. t[3170] = 1275;
  21060. t[3173] = 1278;
  21061. t[3174] = 1279;
  21062. t[3181] = 7622;
  21063. t[3182] = 7623;
  21064. t[3282] = 11799;
  21065. t[3316] = 578;
  21066. t[3379] = 42785;
  21067. t[3393] = 1159;
  21068. t[3416] = 8377;
  21069. });
  21070. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21071. t[227] = 322;
  21072. t[264] = 261;
  21073. t[291] = 346;
  21074. });
  21075. exports.getStdFontMap = getStdFontMap;
  21076. exports.getNonStdFontMap = getNonStdFontMap;
  21077. exports.getSerifFonts = getSerifFonts;
  21078. exports.getSymbolsFonts = getSymbolsFonts;
  21079. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21080. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21081. }));
  21082. (function (root, factory) {
  21083. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21084. }(this, function (exports, sharedUtil) {
  21085. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21086. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21087. t[63721] = 0x00A9;
  21088. t[63193] = 0x00A9;
  21089. t[63720] = 0x00AE;
  21090. t[63194] = 0x00AE;
  21091. t[63722] = 0x2122;
  21092. t[63195] = 0x2122;
  21093. t[63729] = 0x23A7;
  21094. t[63730] = 0x23A8;
  21095. t[63731] = 0x23A9;
  21096. t[63740] = 0x23AB;
  21097. t[63741] = 0x23AC;
  21098. t[63742] = 0x23AD;
  21099. t[63726] = 0x23A1;
  21100. t[63727] = 0x23A2;
  21101. t[63728] = 0x23A3;
  21102. t[63737] = 0x23A4;
  21103. t[63738] = 0x23A5;
  21104. t[63739] = 0x23A6;
  21105. t[63723] = 0x239B;
  21106. t[63724] = 0x239C;
  21107. t[63725] = 0x239D;
  21108. t[63734] = 0x239E;
  21109. t[63735] = 0x239F;
  21110. t[63736] = 0x23A0;
  21111. });
  21112. function mapSpecialUnicodeValues(code) {
  21113. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21114. return 0;
  21115. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21116. return getSpecialPUASymbols()[code] || code;
  21117. }
  21118. return code;
  21119. }
  21120. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21121. var unicode = glyphsUnicodeMap[name];
  21122. if (unicode !== undefined) {
  21123. return unicode;
  21124. }
  21125. if (!name) {
  21126. return -1;
  21127. }
  21128. if (name[0] === 'u') {
  21129. var nameLen = name.length, hexStr;
  21130. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21131. hexStr = name.substr(3);
  21132. } else if (nameLen >= 5 && nameLen <= 7) {
  21133. hexStr = name.substr(1);
  21134. } else {
  21135. return -1;
  21136. }
  21137. if (hexStr === hexStr.toUpperCase()) {
  21138. unicode = parseInt(hexStr, 16);
  21139. if (unicode >= 0) {
  21140. return unicode;
  21141. }
  21142. }
  21143. }
  21144. return -1;
  21145. }
  21146. var UnicodeRanges = [
  21147. {
  21148. 'begin': 0x0000,
  21149. 'end': 0x007F
  21150. },
  21151. {
  21152. 'begin': 0x0080,
  21153. 'end': 0x00FF
  21154. },
  21155. {
  21156. 'begin': 0x0100,
  21157. 'end': 0x017F
  21158. },
  21159. {
  21160. 'begin': 0x0180,
  21161. 'end': 0x024F
  21162. },
  21163. {
  21164. 'begin': 0x0250,
  21165. 'end': 0x02AF
  21166. },
  21167. {
  21168. 'begin': 0x02B0,
  21169. 'end': 0x02FF
  21170. },
  21171. {
  21172. 'begin': 0x0300,
  21173. 'end': 0x036F
  21174. },
  21175. {
  21176. 'begin': 0x0370,
  21177. 'end': 0x03FF
  21178. },
  21179. {
  21180. 'begin': 0x2C80,
  21181. 'end': 0x2CFF
  21182. },
  21183. {
  21184. 'begin': 0x0400,
  21185. 'end': 0x04FF
  21186. },
  21187. {
  21188. 'begin': 0x0530,
  21189. 'end': 0x058F
  21190. },
  21191. {
  21192. 'begin': 0x0590,
  21193. 'end': 0x05FF
  21194. },
  21195. {
  21196. 'begin': 0xA500,
  21197. 'end': 0xA63F
  21198. },
  21199. {
  21200. 'begin': 0x0600,
  21201. 'end': 0x06FF
  21202. },
  21203. {
  21204. 'begin': 0x07C0,
  21205. 'end': 0x07FF
  21206. },
  21207. {
  21208. 'begin': 0x0900,
  21209. 'end': 0x097F
  21210. },
  21211. {
  21212. 'begin': 0x0980,
  21213. 'end': 0x09FF
  21214. },
  21215. {
  21216. 'begin': 0x0A00,
  21217. 'end': 0x0A7F
  21218. },
  21219. {
  21220. 'begin': 0x0A80,
  21221. 'end': 0x0AFF
  21222. },
  21223. {
  21224. 'begin': 0x0B00,
  21225. 'end': 0x0B7F
  21226. },
  21227. {
  21228. 'begin': 0x0B80,
  21229. 'end': 0x0BFF
  21230. },
  21231. {
  21232. 'begin': 0x0C00,
  21233. 'end': 0x0C7F
  21234. },
  21235. {
  21236. 'begin': 0x0C80,
  21237. 'end': 0x0CFF
  21238. },
  21239. {
  21240. 'begin': 0x0D00,
  21241. 'end': 0x0D7F
  21242. },
  21243. {
  21244. 'begin': 0x0E00,
  21245. 'end': 0x0E7F
  21246. },
  21247. {
  21248. 'begin': 0x0E80,
  21249. 'end': 0x0EFF
  21250. },
  21251. {
  21252. 'begin': 0x10A0,
  21253. 'end': 0x10FF
  21254. },
  21255. {
  21256. 'begin': 0x1B00,
  21257. 'end': 0x1B7F
  21258. },
  21259. {
  21260. 'begin': 0x1100,
  21261. 'end': 0x11FF
  21262. },
  21263. {
  21264. 'begin': 0x1E00,
  21265. 'end': 0x1EFF
  21266. },
  21267. {
  21268. 'begin': 0x1F00,
  21269. 'end': 0x1FFF
  21270. },
  21271. {
  21272. 'begin': 0x2000,
  21273. 'end': 0x206F
  21274. },
  21275. {
  21276. 'begin': 0x2070,
  21277. 'end': 0x209F
  21278. },
  21279. {
  21280. 'begin': 0x20A0,
  21281. 'end': 0x20CF
  21282. },
  21283. {
  21284. 'begin': 0x20D0,
  21285. 'end': 0x20FF
  21286. },
  21287. {
  21288. 'begin': 0x2100,
  21289. 'end': 0x214F
  21290. },
  21291. {
  21292. 'begin': 0x2150,
  21293. 'end': 0x218F
  21294. },
  21295. {
  21296. 'begin': 0x2190,
  21297. 'end': 0x21FF
  21298. },
  21299. {
  21300. 'begin': 0x2200,
  21301. 'end': 0x22FF
  21302. },
  21303. {
  21304. 'begin': 0x2300,
  21305. 'end': 0x23FF
  21306. },
  21307. {
  21308. 'begin': 0x2400,
  21309. 'end': 0x243F
  21310. },
  21311. {
  21312. 'begin': 0x2440,
  21313. 'end': 0x245F
  21314. },
  21315. {
  21316. 'begin': 0x2460,
  21317. 'end': 0x24FF
  21318. },
  21319. {
  21320. 'begin': 0x2500,
  21321. 'end': 0x257F
  21322. },
  21323. {
  21324. 'begin': 0x2580,
  21325. 'end': 0x259F
  21326. },
  21327. {
  21328. 'begin': 0x25A0,
  21329. 'end': 0x25FF
  21330. },
  21331. {
  21332. 'begin': 0x2600,
  21333. 'end': 0x26FF
  21334. },
  21335. {
  21336. 'begin': 0x2700,
  21337. 'end': 0x27BF
  21338. },
  21339. {
  21340. 'begin': 0x3000,
  21341. 'end': 0x303F
  21342. },
  21343. {
  21344. 'begin': 0x3040,
  21345. 'end': 0x309F
  21346. },
  21347. {
  21348. 'begin': 0x30A0,
  21349. 'end': 0x30FF
  21350. },
  21351. {
  21352. 'begin': 0x3100,
  21353. 'end': 0x312F
  21354. },
  21355. {
  21356. 'begin': 0x3130,
  21357. 'end': 0x318F
  21358. },
  21359. {
  21360. 'begin': 0xA840,
  21361. 'end': 0xA87F
  21362. },
  21363. {
  21364. 'begin': 0x3200,
  21365. 'end': 0x32FF
  21366. },
  21367. {
  21368. 'begin': 0x3300,
  21369. 'end': 0x33FF
  21370. },
  21371. {
  21372. 'begin': 0xAC00,
  21373. 'end': 0xD7AF
  21374. },
  21375. {
  21376. 'begin': 0xD800,
  21377. 'end': 0xDFFF
  21378. },
  21379. {
  21380. 'begin': 0x10900,
  21381. 'end': 0x1091F
  21382. },
  21383. {
  21384. 'begin': 0x4E00,
  21385. 'end': 0x9FFF
  21386. },
  21387. {
  21388. 'begin': 0xE000,
  21389. 'end': 0xF8FF
  21390. },
  21391. {
  21392. 'begin': 0x31C0,
  21393. 'end': 0x31EF
  21394. },
  21395. {
  21396. 'begin': 0xFB00,
  21397. 'end': 0xFB4F
  21398. },
  21399. {
  21400. 'begin': 0xFB50,
  21401. 'end': 0xFDFF
  21402. },
  21403. {
  21404. 'begin': 0xFE20,
  21405. 'end': 0xFE2F
  21406. },
  21407. {
  21408. 'begin': 0xFE10,
  21409. 'end': 0xFE1F
  21410. },
  21411. {
  21412. 'begin': 0xFE50,
  21413. 'end': 0xFE6F
  21414. },
  21415. {
  21416. 'begin': 0xFE70,
  21417. 'end': 0xFEFF
  21418. },
  21419. {
  21420. 'begin': 0xFF00,
  21421. 'end': 0xFFEF
  21422. },
  21423. {
  21424. 'begin': 0xFFF0,
  21425. 'end': 0xFFFF
  21426. },
  21427. {
  21428. 'begin': 0x0F00,
  21429. 'end': 0x0FFF
  21430. },
  21431. {
  21432. 'begin': 0x0700,
  21433. 'end': 0x074F
  21434. },
  21435. {
  21436. 'begin': 0x0780,
  21437. 'end': 0x07BF
  21438. },
  21439. {
  21440. 'begin': 0x0D80,
  21441. 'end': 0x0DFF
  21442. },
  21443. {
  21444. 'begin': 0x1000,
  21445. 'end': 0x109F
  21446. },
  21447. {
  21448. 'begin': 0x1200,
  21449. 'end': 0x137F
  21450. },
  21451. {
  21452. 'begin': 0x13A0,
  21453. 'end': 0x13FF
  21454. },
  21455. {
  21456. 'begin': 0x1400,
  21457. 'end': 0x167F
  21458. },
  21459. {
  21460. 'begin': 0x1680,
  21461. 'end': 0x169F
  21462. },
  21463. {
  21464. 'begin': 0x16A0,
  21465. 'end': 0x16FF
  21466. },
  21467. {
  21468. 'begin': 0x1780,
  21469. 'end': 0x17FF
  21470. },
  21471. {
  21472. 'begin': 0x1800,
  21473. 'end': 0x18AF
  21474. },
  21475. {
  21476. 'begin': 0x2800,
  21477. 'end': 0x28FF
  21478. },
  21479. {
  21480. 'begin': 0xA000,
  21481. 'end': 0xA48F
  21482. },
  21483. {
  21484. 'begin': 0x1700,
  21485. 'end': 0x171F
  21486. },
  21487. {
  21488. 'begin': 0x10300,
  21489. 'end': 0x1032F
  21490. },
  21491. {
  21492. 'begin': 0x10330,
  21493. 'end': 0x1034F
  21494. },
  21495. {
  21496. 'begin': 0x10400,
  21497. 'end': 0x1044F
  21498. },
  21499. {
  21500. 'begin': 0x1D000,
  21501. 'end': 0x1D0FF
  21502. },
  21503. {
  21504. 'begin': 0x1D400,
  21505. 'end': 0x1D7FF
  21506. },
  21507. {
  21508. 'begin': 0xFF000,
  21509. 'end': 0xFFFFD
  21510. },
  21511. {
  21512. 'begin': 0xFE00,
  21513. 'end': 0xFE0F
  21514. },
  21515. {
  21516. 'begin': 0xE0000,
  21517. 'end': 0xE007F
  21518. },
  21519. {
  21520. 'begin': 0x1900,
  21521. 'end': 0x194F
  21522. },
  21523. {
  21524. 'begin': 0x1950,
  21525. 'end': 0x197F
  21526. },
  21527. {
  21528. 'begin': 0x1980,
  21529. 'end': 0x19DF
  21530. },
  21531. {
  21532. 'begin': 0x1A00,
  21533. 'end': 0x1A1F
  21534. },
  21535. {
  21536. 'begin': 0x2C00,
  21537. 'end': 0x2C5F
  21538. },
  21539. {
  21540. 'begin': 0x2D30,
  21541. 'end': 0x2D7F
  21542. },
  21543. {
  21544. 'begin': 0x4DC0,
  21545. 'end': 0x4DFF
  21546. },
  21547. {
  21548. 'begin': 0xA800,
  21549. 'end': 0xA82F
  21550. },
  21551. {
  21552. 'begin': 0x10000,
  21553. 'end': 0x1007F
  21554. },
  21555. {
  21556. 'begin': 0x10140,
  21557. 'end': 0x1018F
  21558. },
  21559. {
  21560. 'begin': 0x10380,
  21561. 'end': 0x1039F
  21562. },
  21563. {
  21564. 'begin': 0x103A0,
  21565. 'end': 0x103DF
  21566. },
  21567. {
  21568. 'begin': 0x10450,
  21569. 'end': 0x1047F
  21570. },
  21571. {
  21572. 'begin': 0x10480,
  21573. 'end': 0x104AF
  21574. },
  21575. {
  21576. 'begin': 0x10800,
  21577. 'end': 0x1083F
  21578. },
  21579. {
  21580. 'begin': 0x10A00,
  21581. 'end': 0x10A5F
  21582. },
  21583. {
  21584. 'begin': 0x1D300,
  21585. 'end': 0x1D35F
  21586. },
  21587. {
  21588. 'begin': 0x12000,
  21589. 'end': 0x123FF
  21590. },
  21591. {
  21592. 'begin': 0x1D360,
  21593. 'end': 0x1D37F
  21594. },
  21595. {
  21596. 'begin': 0x1B80,
  21597. 'end': 0x1BBF
  21598. },
  21599. {
  21600. 'begin': 0x1C00,
  21601. 'end': 0x1C4F
  21602. },
  21603. {
  21604. 'begin': 0x1C50,
  21605. 'end': 0x1C7F
  21606. },
  21607. {
  21608. 'begin': 0xA880,
  21609. 'end': 0xA8DF
  21610. },
  21611. {
  21612. 'begin': 0xA900,
  21613. 'end': 0xA92F
  21614. },
  21615. {
  21616. 'begin': 0xA930,
  21617. 'end': 0xA95F
  21618. },
  21619. {
  21620. 'begin': 0xAA00,
  21621. 'end': 0xAA5F
  21622. },
  21623. {
  21624. 'begin': 0x10190,
  21625. 'end': 0x101CF
  21626. },
  21627. {
  21628. 'begin': 0x101D0,
  21629. 'end': 0x101FF
  21630. },
  21631. {
  21632. 'begin': 0x102A0,
  21633. 'end': 0x102DF
  21634. },
  21635. {
  21636. 'begin': 0x1F030,
  21637. 'end': 0x1F09F
  21638. }
  21639. ];
  21640. function getUnicodeRangeFor(value) {
  21641. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21642. var range = UnicodeRanges[i];
  21643. if (value >= range.begin && value < range.end) {
  21644. return i;
  21645. }
  21646. }
  21647. return -1;
  21648. }
  21649. function isRTLRangeFor(value) {
  21650. var range = UnicodeRanges[13];
  21651. if (value >= range.begin && value < range.end) {
  21652. return true;
  21653. }
  21654. range = UnicodeRanges[11];
  21655. if (value >= range.begin && value < range.end) {
  21656. return true;
  21657. }
  21658. return false;
  21659. }
  21660. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21661. t['\u00A8'] = '\u0020\u0308';
  21662. t['\u00AF'] = '\u0020\u0304';
  21663. t['\u00B4'] = '\u0020\u0301';
  21664. t['\u00B5'] = '\u03BC';
  21665. t['\u00B8'] = '\u0020\u0327';
  21666. t['\u0132'] = '\u0049\u004A';
  21667. t['\u0133'] = '\u0069\u006A';
  21668. t['\u013F'] = '\u004C\u00B7';
  21669. t['\u0140'] = '\u006C\u00B7';
  21670. t['\u0149'] = '\u02BC\u006E';
  21671. t['\u017F'] = '\u0073';
  21672. t['\u01C4'] = '\u0044\u017D';
  21673. t['\u01C5'] = '\u0044\u017E';
  21674. t['\u01C6'] = '\u0064\u017E';
  21675. t['\u01C7'] = '\u004C\u004A';
  21676. t['\u01C8'] = '\u004C\u006A';
  21677. t['\u01C9'] = '\u006C\u006A';
  21678. t['\u01CA'] = '\u004E\u004A';
  21679. t['\u01CB'] = '\u004E\u006A';
  21680. t['\u01CC'] = '\u006E\u006A';
  21681. t['\u01F1'] = '\u0044\u005A';
  21682. t['\u01F2'] = '\u0044\u007A';
  21683. t['\u01F3'] = '\u0064\u007A';
  21684. t['\u02D8'] = '\u0020\u0306';
  21685. t['\u02D9'] = '\u0020\u0307';
  21686. t['\u02DA'] = '\u0020\u030A';
  21687. t['\u02DB'] = '\u0020\u0328';
  21688. t['\u02DC'] = '\u0020\u0303';
  21689. t['\u02DD'] = '\u0020\u030B';
  21690. t['\u037A'] = '\u0020\u0345';
  21691. t['\u0384'] = '\u0020\u0301';
  21692. t['\u03D0'] = '\u03B2';
  21693. t['\u03D1'] = '\u03B8';
  21694. t['\u03D2'] = '\u03A5';
  21695. t['\u03D5'] = '\u03C6';
  21696. t['\u03D6'] = '\u03C0';
  21697. t['\u03F0'] = '\u03BA';
  21698. t['\u03F1'] = '\u03C1';
  21699. t['\u03F2'] = '\u03C2';
  21700. t['\u03F4'] = '\u0398';
  21701. t['\u03F5'] = '\u03B5';
  21702. t['\u03F9'] = '\u03A3';
  21703. t['\u0587'] = '\u0565\u0582';
  21704. t['\u0675'] = '\u0627\u0674';
  21705. t['\u0676'] = '\u0648\u0674';
  21706. t['\u0677'] = '\u06C7\u0674';
  21707. t['\u0678'] = '\u064A\u0674';
  21708. t['\u0E33'] = '\u0E4D\u0E32';
  21709. t['\u0EB3'] = '\u0ECD\u0EB2';
  21710. t['\u0EDC'] = '\u0EAB\u0E99';
  21711. t['\u0EDD'] = '\u0EAB\u0EA1';
  21712. t['\u0F77'] = '\u0FB2\u0F81';
  21713. t['\u0F79'] = '\u0FB3\u0F81';
  21714. t['\u1E9A'] = '\u0061\u02BE';
  21715. t['\u1FBD'] = '\u0020\u0313';
  21716. t['\u1FBF'] = '\u0020\u0313';
  21717. t['\u1FC0'] = '\u0020\u0342';
  21718. t['\u1FFE'] = '\u0020\u0314';
  21719. t['\u2002'] = '\u0020';
  21720. t['\u2003'] = '\u0020';
  21721. t['\u2004'] = '\u0020';
  21722. t['\u2005'] = '\u0020';
  21723. t['\u2006'] = '\u0020';
  21724. t['\u2008'] = '\u0020';
  21725. t['\u2009'] = '\u0020';
  21726. t['\u200A'] = '\u0020';
  21727. t['\u2017'] = '\u0020\u0333';
  21728. t['\u2024'] = '\u002E';
  21729. t['\u2025'] = '\u002E\u002E';
  21730. t['\u2026'] = '\u002E\u002E\u002E';
  21731. t['\u2033'] = '\u2032\u2032';
  21732. t['\u2034'] = '\u2032\u2032\u2032';
  21733. t['\u2036'] = '\u2035\u2035';
  21734. t['\u2037'] = '\u2035\u2035\u2035';
  21735. t['\u203C'] = '\u0021\u0021';
  21736. t['\u203E'] = '\u0020\u0305';
  21737. t['\u2047'] = '\u003F\u003F';
  21738. t['\u2048'] = '\u003F\u0021';
  21739. t['\u2049'] = '\u0021\u003F';
  21740. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21741. t['\u205F'] = '\u0020';
  21742. t['\u20A8'] = '\u0052\u0073';
  21743. t['\u2100'] = '\u0061\u002F\u0063';
  21744. t['\u2101'] = '\u0061\u002F\u0073';
  21745. t['\u2103'] = '\u00B0\u0043';
  21746. t['\u2105'] = '\u0063\u002F\u006F';
  21747. t['\u2106'] = '\u0063\u002F\u0075';
  21748. t['\u2107'] = '\u0190';
  21749. t['\u2109'] = '\u00B0\u0046';
  21750. t['\u2116'] = '\u004E\u006F';
  21751. t['\u2121'] = '\u0054\u0045\u004C';
  21752. t['\u2135'] = '\u05D0';
  21753. t['\u2136'] = '\u05D1';
  21754. t['\u2137'] = '\u05D2';
  21755. t['\u2138'] = '\u05D3';
  21756. t['\u213B'] = '\u0046\u0041\u0058';
  21757. t['\u2160'] = '\u0049';
  21758. t['\u2161'] = '\u0049\u0049';
  21759. t['\u2162'] = '\u0049\u0049\u0049';
  21760. t['\u2163'] = '\u0049\u0056';
  21761. t['\u2164'] = '\u0056';
  21762. t['\u2165'] = '\u0056\u0049';
  21763. t['\u2166'] = '\u0056\u0049\u0049';
  21764. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21765. t['\u2168'] = '\u0049\u0058';
  21766. t['\u2169'] = '\u0058';
  21767. t['\u216A'] = '\u0058\u0049';
  21768. t['\u216B'] = '\u0058\u0049\u0049';
  21769. t['\u216C'] = '\u004C';
  21770. t['\u216D'] = '\u0043';
  21771. t['\u216E'] = '\u0044';
  21772. t['\u216F'] = '\u004D';
  21773. t['\u2170'] = '\u0069';
  21774. t['\u2171'] = '\u0069\u0069';
  21775. t['\u2172'] = '\u0069\u0069\u0069';
  21776. t['\u2173'] = '\u0069\u0076';
  21777. t['\u2174'] = '\u0076';
  21778. t['\u2175'] = '\u0076\u0069';
  21779. t['\u2176'] = '\u0076\u0069\u0069';
  21780. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21781. t['\u2178'] = '\u0069\u0078';
  21782. t['\u2179'] = '\u0078';
  21783. t['\u217A'] = '\u0078\u0069';
  21784. t['\u217B'] = '\u0078\u0069\u0069';
  21785. t['\u217C'] = '\u006C';
  21786. t['\u217D'] = '\u0063';
  21787. t['\u217E'] = '\u0064';
  21788. t['\u217F'] = '\u006D';
  21789. t['\u222C'] = '\u222B\u222B';
  21790. t['\u222D'] = '\u222B\u222B\u222B';
  21791. t['\u222F'] = '\u222E\u222E';
  21792. t['\u2230'] = '\u222E\u222E\u222E';
  21793. t['\u2474'] = '\u0028\u0031\u0029';
  21794. t['\u2475'] = '\u0028\u0032\u0029';
  21795. t['\u2476'] = '\u0028\u0033\u0029';
  21796. t['\u2477'] = '\u0028\u0034\u0029';
  21797. t['\u2478'] = '\u0028\u0035\u0029';
  21798. t['\u2479'] = '\u0028\u0036\u0029';
  21799. t['\u247A'] = '\u0028\u0037\u0029';
  21800. t['\u247B'] = '\u0028\u0038\u0029';
  21801. t['\u247C'] = '\u0028\u0039\u0029';
  21802. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21803. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21804. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21805. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21806. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21807. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21808. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21809. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21810. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21811. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21812. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21813. t['\u2488'] = '\u0031\u002E';
  21814. t['\u2489'] = '\u0032\u002E';
  21815. t['\u248A'] = '\u0033\u002E';
  21816. t['\u248B'] = '\u0034\u002E';
  21817. t['\u248C'] = '\u0035\u002E';
  21818. t['\u248D'] = '\u0036\u002E';
  21819. t['\u248E'] = '\u0037\u002E';
  21820. t['\u248F'] = '\u0038\u002E';
  21821. t['\u2490'] = '\u0039\u002E';
  21822. t['\u2491'] = '\u0031\u0030\u002E';
  21823. t['\u2492'] = '\u0031\u0031\u002E';
  21824. t['\u2493'] = '\u0031\u0032\u002E';
  21825. t['\u2494'] = '\u0031\u0033\u002E';
  21826. t['\u2495'] = '\u0031\u0034\u002E';
  21827. t['\u2496'] = '\u0031\u0035\u002E';
  21828. t['\u2497'] = '\u0031\u0036\u002E';
  21829. t['\u2498'] = '\u0031\u0037\u002E';
  21830. t['\u2499'] = '\u0031\u0038\u002E';
  21831. t['\u249A'] = '\u0031\u0039\u002E';
  21832. t['\u249B'] = '\u0032\u0030\u002E';
  21833. t['\u249C'] = '\u0028\u0061\u0029';
  21834. t['\u249D'] = '\u0028\u0062\u0029';
  21835. t['\u249E'] = '\u0028\u0063\u0029';
  21836. t['\u249F'] = '\u0028\u0064\u0029';
  21837. t['\u24A0'] = '\u0028\u0065\u0029';
  21838. t['\u24A1'] = '\u0028\u0066\u0029';
  21839. t['\u24A2'] = '\u0028\u0067\u0029';
  21840. t['\u24A3'] = '\u0028\u0068\u0029';
  21841. t['\u24A4'] = '\u0028\u0069\u0029';
  21842. t['\u24A5'] = '\u0028\u006A\u0029';
  21843. t['\u24A6'] = '\u0028\u006B\u0029';
  21844. t['\u24A7'] = '\u0028\u006C\u0029';
  21845. t['\u24A8'] = '\u0028\u006D\u0029';
  21846. t['\u24A9'] = '\u0028\u006E\u0029';
  21847. t['\u24AA'] = '\u0028\u006F\u0029';
  21848. t['\u24AB'] = '\u0028\u0070\u0029';
  21849. t['\u24AC'] = '\u0028\u0071\u0029';
  21850. t['\u24AD'] = '\u0028\u0072\u0029';
  21851. t['\u24AE'] = '\u0028\u0073\u0029';
  21852. t['\u24AF'] = '\u0028\u0074\u0029';
  21853. t['\u24B0'] = '\u0028\u0075\u0029';
  21854. t['\u24B1'] = '\u0028\u0076\u0029';
  21855. t['\u24B2'] = '\u0028\u0077\u0029';
  21856. t['\u24B3'] = '\u0028\u0078\u0029';
  21857. t['\u24B4'] = '\u0028\u0079\u0029';
  21858. t['\u24B5'] = '\u0028\u007A\u0029';
  21859. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21860. t['\u2A74'] = '\u003A\u003A\u003D';
  21861. t['\u2A75'] = '\u003D\u003D';
  21862. t['\u2A76'] = '\u003D\u003D\u003D';
  21863. t['\u2E9F'] = '\u6BCD';
  21864. t['\u2EF3'] = '\u9F9F';
  21865. t['\u2F00'] = '\u4E00';
  21866. t['\u2F01'] = '\u4E28';
  21867. t['\u2F02'] = '\u4E36';
  21868. t['\u2F03'] = '\u4E3F';
  21869. t['\u2F04'] = '\u4E59';
  21870. t['\u2F05'] = '\u4E85';
  21871. t['\u2F06'] = '\u4E8C';
  21872. t['\u2F07'] = '\u4EA0';
  21873. t['\u2F08'] = '\u4EBA';
  21874. t['\u2F09'] = '\u513F';
  21875. t['\u2F0A'] = '\u5165';
  21876. t['\u2F0B'] = '\u516B';
  21877. t['\u2F0C'] = '\u5182';
  21878. t['\u2F0D'] = '\u5196';
  21879. t['\u2F0E'] = '\u51AB';
  21880. t['\u2F0F'] = '\u51E0';
  21881. t['\u2F10'] = '\u51F5';
  21882. t['\u2F11'] = '\u5200';
  21883. t['\u2F12'] = '\u529B';
  21884. t['\u2F13'] = '\u52F9';
  21885. t['\u2F14'] = '\u5315';
  21886. t['\u2F15'] = '\u531A';
  21887. t['\u2F16'] = '\u5338';
  21888. t['\u2F17'] = '\u5341';
  21889. t['\u2F18'] = '\u535C';
  21890. t['\u2F19'] = '\u5369';
  21891. t['\u2F1A'] = '\u5382';
  21892. t['\u2F1B'] = '\u53B6';
  21893. t['\u2F1C'] = '\u53C8';
  21894. t['\u2F1D'] = '\u53E3';
  21895. t['\u2F1E'] = '\u56D7';
  21896. t['\u2F1F'] = '\u571F';
  21897. t['\u2F20'] = '\u58EB';
  21898. t['\u2F21'] = '\u5902';
  21899. t['\u2F22'] = '\u590A';
  21900. t['\u2F23'] = '\u5915';
  21901. t['\u2F24'] = '\u5927';
  21902. t['\u2F25'] = '\u5973';
  21903. t['\u2F26'] = '\u5B50';
  21904. t['\u2F27'] = '\u5B80';
  21905. t['\u2F28'] = '\u5BF8';
  21906. t['\u2F29'] = '\u5C0F';
  21907. t['\u2F2A'] = '\u5C22';
  21908. t['\u2F2B'] = '\u5C38';
  21909. t['\u2F2C'] = '\u5C6E';
  21910. t['\u2F2D'] = '\u5C71';
  21911. t['\u2F2E'] = '\u5DDB';
  21912. t['\u2F2F'] = '\u5DE5';
  21913. t['\u2F30'] = '\u5DF1';
  21914. t['\u2F31'] = '\u5DFE';
  21915. t['\u2F32'] = '\u5E72';
  21916. t['\u2F33'] = '\u5E7A';
  21917. t['\u2F34'] = '\u5E7F';
  21918. t['\u2F35'] = '\u5EF4';
  21919. t['\u2F36'] = '\u5EFE';
  21920. t['\u2F37'] = '\u5F0B';
  21921. t['\u2F38'] = '\u5F13';
  21922. t['\u2F39'] = '\u5F50';
  21923. t['\u2F3A'] = '\u5F61';
  21924. t['\u2F3B'] = '\u5F73';
  21925. t['\u2F3C'] = '\u5FC3';
  21926. t['\u2F3D'] = '\u6208';
  21927. t['\u2F3E'] = '\u6236';
  21928. t['\u2F3F'] = '\u624B';
  21929. t['\u2F40'] = '\u652F';
  21930. t['\u2F41'] = '\u6534';
  21931. t['\u2F42'] = '\u6587';
  21932. t['\u2F43'] = '\u6597';
  21933. t['\u2F44'] = '\u65A4';
  21934. t['\u2F45'] = '\u65B9';
  21935. t['\u2F46'] = '\u65E0';
  21936. t['\u2F47'] = '\u65E5';
  21937. t['\u2F48'] = '\u66F0';
  21938. t['\u2F49'] = '\u6708';
  21939. t['\u2F4A'] = '\u6728';
  21940. t['\u2F4B'] = '\u6B20';
  21941. t['\u2F4C'] = '\u6B62';
  21942. t['\u2F4D'] = '\u6B79';
  21943. t['\u2F4E'] = '\u6BB3';
  21944. t['\u2F4F'] = '\u6BCB';
  21945. t['\u2F50'] = '\u6BD4';
  21946. t['\u2F51'] = '\u6BDB';
  21947. t['\u2F52'] = '\u6C0F';
  21948. t['\u2F53'] = '\u6C14';
  21949. t['\u2F54'] = '\u6C34';
  21950. t['\u2F55'] = '\u706B';
  21951. t['\u2F56'] = '\u722A';
  21952. t['\u2F57'] = '\u7236';
  21953. t['\u2F58'] = '\u723B';
  21954. t['\u2F59'] = '\u723F';
  21955. t['\u2F5A'] = '\u7247';
  21956. t['\u2F5B'] = '\u7259';
  21957. t['\u2F5C'] = '\u725B';
  21958. t['\u2F5D'] = '\u72AC';
  21959. t['\u2F5E'] = '\u7384';
  21960. t['\u2F5F'] = '\u7389';
  21961. t['\u2F60'] = '\u74DC';
  21962. t['\u2F61'] = '\u74E6';
  21963. t['\u2F62'] = '\u7518';
  21964. t['\u2F63'] = '\u751F';
  21965. t['\u2F64'] = '\u7528';
  21966. t['\u2F65'] = '\u7530';
  21967. t['\u2F66'] = '\u758B';
  21968. t['\u2F67'] = '\u7592';
  21969. t['\u2F68'] = '\u7676';
  21970. t['\u2F69'] = '\u767D';
  21971. t['\u2F6A'] = '\u76AE';
  21972. t['\u2F6B'] = '\u76BF';
  21973. t['\u2F6C'] = '\u76EE';
  21974. t['\u2F6D'] = '\u77DB';
  21975. t['\u2F6E'] = '\u77E2';
  21976. t['\u2F6F'] = '\u77F3';
  21977. t['\u2F70'] = '\u793A';
  21978. t['\u2F71'] = '\u79B8';
  21979. t['\u2F72'] = '\u79BE';
  21980. t['\u2F73'] = '\u7A74';
  21981. t['\u2F74'] = '\u7ACB';
  21982. t['\u2F75'] = '\u7AF9';
  21983. t['\u2F76'] = '\u7C73';
  21984. t['\u2F77'] = '\u7CF8';
  21985. t['\u2F78'] = '\u7F36';
  21986. t['\u2F79'] = '\u7F51';
  21987. t['\u2F7A'] = '\u7F8A';
  21988. t['\u2F7B'] = '\u7FBD';
  21989. t['\u2F7C'] = '\u8001';
  21990. t['\u2F7D'] = '\u800C';
  21991. t['\u2F7E'] = '\u8012';
  21992. t['\u2F7F'] = '\u8033';
  21993. t['\u2F80'] = '\u807F';
  21994. t['\u2F81'] = '\u8089';
  21995. t['\u2F82'] = '\u81E3';
  21996. t['\u2F83'] = '\u81EA';
  21997. t['\u2F84'] = '\u81F3';
  21998. t['\u2F85'] = '\u81FC';
  21999. t['\u2F86'] = '\u820C';
  22000. t['\u2F87'] = '\u821B';
  22001. t['\u2F88'] = '\u821F';
  22002. t['\u2F89'] = '\u826E';
  22003. t['\u2F8A'] = '\u8272';
  22004. t['\u2F8B'] = '\u8278';
  22005. t['\u2F8C'] = '\u864D';
  22006. t['\u2F8D'] = '\u866B';
  22007. t['\u2F8E'] = '\u8840';
  22008. t['\u2F8F'] = '\u884C';
  22009. t['\u2F90'] = '\u8863';
  22010. t['\u2F91'] = '\u897E';
  22011. t['\u2F92'] = '\u898B';
  22012. t['\u2F93'] = '\u89D2';
  22013. t['\u2F94'] = '\u8A00';
  22014. t['\u2F95'] = '\u8C37';
  22015. t['\u2F96'] = '\u8C46';
  22016. t['\u2F97'] = '\u8C55';
  22017. t['\u2F98'] = '\u8C78';
  22018. t['\u2F99'] = '\u8C9D';
  22019. t['\u2F9A'] = '\u8D64';
  22020. t['\u2F9B'] = '\u8D70';
  22021. t['\u2F9C'] = '\u8DB3';
  22022. t['\u2F9D'] = '\u8EAB';
  22023. t['\u2F9E'] = '\u8ECA';
  22024. t['\u2F9F'] = '\u8F9B';
  22025. t['\u2FA0'] = '\u8FB0';
  22026. t['\u2FA1'] = '\u8FB5';
  22027. t['\u2FA2'] = '\u9091';
  22028. t['\u2FA3'] = '\u9149';
  22029. t['\u2FA4'] = '\u91C6';
  22030. t['\u2FA5'] = '\u91CC';
  22031. t['\u2FA6'] = '\u91D1';
  22032. t['\u2FA7'] = '\u9577';
  22033. t['\u2FA8'] = '\u9580';
  22034. t['\u2FA9'] = '\u961C';
  22035. t['\u2FAA'] = '\u96B6';
  22036. t['\u2FAB'] = '\u96B9';
  22037. t['\u2FAC'] = '\u96E8';
  22038. t['\u2FAD'] = '\u9751';
  22039. t['\u2FAE'] = '\u975E';
  22040. t['\u2FAF'] = '\u9762';
  22041. t['\u2FB0'] = '\u9769';
  22042. t['\u2FB1'] = '\u97CB';
  22043. t['\u2FB2'] = '\u97ED';
  22044. t['\u2FB3'] = '\u97F3';
  22045. t['\u2FB4'] = '\u9801';
  22046. t['\u2FB5'] = '\u98A8';
  22047. t['\u2FB6'] = '\u98DB';
  22048. t['\u2FB7'] = '\u98DF';
  22049. t['\u2FB8'] = '\u9996';
  22050. t['\u2FB9'] = '\u9999';
  22051. t['\u2FBA'] = '\u99AC';
  22052. t['\u2FBB'] = '\u9AA8';
  22053. t['\u2FBC'] = '\u9AD8';
  22054. t['\u2FBD'] = '\u9ADF';
  22055. t['\u2FBE'] = '\u9B25';
  22056. t['\u2FBF'] = '\u9B2F';
  22057. t['\u2FC0'] = '\u9B32';
  22058. t['\u2FC1'] = '\u9B3C';
  22059. t['\u2FC2'] = '\u9B5A';
  22060. t['\u2FC3'] = '\u9CE5';
  22061. t['\u2FC4'] = '\u9E75';
  22062. t['\u2FC5'] = '\u9E7F';
  22063. t['\u2FC6'] = '\u9EA5';
  22064. t['\u2FC7'] = '\u9EBB';
  22065. t['\u2FC8'] = '\u9EC3';
  22066. t['\u2FC9'] = '\u9ECD';
  22067. t['\u2FCA'] = '\u9ED1';
  22068. t['\u2FCB'] = '\u9EF9';
  22069. t['\u2FCC'] = '\u9EFD';
  22070. t['\u2FCD'] = '\u9F0E';
  22071. t['\u2FCE'] = '\u9F13';
  22072. t['\u2FCF'] = '\u9F20';
  22073. t['\u2FD0'] = '\u9F3B';
  22074. t['\u2FD1'] = '\u9F4A';
  22075. t['\u2FD2'] = '\u9F52';
  22076. t['\u2FD3'] = '\u9F8D';
  22077. t['\u2FD4'] = '\u9F9C';
  22078. t['\u2FD5'] = '\u9FA0';
  22079. t['\u3036'] = '\u3012';
  22080. t['\u3038'] = '\u5341';
  22081. t['\u3039'] = '\u5344';
  22082. t['\u303A'] = '\u5345';
  22083. t['\u309B'] = '\u0020\u3099';
  22084. t['\u309C'] = '\u0020\u309A';
  22085. t['\u3131'] = '\u1100';
  22086. t['\u3132'] = '\u1101';
  22087. t['\u3133'] = '\u11AA';
  22088. t['\u3134'] = '\u1102';
  22089. t['\u3135'] = '\u11AC';
  22090. t['\u3136'] = '\u11AD';
  22091. t['\u3137'] = '\u1103';
  22092. t['\u3138'] = '\u1104';
  22093. t['\u3139'] = '\u1105';
  22094. t['\u313A'] = '\u11B0';
  22095. t['\u313B'] = '\u11B1';
  22096. t['\u313C'] = '\u11B2';
  22097. t['\u313D'] = '\u11B3';
  22098. t['\u313E'] = '\u11B4';
  22099. t['\u313F'] = '\u11B5';
  22100. t['\u3140'] = '\u111A';
  22101. t['\u3141'] = '\u1106';
  22102. t['\u3142'] = '\u1107';
  22103. t['\u3143'] = '\u1108';
  22104. t['\u3144'] = '\u1121';
  22105. t['\u3145'] = '\u1109';
  22106. t['\u3146'] = '\u110A';
  22107. t['\u3147'] = '\u110B';
  22108. t['\u3148'] = '\u110C';
  22109. t['\u3149'] = '\u110D';
  22110. t['\u314A'] = '\u110E';
  22111. t['\u314B'] = '\u110F';
  22112. t['\u314C'] = '\u1110';
  22113. t['\u314D'] = '\u1111';
  22114. t['\u314E'] = '\u1112';
  22115. t['\u314F'] = '\u1161';
  22116. t['\u3150'] = '\u1162';
  22117. t['\u3151'] = '\u1163';
  22118. t['\u3152'] = '\u1164';
  22119. t['\u3153'] = '\u1165';
  22120. t['\u3154'] = '\u1166';
  22121. t['\u3155'] = '\u1167';
  22122. t['\u3156'] = '\u1168';
  22123. t['\u3157'] = '\u1169';
  22124. t['\u3158'] = '\u116A';
  22125. t['\u3159'] = '\u116B';
  22126. t['\u315A'] = '\u116C';
  22127. t['\u315B'] = '\u116D';
  22128. t['\u315C'] = '\u116E';
  22129. t['\u315D'] = '\u116F';
  22130. t['\u315E'] = '\u1170';
  22131. t['\u315F'] = '\u1171';
  22132. t['\u3160'] = '\u1172';
  22133. t['\u3161'] = '\u1173';
  22134. t['\u3162'] = '\u1174';
  22135. t['\u3163'] = '\u1175';
  22136. t['\u3164'] = '\u1160';
  22137. t['\u3165'] = '\u1114';
  22138. t['\u3166'] = '\u1115';
  22139. t['\u3167'] = '\u11C7';
  22140. t['\u3168'] = '\u11C8';
  22141. t['\u3169'] = '\u11CC';
  22142. t['\u316A'] = '\u11CE';
  22143. t['\u316B'] = '\u11D3';
  22144. t['\u316C'] = '\u11D7';
  22145. t['\u316D'] = '\u11D9';
  22146. t['\u316E'] = '\u111C';
  22147. t['\u316F'] = '\u11DD';
  22148. t['\u3170'] = '\u11DF';
  22149. t['\u3171'] = '\u111D';
  22150. t['\u3172'] = '\u111E';
  22151. t['\u3173'] = '\u1120';
  22152. t['\u3174'] = '\u1122';
  22153. t['\u3175'] = '\u1123';
  22154. t['\u3176'] = '\u1127';
  22155. t['\u3177'] = '\u1129';
  22156. t['\u3178'] = '\u112B';
  22157. t['\u3179'] = '\u112C';
  22158. t['\u317A'] = '\u112D';
  22159. t['\u317B'] = '\u112E';
  22160. t['\u317C'] = '\u112F';
  22161. t['\u317D'] = '\u1132';
  22162. t['\u317E'] = '\u1136';
  22163. t['\u317F'] = '\u1140';
  22164. t['\u3180'] = '\u1147';
  22165. t['\u3181'] = '\u114C';
  22166. t['\u3182'] = '\u11F1';
  22167. t['\u3183'] = '\u11F2';
  22168. t['\u3184'] = '\u1157';
  22169. t['\u3185'] = '\u1158';
  22170. t['\u3186'] = '\u1159';
  22171. t['\u3187'] = '\u1184';
  22172. t['\u3188'] = '\u1185';
  22173. t['\u3189'] = '\u1188';
  22174. t['\u318A'] = '\u1191';
  22175. t['\u318B'] = '\u1192';
  22176. t['\u318C'] = '\u1194';
  22177. t['\u318D'] = '\u119E';
  22178. t['\u318E'] = '\u11A1';
  22179. t['\u3200'] = '\u0028\u1100\u0029';
  22180. t['\u3201'] = '\u0028\u1102\u0029';
  22181. t['\u3202'] = '\u0028\u1103\u0029';
  22182. t['\u3203'] = '\u0028\u1105\u0029';
  22183. t['\u3204'] = '\u0028\u1106\u0029';
  22184. t['\u3205'] = '\u0028\u1107\u0029';
  22185. t['\u3206'] = '\u0028\u1109\u0029';
  22186. t['\u3207'] = '\u0028\u110B\u0029';
  22187. t['\u3208'] = '\u0028\u110C\u0029';
  22188. t['\u3209'] = '\u0028\u110E\u0029';
  22189. t['\u320A'] = '\u0028\u110F\u0029';
  22190. t['\u320B'] = '\u0028\u1110\u0029';
  22191. t['\u320C'] = '\u0028\u1111\u0029';
  22192. t['\u320D'] = '\u0028\u1112\u0029';
  22193. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22194. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22195. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22196. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22197. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22198. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22199. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22200. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22201. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22202. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22203. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22204. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22205. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22206. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22207. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22208. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22209. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22210. t['\u3220'] = '\u0028\u4E00\u0029';
  22211. t['\u3221'] = '\u0028\u4E8C\u0029';
  22212. t['\u3222'] = '\u0028\u4E09\u0029';
  22213. t['\u3223'] = '\u0028\u56DB\u0029';
  22214. t['\u3224'] = '\u0028\u4E94\u0029';
  22215. t['\u3225'] = '\u0028\u516D\u0029';
  22216. t['\u3226'] = '\u0028\u4E03\u0029';
  22217. t['\u3227'] = '\u0028\u516B\u0029';
  22218. t['\u3228'] = '\u0028\u4E5D\u0029';
  22219. t['\u3229'] = '\u0028\u5341\u0029';
  22220. t['\u322A'] = '\u0028\u6708\u0029';
  22221. t['\u322B'] = '\u0028\u706B\u0029';
  22222. t['\u322C'] = '\u0028\u6C34\u0029';
  22223. t['\u322D'] = '\u0028\u6728\u0029';
  22224. t['\u322E'] = '\u0028\u91D1\u0029';
  22225. t['\u322F'] = '\u0028\u571F\u0029';
  22226. t['\u3230'] = '\u0028\u65E5\u0029';
  22227. t['\u3231'] = '\u0028\u682A\u0029';
  22228. t['\u3232'] = '\u0028\u6709\u0029';
  22229. t['\u3233'] = '\u0028\u793E\u0029';
  22230. t['\u3234'] = '\u0028\u540D\u0029';
  22231. t['\u3235'] = '\u0028\u7279\u0029';
  22232. t['\u3236'] = '\u0028\u8CA1\u0029';
  22233. t['\u3237'] = '\u0028\u795D\u0029';
  22234. t['\u3238'] = '\u0028\u52B4\u0029';
  22235. t['\u3239'] = '\u0028\u4EE3\u0029';
  22236. t['\u323A'] = '\u0028\u547C\u0029';
  22237. t['\u323B'] = '\u0028\u5B66\u0029';
  22238. t['\u323C'] = '\u0028\u76E3\u0029';
  22239. t['\u323D'] = '\u0028\u4F01\u0029';
  22240. t['\u323E'] = '\u0028\u8CC7\u0029';
  22241. t['\u323F'] = '\u0028\u5354\u0029';
  22242. t['\u3240'] = '\u0028\u796D\u0029';
  22243. t['\u3241'] = '\u0028\u4F11\u0029';
  22244. t['\u3242'] = '\u0028\u81EA\u0029';
  22245. t['\u3243'] = '\u0028\u81F3\u0029';
  22246. t['\u32C0'] = '\u0031\u6708';
  22247. t['\u32C1'] = '\u0032\u6708';
  22248. t['\u32C2'] = '\u0033\u6708';
  22249. t['\u32C3'] = '\u0034\u6708';
  22250. t['\u32C4'] = '\u0035\u6708';
  22251. t['\u32C5'] = '\u0036\u6708';
  22252. t['\u32C6'] = '\u0037\u6708';
  22253. t['\u32C7'] = '\u0038\u6708';
  22254. t['\u32C8'] = '\u0039\u6708';
  22255. t['\u32C9'] = '\u0031\u0030\u6708';
  22256. t['\u32CA'] = '\u0031\u0031\u6708';
  22257. t['\u32CB'] = '\u0031\u0032\u6708';
  22258. t['\u3358'] = '\u0030\u70B9';
  22259. t['\u3359'] = '\u0031\u70B9';
  22260. t['\u335A'] = '\u0032\u70B9';
  22261. t['\u335B'] = '\u0033\u70B9';
  22262. t['\u335C'] = '\u0034\u70B9';
  22263. t['\u335D'] = '\u0035\u70B9';
  22264. t['\u335E'] = '\u0036\u70B9';
  22265. t['\u335F'] = '\u0037\u70B9';
  22266. t['\u3360'] = '\u0038\u70B9';
  22267. t['\u3361'] = '\u0039\u70B9';
  22268. t['\u3362'] = '\u0031\u0030\u70B9';
  22269. t['\u3363'] = '\u0031\u0031\u70B9';
  22270. t['\u3364'] = '\u0031\u0032\u70B9';
  22271. t['\u3365'] = '\u0031\u0033\u70B9';
  22272. t['\u3366'] = '\u0031\u0034\u70B9';
  22273. t['\u3367'] = '\u0031\u0035\u70B9';
  22274. t['\u3368'] = '\u0031\u0036\u70B9';
  22275. t['\u3369'] = '\u0031\u0037\u70B9';
  22276. t['\u336A'] = '\u0031\u0038\u70B9';
  22277. t['\u336B'] = '\u0031\u0039\u70B9';
  22278. t['\u336C'] = '\u0032\u0030\u70B9';
  22279. t['\u336D'] = '\u0032\u0031\u70B9';
  22280. t['\u336E'] = '\u0032\u0032\u70B9';
  22281. t['\u336F'] = '\u0032\u0033\u70B9';
  22282. t['\u3370'] = '\u0032\u0034\u70B9';
  22283. t['\u33E0'] = '\u0031\u65E5';
  22284. t['\u33E1'] = '\u0032\u65E5';
  22285. t['\u33E2'] = '\u0033\u65E5';
  22286. t['\u33E3'] = '\u0034\u65E5';
  22287. t['\u33E4'] = '\u0035\u65E5';
  22288. t['\u33E5'] = '\u0036\u65E5';
  22289. t['\u33E6'] = '\u0037\u65E5';
  22290. t['\u33E7'] = '\u0038\u65E5';
  22291. t['\u33E8'] = '\u0039\u65E5';
  22292. t['\u33E9'] = '\u0031\u0030\u65E5';
  22293. t['\u33EA'] = '\u0031\u0031\u65E5';
  22294. t['\u33EB'] = '\u0031\u0032\u65E5';
  22295. t['\u33EC'] = '\u0031\u0033\u65E5';
  22296. t['\u33ED'] = '\u0031\u0034\u65E5';
  22297. t['\u33EE'] = '\u0031\u0035\u65E5';
  22298. t['\u33EF'] = '\u0031\u0036\u65E5';
  22299. t['\u33F0'] = '\u0031\u0037\u65E5';
  22300. t['\u33F1'] = '\u0031\u0038\u65E5';
  22301. t['\u33F2'] = '\u0031\u0039\u65E5';
  22302. t['\u33F3'] = '\u0032\u0030\u65E5';
  22303. t['\u33F4'] = '\u0032\u0031\u65E5';
  22304. t['\u33F5'] = '\u0032\u0032\u65E5';
  22305. t['\u33F6'] = '\u0032\u0033\u65E5';
  22306. t['\u33F7'] = '\u0032\u0034\u65E5';
  22307. t['\u33F8'] = '\u0032\u0035\u65E5';
  22308. t['\u33F9'] = '\u0032\u0036\u65E5';
  22309. t['\u33FA'] = '\u0032\u0037\u65E5';
  22310. t['\u33FB'] = '\u0032\u0038\u65E5';
  22311. t['\u33FC'] = '\u0032\u0039\u65E5';
  22312. t['\u33FD'] = '\u0033\u0030\u65E5';
  22313. t['\u33FE'] = '\u0033\u0031\u65E5';
  22314. t['\uFB00'] = '\u0066\u0066';
  22315. t['\uFB01'] = '\u0066\u0069';
  22316. t['\uFB02'] = '\u0066\u006C';
  22317. t['\uFB03'] = '\u0066\u0066\u0069';
  22318. t['\uFB04'] = '\u0066\u0066\u006C';
  22319. t['\uFB05'] = '\u017F\u0074';
  22320. t['\uFB06'] = '\u0073\u0074';
  22321. t['\uFB13'] = '\u0574\u0576';
  22322. t['\uFB14'] = '\u0574\u0565';
  22323. t['\uFB15'] = '\u0574\u056B';
  22324. t['\uFB16'] = '\u057E\u0576';
  22325. t['\uFB17'] = '\u0574\u056D';
  22326. t['\uFB4F'] = '\u05D0\u05DC';
  22327. t['\uFB50'] = '\u0671';
  22328. t['\uFB51'] = '\u0671';
  22329. t['\uFB52'] = '\u067B';
  22330. t['\uFB53'] = '\u067B';
  22331. t['\uFB54'] = '\u067B';
  22332. t['\uFB55'] = '\u067B';
  22333. t['\uFB56'] = '\u067E';
  22334. t['\uFB57'] = '\u067E';
  22335. t['\uFB58'] = '\u067E';
  22336. t['\uFB59'] = '\u067E';
  22337. t['\uFB5A'] = '\u0680';
  22338. t['\uFB5B'] = '\u0680';
  22339. t['\uFB5C'] = '\u0680';
  22340. t['\uFB5D'] = '\u0680';
  22341. t['\uFB5E'] = '\u067A';
  22342. t['\uFB5F'] = '\u067A';
  22343. t['\uFB60'] = '\u067A';
  22344. t['\uFB61'] = '\u067A';
  22345. t['\uFB62'] = '\u067F';
  22346. t['\uFB63'] = '\u067F';
  22347. t['\uFB64'] = '\u067F';
  22348. t['\uFB65'] = '\u067F';
  22349. t['\uFB66'] = '\u0679';
  22350. t['\uFB67'] = '\u0679';
  22351. t['\uFB68'] = '\u0679';
  22352. t['\uFB69'] = '\u0679';
  22353. t['\uFB6A'] = '\u06A4';
  22354. t['\uFB6B'] = '\u06A4';
  22355. t['\uFB6C'] = '\u06A4';
  22356. t['\uFB6D'] = '\u06A4';
  22357. t['\uFB6E'] = '\u06A6';
  22358. t['\uFB6F'] = '\u06A6';
  22359. t['\uFB70'] = '\u06A6';
  22360. t['\uFB71'] = '\u06A6';
  22361. t['\uFB72'] = '\u0684';
  22362. t['\uFB73'] = '\u0684';
  22363. t['\uFB74'] = '\u0684';
  22364. t['\uFB75'] = '\u0684';
  22365. t['\uFB76'] = '\u0683';
  22366. t['\uFB77'] = '\u0683';
  22367. t['\uFB78'] = '\u0683';
  22368. t['\uFB79'] = '\u0683';
  22369. t['\uFB7A'] = '\u0686';
  22370. t['\uFB7B'] = '\u0686';
  22371. t['\uFB7C'] = '\u0686';
  22372. t['\uFB7D'] = '\u0686';
  22373. t['\uFB7E'] = '\u0687';
  22374. t['\uFB7F'] = '\u0687';
  22375. t['\uFB80'] = '\u0687';
  22376. t['\uFB81'] = '\u0687';
  22377. t['\uFB82'] = '\u068D';
  22378. t['\uFB83'] = '\u068D';
  22379. t['\uFB84'] = '\u068C';
  22380. t['\uFB85'] = '\u068C';
  22381. t['\uFB86'] = '\u068E';
  22382. t['\uFB87'] = '\u068E';
  22383. t['\uFB88'] = '\u0688';
  22384. t['\uFB89'] = '\u0688';
  22385. t['\uFB8A'] = '\u0698';
  22386. t['\uFB8B'] = '\u0698';
  22387. t['\uFB8C'] = '\u0691';
  22388. t['\uFB8D'] = '\u0691';
  22389. t['\uFB8E'] = '\u06A9';
  22390. t['\uFB8F'] = '\u06A9';
  22391. t['\uFB90'] = '\u06A9';
  22392. t['\uFB91'] = '\u06A9';
  22393. t['\uFB92'] = '\u06AF';
  22394. t['\uFB93'] = '\u06AF';
  22395. t['\uFB94'] = '\u06AF';
  22396. t['\uFB95'] = '\u06AF';
  22397. t['\uFB96'] = '\u06B3';
  22398. t['\uFB97'] = '\u06B3';
  22399. t['\uFB98'] = '\u06B3';
  22400. t['\uFB99'] = '\u06B3';
  22401. t['\uFB9A'] = '\u06B1';
  22402. t['\uFB9B'] = '\u06B1';
  22403. t['\uFB9C'] = '\u06B1';
  22404. t['\uFB9D'] = '\u06B1';
  22405. t['\uFB9E'] = '\u06BA';
  22406. t['\uFB9F'] = '\u06BA';
  22407. t['\uFBA0'] = '\u06BB';
  22408. t['\uFBA1'] = '\u06BB';
  22409. t['\uFBA2'] = '\u06BB';
  22410. t['\uFBA3'] = '\u06BB';
  22411. t['\uFBA4'] = '\u06C0';
  22412. t['\uFBA5'] = '\u06C0';
  22413. t['\uFBA6'] = '\u06C1';
  22414. t['\uFBA7'] = '\u06C1';
  22415. t['\uFBA8'] = '\u06C1';
  22416. t['\uFBA9'] = '\u06C1';
  22417. t['\uFBAA'] = '\u06BE';
  22418. t['\uFBAB'] = '\u06BE';
  22419. t['\uFBAC'] = '\u06BE';
  22420. t['\uFBAD'] = '\u06BE';
  22421. t['\uFBAE'] = '\u06D2';
  22422. t['\uFBAF'] = '\u06D2';
  22423. t['\uFBB0'] = '\u06D3';
  22424. t['\uFBB1'] = '\u06D3';
  22425. t['\uFBD3'] = '\u06AD';
  22426. t['\uFBD4'] = '\u06AD';
  22427. t['\uFBD5'] = '\u06AD';
  22428. t['\uFBD6'] = '\u06AD';
  22429. t['\uFBD7'] = '\u06C7';
  22430. t['\uFBD8'] = '\u06C7';
  22431. t['\uFBD9'] = '\u06C6';
  22432. t['\uFBDA'] = '\u06C6';
  22433. t['\uFBDB'] = '\u06C8';
  22434. t['\uFBDC'] = '\u06C8';
  22435. t['\uFBDD'] = '\u0677';
  22436. t['\uFBDE'] = '\u06CB';
  22437. t['\uFBDF'] = '\u06CB';
  22438. t['\uFBE0'] = '\u06C5';
  22439. t['\uFBE1'] = '\u06C5';
  22440. t['\uFBE2'] = '\u06C9';
  22441. t['\uFBE3'] = '\u06C9';
  22442. t['\uFBE4'] = '\u06D0';
  22443. t['\uFBE5'] = '\u06D0';
  22444. t['\uFBE6'] = '\u06D0';
  22445. t['\uFBE7'] = '\u06D0';
  22446. t['\uFBE8'] = '\u0649';
  22447. t['\uFBE9'] = '\u0649';
  22448. t['\uFBEA'] = '\u0626\u0627';
  22449. t['\uFBEB'] = '\u0626\u0627';
  22450. t['\uFBEC'] = '\u0626\u06D5';
  22451. t['\uFBED'] = '\u0626\u06D5';
  22452. t['\uFBEE'] = '\u0626\u0648';
  22453. t['\uFBEF'] = '\u0626\u0648';
  22454. t['\uFBF0'] = '\u0626\u06C7';
  22455. t['\uFBF1'] = '\u0626\u06C7';
  22456. t['\uFBF2'] = '\u0626\u06C6';
  22457. t['\uFBF3'] = '\u0626\u06C6';
  22458. t['\uFBF4'] = '\u0626\u06C8';
  22459. t['\uFBF5'] = '\u0626\u06C8';
  22460. t['\uFBF6'] = '\u0626\u06D0';
  22461. t['\uFBF7'] = '\u0626\u06D0';
  22462. t['\uFBF8'] = '\u0626\u06D0';
  22463. t['\uFBF9'] = '\u0626\u0649';
  22464. t['\uFBFA'] = '\u0626\u0649';
  22465. t['\uFBFB'] = '\u0626\u0649';
  22466. t['\uFBFC'] = '\u06CC';
  22467. t['\uFBFD'] = '\u06CC';
  22468. t['\uFBFE'] = '\u06CC';
  22469. t['\uFBFF'] = '\u06CC';
  22470. t['\uFC00'] = '\u0626\u062C';
  22471. t['\uFC01'] = '\u0626\u062D';
  22472. t['\uFC02'] = '\u0626\u0645';
  22473. t['\uFC03'] = '\u0626\u0649';
  22474. t['\uFC04'] = '\u0626\u064A';
  22475. t['\uFC05'] = '\u0628\u062C';
  22476. t['\uFC06'] = '\u0628\u062D';
  22477. t['\uFC07'] = '\u0628\u062E';
  22478. t['\uFC08'] = '\u0628\u0645';
  22479. t['\uFC09'] = '\u0628\u0649';
  22480. t['\uFC0A'] = '\u0628\u064A';
  22481. t['\uFC0B'] = '\u062A\u062C';
  22482. t['\uFC0C'] = '\u062A\u062D';
  22483. t['\uFC0D'] = '\u062A\u062E';
  22484. t['\uFC0E'] = '\u062A\u0645';
  22485. t['\uFC0F'] = '\u062A\u0649';
  22486. t['\uFC10'] = '\u062A\u064A';
  22487. t['\uFC11'] = '\u062B\u062C';
  22488. t['\uFC12'] = '\u062B\u0645';
  22489. t['\uFC13'] = '\u062B\u0649';
  22490. t['\uFC14'] = '\u062B\u064A';
  22491. t['\uFC15'] = '\u062C\u062D';
  22492. t['\uFC16'] = '\u062C\u0645';
  22493. t['\uFC17'] = '\u062D\u062C';
  22494. t['\uFC18'] = '\u062D\u0645';
  22495. t['\uFC19'] = '\u062E\u062C';
  22496. t['\uFC1A'] = '\u062E\u062D';
  22497. t['\uFC1B'] = '\u062E\u0645';
  22498. t['\uFC1C'] = '\u0633\u062C';
  22499. t['\uFC1D'] = '\u0633\u062D';
  22500. t['\uFC1E'] = '\u0633\u062E';
  22501. t['\uFC1F'] = '\u0633\u0645';
  22502. t['\uFC20'] = '\u0635\u062D';
  22503. t['\uFC21'] = '\u0635\u0645';
  22504. t['\uFC22'] = '\u0636\u062C';
  22505. t['\uFC23'] = '\u0636\u062D';
  22506. t['\uFC24'] = '\u0636\u062E';
  22507. t['\uFC25'] = '\u0636\u0645';
  22508. t['\uFC26'] = '\u0637\u062D';
  22509. t['\uFC27'] = '\u0637\u0645';
  22510. t['\uFC28'] = '\u0638\u0645';
  22511. t['\uFC29'] = '\u0639\u062C';
  22512. t['\uFC2A'] = '\u0639\u0645';
  22513. t['\uFC2B'] = '\u063A\u062C';
  22514. t['\uFC2C'] = '\u063A\u0645';
  22515. t['\uFC2D'] = '\u0641\u062C';
  22516. t['\uFC2E'] = '\u0641\u062D';
  22517. t['\uFC2F'] = '\u0641\u062E';
  22518. t['\uFC30'] = '\u0641\u0645';
  22519. t['\uFC31'] = '\u0641\u0649';
  22520. t['\uFC32'] = '\u0641\u064A';
  22521. t['\uFC33'] = '\u0642\u062D';
  22522. t['\uFC34'] = '\u0642\u0645';
  22523. t['\uFC35'] = '\u0642\u0649';
  22524. t['\uFC36'] = '\u0642\u064A';
  22525. t['\uFC37'] = '\u0643\u0627';
  22526. t['\uFC38'] = '\u0643\u062C';
  22527. t['\uFC39'] = '\u0643\u062D';
  22528. t['\uFC3A'] = '\u0643\u062E';
  22529. t['\uFC3B'] = '\u0643\u0644';
  22530. t['\uFC3C'] = '\u0643\u0645';
  22531. t['\uFC3D'] = '\u0643\u0649';
  22532. t['\uFC3E'] = '\u0643\u064A';
  22533. t['\uFC3F'] = '\u0644\u062C';
  22534. t['\uFC40'] = '\u0644\u062D';
  22535. t['\uFC41'] = '\u0644\u062E';
  22536. t['\uFC42'] = '\u0644\u0645';
  22537. t['\uFC43'] = '\u0644\u0649';
  22538. t['\uFC44'] = '\u0644\u064A';
  22539. t['\uFC45'] = '\u0645\u062C';
  22540. t['\uFC46'] = '\u0645\u062D';
  22541. t['\uFC47'] = '\u0645\u062E';
  22542. t['\uFC48'] = '\u0645\u0645';
  22543. t['\uFC49'] = '\u0645\u0649';
  22544. t['\uFC4A'] = '\u0645\u064A';
  22545. t['\uFC4B'] = '\u0646\u062C';
  22546. t['\uFC4C'] = '\u0646\u062D';
  22547. t['\uFC4D'] = '\u0646\u062E';
  22548. t['\uFC4E'] = '\u0646\u0645';
  22549. t['\uFC4F'] = '\u0646\u0649';
  22550. t['\uFC50'] = '\u0646\u064A';
  22551. t['\uFC51'] = '\u0647\u062C';
  22552. t['\uFC52'] = '\u0647\u0645';
  22553. t['\uFC53'] = '\u0647\u0649';
  22554. t['\uFC54'] = '\u0647\u064A';
  22555. t['\uFC55'] = '\u064A\u062C';
  22556. t['\uFC56'] = '\u064A\u062D';
  22557. t['\uFC57'] = '\u064A\u062E';
  22558. t['\uFC58'] = '\u064A\u0645';
  22559. t['\uFC59'] = '\u064A\u0649';
  22560. t['\uFC5A'] = '\u064A\u064A';
  22561. t['\uFC5B'] = '\u0630\u0670';
  22562. t['\uFC5C'] = '\u0631\u0670';
  22563. t['\uFC5D'] = '\u0649\u0670';
  22564. t['\uFC5E'] = '\u0020\u064C\u0651';
  22565. t['\uFC5F'] = '\u0020\u064D\u0651';
  22566. t['\uFC60'] = '\u0020\u064E\u0651';
  22567. t['\uFC61'] = '\u0020\u064F\u0651';
  22568. t['\uFC62'] = '\u0020\u0650\u0651';
  22569. t['\uFC63'] = '\u0020\u0651\u0670';
  22570. t['\uFC64'] = '\u0626\u0631';
  22571. t['\uFC65'] = '\u0626\u0632';
  22572. t['\uFC66'] = '\u0626\u0645';
  22573. t['\uFC67'] = '\u0626\u0646';
  22574. t['\uFC68'] = '\u0626\u0649';
  22575. t['\uFC69'] = '\u0626\u064A';
  22576. t['\uFC6A'] = '\u0628\u0631';
  22577. t['\uFC6B'] = '\u0628\u0632';
  22578. t['\uFC6C'] = '\u0628\u0645';
  22579. t['\uFC6D'] = '\u0628\u0646';
  22580. t['\uFC6E'] = '\u0628\u0649';
  22581. t['\uFC6F'] = '\u0628\u064A';
  22582. t['\uFC70'] = '\u062A\u0631';
  22583. t['\uFC71'] = '\u062A\u0632';
  22584. t['\uFC72'] = '\u062A\u0645';
  22585. t['\uFC73'] = '\u062A\u0646';
  22586. t['\uFC74'] = '\u062A\u0649';
  22587. t['\uFC75'] = '\u062A\u064A';
  22588. t['\uFC76'] = '\u062B\u0631';
  22589. t['\uFC77'] = '\u062B\u0632';
  22590. t['\uFC78'] = '\u062B\u0645';
  22591. t['\uFC79'] = '\u062B\u0646';
  22592. t['\uFC7A'] = '\u062B\u0649';
  22593. t['\uFC7B'] = '\u062B\u064A';
  22594. t['\uFC7C'] = '\u0641\u0649';
  22595. t['\uFC7D'] = '\u0641\u064A';
  22596. t['\uFC7E'] = '\u0642\u0649';
  22597. t['\uFC7F'] = '\u0642\u064A';
  22598. t['\uFC80'] = '\u0643\u0627';
  22599. t['\uFC81'] = '\u0643\u0644';
  22600. t['\uFC82'] = '\u0643\u0645';
  22601. t['\uFC83'] = '\u0643\u0649';
  22602. t['\uFC84'] = '\u0643\u064A';
  22603. t['\uFC85'] = '\u0644\u0645';
  22604. t['\uFC86'] = '\u0644\u0649';
  22605. t['\uFC87'] = '\u0644\u064A';
  22606. t['\uFC88'] = '\u0645\u0627';
  22607. t['\uFC89'] = '\u0645\u0645';
  22608. t['\uFC8A'] = '\u0646\u0631';
  22609. t['\uFC8B'] = '\u0646\u0632';
  22610. t['\uFC8C'] = '\u0646\u0645';
  22611. t['\uFC8D'] = '\u0646\u0646';
  22612. t['\uFC8E'] = '\u0646\u0649';
  22613. t['\uFC8F'] = '\u0646\u064A';
  22614. t['\uFC90'] = '\u0649\u0670';
  22615. t['\uFC91'] = '\u064A\u0631';
  22616. t['\uFC92'] = '\u064A\u0632';
  22617. t['\uFC93'] = '\u064A\u0645';
  22618. t['\uFC94'] = '\u064A\u0646';
  22619. t['\uFC95'] = '\u064A\u0649';
  22620. t['\uFC96'] = '\u064A\u064A';
  22621. t['\uFC97'] = '\u0626\u062C';
  22622. t['\uFC98'] = '\u0626\u062D';
  22623. t['\uFC99'] = '\u0626\u062E';
  22624. t['\uFC9A'] = '\u0626\u0645';
  22625. t['\uFC9B'] = '\u0626\u0647';
  22626. t['\uFC9C'] = '\u0628\u062C';
  22627. t['\uFC9D'] = '\u0628\u062D';
  22628. t['\uFC9E'] = '\u0628\u062E';
  22629. t['\uFC9F'] = '\u0628\u0645';
  22630. t['\uFCA0'] = '\u0628\u0647';
  22631. t['\uFCA1'] = '\u062A\u062C';
  22632. t['\uFCA2'] = '\u062A\u062D';
  22633. t['\uFCA3'] = '\u062A\u062E';
  22634. t['\uFCA4'] = '\u062A\u0645';
  22635. t['\uFCA5'] = '\u062A\u0647';
  22636. t['\uFCA6'] = '\u062B\u0645';
  22637. t['\uFCA7'] = '\u062C\u062D';
  22638. t['\uFCA8'] = '\u062C\u0645';
  22639. t['\uFCA9'] = '\u062D\u062C';
  22640. t['\uFCAA'] = '\u062D\u0645';
  22641. t['\uFCAB'] = '\u062E\u062C';
  22642. t['\uFCAC'] = '\u062E\u0645';
  22643. t['\uFCAD'] = '\u0633\u062C';
  22644. t['\uFCAE'] = '\u0633\u062D';
  22645. t['\uFCAF'] = '\u0633\u062E';
  22646. t['\uFCB0'] = '\u0633\u0645';
  22647. t['\uFCB1'] = '\u0635\u062D';
  22648. t['\uFCB2'] = '\u0635\u062E';
  22649. t['\uFCB3'] = '\u0635\u0645';
  22650. t['\uFCB4'] = '\u0636\u062C';
  22651. t['\uFCB5'] = '\u0636\u062D';
  22652. t['\uFCB6'] = '\u0636\u062E';
  22653. t['\uFCB7'] = '\u0636\u0645';
  22654. t['\uFCB8'] = '\u0637\u062D';
  22655. t['\uFCB9'] = '\u0638\u0645';
  22656. t['\uFCBA'] = '\u0639\u062C';
  22657. t['\uFCBB'] = '\u0639\u0645';
  22658. t['\uFCBC'] = '\u063A\u062C';
  22659. t['\uFCBD'] = '\u063A\u0645';
  22660. t['\uFCBE'] = '\u0641\u062C';
  22661. t['\uFCBF'] = '\u0641\u062D';
  22662. t['\uFCC0'] = '\u0641\u062E';
  22663. t['\uFCC1'] = '\u0641\u0645';
  22664. t['\uFCC2'] = '\u0642\u062D';
  22665. t['\uFCC3'] = '\u0642\u0645';
  22666. t['\uFCC4'] = '\u0643\u062C';
  22667. t['\uFCC5'] = '\u0643\u062D';
  22668. t['\uFCC6'] = '\u0643\u062E';
  22669. t['\uFCC7'] = '\u0643\u0644';
  22670. t['\uFCC8'] = '\u0643\u0645';
  22671. t['\uFCC9'] = '\u0644\u062C';
  22672. t['\uFCCA'] = '\u0644\u062D';
  22673. t['\uFCCB'] = '\u0644\u062E';
  22674. t['\uFCCC'] = '\u0644\u0645';
  22675. t['\uFCCD'] = '\u0644\u0647';
  22676. t['\uFCCE'] = '\u0645\u062C';
  22677. t['\uFCCF'] = '\u0645\u062D';
  22678. t['\uFCD0'] = '\u0645\u062E';
  22679. t['\uFCD1'] = '\u0645\u0645';
  22680. t['\uFCD2'] = '\u0646\u062C';
  22681. t['\uFCD3'] = '\u0646\u062D';
  22682. t['\uFCD4'] = '\u0646\u062E';
  22683. t['\uFCD5'] = '\u0646\u0645';
  22684. t['\uFCD6'] = '\u0646\u0647';
  22685. t['\uFCD7'] = '\u0647\u062C';
  22686. t['\uFCD8'] = '\u0647\u0645';
  22687. t['\uFCD9'] = '\u0647\u0670';
  22688. t['\uFCDA'] = '\u064A\u062C';
  22689. t['\uFCDB'] = '\u064A\u062D';
  22690. t['\uFCDC'] = '\u064A\u062E';
  22691. t['\uFCDD'] = '\u064A\u0645';
  22692. t['\uFCDE'] = '\u064A\u0647';
  22693. t['\uFCDF'] = '\u0626\u0645';
  22694. t['\uFCE0'] = '\u0626\u0647';
  22695. t['\uFCE1'] = '\u0628\u0645';
  22696. t['\uFCE2'] = '\u0628\u0647';
  22697. t['\uFCE3'] = '\u062A\u0645';
  22698. t['\uFCE4'] = '\u062A\u0647';
  22699. t['\uFCE5'] = '\u062B\u0645';
  22700. t['\uFCE6'] = '\u062B\u0647';
  22701. t['\uFCE7'] = '\u0633\u0645';
  22702. t['\uFCE8'] = '\u0633\u0647';
  22703. t['\uFCE9'] = '\u0634\u0645';
  22704. t['\uFCEA'] = '\u0634\u0647';
  22705. t['\uFCEB'] = '\u0643\u0644';
  22706. t['\uFCEC'] = '\u0643\u0645';
  22707. t['\uFCED'] = '\u0644\u0645';
  22708. t['\uFCEE'] = '\u0646\u0645';
  22709. t['\uFCEF'] = '\u0646\u0647';
  22710. t['\uFCF0'] = '\u064A\u0645';
  22711. t['\uFCF1'] = '\u064A\u0647';
  22712. t['\uFCF2'] = '\u0640\u064E\u0651';
  22713. t['\uFCF3'] = '\u0640\u064F\u0651';
  22714. t['\uFCF4'] = '\u0640\u0650\u0651';
  22715. t['\uFCF5'] = '\u0637\u0649';
  22716. t['\uFCF6'] = '\u0637\u064A';
  22717. t['\uFCF7'] = '\u0639\u0649';
  22718. t['\uFCF8'] = '\u0639\u064A';
  22719. t['\uFCF9'] = '\u063A\u0649';
  22720. t['\uFCFA'] = '\u063A\u064A';
  22721. t['\uFCFB'] = '\u0633\u0649';
  22722. t['\uFCFC'] = '\u0633\u064A';
  22723. t['\uFCFD'] = '\u0634\u0649';
  22724. t['\uFCFE'] = '\u0634\u064A';
  22725. t['\uFCFF'] = '\u062D\u0649';
  22726. t['\uFD00'] = '\u062D\u064A';
  22727. t['\uFD01'] = '\u062C\u0649';
  22728. t['\uFD02'] = '\u062C\u064A';
  22729. t['\uFD03'] = '\u062E\u0649';
  22730. t['\uFD04'] = '\u062E\u064A';
  22731. t['\uFD05'] = '\u0635\u0649';
  22732. t['\uFD06'] = '\u0635\u064A';
  22733. t['\uFD07'] = '\u0636\u0649';
  22734. t['\uFD08'] = '\u0636\u064A';
  22735. t['\uFD09'] = '\u0634\u062C';
  22736. t['\uFD0A'] = '\u0634\u062D';
  22737. t['\uFD0B'] = '\u0634\u062E';
  22738. t['\uFD0C'] = '\u0634\u0645';
  22739. t['\uFD0D'] = '\u0634\u0631';
  22740. t['\uFD0E'] = '\u0633\u0631';
  22741. t['\uFD0F'] = '\u0635\u0631';
  22742. t['\uFD10'] = '\u0636\u0631';
  22743. t['\uFD11'] = '\u0637\u0649';
  22744. t['\uFD12'] = '\u0637\u064A';
  22745. t['\uFD13'] = '\u0639\u0649';
  22746. t['\uFD14'] = '\u0639\u064A';
  22747. t['\uFD15'] = '\u063A\u0649';
  22748. t['\uFD16'] = '\u063A\u064A';
  22749. t['\uFD17'] = '\u0633\u0649';
  22750. t['\uFD18'] = '\u0633\u064A';
  22751. t['\uFD19'] = '\u0634\u0649';
  22752. t['\uFD1A'] = '\u0634\u064A';
  22753. t['\uFD1B'] = '\u062D\u0649';
  22754. t['\uFD1C'] = '\u062D\u064A';
  22755. t['\uFD1D'] = '\u062C\u0649';
  22756. t['\uFD1E'] = '\u062C\u064A';
  22757. t['\uFD1F'] = '\u062E\u0649';
  22758. t['\uFD20'] = '\u062E\u064A';
  22759. t['\uFD21'] = '\u0635\u0649';
  22760. t['\uFD22'] = '\u0635\u064A';
  22761. t['\uFD23'] = '\u0636\u0649';
  22762. t['\uFD24'] = '\u0636\u064A';
  22763. t['\uFD25'] = '\u0634\u062C';
  22764. t['\uFD26'] = '\u0634\u062D';
  22765. t['\uFD27'] = '\u0634\u062E';
  22766. t['\uFD28'] = '\u0634\u0645';
  22767. t['\uFD29'] = '\u0634\u0631';
  22768. t['\uFD2A'] = '\u0633\u0631';
  22769. t['\uFD2B'] = '\u0635\u0631';
  22770. t['\uFD2C'] = '\u0636\u0631';
  22771. t['\uFD2D'] = '\u0634\u062C';
  22772. t['\uFD2E'] = '\u0634\u062D';
  22773. t['\uFD2F'] = '\u0634\u062E';
  22774. t['\uFD30'] = '\u0634\u0645';
  22775. t['\uFD31'] = '\u0633\u0647';
  22776. t['\uFD32'] = '\u0634\u0647';
  22777. t['\uFD33'] = '\u0637\u0645';
  22778. t['\uFD34'] = '\u0633\u062C';
  22779. t['\uFD35'] = '\u0633\u062D';
  22780. t['\uFD36'] = '\u0633\u062E';
  22781. t['\uFD37'] = '\u0634\u062C';
  22782. t['\uFD38'] = '\u0634\u062D';
  22783. t['\uFD39'] = '\u0634\u062E';
  22784. t['\uFD3A'] = '\u0637\u0645';
  22785. t['\uFD3B'] = '\u0638\u0645';
  22786. t['\uFD3C'] = '\u0627\u064B';
  22787. t['\uFD3D'] = '\u0627\u064B';
  22788. t['\uFD50'] = '\u062A\u062C\u0645';
  22789. t['\uFD51'] = '\u062A\u062D\u062C';
  22790. t['\uFD52'] = '\u062A\u062D\u062C';
  22791. t['\uFD53'] = '\u062A\u062D\u0645';
  22792. t['\uFD54'] = '\u062A\u062E\u0645';
  22793. t['\uFD55'] = '\u062A\u0645\u062C';
  22794. t['\uFD56'] = '\u062A\u0645\u062D';
  22795. t['\uFD57'] = '\u062A\u0645\u062E';
  22796. t['\uFD58'] = '\u062C\u0645\u062D';
  22797. t['\uFD59'] = '\u062C\u0645\u062D';
  22798. t['\uFD5A'] = '\u062D\u0645\u064A';
  22799. t['\uFD5B'] = '\u062D\u0645\u0649';
  22800. t['\uFD5C'] = '\u0633\u062D\u062C';
  22801. t['\uFD5D'] = '\u0633\u062C\u062D';
  22802. t['\uFD5E'] = '\u0633\u062C\u0649';
  22803. t['\uFD5F'] = '\u0633\u0645\u062D';
  22804. t['\uFD60'] = '\u0633\u0645\u062D';
  22805. t['\uFD61'] = '\u0633\u0645\u062C';
  22806. t['\uFD62'] = '\u0633\u0645\u0645';
  22807. t['\uFD63'] = '\u0633\u0645\u0645';
  22808. t['\uFD64'] = '\u0635\u062D\u062D';
  22809. t['\uFD65'] = '\u0635\u062D\u062D';
  22810. t['\uFD66'] = '\u0635\u0645\u0645';
  22811. t['\uFD67'] = '\u0634\u062D\u0645';
  22812. t['\uFD68'] = '\u0634\u062D\u0645';
  22813. t['\uFD69'] = '\u0634\u062C\u064A';
  22814. t['\uFD6A'] = '\u0634\u0645\u062E';
  22815. t['\uFD6B'] = '\u0634\u0645\u062E';
  22816. t['\uFD6C'] = '\u0634\u0645\u0645';
  22817. t['\uFD6D'] = '\u0634\u0645\u0645';
  22818. t['\uFD6E'] = '\u0636\u062D\u0649';
  22819. t['\uFD6F'] = '\u0636\u062E\u0645';
  22820. t['\uFD70'] = '\u0636\u062E\u0645';
  22821. t['\uFD71'] = '\u0637\u0645\u062D';
  22822. t['\uFD72'] = '\u0637\u0645\u062D';
  22823. t['\uFD73'] = '\u0637\u0645\u0645';
  22824. t['\uFD74'] = '\u0637\u0645\u064A';
  22825. t['\uFD75'] = '\u0639\u062C\u0645';
  22826. t['\uFD76'] = '\u0639\u0645\u0645';
  22827. t['\uFD77'] = '\u0639\u0645\u0645';
  22828. t['\uFD78'] = '\u0639\u0645\u0649';
  22829. t['\uFD79'] = '\u063A\u0645\u0645';
  22830. t['\uFD7A'] = '\u063A\u0645\u064A';
  22831. t['\uFD7B'] = '\u063A\u0645\u0649';
  22832. t['\uFD7C'] = '\u0641\u062E\u0645';
  22833. t['\uFD7D'] = '\u0641\u062E\u0645';
  22834. t['\uFD7E'] = '\u0642\u0645\u062D';
  22835. t['\uFD7F'] = '\u0642\u0645\u0645';
  22836. t['\uFD80'] = '\u0644\u062D\u0645';
  22837. t['\uFD81'] = '\u0644\u062D\u064A';
  22838. t['\uFD82'] = '\u0644\u062D\u0649';
  22839. t['\uFD83'] = '\u0644\u062C\u062C';
  22840. t['\uFD84'] = '\u0644\u062C\u062C';
  22841. t['\uFD85'] = '\u0644\u062E\u0645';
  22842. t['\uFD86'] = '\u0644\u062E\u0645';
  22843. t['\uFD87'] = '\u0644\u0645\u062D';
  22844. t['\uFD88'] = '\u0644\u0645\u062D';
  22845. t['\uFD89'] = '\u0645\u062D\u062C';
  22846. t['\uFD8A'] = '\u0645\u062D\u0645';
  22847. t['\uFD8B'] = '\u0645\u062D\u064A';
  22848. t['\uFD8C'] = '\u0645\u062C\u062D';
  22849. t['\uFD8D'] = '\u0645\u062C\u0645';
  22850. t['\uFD8E'] = '\u0645\u062E\u062C';
  22851. t['\uFD8F'] = '\u0645\u062E\u0645';
  22852. t['\uFD92'] = '\u0645\u062C\u062E';
  22853. t['\uFD93'] = '\u0647\u0645\u062C';
  22854. t['\uFD94'] = '\u0647\u0645\u0645';
  22855. t['\uFD95'] = '\u0646\u062D\u0645';
  22856. t['\uFD96'] = '\u0646\u062D\u0649';
  22857. t['\uFD97'] = '\u0646\u062C\u0645';
  22858. t['\uFD98'] = '\u0646\u062C\u0645';
  22859. t['\uFD99'] = '\u0646\u062C\u0649';
  22860. t['\uFD9A'] = '\u0646\u0645\u064A';
  22861. t['\uFD9B'] = '\u0646\u0645\u0649';
  22862. t['\uFD9C'] = '\u064A\u0645\u0645';
  22863. t['\uFD9D'] = '\u064A\u0645\u0645';
  22864. t['\uFD9E'] = '\u0628\u062E\u064A';
  22865. t['\uFD9F'] = '\u062A\u062C\u064A';
  22866. t['\uFDA0'] = '\u062A\u062C\u0649';
  22867. t['\uFDA1'] = '\u062A\u062E\u064A';
  22868. t['\uFDA2'] = '\u062A\u062E\u0649';
  22869. t['\uFDA3'] = '\u062A\u0645\u064A';
  22870. t['\uFDA4'] = '\u062A\u0645\u0649';
  22871. t['\uFDA5'] = '\u062C\u0645\u064A';
  22872. t['\uFDA6'] = '\u062C\u062D\u0649';
  22873. t['\uFDA7'] = '\u062C\u0645\u0649';
  22874. t['\uFDA8'] = '\u0633\u062E\u0649';
  22875. t['\uFDA9'] = '\u0635\u062D\u064A';
  22876. t['\uFDAA'] = '\u0634\u062D\u064A';
  22877. t['\uFDAB'] = '\u0636\u062D\u064A';
  22878. t['\uFDAC'] = '\u0644\u062C\u064A';
  22879. t['\uFDAD'] = '\u0644\u0645\u064A';
  22880. t['\uFDAE'] = '\u064A\u062D\u064A';
  22881. t['\uFDAF'] = '\u064A\u062C\u064A';
  22882. t['\uFDB0'] = '\u064A\u0645\u064A';
  22883. t['\uFDB1'] = '\u0645\u0645\u064A';
  22884. t['\uFDB2'] = '\u0642\u0645\u064A';
  22885. t['\uFDB3'] = '\u0646\u062D\u064A';
  22886. t['\uFDB4'] = '\u0642\u0645\u062D';
  22887. t['\uFDB5'] = '\u0644\u062D\u0645';
  22888. t['\uFDB6'] = '\u0639\u0645\u064A';
  22889. t['\uFDB7'] = '\u0643\u0645\u064A';
  22890. t['\uFDB8'] = '\u0646\u062C\u062D';
  22891. t['\uFDB9'] = '\u0645\u062E\u064A';
  22892. t['\uFDBA'] = '\u0644\u062C\u0645';
  22893. t['\uFDBB'] = '\u0643\u0645\u0645';
  22894. t['\uFDBC'] = '\u0644\u062C\u0645';
  22895. t['\uFDBD'] = '\u0646\u062C\u062D';
  22896. t['\uFDBE'] = '\u062C\u062D\u064A';
  22897. t['\uFDBF'] = '\u062D\u062C\u064A';
  22898. t['\uFDC0'] = '\u0645\u062C\u064A';
  22899. t['\uFDC1'] = '\u0641\u0645\u064A';
  22900. t['\uFDC2'] = '\u0628\u062D\u064A';
  22901. t['\uFDC3'] = '\u0643\u0645\u0645';
  22902. t['\uFDC4'] = '\u0639\u062C\u0645';
  22903. t['\uFDC5'] = '\u0635\u0645\u0645';
  22904. t['\uFDC6'] = '\u0633\u062E\u064A';
  22905. t['\uFDC7'] = '\u0646\u062C\u064A';
  22906. t['\uFE49'] = '\u203E';
  22907. t['\uFE4A'] = '\u203E';
  22908. t['\uFE4B'] = '\u203E';
  22909. t['\uFE4C'] = '\u203E';
  22910. t['\uFE4D'] = '\u005F';
  22911. t['\uFE4E'] = '\u005F';
  22912. t['\uFE4F'] = '\u005F';
  22913. t['\uFE80'] = '\u0621';
  22914. t['\uFE81'] = '\u0622';
  22915. t['\uFE82'] = '\u0622';
  22916. t['\uFE83'] = '\u0623';
  22917. t['\uFE84'] = '\u0623';
  22918. t['\uFE85'] = '\u0624';
  22919. t['\uFE86'] = '\u0624';
  22920. t['\uFE87'] = '\u0625';
  22921. t['\uFE88'] = '\u0625';
  22922. t['\uFE89'] = '\u0626';
  22923. t['\uFE8A'] = '\u0626';
  22924. t['\uFE8B'] = '\u0626';
  22925. t['\uFE8C'] = '\u0626';
  22926. t['\uFE8D'] = '\u0627';
  22927. t['\uFE8E'] = '\u0627';
  22928. t['\uFE8F'] = '\u0628';
  22929. t['\uFE90'] = '\u0628';
  22930. t['\uFE91'] = '\u0628';
  22931. t['\uFE92'] = '\u0628';
  22932. t['\uFE93'] = '\u0629';
  22933. t['\uFE94'] = '\u0629';
  22934. t['\uFE95'] = '\u062A';
  22935. t['\uFE96'] = '\u062A';
  22936. t['\uFE97'] = '\u062A';
  22937. t['\uFE98'] = '\u062A';
  22938. t['\uFE99'] = '\u062B';
  22939. t['\uFE9A'] = '\u062B';
  22940. t['\uFE9B'] = '\u062B';
  22941. t['\uFE9C'] = '\u062B';
  22942. t['\uFE9D'] = '\u062C';
  22943. t['\uFE9E'] = '\u062C';
  22944. t['\uFE9F'] = '\u062C';
  22945. t['\uFEA0'] = '\u062C';
  22946. t['\uFEA1'] = '\u062D';
  22947. t['\uFEA2'] = '\u062D';
  22948. t['\uFEA3'] = '\u062D';
  22949. t['\uFEA4'] = '\u062D';
  22950. t['\uFEA5'] = '\u062E';
  22951. t['\uFEA6'] = '\u062E';
  22952. t['\uFEA7'] = '\u062E';
  22953. t['\uFEA8'] = '\u062E';
  22954. t['\uFEA9'] = '\u062F';
  22955. t['\uFEAA'] = '\u062F';
  22956. t['\uFEAB'] = '\u0630';
  22957. t['\uFEAC'] = '\u0630';
  22958. t['\uFEAD'] = '\u0631';
  22959. t['\uFEAE'] = '\u0631';
  22960. t['\uFEAF'] = '\u0632';
  22961. t['\uFEB0'] = '\u0632';
  22962. t['\uFEB1'] = '\u0633';
  22963. t['\uFEB2'] = '\u0633';
  22964. t['\uFEB3'] = '\u0633';
  22965. t['\uFEB4'] = '\u0633';
  22966. t['\uFEB5'] = '\u0634';
  22967. t['\uFEB6'] = '\u0634';
  22968. t['\uFEB7'] = '\u0634';
  22969. t['\uFEB8'] = '\u0634';
  22970. t['\uFEB9'] = '\u0635';
  22971. t['\uFEBA'] = '\u0635';
  22972. t['\uFEBB'] = '\u0635';
  22973. t['\uFEBC'] = '\u0635';
  22974. t['\uFEBD'] = '\u0636';
  22975. t['\uFEBE'] = '\u0636';
  22976. t['\uFEBF'] = '\u0636';
  22977. t['\uFEC0'] = '\u0636';
  22978. t['\uFEC1'] = '\u0637';
  22979. t['\uFEC2'] = '\u0637';
  22980. t['\uFEC3'] = '\u0637';
  22981. t['\uFEC4'] = '\u0637';
  22982. t['\uFEC5'] = '\u0638';
  22983. t['\uFEC6'] = '\u0638';
  22984. t['\uFEC7'] = '\u0638';
  22985. t['\uFEC8'] = '\u0638';
  22986. t['\uFEC9'] = '\u0639';
  22987. t['\uFECA'] = '\u0639';
  22988. t['\uFECB'] = '\u0639';
  22989. t['\uFECC'] = '\u0639';
  22990. t['\uFECD'] = '\u063A';
  22991. t['\uFECE'] = '\u063A';
  22992. t['\uFECF'] = '\u063A';
  22993. t['\uFED0'] = '\u063A';
  22994. t['\uFED1'] = '\u0641';
  22995. t['\uFED2'] = '\u0641';
  22996. t['\uFED3'] = '\u0641';
  22997. t['\uFED4'] = '\u0641';
  22998. t['\uFED5'] = '\u0642';
  22999. t['\uFED6'] = '\u0642';
  23000. t['\uFED7'] = '\u0642';
  23001. t['\uFED8'] = '\u0642';
  23002. t['\uFED9'] = '\u0643';
  23003. t['\uFEDA'] = '\u0643';
  23004. t['\uFEDB'] = '\u0643';
  23005. t['\uFEDC'] = '\u0643';
  23006. t['\uFEDD'] = '\u0644';
  23007. t['\uFEDE'] = '\u0644';
  23008. t['\uFEDF'] = '\u0644';
  23009. t['\uFEE0'] = '\u0644';
  23010. t['\uFEE1'] = '\u0645';
  23011. t['\uFEE2'] = '\u0645';
  23012. t['\uFEE3'] = '\u0645';
  23013. t['\uFEE4'] = '\u0645';
  23014. t['\uFEE5'] = '\u0646';
  23015. t['\uFEE6'] = '\u0646';
  23016. t['\uFEE7'] = '\u0646';
  23017. t['\uFEE8'] = '\u0646';
  23018. t['\uFEE9'] = '\u0647';
  23019. t['\uFEEA'] = '\u0647';
  23020. t['\uFEEB'] = '\u0647';
  23021. t['\uFEEC'] = '\u0647';
  23022. t['\uFEED'] = '\u0648';
  23023. t['\uFEEE'] = '\u0648';
  23024. t['\uFEEF'] = '\u0649';
  23025. t['\uFEF0'] = '\u0649';
  23026. t['\uFEF1'] = '\u064A';
  23027. t['\uFEF2'] = '\u064A';
  23028. t['\uFEF3'] = '\u064A';
  23029. t['\uFEF4'] = '\u064A';
  23030. t['\uFEF5'] = '\u0644\u0622';
  23031. t['\uFEF6'] = '\u0644\u0622';
  23032. t['\uFEF7'] = '\u0644\u0623';
  23033. t['\uFEF8'] = '\u0644\u0623';
  23034. t['\uFEF9'] = '\u0644\u0625';
  23035. t['\uFEFA'] = '\u0644\u0625';
  23036. t['\uFEFB'] = '\u0644\u0627';
  23037. t['\uFEFC'] = '\u0644\u0627';
  23038. });
  23039. function reverseIfRtl(chars) {
  23040. var charsLength = chars.length;
  23041. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23042. return chars;
  23043. }
  23044. var s = '';
  23045. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23046. s += chars[ii];
  23047. }
  23048. return s;
  23049. }
  23050. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23051. exports.reverseIfRtl = reverseIfRtl;
  23052. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23053. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23054. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23055. }));
  23056. (function (root, factory) {
  23057. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23058. }(this, function (exports, sharedUtil) {
  23059. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23060. var warn = sharedUtil.warn;
  23061. var deprecated = sharedUtil.deprecated;
  23062. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23063. var CustomStyle = function CustomStyleClosure() {
  23064. var prefixes = [
  23065. 'ms',
  23066. 'Moz',
  23067. 'Webkit',
  23068. 'O'
  23069. ];
  23070. var _cache = Object.create(null);
  23071. function CustomStyle() {
  23072. }
  23073. CustomStyle.getProp = function get(propName, element) {
  23074. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23075. return _cache[propName];
  23076. }
  23077. element = element || document.documentElement;
  23078. var style = element.style, prefixed, uPropName;
  23079. if (typeof style[propName] === 'string') {
  23080. return _cache[propName] = propName;
  23081. }
  23082. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23083. for (var i = 0, l = prefixes.length; i < l; i++) {
  23084. prefixed = prefixes[i] + uPropName;
  23085. if (typeof style[prefixed] === 'string') {
  23086. return _cache[propName] = prefixed;
  23087. }
  23088. }
  23089. return _cache[propName] = 'undefined';
  23090. };
  23091. CustomStyle.setProp = function set(propName, element, str) {
  23092. var prop = this.getProp(propName);
  23093. if (prop !== 'undefined') {
  23094. element.style[prop] = str;
  23095. }
  23096. };
  23097. return CustomStyle;
  23098. }();
  23099. var hasCanvasTypedArrays;
  23100. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23101. var canvas = document.createElement('canvas');
  23102. canvas.width = canvas.height = 1;
  23103. var ctx = canvas.getContext('2d');
  23104. var imageData = ctx.createImageData(1, 1);
  23105. return typeof imageData.data.buffer !== 'undefined';
  23106. };
  23107. var LinkTarget = {
  23108. NONE: 0,
  23109. SELF: 1,
  23110. BLANK: 2,
  23111. PARENT: 3,
  23112. TOP: 4
  23113. };
  23114. var LinkTargetStringMap = [
  23115. '',
  23116. '_self',
  23117. '_blank',
  23118. '_parent',
  23119. '_top'
  23120. ];
  23121. function addLinkAttributes(link, params) {
  23122. var url = params && params.url;
  23123. link.href = link.title = url ? removeNullCharacters(url) : '';
  23124. if (url) {
  23125. var target = params.target;
  23126. if (typeof target === 'undefined') {
  23127. target = getDefaultSetting('externalLinkTarget');
  23128. }
  23129. link.target = LinkTargetStringMap[target];
  23130. var rel = params.rel;
  23131. if (typeof rel === 'undefined') {
  23132. rel = getDefaultSetting('externalLinkRel');
  23133. }
  23134. link.rel = rel;
  23135. }
  23136. }
  23137. function getFilenameFromUrl(url) {
  23138. var anchor = url.indexOf('#');
  23139. var query = url.indexOf('?');
  23140. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23141. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23142. }
  23143. function getDefaultSetting(id) {
  23144. var globalSettings = sharedUtil.globalScope.PDFJS;
  23145. switch (id) {
  23146. case 'pdfBug':
  23147. return globalSettings ? globalSettings.pdfBug : false;
  23148. case 'disableAutoFetch':
  23149. return globalSettings ? globalSettings.disableAutoFetch : false;
  23150. case 'disableStream':
  23151. return globalSettings ? globalSettings.disableStream : false;
  23152. case 'disableRange':
  23153. return globalSettings ? globalSettings.disableRange : false;
  23154. case 'disableFontFace':
  23155. return globalSettings ? globalSettings.disableFontFace : false;
  23156. case 'disableCreateObjectURL':
  23157. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23158. case 'disableWebGL':
  23159. return globalSettings ? globalSettings.disableWebGL : true;
  23160. case 'cMapUrl':
  23161. return globalSettings ? globalSettings.cMapUrl : null;
  23162. case 'cMapPacked':
  23163. return globalSettings ? globalSettings.cMapPacked : false;
  23164. case 'postMessageTransfers':
  23165. return globalSettings ? globalSettings.postMessageTransfers : true;
  23166. case 'workerSrc':
  23167. return globalSettings ? globalSettings.workerSrc : null;
  23168. case 'disableWorker':
  23169. return globalSettings ? globalSettings.disableWorker : false;
  23170. case 'maxImageSize':
  23171. return globalSettings ? globalSettings.maxImageSize : -1;
  23172. case 'imageResourcesPath':
  23173. return globalSettings ? globalSettings.imageResourcesPath : '';
  23174. case 'isEvalSupported':
  23175. return globalSettings ? globalSettings.isEvalSupported : true;
  23176. case 'externalLinkTarget':
  23177. if (!globalSettings) {
  23178. return LinkTarget.NONE;
  23179. }
  23180. switch (globalSettings.externalLinkTarget) {
  23181. case LinkTarget.NONE:
  23182. case LinkTarget.SELF:
  23183. case LinkTarget.BLANK:
  23184. case LinkTarget.PARENT:
  23185. case LinkTarget.TOP:
  23186. return globalSettings.externalLinkTarget;
  23187. }
  23188. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23189. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23190. return LinkTarget.NONE;
  23191. case 'externalLinkRel':
  23192. return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
  23193. case 'enableStats':
  23194. return !!(globalSettings && globalSettings.enableStats);
  23195. default:
  23196. throw new Error('Unknown default setting: ' + id);
  23197. }
  23198. }
  23199. function isExternalLinkTargetSet() {
  23200. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23201. switch (externalLinkTarget) {
  23202. case LinkTarget.NONE:
  23203. return false;
  23204. case LinkTarget.SELF:
  23205. case LinkTarget.BLANK:
  23206. case LinkTarget.PARENT:
  23207. case LinkTarget.TOP:
  23208. return true;
  23209. }
  23210. }
  23211. function isValidUrl(url, allowRelative) {
  23212. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23213. var baseUrl = allowRelative ? 'http://example.com' : null;
  23214. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23215. }
  23216. exports.CustomStyle = CustomStyle;
  23217. exports.addLinkAttributes = addLinkAttributes;
  23218. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23219. exports.isValidUrl = isValidUrl;
  23220. exports.getFilenameFromUrl = getFilenameFromUrl;
  23221. exports.LinkTarget = LinkTarget;
  23222. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23223. exports.getDefaultSetting = getDefaultSetting;
  23224. }));
  23225. (function (root, factory) {
  23226. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23227. }(this, function (exports, sharedUtil) {
  23228. var assert = sharedUtil.assert;
  23229. var bytesToString = sharedUtil.bytesToString;
  23230. var string32 = sharedUtil.string32;
  23231. var shadow = sharedUtil.shadow;
  23232. var warn = sharedUtil.warn;
  23233. function FontLoader(docId) {
  23234. this.docId = docId;
  23235. this.styleElement = null;
  23236. this.nativeFontFaces = [];
  23237. this.loadTestFontId = 0;
  23238. this.loadingContext = {
  23239. requests: [],
  23240. nextRequestId: 0
  23241. };
  23242. }
  23243. FontLoader.prototype = {
  23244. insertRule: function fontLoaderInsertRule(rule) {
  23245. var styleElement = this.styleElement;
  23246. if (!styleElement) {
  23247. styleElement = this.styleElement = document.createElement('style');
  23248. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23249. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23250. }
  23251. var styleSheet = styleElement.sheet;
  23252. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23253. },
  23254. clear: function fontLoaderClear() {
  23255. var styleElement = this.styleElement;
  23256. if (styleElement) {
  23257. styleElement.parentNode.removeChild(styleElement);
  23258. styleElement = this.styleElement = null;
  23259. }
  23260. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23261. document.fonts.delete(nativeFontFace);
  23262. });
  23263. this.nativeFontFaces.length = 0;
  23264. }
  23265. };
  23266. var getLoadTestFont = function () {
  23267. 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==');
  23268. };
  23269. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23270. get: function () {
  23271. return shadow(this, 'loadTestFont', getLoadTestFont());
  23272. },
  23273. configurable: true
  23274. });
  23275. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23276. this.nativeFontFaces.push(nativeFontFace);
  23277. document.fonts.add(nativeFontFace);
  23278. };
  23279. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23280. var rules = [];
  23281. var fontsToLoad = [];
  23282. var fontLoadPromises = [];
  23283. var getNativeFontPromise = function (nativeFontFace) {
  23284. return nativeFontFace.loaded.catch(function (e) {
  23285. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23286. });
  23287. };
  23288. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23289. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23290. var font = fonts[i];
  23291. if (font.attached || font.loading === false) {
  23292. continue;
  23293. }
  23294. font.attached = true;
  23295. if (isFontLoadingAPISupported) {
  23296. var nativeFontFace = font.createNativeFontFace();
  23297. if (nativeFontFace) {
  23298. this.addNativeFontFace(nativeFontFace);
  23299. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23300. }
  23301. } else {
  23302. var rule = font.createFontFaceRule();
  23303. if (rule) {
  23304. this.insertRule(rule);
  23305. rules.push(rule);
  23306. fontsToLoad.push(font);
  23307. }
  23308. }
  23309. }
  23310. var request = this.queueLoadingCallback(callback);
  23311. if (isFontLoadingAPISupported) {
  23312. Promise.all(fontLoadPromises).then(function () {
  23313. request.complete();
  23314. });
  23315. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23316. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23317. } else {
  23318. request.complete();
  23319. }
  23320. };
  23321. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23322. function LoadLoader_completeRequest() {
  23323. assert(!request.end, 'completeRequest() cannot be called twice');
  23324. request.end = Date.now();
  23325. while (context.requests.length > 0 && context.requests[0].end) {
  23326. var otherRequest = context.requests.shift();
  23327. setTimeout(otherRequest.callback, 0);
  23328. }
  23329. }
  23330. var context = this.loadingContext;
  23331. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23332. var request = {
  23333. id: requestId,
  23334. complete: LoadLoader_completeRequest,
  23335. callback: callback,
  23336. started: Date.now()
  23337. };
  23338. context.requests.push(request);
  23339. return request;
  23340. };
  23341. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23342. function int32(data, offset) {
  23343. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23344. }
  23345. function spliceString(s, offset, remove, insert) {
  23346. var chunk1 = s.substr(0, offset);
  23347. var chunk2 = s.substr(offset + remove);
  23348. return chunk1 + insert + chunk2;
  23349. }
  23350. var i, ii;
  23351. var canvas = document.createElement('canvas');
  23352. canvas.width = 1;
  23353. canvas.height = 1;
  23354. var ctx = canvas.getContext('2d');
  23355. var called = 0;
  23356. function isFontReady(name, callback) {
  23357. called++;
  23358. if (called > 30) {
  23359. warn('Load test font never loaded.');
  23360. callback();
  23361. return;
  23362. }
  23363. ctx.font = '30px ' + name;
  23364. ctx.fillText('.', 0, 20);
  23365. var imageData = ctx.getImageData(0, 0, 1, 1);
  23366. if (imageData.data[3] > 0) {
  23367. callback();
  23368. return;
  23369. }
  23370. setTimeout(isFontReady.bind(null, name, callback));
  23371. }
  23372. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23373. var data = this.loadTestFont;
  23374. var COMMENT_OFFSET = 976;
  23375. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23376. var CFF_CHECKSUM_OFFSET = 16;
  23377. var XXXX_VALUE = 0x58585858;
  23378. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23379. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23380. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23381. }
  23382. if (i < loadTestFontId.length) {
  23383. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23384. }
  23385. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23386. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23387. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23388. this.insertRule(rule);
  23389. var names = [];
  23390. for (i = 0, ii = fonts.length; i < ii; i++) {
  23391. names.push(fonts[i].loadedName);
  23392. }
  23393. names.push(loadTestFontId);
  23394. var div = document.createElement('div');
  23395. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23396. for (i = 0, ii = names.length; i < ii; ++i) {
  23397. var span = document.createElement('span');
  23398. span.textContent = 'Hi';
  23399. span.style.fontFamily = names[i];
  23400. div.appendChild(span);
  23401. }
  23402. document.body.appendChild(div);
  23403. isFontReady(loadTestFontId, function () {
  23404. document.body.removeChild(div);
  23405. request.complete();
  23406. });
  23407. };
  23408. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23409. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23410. if (typeof navigator === 'undefined') {
  23411. return true;
  23412. }
  23413. var supported = false;
  23414. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23415. if (m && m[1] >= 14) {
  23416. supported = true;
  23417. }
  23418. return supported;
  23419. };
  23420. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23421. get: function () {
  23422. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23423. },
  23424. enumerable: true,
  23425. configurable: true
  23426. });
  23427. var IsEvalSupportedCached = {
  23428. get value() {
  23429. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23430. }
  23431. };
  23432. var FontFaceObject = function FontFaceObjectClosure() {
  23433. function FontFaceObject(translatedData, options) {
  23434. this.compiledGlyphs = Object.create(null);
  23435. for (var i in translatedData) {
  23436. this[i] = translatedData[i];
  23437. }
  23438. this.options = options;
  23439. }
  23440. FontFaceObject.prototype = {
  23441. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23442. if (!this.data) {
  23443. return null;
  23444. }
  23445. if (this.options.disableFontFace) {
  23446. this.disableFontFace = true;
  23447. return null;
  23448. }
  23449. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23450. if (this.options.fontRegistry) {
  23451. this.options.fontRegistry.registerFont(this);
  23452. }
  23453. return nativeFontFace;
  23454. },
  23455. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23456. if (!this.data) {
  23457. return null;
  23458. }
  23459. if (this.options.disableFontFace) {
  23460. this.disableFontFace = true;
  23461. return null;
  23462. }
  23463. var data = bytesToString(new Uint8Array(this.data));
  23464. var fontName = this.loadedName;
  23465. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23466. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23467. if (this.options.fontRegistry) {
  23468. this.options.fontRegistry.registerFont(this, url);
  23469. }
  23470. return rule;
  23471. },
  23472. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23473. if (!(character in this.compiledGlyphs)) {
  23474. var cmds = objs.get(this.loadedName + '_path_' + character);
  23475. var current, i, len;
  23476. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23477. var args, js = '';
  23478. for (i = 0, len = cmds.length; i < len; i++) {
  23479. current = cmds[i];
  23480. if (current.args !== undefined) {
  23481. args = current.args.join(',');
  23482. } else {
  23483. args = '';
  23484. }
  23485. js += 'c.' + current.cmd + '(' + args + ');\n';
  23486. }
  23487. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23488. } else {
  23489. this.compiledGlyphs[character] = function (c, size) {
  23490. for (i = 0, len = cmds.length; i < len; i++) {
  23491. current = cmds[i];
  23492. if (current.cmd === 'scale') {
  23493. current.args = [
  23494. size,
  23495. -size
  23496. ];
  23497. }
  23498. c[current.cmd].apply(c, current.args);
  23499. }
  23500. };
  23501. }
  23502. }
  23503. return this.compiledGlyphs[character];
  23504. }
  23505. };
  23506. return FontFaceObject;
  23507. }();
  23508. exports.FontFaceObject = FontFaceObject;
  23509. exports.FontLoader = FontLoader;
  23510. }));
  23511. (function (root, factory) {
  23512. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23513. }(this, function (exports, sharedUtil) {
  23514. var error = sharedUtil.error;
  23515. function fixMetadata(meta) {
  23516. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23517. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23518. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23519. });
  23520. var chars = '';
  23521. for (var i = 0; i < bytes.length; i += 2) {
  23522. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23523. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 && false ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23524. }
  23525. return '>' + chars;
  23526. });
  23527. }
  23528. function Metadata(meta) {
  23529. if (typeof meta === 'string') {
  23530. meta = fixMetadata(meta);
  23531. var parser = new DOMParser();
  23532. meta = parser.parseFromString(meta, 'application/xml');
  23533. } else if (!(meta instanceof Document)) {
  23534. error('Metadata: Invalid metadata object');
  23535. }
  23536. this.metaDocument = meta;
  23537. this.metadata = Object.create(null);
  23538. this.parse();
  23539. }
  23540. Metadata.prototype = {
  23541. parse: function Metadata_parse() {
  23542. var doc = this.metaDocument;
  23543. var rdf = doc.documentElement;
  23544. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23545. rdf = rdf.firstChild;
  23546. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23547. rdf = rdf.nextSibling;
  23548. }
  23549. }
  23550. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23551. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23552. return;
  23553. }
  23554. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23555. for (i = 0, length = children.length; i < length; i++) {
  23556. desc = children[i];
  23557. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23558. continue;
  23559. }
  23560. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23561. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23562. entry = desc.childNodes[ii];
  23563. name = entry.nodeName.toLowerCase();
  23564. this.metadata[name] = entry.textContent.trim();
  23565. }
  23566. }
  23567. }
  23568. },
  23569. get: function Metadata_get(name) {
  23570. return this.metadata[name] || null;
  23571. },
  23572. has: function Metadata_has(name) {
  23573. return typeof this.metadata[name] !== 'undefined';
  23574. }
  23575. };
  23576. exports.Metadata = Metadata;
  23577. }));
  23578. (function (root, factory) {
  23579. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23580. }(this, function (exports, sharedUtil) {
  23581. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23582. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23583. var ImageKind = sharedUtil.ImageKind;
  23584. var OPS = sharedUtil.OPS;
  23585. var Util = sharedUtil.Util;
  23586. var isNum = sharedUtil.isNum;
  23587. var isArray = sharedUtil.isArray;
  23588. var warn = sharedUtil.warn;
  23589. var createObjectURL = sharedUtil.createObjectURL;
  23590. var SVG_DEFAULTS = {
  23591. fontStyle: 'normal',
  23592. fontWeight: 'normal',
  23593. fillColor: '#000000'
  23594. };
  23595. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23596. var PNG_HEADER = new Uint8Array([
  23597. 0x89,
  23598. 0x50,
  23599. 0x4e,
  23600. 0x47,
  23601. 0x0d,
  23602. 0x0a,
  23603. 0x1a,
  23604. 0x0a
  23605. ]);
  23606. var CHUNK_WRAPPER_SIZE = 12;
  23607. var crcTable = new Int32Array(256);
  23608. for (var i = 0; i < 256; i++) {
  23609. var c = i;
  23610. for (var h = 0; h < 8; h++) {
  23611. if (c & 1) {
  23612. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23613. } else {
  23614. c = c >> 1 & 0x7fffffff;
  23615. }
  23616. }
  23617. crcTable[i] = c;
  23618. }
  23619. function crc32(data, start, end) {
  23620. var crc = -1;
  23621. for (var i = start; i < end; i++) {
  23622. var a = (crc ^ data[i]) & 0xff;
  23623. var b = crcTable[a];
  23624. crc = crc >>> 8 ^ b;
  23625. }
  23626. return crc ^ -1;
  23627. }
  23628. function writePngChunk(type, body, data, offset) {
  23629. var p = offset;
  23630. var len = body.length;
  23631. data[p] = len >> 24 & 0xff;
  23632. data[p + 1] = len >> 16 & 0xff;
  23633. data[p + 2] = len >> 8 & 0xff;
  23634. data[p + 3] = len & 0xff;
  23635. p += 4;
  23636. data[p] = type.charCodeAt(0) & 0xff;
  23637. data[p + 1] = type.charCodeAt(1) & 0xff;
  23638. data[p + 2] = type.charCodeAt(2) & 0xff;
  23639. data[p + 3] = type.charCodeAt(3) & 0xff;
  23640. p += 4;
  23641. data.set(body, p);
  23642. p += body.length;
  23643. var crc = crc32(data, offset + 4, p);
  23644. data[p] = crc >> 24 & 0xff;
  23645. data[p + 1] = crc >> 16 & 0xff;
  23646. data[p + 2] = crc >> 8 & 0xff;
  23647. data[p + 3] = crc & 0xff;
  23648. }
  23649. function adler32(data, start, end) {
  23650. var a = 1;
  23651. var b = 0;
  23652. for (var i = start; i < end; ++i) {
  23653. a = (a + (data[i] & 0xff)) % 65521;
  23654. b = (b + a) % 65521;
  23655. }
  23656. return b << 16 | a;
  23657. }
  23658. function encode(imgData, kind, forceDataSchema) {
  23659. var width = imgData.width;
  23660. var height = imgData.height;
  23661. var bitDepth, colorType, lineSize;
  23662. var bytes = imgData.data;
  23663. switch (kind) {
  23664. case ImageKind.GRAYSCALE_1BPP:
  23665. colorType = 0;
  23666. bitDepth = 1;
  23667. lineSize = width + 7 >> 3;
  23668. break;
  23669. case ImageKind.RGB_24BPP:
  23670. colorType = 2;
  23671. bitDepth = 8;
  23672. lineSize = width * 3;
  23673. break;
  23674. case ImageKind.RGBA_32BPP:
  23675. colorType = 6;
  23676. bitDepth = 8;
  23677. lineSize = width * 4;
  23678. break;
  23679. default:
  23680. throw new Error('invalid format');
  23681. }
  23682. var literals = new Uint8Array((1 + lineSize) * height);
  23683. var offsetLiterals = 0, offsetBytes = 0;
  23684. var y, i;
  23685. for (y = 0; y < height; ++y) {
  23686. literals[offsetLiterals++] = 0;
  23687. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23688. offsetBytes += lineSize;
  23689. offsetLiterals += lineSize;
  23690. }
  23691. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23692. offsetLiterals = 0;
  23693. for (y = 0; y < height; y++) {
  23694. offsetLiterals++;
  23695. for (i = 0; i < lineSize; i++) {
  23696. literals[offsetLiterals++] ^= 0xFF;
  23697. }
  23698. }
  23699. }
  23700. var ihdr = new Uint8Array([
  23701. width >> 24 & 0xff,
  23702. width >> 16 & 0xff,
  23703. width >> 8 & 0xff,
  23704. width & 0xff,
  23705. height >> 24 & 0xff,
  23706. height >> 16 & 0xff,
  23707. height >> 8 & 0xff,
  23708. height & 0xff,
  23709. bitDepth,
  23710. colorType,
  23711. 0x00,
  23712. 0x00,
  23713. 0x00
  23714. ]);
  23715. var len = literals.length;
  23716. var maxBlockLength = 0xFFFF;
  23717. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23718. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23719. var pi = 0;
  23720. idat[pi++] = 0x78;
  23721. idat[pi++] = 0x9c;
  23722. var pos = 0;
  23723. while (len > maxBlockLength) {
  23724. idat[pi++] = 0x00;
  23725. idat[pi++] = 0xff;
  23726. idat[pi++] = 0xff;
  23727. idat[pi++] = 0x00;
  23728. idat[pi++] = 0x00;
  23729. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23730. pi += maxBlockLength;
  23731. pos += maxBlockLength;
  23732. len -= maxBlockLength;
  23733. }
  23734. idat[pi++] = 0x01;
  23735. idat[pi++] = len & 0xff;
  23736. idat[pi++] = len >> 8 & 0xff;
  23737. idat[pi++] = ~len & 0xffff & 0xff;
  23738. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23739. idat.set(literals.subarray(pos), pi);
  23740. pi += literals.length - pos;
  23741. var adler = adler32(literals, 0, literals.length);
  23742. idat[pi++] = adler >> 24 & 0xff;
  23743. idat[pi++] = adler >> 16 & 0xff;
  23744. idat[pi++] = adler >> 8 & 0xff;
  23745. idat[pi++] = adler & 0xff;
  23746. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23747. var data = new Uint8Array(pngLength);
  23748. var offset = 0;
  23749. data.set(PNG_HEADER, offset);
  23750. offset += PNG_HEADER.length;
  23751. writePngChunk('IHDR', ihdr, data, offset);
  23752. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23753. writePngChunk('IDATA', idat, data, offset);
  23754. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23755. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23756. return createObjectURL(data, 'image/png', forceDataSchema);
  23757. }
  23758. return function convertImgDataToPng(imgData, forceDataSchema) {
  23759. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23760. return encode(imgData, kind, forceDataSchema);
  23761. };
  23762. }();
  23763. var SVGExtraState = function SVGExtraStateClosure() {
  23764. function SVGExtraState() {
  23765. this.fontSizeScale = 1;
  23766. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23767. this.fontSize = 0;
  23768. this.textMatrix = IDENTITY_MATRIX;
  23769. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23770. this.leading = 0;
  23771. this.x = 0;
  23772. this.y = 0;
  23773. this.lineX = 0;
  23774. this.lineY = 0;
  23775. this.charSpacing = 0;
  23776. this.wordSpacing = 0;
  23777. this.textHScale = 1;
  23778. this.textRise = 0;
  23779. this.fillColor = SVG_DEFAULTS.fillColor;
  23780. this.strokeColor = '#000000';
  23781. this.fillAlpha = 1;
  23782. this.strokeAlpha = 1;
  23783. this.lineWidth = 1;
  23784. this.lineJoin = '';
  23785. this.lineCap = '';
  23786. this.miterLimit = 0;
  23787. this.dashArray = [];
  23788. this.dashPhase = 0;
  23789. this.dependencies = [];
  23790. this.activeClipUrl = null;
  23791. this.clipGroup = null;
  23792. this.maskId = '';
  23793. }
  23794. SVGExtraState.prototype = {
  23795. clone: function SVGExtraState_clone() {
  23796. return Object.create(this);
  23797. },
  23798. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23799. this.x = x;
  23800. this.y = y;
  23801. }
  23802. };
  23803. return SVGExtraState;
  23804. }();
  23805. var SVGGraphics = function SVGGraphicsClosure() {
  23806. function opListToTree(opList) {
  23807. var opTree = [];
  23808. var tmp = [];
  23809. var opListLen = opList.length;
  23810. for (var x = 0; x < opListLen; x++) {
  23811. if (opList[x].fn === 'save') {
  23812. opTree.push({
  23813. 'fnId': 92,
  23814. 'fn': 'group',
  23815. 'items': []
  23816. });
  23817. tmp.push(opTree);
  23818. opTree = opTree[opTree.length - 1].items;
  23819. continue;
  23820. }
  23821. if (opList[x].fn === 'restore') {
  23822. opTree = tmp.pop();
  23823. } else {
  23824. opTree.push(opList[x]);
  23825. }
  23826. }
  23827. return opTree;
  23828. }
  23829. function pf(value) {
  23830. if (value === (value | 0)) {
  23831. return value.toString();
  23832. }
  23833. var s = value.toFixed(10);
  23834. var i = s.length - 1;
  23835. if (s[i] !== '0') {
  23836. return s;
  23837. }
  23838. do {
  23839. i--;
  23840. } while (s[i] === '0');
  23841. return s.substr(0, s[i] === '.' ? i : i + 1);
  23842. }
  23843. function pm(m) {
  23844. if (m[4] === 0 && m[5] === 0) {
  23845. if (m[1] === 0 && m[2] === 0) {
  23846. if (m[0] === 1 && m[3] === 1) {
  23847. return '';
  23848. }
  23849. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  23850. }
  23851. if (m[0] === m[3] && m[1] === -m[2]) {
  23852. var a = Math.acos(m[0]) * 180 / Math.PI;
  23853. return 'rotate(' + pf(a) + ')';
  23854. }
  23855. } else {
  23856. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  23857. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23858. }
  23859. }
  23860. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23861. }
  23862. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  23863. this.current = new SVGExtraState();
  23864. this.transformMatrix = IDENTITY_MATRIX;
  23865. this.transformStack = [];
  23866. this.extraStack = [];
  23867. this.commonObjs = commonObjs;
  23868. this.objs = objs;
  23869. this.pendingEOFill = false;
  23870. this.embedFonts = false;
  23871. this.embeddedFonts = Object.create(null);
  23872. this.cssStyle = null;
  23873. this.forceDataSchema = !!forceDataSchema;
  23874. }
  23875. var NS = 'http://www.w3.org/2000/svg';
  23876. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  23877. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  23878. var LINE_CAP_STYLES = [
  23879. 'butt',
  23880. 'round',
  23881. 'square'
  23882. ];
  23883. var LINE_JOIN_STYLES = [
  23884. 'miter',
  23885. 'round',
  23886. 'bevel'
  23887. ];
  23888. var clipCount = 0;
  23889. var maskCount = 0;
  23890. SVGGraphics.prototype = {
  23891. save: function SVGGraphics_save() {
  23892. this.transformStack.push(this.transformMatrix);
  23893. var old = this.current;
  23894. this.extraStack.push(old);
  23895. this.current = old.clone();
  23896. },
  23897. restore: function SVGGraphics_restore() {
  23898. this.transformMatrix = this.transformStack.pop();
  23899. this.current = this.extraStack.pop();
  23900. this.tgrp = null;
  23901. },
  23902. group: function SVGGraphics_group(items) {
  23903. this.save();
  23904. this.executeOpTree(items);
  23905. this.restore();
  23906. },
  23907. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  23908. var fnArray = operatorList.fnArray;
  23909. var fnArrayLen = fnArray.length;
  23910. var argsArray = operatorList.argsArray;
  23911. var self = this;
  23912. for (var i = 0; i < fnArrayLen; i++) {
  23913. if (OPS.dependency === fnArray[i]) {
  23914. var deps = argsArray[i];
  23915. for (var n = 0, nn = deps.length; n < nn; n++) {
  23916. var obj = deps[n];
  23917. var common = obj.substring(0, 2) === 'g_';
  23918. var promise;
  23919. if (common) {
  23920. promise = new Promise(function (resolve) {
  23921. self.commonObjs.get(obj, resolve);
  23922. });
  23923. } else {
  23924. promise = new Promise(function (resolve) {
  23925. self.objs.get(obj, resolve);
  23926. });
  23927. }
  23928. this.current.dependencies.push(promise);
  23929. }
  23930. }
  23931. }
  23932. return Promise.all(this.current.dependencies);
  23933. },
  23934. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  23935. var transformMatrix = [
  23936. a,
  23937. b,
  23938. c,
  23939. d,
  23940. e,
  23941. f
  23942. ];
  23943. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  23944. this.tgrp = null;
  23945. },
  23946. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  23947. this.viewport = viewport;
  23948. var svgElement = this._initialize(viewport);
  23949. return this.loadDependencies(operatorList).then(function () {
  23950. this.transformMatrix = IDENTITY_MATRIX;
  23951. var opTree = this.convertOpList(operatorList);
  23952. this.executeOpTree(opTree);
  23953. return svgElement;
  23954. }.bind(this));
  23955. },
  23956. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  23957. var argsArray = operatorList.argsArray;
  23958. var fnArray = operatorList.fnArray;
  23959. var fnArrayLen = fnArray.length;
  23960. var REVOPS = [];
  23961. var opList = [];
  23962. for (var op in OPS) {
  23963. REVOPS[OPS[op]] = op;
  23964. }
  23965. for (var x = 0; x < fnArrayLen; x++) {
  23966. var fnId = fnArray[x];
  23967. opList.push({
  23968. 'fnId': fnId,
  23969. 'fn': REVOPS[fnId],
  23970. 'args': argsArray[x]
  23971. });
  23972. }
  23973. return opListToTree(opList);
  23974. },
  23975. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  23976. var opTreeLen = opTree.length;
  23977. for (var x = 0; x < opTreeLen; x++) {
  23978. var fn = opTree[x].fn;
  23979. var fnId = opTree[x].fnId;
  23980. var args = opTree[x].args;
  23981. switch (fnId | 0) {
  23982. case OPS.beginText:
  23983. this.beginText();
  23984. break;
  23985. case OPS.setLeading:
  23986. this.setLeading(args);
  23987. break;
  23988. case OPS.setLeadingMoveText:
  23989. this.setLeadingMoveText(args[0], args[1]);
  23990. break;
  23991. case OPS.setFont:
  23992. this.setFont(args);
  23993. break;
  23994. case OPS.showText:
  23995. this.showText(args[0]);
  23996. break;
  23997. case OPS.showSpacedText:
  23998. this.showText(args[0]);
  23999. break;
  24000. case OPS.endText:
  24001. this.endText();
  24002. break;
  24003. case OPS.moveText:
  24004. this.moveText(args[0], args[1]);
  24005. break;
  24006. case OPS.setCharSpacing:
  24007. this.setCharSpacing(args[0]);
  24008. break;
  24009. case OPS.setWordSpacing:
  24010. this.setWordSpacing(args[0]);
  24011. break;
  24012. case OPS.setHScale:
  24013. this.setHScale(args[0]);
  24014. break;
  24015. case OPS.setTextMatrix:
  24016. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24017. break;
  24018. case OPS.setLineWidth:
  24019. this.setLineWidth(args[0]);
  24020. break;
  24021. case OPS.setLineJoin:
  24022. this.setLineJoin(args[0]);
  24023. break;
  24024. case OPS.setLineCap:
  24025. this.setLineCap(args[0]);
  24026. break;
  24027. case OPS.setMiterLimit:
  24028. this.setMiterLimit(args[0]);
  24029. break;
  24030. case OPS.setFillRGBColor:
  24031. this.setFillRGBColor(args[0], args[1], args[2]);
  24032. break;
  24033. case OPS.setStrokeRGBColor:
  24034. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24035. break;
  24036. case OPS.setDash:
  24037. this.setDash(args[0], args[1]);
  24038. break;
  24039. case OPS.setGState:
  24040. this.setGState(args[0]);
  24041. break;
  24042. case OPS.fill:
  24043. this.fill();
  24044. break;
  24045. case OPS.eoFill:
  24046. this.eoFill();
  24047. break;
  24048. case OPS.stroke:
  24049. this.stroke();
  24050. break;
  24051. case OPS.fillStroke:
  24052. this.fillStroke();
  24053. break;
  24054. case OPS.eoFillStroke:
  24055. this.eoFillStroke();
  24056. break;
  24057. case OPS.clip:
  24058. this.clip('nonzero');
  24059. break;
  24060. case OPS.eoClip:
  24061. this.clip('evenodd');
  24062. break;
  24063. case OPS.paintSolidColorImageMask:
  24064. this.paintSolidColorImageMask();
  24065. break;
  24066. case OPS.paintJpegXObject:
  24067. this.paintJpegXObject(args[0], args[1], args[2]);
  24068. break;
  24069. case OPS.paintImageXObject:
  24070. this.paintImageXObject(args[0]);
  24071. break;
  24072. case OPS.paintInlineImageXObject:
  24073. this.paintInlineImageXObject(args[0]);
  24074. break;
  24075. case OPS.paintImageMaskXObject:
  24076. this.paintImageMaskXObject(args[0]);
  24077. break;
  24078. case OPS.paintFormXObjectBegin:
  24079. this.paintFormXObjectBegin(args[0], args[1]);
  24080. break;
  24081. case OPS.paintFormXObjectEnd:
  24082. this.paintFormXObjectEnd();
  24083. break;
  24084. case OPS.closePath:
  24085. this.closePath();
  24086. break;
  24087. case OPS.closeStroke:
  24088. this.closeStroke();
  24089. break;
  24090. case OPS.closeFillStroke:
  24091. this.closeFillStroke();
  24092. break;
  24093. case OPS.nextLine:
  24094. this.nextLine();
  24095. break;
  24096. case OPS.transform:
  24097. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24098. break;
  24099. case OPS.constructPath:
  24100. this.constructPath(args[0], args[1]);
  24101. break;
  24102. case OPS.endPath:
  24103. this.endPath();
  24104. break;
  24105. case 92:
  24106. this.group(opTree[x].items);
  24107. break;
  24108. default:
  24109. warn('Unimplemented operator ' + fn);
  24110. break;
  24111. }
  24112. }
  24113. },
  24114. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24115. this.current.wordSpacing = wordSpacing;
  24116. },
  24117. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24118. this.current.charSpacing = charSpacing;
  24119. },
  24120. nextLine: function SVGGraphics_nextLine() {
  24121. this.moveText(0, this.current.leading);
  24122. },
  24123. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24124. var current = this.current;
  24125. this.current.textMatrix = this.current.lineMatrix = [
  24126. a,
  24127. b,
  24128. c,
  24129. d,
  24130. e,
  24131. f
  24132. ];
  24133. this.current.x = this.current.lineX = 0;
  24134. this.current.y = this.current.lineY = 0;
  24135. current.xcoords = [];
  24136. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24137. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24138. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24139. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24140. current.txtElement = document.createElementNS(NS, 'svg:text');
  24141. current.txtElement.appendChild(current.tspan);
  24142. },
  24143. beginText: function SVGGraphics_beginText() {
  24144. this.current.x = this.current.lineX = 0;
  24145. this.current.y = this.current.lineY = 0;
  24146. this.current.textMatrix = IDENTITY_MATRIX;
  24147. this.current.lineMatrix = IDENTITY_MATRIX;
  24148. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24149. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24150. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24151. this.current.xcoords = [];
  24152. },
  24153. moveText: function SVGGraphics_moveText(x, y) {
  24154. var current = this.current;
  24155. this.current.x = this.current.lineX += x;
  24156. this.current.y = this.current.lineY += y;
  24157. current.xcoords = [];
  24158. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24159. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24160. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24161. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24162. },
  24163. showText: function SVGGraphics_showText(glyphs) {
  24164. var current = this.current;
  24165. var font = current.font;
  24166. var fontSize = current.fontSize;
  24167. if (fontSize === 0) {
  24168. return;
  24169. }
  24170. var charSpacing = current.charSpacing;
  24171. var wordSpacing = current.wordSpacing;
  24172. var fontDirection = current.fontDirection;
  24173. var textHScale = current.textHScale * fontDirection;
  24174. var glyphsLength = glyphs.length;
  24175. var vertical = font.vertical;
  24176. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24177. var x = 0, i;
  24178. for (i = 0; i < glyphsLength; ++i) {
  24179. var glyph = glyphs[i];
  24180. if (glyph === null) {
  24181. x += fontDirection * wordSpacing;
  24182. continue;
  24183. } else if (isNum(glyph)) {
  24184. x += -glyph * fontSize * 0.001;
  24185. continue;
  24186. }
  24187. current.xcoords.push(current.x + x * textHScale);
  24188. var width = glyph.width;
  24189. var character = glyph.fontChar;
  24190. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24191. x += charWidth;
  24192. current.tspan.textContent += character;
  24193. }
  24194. if (vertical) {
  24195. current.y -= x * textHScale;
  24196. } else {
  24197. current.x += x * textHScale;
  24198. }
  24199. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24200. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24201. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24202. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24203. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24204. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24205. }
  24206. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24207. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24208. }
  24209. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24210. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24211. }
  24212. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24213. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24214. current.txtElement.appendChild(current.tspan);
  24215. current.txtgrp.appendChild(current.txtElement);
  24216. this._ensureTransformGroup().appendChild(current.txtElement);
  24217. },
  24218. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24219. this.setLeading(-y);
  24220. this.moveText(x, y);
  24221. },
  24222. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24223. if (!this.cssStyle) {
  24224. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24225. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24226. this.defs.appendChild(this.cssStyle);
  24227. }
  24228. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24229. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24230. },
  24231. setFont: function SVGGraphics_setFont(details) {
  24232. var current = this.current;
  24233. var fontObj = this.commonObjs.get(details[0]);
  24234. var size = details[1];
  24235. this.current.font = fontObj;
  24236. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24237. this.addFontStyle(fontObj);
  24238. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24239. }
  24240. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24241. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24242. var italic = fontObj.italic ? 'italic' : 'normal';
  24243. if (size < 0) {
  24244. size = -size;
  24245. current.fontDirection = -1;
  24246. } else {
  24247. current.fontDirection = 1;
  24248. }
  24249. current.fontSize = size;
  24250. current.fontFamily = fontObj.loadedName;
  24251. current.fontWeight = bold;
  24252. current.fontStyle = italic;
  24253. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24254. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24255. current.xcoords = [];
  24256. },
  24257. endText: function SVGGraphics_endText() {
  24258. },
  24259. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24260. this.current.lineWidth = width;
  24261. },
  24262. setLineCap: function SVGGraphics_setLineCap(style) {
  24263. this.current.lineCap = LINE_CAP_STYLES[style];
  24264. },
  24265. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24266. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24267. },
  24268. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24269. this.current.miterLimit = limit;
  24270. },
  24271. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24272. var color = Util.makeCssRgb(r, g, b);
  24273. this.current.strokeColor = color;
  24274. },
  24275. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24276. var color = Util.makeCssRgb(r, g, b);
  24277. this.current.fillColor = color;
  24278. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24279. this.current.xcoords = [];
  24280. },
  24281. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24282. this.current.dashArray = dashArray;
  24283. this.current.dashPhase = dashPhase;
  24284. },
  24285. constructPath: function SVGGraphics_constructPath(ops, args) {
  24286. var current = this.current;
  24287. var x = current.x, y = current.y;
  24288. current.path = document.createElementNS(NS, 'svg:path');
  24289. var d = [];
  24290. var opLength = ops.length;
  24291. for (var i = 0, j = 0; i < opLength; i++) {
  24292. switch (ops[i] | 0) {
  24293. case OPS.rectangle:
  24294. x = args[j++];
  24295. y = args[j++];
  24296. var width = args[j++];
  24297. var height = args[j++];
  24298. var xw = x + width;
  24299. var yh = y + height;
  24300. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24301. break;
  24302. case OPS.moveTo:
  24303. x = args[j++];
  24304. y = args[j++];
  24305. d.push('M', pf(x), pf(y));
  24306. break;
  24307. case OPS.lineTo:
  24308. x = args[j++];
  24309. y = args[j++];
  24310. d.push('L', pf(x), pf(y));
  24311. break;
  24312. case OPS.curveTo:
  24313. x = args[j + 4];
  24314. y = args[j + 5];
  24315. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24316. j += 6;
  24317. break;
  24318. case OPS.curveTo2:
  24319. x = args[j + 2];
  24320. y = args[j + 3];
  24321. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24322. j += 4;
  24323. break;
  24324. case OPS.curveTo3:
  24325. x = args[j + 2];
  24326. y = args[j + 3];
  24327. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24328. j += 4;
  24329. break;
  24330. case OPS.closePath:
  24331. d.push('Z');
  24332. break;
  24333. }
  24334. }
  24335. current.path.setAttributeNS(null, 'd', d.join(' '));
  24336. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24337. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24338. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24339. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24340. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24341. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24342. current.path.setAttributeNS(null, 'fill', 'none');
  24343. this._ensureTransformGroup().appendChild(current.path);
  24344. current.element = current.path;
  24345. current.setCurrentPoint(x, y);
  24346. },
  24347. endPath: function SVGGraphics_endPath() {
  24348. },
  24349. clip: function SVGGraphics_clip(type) {
  24350. var current = this.current;
  24351. var clipId = 'clippath' + clipCount;
  24352. clipCount++;
  24353. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24354. clipPath.setAttributeNS(null, 'id', clipId);
  24355. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24356. var clipElement = current.element.cloneNode();
  24357. if (type === 'evenodd') {
  24358. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24359. } else {
  24360. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24361. }
  24362. clipPath.appendChild(clipElement);
  24363. this.defs.appendChild(clipPath);
  24364. if (current.activeClipUrl) {
  24365. current.clipGroup = null;
  24366. this.extraStack.forEach(function (prev) {
  24367. prev.clipGroup = null;
  24368. });
  24369. }
  24370. current.activeClipUrl = 'url(#' + clipId + ')';
  24371. this.tgrp = null;
  24372. },
  24373. closePath: function SVGGraphics_closePath() {
  24374. var current = this.current;
  24375. var d = current.path.getAttributeNS(null, 'd');
  24376. d += 'Z';
  24377. current.path.setAttributeNS(null, 'd', d);
  24378. },
  24379. setLeading: function SVGGraphics_setLeading(leading) {
  24380. this.current.leading = -leading;
  24381. },
  24382. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24383. this.current.textRise = textRise;
  24384. },
  24385. setHScale: function SVGGraphics_setHScale(scale) {
  24386. this.current.textHScale = scale / 100;
  24387. },
  24388. setGState: function SVGGraphics_setGState(states) {
  24389. for (var i = 0, ii = states.length; i < ii; i++) {
  24390. var state = states[i];
  24391. var key = state[0];
  24392. var value = state[1];
  24393. switch (key) {
  24394. case 'LW':
  24395. this.setLineWidth(value);
  24396. break;
  24397. case 'LC':
  24398. this.setLineCap(value);
  24399. break;
  24400. case 'LJ':
  24401. this.setLineJoin(value);
  24402. break;
  24403. case 'ML':
  24404. this.setMiterLimit(value);
  24405. break;
  24406. case 'D':
  24407. this.setDash(value[0], value[1]);
  24408. break;
  24409. case 'Font':
  24410. this.setFont(value);
  24411. break;
  24412. default:
  24413. warn('Unimplemented graphic state ' + key);
  24414. break;
  24415. }
  24416. }
  24417. },
  24418. fill: function SVGGraphics_fill() {
  24419. var current = this.current;
  24420. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24421. },
  24422. stroke: function SVGGraphics_stroke() {
  24423. var current = this.current;
  24424. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24425. current.element.setAttributeNS(null, 'fill', 'none');
  24426. },
  24427. eoFill: function SVGGraphics_eoFill() {
  24428. var current = this.current;
  24429. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24430. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24431. },
  24432. fillStroke: function SVGGraphics_fillStroke() {
  24433. this.stroke();
  24434. this.fill();
  24435. },
  24436. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24437. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24438. this.fillStroke();
  24439. },
  24440. closeStroke: function SVGGraphics_closeStroke() {
  24441. this.closePath();
  24442. this.stroke();
  24443. },
  24444. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24445. this.closePath();
  24446. this.fillStroke();
  24447. },
  24448. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24449. var current = this.current;
  24450. var rect = document.createElementNS(NS, 'svg:rect');
  24451. rect.setAttributeNS(null, 'x', '0');
  24452. rect.setAttributeNS(null, 'y', '0');
  24453. rect.setAttributeNS(null, 'width', '1px');
  24454. rect.setAttributeNS(null, 'height', '1px');
  24455. rect.setAttributeNS(null, 'fill', current.fillColor);
  24456. this._ensureTransformGroup().appendChild(rect);
  24457. },
  24458. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24459. var imgObj = this.objs.get(objId);
  24460. var imgEl = document.createElementNS(NS, 'svg:image');
  24461. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24462. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24463. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24464. imgEl.setAttributeNS(null, 'x', '0');
  24465. imgEl.setAttributeNS(null, 'y', pf(-h));
  24466. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24467. this._ensureTransformGroup().appendChild(imgEl);
  24468. },
  24469. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24470. var imgData = this.objs.get(objId);
  24471. if (!imgData) {
  24472. warn('Dependent image isn\'t ready yet');
  24473. return;
  24474. }
  24475. this.paintInlineImageXObject(imgData);
  24476. },
  24477. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24478. var width = imgData.width;
  24479. var height = imgData.height;
  24480. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24481. var cliprect = document.createElementNS(NS, 'svg:rect');
  24482. cliprect.setAttributeNS(null, 'x', '0');
  24483. cliprect.setAttributeNS(null, 'y', '0');
  24484. cliprect.setAttributeNS(null, 'width', pf(width));
  24485. cliprect.setAttributeNS(null, 'height', pf(height));
  24486. this.current.element = cliprect;
  24487. this.clip('nonzero');
  24488. var imgEl = document.createElementNS(NS, 'svg:image');
  24489. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24490. imgEl.setAttributeNS(null, 'x', '0');
  24491. imgEl.setAttributeNS(null, 'y', pf(-height));
  24492. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24493. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24494. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24495. if (mask) {
  24496. mask.appendChild(imgEl);
  24497. } else {
  24498. this._ensureTransformGroup().appendChild(imgEl);
  24499. }
  24500. },
  24501. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24502. var current = this.current;
  24503. var width = imgData.width;
  24504. var height = imgData.height;
  24505. var fillColor = current.fillColor;
  24506. current.maskId = 'mask' + maskCount++;
  24507. var mask = document.createElementNS(NS, 'svg:mask');
  24508. mask.setAttributeNS(null, 'id', current.maskId);
  24509. var rect = document.createElementNS(NS, 'svg:rect');
  24510. rect.setAttributeNS(null, 'x', '0');
  24511. rect.setAttributeNS(null, 'y', '0');
  24512. rect.setAttributeNS(null, 'width', pf(width));
  24513. rect.setAttributeNS(null, 'height', pf(height));
  24514. rect.setAttributeNS(null, 'fill', fillColor);
  24515. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24516. this.defs.appendChild(mask);
  24517. this._ensureTransformGroup().appendChild(rect);
  24518. this.paintInlineImageXObject(imgData, mask);
  24519. },
  24520. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24521. if (isArray(matrix) && matrix.length === 6) {
  24522. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24523. }
  24524. if (isArray(bbox) && bbox.length === 4) {
  24525. var width = bbox[2] - bbox[0];
  24526. var height = bbox[3] - bbox[1];
  24527. var cliprect = document.createElementNS(NS, 'svg:rect');
  24528. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24529. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24530. cliprect.setAttributeNS(null, 'width', pf(width));
  24531. cliprect.setAttributeNS(null, 'height', pf(height));
  24532. this.current.element = cliprect;
  24533. this.clip('nonzero');
  24534. this.endPath();
  24535. }
  24536. },
  24537. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24538. },
  24539. _initialize: function SVGGraphics_initialize(viewport) {
  24540. var svg = document.createElementNS(NS, 'svg:svg');
  24541. svg.setAttributeNS(null, 'version', '1.1');
  24542. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24543. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24544. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24545. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24546. var definitions = document.createElementNS(NS, 'svg:defs');
  24547. svg.appendChild(definitions);
  24548. this.defs = definitions;
  24549. var rootGroup = document.createElementNS(NS, 'svg:g');
  24550. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24551. svg.appendChild(rootGroup);
  24552. this.svg = rootGroup;
  24553. return svg;
  24554. },
  24555. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24556. if (!this.current.clipGroup) {
  24557. var clipGroup = document.createElementNS(NS, 'svg:g');
  24558. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24559. this.svg.appendChild(clipGroup);
  24560. this.current.clipGroup = clipGroup;
  24561. }
  24562. return this.current.clipGroup;
  24563. },
  24564. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24565. if (!this.tgrp) {
  24566. this.tgrp = document.createElementNS(NS, 'svg:g');
  24567. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24568. if (this.current.activeClipUrl) {
  24569. this._ensureClipGroup().appendChild(this.tgrp);
  24570. } else {
  24571. this.svg.appendChild(this.tgrp);
  24572. }
  24573. }
  24574. return this.tgrp;
  24575. }
  24576. };
  24577. return SVGGraphics;
  24578. }();
  24579. exports.SVGGraphics = SVGGraphics;
  24580. }));
  24581. (function (root, factory) {
  24582. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24583. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24584. var Util = sharedUtil.Util;
  24585. var error = sharedUtil.error;
  24586. var info = sharedUtil.info;
  24587. var isInt = sharedUtil.isInt;
  24588. var isArray = sharedUtil.isArray;
  24589. var createObjectURL = sharedUtil.createObjectURL;
  24590. var shadow = sharedUtil.shadow;
  24591. var warn = sharedUtil.warn;
  24592. var isSpace = sharedUtil.isSpace;
  24593. var Dict = corePrimitives.Dict;
  24594. var isDict = corePrimitives.isDict;
  24595. var isStream = corePrimitives.isStream;
  24596. var Jbig2Image = coreJbig2.Jbig2Image;
  24597. var JpegImage = coreJpg.JpegImage;
  24598. var JpxImage = coreJpx.JpxImage;
  24599. var Stream = function StreamClosure() {
  24600. function Stream(arrayBuffer, start, length, dict) {
  24601. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24602. this.start = start || 0;
  24603. this.pos = this.start;
  24604. this.end = start + length || this.bytes.length;
  24605. this.dict = dict;
  24606. }
  24607. Stream.prototype = {
  24608. get length() {
  24609. return this.end - this.start;
  24610. },
  24611. get isEmpty() {
  24612. return this.length === 0;
  24613. },
  24614. getByte: function Stream_getByte() {
  24615. if (this.pos >= this.end) {
  24616. return -1;
  24617. }
  24618. return this.bytes[this.pos++];
  24619. },
  24620. getUint16: function Stream_getUint16() {
  24621. var b0 = this.getByte();
  24622. var b1 = this.getByte();
  24623. if (b0 === -1 || b1 === -1) {
  24624. return -1;
  24625. }
  24626. return (b0 << 8) + b1;
  24627. },
  24628. getInt32: function Stream_getInt32() {
  24629. var b0 = this.getByte();
  24630. var b1 = this.getByte();
  24631. var b2 = this.getByte();
  24632. var b3 = this.getByte();
  24633. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24634. },
  24635. getBytes: function Stream_getBytes(length) {
  24636. var bytes = this.bytes;
  24637. var pos = this.pos;
  24638. var strEnd = this.end;
  24639. if (!length) {
  24640. return bytes.subarray(pos, strEnd);
  24641. }
  24642. var end = pos + length;
  24643. if (end > strEnd) {
  24644. end = strEnd;
  24645. }
  24646. this.pos = end;
  24647. return bytes.subarray(pos, end);
  24648. },
  24649. peekByte: function Stream_peekByte() {
  24650. var peekedByte = this.getByte();
  24651. this.pos--;
  24652. return peekedByte;
  24653. },
  24654. peekBytes: function Stream_peekBytes(length) {
  24655. var bytes = this.getBytes(length);
  24656. this.pos -= bytes.length;
  24657. return bytes;
  24658. },
  24659. skip: function Stream_skip(n) {
  24660. if (!n) {
  24661. n = 1;
  24662. }
  24663. this.pos += n;
  24664. },
  24665. reset: function Stream_reset() {
  24666. this.pos = this.start;
  24667. },
  24668. moveStart: function Stream_moveStart() {
  24669. this.start = this.pos;
  24670. },
  24671. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24672. return new Stream(this.bytes.buffer, start, length, dict);
  24673. },
  24674. isStream: true
  24675. };
  24676. return Stream;
  24677. }();
  24678. var StringStream = function StringStreamClosure() {
  24679. function StringStream(str) {
  24680. var length = str.length;
  24681. var bytes = new Uint8Array(length);
  24682. for (var n = 0; n < length; ++n) {
  24683. bytes[n] = str.charCodeAt(n);
  24684. }
  24685. Stream.call(this, bytes);
  24686. }
  24687. StringStream.prototype = Stream.prototype;
  24688. return StringStream;
  24689. }();
  24690. var DecodeStream = function DecodeStreamClosure() {
  24691. var emptyBuffer = new Uint8Array(0);
  24692. function DecodeStream(maybeMinBufferLength) {
  24693. this.pos = 0;
  24694. this.bufferLength = 0;
  24695. this.eof = false;
  24696. this.buffer = emptyBuffer;
  24697. this.minBufferLength = 512;
  24698. if (maybeMinBufferLength) {
  24699. while (this.minBufferLength < maybeMinBufferLength) {
  24700. this.minBufferLength *= 2;
  24701. }
  24702. }
  24703. }
  24704. DecodeStream.prototype = {
  24705. get isEmpty() {
  24706. while (!this.eof && this.bufferLength === 0) {
  24707. this.readBlock();
  24708. }
  24709. return this.bufferLength === 0;
  24710. },
  24711. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24712. var buffer = this.buffer;
  24713. if (requested <= buffer.byteLength) {
  24714. return buffer;
  24715. }
  24716. var size = this.minBufferLength;
  24717. while (size < requested) {
  24718. size *= 2;
  24719. }
  24720. var buffer2 = new Uint8Array(size);
  24721. buffer2.set(buffer);
  24722. return this.buffer = buffer2;
  24723. },
  24724. getByte: function DecodeStream_getByte() {
  24725. var pos = this.pos;
  24726. while (this.bufferLength <= pos) {
  24727. if (this.eof) {
  24728. return -1;
  24729. }
  24730. this.readBlock();
  24731. }
  24732. return this.buffer[this.pos++];
  24733. },
  24734. getUint16: function DecodeStream_getUint16() {
  24735. var b0 = this.getByte();
  24736. var b1 = this.getByte();
  24737. if (b0 === -1 || b1 === -1) {
  24738. return -1;
  24739. }
  24740. return (b0 << 8) + b1;
  24741. },
  24742. getInt32: function DecodeStream_getInt32() {
  24743. var b0 = this.getByte();
  24744. var b1 = this.getByte();
  24745. var b2 = this.getByte();
  24746. var b3 = this.getByte();
  24747. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24748. },
  24749. getBytes: function DecodeStream_getBytes(length) {
  24750. var end, pos = this.pos;
  24751. if (length) {
  24752. this.ensureBuffer(pos + length);
  24753. end = pos + length;
  24754. while (!this.eof && this.bufferLength < end) {
  24755. this.readBlock();
  24756. }
  24757. var bufEnd = this.bufferLength;
  24758. if (end > bufEnd) {
  24759. end = bufEnd;
  24760. }
  24761. } else {
  24762. while (!this.eof) {
  24763. this.readBlock();
  24764. }
  24765. end = this.bufferLength;
  24766. }
  24767. this.pos = end;
  24768. return this.buffer.subarray(pos, end);
  24769. },
  24770. peekByte: function DecodeStream_peekByte() {
  24771. var peekedByte = this.getByte();
  24772. this.pos--;
  24773. return peekedByte;
  24774. },
  24775. peekBytes: function DecodeStream_peekBytes(length) {
  24776. var bytes = this.getBytes(length);
  24777. this.pos -= bytes.length;
  24778. return bytes;
  24779. },
  24780. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24781. var end = start + length;
  24782. while (this.bufferLength <= end && !this.eof) {
  24783. this.readBlock();
  24784. }
  24785. return new Stream(this.buffer, start, length, dict);
  24786. },
  24787. skip: function DecodeStream_skip(n) {
  24788. if (!n) {
  24789. n = 1;
  24790. }
  24791. this.pos += n;
  24792. },
  24793. reset: function DecodeStream_reset() {
  24794. this.pos = 0;
  24795. },
  24796. getBaseStreams: function DecodeStream_getBaseStreams() {
  24797. if (this.str && this.str.getBaseStreams) {
  24798. return this.str.getBaseStreams();
  24799. }
  24800. return [];
  24801. }
  24802. };
  24803. return DecodeStream;
  24804. }();
  24805. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24806. function StreamsSequenceStream(streams) {
  24807. this.streams = streams;
  24808. DecodeStream.call(this, null);
  24809. }
  24810. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24811. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24812. var streams = this.streams;
  24813. if (streams.length === 0) {
  24814. this.eof = true;
  24815. return;
  24816. }
  24817. var stream = streams.shift();
  24818. var chunk = stream.getBytes();
  24819. var bufferLength = this.bufferLength;
  24820. var newLength = bufferLength + chunk.length;
  24821. var buffer = this.ensureBuffer(newLength);
  24822. buffer.set(chunk, bufferLength);
  24823. this.bufferLength = newLength;
  24824. };
  24825. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24826. var baseStreams = [];
  24827. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24828. var stream = this.streams[i];
  24829. if (stream.getBaseStreams) {
  24830. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24831. }
  24832. }
  24833. return baseStreams;
  24834. };
  24835. return StreamsSequenceStream;
  24836. }();
  24837. var FlateStream = function FlateStreamClosure() {
  24838. var codeLenCodeMap = new Int32Array([
  24839. 16,
  24840. 17,
  24841. 18,
  24842. 0,
  24843. 8,
  24844. 7,
  24845. 9,
  24846. 6,
  24847. 10,
  24848. 5,
  24849. 11,
  24850. 4,
  24851. 12,
  24852. 3,
  24853. 13,
  24854. 2,
  24855. 14,
  24856. 1,
  24857. 15
  24858. ]);
  24859. var lengthDecode = new Int32Array([
  24860. 0x00003,
  24861. 0x00004,
  24862. 0x00005,
  24863. 0x00006,
  24864. 0x00007,
  24865. 0x00008,
  24866. 0x00009,
  24867. 0x0000a,
  24868. 0x1000b,
  24869. 0x1000d,
  24870. 0x1000f,
  24871. 0x10011,
  24872. 0x20013,
  24873. 0x20017,
  24874. 0x2001b,
  24875. 0x2001f,
  24876. 0x30023,
  24877. 0x3002b,
  24878. 0x30033,
  24879. 0x3003b,
  24880. 0x40043,
  24881. 0x40053,
  24882. 0x40063,
  24883. 0x40073,
  24884. 0x50083,
  24885. 0x500a3,
  24886. 0x500c3,
  24887. 0x500e3,
  24888. 0x00102,
  24889. 0x00102,
  24890. 0x00102
  24891. ]);
  24892. var distDecode = new Int32Array([
  24893. 0x00001,
  24894. 0x00002,
  24895. 0x00003,
  24896. 0x00004,
  24897. 0x10005,
  24898. 0x10007,
  24899. 0x20009,
  24900. 0x2000d,
  24901. 0x30011,
  24902. 0x30019,
  24903. 0x40021,
  24904. 0x40031,
  24905. 0x50041,
  24906. 0x50061,
  24907. 0x60081,
  24908. 0x600c1,
  24909. 0x70101,
  24910. 0x70181,
  24911. 0x80201,
  24912. 0x80301,
  24913. 0x90401,
  24914. 0x90601,
  24915. 0xa0801,
  24916. 0xa0c01,
  24917. 0xb1001,
  24918. 0xb1801,
  24919. 0xc2001,
  24920. 0xc3001,
  24921. 0xd4001,
  24922. 0xd6001
  24923. ]);
  24924. var fixedLitCodeTab = [
  24925. new Int32Array([
  24926. 0x70100,
  24927. 0x80050,
  24928. 0x80010,
  24929. 0x80118,
  24930. 0x70110,
  24931. 0x80070,
  24932. 0x80030,
  24933. 0x900c0,
  24934. 0x70108,
  24935. 0x80060,
  24936. 0x80020,
  24937. 0x900a0,
  24938. 0x80000,
  24939. 0x80080,
  24940. 0x80040,
  24941. 0x900e0,
  24942. 0x70104,
  24943. 0x80058,
  24944. 0x80018,
  24945. 0x90090,
  24946. 0x70114,
  24947. 0x80078,
  24948. 0x80038,
  24949. 0x900d0,
  24950. 0x7010c,
  24951. 0x80068,
  24952. 0x80028,
  24953. 0x900b0,
  24954. 0x80008,
  24955. 0x80088,
  24956. 0x80048,
  24957. 0x900f0,
  24958. 0x70102,
  24959. 0x80054,
  24960. 0x80014,
  24961. 0x8011c,
  24962. 0x70112,
  24963. 0x80074,
  24964. 0x80034,
  24965. 0x900c8,
  24966. 0x7010a,
  24967. 0x80064,
  24968. 0x80024,
  24969. 0x900a8,
  24970. 0x80004,
  24971. 0x80084,
  24972. 0x80044,
  24973. 0x900e8,
  24974. 0x70106,
  24975. 0x8005c,
  24976. 0x8001c,
  24977. 0x90098,
  24978. 0x70116,
  24979. 0x8007c,
  24980. 0x8003c,
  24981. 0x900d8,
  24982. 0x7010e,
  24983. 0x8006c,
  24984. 0x8002c,
  24985. 0x900b8,
  24986. 0x8000c,
  24987. 0x8008c,
  24988. 0x8004c,
  24989. 0x900f8,
  24990. 0x70101,
  24991. 0x80052,
  24992. 0x80012,
  24993. 0x8011a,
  24994. 0x70111,
  24995. 0x80072,
  24996. 0x80032,
  24997. 0x900c4,
  24998. 0x70109,
  24999. 0x80062,
  25000. 0x80022,
  25001. 0x900a4,
  25002. 0x80002,
  25003. 0x80082,
  25004. 0x80042,
  25005. 0x900e4,
  25006. 0x70105,
  25007. 0x8005a,
  25008. 0x8001a,
  25009. 0x90094,
  25010. 0x70115,
  25011. 0x8007a,
  25012. 0x8003a,
  25013. 0x900d4,
  25014. 0x7010d,
  25015. 0x8006a,
  25016. 0x8002a,
  25017. 0x900b4,
  25018. 0x8000a,
  25019. 0x8008a,
  25020. 0x8004a,
  25021. 0x900f4,
  25022. 0x70103,
  25023. 0x80056,
  25024. 0x80016,
  25025. 0x8011e,
  25026. 0x70113,
  25027. 0x80076,
  25028. 0x80036,
  25029. 0x900cc,
  25030. 0x7010b,
  25031. 0x80066,
  25032. 0x80026,
  25033. 0x900ac,
  25034. 0x80006,
  25035. 0x80086,
  25036. 0x80046,
  25037. 0x900ec,
  25038. 0x70107,
  25039. 0x8005e,
  25040. 0x8001e,
  25041. 0x9009c,
  25042. 0x70117,
  25043. 0x8007e,
  25044. 0x8003e,
  25045. 0x900dc,
  25046. 0x7010f,
  25047. 0x8006e,
  25048. 0x8002e,
  25049. 0x900bc,
  25050. 0x8000e,
  25051. 0x8008e,
  25052. 0x8004e,
  25053. 0x900fc,
  25054. 0x70100,
  25055. 0x80051,
  25056. 0x80011,
  25057. 0x80119,
  25058. 0x70110,
  25059. 0x80071,
  25060. 0x80031,
  25061. 0x900c2,
  25062. 0x70108,
  25063. 0x80061,
  25064. 0x80021,
  25065. 0x900a2,
  25066. 0x80001,
  25067. 0x80081,
  25068. 0x80041,
  25069. 0x900e2,
  25070. 0x70104,
  25071. 0x80059,
  25072. 0x80019,
  25073. 0x90092,
  25074. 0x70114,
  25075. 0x80079,
  25076. 0x80039,
  25077. 0x900d2,
  25078. 0x7010c,
  25079. 0x80069,
  25080. 0x80029,
  25081. 0x900b2,
  25082. 0x80009,
  25083. 0x80089,
  25084. 0x80049,
  25085. 0x900f2,
  25086. 0x70102,
  25087. 0x80055,
  25088. 0x80015,
  25089. 0x8011d,
  25090. 0x70112,
  25091. 0x80075,
  25092. 0x80035,
  25093. 0x900ca,
  25094. 0x7010a,
  25095. 0x80065,
  25096. 0x80025,
  25097. 0x900aa,
  25098. 0x80005,
  25099. 0x80085,
  25100. 0x80045,
  25101. 0x900ea,
  25102. 0x70106,
  25103. 0x8005d,
  25104. 0x8001d,
  25105. 0x9009a,
  25106. 0x70116,
  25107. 0x8007d,
  25108. 0x8003d,
  25109. 0x900da,
  25110. 0x7010e,
  25111. 0x8006d,
  25112. 0x8002d,
  25113. 0x900ba,
  25114. 0x8000d,
  25115. 0x8008d,
  25116. 0x8004d,
  25117. 0x900fa,
  25118. 0x70101,
  25119. 0x80053,
  25120. 0x80013,
  25121. 0x8011b,
  25122. 0x70111,
  25123. 0x80073,
  25124. 0x80033,
  25125. 0x900c6,
  25126. 0x70109,
  25127. 0x80063,
  25128. 0x80023,
  25129. 0x900a6,
  25130. 0x80003,
  25131. 0x80083,
  25132. 0x80043,
  25133. 0x900e6,
  25134. 0x70105,
  25135. 0x8005b,
  25136. 0x8001b,
  25137. 0x90096,
  25138. 0x70115,
  25139. 0x8007b,
  25140. 0x8003b,
  25141. 0x900d6,
  25142. 0x7010d,
  25143. 0x8006b,
  25144. 0x8002b,
  25145. 0x900b6,
  25146. 0x8000b,
  25147. 0x8008b,
  25148. 0x8004b,
  25149. 0x900f6,
  25150. 0x70103,
  25151. 0x80057,
  25152. 0x80017,
  25153. 0x8011f,
  25154. 0x70113,
  25155. 0x80077,
  25156. 0x80037,
  25157. 0x900ce,
  25158. 0x7010b,
  25159. 0x80067,
  25160. 0x80027,
  25161. 0x900ae,
  25162. 0x80007,
  25163. 0x80087,
  25164. 0x80047,
  25165. 0x900ee,
  25166. 0x70107,
  25167. 0x8005f,
  25168. 0x8001f,
  25169. 0x9009e,
  25170. 0x70117,
  25171. 0x8007f,
  25172. 0x8003f,
  25173. 0x900de,
  25174. 0x7010f,
  25175. 0x8006f,
  25176. 0x8002f,
  25177. 0x900be,
  25178. 0x8000f,
  25179. 0x8008f,
  25180. 0x8004f,
  25181. 0x900fe,
  25182. 0x70100,
  25183. 0x80050,
  25184. 0x80010,
  25185. 0x80118,
  25186. 0x70110,
  25187. 0x80070,
  25188. 0x80030,
  25189. 0x900c1,
  25190. 0x70108,
  25191. 0x80060,
  25192. 0x80020,
  25193. 0x900a1,
  25194. 0x80000,
  25195. 0x80080,
  25196. 0x80040,
  25197. 0x900e1,
  25198. 0x70104,
  25199. 0x80058,
  25200. 0x80018,
  25201. 0x90091,
  25202. 0x70114,
  25203. 0x80078,
  25204. 0x80038,
  25205. 0x900d1,
  25206. 0x7010c,
  25207. 0x80068,
  25208. 0x80028,
  25209. 0x900b1,
  25210. 0x80008,
  25211. 0x80088,
  25212. 0x80048,
  25213. 0x900f1,
  25214. 0x70102,
  25215. 0x80054,
  25216. 0x80014,
  25217. 0x8011c,
  25218. 0x70112,
  25219. 0x80074,
  25220. 0x80034,
  25221. 0x900c9,
  25222. 0x7010a,
  25223. 0x80064,
  25224. 0x80024,
  25225. 0x900a9,
  25226. 0x80004,
  25227. 0x80084,
  25228. 0x80044,
  25229. 0x900e9,
  25230. 0x70106,
  25231. 0x8005c,
  25232. 0x8001c,
  25233. 0x90099,
  25234. 0x70116,
  25235. 0x8007c,
  25236. 0x8003c,
  25237. 0x900d9,
  25238. 0x7010e,
  25239. 0x8006c,
  25240. 0x8002c,
  25241. 0x900b9,
  25242. 0x8000c,
  25243. 0x8008c,
  25244. 0x8004c,
  25245. 0x900f9,
  25246. 0x70101,
  25247. 0x80052,
  25248. 0x80012,
  25249. 0x8011a,
  25250. 0x70111,
  25251. 0x80072,
  25252. 0x80032,
  25253. 0x900c5,
  25254. 0x70109,
  25255. 0x80062,
  25256. 0x80022,
  25257. 0x900a5,
  25258. 0x80002,
  25259. 0x80082,
  25260. 0x80042,
  25261. 0x900e5,
  25262. 0x70105,
  25263. 0x8005a,
  25264. 0x8001a,
  25265. 0x90095,
  25266. 0x70115,
  25267. 0x8007a,
  25268. 0x8003a,
  25269. 0x900d5,
  25270. 0x7010d,
  25271. 0x8006a,
  25272. 0x8002a,
  25273. 0x900b5,
  25274. 0x8000a,
  25275. 0x8008a,
  25276. 0x8004a,
  25277. 0x900f5,
  25278. 0x70103,
  25279. 0x80056,
  25280. 0x80016,
  25281. 0x8011e,
  25282. 0x70113,
  25283. 0x80076,
  25284. 0x80036,
  25285. 0x900cd,
  25286. 0x7010b,
  25287. 0x80066,
  25288. 0x80026,
  25289. 0x900ad,
  25290. 0x80006,
  25291. 0x80086,
  25292. 0x80046,
  25293. 0x900ed,
  25294. 0x70107,
  25295. 0x8005e,
  25296. 0x8001e,
  25297. 0x9009d,
  25298. 0x70117,
  25299. 0x8007e,
  25300. 0x8003e,
  25301. 0x900dd,
  25302. 0x7010f,
  25303. 0x8006e,
  25304. 0x8002e,
  25305. 0x900bd,
  25306. 0x8000e,
  25307. 0x8008e,
  25308. 0x8004e,
  25309. 0x900fd,
  25310. 0x70100,
  25311. 0x80051,
  25312. 0x80011,
  25313. 0x80119,
  25314. 0x70110,
  25315. 0x80071,
  25316. 0x80031,
  25317. 0x900c3,
  25318. 0x70108,
  25319. 0x80061,
  25320. 0x80021,
  25321. 0x900a3,
  25322. 0x80001,
  25323. 0x80081,
  25324. 0x80041,
  25325. 0x900e3,
  25326. 0x70104,
  25327. 0x80059,
  25328. 0x80019,
  25329. 0x90093,
  25330. 0x70114,
  25331. 0x80079,
  25332. 0x80039,
  25333. 0x900d3,
  25334. 0x7010c,
  25335. 0x80069,
  25336. 0x80029,
  25337. 0x900b3,
  25338. 0x80009,
  25339. 0x80089,
  25340. 0x80049,
  25341. 0x900f3,
  25342. 0x70102,
  25343. 0x80055,
  25344. 0x80015,
  25345. 0x8011d,
  25346. 0x70112,
  25347. 0x80075,
  25348. 0x80035,
  25349. 0x900cb,
  25350. 0x7010a,
  25351. 0x80065,
  25352. 0x80025,
  25353. 0x900ab,
  25354. 0x80005,
  25355. 0x80085,
  25356. 0x80045,
  25357. 0x900eb,
  25358. 0x70106,
  25359. 0x8005d,
  25360. 0x8001d,
  25361. 0x9009b,
  25362. 0x70116,
  25363. 0x8007d,
  25364. 0x8003d,
  25365. 0x900db,
  25366. 0x7010e,
  25367. 0x8006d,
  25368. 0x8002d,
  25369. 0x900bb,
  25370. 0x8000d,
  25371. 0x8008d,
  25372. 0x8004d,
  25373. 0x900fb,
  25374. 0x70101,
  25375. 0x80053,
  25376. 0x80013,
  25377. 0x8011b,
  25378. 0x70111,
  25379. 0x80073,
  25380. 0x80033,
  25381. 0x900c7,
  25382. 0x70109,
  25383. 0x80063,
  25384. 0x80023,
  25385. 0x900a7,
  25386. 0x80003,
  25387. 0x80083,
  25388. 0x80043,
  25389. 0x900e7,
  25390. 0x70105,
  25391. 0x8005b,
  25392. 0x8001b,
  25393. 0x90097,
  25394. 0x70115,
  25395. 0x8007b,
  25396. 0x8003b,
  25397. 0x900d7,
  25398. 0x7010d,
  25399. 0x8006b,
  25400. 0x8002b,
  25401. 0x900b7,
  25402. 0x8000b,
  25403. 0x8008b,
  25404. 0x8004b,
  25405. 0x900f7,
  25406. 0x70103,
  25407. 0x80057,
  25408. 0x80017,
  25409. 0x8011f,
  25410. 0x70113,
  25411. 0x80077,
  25412. 0x80037,
  25413. 0x900cf,
  25414. 0x7010b,
  25415. 0x80067,
  25416. 0x80027,
  25417. 0x900af,
  25418. 0x80007,
  25419. 0x80087,
  25420. 0x80047,
  25421. 0x900ef,
  25422. 0x70107,
  25423. 0x8005f,
  25424. 0x8001f,
  25425. 0x9009f,
  25426. 0x70117,
  25427. 0x8007f,
  25428. 0x8003f,
  25429. 0x900df,
  25430. 0x7010f,
  25431. 0x8006f,
  25432. 0x8002f,
  25433. 0x900bf,
  25434. 0x8000f,
  25435. 0x8008f,
  25436. 0x8004f,
  25437. 0x900ff
  25438. ]),
  25439. 9
  25440. ];
  25441. var fixedDistCodeTab = [
  25442. new Int32Array([
  25443. 0x50000,
  25444. 0x50010,
  25445. 0x50008,
  25446. 0x50018,
  25447. 0x50004,
  25448. 0x50014,
  25449. 0x5000c,
  25450. 0x5001c,
  25451. 0x50002,
  25452. 0x50012,
  25453. 0x5000a,
  25454. 0x5001a,
  25455. 0x50006,
  25456. 0x50016,
  25457. 0x5000e,
  25458. 0x00000,
  25459. 0x50001,
  25460. 0x50011,
  25461. 0x50009,
  25462. 0x50019,
  25463. 0x50005,
  25464. 0x50015,
  25465. 0x5000d,
  25466. 0x5001d,
  25467. 0x50003,
  25468. 0x50013,
  25469. 0x5000b,
  25470. 0x5001b,
  25471. 0x50007,
  25472. 0x50017,
  25473. 0x5000f,
  25474. 0x00000
  25475. ]),
  25476. 5
  25477. ];
  25478. function FlateStream(str, maybeLength) {
  25479. this.str = str;
  25480. this.dict = str.dict;
  25481. var cmf = str.getByte();
  25482. var flg = str.getByte();
  25483. if (cmf === -1 || flg === -1) {
  25484. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25485. }
  25486. if ((cmf & 0x0f) !== 0x08) {
  25487. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25488. }
  25489. if (((cmf << 8) + flg) % 31 !== 0) {
  25490. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25491. }
  25492. if (flg & 0x20) {
  25493. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25494. }
  25495. this.codeSize = 0;
  25496. this.codeBuf = 0;
  25497. DecodeStream.call(this, maybeLength);
  25498. }
  25499. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25500. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25501. var str = this.str;
  25502. var codeSize = this.codeSize;
  25503. var codeBuf = this.codeBuf;
  25504. var b;
  25505. while (codeSize < bits) {
  25506. if ((b = str.getByte()) === -1) {
  25507. error('Bad encoding in flate stream');
  25508. }
  25509. codeBuf |= b << codeSize;
  25510. codeSize += 8;
  25511. }
  25512. b = codeBuf & (1 << bits) - 1;
  25513. this.codeBuf = codeBuf >> bits;
  25514. this.codeSize = codeSize -= bits;
  25515. return b;
  25516. };
  25517. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25518. var str = this.str;
  25519. var codes = table[0];
  25520. var maxLen = table[1];
  25521. var codeSize = this.codeSize;
  25522. var codeBuf = this.codeBuf;
  25523. var b;
  25524. while (codeSize < maxLen) {
  25525. if ((b = str.getByte()) === -1) {
  25526. break;
  25527. }
  25528. codeBuf |= b << codeSize;
  25529. codeSize += 8;
  25530. }
  25531. var code = codes[codeBuf & (1 << maxLen) - 1];
  25532. var codeLen = code >> 16;
  25533. var codeVal = code & 0xffff;
  25534. if (codeLen < 1 || codeSize < codeLen) {
  25535. error('Bad encoding in flate stream');
  25536. }
  25537. this.codeBuf = codeBuf >> codeLen;
  25538. this.codeSize = codeSize - codeLen;
  25539. return codeVal;
  25540. };
  25541. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25542. var n = lengths.length;
  25543. var maxLen = 0;
  25544. var i;
  25545. for (i = 0; i < n; ++i) {
  25546. if (lengths[i] > maxLen) {
  25547. maxLen = lengths[i];
  25548. }
  25549. }
  25550. var size = 1 << maxLen;
  25551. var codes = new Int32Array(size);
  25552. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25553. for (var val = 0; val < n; ++val) {
  25554. if (lengths[val] === len) {
  25555. var code2 = 0;
  25556. var t = code;
  25557. for (i = 0; i < len; ++i) {
  25558. code2 = code2 << 1 | t & 1;
  25559. t >>= 1;
  25560. }
  25561. for (i = code2; i < size; i += skip) {
  25562. codes[i] = len << 16 | val;
  25563. }
  25564. ++code;
  25565. }
  25566. }
  25567. }
  25568. return [
  25569. codes,
  25570. maxLen
  25571. ];
  25572. };
  25573. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25574. var buffer, len;
  25575. var str = this.str;
  25576. var hdr = this.getBits(3);
  25577. if (hdr & 1) {
  25578. this.eof = true;
  25579. }
  25580. hdr >>= 1;
  25581. if (hdr === 0) {
  25582. var b;
  25583. if ((b = str.getByte()) === -1) {
  25584. error('Bad block header in flate stream');
  25585. }
  25586. var blockLen = b;
  25587. if ((b = str.getByte()) === -1) {
  25588. error('Bad block header in flate stream');
  25589. }
  25590. blockLen |= b << 8;
  25591. if ((b = str.getByte()) === -1) {
  25592. error('Bad block header in flate stream');
  25593. }
  25594. var check = b;
  25595. if ((b = str.getByte()) === -1) {
  25596. error('Bad block header in flate stream');
  25597. }
  25598. check |= b << 8;
  25599. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25600. error('Bad uncompressed block length in flate stream');
  25601. }
  25602. this.codeBuf = 0;
  25603. this.codeSize = 0;
  25604. var bufferLength = this.bufferLength;
  25605. buffer = this.ensureBuffer(bufferLength + blockLen);
  25606. var end = bufferLength + blockLen;
  25607. this.bufferLength = end;
  25608. if (blockLen === 0) {
  25609. if (str.peekByte() === -1) {
  25610. this.eof = true;
  25611. }
  25612. } else {
  25613. for (var n = bufferLength; n < end; ++n) {
  25614. if ((b = str.getByte()) === -1) {
  25615. this.eof = true;
  25616. break;
  25617. }
  25618. buffer[n] = b;
  25619. }
  25620. }
  25621. return;
  25622. }
  25623. var litCodeTable;
  25624. var distCodeTable;
  25625. if (hdr === 1) {
  25626. litCodeTable = fixedLitCodeTab;
  25627. distCodeTable = fixedDistCodeTab;
  25628. } else if (hdr === 2) {
  25629. var numLitCodes = this.getBits(5) + 257;
  25630. var numDistCodes = this.getBits(5) + 1;
  25631. var numCodeLenCodes = this.getBits(4) + 4;
  25632. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25633. var i;
  25634. for (i = 0; i < numCodeLenCodes; ++i) {
  25635. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25636. }
  25637. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25638. len = 0;
  25639. i = 0;
  25640. var codes = numLitCodes + numDistCodes;
  25641. var codeLengths = new Uint8Array(codes);
  25642. var bitsLength, bitsOffset, what;
  25643. while (i < codes) {
  25644. var code = this.getCode(codeLenCodeTab);
  25645. if (code === 16) {
  25646. bitsLength = 2;
  25647. bitsOffset = 3;
  25648. what = len;
  25649. } else if (code === 17) {
  25650. bitsLength = 3;
  25651. bitsOffset = 3;
  25652. what = len = 0;
  25653. } else if (code === 18) {
  25654. bitsLength = 7;
  25655. bitsOffset = 11;
  25656. what = len = 0;
  25657. } else {
  25658. codeLengths[i++] = len = code;
  25659. continue;
  25660. }
  25661. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25662. while (repeatLength-- > 0) {
  25663. codeLengths[i++] = what;
  25664. }
  25665. }
  25666. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25667. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25668. } else {
  25669. error('Unknown block type in flate stream');
  25670. }
  25671. buffer = this.buffer;
  25672. var limit = buffer ? buffer.length : 0;
  25673. var pos = this.bufferLength;
  25674. while (true) {
  25675. var code1 = this.getCode(litCodeTable);
  25676. if (code1 < 256) {
  25677. if (pos + 1 >= limit) {
  25678. buffer = this.ensureBuffer(pos + 1);
  25679. limit = buffer.length;
  25680. }
  25681. buffer[pos++] = code1;
  25682. continue;
  25683. }
  25684. if (code1 === 256) {
  25685. this.bufferLength = pos;
  25686. return;
  25687. }
  25688. code1 -= 257;
  25689. code1 = lengthDecode[code1];
  25690. var code2 = code1 >> 16;
  25691. if (code2 > 0) {
  25692. code2 = this.getBits(code2);
  25693. }
  25694. len = (code1 & 0xffff) + code2;
  25695. code1 = this.getCode(distCodeTable);
  25696. code1 = distDecode[code1];
  25697. code2 = code1 >> 16;
  25698. if (code2 > 0) {
  25699. code2 = this.getBits(code2);
  25700. }
  25701. var dist = (code1 & 0xffff) + code2;
  25702. if (pos + len >= limit) {
  25703. buffer = this.ensureBuffer(pos + len);
  25704. limit = buffer.length;
  25705. }
  25706. for (var k = 0; k < len; ++k, ++pos) {
  25707. buffer[pos] = buffer[pos - dist];
  25708. }
  25709. }
  25710. };
  25711. return FlateStream;
  25712. }();
  25713. var PredictorStream = function PredictorStreamClosure() {
  25714. function PredictorStream(str, maybeLength, params) {
  25715. if (!isDict(params)) {
  25716. return str;
  25717. }
  25718. var predictor = this.predictor = params.get('Predictor') || 1;
  25719. if (predictor <= 1) {
  25720. return str;
  25721. }
  25722. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25723. error('Unsupported predictor: ' + predictor);
  25724. }
  25725. if (predictor === 2) {
  25726. this.readBlock = this.readBlockTiff;
  25727. } else {
  25728. this.readBlock = this.readBlockPng;
  25729. }
  25730. this.str = str;
  25731. this.dict = str.dict;
  25732. var colors = this.colors = params.get('Colors') || 1;
  25733. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25734. var columns = this.columns = params.get('Columns') || 1;
  25735. this.pixBytes = colors * bits + 7 >> 3;
  25736. this.rowBytes = columns * colors * bits + 7 >> 3;
  25737. DecodeStream.call(this, maybeLength);
  25738. return this;
  25739. }
  25740. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25741. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25742. var rowBytes = this.rowBytes;
  25743. var bufferLength = this.bufferLength;
  25744. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25745. var bits = this.bits;
  25746. var colors = this.colors;
  25747. var rawBytes = this.str.getBytes(rowBytes);
  25748. this.eof = !rawBytes.length;
  25749. if (this.eof) {
  25750. return;
  25751. }
  25752. var inbuf = 0, outbuf = 0;
  25753. var inbits = 0, outbits = 0;
  25754. var pos = bufferLength;
  25755. var i;
  25756. if (bits === 1) {
  25757. for (i = 0; i < rowBytes; ++i) {
  25758. var c = rawBytes[i];
  25759. inbuf = inbuf << 8 | c;
  25760. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  25761. inbuf &= 0xFFFF;
  25762. }
  25763. } else if (bits === 8) {
  25764. for (i = 0; i < colors; ++i) {
  25765. buffer[pos++] = rawBytes[i];
  25766. }
  25767. for (; i < rowBytes; ++i) {
  25768. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  25769. pos++;
  25770. }
  25771. } else {
  25772. var compArray = new Uint8Array(colors + 1);
  25773. var bitMask = (1 << bits) - 1;
  25774. var j = 0, k = bufferLength;
  25775. var columns = this.columns;
  25776. for (i = 0; i < columns; ++i) {
  25777. for (var kk = 0; kk < colors; ++kk) {
  25778. if (inbits < bits) {
  25779. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  25780. inbits += 8;
  25781. }
  25782. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  25783. inbits -= bits;
  25784. outbuf = outbuf << bits | compArray[kk];
  25785. outbits += bits;
  25786. if (outbits >= 8) {
  25787. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  25788. outbits -= 8;
  25789. }
  25790. }
  25791. }
  25792. if (outbits > 0) {
  25793. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  25794. }
  25795. }
  25796. this.bufferLength += rowBytes;
  25797. };
  25798. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  25799. var rowBytes = this.rowBytes;
  25800. var pixBytes = this.pixBytes;
  25801. var predictor = this.str.getByte();
  25802. var rawBytes = this.str.getBytes(rowBytes);
  25803. this.eof = !rawBytes.length;
  25804. if (this.eof) {
  25805. return;
  25806. }
  25807. var bufferLength = this.bufferLength;
  25808. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25809. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  25810. if (prevRow.length === 0) {
  25811. prevRow = new Uint8Array(rowBytes);
  25812. }
  25813. var i, j = bufferLength, up, c;
  25814. switch (predictor) {
  25815. case 0:
  25816. for (i = 0; i < rowBytes; ++i) {
  25817. buffer[j++] = rawBytes[i];
  25818. }
  25819. break;
  25820. case 1:
  25821. for (i = 0; i < pixBytes; ++i) {
  25822. buffer[j++] = rawBytes[i];
  25823. }
  25824. for (; i < rowBytes; ++i) {
  25825. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  25826. j++;
  25827. }
  25828. break;
  25829. case 2:
  25830. for (i = 0; i < rowBytes; ++i) {
  25831. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  25832. }
  25833. break;
  25834. case 3:
  25835. for (i = 0; i < pixBytes; ++i) {
  25836. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  25837. }
  25838. for (; i < rowBytes; ++i) {
  25839. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  25840. j++;
  25841. }
  25842. break;
  25843. case 4:
  25844. for (i = 0; i < pixBytes; ++i) {
  25845. up = prevRow[i];
  25846. c = rawBytes[i];
  25847. buffer[j++] = up + c;
  25848. }
  25849. for (; i < rowBytes; ++i) {
  25850. up = prevRow[i];
  25851. var upLeft = prevRow[i - pixBytes];
  25852. var left = buffer[j - pixBytes];
  25853. var p = left + up - upLeft;
  25854. var pa = p - left;
  25855. if (pa < 0) {
  25856. pa = -pa;
  25857. }
  25858. var pb = p - up;
  25859. if (pb < 0) {
  25860. pb = -pb;
  25861. }
  25862. var pc = p - upLeft;
  25863. if (pc < 0) {
  25864. pc = -pc;
  25865. }
  25866. c = rawBytes[i];
  25867. if (pa <= pb && pa <= pc) {
  25868. buffer[j++] = left + c;
  25869. } else if (pb <= pc) {
  25870. buffer[j++] = up + c;
  25871. } else {
  25872. buffer[j++] = upLeft + c;
  25873. }
  25874. }
  25875. break;
  25876. default:
  25877. error('Unsupported predictor: ' + predictor);
  25878. }
  25879. this.bufferLength += rowBytes;
  25880. };
  25881. return PredictorStream;
  25882. }();
  25883. var JpegStream = function JpegStreamClosure() {
  25884. function JpegStream(stream, maybeLength, dict, params) {
  25885. var ch;
  25886. while ((ch = stream.getByte()) !== -1) {
  25887. if (ch === 0xFF) {
  25888. stream.skip(-1);
  25889. break;
  25890. }
  25891. }
  25892. this.stream = stream;
  25893. this.maybeLength = maybeLength;
  25894. this.dict = dict;
  25895. this.params = params;
  25896. DecodeStream.call(this, maybeLength);
  25897. }
  25898. JpegStream.prototype = Object.create(DecodeStream.prototype);
  25899. Object.defineProperty(JpegStream.prototype, 'bytes', {
  25900. get: function JpegStream_bytes() {
  25901. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25902. },
  25903. configurable: true
  25904. });
  25905. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  25906. if (this.bufferLength) {
  25907. return;
  25908. }
  25909. var jpegImage = new JpegImage();
  25910. var decodeArr = this.dict.getArray('Decode', 'D');
  25911. if (this.forceRGB && isArray(decodeArr)) {
  25912. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  25913. var decodeArrLength = decodeArr.length;
  25914. var transform = new Int32Array(decodeArrLength);
  25915. var transformNeeded = false;
  25916. var maxValue = (1 << bitsPerComponent) - 1;
  25917. for (var i = 0; i < decodeArrLength; i += 2) {
  25918. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  25919. transform[i + 1] = decodeArr[i] * maxValue | 0;
  25920. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  25921. transformNeeded = true;
  25922. }
  25923. }
  25924. if (transformNeeded) {
  25925. jpegImage.decodeTransform = transform;
  25926. }
  25927. }
  25928. if (isDict(this.params)) {
  25929. var colorTransform = this.params.get('ColorTransform');
  25930. if (isInt(colorTransform)) {
  25931. jpegImage.colorTransform = colorTransform;
  25932. }
  25933. }
  25934. jpegImage.parse(this.bytes);
  25935. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  25936. this.buffer = data;
  25937. this.bufferLength = data.length;
  25938. this.eof = true;
  25939. };
  25940. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  25941. this.ensureBuffer();
  25942. return this.buffer;
  25943. };
  25944. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  25945. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  25946. };
  25947. return JpegStream;
  25948. }();
  25949. var JpxStream = function JpxStreamClosure() {
  25950. function JpxStream(stream, maybeLength, dict, params) {
  25951. this.stream = stream;
  25952. this.maybeLength = maybeLength;
  25953. this.dict = dict;
  25954. this.params = params;
  25955. DecodeStream.call(this, maybeLength);
  25956. }
  25957. JpxStream.prototype = Object.create(DecodeStream.prototype);
  25958. Object.defineProperty(JpxStream.prototype, 'bytes', {
  25959. get: function JpxStream_bytes() {
  25960. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25961. },
  25962. configurable: true
  25963. });
  25964. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  25965. if (this.bufferLength) {
  25966. return;
  25967. }
  25968. var jpxImage = new JpxImage();
  25969. jpxImage.parse(this.bytes);
  25970. var width = jpxImage.width;
  25971. var height = jpxImage.height;
  25972. var componentsCount = jpxImage.componentsCount;
  25973. var tileCount = jpxImage.tiles.length;
  25974. if (tileCount === 1) {
  25975. this.buffer = jpxImage.tiles[0].items;
  25976. } else {
  25977. var data = new Uint8Array(width * height * componentsCount);
  25978. for (var k = 0; k < tileCount; k++) {
  25979. var tileComponents = jpxImage.tiles[k];
  25980. var tileWidth = tileComponents.width;
  25981. var tileHeight = tileComponents.height;
  25982. var tileLeft = tileComponents.left;
  25983. var tileTop = tileComponents.top;
  25984. var src = tileComponents.items;
  25985. var srcPosition = 0;
  25986. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  25987. var imgRowSize = width * componentsCount;
  25988. var tileRowSize = tileWidth * componentsCount;
  25989. for (var j = 0; j < tileHeight; j++) {
  25990. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  25991. data.set(rowBytes, dataPosition);
  25992. srcPosition += tileRowSize;
  25993. dataPosition += imgRowSize;
  25994. }
  25995. }
  25996. this.buffer = data;
  25997. }
  25998. this.bufferLength = this.buffer.length;
  25999. this.eof = true;
  26000. };
  26001. return JpxStream;
  26002. }();
  26003. var Jbig2Stream = function Jbig2StreamClosure() {
  26004. function Jbig2Stream(stream, maybeLength, dict, params) {
  26005. this.stream = stream;
  26006. this.maybeLength = maybeLength;
  26007. this.dict = dict;
  26008. this.params = params;
  26009. DecodeStream.call(this, maybeLength);
  26010. }
  26011. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26012. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26013. get: function Jbig2Stream_bytes() {
  26014. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26015. },
  26016. configurable: true
  26017. });
  26018. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26019. if (this.bufferLength) {
  26020. return;
  26021. }
  26022. var jbig2Image = new Jbig2Image();
  26023. var chunks = [];
  26024. if (isDict(this.params)) {
  26025. var globalsStream = this.params.get('JBIG2Globals');
  26026. if (isStream(globalsStream)) {
  26027. var globals = globalsStream.getBytes();
  26028. chunks.push({
  26029. data: globals,
  26030. start: 0,
  26031. end: globals.length
  26032. });
  26033. }
  26034. }
  26035. chunks.push({
  26036. data: this.bytes,
  26037. start: 0,
  26038. end: this.bytes.length
  26039. });
  26040. var data = jbig2Image.parseChunks(chunks);
  26041. var dataLength = data.length;
  26042. for (var i = 0; i < dataLength; i++) {
  26043. data[i] ^= 0xFF;
  26044. }
  26045. this.buffer = data;
  26046. this.bufferLength = dataLength;
  26047. this.eof = true;
  26048. };
  26049. return Jbig2Stream;
  26050. }();
  26051. var DecryptStream = function DecryptStreamClosure() {
  26052. function DecryptStream(str, maybeLength, decrypt) {
  26053. this.str = str;
  26054. this.dict = str.dict;
  26055. this.decrypt = decrypt;
  26056. this.nextChunk = null;
  26057. this.initialized = false;
  26058. DecodeStream.call(this, maybeLength);
  26059. }
  26060. var chunkSize = 512;
  26061. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26062. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26063. var chunk;
  26064. if (this.initialized) {
  26065. chunk = this.nextChunk;
  26066. } else {
  26067. chunk = this.str.getBytes(chunkSize);
  26068. this.initialized = true;
  26069. }
  26070. if (!chunk || chunk.length === 0) {
  26071. this.eof = true;
  26072. return;
  26073. }
  26074. this.nextChunk = this.str.getBytes(chunkSize);
  26075. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26076. var decrypt = this.decrypt;
  26077. chunk = decrypt(chunk, !hasMoreData);
  26078. var bufferLength = this.bufferLength;
  26079. var i, n = chunk.length;
  26080. var buffer = this.ensureBuffer(bufferLength + n);
  26081. for (i = 0; i < n; i++) {
  26082. buffer[bufferLength++] = chunk[i];
  26083. }
  26084. this.bufferLength = bufferLength;
  26085. };
  26086. return DecryptStream;
  26087. }();
  26088. var Ascii85Stream = function Ascii85StreamClosure() {
  26089. function Ascii85Stream(str, maybeLength) {
  26090. this.str = str;
  26091. this.dict = str.dict;
  26092. this.input = new Uint8Array(5);
  26093. if (maybeLength) {
  26094. maybeLength = 0.8 * maybeLength;
  26095. }
  26096. DecodeStream.call(this, maybeLength);
  26097. }
  26098. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26099. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26100. var TILDA_CHAR = 0x7E;
  26101. var Z_LOWER_CHAR = 0x7A;
  26102. var EOF = -1;
  26103. var str = this.str;
  26104. var c = str.getByte();
  26105. while (isSpace(c)) {
  26106. c = str.getByte();
  26107. }
  26108. if (c === EOF || c === TILDA_CHAR) {
  26109. this.eof = true;
  26110. return;
  26111. }
  26112. var bufferLength = this.bufferLength, buffer;
  26113. var i;
  26114. if (c === Z_LOWER_CHAR) {
  26115. buffer = this.ensureBuffer(bufferLength + 4);
  26116. for (i = 0; i < 4; ++i) {
  26117. buffer[bufferLength + i] = 0;
  26118. }
  26119. this.bufferLength += 4;
  26120. } else {
  26121. var input = this.input;
  26122. input[0] = c;
  26123. for (i = 1; i < 5; ++i) {
  26124. c = str.getByte();
  26125. while (isSpace(c)) {
  26126. c = str.getByte();
  26127. }
  26128. input[i] = c;
  26129. if (c === EOF || c === TILDA_CHAR) {
  26130. break;
  26131. }
  26132. }
  26133. buffer = this.ensureBuffer(bufferLength + i - 1);
  26134. this.bufferLength += i - 1;
  26135. if (i < 5) {
  26136. for (; i < 5; ++i) {
  26137. input[i] = 0x21 + 84;
  26138. }
  26139. this.eof = true;
  26140. }
  26141. var t = 0;
  26142. for (i = 0; i < 5; ++i) {
  26143. t = t * 85 + (input[i] - 0x21);
  26144. }
  26145. for (i = 3; i >= 0; --i) {
  26146. buffer[bufferLength + i] = t & 0xFF;
  26147. t >>= 8;
  26148. }
  26149. }
  26150. };
  26151. return Ascii85Stream;
  26152. }();
  26153. var AsciiHexStream = function AsciiHexStreamClosure() {
  26154. function AsciiHexStream(str, maybeLength) {
  26155. this.str = str;
  26156. this.dict = str.dict;
  26157. this.firstDigit = -1;
  26158. if (maybeLength) {
  26159. maybeLength = 0.5 * maybeLength;
  26160. }
  26161. DecodeStream.call(this, maybeLength);
  26162. }
  26163. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26164. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26165. var UPSTREAM_BLOCK_SIZE = 8000;
  26166. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26167. if (!bytes.length) {
  26168. this.eof = true;
  26169. return;
  26170. }
  26171. var maxDecodeLength = bytes.length + 1 >> 1;
  26172. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26173. var bufferLength = this.bufferLength;
  26174. var firstDigit = this.firstDigit;
  26175. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26176. var ch = bytes[i], digit;
  26177. if (ch >= 0x30 && ch <= 0x39) {
  26178. digit = ch & 0x0F;
  26179. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26180. digit = (ch & 0x0F) + 9;
  26181. } else if (ch === 0x3E) {
  26182. this.eof = true;
  26183. break;
  26184. } else {
  26185. continue;
  26186. }
  26187. if (firstDigit < 0) {
  26188. firstDigit = digit;
  26189. } else {
  26190. buffer[bufferLength++] = firstDigit << 4 | digit;
  26191. firstDigit = -1;
  26192. }
  26193. }
  26194. if (firstDigit >= 0 && this.eof) {
  26195. buffer[bufferLength++] = firstDigit << 4;
  26196. firstDigit = -1;
  26197. }
  26198. this.firstDigit = firstDigit;
  26199. this.bufferLength = bufferLength;
  26200. };
  26201. return AsciiHexStream;
  26202. }();
  26203. var RunLengthStream = function RunLengthStreamClosure() {
  26204. function RunLengthStream(str, maybeLength) {
  26205. this.str = str;
  26206. this.dict = str.dict;
  26207. DecodeStream.call(this, maybeLength);
  26208. }
  26209. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26210. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26211. var repeatHeader = this.str.getBytes(2);
  26212. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26213. this.eof = true;
  26214. return;
  26215. }
  26216. var buffer;
  26217. var bufferLength = this.bufferLength;
  26218. var n = repeatHeader[0];
  26219. if (n < 128) {
  26220. buffer = this.ensureBuffer(bufferLength + n + 1);
  26221. buffer[bufferLength++] = repeatHeader[1];
  26222. if (n > 0) {
  26223. var source = this.str.getBytes(n);
  26224. buffer.set(source, bufferLength);
  26225. bufferLength += n;
  26226. }
  26227. } else {
  26228. n = 257 - n;
  26229. var b = repeatHeader[1];
  26230. buffer = this.ensureBuffer(bufferLength + n + 1);
  26231. for (var i = 0; i < n; i++) {
  26232. buffer[bufferLength++] = b;
  26233. }
  26234. }
  26235. this.bufferLength = bufferLength;
  26236. };
  26237. return RunLengthStream;
  26238. }();
  26239. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26240. var ccittEOL = -2;
  26241. var ccittEOF = -1;
  26242. var twoDimPass = 0;
  26243. var twoDimHoriz = 1;
  26244. var twoDimVert0 = 2;
  26245. var twoDimVertR1 = 3;
  26246. var twoDimVertL1 = 4;
  26247. var twoDimVertR2 = 5;
  26248. var twoDimVertL2 = 6;
  26249. var twoDimVertR3 = 7;
  26250. var twoDimVertL3 = 8;
  26251. var twoDimTable = [
  26252. [
  26253. -1,
  26254. -1
  26255. ],
  26256. [
  26257. -1,
  26258. -1
  26259. ],
  26260. [
  26261. 7,
  26262. twoDimVertL3
  26263. ],
  26264. [
  26265. 7,
  26266. twoDimVertR3
  26267. ],
  26268. [
  26269. 6,
  26270. twoDimVertL2
  26271. ],
  26272. [
  26273. 6,
  26274. twoDimVertL2
  26275. ],
  26276. [
  26277. 6,
  26278. twoDimVertR2
  26279. ],
  26280. [
  26281. 6,
  26282. twoDimVertR2
  26283. ],
  26284. [
  26285. 4,
  26286. twoDimPass
  26287. ],
  26288. [
  26289. 4,
  26290. twoDimPass
  26291. ],
  26292. [
  26293. 4,
  26294. twoDimPass
  26295. ],
  26296. [
  26297. 4,
  26298. twoDimPass
  26299. ],
  26300. [
  26301. 4,
  26302. twoDimPass
  26303. ],
  26304. [
  26305. 4,
  26306. twoDimPass
  26307. ],
  26308. [
  26309. 4,
  26310. twoDimPass
  26311. ],
  26312. [
  26313. 4,
  26314. twoDimPass
  26315. ],
  26316. [
  26317. 3,
  26318. twoDimHoriz
  26319. ],
  26320. [
  26321. 3,
  26322. twoDimHoriz
  26323. ],
  26324. [
  26325. 3,
  26326. twoDimHoriz
  26327. ],
  26328. [
  26329. 3,
  26330. twoDimHoriz
  26331. ],
  26332. [
  26333. 3,
  26334. twoDimHoriz
  26335. ],
  26336. [
  26337. 3,
  26338. twoDimHoriz
  26339. ],
  26340. [
  26341. 3,
  26342. twoDimHoriz
  26343. ],
  26344. [
  26345. 3,
  26346. twoDimHoriz
  26347. ],
  26348. [
  26349. 3,
  26350. twoDimHoriz
  26351. ],
  26352. [
  26353. 3,
  26354. twoDimHoriz
  26355. ],
  26356. [
  26357. 3,
  26358. twoDimHoriz
  26359. ],
  26360. [
  26361. 3,
  26362. twoDimHoriz
  26363. ],
  26364. [
  26365. 3,
  26366. twoDimHoriz
  26367. ],
  26368. [
  26369. 3,
  26370. twoDimHoriz
  26371. ],
  26372. [
  26373. 3,
  26374. twoDimHoriz
  26375. ],
  26376. [
  26377. 3,
  26378. twoDimHoriz
  26379. ],
  26380. [
  26381. 3,
  26382. twoDimVertL1
  26383. ],
  26384. [
  26385. 3,
  26386. twoDimVertL1
  26387. ],
  26388. [
  26389. 3,
  26390. twoDimVertL1
  26391. ],
  26392. [
  26393. 3,
  26394. twoDimVertL1
  26395. ],
  26396. [
  26397. 3,
  26398. twoDimVertL1
  26399. ],
  26400. [
  26401. 3,
  26402. twoDimVertL1
  26403. ],
  26404. [
  26405. 3,
  26406. twoDimVertL1
  26407. ],
  26408. [
  26409. 3,
  26410. twoDimVertL1
  26411. ],
  26412. [
  26413. 3,
  26414. twoDimVertL1
  26415. ],
  26416. [
  26417. 3,
  26418. twoDimVertL1
  26419. ],
  26420. [
  26421. 3,
  26422. twoDimVertL1
  26423. ],
  26424. [
  26425. 3,
  26426. twoDimVertL1
  26427. ],
  26428. [
  26429. 3,
  26430. twoDimVertL1
  26431. ],
  26432. [
  26433. 3,
  26434. twoDimVertL1
  26435. ],
  26436. [
  26437. 3,
  26438. twoDimVertL1
  26439. ],
  26440. [
  26441. 3,
  26442. twoDimVertL1
  26443. ],
  26444. [
  26445. 3,
  26446. twoDimVertR1
  26447. ],
  26448. [
  26449. 3,
  26450. twoDimVertR1
  26451. ],
  26452. [
  26453. 3,
  26454. twoDimVertR1
  26455. ],
  26456. [
  26457. 3,
  26458. twoDimVertR1
  26459. ],
  26460. [
  26461. 3,
  26462. twoDimVertR1
  26463. ],
  26464. [
  26465. 3,
  26466. twoDimVertR1
  26467. ],
  26468. [
  26469. 3,
  26470. twoDimVertR1
  26471. ],
  26472. [
  26473. 3,
  26474. twoDimVertR1
  26475. ],
  26476. [
  26477. 3,
  26478. twoDimVertR1
  26479. ],
  26480. [
  26481. 3,
  26482. twoDimVertR1
  26483. ],
  26484. [
  26485. 3,
  26486. twoDimVertR1
  26487. ],
  26488. [
  26489. 3,
  26490. twoDimVertR1
  26491. ],
  26492. [
  26493. 3,
  26494. twoDimVertR1
  26495. ],
  26496. [
  26497. 3,
  26498. twoDimVertR1
  26499. ],
  26500. [
  26501. 3,
  26502. twoDimVertR1
  26503. ],
  26504. [
  26505. 3,
  26506. twoDimVertR1
  26507. ],
  26508. [
  26509. 1,
  26510. twoDimVert0
  26511. ],
  26512. [
  26513. 1,
  26514. twoDimVert0
  26515. ],
  26516. [
  26517. 1,
  26518. twoDimVert0
  26519. ],
  26520. [
  26521. 1,
  26522. twoDimVert0
  26523. ],
  26524. [
  26525. 1,
  26526. twoDimVert0
  26527. ],
  26528. [
  26529. 1,
  26530. twoDimVert0
  26531. ],
  26532. [
  26533. 1,
  26534. twoDimVert0
  26535. ],
  26536. [
  26537. 1,
  26538. twoDimVert0
  26539. ],
  26540. [
  26541. 1,
  26542. twoDimVert0
  26543. ],
  26544. [
  26545. 1,
  26546. twoDimVert0
  26547. ],
  26548. [
  26549. 1,
  26550. twoDimVert0
  26551. ],
  26552. [
  26553. 1,
  26554. twoDimVert0
  26555. ],
  26556. [
  26557. 1,
  26558. twoDimVert0
  26559. ],
  26560. [
  26561. 1,
  26562. twoDimVert0
  26563. ],
  26564. [
  26565. 1,
  26566. twoDimVert0
  26567. ],
  26568. [
  26569. 1,
  26570. twoDimVert0
  26571. ],
  26572. [
  26573. 1,
  26574. twoDimVert0
  26575. ],
  26576. [
  26577. 1,
  26578. twoDimVert0
  26579. ],
  26580. [
  26581. 1,
  26582. twoDimVert0
  26583. ],
  26584. [
  26585. 1,
  26586. twoDimVert0
  26587. ],
  26588. [
  26589. 1,
  26590. twoDimVert0
  26591. ],
  26592. [
  26593. 1,
  26594. twoDimVert0
  26595. ],
  26596. [
  26597. 1,
  26598. twoDimVert0
  26599. ],
  26600. [
  26601. 1,
  26602. twoDimVert0
  26603. ],
  26604. [
  26605. 1,
  26606. twoDimVert0
  26607. ],
  26608. [
  26609. 1,
  26610. twoDimVert0
  26611. ],
  26612. [
  26613. 1,
  26614. twoDimVert0
  26615. ],
  26616. [
  26617. 1,
  26618. twoDimVert0
  26619. ],
  26620. [
  26621. 1,
  26622. twoDimVert0
  26623. ],
  26624. [
  26625. 1,
  26626. twoDimVert0
  26627. ],
  26628. [
  26629. 1,
  26630. twoDimVert0
  26631. ],
  26632. [
  26633. 1,
  26634. twoDimVert0
  26635. ],
  26636. [
  26637. 1,
  26638. twoDimVert0
  26639. ],
  26640. [
  26641. 1,
  26642. twoDimVert0
  26643. ],
  26644. [
  26645. 1,
  26646. twoDimVert0
  26647. ],
  26648. [
  26649. 1,
  26650. twoDimVert0
  26651. ],
  26652. [
  26653. 1,
  26654. twoDimVert0
  26655. ],
  26656. [
  26657. 1,
  26658. twoDimVert0
  26659. ],
  26660. [
  26661. 1,
  26662. twoDimVert0
  26663. ],
  26664. [
  26665. 1,
  26666. twoDimVert0
  26667. ],
  26668. [
  26669. 1,
  26670. twoDimVert0
  26671. ],
  26672. [
  26673. 1,
  26674. twoDimVert0
  26675. ],
  26676. [
  26677. 1,
  26678. twoDimVert0
  26679. ],
  26680. [
  26681. 1,
  26682. twoDimVert0
  26683. ],
  26684. [
  26685. 1,
  26686. twoDimVert0
  26687. ],
  26688. [
  26689. 1,
  26690. twoDimVert0
  26691. ],
  26692. [
  26693. 1,
  26694. twoDimVert0
  26695. ],
  26696. [
  26697. 1,
  26698. twoDimVert0
  26699. ],
  26700. [
  26701. 1,
  26702. twoDimVert0
  26703. ],
  26704. [
  26705. 1,
  26706. twoDimVert0
  26707. ],
  26708. [
  26709. 1,
  26710. twoDimVert0
  26711. ],
  26712. [
  26713. 1,
  26714. twoDimVert0
  26715. ],
  26716. [
  26717. 1,
  26718. twoDimVert0
  26719. ],
  26720. [
  26721. 1,
  26722. twoDimVert0
  26723. ],
  26724. [
  26725. 1,
  26726. twoDimVert0
  26727. ],
  26728. [
  26729. 1,
  26730. twoDimVert0
  26731. ],
  26732. [
  26733. 1,
  26734. twoDimVert0
  26735. ],
  26736. [
  26737. 1,
  26738. twoDimVert0
  26739. ],
  26740. [
  26741. 1,
  26742. twoDimVert0
  26743. ],
  26744. [
  26745. 1,
  26746. twoDimVert0
  26747. ],
  26748. [
  26749. 1,
  26750. twoDimVert0
  26751. ],
  26752. [
  26753. 1,
  26754. twoDimVert0
  26755. ],
  26756. [
  26757. 1,
  26758. twoDimVert0
  26759. ],
  26760. [
  26761. 1,
  26762. twoDimVert0
  26763. ]
  26764. ];
  26765. var whiteTable1 = [
  26766. [
  26767. -1,
  26768. -1
  26769. ],
  26770. [
  26771. 12,
  26772. ccittEOL
  26773. ],
  26774. [
  26775. -1,
  26776. -1
  26777. ],
  26778. [
  26779. -1,
  26780. -1
  26781. ],
  26782. [
  26783. -1,
  26784. -1
  26785. ],
  26786. [
  26787. -1,
  26788. -1
  26789. ],
  26790. [
  26791. -1,
  26792. -1
  26793. ],
  26794. [
  26795. -1,
  26796. -1
  26797. ],
  26798. [
  26799. -1,
  26800. -1
  26801. ],
  26802. [
  26803. -1,
  26804. -1
  26805. ],
  26806. [
  26807. -1,
  26808. -1
  26809. ],
  26810. [
  26811. -1,
  26812. -1
  26813. ],
  26814. [
  26815. -1,
  26816. -1
  26817. ],
  26818. [
  26819. -1,
  26820. -1
  26821. ],
  26822. [
  26823. -1,
  26824. -1
  26825. ],
  26826. [
  26827. -1,
  26828. -1
  26829. ],
  26830. [
  26831. 11,
  26832. 1792
  26833. ],
  26834. [
  26835. 11,
  26836. 1792
  26837. ],
  26838. [
  26839. 12,
  26840. 1984
  26841. ],
  26842. [
  26843. 12,
  26844. 2048
  26845. ],
  26846. [
  26847. 12,
  26848. 2112
  26849. ],
  26850. [
  26851. 12,
  26852. 2176
  26853. ],
  26854. [
  26855. 12,
  26856. 2240
  26857. ],
  26858. [
  26859. 12,
  26860. 2304
  26861. ],
  26862. [
  26863. 11,
  26864. 1856
  26865. ],
  26866. [
  26867. 11,
  26868. 1856
  26869. ],
  26870. [
  26871. 11,
  26872. 1920
  26873. ],
  26874. [
  26875. 11,
  26876. 1920
  26877. ],
  26878. [
  26879. 12,
  26880. 2368
  26881. ],
  26882. [
  26883. 12,
  26884. 2432
  26885. ],
  26886. [
  26887. 12,
  26888. 2496
  26889. ],
  26890. [
  26891. 12,
  26892. 2560
  26893. ]
  26894. ];
  26895. var whiteTable2 = [
  26896. [
  26897. -1,
  26898. -1
  26899. ],
  26900. [
  26901. -1,
  26902. -1
  26903. ],
  26904. [
  26905. -1,
  26906. -1
  26907. ],
  26908. [
  26909. -1,
  26910. -1
  26911. ],
  26912. [
  26913. 8,
  26914. 29
  26915. ],
  26916. [
  26917. 8,
  26918. 29
  26919. ],
  26920. [
  26921. 8,
  26922. 30
  26923. ],
  26924. [
  26925. 8,
  26926. 30
  26927. ],
  26928. [
  26929. 8,
  26930. 45
  26931. ],
  26932. [
  26933. 8,
  26934. 45
  26935. ],
  26936. [
  26937. 8,
  26938. 46
  26939. ],
  26940. [
  26941. 8,
  26942. 46
  26943. ],
  26944. [
  26945. 7,
  26946. 22
  26947. ],
  26948. [
  26949. 7,
  26950. 22
  26951. ],
  26952. [
  26953. 7,
  26954. 22
  26955. ],
  26956. [
  26957. 7,
  26958. 22
  26959. ],
  26960. [
  26961. 7,
  26962. 23
  26963. ],
  26964. [
  26965. 7,
  26966. 23
  26967. ],
  26968. [
  26969. 7,
  26970. 23
  26971. ],
  26972. [
  26973. 7,
  26974. 23
  26975. ],
  26976. [
  26977. 8,
  26978. 47
  26979. ],
  26980. [
  26981. 8,
  26982. 47
  26983. ],
  26984. [
  26985. 8,
  26986. 48
  26987. ],
  26988. [
  26989. 8,
  26990. 48
  26991. ],
  26992. [
  26993. 6,
  26994. 13
  26995. ],
  26996. [
  26997. 6,
  26998. 13
  26999. ],
  27000. [
  27001. 6,
  27002. 13
  27003. ],
  27004. [
  27005. 6,
  27006. 13
  27007. ],
  27008. [
  27009. 6,
  27010. 13
  27011. ],
  27012. [
  27013. 6,
  27014. 13
  27015. ],
  27016. [
  27017. 6,
  27018. 13
  27019. ],
  27020. [
  27021. 6,
  27022. 13
  27023. ],
  27024. [
  27025. 7,
  27026. 20
  27027. ],
  27028. [
  27029. 7,
  27030. 20
  27031. ],
  27032. [
  27033. 7,
  27034. 20
  27035. ],
  27036. [
  27037. 7,
  27038. 20
  27039. ],
  27040. [
  27041. 8,
  27042. 33
  27043. ],
  27044. [
  27045. 8,
  27046. 33
  27047. ],
  27048. [
  27049. 8,
  27050. 34
  27051. ],
  27052. [
  27053. 8,
  27054. 34
  27055. ],
  27056. [
  27057. 8,
  27058. 35
  27059. ],
  27060. [
  27061. 8,
  27062. 35
  27063. ],
  27064. [
  27065. 8,
  27066. 36
  27067. ],
  27068. [
  27069. 8,
  27070. 36
  27071. ],
  27072. [
  27073. 8,
  27074. 37
  27075. ],
  27076. [
  27077. 8,
  27078. 37
  27079. ],
  27080. [
  27081. 8,
  27082. 38
  27083. ],
  27084. [
  27085. 8,
  27086. 38
  27087. ],
  27088. [
  27089. 7,
  27090. 19
  27091. ],
  27092. [
  27093. 7,
  27094. 19
  27095. ],
  27096. [
  27097. 7,
  27098. 19
  27099. ],
  27100. [
  27101. 7,
  27102. 19
  27103. ],
  27104. [
  27105. 8,
  27106. 31
  27107. ],
  27108. [
  27109. 8,
  27110. 31
  27111. ],
  27112. [
  27113. 8,
  27114. 32
  27115. ],
  27116. [
  27117. 8,
  27118. 32
  27119. ],
  27120. [
  27121. 6,
  27122. 1
  27123. ],
  27124. [
  27125. 6,
  27126. 1
  27127. ],
  27128. [
  27129. 6,
  27130. 1
  27131. ],
  27132. [
  27133. 6,
  27134. 1
  27135. ],
  27136. [
  27137. 6,
  27138. 1
  27139. ],
  27140. [
  27141. 6,
  27142. 1
  27143. ],
  27144. [
  27145. 6,
  27146. 1
  27147. ],
  27148. [
  27149. 6,
  27150. 1
  27151. ],
  27152. [
  27153. 6,
  27154. 12
  27155. ],
  27156. [
  27157. 6,
  27158. 12
  27159. ],
  27160. [
  27161. 6,
  27162. 12
  27163. ],
  27164. [
  27165. 6,
  27166. 12
  27167. ],
  27168. [
  27169. 6,
  27170. 12
  27171. ],
  27172. [
  27173. 6,
  27174. 12
  27175. ],
  27176. [
  27177. 6,
  27178. 12
  27179. ],
  27180. [
  27181. 6,
  27182. 12
  27183. ],
  27184. [
  27185. 8,
  27186. 53
  27187. ],
  27188. [
  27189. 8,
  27190. 53
  27191. ],
  27192. [
  27193. 8,
  27194. 54
  27195. ],
  27196. [
  27197. 8,
  27198. 54
  27199. ],
  27200. [
  27201. 7,
  27202. 26
  27203. ],
  27204. [
  27205. 7,
  27206. 26
  27207. ],
  27208. [
  27209. 7,
  27210. 26
  27211. ],
  27212. [
  27213. 7,
  27214. 26
  27215. ],
  27216. [
  27217. 8,
  27218. 39
  27219. ],
  27220. [
  27221. 8,
  27222. 39
  27223. ],
  27224. [
  27225. 8,
  27226. 40
  27227. ],
  27228. [
  27229. 8,
  27230. 40
  27231. ],
  27232. [
  27233. 8,
  27234. 41
  27235. ],
  27236. [
  27237. 8,
  27238. 41
  27239. ],
  27240. [
  27241. 8,
  27242. 42
  27243. ],
  27244. [
  27245. 8,
  27246. 42
  27247. ],
  27248. [
  27249. 8,
  27250. 43
  27251. ],
  27252. [
  27253. 8,
  27254. 43
  27255. ],
  27256. [
  27257. 8,
  27258. 44
  27259. ],
  27260. [
  27261. 8,
  27262. 44
  27263. ],
  27264. [
  27265. 7,
  27266. 21
  27267. ],
  27268. [
  27269. 7,
  27270. 21
  27271. ],
  27272. [
  27273. 7,
  27274. 21
  27275. ],
  27276. [
  27277. 7,
  27278. 21
  27279. ],
  27280. [
  27281. 7,
  27282. 28
  27283. ],
  27284. [
  27285. 7,
  27286. 28
  27287. ],
  27288. [
  27289. 7,
  27290. 28
  27291. ],
  27292. [
  27293. 7,
  27294. 28
  27295. ],
  27296. [
  27297. 8,
  27298. 61
  27299. ],
  27300. [
  27301. 8,
  27302. 61
  27303. ],
  27304. [
  27305. 8,
  27306. 62
  27307. ],
  27308. [
  27309. 8,
  27310. 62
  27311. ],
  27312. [
  27313. 8,
  27314. 63
  27315. ],
  27316. [
  27317. 8,
  27318. 63
  27319. ],
  27320. [
  27321. 8,
  27322. 0
  27323. ],
  27324. [
  27325. 8,
  27326. 0
  27327. ],
  27328. [
  27329. 8,
  27330. 320
  27331. ],
  27332. [
  27333. 8,
  27334. 320
  27335. ],
  27336. [
  27337. 8,
  27338. 384
  27339. ],
  27340. [
  27341. 8,
  27342. 384
  27343. ],
  27344. [
  27345. 5,
  27346. 10
  27347. ],
  27348. [
  27349. 5,
  27350. 10
  27351. ],
  27352. [
  27353. 5,
  27354. 10
  27355. ],
  27356. [
  27357. 5,
  27358. 10
  27359. ],
  27360. [
  27361. 5,
  27362. 10
  27363. ],
  27364. [
  27365. 5,
  27366. 10
  27367. ],
  27368. [
  27369. 5,
  27370. 10
  27371. ],
  27372. [
  27373. 5,
  27374. 10
  27375. ],
  27376. [
  27377. 5,
  27378. 10
  27379. ],
  27380. [
  27381. 5,
  27382. 10
  27383. ],
  27384. [
  27385. 5,
  27386. 10
  27387. ],
  27388. [
  27389. 5,
  27390. 10
  27391. ],
  27392. [
  27393. 5,
  27394. 10
  27395. ],
  27396. [
  27397. 5,
  27398. 10
  27399. ],
  27400. [
  27401. 5,
  27402. 10
  27403. ],
  27404. [
  27405. 5,
  27406. 10
  27407. ],
  27408. [
  27409. 5,
  27410. 11
  27411. ],
  27412. [
  27413. 5,
  27414. 11
  27415. ],
  27416. [
  27417. 5,
  27418. 11
  27419. ],
  27420. [
  27421. 5,
  27422. 11
  27423. ],
  27424. [
  27425. 5,
  27426. 11
  27427. ],
  27428. [
  27429. 5,
  27430. 11
  27431. ],
  27432. [
  27433. 5,
  27434. 11
  27435. ],
  27436. [
  27437. 5,
  27438. 11
  27439. ],
  27440. [
  27441. 5,
  27442. 11
  27443. ],
  27444. [
  27445. 5,
  27446. 11
  27447. ],
  27448. [
  27449. 5,
  27450. 11
  27451. ],
  27452. [
  27453. 5,
  27454. 11
  27455. ],
  27456. [
  27457. 5,
  27458. 11
  27459. ],
  27460. [
  27461. 5,
  27462. 11
  27463. ],
  27464. [
  27465. 5,
  27466. 11
  27467. ],
  27468. [
  27469. 5,
  27470. 11
  27471. ],
  27472. [
  27473. 7,
  27474. 27
  27475. ],
  27476. [
  27477. 7,
  27478. 27
  27479. ],
  27480. [
  27481. 7,
  27482. 27
  27483. ],
  27484. [
  27485. 7,
  27486. 27
  27487. ],
  27488. [
  27489. 8,
  27490. 59
  27491. ],
  27492. [
  27493. 8,
  27494. 59
  27495. ],
  27496. [
  27497. 8,
  27498. 60
  27499. ],
  27500. [
  27501. 8,
  27502. 60
  27503. ],
  27504. [
  27505. 9,
  27506. 1472
  27507. ],
  27508. [
  27509. 9,
  27510. 1536
  27511. ],
  27512. [
  27513. 9,
  27514. 1600
  27515. ],
  27516. [
  27517. 9,
  27518. 1728
  27519. ],
  27520. [
  27521. 7,
  27522. 18
  27523. ],
  27524. [
  27525. 7,
  27526. 18
  27527. ],
  27528. [
  27529. 7,
  27530. 18
  27531. ],
  27532. [
  27533. 7,
  27534. 18
  27535. ],
  27536. [
  27537. 7,
  27538. 24
  27539. ],
  27540. [
  27541. 7,
  27542. 24
  27543. ],
  27544. [
  27545. 7,
  27546. 24
  27547. ],
  27548. [
  27549. 7,
  27550. 24
  27551. ],
  27552. [
  27553. 8,
  27554. 49
  27555. ],
  27556. [
  27557. 8,
  27558. 49
  27559. ],
  27560. [
  27561. 8,
  27562. 50
  27563. ],
  27564. [
  27565. 8,
  27566. 50
  27567. ],
  27568. [
  27569. 8,
  27570. 51
  27571. ],
  27572. [
  27573. 8,
  27574. 51
  27575. ],
  27576. [
  27577. 8,
  27578. 52
  27579. ],
  27580. [
  27581. 8,
  27582. 52
  27583. ],
  27584. [
  27585. 7,
  27586. 25
  27587. ],
  27588. [
  27589. 7,
  27590. 25
  27591. ],
  27592. [
  27593. 7,
  27594. 25
  27595. ],
  27596. [
  27597. 7,
  27598. 25
  27599. ],
  27600. [
  27601. 8,
  27602. 55
  27603. ],
  27604. [
  27605. 8,
  27606. 55
  27607. ],
  27608. [
  27609. 8,
  27610. 56
  27611. ],
  27612. [
  27613. 8,
  27614. 56
  27615. ],
  27616. [
  27617. 8,
  27618. 57
  27619. ],
  27620. [
  27621. 8,
  27622. 57
  27623. ],
  27624. [
  27625. 8,
  27626. 58
  27627. ],
  27628. [
  27629. 8,
  27630. 58
  27631. ],
  27632. [
  27633. 6,
  27634. 192
  27635. ],
  27636. [
  27637. 6,
  27638. 192
  27639. ],
  27640. [
  27641. 6,
  27642. 192
  27643. ],
  27644. [
  27645. 6,
  27646. 192
  27647. ],
  27648. [
  27649. 6,
  27650. 192
  27651. ],
  27652. [
  27653. 6,
  27654. 192
  27655. ],
  27656. [
  27657. 6,
  27658. 192
  27659. ],
  27660. [
  27661. 6,
  27662. 192
  27663. ],
  27664. [
  27665. 6,
  27666. 1664
  27667. ],
  27668. [
  27669. 6,
  27670. 1664
  27671. ],
  27672. [
  27673. 6,
  27674. 1664
  27675. ],
  27676. [
  27677. 6,
  27678. 1664
  27679. ],
  27680. [
  27681. 6,
  27682. 1664
  27683. ],
  27684. [
  27685. 6,
  27686. 1664
  27687. ],
  27688. [
  27689. 6,
  27690. 1664
  27691. ],
  27692. [
  27693. 6,
  27694. 1664
  27695. ],
  27696. [
  27697. 8,
  27698. 448
  27699. ],
  27700. [
  27701. 8,
  27702. 448
  27703. ],
  27704. [
  27705. 8,
  27706. 512
  27707. ],
  27708. [
  27709. 8,
  27710. 512
  27711. ],
  27712. [
  27713. 9,
  27714. 704
  27715. ],
  27716. [
  27717. 9,
  27718. 768
  27719. ],
  27720. [
  27721. 8,
  27722. 640
  27723. ],
  27724. [
  27725. 8,
  27726. 640
  27727. ],
  27728. [
  27729. 8,
  27730. 576
  27731. ],
  27732. [
  27733. 8,
  27734. 576
  27735. ],
  27736. [
  27737. 9,
  27738. 832
  27739. ],
  27740. [
  27741. 9,
  27742. 896
  27743. ],
  27744. [
  27745. 9,
  27746. 960
  27747. ],
  27748. [
  27749. 9,
  27750. 1024
  27751. ],
  27752. [
  27753. 9,
  27754. 1088
  27755. ],
  27756. [
  27757. 9,
  27758. 1152
  27759. ],
  27760. [
  27761. 9,
  27762. 1216
  27763. ],
  27764. [
  27765. 9,
  27766. 1280
  27767. ],
  27768. [
  27769. 9,
  27770. 1344
  27771. ],
  27772. [
  27773. 9,
  27774. 1408
  27775. ],
  27776. [
  27777. 7,
  27778. 256
  27779. ],
  27780. [
  27781. 7,
  27782. 256
  27783. ],
  27784. [
  27785. 7,
  27786. 256
  27787. ],
  27788. [
  27789. 7,
  27790. 256
  27791. ],
  27792. [
  27793. 4,
  27794. 2
  27795. ],
  27796. [
  27797. 4,
  27798. 2
  27799. ],
  27800. [
  27801. 4,
  27802. 2
  27803. ],
  27804. [
  27805. 4,
  27806. 2
  27807. ],
  27808. [
  27809. 4,
  27810. 2
  27811. ],
  27812. [
  27813. 4,
  27814. 2
  27815. ],
  27816. [
  27817. 4,
  27818. 2
  27819. ],
  27820. [
  27821. 4,
  27822. 2
  27823. ],
  27824. [
  27825. 4,
  27826. 2
  27827. ],
  27828. [
  27829. 4,
  27830. 2
  27831. ],
  27832. [
  27833. 4,
  27834. 2
  27835. ],
  27836. [
  27837. 4,
  27838. 2
  27839. ],
  27840. [
  27841. 4,
  27842. 2
  27843. ],
  27844. [
  27845. 4,
  27846. 2
  27847. ],
  27848. [
  27849. 4,
  27850. 2
  27851. ],
  27852. [
  27853. 4,
  27854. 2
  27855. ],
  27856. [
  27857. 4,
  27858. 2
  27859. ],
  27860. [
  27861. 4,
  27862. 2
  27863. ],
  27864. [
  27865. 4,
  27866. 2
  27867. ],
  27868. [
  27869. 4,
  27870. 2
  27871. ],
  27872. [
  27873. 4,
  27874. 2
  27875. ],
  27876. [
  27877. 4,
  27878. 2
  27879. ],
  27880. [
  27881. 4,
  27882. 2
  27883. ],
  27884. [
  27885. 4,
  27886. 2
  27887. ],
  27888. [
  27889. 4,
  27890. 2
  27891. ],
  27892. [
  27893. 4,
  27894. 2
  27895. ],
  27896. [
  27897. 4,
  27898. 2
  27899. ],
  27900. [
  27901. 4,
  27902. 2
  27903. ],
  27904. [
  27905. 4,
  27906. 2
  27907. ],
  27908. [
  27909. 4,
  27910. 2
  27911. ],
  27912. [
  27913. 4,
  27914. 2
  27915. ],
  27916. [
  27917. 4,
  27918. 2
  27919. ],
  27920. [
  27921. 4,
  27922. 3
  27923. ],
  27924. [
  27925. 4,
  27926. 3
  27927. ],
  27928. [
  27929. 4,
  27930. 3
  27931. ],
  27932. [
  27933. 4,
  27934. 3
  27935. ],
  27936. [
  27937. 4,
  27938. 3
  27939. ],
  27940. [
  27941. 4,
  27942. 3
  27943. ],
  27944. [
  27945. 4,
  27946. 3
  27947. ],
  27948. [
  27949. 4,
  27950. 3
  27951. ],
  27952. [
  27953. 4,
  27954. 3
  27955. ],
  27956. [
  27957. 4,
  27958. 3
  27959. ],
  27960. [
  27961. 4,
  27962. 3
  27963. ],
  27964. [
  27965. 4,
  27966. 3
  27967. ],
  27968. [
  27969. 4,
  27970. 3
  27971. ],
  27972. [
  27973. 4,
  27974. 3
  27975. ],
  27976. [
  27977. 4,
  27978. 3
  27979. ],
  27980. [
  27981. 4,
  27982. 3
  27983. ],
  27984. [
  27985. 4,
  27986. 3
  27987. ],
  27988. [
  27989. 4,
  27990. 3
  27991. ],
  27992. [
  27993. 4,
  27994. 3
  27995. ],
  27996. [
  27997. 4,
  27998. 3
  27999. ],
  28000. [
  28001. 4,
  28002. 3
  28003. ],
  28004. [
  28005. 4,
  28006. 3
  28007. ],
  28008. [
  28009. 4,
  28010. 3
  28011. ],
  28012. [
  28013. 4,
  28014. 3
  28015. ],
  28016. [
  28017. 4,
  28018. 3
  28019. ],
  28020. [
  28021. 4,
  28022. 3
  28023. ],
  28024. [
  28025. 4,
  28026. 3
  28027. ],
  28028. [
  28029. 4,
  28030. 3
  28031. ],
  28032. [
  28033. 4,
  28034. 3
  28035. ],
  28036. [
  28037. 4,
  28038. 3
  28039. ],
  28040. [
  28041. 4,
  28042. 3
  28043. ],
  28044. [
  28045. 4,
  28046. 3
  28047. ],
  28048. [
  28049. 5,
  28050. 128
  28051. ],
  28052. [
  28053. 5,
  28054. 128
  28055. ],
  28056. [
  28057. 5,
  28058. 128
  28059. ],
  28060. [
  28061. 5,
  28062. 128
  28063. ],
  28064. [
  28065. 5,
  28066. 128
  28067. ],
  28068. [
  28069. 5,
  28070. 128
  28071. ],
  28072. [
  28073. 5,
  28074. 128
  28075. ],
  28076. [
  28077. 5,
  28078. 128
  28079. ],
  28080. [
  28081. 5,
  28082. 128
  28083. ],
  28084. [
  28085. 5,
  28086. 128
  28087. ],
  28088. [
  28089. 5,
  28090. 128
  28091. ],
  28092. [
  28093. 5,
  28094. 128
  28095. ],
  28096. [
  28097. 5,
  28098. 128
  28099. ],
  28100. [
  28101. 5,
  28102. 128
  28103. ],
  28104. [
  28105. 5,
  28106. 128
  28107. ],
  28108. [
  28109. 5,
  28110. 128
  28111. ],
  28112. [
  28113. 5,
  28114. 8
  28115. ],
  28116. [
  28117. 5,
  28118. 8
  28119. ],
  28120. [
  28121. 5,
  28122. 8
  28123. ],
  28124. [
  28125. 5,
  28126. 8
  28127. ],
  28128. [
  28129. 5,
  28130. 8
  28131. ],
  28132. [
  28133. 5,
  28134. 8
  28135. ],
  28136. [
  28137. 5,
  28138. 8
  28139. ],
  28140. [
  28141. 5,
  28142. 8
  28143. ],
  28144. [
  28145. 5,
  28146. 8
  28147. ],
  28148. [
  28149. 5,
  28150. 8
  28151. ],
  28152. [
  28153. 5,
  28154. 8
  28155. ],
  28156. [
  28157. 5,
  28158. 8
  28159. ],
  28160. [
  28161. 5,
  28162. 8
  28163. ],
  28164. [
  28165. 5,
  28166. 8
  28167. ],
  28168. [
  28169. 5,
  28170. 8
  28171. ],
  28172. [
  28173. 5,
  28174. 8
  28175. ],
  28176. [
  28177. 5,
  28178. 9
  28179. ],
  28180. [
  28181. 5,
  28182. 9
  28183. ],
  28184. [
  28185. 5,
  28186. 9
  28187. ],
  28188. [
  28189. 5,
  28190. 9
  28191. ],
  28192. [
  28193. 5,
  28194. 9
  28195. ],
  28196. [
  28197. 5,
  28198. 9
  28199. ],
  28200. [
  28201. 5,
  28202. 9
  28203. ],
  28204. [
  28205. 5,
  28206. 9
  28207. ],
  28208. [
  28209. 5,
  28210. 9
  28211. ],
  28212. [
  28213. 5,
  28214. 9
  28215. ],
  28216. [
  28217. 5,
  28218. 9
  28219. ],
  28220. [
  28221. 5,
  28222. 9
  28223. ],
  28224. [
  28225. 5,
  28226. 9
  28227. ],
  28228. [
  28229. 5,
  28230. 9
  28231. ],
  28232. [
  28233. 5,
  28234. 9
  28235. ],
  28236. [
  28237. 5,
  28238. 9
  28239. ],
  28240. [
  28241. 6,
  28242. 16
  28243. ],
  28244. [
  28245. 6,
  28246. 16
  28247. ],
  28248. [
  28249. 6,
  28250. 16
  28251. ],
  28252. [
  28253. 6,
  28254. 16
  28255. ],
  28256. [
  28257. 6,
  28258. 16
  28259. ],
  28260. [
  28261. 6,
  28262. 16
  28263. ],
  28264. [
  28265. 6,
  28266. 16
  28267. ],
  28268. [
  28269. 6,
  28270. 16
  28271. ],
  28272. [
  28273. 6,
  28274. 17
  28275. ],
  28276. [
  28277. 6,
  28278. 17
  28279. ],
  28280. [
  28281. 6,
  28282. 17
  28283. ],
  28284. [
  28285. 6,
  28286. 17
  28287. ],
  28288. [
  28289. 6,
  28290. 17
  28291. ],
  28292. [
  28293. 6,
  28294. 17
  28295. ],
  28296. [
  28297. 6,
  28298. 17
  28299. ],
  28300. [
  28301. 6,
  28302. 17
  28303. ],
  28304. [
  28305. 4,
  28306. 4
  28307. ],
  28308. [
  28309. 4,
  28310. 4
  28311. ],
  28312. [
  28313. 4,
  28314. 4
  28315. ],
  28316. [
  28317. 4,
  28318. 4
  28319. ],
  28320. [
  28321. 4,
  28322. 4
  28323. ],
  28324. [
  28325. 4,
  28326. 4
  28327. ],
  28328. [
  28329. 4,
  28330. 4
  28331. ],
  28332. [
  28333. 4,
  28334. 4
  28335. ],
  28336. [
  28337. 4,
  28338. 4
  28339. ],
  28340. [
  28341. 4,
  28342. 4
  28343. ],
  28344. [
  28345. 4,
  28346. 4
  28347. ],
  28348. [
  28349. 4,
  28350. 4
  28351. ],
  28352. [
  28353. 4,
  28354. 4
  28355. ],
  28356. [
  28357. 4,
  28358. 4
  28359. ],
  28360. [
  28361. 4,
  28362. 4
  28363. ],
  28364. [
  28365. 4,
  28366. 4
  28367. ],
  28368. [
  28369. 4,
  28370. 4
  28371. ],
  28372. [
  28373. 4,
  28374. 4
  28375. ],
  28376. [
  28377. 4,
  28378. 4
  28379. ],
  28380. [
  28381. 4,
  28382. 4
  28383. ],
  28384. [
  28385. 4,
  28386. 4
  28387. ],
  28388. [
  28389. 4,
  28390. 4
  28391. ],
  28392. [
  28393. 4,
  28394. 4
  28395. ],
  28396. [
  28397. 4,
  28398. 4
  28399. ],
  28400. [
  28401. 4,
  28402. 4
  28403. ],
  28404. [
  28405. 4,
  28406. 4
  28407. ],
  28408. [
  28409. 4,
  28410. 4
  28411. ],
  28412. [
  28413. 4,
  28414. 4
  28415. ],
  28416. [
  28417. 4,
  28418. 4
  28419. ],
  28420. [
  28421. 4,
  28422. 4
  28423. ],
  28424. [
  28425. 4,
  28426. 4
  28427. ],
  28428. [
  28429. 4,
  28430. 4
  28431. ],
  28432. [
  28433. 4,
  28434. 5
  28435. ],
  28436. [
  28437. 4,
  28438. 5
  28439. ],
  28440. [
  28441. 4,
  28442. 5
  28443. ],
  28444. [
  28445. 4,
  28446. 5
  28447. ],
  28448. [
  28449. 4,
  28450. 5
  28451. ],
  28452. [
  28453. 4,
  28454. 5
  28455. ],
  28456. [
  28457. 4,
  28458. 5
  28459. ],
  28460. [
  28461. 4,
  28462. 5
  28463. ],
  28464. [
  28465. 4,
  28466. 5
  28467. ],
  28468. [
  28469. 4,
  28470. 5
  28471. ],
  28472. [
  28473. 4,
  28474. 5
  28475. ],
  28476. [
  28477. 4,
  28478. 5
  28479. ],
  28480. [
  28481. 4,
  28482. 5
  28483. ],
  28484. [
  28485. 4,
  28486. 5
  28487. ],
  28488. [
  28489. 4,
  28490. 5
  28491. ],
  28492. [
  28493. 4,
  28494. 5
  28495. ],
  28496. [
  28497. 4,
  28498. 5
  28499. ],
  28500. [
  28501. 4,
  28502. 5
  28503. ],
  28504. [
  28505. 4,
  28506. 5
  28507. ],
  28508. [
  28509. 4,
  28510. 5
  28511. ],
  28512. [
  28513. 4,
  28514. 5
  28515. ],
  28516. [
  28517. 4,
  28518. 5
  28519. ],
  28520. [
  28521. 4,
  28522. 5
  28523. ],
  28524. [
  28525. 4,
  28526. 5
  28527. ],
  28528. [
  28529. 4,
  28530. 5
  28531. ],
  28532. [
  28533. 4,
  28534. 5
  28535. ],
  28536. [
  28537. 4,
  28538. 5
  28539. ],
  28540. [
  28541. 4,
  28542. 5
  28543. ],
  28544. [
  28545. 4,
  28546. 5
  28547. ],
  28548. [
  28549. 4,
  28550. 5
  28551. ],
  28552. [
  28553. 4,
  28554. 5
  28555. ],
  28556. [
  28557. 4,
  28558. 5
  28559. ],
  28560. [
  28561. 6,
  28562. 14
  28563. ],
  28564. [
  28565. 6,
  28566. 14
  28567. ],
  28568. [
  28569. 6,
  28570. 14
  28571. ],
  28572. [
  28573. 6,
  28574. 14
  28575. ],
  28576. [
  28577. 6,
  28578. 14
  28579. ],
  28580. [
  28581. 6,
  28582. 14
  28583. ],
  28584. [
  28585. 6,
  28586. 14
  28587. ],
  28588. [
  28589. 6,
  28590. 14
  28591. ],
  28592. [
  28593. 6,
  28594. 15
  28595. ],
  28596. [
  28597. 6,
  28598. 15
  28599. ],
  28600. [
  28601. 6,
  28602. 15
  28603. ],
  28604. [
  28605. 6,
  28606. 15
  28607. ],
  28608. [
  28609. 6,
  28610. 15
  28611. ],
  28612. [
  28613. 6,
  28614. 15
  28615. ],
  28616. [
  28617. 6,
  28618. 15
  28619. ],
  28620. [
  28621. 6,
  28622. 15
  28623. ],
  28624. [
  28625. 5,
  28626. 64
  28627. ],
  28628. [
  28629. 5,
  28630. 64
  28631. ],
  28632. [
  28633. 5,
  28634. 64
  28635. ],
  28636. [
  28637. 5,
  28638. 64
  28639. ],
  28640. [
  28641. 5,
  28642. 64
  28643. ],
  28644. [
  28645. 5,
  28646. 64
  28647. ],
  28648. [
  28649. 5,
  28650. 64
  28651. ],
  28652. [
  28653. 5,
  28654. 64
  28655. ],
  28656. [
  28657. 5,
  28658. 64
  28659. ],
  28660. [
  28661. 5,
  28662. 64
  28663. ],
  28664. [
  28665. 5,
  28666. 64
  28667. ],
  28668. [
  28669. 5,
  28670. 64
  28671. ],
  28672. [
  28673. 5,
  28674. 64
  28675. ],
  28676. [
  28677. 5,
  28678. 64
  28679. ],
  28680. [
  28681. 5,
  28682. 64
  28683. ],
  28684. [
  28685. 5,
  28686. 64
  28687. ],
  28688. [
  28689. 4,
  28690. 6
  28691. ],
  28692. [
  28693. 4,
  28694. 6
  28695. ],
  28696. [
  28697. 4,
  28698. 6
  28699. ],
  28700. [
  28701. 4,
  28702. 6
  28703. ],
  28704. [
  28705. 4,
  28706. 6
  28707. ],
  28708. [
  28709. 4,
  28710. 6
  28711. ],
  28712. [
  28713. 4,
  28714. 6
  28715. ],
  28716. [
  28717. 4,
  28718. 6
  28719. ],
  28720. [
  28721. 4,
  28722. 6
  28723. ],
  28724. [
  28725. 4,
  28726. 6
  28727. ],
  28728. [
  28729. 4,
  28730. 6
  28731. ],
  28732. [
  28733. 4,
  28734. 6
  28735. ],
  28736. [
  28737. 4,
  28738. 6
  28739. ],
  28740. [
  28741. 4,
  28742. 6
  28743. ],
  28744. [
  28745. 4,
  28746. 6
  28747. ],
  28748. [
  28749. 4,
  28750. 6
  28751. ],
  28752. [
  28753. 4,
  28754. 6
  28755. ],
  28756. [
  28757. 4,
  28758. 6
  28759. ],
  28760. [
  28761. 4,
  28762. 6
  28763. ],
  28764. [
  28765. 4,
  28766. 6
  28767. ],
  28768. [
  28769. 4,
  28770. 6
  28771. ],
  28772. [
  28773. 4,
  28774. 6
  28775. ],
  28776. [
  28777. 4,
  28778. 6
  28779. ],
  28780. [
  28781. 4,
  28782. 6
  28783. ],
  28784. [
  28785. 4,
  28786. 6
  28787. ],
  28788. [
  28789. 4,
  28790. 6
  28791. ],
  28792. [
  28793. 4,
  28794. 6
  28795. ],
  28796. [
  28797. 4,
  28798. 6
  28799. ],
  28800. [
  28801. 4,
  28802. 6
  28803. ],
  28804. [
  28805. 4,
  28806. 6
  28807. ],
  28808. [
  28809. 4,
  28810. 6
  28811. ],
  28812. [
  28813. 4,
  28814. 6
  28815. ],
  28816. [
  28817. 4,
  28818. 7
  28819. ],
  28820. [
  28821. 4,
  28822. 7
  28823. ],
  28824. [
  28825. 4,
  28826. 7
  28827. ],
  28828. [
  28829. 4,
  28830. 7
  28831. ],
  28832. [
  28833. 4,
  28834. 7
  28835. ],
  28836. [
  28837. 4,
  28838. 7
  28839. ],
  28840. [
  28841. 4,
  28842. 7
  28843. ],
  28844. [
  28845. 4,
  28846. 7
  28847. ],
  28848. [
  28849. 4,
  28850. 7
  28851. ],
  28852. [
  28853. 4,
  28854. 7
  28855. ],
  28856. [
  28857. 4,
  28858. 7
  28859. ],
  28860. [
  28861. 4,
  28862. 7
  28863. ],
  28864. [
  28865. 4,
  28866. 7
  28867. ],
  28868. [
  28869. 4,
  28870. 7
  28871. ],
  28872. [
  28873. 4,
  28874. 7
  28875. ],
  28876. [
  28877. 4,
  28878. 7
  28879. ],
  28880. [
  28881. 4,
  28882. 7
  28883. ],
  28884. [
  28885. 4,
  28886. 7
  28887. ],
  28888. [
  28889. 4,
  28890. 7
  28891. ],
  28892. [
  28893. 4,
  28894. 7
  28895. ],
  28896. [
  28897. 4,
  28898. 7
  28899. ],
  28900. [
  28901. 4,
  28902. 7
  28903. ],
  28904. [
  28905. 4,
  28906. 7
  28907. ],
  28908. [
  28909. 4,
  28910. 7
  28911. ],
  28912. [
  28913. 4,
  28914. 7
  28915. ],
  28916. [
  28917. 4,
  28918. 7
  28919. ],
  28920. [
  28921. 4,
  28922. 7
  28923. ],
  28924. [
  28925. 4,
  28926. 7
  28927. ],
  28928. [
  28929. 4,
  28930. 7
  28931. ],
  28932. [
  28933. 4,
  28934. 7
  28935. ],
  28936. [
  28937. 4,
  28938. 7
  28939. ],
  28940. [
  28941. 4,
  28942. 7
  28943. ]
  28944. ];
  28945. var blackTable1 = [
  28946. [
  28947. -1,
  28948. -1
  28949. ],
  28950. [
  28951. -1,
  28952. -1
  28953. ],
  28954. [
  28955. 12,
  28956. ccittEOL
  28957. ],
  28958. [
  28959. 12,
  28960. ccittEOL
  28961. ],
  28962. [
  28963. -1,
  28964. -1
  28965. ],
  28966. [
  28967. -1,
  28968. -1
  28969. ],
  28970. [
  28971. -1,
  28972. -1
  28973. ],
  28974. [
  28975. -1,
  28976. -1
  28977. ],
  28978. [
  28979. -1,
  28980. -1
  28981. ],
  28982. [
  28983. -1,
  28984. -1
  28985. ],
  28986. [
  28987. -1,
  28988. -1
  28989. ],
  28990. [
  28991. -1,
  28992. -1
  28993. ],
  28994. [
  28995. -1,
  28996. -1
  28997. ],
  28998. [
  28999. -1,
  29000. -1
  29001. ],
  29002. [
  29003. -1,
  29004. -1
  29005. ],
  29006. [
  29007. -1,
  29008. -1
  29009. ],
  29010. [
  29011. -1,
  29012. -1
  29013. ],
  29014. [
  29015. -1,
  29016. -1
  29017. ],
  29018. [
  29019. -1,
  29020. -1
  29021. ],
  29022. [
  29023. -1,
  29024. -1
  29025. ],
  29026. [
  29027. -1,
  29028. -1
  29029. ],
  29030. [
  29031. -1,
  29032. -1
  29033. ],
  29034. [
  29035. -1,
  29036. -1
  29037. ],
  29038. [
  29039. -1,
  29040. -1
  29041. ],
  29042. [
  29043. -1,
  29044. -1
  29045. ],
  29046. [
  29047. -1,
  29048. -1
  29049. ],
  29050. [
  29051. -1,
  29052. -1
  29053. ],
  29054. [
  29055. -1,
  29056. -1
  29057. ],
  29058. [
  29059. -1,
  29060. -1
  29061. ],
  29062. [
  29063. -1,
  29064. -1
  29065. ],
  29066. [
  29067. -1,
  29068. -1
  29069. ],
  29070. [
  29071. -1,
  29072. -1
  29073. ],
  29074. [
  29075. 11,
  29076. 1792
  29077. ],
  29078. [
  29079. 11,
  29080. 1792
  29081. ],
  29082. [
  29083. 11,
  29084. 1792
  29085. ],
  29086. [
  29087. 11,
  29088. 1792
  29089. ],
  29090. [
  29091. 12,
  29092. 1984
  29093. ],
  29094. [
  29095. 12,
  29096. 1984
  29097. ],
  29098. [
  29099. 12,
  29100. 2048
  29101. ],
  29102. [
  29103. 12,
  29104. 2048
  29105. ],
  29106. [
  29107. 12,
  29108. 2112
  29109. ],
  29110. [
  29111. 12,
  29112. 2112
  29113. ],
  29114. [
  29115. 12,
  29116. 2176
  29117. ],
  29118. [
  29119. 12,
  29120. 2176
  29121. ],
  29122. [
  29123. 12,
  29124. 2240
  29125. ],
  29126. [
  29127. 12,
  29128. 2240
  29129. ],
  29130. [
  29131. 12,
  29132. 2304
  29133. ],
  29134. [
  29135. 12,
  29136. 2304
  29137. ],
  29138. [
  29139. 11,
  29140. 1856
  29141. ],
  29142. [
  29143. 11,
  29144. 1856
  29145. ],
  29146. [
  29147. 11,
  29148. 1856
  29149. ],
  29150. [
  29151. 11,
  29152. 1856
  29153. ],
  29154. [
  29155. 11,
  29156. 1920
  29157. ],
  29158. [
  29159. 11,
  29160. 1920
  29161. ],
  29162. [
  29163. 11,
  29164. 1920
  29165. ],
  29166. [
  29167. 11,
  29168. 1920
  29169. ],
  29170. [
  29171. 12,
  29172. 2368
  29173. ],
  29174. [
  29175. 12,
  29176. 2368
  29177. ],
  29178. [
  29179. 12,
  29180. 2432
  29181. ],
  29182. [
  29183. 12,
  29184. 2432
  29185. ],
  29186. [
  29187. 12,
  29188. 2496
  29189. ],
  29190. [
  29191. 12,
  29192. 2496
  29193. ],
  29194. [
  29195. 12,
  29196. 2560
  29197. ],
  29198. [
  29199. 12,
  29200. 2560
  29201. ],
  29202. [
  29203. 10,
  29204. 18
  29205. ],
  29206. [
  29207. 10,
  29208. 18
  29209. ],
  29210. [
  29211. 10,
  29212. 18
  29213. ],
  29214. [
  29215. 10,
  29216. 18
  29217. ],
  29218. [
  29219. 10,
  29220. 18
  29221. ],
  29222. [
  29223. 10,
  29224. 18
  29225. ],
  29226. [
  29227. 10,
  29228. 18
  29229. ],
  29230. [
  29231. 10,
  29232. 18
  29233. ],
  29234. [
  29235. 12,
  29236. 52
  29237. ],
  29238. [
  29239. 12,
  29240. 52
  29241. ],
  29242. [
  29243. 13,
  29244. 640
  29245. ],
  29246. [
  29247. 13,
  29248. 704
  29249. ],
  29250. [
  29251. 13,
  29252. 768
  29253. ],
  29254. [
  29255. 13,
  29256. 832
  29257. ],
  29258. [
  29259. 12,
  29260. 55
  29261. ],
  29262. [
  29263. 12,
  29264. 55
  29265. ],
  29266. [
  29267. 12,
  29268. 56
  29269. ],
  29270. [
  29271. 12,
  29272. 56
  29273. ],
  29274. [
  29275. 13,
  29276. 1280
  29277. ],
  29278. [
  29279. 13,
  29280. 1344
  29281. ],
  29282. [
  29283. 13,
  29284. 1408
  29285. ],
  29286. [
  29287. 13,
  29288. 1472
  29289. ],
  29290. [
  29291. 12,
  29292. 59
  29293. ],
  29294. [
  29295. 12,
  29296. 59
  29297. ],
  29298. [
  29299. 12,
  29300. 60
  29301. ],
  29302. [
  29303. 12,
  29304. 60
  29305. ],
  29306. [
  29307. 13,
  29308. 1536
  29309. ],
  29310. [
  29311. 13,
  29312. 1600
  29313. ],
  29314. [
  29315. 11,
  29316. 24
  29317. ],
  29318. [
  29319. 11,
  29320. 24
  29321. ],
  29322. [
  29323. 11,
  29324. 24
  29325. ],
  29326. [
  29327. 11,
  29328. 24
  29329. ],
  29330. [
  29331. 11,
  29332. 25
  29333. ],
  29334. [
  29335. 11,
  29336. 25
  29337. ],
  29338. [
  29339. 11,
  29340. 25
  29341. ],
  29342. [
  29343. 11,
  29344. 25
  29345. ],
  29346. [
  29347. 13,
  29348. 1664
  29349. ],
  29350. [
  29351. 13,
  29352. 1728
  29353. ],
  29354. [
  29355. 12,
  29356. 320
  29357. ],
  29358. [
  29359. 12,
  29360. 320
  29361. ],
  29362. [
  29363. 12,
  29364. 384
  29365. ],
  29366. [
  29367. 12,
  29368. 384
  29369. ],
  29370. [
  29371. 12,
  29372. 448
  29373. ],
  29374. [
  29375. 12,
  29376. 448
  29377. ],
  29378. [
  29379. 13,
  29380. 512
  29381. ],
  29382. [
  29383. 13,
  29384. 576
  29385. ],
  29386. [
  29387. 12,
  29388. 53
  29389. ],
  29390. [
  29391. 12,
  29392. 53
  29393. ],
  29394. [
  29395. 12,
  29396. 54
  29397. ],
  29398. [
  29399. 12,
  29400. 54
  29401. ],
  29402. [
  29403. 13,
  29404. 896
  29405. ],
  29406. [
  29407. 13,
  29408. 960
  29409. ],
  29410. [
  29411. 13,
  29412. 1024
  29413. ],
  29414. [
  29415. 13,
  29416. 1088
  29417. ],
  29418. [
  29419. 13,
  29420. 1152
  29421. ],
  29422. [
  29423. 13,
  29424. 1216
  29425. ],
  29426. [
  29427. 10,
  29428. 64
  29429. ],
  29430. [
  29431. 10,
  29432. 64
  29433. ],
  29434. [
  29435. 10,
  29436. 64
  29437. ],
  29438. [
  29439. 10,
  29440. 64
  29441. ],
  29442. [
  29443. 10,
  29444. 64
  29445. ],
  29446. [
  29447. 10,
  29448. 64
  29449. ],
  29450. [
  29451. 10,
  29452. 64
  29453. ],
  29454. [
  29455. 10,
  29456. 64
  29457. ]
  29458. ];
  29459. var blackTable2 = [
  29460. [
  29461. 8,
  29462. 13
  29463. ],
  29464. [
  29465. 8,
  29466. 13
  29467. ],
  29468. [
  29469. 8,
  29470. 13
  29471. ],
  29472. [
  29473. 8,
  29474. 13
  29475. ],
  29476. [
  29477. 8,
  29478. 13
  29479. ],
  29480. [
  29481. 8,
  29482. 13
  29483. ],
  29484. [
  29485. 8,
  29486. 13
  29487. ],
  29488. [
  29489. 8,
  29490. 13
  29491. ],
  29492. [
  29493. 8,
  29494. 13
  29495. ],
  29496. [
  29497. 8,
  29498. 13
  29499. ],
  29500. [
  29501. 8,
  29502. 13
  29503. ],
  29504. [
  29505. 8,
  29506. 13
  29507. ],
  29508. [
  29509. 8,
  29510. 13
  29511. ],
  29512. [
  29513. 8,
  29514. 13
  29515. ],
  29516. [
  29517. 8,
  29518. 13
  29519. ],
  29520. [
  29521. 8,
  29522. 13
  29523. ],
  29524. [
  29525. 11,
  29526. 23
  29527. ],
  29528. [
  29529. 11,
  29530. 23
  29531. ],
  29532. [
  29533. 12,
  29534. 50
  29535. ],
  29536. [
  29537. 12,
  29538. 51
  29539. ],
  29540. [
  29541. 12,
  29542. 44
  29543. ],
  29544. [
  29545. 12,
  29546. 45
  29547. ],
  29548. [
  29549. 12,
  29550. 46
  29551. ],
  29552. [
  29553. 12,
  29554. 47
  29555. ],
  29556. [
  29557. 12,
  29558. 57
  29559. ],
  29560. [
  29561. 12,
  29562. 58
  29563. ],
  29564. [
  29565. 12,
  29566. 61
  29567. ],
  29568. [
  29569. 12,
  29570. 256
  29571. ],
  29572. [
  29573. 10,
  29574. 16
  29575. ],
  29576. [
  29577. 10,
  29578. 16
  29579. ],
  29580. [
  29581. 10,
  29582. 16
  29583. ],
  29584. [
  29585. 10,
  29586. 16
  29587. ],
  29588. [
  29589. 10,
  29590. 17
  29591. ],
  29592. [
  29593. 10,
  29594. 17
  29595. ],
  29596. [
  29597. 10,
  29598. 17
  29599. ],
  29600. [
  29601. 10,
  29602. 17
  29603. ],
  29604. [
  29605. 12,
  29606. 48
  29607. ],
  29608. [
  29609. 12,
  29610. 49
  29611. ],
  29612. [
  29613. 12,
  29614. 62
  29615. ],
  29616. [
  29617. 12,
  29618. 63
  29619. ],
  29620. [
  29621. 12,
  29622. 30
  29623. ],
  29624. [
  29625. 12,
  29626. 31
  29627. ],
  29628. [
  29629. 12,
  29630. 32
  29631. ],
  29632. [
  29633. 12,
  29634. 33
  29635. ],
  29636. [
  29637. 12,
  29638. 40
  29639. ],
  29640. [
  29641. 12,
  29642. 41
  29643. ],
  29644. [
  29645. 11,
  29646. 22
  29647. ],
  29648. [
  29649. 11,
  29650. 22
  29651. ],
  29652. [
  29653. 8,
  29654. 14
  29655. ],
  29656. [
  29657. 8,
  29658. 14
  29659. ],
  29660. [
  29661. 8,
  29662. 14
  29663. ],
  29664. [
  29665. 8,
  29666. 14
  29667. ],
  29668. [
  29669. 8,
  29670. 14
  29671. ],
  29672. [
  29673. 8,
  29674. 14
  29675. ],
  29676. [
  29677. 8,
  29678. 14
  29679. ],
  29680. [
  29681. 8,
  29682. 14
  29683. ],
  29684. [
  29685. 8,
  29686. 14
  29687. ],
  29688. [
  29689. 8,
  29690. 14
  29691. ],
  29692. [
  29693. 8,
  29694. 14
  29695. ],
  29696. [
  29697. 8,
  29698. 14
  29699. ],
  29700. [
  29701. 8,
  29702. 14
  29703. ],
  29704. [
  29705. 8,
  29706. 14
  29707. ],
  29708. [
  29709. 8,
  29710. 14
  29711. ],
  29712. [
  29713. 8,
  29714. 14
  29715. ],
  29716. [
  29717. 7,
  29718. 10
  29719. ],
  29720. [
  29721. 7,
  29722. 10
  29723. ],
  29724. [
  29725. 7,
  29726. 10
  29727. ],
  29728. [
  29729. 7,
  29730. 10
  29731. ],
  29732. [
  29733. 7,
  29734. 10
  29735. ],
  29736. [
  29737. 7,
  29738. 10
  29739. ],
  29740. [
  29741. 7,
  29742. 10
  29743. ],
  29744. [
  29745. 7,
  29746. 10
  29747. ],
  29748. [
  29749. 7,
  29750. 10
  29751. ],
  29752. [
  29753. 7,
  29754. 10
  29755. ],
  29756. [
  29757. 7,
  29758. 10
  29759. ],
  29760. [
  29761. 7,
  29762. 10
  29763. ],
  29764. [
  29765. 7,
  29766. 10
  29767. ],
  29768. [
  29769. 7,
  29770. 10
  29771. ],
  29772. [
  29773. 7,
  29774. 10
  29775. ],
  29776. [
  29777. 7,
  29778. 10
  29779. ],
  29780. [
  29781. 7,
  29782. 10
  29783. ],
  29784. [
  29785. 7,
  29786. 10
  29787. ],
  29788. [
  29789. 7,
  29790. 10
  29791. ],
  29792. [
  29793. 7,
  29794. 10
  29795. ],
  29796. [
  29797. 7,
  29798. 10
  29799. ],
  29800. [
  29801. 7,
  29802. 10
  29803. ],
  29804. [
  29805. 7,
  29806. 10
  29807. ],
  29808. [
  29809. 7,
  29810. 10
  29811. ],
  29812. [
  29813. 7,
  29814. 10
  29815. ],
  29816. [
  29817. 7,
  29818. 10
  29819. ],
  29820. [
  29821. 7,
  29822. 10
  29823. ],
  29824. [
  29825. 7,
  29826. 10
  29827. ],
  29828. [
  29829. 7,
  29830. 10
  29831. ],
  29832. [
  29833. 7,
  29834. 10
  29835. ],
  29836. [
  29837. 7,
  29838. 10
  29839. ],
  29840. [
  29841. 7,
  29842. 10
  29843. ],
  29844. [
  29845. 7,
  29846. 11
  29847. ],
  29848. [
  29849. 7,
  29850. 11
  29851. ],
  29852. [
  29853. 7,
  29854. 11
  29855. ],
  29856. [
  29857. 7,
  29858. 11
  29859. ],
  29860. [
  29861. 7,
  29862. 11
  29863. ],
  29864. [
  29865. 7,
  29866. 11
  29867. ],
  29868. [
  29869. 7,
  29870. 11
  29871. ],
  29872. [
  29873. 7,
  29874. 11
  29875. ],
  29876. [
  29877. 7,
  29878. 11
  29879. ],
  29880. [
  29881. 7,
  29882. 11
  29883. ],
  29884. [
  29885. 7,
  29886. 11
  29887. ],
  29888. [
  29889. 7,
  29890. 11
  29891. ],
  29892. [
  29893. 7,
  29894. 11
  29895. ],
  29896. [
  29897. 7,
  29898. 11
  29899. ],
  29900. [
  29901. 7,
  29902. 11
  29903. ],
  29904. [
  29905. 7,
  29906. 11
  29907. ],
  29908. [
  29909. 7,
  29910. 11
  29911. ],
  29912. [
  29913. 7,
  29914. 11
  29915. ],
  29916. [
  29917. 7,
  29918. 11
  29919. ],
  29920. [
  29921. 7,
  29922. 11
  29923. ],
  29924. [
  29925. 7,
  29926. 11
  29927. ],
  29928. [
  29929. 7,
  29930. 11
  29931. ],
  29932. [
  29933. 7,
  29934. 11
  29935. ],
  29936. [
  29937. 7,
  29938. 11
  29939. ],
  29940. [
  29941. 7,
  29942. 11
  29943. ],
  29944. [
  29945. 7,
  29946. 11
  29947. ],
  29948. [
  29949. 7,
  29950. 11
  29951. ],
  29952. [
  29953. 7,
  29954. 11
  29955. ],
  29956. [
  29957. 7,
  29958. 11
  29959. ],
  29960. [
  29961. 7,
  29962. 11
  29963. ],
  29964. [
  29965. 7,
  29966. 11
  29967. ],
  29968. [
  29969. 7,
  29970. 11
  29971. ],
  29972. [
  29973. 9,
  29974. 15
  29975. ],
  29976. [
  29977. 9,
  29978. 15
  29979. ],
  29980. [
  29981. 9,
  29982. 15
  29983. ],
  29984. [
  29985. 9,
  29986. 15
  29987. ],
  29988. [
  29989. 9,
  29990. 15
  29991. ],
  29992. [
  29993. 9,
  29994. 15
  29995. ],
  29996. [
  29997. 9,
  29998. 15
  29999. ],
  30000. [
  30001. 9,
  30002. 15
  30003. ],
  30004. [
  30005. 12,
  30006. 128
  30007. ],
  30008. [
  30009. 12,
  30010. 192
  30011. ],
  30012. [
  30013. 12,
  30014. 26
  30015. ],
  30016. [
  30017. 12,
  30018. 27
  30019. ],
  30020. [
  30021. 12,
  30022. 28
  30023. ],
  30024. [
  30025. 12,
  30026. 29
  30027. ],
  30028. [
  30029. 11,
  30030. 19
  30031. ],
  30032. [
  30033. 11,
  30034. 19
  30035. ],
  30036. [
  30037. 11,
  30038. 20
  30039. ],
  30040. [
  30041. 11,
  30042. 20
  30043. ],
  30044. [
  30045. 12,
  30046. 34
  30047. ],
  30048. [
  30049. 12,
  30050. 35
  30051. ],
  30052. [
  30053. 12,
  30054. 36
  30055. ],
  30056. [
  30057. 12,
  30058. 37
  30059. ],
  30060. [
  30061. 12,
  30062. 38
  30063. ],
  30064. [
  30065. 12,
  30066. 39
  30067. ],
  30068. [
  30069. 11,
  30070. 21
  30071. ],
  30072. [
  30073. 11,
  30074. 21
  30075. ],
  30076. [
  30077. 12,
  30078. 42
  30079. ],
  30080. [
  30081. 12,
  30082. 43
  30083. ],
  30084. [
  30085. 10,
  30086. 0
  30087. ],
  30088. [
  30089. 10,
  30090. 0
  30091. ],
  30092. [
  30093. 10,
  30094. 0
  30095. ],
  30096. [
  30097. 10,
  30098. 0
  30099. ],
  30100. [
  30101. 7,
  30102. 12
  30103. ],
  30104. [
  30105. 7,
  30106. 12
  30107. ],
  30108. [
  30109. 7,
  30110. 12
  30111. ],
  30112. [
  30113. 7,
  30114. 12
  30115. ],
  30116. [
  30117. 7,
  30118. 12
  30119. ],
  30120. [
  30121. 7,
  30122. 12
  30123. ],
  30124. [
  30125. 7,
  30126. 12
  30127. ],
  30128. [
  30129. 7,
  30130. 12
  30131. ],
  30132. [
  30133. 7,
  30134. 12
  30135. ],
  30136. [
  30137. 7,
  30138. 12
  30139. ],
  30140. [
  30141. 7,
  30142. 12
  30143. ],
  30144. [
  30145. 7,
  30146. 12
  30147. ],
  30148. [
  30149. 7,
  30150. 12
  30151. ],
  30152. [
  30153. 7,
  30154. 12
  30155. ],
  30156. [
  30157. 7,
  30158. 12
  30159. ],
  30160. [
  30161. 7,
  30162. 12
  30163. ],
  30164. [
  30165. 7,
  30166. 12
  30167. ],
  30168. [
  30169. 7,
  30170. 12
  30171. ],
  30172. [
  30173. 7,
  30174. 12
  30175. ],
  30176. [
  30177. 7,
  30178. 12
  30179. ],
  30180. [
  30181. 7,
  30182. 12
  30183. ],
  30184. [
  30185. 7,
  30186. 12
  30187. ],
  30188. [
  30189. 7,
  30190. 12
  30191. ],
  30192. [
  30193. 7,
  30194. 12
  30195. ],
  30196. [
  30197. 7,
  30198. 12
  30199. ],
  30200. [
  30201. 7,
  30202. 12
  30203. ],
  30204. [
  30205. 7,
  30206. 12
  30207. ],
  30208. [
  30209. 7,
  30210. 12
  30211. ],
  30212. [
  30213. 7,
  30214. 12
  30215. ],
  30216. [
  30217. 7,
  30218. 12
  30219. ],
  30220. [
  30221. 7,
  30222. 12
  30223. ],
  30224. [
  30225. 7,
  30226. 12
  30227. ]
  30228. ];
  30229. var blackTable3 = [
  30230. [
  30231. -1,
  30232. -1
  30233. ],
  30234. [
  30235. -1,
  30236. -1
  30237. ],
  30238. [
  30239. -1,
  30240. -1
  30241. ],
  30242. [
  30243. -1,
  30244. -1
  30245. ],
  30246. [
  30247. 6,
  30248. 9
  30249. ],
  30250. [
  30251. 6,
  30252. 8
  30253. ],
  30254. [
  30255. 5,
  30256. 7
  30257. ],
  30258. [
  30259. 5,
  30260. 7
  30261. ],
  30262. [
  30263. 4,
  30264. 6
  30265. ],
  30266. [
  30267. 4,
  30268. 6
  30269. ],
  30270. [
  30271. 4,
  30272. 6
  30273. ],
  30274. [
  30275. 4,
  30276. 6
  30277. ],
  30278. [
  30279. 4,
  30280. 5
  30281. ],
  30282. [
  30283. 4,
  30284. 5
  30285. ],
  30286. [
  30287. 4,
  30288. 5
  30289. ],
  30290. [
  30291. 4,
  30292. 5
  30293. ],
  30294. [
  30295. 3,
  30296. 1
  30297. ],
  30298. [
  30299. 3,
  30300. 1
  30301. ],
  30302. [
  30303. 3,
  30304. 1
  30305. ],
  30306. [
  30307. 3,
  30308. 1
  30309. ],
  30310. [
  30311. 3,
  30312. 1
  30313. ],
  30314. [
  30315. 3,
  30316. 1
  30317. ],
  30318. [
  30319. 3,
  30320. 1
  30321. ],
  30322. [
  30323. 3,
  30324. 1
  30325. ],
  30326. [
  30327. 3,
  30328. 4
  30329. ],
  30330. [
  30331. 3,
  30332. 4
  30333. ],
  30334. [
  30335. 3,
  30336. 4
  30337. ],
  30338. [
  30339. 3,
  30340. 4
  30341. ],
  30342. [
  30343. 3,
  30344. 4
  30345. ],
  30346. [
  30347. 3,
  30348. 4
  30349. ],
  30350. [
  30351. 3,
  30352. 4
  30353. ],
  30354. [
  30355. 3,
  30356. 4
  30357. ],
  30358. [
  30359. 2,
  30360. 3
  30361. ],
  30362. [
  30363. 2,
  30364. 3
  30365. ],
  30366. [
  30367. 2,
  30368. 3
  30369. ],
  30370. [
  30371. 2,
  30372. 3
  30373. ],
  30374. [
  30375. 2,
  30376. 3
  30377. ],
  30378. [
  30379. 2,
  30380. 3
  30381. ],
  30382. [
  30383. 2,
  30384. 3
  30385. ],
  30386. [
  30387. 2,
  30388. 3
  30389. ],
  30390. [
  30391. 2,
  30392. 3
  30393. ],
  30394. [
  30395. 2,
  30396. 3
  30397. ],
  30398. [
  30399. 2,
  30400. 3
  30401. ],
  30402. [
  30403. 2,
  30404. 3
  30405. ],
  30406. [
  30407. 2,
  30408. 3
  30409. ],
  30410. [
  30411. 2,
  30412. 3
  30413. ],
  30414. [
  30415. 2,
  30416. 3
  30417. ],
  30418. [
  30419. 2,
  30420. 3
  30421. ],
  30422. [
  30423. 2,
  30424. 2
  30425. ],
  30426. [
  30427. 2,
  30428. 2
  30429. ],
  30430. [
  30431. 2,
  30432. 2
  30433. ],
  30434. [
  30435. 2,
  30436. 2
  30437. ],
  30438. [
  30439. 2,
  30440. 2
  30441. ],
  30442. [
  30443. 2,
  30444. 2
  30445. ],
  30446. [
  30447. 2,
  30448. 2
  30449. ],
  30450. [
  30451. 2,
  30452. 2
  30453. ],
  30454. [
  30455. 2,
  30456. 2
  30457. ],
  30458. [
  30459. 2,
  30460. 2
  30461. ],
  30462. [
  30463. 2,
  30464. 2
  30465. ],
  30466. [
  30467. 2,
  30468. 2
  30469. ],
  30470. [
  30471. 2,
  30472. 2
  30473. ],
  30474. [
  30475. 2,
  30476. 2
  30477. ],
  30478. [
  30479. 2,
  30480. 2
  30481. ],
  30482. [
  30483. 2,
  30484. 2
  30485. ]
  30486. ];
  30487. function CCITTFaxStream(str, maybeLength, params) {
  30488. this.str = str;
  30489. this.dict = str.dict;
  30490. params = params || Dict.empty;
  30491. this.encoding = params.get('K') || 0;
  30492. this.eoline = params.get('EndOfLine') || false;
  30493. this.byteAlign = params.get('EncodedByteAlign') || false;
  30494. this.columns = params.get('Columns') || 1728;
  30495. this.rows = params.get('Rows') || 0;
  30496. var eoblock = params.get('EndOfBlock');
  30497. if (eoblock === null || eoblock === undefined) {
  30498. eoblock = true;
  30499. }
  30500. this.eoblock = eoblock;
  30501. this.black = params.get('BlackIs1') || false;
  30502. this.codingLine = new Uint32Array(this.columns + 1);
  30503. this.refLine = new Uint32Array(this.columns + 2);
  30504. this.codingLine[0] = this.columns;
  30505. this.codingPos = 0;
  30506. this.row = 0;
  30507. this.nextLine2D = this.encoding < 0;
  30508. this.inputBits = 0;
  30509. this.inputBuf = 0;
  30510. this.outputBits = 0;
  30511. var code1;
  30512. while ((code1 = this.lookBits(12)) === 0) {
  30513. this.eatBits(1);
  30514. }
  30515. if (code1 === 1) {
  30516. this.eatBits(12);
  30517. }
  30518. if (this.encoding > 0) {
  30519. this.nextLine2D = !this.lookBits(1);
  30520. this.eatBits(1);
  30521. }
  30522. DecodeStream.call(this, maybeLength);
  30523. }
  30524. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30525. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30526. while (!this.eof) {
  30527. var c = this.lookChar();
  30528. this.ensureBuffer(this.bufferLength + 1);
  30529. this.buffer[this.bufferLength++] = c;
  30530. }
  30531. };
  30532. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30533. var codingLine = this.codingLine;
  30534. var codingPos = this.codingPos;
  30535. if (a1 > codingLine[codingPos]) {
  30536. if (a1 > this.columns) {
  30537. info('row is wrong length');
  30538. this.err = true;
  30539. a1 = this.columns;
  30540. }
  30541. if (codingPos & 1 ^ blackPixels) {
  30542. ++codingPos;
  30543. }
  30544. codingLine[codingPos] = a1;
  30545. }
  30546. this.codingPos = codingPos;
  30547. };
  30548. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30549. var codingLine = this.codingLine;
  30550. var codingPos = this.codingPos;
  30551. if (a1 > codingLine[codingPos]) {
  30552. if (a1 > this.columns) {
  30553. info('row is wrong length');
  30554. this.err = true;
  30555. a1 = this.columns;
  30556. }
  30557. if (codingPos & 1 ^ blackPixels) {
  30558. ++codingPos;
  30559. }
  30560. codingLine[codingPos] = a1;
  30561. } else if (a1 < codingLine[codingPos]) {
  30562. if (a1 < 0) {
  30563. info('invalid code');
  30564. this.err = true;
  30565. a1 = 0;
  30566. }
  30567. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30568. --codingPos;
  30569. }
  30570. codingLine[codingPos] = a1;
  30571. }
  30572. this.codingPos = codingPos;
  30573. };
  30574. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30575. var refLine = this.refLine;
  30576. var codingLine = this.codingLine;
  30577. var columns = this.columns;
  30578. var refPos, blackPixels, bits, i;
  30579. if (this.outputBits === 0) {
  30580. if (this.eof) {
  30581. return null;
  30582. }
  30583. this.err = false;
  30584. var code1, code2, code3;
  30585. if (this.nextLine2D) {
  30586. for (i = 0; codingLine[i] < columns; ++i) {
  30587. refLine[i] = codingLine[i];
  30588. }
  30589. refLine[i++] = columns;
  30590. refLine[i] = columns;
  30591. codingLine[0] = 0;
  30592. this.codingPos = 0;
  30593. refPos = 0;
  30594. blackPixels = 0;
  30595. while (codingLine[this.codingPos] < columns) {
  30596. code1 = this.getTwoDimCode();
  30597. switch (code1) {
  30598. case twoDimPass:
  30599. this.addPixels(refLine[refPos + 1], blackPixels);
  30600. if (refLine[refPos + 1] < columns) {
  30601. refPos += 2;
  30602. }
  30603. break;
  30604. case twoDimHoriz:
  30605. code1 = code2 = 0;
  30606. if (blackPixels) {
  30607. do {
  30608. code1 += code3 = this.getBlackCode();
  30609. } while (code3 >= 64);
  30610. do {
  30611. code2 += code3 = this.getWhiteCode();
  30612. } while (code3 >= 64);
  30613. } else {
  30614. do {
  30615. code1 += code3 = this.getWhiteCode();
  30616. } while (code3 >= 64);
  30617. do {
  30618. code2 += code3 = this.getBlackCode();
  30619. } while (code3 >= 64);
  30620. }
  30621. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30622. if (codingLine[this.codingPos] < columns) {
  30623. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30624. }
  30625. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30626. refPos += 2;
  30627. }
  30628. break;
  30629. case twoDimVertR3:
  30630. this.addPixels(refLine[refPos] + 3, blackPixels);
  30631. blackPixels ^= 1;
  30632. if (codingLine[this.codingPos] < columns) {
  30633. ++refPos;
  30634. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30635. refPos += 2;
  30636. }
  30637. }
  30638. break;
  30639. case twoDimVertR2:
  30640. this.addPixels(refLine[refPos] + 2, 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 twoDimVertR1:
  30650. this.addPixels(refLine[refPos] + 1, 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 twoDimVert0:
  30660. this.addPixels(refLine[refPos], 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 twoDimVertL3:
  30670. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  30671. blackPixels ^= 1;
  30672. if (codingLine[this.codingPos] < columns) {
  30673. if (refPos > 0) {
  30674. --refPos;
  30675. } else {
  30676. ++refPos;
  30677. }
  30678. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30679. refPos += 2;
  30680. }
  30681. }
  30682. break;
  30683. case twoDimVertL2:
  30684. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  30685. blackPixels ^= 1;
  30686. if (codingLine[this.codingPos] < columns) {
  30687. if (refPos > 0) {
  30688. --refPos;
  30689. } else {
  30690. ++refPos;
  30691. }
  30692. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30693. refPos += 2;
  30694. }
  30695. }
  30696. break;
  30697. case twoDimVertL1:
  30698. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  30699. blackPixels ^= 1;
  30700. if (codingLine[this.codingPos] < columns) {
  30701. if (refPos > 0) {
  30702. --refPos;
  30703. } else {
  30704. ++refPos;
  30705. }
  30706. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30707. refPos += 2;
  30708. }
  30709. }
  30710. break;
  30711. case ccittEOF:
  30712. this.addPixels(columns, 0);
  30713. this.eof = true;
  30714. break;
  30715. default:
  30716. info('bad 2d code');
  30717. this.addPixels(columns, 0);
  30718. this.err = true;
  30719. }
  30720. }
  30721. } else {
  30722. codingLine[0] = 0;
  30723. this.codingPos = 0;
  30724. blackPixels = 0;
  30725. while (codingLine[this.codingPos] < columns) {
  30726. code1 = 0;
  30727. if (blackPixels) {
  30728. do {
  30729. code1 += code3 = this.getBlackCode();
  30730. } while (code3 >= 64);
  30731. } else {
  30732. do {
  30733. code1 += code3 = this.getWhiteCode();
  30734. } while (code3 >= 64);
  30735. }
  30736. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30737. blackPixels ^= 1;
  30738. }
  30739. }
  30740. var gotEOL = false;
  30741. if (this.byteAlign) {
  30742. this.inputBits &= ~7;
  30743. }
  30744. if (!this.eoblock && this.row === this.rows - 1) {
  30745. this.eof = true;
  30746. } else {
  30747. code1 = this.lookBits(12);
  30748. if (this.eoline) {
  30749. while (code1 !== ccittEOF && code1 !== 1) {
  30750. this.eatBits(1);
  30751. code1 = this.lookBits(12);
  30752. }
  30753. } else {
  30754. while (code1 === 0) {
  30755. this.eatBits(1);
  30756. code1 = this.lookBits(12);
  30757. }
  30758. }
  30759. if (code1 === 1) {
  30760. this.eatBits(12);
  30761. gotEOL = true;
  30762. } else if (code1 === ccittEOF) {
  30763. this.eof = true;
  30764. }
  30765. }
  30766. if (!this.eof && this.encoding > 0) {
  30767. this.nextLine2D = !this.lookBits(1);
  30768. this.eatBits(1);
  30769. }
  30770. if (this.eoblock && gotEOL && this.byteAlign) {
  30771. code1 = this.lookBits(12);
  30772. if (code1 === 1) {
  30773. this.eatBits(12);
  30774. if (this.encoding > 0) {
  30775. this.lookBits(1);
  30776. this.eatBits(1);
  30777. }
  30778. if (this.encoding >= 0) {
  30779. for (i = 0; i < 4; ++i) {
  30780. code1 = this.lookBits(12);
  30781. if (code1 !== 1) {
  30782. info('bad rtc code: ' + code1);
  30783. }
  30784. this.eatBits(12);
  30785. if (this.encoding > 0) {
  30786. this.lookBits(1);
  30787. this.eatBits(1);
  30788. }
  30789. }
  30790. }
  30791. this.eof = true;
  30792. }
  30793. } else if (this.err && this.eoline) {
  30794. while (true) {
  30795. code1 = this.lookBits(13);
  30796. if (code1 === ccittEOF) {
  30797. this.eof = true;
  30798. return null;
  30799. }
  30800. if (code1 >> 1 === 1) {
  30801. break;
  30802. }
  30803. this.eatBits(1);
  30804. }
  30805. this.eatBits(12);
  30806. if (this.encoding > 0) {
  30807. this.eatBits(1);
  30808. this.nextLine2D = !(code1 & 1);
  30809. }
  30810. }
  30811. if (codingLine[0] > 0) {
  30812. this.outputBits = codingLine[this.codingPos = 0];
  30813. } else {
  30814. this.outputBits = codingLine[this.codingPos = 1];
  30815. }
  30816. this.row++;
  30817. }
  30818. var c;
  30819. if (this.outputBits >= 8) {
  30820. c = this.codingPos & 1 ? 0 : 0xFF;
  30821. this.outputBits -= 8;
  30822. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  30823. this.codingPos++;
  30824. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30825. }
  30826. } else {
  30827. bits = 8;
  30828. c = 0;
  30829. do {
  30830. if (this.outputBits > bits) {
  30831. c <<= bits;
  30832. if (!(this.codingPos & 1)) {
  30833. c |= 0xFF >> 8 - bits;
  30834. }
  30835. this.outputBits -= bits;
  30836. bits = 0;
  30837. } else {
  30838. c <<= this.outputBits;
  30839. if (!(this.codingPos & 1)) {
  30840. c |= 0xFF >> 8 - this.outputBits;
  30841. }
  30842. bits -= this.outputBits;
  30843. this.outputBits = 0;
  30844. if (codingLine[this.codingPos] < columns) {
  30845. this.codingPos++;
  30846. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30847. } else if (bits > 0) {
  30848. c <<= bits;
  30849. bits = 0;
  30850. }
  30851. }
  30852. } while (bits);
  30853. }
  30854. if (this.black) {
  30855. c ^= 0xFF;
  30856. }
  30857. return c;
  30858. };
  30859. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  30860. var limitValue = limit || 0;
  30861. for (var i = start; i <= end; ++i) {
  30862. var code = this.lookBits(i);
  30863. if (code === ccittEOF) {
  30864. return [
  30865. true,
  30866. 1,
  30867. false
  30868. ];
  30869. }
  30870. if (i < end) {
  30871. code <<= end - i;
  30872. }
  30873. if (!limitValue || code >= limitValue) {
  30874. var p = table[code - limitValue];
  30875. if (p[0] === i) {
  30876. this.eatBits(i);
  30877. return [
  30878. true,
  30879. p[1],
  30880. true
  30881. ];
  30882. }
  30883. }
  30884. }
  30885. return [
  30886. false,
  30887. 0,
  30888. false
  30889. ];
  30890. };
  30891. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  30892. var code = 0;
  30893. var p;
  30894. if (this.eoblock) {
  30895. code = this.lookBits(7);
  30896. p = twoDimTable[code];
  30897. if (p && p[0] > 0) {
  30898. this.eatBits(p[0]);
  30899. return p[1];
  30900. }
  30901. } else {
  30902. var result = this.findTableCode(1, 7, twoDimTable);
  30903. if (result[0] && result[2]) {
  30904. return result[1];
  30905. }
  30906. }
  30907. info('Bad two dim code');
  30908. return ccittEOF;
  30909. };
  30910. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  30911. var code = 0;
  30912. var p;
  30913. if (this.eoblock) {
  30914. code = this.lookBits(12);
  30915. if (code === ccittEOF) {
  30916. return 1;
  30917. }
  30918. if (code >> 5 === 0) {
  30919. p = whiteTable1[code];
  30920. } else {
  30921. p = whiteTable2[code >> 3];
  30922. }
  30923. if (p[0] > 0) {
  30924. this.eatBits(p[0]);
  30925. return p[1];
  30926. }
  30927. } else {
  30928. var result = this.findTableCode(1, 9, whiteTable2);
  30929. if (result[0]) {
  30930. return result[1];
  30931. }
  30932. result = this.findTableCode(11, 12, whiteTable1);
  30933. if (result[0]) {
  30934. return result[1];
  30935. }
  30936. }
  30937. info('bad white code');
  30938. this.eatBits(1);
  30939. return 1;
  30940. };
  30941. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  30942. var code, p;
  30943. if (this.eoblock) {
  30944. code = this.lookBits(13);
  30945. if (code === ccittEOF) {
  30946. return 1;
  30947. }
  30948. if (code >> 7 === 0) {
  30949. p = blackTable1[code];
  30950. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  30951. p = blackTable2[(code >> 1) - 64];
  30952. } else {
  30953. p = blackTable3[code >> 7];
  30954. }
  30955. if (p[0] > 0) {
  30956. this.eatBits(p[0]);
  30957. return p[1];
  30958. }
  30959. } else {
  30960. var result = this.findTableCode(2, 6, blackTable3);
  30961. if (result[0]) {
  30962. return result[1];
  30963. }
  30964. result = this.findTableCode(7, 12, blackTable2, 64);
  30965. if (result[0]) {
  30966. return result[1];
  30967. }
  30968. result = this.findTableCode(10, 13, blackTable1);
  30969. if (result[0]) {
  30970. return result[1];
  30971. }
  30972. }
  30973. info('bad black code');
  30974. this.eatBits(1);
  30975. return 1;
  30976. };
  30977. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  30978. var c;
  30979. while (this.inputBits < n) {
  30980. if ((c = this.str.getByte()) === -1) {
  30981. if (this.inputBits === 0) {
  30982. return ccittEOF;
  30983. }
  30984. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  30985. }
  30986. this.inputBuf = this.inputBuf << 8 | c;
  30987. this.inputBits += 8;
  30988. }
  30989. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  30990. };
  30991. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  30992. if ((this.inputBits -= n) < 0) {
  30993. this.inputBits = 0;
  30994. }
  30995. };
  30996. return CCITTFaxStream;
  30997. }();
  30998. var LZWStream = function LZWStreamClosure() {
  30999. function LZWStream(str, maybeLength, earlyChange) {
  31000. this.str = str;
  31001. this.dict = str.dict;
  31002. this.cachedData = 0;
  31003. this.bitsCached = 0;
  31004. var maxLzwDictionarySize = 4096;
  31005. var lzwState = {
  31006. earlyChange: earlyChange,
  31007. codeLength: 9,
  31008. nextCode: 258,
  31009. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31010. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31011. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31012. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31013. currentSequenceLength: 0
  31014. };
  31015. for (var i = 0; i < 256; ++i) {
  31016. lzwState.dictionaryValues[i] = i;
  31017. lzwState.dictionaryLengths[i] = 1;
  31018. }
  31019. this.lzwState = lzwState;
  31020. DecodeStream.call(this, maybeLength);
  31021. }
  31022. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31023. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31024. var bitsCached = this.bitsCached;
  31025. var cachedData = this.cachedData;
  31026. while (bitsCached < n) {
  31027. var c = this.str.getByte();
  31028. if (c === -1) {
  31029. this.eof = true;
  31030. return null;
  31031. }
  31032. cachedData = cachedData << 8 | c;
  31033. bitsCached += 8;
  31034. }
  31035. this.bitsCached = bitsCached -= n;
  31036. this.cachedData = cachedData;
  31037. this.lastCode = null;
  31038. return cachedData >>> bitsCached & (1 << n) - 1;
  31039. };
  31040. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31041. var blockSize = 512;
  31042. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31043. var i, j, q;
  31044. var lzwState = this.lzwState;
  31045. if (!lzwState) {
  31046. return;
  31047. }
  31048. var earlyChange = lzwState.earlyChange;
  31049. var nextCode = lzwState.nextCode;
  31050. var dictionaryValues = lzwState.dictionaryValues;
  31051. var dictionaryLengths = lzwState.dictionaryLengths;
  31052. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31053. var codeLength = lzwState.codeLength;
  31054. var prevCode = lzwState.prevCode;
  31055. var currentSequence = lzwState.currentSequence;
  31056. var currentSequenceLength = lzwState.currentSequenceLength;
  31057. var decodedLength = 0;
  31058. var currentBufferLength = this.bufferLength;
  31059. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31060. for (i = 0; i < blockSize; i++) {
  31061. var code = this.readBits(codeLength);
  31062. var hasPrev = currentSequenceLength > 0;
  31063. if (code < 256) {
  31064. currentSequence[0] = code;
  31065. currentSequenceLength = 1;
  31066. } else if (code >= 258) {
  31067. if (code < nextCode) {
  31068. currentSequenceLength = dictionaryLengths[code];
  31069. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31070. currentSequence[j] = dictionaryValues[q];
  31071. q = dictionaryPrevCodes[q];
  31072. }
  31073. } else {
  31074. currentSequence[currentSequenceLength++] = currentSequence[0];
  31075. }
  31076. } else if (code === 256) {
  31077. codeLength = 9;
  31078. nextCode = 258;
  31079. currentSequenceLength = 0;
  31080. continue;
  31081. } else {
  31082. this.eof = true;
  31083. delete this.lzwState;
  31084. break;
  31085. }
  31086. if (hasPrev) {
  31087. dictionaryPrevCodes[nextCode] = prevCode;
  31088. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31089. dictionaryValues[nextCode] = currentSequence[0];
  31090. nextCode++;
  31091. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31092. }
  31093. prevCode = code;
  31094. decodedLength += currentSequenceLength;
  31095. if (estimatedDecodedSize < decodedLength) {
  31096. do {
  31097. estimatedDecodedSize += decodedSizeDelta;
  31098. } while (estimatedDecodedSize < decodedLength);
  31099. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31100. }
  31101. for (j = 0; j < currentSequenceLength; j++) {
  31102. buffer[currentBufferLength++] = currentSequence[j];
  31103. }
  31104. }
  31105. lzwState.nextCode = nextCode;
  31106. lzwState.codeLength = codeLength;
  31107. lzwState.prevCode = prevCode;
  31108. lzwState.currentSequenceLength = currentSequenceLength;
  31109. this.bufferLength = currentBufferLength;
  31110. };
  31111. return LZWStream;
  31112. }();
  31113. var NullStream = function NullStreamClosure() {
  31114. function NullStream() {
  31115. Stream.call(this, new Uint8Array(0));
  31116. }
  31117. NullStream.prototype = Stream.prototype;
  31118. return NullStream;
  31119. }();
  31120. exports.Ascii85Stream = Ascii85Stream;
  31121. exports.AsciiHexStream = AsciiHexStream;
  31122. exports.CCITTFaxStream = CCITTFaxStream;
  31123. exports.DecryptStream = DecryptStream;
  31124. exports.DecodeStream = DecodeStream;
  31125. exports.FlateStream = FlateStream;
  31126. exports.Jbig2Stream = Jbig2Stream;
  31127. exports.JpegStream = JpegStream;
  31128. exports.JpxStream = JpxStream;
  31129. exports.NullStream = NullStream;
  31130. exports.PredictorStream = PredictorStream;
  31131. exports.RunLengthStream = RunLengthStream;
  31132. exports.Stream = Stream;
  31133. exports.StreamsSequenceStream = StreamsSequenceStream;
  31134. exports.StringStream = StringStream;
  31135. exports.LZWStream = LZWStream;
  31136. }));
  31137. (function (root, factory) {
  31138. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31139. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31140. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31141. var AnnotationType = sharedUtil.AnnotationType;
  31142. var Util = sharedUtil.Util;
  31143. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31144. var LinkTarget = displayDOMUtils.LinkTarget;
  31145. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31146. var warn = sharedUtil.warn;
  31147. var CustomStyle = displayDOMUtils.CustomStyle;
  31148. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31149. function AnnotationElementFactory() {
  31150. }
  31151. AnnotationElementFactory.prototype = {
  31152. create: function AnnotationElementFactory_create(parameters) {
  31153. var subtype = parameters.data.annotationType;
  31154. switch (subtype) {
  31155. case AnnotationType.LINK:
  31156. return new LinkAnnotationElement(parameters);
  31157. case AnnotationType.TEXT:
  31158. return new TextAnnotationElement(parameters);
  31159. case AnnotationType.WIDGET:
  31160. var fieldType = parameters.data.fieldType;
  31161. switch (fieldType) {
  31162. case 'Tx':
  31163. return new TextWidgetAnnotationElement(parameters);
  31164. case 'Ch':
  31165. return new ChoiceWidgetAnnotationElement(parameters);
  31166. }
  31167. return new WidgetAnnotationElement(parameters);
  31168. case AnnotationType.POPUP:
  31169. return new PopupAnnotationElement(parameters);
  31170. case AnnotationType.HIGHLIGHT:
  31171. return new HighlightAnnotationElement(parameters);
  31172. case AnnotationType.UNDERLINE:
  31173. return new UnderlineAnnotationElement(parameters);
  31174. case AnnotationType.SQUIGGLY:
  31175. return new SquigglyAnnotationElement(parameters);
  31176. case AnnotationType.STRIKEOUT:
  31177. return new StrikeOutAnnotationElement(parameters);
  31178. case AnnotationType.FILEATTACHMENT:
  31179. return new FileAttachmentAnnotationElement(parameters);
  31180. default:
  31181. return new AnnotationElement(parameters);
  31182. }
  31183. }
  31184. };
  31185. var AnnotationElement = function AnnotationElementClosure() {
  31186. function AnnotationElement(parameters, isRenderable) {
  31187. this.isRenderable = isRenderable || false;
  31188. this.data = parameters.data;
  31189. this.layer = parameters.layer;
  31190. this.page = parameters.page;
  31191. this.viewport = parameters.viewport;
  31192. this.linkService = parameters.linkService;
  31193. this.downloadManager = parameters.downloadManager;
  31194. this.imageResourcesPath = parameters.imageResourcesPath;
  31195. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31196. if (isRenderable) {
  31197. this.container = this._createContainer();
  31198. }
  31199. }
  31200. AnnotationElement.prototype = {
  31201. _createContainer: function AnnotationElement_createContainer() {
  31202. var data = this.data, page = this.page, viewport = this.viewport;
  31203. var container = document.createElement('section');
  31204. var width = data.rect[2] - data.rect[0];
  31205. var height = data.rect[3] - data.rect[1];
  31206. container.setAttribute('data-annotation-id', data.id);
  31207. var rect = Util.normalizeRect([
  31208. data.rect[0],
  31209. page.view[3] - data.rect[1] + page.view[1],
  31210. data.rect[2],
  31211. page.view[3] - data.rect[3] + page.view[1]
  31212. ]);
  31213. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31214. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31215. if (data.borderStyle.width > 0) {
  31216. container.style.borderWidth = data.borderStyle.width + 'px';
  31217. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31218. width = width - 2 * data.borderStyle.width;
  31219. height = height - 2 * data.borderStyle.width;
  31220. }
  31221. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31222. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31223. if (horizontalRadius > 0 || verticalRadius > 0) {
  31224. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31225. CustomStyle.setProp('borderRadius', container, radius);
  31226. }
  31227. switch (data.borderStyle.style) {
  31228. case AnnotationBorderStyleType.SOLID:
  31229. container.style.borderStyle = 'solid';
  31230. break;
  31231. case AnnotationBorderStyleType.DASHED:
  31232. container.style.borderStyle = 'dashed';
  31233. break;
  31234. case AnnotationBorderStyleType.BEVELED:
  31235. warn('Unimplemented border style: beveled');
  31236. break;
  31237. case AnnotationBorderStyleType.INSET:
  31238. warn('Unimplemented border style: inset');
  31239. break;
  31240. case AnnotationBorderStyleType.UNDERLINE:
  31241. container.style.borderBottomStyle = 'solid';
  31242. break;
  31243. default:
  31244. break;
  31245. }
  31246. if (data.color) {
  31247. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31248. } else {
  31249. container.style.borderWidth = 0;
  31250. }
  31251. }
  31252. container.style.left = rect[0] + 'px';
  31253. container.style.top = rect[1] + 'px';
  31254. container.style.width = width + 'px';
  31255. container.style.height = height + 'px';
  31256. return container;
  31257. },
  31258. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31259. if (!trigger) {
  31260. trigger = document.createElement('div');
  31261. trigger.style.height = container.style.height;
  31262. trigger.style.width = container.style.width;
  31263. container.appendChild(trigger);
  31264. }
  31265. var popupElement = new PopupElement({
  31266. container: container,
  31267. trigger: trigger,
  31268. color: data.color,
  31269. title: data.title,
  31270. contents: data.contents,
  31271. hideWrapper: true
  31272. });
  31273. var popup = popupElement.render();
  31274. popup.style.left = container.style.width;
  31275. container.appendChild(popup);
  31276. },
  31277. render: function AnnotationElement_render() {
  31278. throw new Error('Abstract method AnnotationElement.render called');
  31279. }
  31280. };
  31281. return AnnotationElement;
  31282. }();
  31283. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31284. function LinkAnnotationElement(parameters) {
  31285. AnnotationElement.call(this, parameters, true);
  31286. }
  31287. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31288. render: function LinkAnnotationElement_render() {
  31289. this.container.className = 'linkAnnotation';
  31290. var link = document.createElement('a');
  31291. addLinkAttributes(link, {
  31292. url: this.data.url,
  31293. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31294. });
  31295. if (!this.data.url) {
  31296. if (this.data.action) {
  31297. this._bindNamedAction(link, this.data.action);
  31298. } else {
  31299. this._bindLink(link, this.data.dest);
  31300. }
  31301. }
  31302. this.container.appendChild(link);
  31303. return this.container;
  31304. },
  31305. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31306. var self = this;
  31307. link.href = this.linkService.getDestinationHash(destination);
  31308. link.onclick = function () {
  31309. if (destination) {
  31310. self.linkService.navigateTo(destination);
  31311. }
  31312. return false;
  31313. };
  31314. if (destination) {
  31315. link.className = 'internalLink';
  31316. }
  31317. },
  31318. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31319. var self = this;
  31320. link.href = this.linkService.getAnchorUrl('');
  31321. link.onclick = function () {
  31322. self.linkService.executeNamedAction(action);
  31323. return false;
  31324. };
  31325. link.className = 'internalLink';
  31326. }
  31327. });
  31328. return LinkAnnotationElement;
  31329. }();
  31330. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31331. function TextAnnotationElement(parameters) {
  31332. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31333. AnnotationElement.call(this, parameters, isRenderable);
  31334. }
  31335. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31336. render: function TextAnnotationElement_render() {
  31337. this.container.className = 'textAnnotation';
  31338. var image = document.createElement('img');
  31339. image.style.height = this.container.style.height;
  31340. image.style.width = this.container.style.width;
  31341. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31342. image.alt = '[{{type}} Annotation]';
  31343. image.dataset.l10nId = 'text_annotation_type';
  31344. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31345. if (!this.data.hasPopup) {
  31346. this._createPopup(this.container, image, this.data);
  31347. }
  31348. this.container.appendChild(image);
  31349. return this.container;
  31350. }
  31351. });
  31352. return TextAnnotationElement;
  31353. }();
  31354. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31355. function WidgetAnnotationElement(parameters, isRenderable) {
  31356. AnnotationElement.call(this, parameters, isRenderable);
  31357. }
  31358. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31359. render: function WidgetAnnotationElement_render() {
  31360. return this.container;
  31361. }
  31362. });
  31363. return WidgetAnnotationElement;
  31364. }();
  31365. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31366. var TEXT_ALIGNMENT = [
  31367. 'left',
  31368. 'center',
  31369. 'right'
  31370. ];
  31371. function TextWidgetAnnotationElement(parameters) {
  31372. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31373. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31374. }
  31375. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31376. render: function TextWidgetAnnotationElement_render() {
  31377. this.container.className = 'textWidgetAnnotation';
  31378. var element = null;
  31379. if (this.renderInteractiveForms) {
  31380. if (this.data.multiLine) {
  31381. element = document.createElement('textarea');
  31382. element.textContent = this.data.fieldValue;
  31383. } else {
  31384. element = document.createElement('input');
  31385. element.type = 'text';
  31386. element.setAttribute('value', this.data.fieldValue);
  31387. }
  31388. element.disabled = this.data.readOnly;
  31389. if (this.data.maxLen !== null) {
  31390. element.maxLength = this.data.maxLen;
  31391. }
  31392. if (this.data.comb) {
  31393. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31394. var combWidth = fieldWidth / this.data.maxLen;
  31395. element.classList.add('comb');
  31396. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31397. }
  31398. } else {
  31399. element = document.createElement('div');
  31400. element.textContent = this.data.fieldValue;
  31401. element.style.verticalAlign = 'middle';
  31402. element.style.display = 'table-cell';
  31403. var font = null;
  31404. if (this.data.fontRefName) {
  31405. font = this.page.commonObjs.getData(this.data.fontRefName);
  31406. }
  31407. this._setTextStyle(element, font);
  31408. }
  31409. if (this.data.textAlignment !== null) {
  31410. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31411. }
  31412. this.container.appendChild(element);
  31413. return this.container;
  31414. },
  31415. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31416. var style = element.style;
  31417. style.fontSize = this.data.fontSize + 'px';
  31418. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31419. if (!font) {
  31420. return;
  31421. }
  31422. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31423. style.fontStyle = font.italic ? 'italic' : 'normal';
  31424. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31425. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31426. style.fontFamily = fontFamily + fallbackName;
  31427. }
  31428. });
  31429. return TextWidgetAnnotationElement;
  31430. }();
  31431. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31432. function ChoiceWidgetAnnotationElement(parameters) {
  31433. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31434. }
  31435. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31436. render: function ChoiceWidgetAnnotationElement_render() {
  31437. this.container.className = 'choiceWidgetAnnotation';
  31438. var selectElement = document.createElement('select');
  31439. selectElement.disabled = this.data.readOnly;
  31440. if (!this.data.combo) {
  31441. selectElement.size = this.data.options.length;
  31442. if (this.data.multiSelect) {
  31443. selectElement.multiple = true;
  31444. }
  31445. }
  31446. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31447. var option = this.data.options[i];
  31448. var optionElement = document.createElement('option');
  31449. optionElement.textContent = option.displayValue;
  31450. optionElement.value = option.exportValue;
  31451. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31452. optionElement.setAttribute('selected', true);
  31453. }
  31454. selectElement.appendChild(optionElement);
  31455. }
  31456. this.container.appendChild(selectElement);
  31457. return this.container;
  31458. }
  31459. });
  31460. return ChoiceWidgetAnnotationElement;
  31461. }();
  31462. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31463. function PopupAnnotationElement(parameters) {
  31464. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31465. AnnotationElement.call(this, parameters, isRenderable);
  31466. }
  31467. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31468. render: function PopupAnnotationElement_render() {
  31469. this.container.className = 'popupAnnotation';
  31470. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31471. var parentElement = this.layer.querySelector(selector);
  31472. if (!parentElement) {
  31473. return this.container;
  31474. }
  31475. var popup = new PopupElement({
  31476. container: this.container,
  31477. trigger: parentElement,
  31478. color: this.data.color,
  31479. title: this.data.title,
  31480. contents: this.data.contents
  31481. });
  31482. var parentLeft = parseFloat(parentElement.style.left);
  31483. var parentWidth = parseFloat(parentElement.style.width);
  31484. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31485. this.container.style.left = parentLeft + parentWidth + 'px';
  31486. this.container.appendChild(popup.render());
  31487. return this.container;
  31488. }
  31489. });
  31490. return PopupAnnotationElement;
  31491. }();
  31492. var PopupElement = function PopupElementClosure() {
  31493. var BACKGROUND_ENLIGHT = 0.7;
  31494. function PopupElement(parameters) {
  31495. this.container = parameters.container;
  31496. this.trigger = parameters.trigger;
  31497. this.color = parameters.color;
  31498. this.title = parameters.title;
  31499. this.contents = parameters.contents;
  31500. this.hideWrapper = parameters.hideWrapper || false;
  31501. this.pinned = false;
  31502. }
  31503. PopupElement.prototype = {
  31504. render: function PopupElement_render() {
  31505. var wrapper = document.createElement('div');
  31506. wrapper.className = 'popupWrapper';
  31507. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31508. this.hideElement.setAttribute('hidden', true);
  31509. var popup = document.createElement('div');
  31510. popup.className = 'popup';
  31511. var color = this.color;
  31512. if (color) {
  31513. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31514. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31515. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31516. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31517. }
  31518. var contents = this._formatContents(this.contents);
  31519. var title = document.createElement('h1');
  31520. title.textContent = this.title;
  31521. this.trigger.addEventListener('click', this._toggle.bind(this));
  31522. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31523. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31524. popup.addEventListener('click', this._hide.bind(this, true));
  31525. popup.appendChild(title);
  31526. popup.appendChild(contents);
  31527. wrapper.appendChild(popup);
  31528. return wrapper;
  31529. },
  31530. _formatContents: function PopupElement_formatContents(contents) {
  31531. var p = document.createElement('p');
  31532. var lines = contents.split(/(?:\r\n?|\n)/);
  31533. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31534. var line = lines[i];
  31535. p.appendChild(document.createTextNode(line));
  31536. if (i < ii - 1) {
  31537. p.appendChild(document.createElement('br'));
  31538. }
  31539. }
  31540. return p;
  31541. },
  31542. _toggle: function PopupElement_toggle() {
  31543. if (this.pinned) {
  31544. this._hide(true);
  31545. } else {
  31546. this._show(true);
  31547. }
  31548. },
  31549. _show: function PopupElement_show(pin) {
  31550. if (pin) {
  31551. this.pinned = true;
  31552. }
  31553. if (this.hideElement.hasAttribute('hidden')) {
  31554. this.hideElement.removeAttribute('hidden');
  31555. this.container.style.zIndex += 1;
  31556. }
  31557. },
  31558. _hide: function PopupElement_hide(unpin) {
  31559. if (unpin) {
  31560. this.pinned = false;
  31561. }
  31562. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31563. this.hideElement.setAttribute('hidden', true);
  31564. this.container.style.zIndex -= 1;
  31565. }
  31566. }
  31567. };
  31568. return PopupElement;
  31569. }();
  31570. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31571. function HighlightAnnotationElement(parameters) {
  31572. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31573. AnnotationElement.call(this, parameters, isRenderable);
  31574. }
  31575. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31576. render: function HighlightAnnotationElement_render() {
  31577. this.container.className = 'highlightAnnotation';
  31578. if (!this.data.hasPopup) {
  31579. this._createPopup(this.container, null, this.data);
  31580. }
  31581. return this.container;
  31582. }
  31583. });
  31584. return HighlightAnnotationElement;
  31585. }();
  31586. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31587. function UnderlineAnnotationElement(parameters) {
  31588. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31589. AnnotationElement.call(this, parameters, isRenderable);
  31590. }
  31591. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31592. render: function UnderlineAnnotationElement_render() {
  31593. this.container.className = 'underlineAnnotation';
  31594. if (!this.data.hasPopup) {
  31595. this._createPopup(this.container, null, this.data);
  31596. }
  31597. return this.container;
  31598. }
  31599. });
  31600. return UnderlineAnnotationElement;
  31601. }();
  31602. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31603. function SquigglyAnnotationElement(parameters) {
  31604. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31605. AnnotationElement.call(this, parameters, isRenderable);
  31606. }
  31607. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31608. render: function SquigglyAnnotationElement_render() {
  31609. this.container.className = 'squigglyAnnotation';
  31610. if (!this.data.hasPopup) {
  31611. this._createPopup(this.container, null, this.data);
  31612. }
  31613. return this.container;
  31614. }
  31615. });
  31616. return SquigglyAnnotationElement;
  31617. }();
  31618. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31619. function StrikeOutAnnotationElement(parameters) {
  31620. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31621. AnnotationElement.call(this, parameters, isRenderable);
  31622. }
  31623. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31624. render: function StrikeOutAnnotationElement_render() {
  31625. this.container.className = 'strikeoutAnnotation';
  31626. if (!this.data.hasPopup) {
  31627. this._createPopup(this.container, null, this.data);
  31628. }
  31629. return this.container;
  31630. }
  31631. });
  31632. return StrikeOutAnnotationElement;
  31633. }();
  31634. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31635. function FileAttachmentAnnotationElement(parameters) {
  31636. AnnotationElement.call(this, parameters, true);
  31637. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31638. this.content = parameters.data.file.content;
  31639. }
  31640. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31641. render: function FileAttachmentAnnotationElement_render() {
  31642. this.container.className = 'fileAttachmentAnnotation';
  31643. var trigger = document.createElement('div');
  31644. trigger.style.height = this.container.style.height;
  31645. trigger.style.width = this.container.style.width;
  31646. trigger.addEventListener('dblclick', this._download.bind(this));
  31647. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31648. this._createPopup(this.container, trigger, this.data);
  31649. }
  31650. this.container.appendChild(trigger);
  31651. return this.container;
  31652. },
  31653. _download: function FileAttachmentAnnotationElement_download() {
  31654. if (!this.downloadManager) {
  31655. warn('Download cannot be started due to unavailable download manager');
  31656. return;
  31657. }
  31658. this.downloadManager.downloadData(this.content, this.filename, '');
  31659. }
  31660. });
  31661. return FileAttachmentAnnotationElement;
  31662. }();
  31663. var AnnotationLayer = function AnnotationLayerClosure() {
  31664. return {
  31665. render: function AnnotationLayer_render(parameters) {
  31666. var annotationElementFactory = new AnnotationElementFactory();
  31667. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31668. var data = parameters.annotations[i];
  31669. if (!data) {
  31670. continue;
  31671. }
  31672. var properties = {
  31673. data: data,
  31674. layer: parameters.div,
  31675. page: parameters.page,
  31676. viewport: parameters.viewport,
  31677. linkService: parameters.linkService,
  31678. downloadManager: parameters.downloadManager,
  31679. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31680. renderInteractiveForms: parameters.renderInteractiveForms || false
  31681. };
  31682. var element = annotationElementFactory.create(properties);
  31683. if (element.isRenderable) {
  31684. parameters.div.appendChild(element.render());
  31685. }
  31686. }
  31687. },
  31688. update: function AnnotationLayer_update(parameters) {
  31689. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31690. var data = parameters.annotations[i];
  31691. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31692. if (element) {
  31693. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31694. }
  31695. }
  31696. parameters.div.removeAttribute('hidden');
  31697. }
  31698. };
  31699. }();
  31700. exports.AnnotationLayer = AnnotationLayer;
  31701. }));
  31702. (function (root, factory) {
  31703. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31704. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31705. var Util = sharedUtil.Util;
  31706. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31707. var CustomStyle = displayDOMUtils.CustomStyle;
  31708. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31709. var renderTextLayer = function renderTextLayerClosure() {
  31710. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31711. var NonWhitespaceRegexp = /\S/;
  31712. function isAllWhitespace(str) {
  31713. return !NonWhitespaceRegexp.test(str);
  31714. }
  31715. var styleBuf = [
  31716. 'left: ',
  31717. 0,
  31718. 'px; top: ',
  31719. 0,
  31720. 'px; font-size: ',
  31721. 0,
  31722. 'px; font-family: ',
  31723. '',
  31724. ';'
  31725. ];
  31726. function appendText(task, geom, styles) {
  31727. var textDiv = document.createElement('div');
  31728. var textDivProperties = {
  31729. style: null,
  31730. angle: 0,
  31731. canvasWidth: 0,
  31732. isWhitespace: false,
  31733. originalTransform: null,
  31734. paddingBottom: 0,
  31735. paddingLeft: 0,
  31736. paddingRight: 0,
  31737. paddingTop: 0,
  31738. scale: 1
  31739. };
  31740. task._textDivs.push(textDiv);
  31741. if (isAllWhitespace(geom.str)) {
  31742. textDivProperties.isWhitespace = true;
  31743. task._textDivProperties.set(textDiv, textDivProperties);
  31744. return;
  31745. }
  31746. var tx = Util.transform(task._viewport.transform, geom.transform);
  31747. var angle = Math.atan2(tx[1], tx[0]);
  31748. var style = styles[geom.fontName];
  31749. if (style.vertical) {
  31750. angle += Math.PI / 2;
  31751. }
  31752. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31753. var fontAscent = fontHeight;
  31754. if (style.ascent) {
  31755. fontAscent = style.ascent * fontAscent;
  31756. } else if (style.descent) {
  31757. fontAscent = (1 + style.descent) * fontAscent;
  31758. }
  31759. var left;
  31760. var top;
  31761. if (angle === 0) {
  31762. left = tx[4];
  31763. top = tx[5] - fontAscent;
  31764. } else {
  31765. left = tx[4] + fontAscent * Math.sin(angle);
  31766. top = tx[5] - fontAscent * Math.cos(angle);
  31767. }
  31768. styleBuf[1] = left;
  31769. styleBuf[3] = top;
  31770. styleBuf[5] = fontHeight;
  31771. styleBuf[7] = style.fontFamily;
  31772. textDivProperties.style = styleBuf.join('');
  31773. textDiv.setAttribute('style', textDivProperties.style);
  31774. textDiv.textContent = geom.str;
  31775. if (getDefaultSetting('pdfBug')) {
  31776. textDiv.dataset.fontName = geom.fontName;
  31777. }
  31778. if (angle !== 0) {
  31779. textDivProperties.angle = angle * (180 / Math.PI);
  31780. }
  31781. if (geom.str.length > 1) {
  31782. if (style.vertical) {
  31783. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31784. } else {
  31785. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31786. }
  31787. }
  31788. task._textDivProperties.set(textDiv, textDivProperties);
  31789. if (task._enhanceTextSelection) {
  31790. var angleCos = 1, angleSin = 0;
  31791. if (angle !== 0) {
  31792. angleCos = Math.cos(angle);
  31793. angleSin = Math.sin(angle);
  31794. }
  31795. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31796. var divHeight = fontHeight;
  31797. var m, b;
  31798. if (angle !== 0) {
  31799. m = [
  31800. angleCos,
  31801. angleSin,
  31802. -angleSin,
  31803. angleCos,
  31804. left,
  31805. top
  31806. ];
  31807. b = Util.getAxialAlignedBoundingBox([
  31808. 0,
  31809. 0,
  31810. divWidth,
  31811. divHeight
  31812. ], m);
  31813. } else {
  31814. b = [
  31815. left,
  31816. top,
  31817. left + divWidth,
  31818. top + divHeight
  31819. ];
  31820. }
  31821. task._bounds.push({
  31822. left: b[0],
  31823. top: b[1],
  31824. right: b[2],
  31825. bottom: b[3],
  31826. div: textDiv,
  31827. size: [
  31828. divWidth,
  31829. divHeight
  31830. ],
  31831. m: m
  31832. });
  31833. }
  31834. }
  31835. function render(task) {
  31836. if (task._canceled) {
  31837. return;
  31838. }
  31839. var textLayerFrag = task._container;
  31840. var textDivs = task._textDivs;
  31841. var capability = task._capability;
  31842. var textDivsLength = textDivs.length;
  31843. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  31844. task._renderingDone = true;
  31845. capability.resolve();
  31846. return;
  31847. }
  31848. var canvas = document.createElement('canvas');
  31849. var ctx = canvas.getContext('2d', { alpha: false });
  31850. var lastFontSize;
  31851. var lastFontFamily;
  31852. for (var i = 0; i < textDivsLength; i++) {
  31853. var textDiv = textDivs[i];
  31854. var textDivProperties = task._textDivProperties.get(textDiv);
  31855. if (textDivProperties.isWhitespace) {
  31856. continue;
  31857. }
  31858. var fontSize = textDiv.style.fontSize;
  31859. var fontFamily = textDiv.style.fontFamily;
  31860. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  31861. ctx.font = fontSize + ' ' + fontFamily;
  31862. lastFontSize = fontSize;
  31863. lastFontFamily = fontFamily;
  31864. }
  31865. var width = ctx.measureText(textDiv.textContent).width;
  31866. textLayerFrag.appendChild(textDiv);
  31867. var transform = '';
  31868. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  31869. textDivProperties.scale = textDivProperties.canvasWidth / width;
  31870. transform = 'scaleX(' + textDivProperties.scale + ')';
  31871. }
  31872. if (textDivProperties.angle !== 0) {
  31873. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  31874. }
  31875. if (transform !== '') {
  31876. textDivProperties.originalTransform = transform;
  31877. CustomStyle.setProp('transform', textDiv, transform);
  31878. }
  31879. task._textDivProperties.set(textDiv, textDivProperties);
  31880. }
  31881. task._renderingDone = true;
  31882. capability.resolve();
  31883. }
  31884. function expand(task) {
  31885. var bounds = task._bounds;
  31886. var viewport = task._viewport;
  31887. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  31888. for (var i = 0; i < expanded.length; i++) {
  31889. var div = bounds[i].div;
  31890. var divProperties = task._textDivProperties.get(div);
  31891. if (divProperties.angle === 0) {
  31892. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  31893. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  31894. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  31895. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  31896. task._textDivProperties.set(div, divProperties);
  31897. continue;
  31898. }
  31899. var e = expanded[i], b = bounds[i];
  31900. var m = b.m, c = m[0], s = m[1];
  31901. var points = [
  31902. [
  31903. 0,
  31904. 0
  31905. ],
  31906. [
  31907. 0,
  31908. b.size[1]
  31909. ],
  31910. [
  31911. b.size[0],
  31912. 0
  31913. ],
  31914. b.size
  31915. ];
  31916. var ts = new Float64Array(64);
  31917. points.forEach(function (p, i) {
  31918. var t = Util.applyTransform(p, m);
  31919. ts[i + 0] = c && (e.left - t[0]) / c;
  31920. ts[i + 4] = s && (e.top - t[1]) / s;
  31921. ts[i + 8] = c && (e.right - t[0]) / c;
  31922. ts[i + 12] = s && (e.bottom - t[1]) / s;
  31923. ts[i + 16] = s && (e.left - t[0]) / -s;
  31924. ts[i + 20] = c && (e.top - t[1]) / c;
  31925. ts[i + 24] = s && (e.right - t[0]) / -s;
  31926. ts[i + 28] = c && (e.bottom - t[1]) / c;
  31927. ts[i + 32] = c && (e.left - t[0]) / -c;
  31928. ts[i + 36] = s && (e.top - t[1]) / -s;
  31929. ts[i + 40] = c && (e.right - t[0]) / -c;
  31930. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  31931. ts[i + 48] = s && (e.left - t[0]) / s;
  31932. ts[i + 52] = c && (e.top - t[1]) / -c;
  31933. ts[i + 56] = s && (e.right - t[0]) / s;
  31934. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  31935. });
  31936. var findPositiveMin = function (ts, offset, count) {
  31937. var result = 0;
  31938. for (var i = 0; i < count; i++) {
  31939. var t = ts[offset++];
  31940. if (t > 0) {
  31941. result = result ? Math.min(t, result) : t;
  31942. }
  31943. }
  31944. return result;
  31945. };
  31946. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  31947. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  31948. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  31949. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  31950. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  31951. task._textDivProperties.set(div, divProperties);
  31952. }
  31953. }
  31954. function expandBounds(width, height, boxes) {
  31955. var bounds = boxes.map(function (box, i) {
  31956. return {
  31957. x1: box.left,
  31958. y1: box.top,
  31959. x2: box.right,
  31960. y2: box.bottom,
  31961. index: i,
  31962. x1New: undefined,
  31963. x2New: undefined
  31964. };
  31965. });
  31966. expandBoundsLTR(width, bounds);
  31967. var expanded = new Array(boxes.length);
  31968. bounds.forEach(function (b) {
  31969. var i = b.index;
  31970. expanded[i] = {
  31971. left: b.x1New,
  31972. top: 0,
  31973. right: b.x2New,
  31974. bottom: 0
  31975. };
  31976. });
  31977. boxes.map(function (box, i) {
  31978. var e = expanded[i], b = bounds[i];
  31979. b.x1 = box.top;
  31980. b.y1 = width - e.right;
  31981. b.x2 = box.bottom;
  31982. b.y2 = width - e.left;
  31983. b.index = i;
  31984. b.x1New = undefined;
  31985. b.x2New = undefined;
  31986. });
  31987. expandBoundsLTR(height, bounds);
  31988. bounds.forEach(function (b) {
  31989. var i = b.index;
  31990. expanded[i].top = b.x1New;
  31991. expanded[i].bottom = b.x2New;
  31992. });
  31993. return expanded;
  31994. }
  31995. function expandBoundsLTR(width, bounds) {
  31996. bounds.sort(function (a, b) {
  31997. return a.x1 - b.x1 || a.index - b.index;
  31998. });
  31999. var fakeBoundary = {
  32000. x1: -Infinity,
  32001. y1: -Infinity,
  32002. x2: 0,
  32003. y2: Infinity,
  32004. index: -1,
  32005. x1New: 0,
  32006. x2New: 0
  32007. };
  32008. var horizon = [{
  32009. start: -Infinity,
  32010. end: Infinity,
  32011. boundary: fakeBoundary
  32012. }];
  32013. bounds.forEach(function (boundary) {
  32014. var i = 0;
  32015. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32016. i++;
  32017. }
  32018. var j = horizon.length - 1;
  32019. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32020. j--;
  32021. }
  32022. var horizonPart, affectedBoundary;
  32023. var q, k, maxXNew = -Infinity;
  32024. for (q = i; q <= j; q++) {
  32025. horizonPart = horizon[q];
  32026. affectedBoundary = horizonPart.boundary;
  32027. var xNew;
  32028. if (affectedBoundary.x2 > boundary.x1) {
  32029. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32030. } else if (affectedBoundary.x2New === undefined) {
  32031. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32032. } else {
  32033. xNew = affectedBoundary.x2New;
  32034. }
  32035. if (xNew > maxXNew) {
  32036. maxXNew = xNew;
  32037. }
  32038. }
  32039. boundary.x1New = maxXNew;
  32040. for (q = i; q <= j; q++) {
  32041. horizonPart = horizon[q];
  32042. affectedBoundary = horizonPart.boundary;
  32043. if (affectedBoundary.x2New === undefined) {
  32044. if (affectedBoundary.x2 > boundary.x1) {
  32045. if (affectedBoundary.index > boundary.index) {
  32046. affectedBoundary.x2New = affectedBoundary.x2;
  32047. }
  32048. } else {
  32049. affectedBoundary.x2New = maxXNew;
  32050. }
  32051. } else if (affectedBoundary.x2New > maxXNew) {
  32052. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32053. }
  32054. }
  32055. var changedHorizon = [], lastBoundary = null;
  32056. for (q = i; q <= j; q++) {
  32057. horizonPart = horizon[q];
  32058. affectedBoundary = horizonPart.boundary;
  32059. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32060. if (lastBoundary === useBoundary) {
  32061. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32062. } else {
  32063. changedHorizon.push({
  32064. start: horizonPart.start,
  32065. end: horizonPart.end,
  32066. boundary: useBoundary
  32067. });
  32068. lastBoundary = useBoundary;
  32069. }
  32070. }
  32071. if (horizon[i].start < boundary.y1) {
  32072. changedHorizon[0].start = boundary.y1;
  32073. changedHorizon.unshift({
  32074. start: horizon[i].start,
  32075. end: boundary.y1,
  32076. boundary: horizon[i].boundary
  32077. });
  32078. }
  32079. if (boundary.y2 < horizon[j].end) {
  32080. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32081. changedHorizon.push({
  32082. start: boundary.y2,
  32083. end: horizon[j].end,
  32084. boundary: horizon[j].boundary
  32085. });
  32086. }
  32087. for (q = i; q <= j; q++) {
  32088. horizonPart = horizon[q];
  32089. affectedBoundary = horizonPart.boundary;
  32090. if (affectedBoundary.x2New !== undefined) {
  32091. continue;
  32092. }
  32093. var used = false;
  32094. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32095. used = horizon[k].boundary === affectedBoundary;
  32096. }
  32097. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32098. used = horizon[k].boundary === affectedBoundary;
  32099. }
  32100. for (k = 0; !used && k < changedHorizon.length; k++) {
  32101. used = changedHorizon[k].boundary === affectedBoundary;
  32102. }
  32103. if (!used) {
  32104. affectedBoundary.x2New = maxXNew;
  32105. }
  32106. }
  32107. Array.prototype.splice.apply(horizon, [
  32108. i,
  32109. j - i + 1
  32110. ].concat(changedHorizon));
  32111. });
  32112. horizon.forEach(function (horizonPart) {
  32113. var affectedBoundary = horizonPart.boundary;
  32114. if (affectedBoundary.x2New === undefined) {
  32115. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32116. }
  32117. });
  32118. }
  32119. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32120. this._textContent = textContent;
  32121. this._container = container;
  32122. this._viewport = viewport;
  32123. this._textDivs = textDivs || [];
  32124. this._textDivProperties = new WeakMap();
  32125. this._renderingDone = false;
  32126. this._canceled = false;
  32127. this._capability = createPromiseCapability();
  32128. this._renderTimer = null;
  32129. this._bounds = [];
  32130. this._enhanceTextSelection = !!enhanceTextSelection;
  32131. }
  32132. TextLayerRenderTask.prototype = {
  32133. get promise() {
  32134. return this._capability.promise;
  32135. },
  32136. cancel: function TextLayer_cancel() {
  32137. this._canceled = true;
  32138. if (this._renderTimer !== null) {
  32139. clearTimeout(this._renderTimer);
  32140. this._renderTimer = null;
  32141. }
  32142. this._capability.reject('canceled');
  32143. },
  32144. _render: function TextLayer_render(timeout) {
  32145. var textItems = this._textContent.items;
  32146. var textStyles = this._textContent.styles;
  32147. for (var i = 0, len = textItems.length; i < len; i++) {
  32148. appendText(this, textItems[i], textStyles);
  32149. }
  32150. if (!timeout) {
  32151. render(this);
  32152. } else {
  32153. var self = this;
  32154. this._renderTimer = setTimeout(function () {
  32155. render(self);
  32156. self._renderTimer = null;
  32157. }, timeout);
  32158. }
  32159. },
  32160. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32161. if (!this._enhanceTextSelection || !this._renderingDone) {
  32162. return;
  32163. }
  32164. if (this._bounds !== null) {
  32165. expand(this);
  32166. this._bounds = null;
  32167. }
  32168. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32169. var div = this._textDivs[i];
  32170. var divProperties = this._textDivProperties.get(div);
  32171. if (divProperties.isWhitespace) {
  32172. continue;
  32173. }
  32174. if (expandDivs) {
  32175. var transform = '', padding = '';
  32176. if (divProperties.scale !== 1) {
  32177. transform = 'scaleX(' + divProperties.scale + ')';
  32178. }
  32179. if (divProperties.angle !== 0) {
  32180. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32181. }
  32182. if (divProperties.paddingLeft !== 0) {
  32183. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32184. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32185. }
  32186. if (divProperties.paddingTop !== 0) {
  32187. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32188. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32189. }
  32190. if (divProperties.paddingRight !== 0) {
  32191. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32192. }
  32193. if (divProperties.paddingBottom !== 0) {
  32194. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32195. }
  32196. if (padding !== '') {
  32197. div.setAttribute('style', divProperties.style + padding);
  32198. }
  32199. if (transform !== '') {
  32200. CustomStyle.setProp('transform', div, transform);
  32201. }
  32202. } else {
  32203. div.style.padding = 0;
  32204. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32205. }
  32206. }
  32207. }
  32208. };
  32209. function renderTextLayer(renderParameters) {
  32210. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32211. task._render(renderParameters.timeout);
  32212. return task;
  32213. }
  32214. return renderTextLayer;
  32215. }();
  32216. exports.renderTextLayer = renderTextLayer;
  32217. }));
  32218. (function (root, factory) {
  32219. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32220. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32221. var shadow = sharedUtil.shadow;
  32222. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32223. var WebGLUtils = function WebGLUtilsClosure() {
  32224. function loadShader(gl, code, shaderType) {
  32225. var shader = gl.createShader(shaderType);
  32226. gl.shaderSource(shader, code);
  32227. gl.compileShader(shader);
  32228. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32229. if (!compiled) {
  32230. var errorMsg = gl.getShaderInfoLog(shader);
  32231. throw new Error('Error during shader compilation: ' + errorMsg);
  32232. }
  32233. return shader;
  32234. }
  32235. function createVertexShader(gl, code) {
  32236. return loadShader(gl, code, gl.VERTEX_SHADER);
  32237. }
  32238. function createFragmentShader(gl, code) {
  32239. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32240. }
  32241. function createProgram(gl, shaders) {
  32242. var program = gl.createProgram();
  32243. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32244. gl.attachShader(program, shaders[i]);
  32245. }
  32246. gl.linkProgram(program);
  32247. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32248. if (!linked) {
  32249. var errorMsg = gl.getProgramInfoLog(program);
  32250. throw new Error('Error during program linking: ' + errorMsg);
  32251. }
  32252. return program;
  32253. }
  32254. function createTexture(gl, image, textureId) {
  32255. gl.activeTexture(textureId);
  32256. var texture = gl.createTexture();
  32257. gl.bindTexture(gl.TEXTURE_2D, texture);
  32258. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32259. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32260. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32261. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32262. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32263. return texture;
  32264. }
  32265. var currentGL, currentCanvas;
  32266. function generateGL() {
  32267. if (currentGL) {
  32268. return;
  32269. }
  32270. currentCanvas = document.createElement('canvas');
  32271. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32272. }
  32273. var smaskVertexShaderCode = '\
  32274. attribute vec2 a_position; \
  32275. attribute vec2 a_texCoord; \
  32276. \
  32277. uniform vec2 u_resolution; \
  32278. \
  32279. varying vec2 v_texCoord; \
  32280. \
  32281. void main() { \
  32282. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32283. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32284. \
  32285. v_texCoord = a_texCoord; \
  32286. } ';
  32287. var smaskFragmentShaderCode = '\
  32288. precision mediump float; \
  32289. \
  32290. uniform vec4 u_backdrop; \
  32291. uniform int u_subtype; \
  32292. uniform sampler2D u_image; \
  32293. uniform sampler2D u_mask; \
  32294. \
  32295. varying vec2 v_texCoord; \
  32296. \
  32297. void main() { \
  32298. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32299. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32300. if (u_backdrop.a > 0.0) { \
  32301. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32302. u_backdrop.rgb * (1.0 - maskColor.a); \
  32303. } \
  32304. float lum; \
  32305. if (u_subtype == 0) { \
  32306. lum = maskColor.a; \
  32307. } else { \
  32308. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32309. maskColor.b * 0.11; \
  32310. } \
  32311. imageColor.a *= lum; \
  32312. imageColor.rgb *= imageColor.a; \
  32313. gl_FragColor = imageColor; \
  32314. } ';
  32315. var smaskCache = null;
  32316. function initSmaskGL() {
  32317. var canvas, gl;
  32318. generateGL();
  32319. canvas = currentCanvas;
  32320. currentCanvas = null;
  32321. gl = currentGL;
  32322. currentGL = null;
  32323. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32324. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32325. var program = createProgram(gl, [
  32326. vertexShader,
  32327. fragmentShader
  32328. ]);
  32329. gl.useProgram(program);
  32330. var cache = {};
  32331. cache.gl = gl;
  32332. cache.canvas = canvas;
  32333. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32334. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32335. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32336. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32337. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32338. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32339. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32340. var texCoordBuffer = gl.createBuffer();
  32341. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32342. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32343. 0.0,
  32344. 0.0,
  32345. 1.0,
  32346. 0.0,
  32347. 0.0,
  32348. 1.0,
  32349. 0.0,
  32350. 1.0,
  32351. 1.0,
  32352. 0.0,
  32353. 1.0,
  32354. 1.0
  32355. ]), gl.STATIC_DRAW);
  32356. gl.enableVertexAttribArray(texCoordLocation);
  32357. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32358. gl.uniform1i(texLayerLocation, 0);
  32359. gl.uniform1i(texMaskLocation, 1);
  32360. smaskCache = cache;
  32361. }
  32362. function composeSMask(layer, mask, properties) {
  32363. var width = layer.width, height = layer.height;
  32364. if (!smaskCache) {
  32365. initSmaskGL();
  32366. }
  32367. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32368. canvas.width = width;
  32369. canvas.height = height;
  32370. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32371. gl.uniform2f(cache.resolutionLocation, width, height);
  32372. if (properties.backdrop) {
  32373. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32374. } else {
  32375. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32376. }
  32377. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32378. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32379. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32380. var buffer = gl.createBuffer();
  32381. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32382. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32383. 0,
  32384. 0,
  32385. width,
  32386. 0,
  32387. 0,
  32388. height,
  32389. 0,
  32390. height,
  32391. width,
  32392. 0,
  32393. width,
  32394. height
  32395. ]), gl.STATIC_DRAW);
  32396. gl.enableVertexAttribArray(cache.positionLocation);
  32397. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32398. gl.clearColor(0, 0, 0, 0);
  32399. gl.enable(gl.BLEND);
  32400. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32401. gl.clear(gl.COLOR_BUFFER_BIT);
  32402. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32403. gl.flush();
  32404. gl.deleteTexture(texture);
  32405. gl.deleteTexture(maskTexture);
  32406. gl.deleteBuffer(buffer);
  32407. return canvas;
  32408. }
  32409. var figuresVertexShaderCode = '\
  32410. attribute vec2 a_position; \
  32411. attribute vec3 a_color; \
  32412. \
  32413. uniform vec2 u_resolution; \
  32414. uniform vec2 u_scale; \
  32415. uniform vec2 u_offset; \
  32416. \
  32417. varying vec4 v_color; \
  32418. \
  32419. void main() { \
  32420. vec2 position = (a_position + u_offset) * u_scale; \
  32421. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32422. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32423. \
  32424. v_color = vec4(a_color / 255.0, 1.0); \
  32425. } ';
  32426. var figuresFragmentShaderCode = '\
  32427. precision mediump float; \
  32428. \
  32429. varying vec4 v_color; \
  32430. \
  32431. void main() { \
  32432. gl_FragColor = v_color; \
  32433. } ';
  32434. var figuresCache = null;
  32435. function initFiguresGL() {
  32436. var canvas, gl;
  32437. generateGL();
  32438. canvas = currentCanvas;
  32439. currentCanvas = null;
  32440. gl = currentGL;
  32441. currentGL = null;
  32442. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32443. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32444. var program = createProgram(gl, [
  32445. vertexShader,
  32446. fragmentShader
  32447. ]);
  32448. gl.useProgram(program);
  32449. var cache = {};
  32450. cache.gl = gl;
  32451. cache.canvas = canvas;
  32452. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32453. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32454. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32455. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32456. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32457. figuresCache = cache;
  32458. }
  32459. function drawFigures(width, height, backgroundColor, figures, context) {
  32460. if (!figuresCache) {
  32461. initFiguresGL();
  32462. }
  32463. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32464. canvas.width = width;
  32465. canvas.height = height;
  32466. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32467. gl.uniform2f(cache.resolutionLocation, width, height);
  32468. var count = 0;
  32469. var i, ii, rows;
  32470. for (i = 0, ii = figures.length; i < ii; i++) {
  32471. switch (figures[i].type) {
  32472. case 'lattice':
  32473. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32474. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32475. break;
  32476. case 'triangles':
  32477. count += figures[i].coords.length;
  32478. break;
  32479. }
  32480. }
  32481. var coords = new Float32Array(count * 2);
  32482. var colors = new Uint8Array(count * 3);
  32483. var coordsMap = context.coords, colorsMap = context.colors;
  32484. var pIndex = 0, cIndex = 0;
  32485. for (i = 0, ii = figures.length; i < ii; i++) {
  32486. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32487. switch (figure.type) {
  32488. case 'lattice':
  32489. var cols = figure.verticesPerRow;
  32490. rows = ps.length / cols | 0;
  32491. for (var row = 1; row < rows; row++) {
  32492. var offset = row * cols + 1;
  32493. for (var col = 1; col < cols; col++, offset++) {
  32494. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32495. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32496. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32497. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32498. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32499. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32500. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32501. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32502. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32503. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32504. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32505. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32506. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32507. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32508. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32509. coords[pIndex + 6] = coords[pIndex + 2];
  32510. coords[pIndex + 7] = coords[pIndex + 3];
  32511. coords[pIndex + 8] = coords[pIndex + 4];
  32512. coords[pIndex + 9] = coords[pIndex + 5];
  32513. coords[pIndex + 10] = coordsMap[ps[offset]];
  32514. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32515. colors[cIndex + 9] = colors[cIndex + 3];
  32516. colors[cIndex + 10] = colors[cIndex + 4];
  32517. colors[cIndex + 11] = colors[cIndex + 5];
  32518. colors[cIndex + 12] = colors[cIndex + 6];
  32519. colors[cIndex + 13] = colors[cIndex + 7];
  32520. colors[cIndex + 14] = colors[cIndex + 8];
  32521. colors[cIndex + 15] = colorsMap[cs[offset]];
  32522. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32523. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32524. pIndex += 12;
  32525. cIndex += 18;
  32526. }
  32527. }
  32528. break;
  32529. case 'triangles':
  32530. for (var j = 0, jj = ps.length; j < jj; j++) {
  32531. coords[pIndex] = coordsMap[ps[j]];
  32532. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32533. colors[cIndex] = colorsMap[cs[j]];
  32534. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32535. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32536. pIndex += 2;
  32537. cIndex += 3;
  32538. }
  32539. break;
  32540. }
  32541. }
  32542. if (backgroundColor) {
  32543. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32544. } else {
  32545. gl.clearColor(0, 0, 0, 0);
  32546. }
  32547. gl.clear(gl.COLOR_BUFFER_BIT);
  32548. var coordsBuffer = gl.createBuffer();
  32549. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32550. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32551. gl.enableVertexAttribArray(cache.positionLocation);
  32552. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32553. var colorsBuffer = gl.createBuffer();
  32554. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32555. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32556. gl.enableVertexAttribArray(cache.colorLocation);
  32557. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32558. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32559. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32560. gl.drawArrays(gl.TRIANGLES, 0, count);
  32561. gl.flush();
  32562. gl.deleteBuffer(coordsBuffer);
  32563. gl.deleteBuffer(colorsBuffer);
  32564. return canvas;
  32565. }
  32566. function cleanup() {
  32567. if (smaskCache && smaskCache.canvas) {
  32568. smaskCache.canvas.width = 0;
  32569. smaskCache.canvas.height = 0;
  32570. }
  32571. if (figuresCache && figuresCache.canvas) {
  32572. figuresCache.canvas.width = 0;
  32573. figuresCache.canvas.height = 0;
  32574. }
  32575. smaskCache = null;
  32576. figuresCache = null;
  32577. }
  32578. return {
  32579. get isEnabled() {
  32580. if (getDefaultSetting('disableWebGL')) {
  32581. return false;
  32582. }
  32583. var enabled = false;
  32584. try {
  32585. generateGL();
  32586. enabled = !!currentGL;
  32587. } catch (e) {
  32588. }
  32589. return shadow(this, 'isEnabled', enabled);
  32590. },
  32591. composeSMask: composeSMask,
  32592. drawFigures: drawFigures,
  32593. clear: cleanup
  32594. };
  32595. }();
  32596. exports.WebGLUtils = WebGLUtils;
  32597. }));
  32598. (function (root, factory) {
  32599. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32600. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32601. var PasswordException = sharedUtil.PasswordException;
  32602. var PasswordResponses = sharedUtil.PasswordResponses;
  32603. var bytesToString = sharedUtil.bytesToString;
  32604. var warn = sharedUtil.warn;
  32605. var error = sharedUtil.error;
  32606. var assert = sharedUtil.assert;
  32607. var isInt = sharedUtil.isInt;
  32608. var stringToBytes = sharedUtil.stringToBytes;
  32609. var utf8StringToString = sharedUtil.utf8StringToString;
  32610. var Name = corePrimitives.Name;
  32611. var isName = corePrimitives.isName;
  32612. var isDict = corePrimitives.isDict;
  32613. var DecryptStream = coreStream.DecryptStream;
  32614. var ARCFourCipher = function ARCFourCipherClosure() {
  32615. function ARCFourCipher(key) {
  32616. this.a = 0;
  32617. this.b = 0;
  32618. var s = new Uint8Array(256);
  32619. var i, j = 0, tmp, keyLength = key.length;
  32620. for (i = 0; i < 256; ++i) {
  32621. s[i] = i;
  32622. }
  32623. for (i = 0; i < 256; ++i) {
  32624. tmp = s[i];
  32625. j = j + tmp + key[i % keyLength] & 0xFF;
  32626. s[i] = s[j];
  32627. s[j] = tmp;
  32628. }
  32629. this.s = s;
  32630. }
  32631. ARCFourCipher.prototype = {
  32632. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32633. var i, n = data.length, tmp, tmp2;
  32634. var a = this.a, b = this.b, s = this.s;
  32635. var output = new Uint8Array(n);
  32636. for (i = 0; i < n; ++i) {
  32637. a = a + 1 & 0xFF;
  32638. tmp = s[a];
  32639. b = b + tmp & 0xFF;
  32640. tmp2 = s[b];
  32641. s[a] = tmp2;
  32642. s[b] = tmp;
  32643. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32644. }
  32645. this.a = a;
  32646. this.b = b;
  32647. return output;
  32648. }
  32649. };
  32650. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32651. return ARCFourCipher;
  32652. }();
  32653. var calculateMD5 = function calculateMD5Closure() {
  32654. var r = new Uint8Array([
  32655. 7,
  32656. 12,
  32657. 17,
  32658. 22,
  32659. 7,
  32660. 12,
  32661. 17,
  32662. 22,
  32663. 7,
  32664. 12,
  32665. 17,
  32666. 22,
  32667. 7,
  32668. 12,
  32669. 17,
  32670. 22,
  32671. 5,
  32672. 9,
  32673. 14,
  32674. 20,
  32675. 5,
  32676. 9,
  32677. 14,
  32678. 20,
  32679. 5,
  32680. 9,
  32681. 14,
  32682. 20,
  32683. 5,
  32684. 9,
  32685. 14,
  32686. 20,
  32687. 4,
  32688. 11,
  32689. 16,
  32690. 23,
  32691. 4,
  32692. 11,
  32693. 16,
  32694. 23,
  32695. 4,
  32696. 11,
  32697. 16,
  32698. 23,
  32699. 4,
  32700. 11,
  32701. 16,
  32702. 23,
  32703. 6,
  32704. 10,
  32705. 15,
  32706. 21,
  32707. 6,
  32708. 10,
  32709. 15,
  32710. 21,
  32711. 6,
  32712. 10,
  32713. 15,
  32714. 21,
  32715. 6,
  32716. 10,
  32717. 15,
  32718. 21
  32719. ]);
  32720. var k = new Int32Array([
  32721. -680876936,
  32722. -389564586,
  32723. 606105819,
  32724. -1044525330,
  32725. -176418897,
  32726. 1200080426,
  32727. -1473231341,
  32728. -45705983,
  32729. 1770035416,
  32730. -1958414417,
  32731. -42063,
  32732. -1990404162,
  32733. 1804603682,
  32734. -40341101,
  32735. -1502002290,
  32736. 1236535329,
  32737. -165796510,
  32738. -1069501632,
  32739. 643717713,
  32740. -373897302,
  32741. -701558691,
  32742. 38016083,
  32743. -660478335,
  32744. -405537848,
  32745. 568446438,
  32746. -1019803690,
  32747. -187363961,
  32748. 1163531501,
  32749. -1444681467,
  32750. -51403784,
  32751. 1735328473,
  32752. -1926607734,
  32753. -378558,
  32754. -2022574463,
  32755. 1839030562,
  32756. -35309556,
  32757. -1530992060,
  32758. 1272893353,
  32759. -155497632,
  32760. -1094730640,
  32761. 681279174,
  32762. -358537222,
  32763. -722521979,
  32764. 76029189,
  32765. -640364487,
  32766. -421815835,
  32767. 530742520,
  32768. -995338651,
  32769. -198630844,
  32770. 1126891415,
  32771. -1416354905,
  32772. -57434055,
  32773. 1700485571,
  32774. -1894986606,
  32775. -1051523,
  32776. -2054922799,
  32777. 1873313359,
  32778. -30611744,
  32779. -1560198380,
  32780. 1309151649,
  32781. -145523070,
  32782. -1120210379,
  32783. 718787259,
  32784. -343485551
  32785. ]);
  32786. function hash(data, offset, length) {
  32787. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32788. var paddedLength = length + 72 & ~63;
  32789. var padded = new Uint8Array(paddedLength);
  32790. var i, j, n;
  32791. for (i = 0; i < length; ++i) {
  32792. padded[i] = data[offset++];
  32793. }
  32794. padded[i++] = 0x80;
  32795. n = paddedLength - 8;
  32796. while (i < n) {
  32797. padded[i++] = 0;
  32798. }
  32799. padded[i++] = length << 3 & 0xFF;
  32800. padded[i++] = length >> 5 & 0xFF;
  32801. padded[i++] = length >> 13 & 0xFF;
  32802. padded[i++] = length >> 21 & 0xFF;
  32803. padded[i++] = length >>> 29 & 0xFF;
  32804. padded[i++] = 0;
  32805. padded[i++] = 0;
  32806. padded[i++] = 0;
  32807. var w = new Int32Array(16);
  32808. for (i = 0; i < paddedLength;) {
  32809. for (j = 0; j < 16; ++j, i += 4) {
  32810. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32811. }
  32812. var a = h0, b = h1, c = h2, d = h3, f, g;
  32813. for (j = 0; j < 64; ++j) {
  32814. if (j < 16) {
  32815. f = b & c | ~b & d;
  32816. g = j;
  32817. } else if (j < 32) {
  32818. f = d & b | ~d & c;
  32819. g = 5 * j + 1 & 15;
  32820. } else if (j < 48) {
  32821. f = b ^ c ^ d;
  32822. g = 3 * j + 5 & 15;
  32823. } else {
  32824. f = c ^ (b | ~d);
  32825. g = 7 * j & 15;
  32826. }
  32827. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  32828. d = c;
  32829. c = b;
  32830. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  32831. a = tmp;
  32832. }
  32833. h0 = h0 + a | 0;
  32834. h1 = h1 + b | 0;
  32835. h2 = h2 + c | 0;
  32836. h3 = h3 + d | 0;
  32837. }
  32838. return new Uint8Array([
  32839. h0 & 0xFF,
  32840. h0 >> 8 & 0xFF,
  32841. h0 >> 16 & 0xFF,
  32842. h0 >>> 24 & 0xFF,
  32843. h1 & 0xFF,
  32844. h1 >> 8 & 0xFF,
  32845. h1 >> 16 & 0xFF,
  32846. h1 >>> 24 & 0xFF,
  32847. h2 & 0xFF,
  32848. h2 >> 8 & 0xFF,
  32849. h2 >> 16 & 0xFF,
  32850. h2 >>> 24 & 0xFF,
  32851. h3 & 0xFF,
  32852. h3 >> 8 & 0xFF,
  32853. h3 >> 16 & 0xFF,
  32854. h3 >>> 24 & 0xFF
  32855. ]);
  32856. }
  32857. return hash;
  32858. }();
  32859. var Word64 = function Word64Closure() {
  32860. function Word64(highInteger, lowInteger) {
  32861. this.high = highInteger | 0;
  32862. this.low = lowInteger | 0;
  32863. }
  32864. Word64.prototype = {
  32865. and: function Word64_and(word) {
  32866. this.high &= word.high;
  32867. this.low &= word.low;
  32868. },
  32869. xor: function Word64_xor(word) {
  32870. this.high ^= word.high;
  32871. this.low ^= word.low;
  32872. },
  32873. or: function Word64_or(word) {
  32874. this.high |= word.high;
  32875. this.low |= word.low;
  32876. },
  32877. shiftRight: function Word64_shiftRight(places) {
  32878. if (places >= 32) {
  32879. this.low = this.high >>> places - 32 | 0;
  32880. this.high = 0;
  32881. } else {
  32882. this.low = this.low >>> places | this.high << 32 - places;
  32883. this.high = this.high >>> places | 0;
  32884. }
  32885. },
  32886. shiftLeft: function Word64_shiftLeft(places) {
  32887. if (places >= 32) {
  32888. this.high = this.low << places - 32;
  32889. this.low = 0;
  32890. } else {
  32891. this.high = this.high << places | this.low >>> 32 - places;
  32892. this.low = this.low << places;
  32893. }
  32894. },
  32895. rotateRight: function Word64_rotateRight(places) {
  32896. var low, high;
  32897. if (places & 32) {
  32898. high = this.low;
  32899. low = this.high;
  32900. } else {
  32901. low = this.low;
  32902. high = this.high;
  32903. }
  32904. places &= 31;
  32905. this.low = low >>> places | high << 32 - places;
  32906. this.high = high >>> places | low << 32 - places;
  32907. },
  32908. not: function Word64_not() {
  32909. this.high = ~this.high;
  32910. this.low = ~this.low;
  32911. },
  32912. add: function Word64_add(word) {
  32913. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  32914. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  32915. if (lowAdd > 0xFFFFFFFF) {
  32916. highAdd += 1;
  32917. }
  32918. this.low = lowAdd | 0;
  32919. this.high = highAdd | 0;
  32920. },
  32921. copyTo: function Word64_copyTo(bytes, offset) {
  32922. bytes[offset] = this.high >>> 24 & 0xFF;
  32923. bytes[offset + 1] = this.high >> 16 & 0xFF;
  32924. bytes[offset + 2] = this.high >> 8 & 0xFF;
  32925. bytes[offset + 3] = this.high & 0xFF;
  32926. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  32927. bytes[offset + 5] = this.low >> 16 & 0xFF;
  32928. bytes[offset + 6] = this.low >> 8 & 0xFF;
  32929. bytes[offset + 7] = this.low & 0xFF;
  32930. },
  32931. assign: function Word64_assign(word) {
  32932. this.high = word.high;
  32933. this.low = word.low;
  32934. }
  32935. };
  32936. return Word64;
  32937. }();
  32938. var calculateSHA256 = function calculateSHA256Closure() {
  32939. function rotr(x, n) {
  32940. return x >>> n | x << 32 - n;
  32941. }
  32942. function ch(x, y, z) {
  32943. return x & y ^ ~x & z;
  32944. }
  32945. function maj(x, y, z) {
  32946. return x & y ^ x & z ^ y & z;
  32947. }
  32948. function sigma(x) {
  32949. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  32950. }
  32951. function sigmaPrime(x) {
  32952. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  32953. }
  32954. function littleSigma(x) {
  32955. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  32956. }
  32957. function littleSigmaPrime(x) {
  32958. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  32959. }
  32960. var k = [
  32961. 0x428a2f98,
  32962. 0x71374491,
  32963. 0xb5c0fbcf,
  32964. 0xe9b5dba5,
  32965. 0x3956c25b,
  32966. 0x59f111f1,
  32967. 0x923f82a4,
  32968. 0xab1c5ed5,
  32969. 0xd807aa98,
  32970. 0x12835b01,
  32971. 0x243185be,
  32972. 0x550c7dc3,
  32973. 0x72be5d74,
  32974. 0x80deb1fe,
  32975. 0x9bdc06a7,
  32976. 0xc19bf174,
  32977. 0xe49b69c1,
  32978. 0xefbe4786,
  32979. 0x0fc19dc6,
  32980. 0x240ca1cc,
  32981. 0x2de92c6f,
  32982. 0x4a7484aa,
  32983. 0x5cb0a9dc,
  32984. 0x76f988da,
  32985. 0x983e5152,
  32986. 0xa831c66d,
  32987. 0xb00327c8,
  32988. 0xbf597fc7,
  32989. 0xc6e00bf3,
  32990. 0xd5a79147,
  32991. 0x06ca6351,
  32992. 0x14292967,
  32993. 0x27b70a85,
  32994. 0x2e1b2138,
  32995. 0x4d2c6dfc,
  32996. 0x53380d13,
  32997. 0x650a7354,
  32998. 0x766a0abb,
  32999. 0x81c2c92e,
  33000. 0x92722c85,
  33001. 0xa2bfe8a1,
  33002. 0xa81a664b,
  33003. 0xc24b8b70,
  33004. 0xc76c51a3,
  33005. 0xd192e819,
  33006. 0xd6990624,
  33007. 0xf40e3585,
  33008. 0x106aa070,
  33009. 0x19a4c116,
  33010. 0x1e376c08,
  33011. 0x2748774c,
  33012. 0x34b0bcb5,
  33013. 0x391c0cb3,
  33014. 0x4ed8aa4a,
  33015. 0x5b9cca4f,
  33016. 0x682e6ff3,
  33017. 0x748f82ee,
  33018. 0x78a5636f,
  33019. 0x84c87814,
  33020. 0x8cc70208,
  33021. 0x90befffa,
  33022. 0xa4506ceb,
  33023. 0xbef9a3f7,
  33024. 0xc67178f2
  33025. ];
  33026. function hash(data, offset, length) {
  33027. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33028. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33029. var padded = new Uint8Array(paddedLength);
  33030. var i, j, n;
  33031. for (i = 0; i < length; ++i) {
  33032. padded[i] = data[offset++];
  33033. }
  33034. padded[i++] = 0x80;
  33035. n = paddedLength - 8;
  33036. while (i < n) {
  33037. padded[i++] = 0;
  33038. }
  33039. padded[i++] = 0;
  33040. padded[i++] = 0;
  33041. padded[i++] = 0;
  33042. padded[i++] = length >>> 29 & 0xFF;
  33043. padded[i++] = length >> 21 & 0xFF;
  33044. padded[i++] = length >> 13 & 0xFF;
  33045. padded[i++] = length >> 5 & 0xFF;
  33046. padded[i++] = length << 3 & 0xFF;
  33047. var w = new Uint32Array(64);
  33048. for (i = 0; i < paddedLength;) {
  33049. for (j = 0; j < 16; ++j) {
  33050. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33051. i += 4;
  33052. }
  33053. for (j = 16; j < 64; ++j) {
  33054. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33055. }
  33056. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33057. for (j = 0; j < 64; ++j) {
  33058. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33059. t2 = sigma(a) + maj(a, b, c);
  33060. h = g;
  33061. g = f;
  33062. f = e;
  33063. e = d + t1 | 0;
  33064. d = c;
  33065. c = b;
  33066. b = a;
  33067. a = t1 + t2 | 0;
  33068. }
  33069. h0 = h0 + a | 0;
  33070. h1 = h1 + b | 0;
  33071. h2 = h2 + c | 0;
  33072. h3 = h3 + d | 0;
  33073. h4 = h4 + e | 0;
  33074. h5 = h5 + f | 0;
  33075. h6 = h6 + g | 0;
  33076. h7 = h7 + h | 0;
  33077. }
  33078. return new Uint8Array([
  33079. h0 >> 24 & 0xFF,
  33080. h0 >> 16 & 0xFF,
  33081. h0 >> 8 & 0xFF,
  33082. h0 & 0xFF,
  33083. h1 >> 24 & 0xFF,
  33084. h1 >> 16 & 0xFF,
  33085. h1 >> 8 & 0xFF,
  33086. h1 & 0xFF,
  33087. h2 >> 24 & 0xFF,
  33088. h2 >> 16 & 0xFF,
  33089. h2 >> 8 & 0xFF,
  33090. h2 & 0xFF,
  33091. h3 >> 24 & 0xFF,
  33092. h3 >> 16 & 0xFF,
  33093. h3 >> 8 & 0xFF,
  33094. h3 & 0xFF,
  33095. h4 >> 24 & 0xFF,
  33096. h4 >> 16 & 0xFF,
  33097. h4 >> 8 & 0xFF,
  33098. h4 & 0xFF,
  33099. h5 >> 24 & 0xFF,
  33100. h5 >> 16 & 0xFF,
  33101. h5 >> 8 & 0xFF,
  33102. h5 & 0xFF,
  33103. h6 >> 24 & 0xFF,
  33104. h6 >> 16 & 0xFF,
  33105. h6 >> 8 & 0xFF,
  33106. h6 & 0xFF,
  33107. h7 >> 24 & 0xFF,
  33108. h7 >> 16 & 0xFF,
  33109. h7 >> 8 & 0xFF,
  33110. h7 & 0xFF
  33111. ]);
  33112. }
  33113. return hash;
  33114. }();
  33115. var calculateSHA512 = function calculateSHA512Closure() {
  33116. function ch(result, x, y, z, tmp) {
  33117. result.assign(x);
  33118. result.and(y);
  33119. tmp.assign(x);
  33120. tmp.not();
  33121. tmp.and(z);
  33122. result.xor(tmp);
  33123. }
  33124. function maj(result, x, y, z, tmp) {
  33125. result.assign(x);
  33126. result.and(y);
  33127. tmp.assign(x);
  33128. tmp.and(z);
  33129. result.xor(tmp);
  33130. tmp.assign(y);
  33131. tmp.and(z);
  33132. result.xor(tmp);
  33133. }
  33134. function sigma(result, x, tmp) {
  33135. result.assign(x);
  33136. result.rotateRight(28);
  33137. tmp.assign(x);
  33138. tmp.rotateRight(34);
  33139. result.xor(tmp);
  33140. tmp.assign(x);
  33141. tmp.rotateRight(39);
  33142. result.xor(tmp);
  33143. }
  33144. function sigmaPrime(result, x, tmp) {
  33145. result.assign(x);
  33146. result.rotateRight(14);
  33147. tmp.assign(x);
  33148. tmp.rotateRight(18);
  33149. result.xor(tmp);
  33150. tmp.assign(x);
  33151. tmp.rotateRight(41);
  33152. result.xor(tmp);
  33153. }
  33154. function littleSigma(result, x, tmp) {
  33155. result.assign(x);
  33156. result.rotateRight(1);
  33157. tmp.assign(x);
  33158. tmp.rotateRight(8);
  33159. result.xor(tmp);
  33160. tmp.assign(x);
  33161. tmp.shiftRight(7);
  33162. result.xor(tmp);
  33163. }
  33164. function littleSigmaPrime(result, x, tmp) {
  33165. result.assign(x);
  33166. result.rotateRight(19);
  33167. tmp.assign(x);
  33168. tmp.rotateRight(61);
  33169. result.xor(tmp);
  33170. tmp.assign(x);
  33171. tmp.shiftRight(6);
  33172. result.xor(tmp);
  33173. }
  33174. var k = [
  33175. new Word64(0x428a2f98, 0xd728ae22),
  33176. new Word64(0x71374491, 0x23ef65cd),
  33177. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33178. new Word64(0xe9b5dba5, 0x8189dbbc),
  33179. new Word64(0x3956c25b, 0xf348b538),
  33180. new Word64(0x59f111f1, 0xb605d019),
  33181. new Word64(0x923f82a4, 0xaf194f9b),
  33182. new Word64(0xab1c5ed5, 0xda6d8118),
  33183. new Word64(0xd807aa98, 0xa3030242),
  33184. new Word64(0x12835b01, 0x45706fbe),
  33185. new Word64(0x243185be, 0x4ee4b28c),
  33186. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33187. new Word64(0x72be5d74, 0xf27b896f),
  33188. new Word64(0x80deb1fe, 0x3b1696b1),
  33189. new Word64(0x9bdc06a7, 0x25c71235),
  33190. new Word64(0xc19bf174, 0xcf692694),
  33191. new Word64(0xe49b69c1, 0x9ef14ad2),
  33192. new Word64(0xefbe4786, 0x384f25e3),
  33193. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33194. new Word64(0x240ca1cc, 0x77ac9c65),
  33195. new Word64(0x2de92c6f, 0x592b0275),
  33196. new Word64(0x4a7484aa, 0x6ea6e483),
  33197. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33198. new Word64(0x76f988da, 0x831153b5),
  33199. new Word64(0x983e5152, 0xee66dfab),
  33200. new Word64(0xa831c66d, 0x2db43210),
  33201. new Word64(0xb00327c8, 0x98fb213f),
  33202. new Word64(0xbf597fc7, 0xbeef0ee4),
  33203. new Word64(0xc6e00bf3, 0x3da88fc2),
  33204. new Word64(0xd5a79147, 0x930aa725),
  33205. new Word64(0x06ca6351, 0xe003826f),
  33206. new Word64(0x14292967, 0x0a0e6e70),
  33207. new Word64(0x27b70a85, 0x46d22ffc),
  33208. new Word64(0x2e1b2138, 0x5c26c926),
  33209. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33210. new Word64(0x53380d13, 0x9d95b3df),
  33211. new Word64(0x650a7354, 0x8baf63de),
  33212. new Word64(0x766a0abb, 0x3c77b2a8),
  33213. new Word64(0x81c2c92e, 0x47edaee6),
  33214. new Word64(0x92722c85, 0x1482353b),
  33215. new Word64(0xa2bfe8a1, 0x4cf10364),
  33216. new Word64(0xa81a664b, 0xbc423001),
  33217. new Word64(0xc24b8b70, 0xd0f89791),
  33218. new Word64(0xc76c51a3, 0x0654be30),
  33219. new Word64(0xd192e819, 0xd6ef5218),
  33220. new Word64(0xd6990624, 0x5565a910),
  33221. new Word64(0xf40e3585, 0x5771202a),
  33222. new Word64(0x106aa070, 0x32bbd1b8),
  33223. new Word64(0x19a4c116, 0xb8d2d0c8),
  33224. new Word64(0x1e376c08, 0x5141ab53),
  33225. new Word64(0x2748774c, 0xdf8eeb99),
  33226. new Word64(0x34b0bcb5, 0xe19b48a8),
  33227. new Word64(0x391c0cb3, 0xc5c95a63),
  33228. new Word64(0x4ed8aa4a, 0xe3418acb),
  33229. new Word64(0x5b9cca4f, 0x7763e373),
  33230. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33231. new Word64(0x748f82ee, 0x5defb2fc),
  33232. new Word64(0x78a5636f, 0x43172f60),
  33233. new Word64(0x84c87814, 0xa1f0ab72),
  33234. new Word64(0x8cc70208, 0x1a6439ec),
  33235. new Word64(0x90befffa, 0x23631e28),
  33236. new Word64(0xa4506ceb, 0xde82bde9),
  33237. new Word64(0xbef9a3f7, 0xb2c67915),
  33238. new Word64(0xc67178f2, 0xe372532b),
  33239. new Word64(0xca273ece, 0xea26619c),
  33240. new Word64(0xd186b8c7, 0x21c0c207),
  33241. new Word64(0xeada7dd6, 0xcde0eb1e),
  33242. new Word64(0xf57d4f7f, 0xee6ed178),
  33243. new Word64(0x06f067aa, 0x72176fba),
  33244. new Word64(0x0a637dc5, 0xa2c898a6),
  33245. new Word64(0x113f9804, 0xbef90dae),
  33246. new Word64(0x1b710b35, 0x131c471b),
  33247. new Word64(0x28db77f5, 0x23047d84),
  33248. new Word64(0x32caab7b, 0x40c72493),
  33249. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33250. new Word64(0x431d67c4, 0x9c100d4c),
  33251. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33252. new Word64(0x597f299c, 0xfc657e2a),
  33253. new Word64(0x5fcb6fab, 0x3ad6faec),
  33254. new Word64(0x6c44198c, 0x4a475817)
  33255. ];
  33256. function hash(data, offset, length, mode384) {
  33257. mode384 = !!mode384;
  33258. var h0, h1, h2, h3, h4, h5, h6, h7;
  33259. if (!mode384) {
  33260. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33261. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33262. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33263. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33264. h4 = new Word64(0x510e527f, 0xade682d1);
  33265. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33266. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33267. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33268. } else {
  33269. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33270. h1 = new Word64(0x629a292a, 0x367cd507);
  33271. h2 = new Word64(0x9159015a, 0x3070dd17);
  33272. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33273. h4 = new Word64(0x67332667, 0xffc00b31);
  33274. h5 = new Word64(0x8eb44a87, 0x68581511);
  33275. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33276. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33277. }
  33278. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33279. var padded = new Uint8Array(paddedLength);
  33280. var i, j, n;
  33281. for (i = 0; i < length; ++i) {
  33282. padded[i] = data[offset++];
  33283. }
  33284. padded[i++] = 0x80;
  33285. n = paddedLength - 16;
  33286. while (i < n) {
  33287. padded[i++] = 0;
  33288. }
  33289. padded[i++] = 0;
  33290. padded[i++] = 0;
  33291. padded[i++] = 0;
  33292. padded[i++] = 0;
  33293. padded[i++] = 0;
  33294. padded[i++] = 0;
  33295. padded[i++] = 0;
  33296. padded[i++] = 0;
  33297. padded[i++] = 0;
  33298. padded[i++] = 0;
  33299. padded[i++] = 0;
  33300. padded[i++] = length >>> 29 & 0xFF;
  33301. padded[i++] = length >> 21 & 0xFF;
  33302. padded[i++] = length >> 13 & 0xFF;
  33303. padded[i++] = length >> 5 & 0xFF;
  33304. padded[i++] = length << 3 & 0xFF;
  33305. var w = new Array(80);
  33306. for (i = 0; i < 80; i++) {
  33307. w[i] = new Word64(0, 0);
  33308. }
  33309. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33310. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33311. var g = new Word64(0, 0), h = new Word64(0, 0);
  33312. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33313. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33314. for (i = 0; i < paddedLength;) {
  33315. for (j = 0; j < 16; ++j) {
  33316. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33317. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33318. i += 8;
  33319. }
  33320. for (j = 16; j < 80; ++j) {
  33321. tmp3 = w[j];
  33322. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33323. tmp3.add(w[j - 7]);
  33324. littleSigma(tmp1, w[j - 15], tmp2);
  33325. tmp3.add(tmp1);
  33326. tmp3.add(w[j - 16]);
  33327. }
  33328. a.assign(h0);
  33329. b.assign(h1);
  33330. c.assign(h2);
  33331. d.assign(h3);
  33332. e.assign(h4);
  33333. f.assign(h5);
  33334. g.assign(h6);
  33335. h.assign(h7);
  33336. for (j = 0; j < 80; ++j) {
  33337. t1.assign(h);
  33338. sigmaPrime(tmp1, e, tmp2);
  33339. t1.add(tmp1);
  33340. ch(tmp1, e, f, g, tmp2);
  33341. t1.add(tmp1);
  33342. t1.add(k[j]);
  33343. t1.add(w[j]);
  33344. sigma(t2, a, tmp2);
  33345. maj(tmp1, a, b, c, tmp2);
  33346. t2.add(tmp1);
  33347. tmp3 = h;
  33348. h = g;
  33349. g = f;
  33350. f = e;
  33351. d.add(t1);
  33352. e = d;
  33353. d = c;
  33354. c = b;
  33355. b = a;
  33356. tmp3.assign(t1);
  33357. tmp3.add(t2);
  33358. a = tmp3;
  33359. }
  33360. h0.add(a);
  33361. h1.add(b);
  33362. h2.add(c);
  33363. h3.add(d);
  33364. h4.add(e);
  33365. h5.add(f);
  33366. h6.add(g);
  33367. h7.add(h);
  33368. }
  33369. var result;
  33370. if (!mode384) {
  33371. result = new Uint8Array(64);
  33372. h0.copyTo(result, 0);
  33373. h1.copyTo(result, 8);
  33374. h2.copyTo(result, 16);
  33375. h3.copyTo(result, 24);
  33376. h4.copyTo(result, 32);
  33377. h5.copyTo(result, 40);
  33378. h6.copyTo(result, 48);
  33379. h7.copyTo(result, 56);
  33380. } else {
  33381. result = new Uint8Array(48);
  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. }
  33389. return result;
  33390. }
  33391. return hash;
  33392. }();
  33393. var calculateSHA384 = function calculateSHA384Closure() {
  33394. function hash(data, offset, length) {
  33395. return calculateSHA512(data, offset, length, true);
  33396. }
  33397. return hash;
  33398. }();
  33399. var NullCipher = function NullCipherClosure() {
  33400. function NullCipher() {
  33401. }
  33402. NullCipher.prototype = {
  33403. decryptBlock: function NullCipher_decryptBlock(data) {
  33404. return data;
  33405. }
  33406. };
  33407. return NullCipher;
  33408. }();
  33409. var AES128Cipher = function AES128CipherClosure() {
  33410. var rcon = new Uint8Array([
  33411. 0x8d,
  33412. 0x01,
  33413. 0x02,
  33414. 0x04,
  33415. 0x08,
  33416. 0x10,
  33417. 0x20,
  33418. 0x40,
  33419. 0x80,
  33420. 0x1b,
  33421. 0x36,
  33422. 0x6c,
  33423. 0xd8,
  33424. 0xab,
  33425. 0x4d,
  33426. 0x9a,
  33427. 0x2f,
  33428. 0x5e,
  33429. 0xbc,
  33430. 0x63,
  33431. 0xc6,
  33432. 0x97,
  33433. 0x35,
  33434. 0x6a,
  33435. 0xd4,
  33436. 0xb3,
  33437. 0x7d,
  33438. 0xfa,
  33439. 0xef,
  33440. 0xc5,
  33441. 0x91,
  33442. 0x39,
  33443. 0x72,
  33444. 0xe4,
  33445. 0xd3,
  33446. 0xbd,
  33447. 0x61,
  33448. 0xc2,
  33449. 0x9f,
  33450. 0x25,
  33451. 0x4a,
  33452. 0x94,
  33453. 0x33,
  33454. 0x66,
  33455. 0xcc,
  33456. 0x83,
  33457. 0x1d,
  33458. 0x3a,
  33459. 0x74,
  33460. 0xe8,
  33461. 0xcb,
  33462. 0x8d,
  33463. 0x01,
  33464. 0x02,
  33465. 0x04,
  33466. 0x08,
  33467. 0x10,
  33468. 0x20,
  33469. 0x40,
  33470. 0x80,
  33471. 0x1b,
  33472. 0x36,
  33473. 0x6c,
  33474. 0xd8,
  33475. 0xab,
  33476. 0x4d,
  33477. 0x9a,
  33478. 0x2f,
  33479. 0x5e,
  33480. 0xbc,
  33481. 0x63,
  33482. 0xc6,
  33483. 0x97,
  33484. 0x35,
  33485. 0x6a,
  33486. 0xd4,
  33487. 0xb3,
  33488. 0x7d,
  33489. 0xfa,
  33490. 0xef,
  33491. 0xc5,
  33492. 0x91,
  33493. 0x39,
  33494. 0x72,
  33495. 0xe4,
  33496. 0xd3,
  33497. 0xbd,
  33498. 0x61,
  33499. 0xc2,
  33500. 0x9f,
  33501. 0x25,
  33502. 0x4a,
  33503. 0x94,
  33504. 0x33,
  33505. 0x66,
  33506. 0xcc,
  33507. 0x83,
  33508. 0x1d,
  33509. 0x3a,
  33510. 0x74,
  33511. 0xe8,
  33512. 0xcb,
  33513. 0x8d,
  33514. 0x01,
  33515. 0x02,
  33516. 0x04,
  33517. 0x08,
  33518. 0x10,
  33519. 0x20,
  33520. 0x40,
  33521. 0x80,
  33522. 0x1b,
  33523. 0x36,
  33524. 0x6c,
  33525. 0xd8,
  33526. 0xab,
  33527. 0x4d,
  33528. 0x9a,
  33529. 0x2f,
  33530. 0x5e,
  33531. 0xbc,
  33532. 0x63,
  33533. 0xc6,
  33534. 0x97,
  33535. 0x35,
  33536. 0x6a,
  33537. 0xd4,
  33538. 0xb3,
  33539. 0x7d,
  33540. 0xfa,
  33541. 0xef,
  33542. 0xc5,
  33543. 0x91,
  33544. 0x39,
  33545. 0x72,
  33546. 0xe4,
  33547. 0xd3,
  33548. 0xbd,
  33549. 0x61,
  33550. 0xc2,
  33551. 0x9f,
  33552. 0x25,
  33553. 0x4a,
  33554. 0x94,
  33555. 0x33,
  33556. 0x66,
  33557. 0xcc,
  33558. 0x83,
  33559. 0x1d,
  33560. 0x3a,
  33561. 0x74,
  33562. 0xe8,
  33563. 0xcb,
  33564. 0x8d,
  33565. 0x01,
  33566. 0x02,
  33567. 0x04,
  33568. 0x08,
  33569. 0x10,
  33570. 0x20,
  33571. 0x40,
  33572. 0x80,
  33573. 0x1b,
  33574. 0x36,
  33575. 0x6c,
  33576. 0xd8,
  33577. 0xab,
  33578. 0x4d,
  33579. 0x9a,
  33580. 0x2f,
  33581. 0x5e,
  33582. 0xbc,
  33583. 0x63,
  33584. 0xc6,
  33585. 0x97,
  33586. 0x35,
  33587. 0x6a,
  33588. 0xd4,
  33589. 0xb3,
  33590. 0x7d,
  33591. 0xfa,
  33592. 0xef,
  33593. 0xc5,
  33594. 0x91,
  33595. 0x39,
  33596. 0x72,
  33597. 0xe4,
  33598. 0xd3,
  33599. 0xbd,
  33600. 0x61,
  33601. 0xc2,
  33602. 0x9f,
  33603. 0x25,
  33604. 0x4a,
  33605. 0x94,
  33606. 0x33,
  33607. 0x66,
  33608. 0xcc,
  33609. 0x83,
  33610. 0x1d,
  33611. 0x3a,
  33612. 0x74,
  33613. 0xe8,
  33614. 0xcb,
  33615. 0x8d,
  33616. 0x01,
  33617. 0x02,
  33618. 0x04,
  33619. 0x08,
  33620. 0x10,
  33621. 0x20,
  33622. 0x40,
  33623. 0x80,
  33624. 0x1b,
  33625. 0x36,
  33626. 0x6c,
  33627. 0xd8,
  33628. 0xab,
  33629. 0x4d,
  33630. 0x9a,
  33631. 0x2f,
  33632. 0x5e,
  33633. 0xbc,
  33634. 0x63,
  33635. 0xc6,
  33636. 0x97,
  33637. 0x35,
  33638. 0x6a,
  33639. 0xd4,
  33640. 0xb3,
  33641. 0x7d,
  33642. 0xfa,
  33643. 0xef,
  33644. 0xc5,
  33645. 0x91,
  33646. 0x39,
  33647. 0x72,
  33648. 0xe4,
  33649. 0xd3,
  33650. 0xbd,
  33651. 0x61,
  33652. 0xc2,
  33653. 0x9f,
  33654. 0x25,
  33655. 0x4a,
  33656. 0x94,
  33657. 0x33,
  33658. 0x66,
  33659. 0xcc,
  33660. 0x83,
  33661. 0x1d,
  33662. 0x3a,
  33663. 0x74,
  33664. 0xe8,
  33665. 0xcb,
  33666. 0x8d
  33667. ]);
  33668. var s = new Uint8Array([
  33669. 0x63,
  33670. 0x7c,
  33671. 0x77,
  33672. 0x7b,
  33673. 0xf2,
  33674. 0x6b,
  33675. 0x6f,
  33676. 0xc5,
  33677. 0x30,
  33678. 0x01,
  33679. 0x67,
  33680. 0x2b,
  33681. 0xfe,
  33682. 0xd7,
  33683. 0xab,
  33684. 0x76,
  33685. 0xca,
  33686. 0x82,
  33687. 0xc9,
  33688. 0x7d,
  33689. 0xfa,
  33690. 0x59,
  33691. 0x47,
  33692. 0xf0,
  33693. 0xad,
  33694. 0xd4,
  33695. 0xa2,
  33696. 0xaf,
  33697. 0x9c,
  33698. 0xa4,
  33699. 0x72,
  33700. 0xc0,
  33701. 0xb7,
  33702. 0xfd,
  33703. 0x93,
  33704. 0x26,
  33705. 0x36,
  33706. 0x3f,
  33707. 0xf7,
  33708. 0xcc,
  33709. 0x34,
  33710. 0xa5,
  33711. 0xe5,
  33712. 0xf1,
  33713. 0x71,
  33714. 0xd8,
  33715. 0x31,
  33716. 0x15,
  33717. 0x04,
  33718. 0xc7,
  33719. 0x23,
  33720. 0xc3,
  33721. 0x18,
  33722. 0x96,
  33723. 0x05,
  33724. 0x9a,
  33725. 0x07,
  33726. 0x12,
  33727. 0x80,
  33728. 0xe2,
  33729. 0xeb,
  33730. 0x27,
  33731. 0xb2,
  33732. 0x75,
  33733. 0x09,
  33734. 0x83,
  33735. 0x2c,
  33736. 0x1a,
  33737. 0x1b,
  33738. 0x6e,
  33739. 0x5a,
  33740. 0xa0,
  33741. 0x52,
  33742. 0x3b,
  33743. 0xd6,
  33744. 0xb3,
  33745. 0x29,
  33746. 0xe3,
  33747. 0x2f,
  33748. 0x84,
  33749. 0x53,
  33750. 0xd1,
  33751. 0x00,
  33752. 0xed,
  33753. 0x20,
  33754. 0xfc,
  33755. 0xb1,
  33756. 0x5b,
  33757. 0x6a,
  33758. 0xcb,
  33759. 0xbe,
  33760. 0x39,
  33761. 0x4a,
  33762. 0x4c,
  33763. 0x58,
  33764. 0xcf,
  33765. 0xd0,
  33766. 0xef,
  33767. 0xaa,
  33768. 0xfb,
  33769. 0x43,
  33770. 0x4d,
  33771. 0x33,
  33772. 0x85,
  33773. 0x45,
  33774. 0xf9,
  33775. 0x02,
  33776. 0x7f,
  33777. 0x50,
  33778. 0x3c,
  33779. 0x9f,
  33780. 0xa8,
  33781. 0x51,
  33782. 0xa3,
  33783. 0x40,
  33784. 0x8f,
  33785. 0x92,
  33786. 0x9d,
  33787. 0x38,
  33788. 0xf5,
  33789. 0xbc,
  33790. 0xb6,
  33791. 0xda,
  33792. 0x21,
  33793. 0x10,
  33794. 0xff,
  33795. 0xf3,
  33796. 0xd2,
  33797. 0xcd,
  33798. 0x0c,
  33799. 0x13,
  33800. 0xec,
  33801. 0x5f,
  33802. 0x97,
  33803. 0x44,
  33804. 0x17,
  33805. 0xc4,
  33806. 0xa7,
  33807. 0x7e,
  33808. 0x3d,
  33809. 0x64,
  33810. 0x5d,
  33811. 0x19,
  33812. 0x73,
  33813. 0x60,
  33814. 0x81,
  33815. 0x4f,
  33816. 0xdc,
  33817. 0x22,
  33818. 0x2a,
  33819. 0x90,
  33820. 0x88,
  33821. 0x46,
  33822. 0xee,
  33823. 0xb8,
  33824. 0x14,
  33825. 0xde,
  33826. 0x5e,
  33827. 0x0b,
  33828. 0xdb,
  33829. 0xe0,
  33830. 0x32,
  33831. 0x3a,
  33832. 0x0a,
  33833. 0x49,
  33834. 0x06,
  33835. 0x24,
  33836. 0x5c,
  33837. 0xc2,
  33838. 0xd3,
  33839. 0xac,
  33840. 0x62,
  33841. 0x91,
  33842. 0x95,
  33843. 0xe4,
  33844. 0x79,
  33845. 0xe7,
  33846. 0xc8,
  33847. 0x37,
  33848. 0x6d,
  33849. 0x8d,
  33850. 0xd5,
  33851. 0x4e,
  33852. 0xa9,
  33853. 0x6c,
  33854. 0x56,
  33855. 0xf4,
  33856. 0xea,
  33857. 0x65,
  33858. 0x7a,
  33859. 0xae,
  33860. 0x08,
  33861. 0xba,
  33862. 0x78,
  33863. 0x25,
  33864. 0x2e,
  33865. 0x1c,
  33866. 0xa6,
  33867. 0xb4,
  33868. 0xc6,
  33869. 0xe8,
  33870. 0xdd,
  33871. 0x74,
  33872. 0x1f,
  33873. 0x4b,
  33874. 0xbd,
  33875. 0x8b,
  33876. 0x8a,
  33877. 0x70,
  33878. 0x3e,
  33879. 0xb5,
  33880. 0x66,
  33881. 0x48,
  33882. 0x03,
  33883. 0xf6,
  33884. 0x0e,
  33885. 0x61,
  33886. 0x35,
  33887. 0x57,
  33888. 0xb9,
  33889. 0x86,
  33890. 0xc1,
  33891. 0x1d,
  33892. 0x9e,
  33893. 0xe1,
  33894. 0xf8,
  33895. 0x98,
  33896. 0x11,
  33897. 0x69,
  33898. 0xd9,
  33899. 0x8e,
  33900. 0x94,
  33901. 0x9b,
  33902. 0x1e,
  33903. 0x87,
  33904. 0xe9,
  33905. 0xce,
  33906. 0x55,
  33907. 0x28,
  33908. 0xdf,
  33909. 0x8c,
  33910. 0xa1,
  33911. 0x89,
  33912. 0x0d,
  33913. 0xbf,
  33914. 0xe6,
  33915. 0x42,
  33916. 0x68,
  33917. 0x41,
  33918. 0x99,
  33919. 0x2d,
  33920. 0x0f,
  33921. 0xb0,
  33922. 0x54,
  33923. 0xbb,
  33924. 0x16
  33925. ]);
  33926. var inv_s = new Uint8Array([
  33927. 0x52,
  33928. 0x09,
  33929. 0x6a,
  33930. 0xd5,
  33931. 0x30,
  33932. 0x36,
  33933. 0xa5,
  33934. 0x38,
  33935. 0xbf,
  33936. 0x40,
  33937. 0xa3,
  33938. 0x9e,
  33939. 0x81,
  33940. 0xf3,
  33941. 0xd7,
  33942. 0xfb,
  33943. 0x7c,
  33944. 0xe3,
  33945. 0x39,
  33946. 0x82,
  33947. 0x9b,
  33948. 0x2f,
  33949. 0xff,
  33950. 0x87,
  33951. 0x34,
  33952. 0x8e,
  33953. 0x43,
  33954. 0x44,
  33955. 0xc4,
  33956. 0xde,
  33957. 0xe9,
  33958. 0xcb,
  33959. 0x54,
  33960. 0x7b,
  33961. 0x94,
  33962. 0x32,
  33963. 0xa6,
  33964. 0xc2,
  33965. 0x23,
  33966. 0x3d,
  33967. 0xee,
  33968. 0x4c,
  33969. 0x95,
  33970. 0x0b,
  33971. 0x42,
  33972. 0xfa,
  33973. 0xc3,
  33974. 0x4e,
  33975. 0x08,
  33976. 0x2e,
  33977. 0xa1,
  33978. 0x66,
  33979. 0x28,
  33980. 0xd9,
  33981. 0x24,
  33982. 0xb2,
  33983. 0x76,
  33984. 0x5b,
  33985. 0xa2,
  33986. 0x49,
  33987. 0x6d,
  33988. 0x8b,
  33989. 0xd1,
  33990. 0x25,
  33991. 0x72,
  33992. 0xf8,
  33993. 0xf6,
  33994. 0x64,
  33995. 0x86,
  33996. 0x68,
  33997. 0x98,
  33998. 0x16,
  33999. 0xd4,
  34000. 0xa4,
  34001. 0x5c,
  34002. 0xcc,
  34003. 0x5d,
  34004. 0x65,
  34005. 0xb6,
  34006. 0x92,
  34007. 0x6c,
  34008. 0x70,
  34009. 0x48,
  34010. 0x50,
  34011. 0xfd,
  34012. 0xed,
  34013. 0xb9,
  34014. 0xda,
  34015. 0x5e,
  34016. 0x15,
  34017. 0x46,
  34018. 0x57,
  34019. 0xa7,
  34020. 0x8d,
  34021. 0x9d,
  34022. 0x84,
  34023. 0x90,
  34024. 0xd8,
  34025. 0xab,
  34026. 0x00,
  34027. 0x8c,
  34028. 0xbc,
  34029. 0xd3,
  34030. 0x0a,
  34031. 0xf7,
  34032. 0xe4,
  34033. 0x58,
  34034. 0x05,
  34035. 0xb8,
  34036. 0xb3,
  34037. 0x45,
  34038. 0x06,
  34039. 0xd0,
  34040. 0x2c,
  34041. 0x1e,
  34042. 0x8f,
  34043. 0xca,
  34044. 0x3f,
  34045. 0x0f,
  34046. 0x02,
  34047. 0xc1,
  34048. 0xaf,
  34049. 0xbd,
  34050. 0x03,
  34051. 0x01,
  34052. 0x13,
  34053. 0x8a,
  34054. 0x6b,
  34055. 0x3a,
  34056. 0x91,
  34057. 0x11,
  34058. 0x41,
  34059. 0x4f,
  34060. 0x67,
  34061. 0xdc,
  34062. 0xea,
  34063. 0x97,
  34064. 0xf2,
  34065. 0xcf,
  34066. 0xce,
  34067. 0xf0,
  34068. 0xb4,
  34069. 0xe6,
  34070. 0x73,
  34071. 0x96,
  34072. 0xac,
  34073. 0x74,
  34074. 0x22,
  34075. 0xe7,
  34076. 0xad,
  34077. 0x35,
  34078. 0x85,
  34079. 0xe2,
  34080. 0xf9,
  34081. 0x37,
  34082. 0xe8,
  34083. 0x1c,
  34084. 0x75,
  34085. 0xdf,
  34086. 0x6e,
  34087. 0x47,
  34088. 0xf1,
  34089. 0x1a,
  34090. 0x71,
  34091. 0x1d,
  34092. 0x29,
  34093. 0xc5,
  34094. 0x89,
  34095. 0x6f,
  34096. 0xb7,
  34097. 0x62,
  34098. 0x0e,
  34099. 0xaa,
  34100. 0x18,
  34101. 0xbe,
  34102. 0x1b,
  34103. 0xfc,
  34104. 0x56,
  34105. 0x3e,
  34106. 0x4b,
  34107. 0xc6,
  34108. 0xd2,
  34109. 0x79,
  34110. 0x20,
  34111. 0x9a,
  34112. 0xdb,
  34113. 0xc0,
  34114. 0xfe,
  34115. 0x78,
  34116. 0xcd,
  34117. 0x5a,
  34118. 0xf4,
  34119. 0x1f,
  34120. 0xdd,
  34121. 0xa8,
  34122. 0x33,
  34123. 0x88,
  34124. 0x07,
  34125. 0xc7,
  34126. 0x31,
  34127. 0xb1,
  34128. 0x12,
  34129. 0x10,
  34130. 0x59,
  34131. 0x27,
  34132. 0x80,
  34133. 0xec,
  34134. 0x5f,
  34135. 0x60,
  34136. 0x51,
  34137. 0x7f,
  34138. 0xa9,
  34139. 0x19,
  34140. 0xb5,
  34141. 0x4a,
  34142. 0x0d,
  34143. 0x2d,
  34144. 0xe5,
  34145. 0x7a,
  34146. 0x9f,
  34147. 0x93,
  34148. 0xc9,
  34149. 0x9c,
  34150. 0xef,
  34151. 0xa0,
  34152. 0xe0,
  34153. 0x3b,
  34154. 0x4d,
  34155. 0xae,
  34156. 0x2a,
  34157. 0xf5,
  34158. 0xb0,
  34159. 0xc8,
  34160. 0xeb,
  34161. 0xbb,
  34162. 0x3c,
  34163. 0x83,
  34164. 0x53,
  34165. 0x99,
  34166. 0x61,
  34167. 0x17,
  34168. 0x2b,
  34169. 0x04,
  34170. 0x7e,
  34171. 0xba,
  34172. 0x77,
  34173. 0xd6,
  34174. 0x26,
  34175. 0xe1,
  34176. 0x69,
  34177. 0x14,
  34178. 0x63,
  34179. 0x55,
  34180. 0x21,
  34181. 0x0c,
  34182. 0x7d
  34183. ]);
  34184. var mixCol = new Uint8Array(256);
  34185. for (var i = 0; i < 256; i++) {
  34186. if (i < 128) {
  34187. mixCol[i] = i << 1;
  34188. } else {
  34189. mixCol[i] = i << 1 ^ 0x1b;
  34190. }
  34191. }
  34192. var mix = new Uint32Array([
  34193. 0x00000000,
  34194. 0x0e090d0b,
  34195. 0x1c121a16,
  34196. 0x121b171d,
  34197. 0x3824342c,
  34198. 0x362d3927,
  34199. 0x24362e3a,
  34200. 0x2a3f2331,
  34201. 0x70486858,
  34202. 0x7e416553,
  34203. 0x6c5a724e,
  34204. 0x62537f45,
  34205. 0x486c5c74,
  34206. 0x4665517f,
  34207. 0x547e4662,
  34208. 0x5a774b69,
  34209. 0xe090d0b0,
  34210. 0xee99ddbb,
  34211. 0xfc82caa6,
  34212. 0xf28bc7ad,
  34213. 0xd8b4e49c,
  34214. 0xd6bde997,
  34215. 0xc4a6fe8a,
  34216. 0xcaaff381,
  34217. 0x90d8b8e8,
  34218. 0x9ed1b5e3,
  34219. 0x8ccaa2fe,
  34220. 0x82c3aff5,
  34221. 0xa8fc8cc4,
  34222. 0xa6f581cf,
  34223. 0xb4ee96d2,
  34224. 0xbae79bd9,
  34225. 0xdb3bbb7b,
  34226. 0xd532b670,
  34227. 0xc729a16d,
  34228. 0xc920ac66,
  34229. 0xe31f8f57,
  34230. 0xed16825c,
  34231. 0xff0d9541,
  34232. 0xf104984a,
  34233. 0xab73d323,
  34234. 0xa57ade28,
  34235. 0xb761c935,
  34236. 0xb968c43e,
  34237. 0x9357e70f,
  34238. 0x9d5eea04,
  34239. 0x8f45fd19,
  34240. 0x814cf012,
  34241. 0x3bab6bcb,
  34242. 0x35a266c0,
  34243. 0x27b971dd,
  34244. 0x29b07cd6,
  34245. 0x038f5fe7,
  34246. 0x0d8652ec,
  34247. 0x1f9d45f1,
  34248. 0x119448fa,
  34249. 0x4be30393,
  34250. 0x45ea0e98,
  34251. 0x57f11985,
  34252. 0x59f8148e,
  34253. 0x73c737bf,
  34254. 0x7dce3ab4,
  34255. 0x6fd52da9,
  34256. 0x61dc20a2,
  34257. 0xad766df6,
  34258. 0xa37f60fd,
  34259. 0xb16477e0,
  34260. 0xbf6d7aeb,
  34261. 0x955259da,
  34262. 0x9b5b54d1,
  34263. 0x894043cc,
  34264. 0x87494ec7,
  34265. 0xdd3e05ae,
  34266. 0xd33708a5,
  34267. 0xc12c1fb8,
  34268. 0xcf2512b3,
  34269. 0xe51a3182,
  34270. 0xeb133c89,
  34271. 0xf9082b94,
  34272. 0xf701269f,
  34273. 0x4de6bd46,
  34274. 0x43efb04d,
  34275. 0x51f4a750,
  34276. 0x5ffdaa5b,
  34277. 0x75c2896a,
  34278. 0x7bcb8461,
  34279. 0x69d0937c,
  34280. 0x67d99e77,
  34281. 0x3daed51e,
  34282. 0x33a7d815,
  34283. 0x21bccf08,
  34284. 0x2fb5c203,
  34285. 0x058ae132,
  34286. 0x0b83ec39,
  34287. 0x1998fb24,
  34288. 0x1791f62f,
  34289. 0x764dd68d,
  34290. 0x7844db86,
  34291. 0x6a5fcc9b,
  34292. 0x6456c190,
  34293. 0x4e69e2a1,
  34294. 0x4060efaa,
  34295. 0x527bf8b7,
  34296. 0x5c72f5bc,
  34297. 0x0605bed5,
  34298. 0x080cb3de,
  34299. 0x1a17a4c3,
  34300. 0x141ea9c8,
  34301. 0x3e218af9,
  34302. 0x302887f2,
  34303. 0x223390ef,
  34304. 0x2c3a9de4,
  34305. 0x96dd063d,
  34306. 0x98d40b36,
  34307. 0x8acf1c2b,
  34308. 0x84c61120,
  34309. 0xaef93211,
  34310. 0xa0f03f1a,
  34311. 0xb2eb2807,
  34312. 0xbce2250c,
  34313. 0xe6956e65,
  34314. 0xe89c636e,
  34315. 0xfa877473,
  34316. 0xf48e7978,
  34317. 0xdeb15a49,
  34318. 0xd0b85742,
  34319. 0xc2a3405f,
  34320. 0xccaa4d54,
  34321. 0x41ecdaf7,
  34322. 0x4fe5d7fc,
  34323. 0x5dfec0e1,
  34324. 0x53f7cdea,
  34325. 0x79c8eedb,
  34326. 0x77c1e3d0,
  34327. 0x65daf4cd,
  34328. 0x6bd3f9c6,
  34329. 0x31a4b2af,
  34330. 0x3fadbfa4,
  34331. 0x2db6a8b9,
  34332. 0x23bfa5b2,
  34333. 0x09808683,
  34334. 0x07898b88,
  34335. 0x15929c95,
  34336. 0x1b9b919e,
  34337. 0xa17c0a47,
  34338. 0xaf75074c,
  34339. 0xbd6e1051,
  34340. 0xb3671d5a,
  34341. 0x99583e6b,
  34342. 0x97513360,
  34343. 0x854a247d,
  34344. 0x8b432976,
  34345. 0xd134621f,
  34346. 0xdf3d6f14,
  34347. 0xcd267809,
  34348. 0xc32f7502,
  34349. 0xe9105633,
  34350. 0xe7195b38,
  34351. 0xf5024c25,
  34352. 0xfb0b412e,
  34353. 0x9ad7618c,
  34354. 0x94de6c87,
  34355. 0x86c57b9a,
  34356. 0x88cc7691,
  34357. 0xa2f355a0,
  34358. 0xacfa58ab,
  34359. 0xbee14fb6,
  34360. 0xb0e842bd,
  34361. 0xea9f09d4,
  34362. 0xe49604df,
  34363. 0xf68d13c2,
  34364. 0xf8841ec9,
  34365. 0xd2bb3df8,
  34366. 0xdcb230f3,
  34367. 0xcea927ee,
  34368. 0xc0a02ae5,
  34369. 0x7a47b13c,
  34370. 0x744ebc37,
  34371. 0x6655ab2a,
  34372. 0x685ca621,
  34373. 0x42638510,
  34374. 0x4c6a881b,
  34375. 0x5e719f06,
  34376. 0x5078920d,
  34377. 0x0a0fd964,
  34378. 0x0406d46f,
  34379. 0x161dc372,
  34380. 0x1814ce79,
  34381. 0x322bed48,
  34382. 0x3c22e043,
  34383. 0x2e39f75e,
  34384. 0x2030fa55,
  34385. 0xec9ab701,
  34386. 0xe293ba0a,
  34387. 0xf088ad17,
  34388. 0xfe81a01c,
  34389. 0xd4be832d,
  34390. 0xdab78e26,
  34391. 0xc8ac993b,
  34392. 0xc6a59430,
  34393. 0x9cd2df59,
  34394. 0x92dbd252,
  34395. 0x80c0c54f,
  34396. 0x8ec9c844,
  34397. 0xa4f6eb75,
  34398. 0xaaffe67e,
  34399. 0xb8e4f163,
  34400. 0xb6edfc68,
  34401. 0x0c0a67b1,
  34402. 0x02036aba,
  34403. 0x10187da7,
  34404. 0x1e1170ac,
  34405. 0x342e539d,
  34406. 0x3a275e96,
  34407. 0x283c498b,
  34408. 0x26354480,
  34409. 0x7c420fe9,
  34410. 0x724b02e2,
  34411. 0x605015ff,
  34412. 0x6e5918f4,
  34413. 0x44663bc5,
  34414. 0x4a6f36ce,
  34415. 0x587421d3,
  34416. 0x567d2cd8,
  34417. 0x37a10c7a,
  34418. 0x39a80171,
  34419. 0x2bb3166c,
  34420. 0x25ba1b67,
  34421. 0x0f853856,
  34422. 0x018c355d,
  34423. 0x13972240,
  34424. 0x1d9e2f4b,
  34425. 0x47e96422,
  34426. 0x49e06929,
  34427. 0x5bfb7e34,
  34428. 0x55f2733f,
  34429. 0x7fcd500e,
  34430. 0x71c45d05,
  34431. 0x63df4a18,
  34432. 0x6dd64713,
  34433. 0xd731dcca,
  34434. 0xd938d1c1,
  34435. 0xcb23c6dc,
  34436. 0xc52acbd7,
  34437. 0xef15e8e6,
  34438. 0xe11ce5ed,
  34439. 0xf307f2f0,
  34440. 0xfd0efffb,
  34441. 0xa779b492,
  34442. 0xa970b999,
  34443. 0xbb6bae84,
  34444. 0xb562a38f,
  34445. 0x9f5d80be,
  34446. 0x91548db5,
  34447. 0x834f9aa8,
  34448. 0x8d4697a3
  34449. ]);
  34450. function expandKey128(cipherKey) {
  34451. var b = 176, result = new Uint8Array(b);
  34452. result.set(cipherKey);
  34453. for (var j = 16, i = 1; j < b; ++i) {
  34454. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34455. t1 = s[t1];
  34456. t2 = s[t2];
  34457. t3 = s[t3];
  34458. t4 = s[t4];
  34459. t1 = t1 ^ rcon[i];
  34460. for (var n = 0; n < 4; ++n) {
  34461. result[j] = t1 ^= result[j - 16];
  34462. j++;
  34463. result[j] = t2 ^= result[j - 16];
  34464. j++;
  34465. result[j] = t3 ^= result[j - 16];
  34466. j++;
  34467. result[j] = t4 ^= result[j - 16];
  34468. j++;
  34469. }
  34470. }
  34471. return result;
  34472. }
  34473. function decrypt128(input, key) {
  34474. var state = new Uint8Array(16);
  34475. state.set(input);
  34476. var i, j, k;
  34477. var t, u, v;
  34478. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34479. state[j] ^= key[k];
  34480. }
  34481. for (i = 9; i >= 1; --i) {
  34482. t = state[13];
  34483. state[13] = state[9];
  34484. state[9] = state[5];
  34485. state[5] = state[1];
  34486. state[1] = t;
  34487. t = state[14];
  34488. u = state[10];
  34489. state[14] = state[6];
  34490. state[10] = state[2];
  34491. state[6] = t;
  34492. state[2] = u;
  34493. t = state[15];
  34494. u = state[11];
  34495. v = state[7];
  34496. state[15] = state[3];
  34497. state[11] = t;
  34498. state[7] = u;
  34499. state[3] = v;
  34500. for (j = 0; j < 16; ++j) {
  34501. state[j] = inv_s[state[j]];
  34502. }
  34503. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34504. state[j] ^= key[k];
  34505. }
  34506. for (j = 0; j < 16; j += 4) {
  34507. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34508. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34509. state[j] = t >>> 24 & 0xFF;
  34510. state[j + 1] = t >> 16 & 0xFF;
  34511. state[j + 2] = t >> 8 & 0xFF;
  34512. state[j + 3] = t & 0xFF;
  34513. }
  34514. }
  34515. t = state[13];
  34516. state[13] = state[9];
  34517. state[9] = state[5];
  34518. state[5] = state[1];
  34519. state[1] = t;
  34520. t = state[14];
  34521. u = state[10];
  34522. state[14] = state[6];
  34523. state[10] = state[2];
  34524. state[6] = t;
  34525. state[2] = u;
  34526. t = state[15];
  34527. u = state[11];
  34528. v = state[7];
  34529. state[15] = state[3];
  34530. state[11] = t;
  34531. state[7] = u;
  34532. state[3] = v;
  34533. for (j = 0; j < 16; ++j) {
  34534. state[j] = inv_s[state[j]];
  34535. state[j] ^= key[j];
  34536. }
  34537. return state;
  34538. }
  34539. function encrypt128(input, key) {
  34540. var t, u, v, k;
  34541. var state = new Uint8Array(16);
  34542. state.set(input);
  34543. for (j = 0; j < 16; ++j) {
  34544. state[j] ^= key[j];
  34545. }
  34546. for (i = 1; i < 10; i++) {
  34547. for (j = 0; j < 16; ++j) {
  34548. state[j] = s[state[j]];
  34549. }
  34550. v = state[1];
  34551. state[1] = state[5];
  34552. state[5] = state[9];
  34553. state[9] = state[13];
  34554. state[13] = v;
  34555. v = state[2];
  34556. u = state[6];
  34557. state[2] = state[10];
  34558. state[6] = state[14];
  34559. state[10] = v;
  34560. state[14] = u;
  34561. v = state[3];
  34562. u = state[7];
  34563. t = state[11];
  34564. state[3] = state[15];
  34565. state[7] = v;
  34566. state[11] = u;
  34567. state[15] = t;
  34568. for (var j = 0; j < 16; j += 4) {
  34569. var s0 = state[j + 0], s1 = state[j + 1];
  34570. var s2 = state[j + 2], s3 = state[j + 3];
  34571. t = s0 ^ s1 ^ s2 ^ s3;
  34572. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34573. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34574. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34575. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34576. }
  34577. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34578. state[j] ^= key[k];
  34579. }
  34580. }
  34581. for (j = 0; j < 16; ++j) {
  34582. state[j] = s[state[j]];
  34583. }
  34584. v = state[1];
  34585. state[1] = state[5];
  34586. state[5] = state[9];
  34587. state[9] = state[13];
  34588. state[13] = v;
  34589. v = state[2];
  34590. u = state[6];
  34591. state[2] = state[10];
  34592. state[6] = state[14];
  34593. state[10] = v;
  34594. state[14] = u;
  34595. v = state[3];
  34596. u = state[7];
  34597. t = state[11];
  34598. state[3] = state[15];
  34599. state[7] = v;
  34600. state[11] = u;
  34601. state[15] = t;
  34602. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34603. state[j] ^= key[k];
  34604. }
  34605. return state;
  34606. }
  34607. function AES128Cipher(key) {
  34608. this.key = expandKey128(key);
  34609. this.buffer = new Uint8Array(16);
  34610. this.bufferPosition = 0;
  34611. }
  34612. function decryptBlock2(data, finalize) {
  34613. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34614. for (i = 0; i < sourceLength; ++i) {
  34615. buffer[bufferLength] = data[i];
  34616. ++bufferLength;
  34617. if (bufferLength < 16) {
  34618. continue;
  34619. }
  34620. var plain = decrypt128(buffer, this.key);
  34621. for (j = 0; j < 16; ++j) {
  34622. plain[j] ^= iv[j];
  34623. }
  34624. iv = buffer;
  34625. result.push(plain);
  34626. buffer = new Uint8Array(16);
  34627. bufferLength = 0;
  34628. }
  34629. this.buffer = buffer;
  34630. this.bufferLength = bufferLength;
  34631. this.iv = iv;
  34632. if (result.length === 0) {
  34633. return new Uint8Array([]);
  34634. }
  34635. var outputLength = 16 * result.length;
  34636. if (finalize) {
  34637. var lastBlock = result[result.length - 1];
  34638. var psLen = lastBlock[15];
  34639. if (psLen <= 16) {
  34640. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34641. if (lastBlock[i] !== psLen) {
  34642. psLen = 0;
  34643. break;
  34644. }
  34645. }
  34646. outputLength -= psLen;
  34647. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34648. }
  34649. }
  34650. var output = new Uint8Array(outputLength);
  34651. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34652. output.set(result[i], j);
  34653. }
  34654. return output;
  34655. }
  34656. AES128Cipher.prototype = {
  34657. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34658. var i, sourceLength = data.length;
  34659. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34660. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34661. buffer[bufferLength] = data[i];
  34662. }
  34663. if (bufferLength < 16) {
  34664. this.bufferLength = bufferLength;
  34665. return new Uint8Array([]);
  34666. }
  34667. this.iv = buffer;
  34668. this.buffer = new Uint8Array(16);
  34669. this.bufferLength = 0;
  34670. this.decryptBlock = decryptBlock2;
  34671. return this.decryptBlock(data.subarray(16), finalize);
  34672. },
  34673. encrypt: function AES128Cipher_encrypt(data, iv) {
  34674. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34675. if (!iv) {
  34676. iv = new Uint8Array(16);
  34677. }
  34678. for (i = 0; i < sourceLength; ++i) {
  34679. buffer[bufferLength] = data[i];
  34680. ++bufferLength;
  34681. if (bufferLength < 16) {
  34682. continue;
  34683. }
  34684. for (j = 0; j < 16; ++j) {
  34685. buffer[j] ^= iv[j];
  34686. }
  34687. var cipher = encrypt128(buffer, this.key);
  34688. iv = cipher;
  34689. result.push(cipher);
  34690. buffer = new Uint8Array(16);
  34691. bufferLength = 0;
  34692. }
  34693. this.buffer = buffer;
  34694. this.bufferLength = bufferLength;
  34695. this.iv = iv;
  34696. if (result.length === 0) {
  34697. return new Uint8Array([]);
  34698. }
  34699. var outputLength = 16 * result.length;
  34700. var output = new Uint8Array(outputLength);
  34701. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34702. output.set(result[i], j);
  34703. }
  34704. return output;
  34705. }
  34706. };
  34707. return AES128Cipher;
  34708. }();
  34709. var AES256Cipher = function AES256CipherClosure() {
  34710. var rcon = new Uint8Array([
  34711. 0x8d,
  34712. 0x01,
  34713. 0x02,
  34714. 0x04,
  34715. 0x08,
  34716. 0x10,
  34717. 0x20,
  34718. 0x40,
  34719. 0x80,
  34720. 0x1b,
  34721. 0x36,
  34722. 0x6c,
  34723. 0xd8,
  34724. 0xab,
  34725. 0x4d,
  34726. 0x9a,
  34727. 0x2f,
  34728. 0x5e,
  34729. 0xbc,
  34730. 0x63,
  34731. 0xc6,
  34732. 0x97,
  34733. 0x35,
  34734. 0x6a,
  34735. 0xd4,
  34736. 0xb3,
  34737. 0x7d,
  34738. 0xfa,
  34739. 0xef,
  34740. 0xc5,
  34741. 0x91,
  34742. 0x39,
  34743. 0x72,
  34744. 0xe4,
  34745. 0xd3,
  34746. 0xbd,
  34747. 0x61,
  34748. 0xc2,
  34749. 0x9f,
  34750. 0x25,
  34751. 0x4a,
  34752. 0x94,
  34753. 0x33,
  34754. 0x66,
  34755. 0xcc,
  34756. 0x83,
  34757. 0x1d,
  34758. 0x3a,
  34759. 0x74,
  34760. 0xe8,
  34761. 0xcb,
  34762. 0x8d,
  34763. 0x01,
  34764. 0x02,
  34765. 0x04,
  34766. 0x08,
  34767. 0x10,
  34768. 0x20,
  34769. 0x40,
  34770. 0x80,
  34771. 0x1b,
  34772. 0x36,
  34773. 0x6c,
  34774. 0xd8,
  34775. 0xab,
  34776. 0x4d,
  34777. 0x9a,
  34778. 0x2f,
  34779. 0x5e,
  34780. 0xbc,
  34781. 0x63,
  34782. 0xc6,
  34783. 0x97,
  34784. 0x35,
  34785. 0x6a,
  34786. 0xd4,
  34787. 0xb3,
  34788. 0x7d,
  34789. 0xfa,
  34790. 0xef,
  34791. 0xc5,
  34792. 0x91,
  34793. 0x39,
  34794. 0x72,
  34795. 0xe4,
  34796. 0xd3,
  34797. 0xbd,
  34798. 0x61,
  34799. 0xc2,
  34800. 0x9f,
  34801. 0x25,
  34802. 0x4a,
  34803. 0x94,
  34804. 0x33,
  34805. 0x66,
  34806. 0xcc,
  34807. 0x83,
  34808. 0x1d,
  34809. 0x3a,
  34810. 0x74,
  34811. 0xe8,
  34812. 0xcb,
  34813. 0x8d,
  34814. 0x01,
  34815. 0x02,
  34816. 0x04,
  34817. 0x08,
  34818. 0x10,
  34819. 0x20,
  34820. 0x40,
  34821. 0x80,
  34822. 0x1b,
  34823. 0x36,
  34824. 0x6c,
  34825. 0xd8,
  34826. 0xab,
  34827. 0x4d,
  34828. 0x9a,
  34829. 0x2f,
  34830. 0x5e,
  34831. 0xbc,
  34832. 0x63,
  34833. 0xc6,
  34834. 0x97,
  34835. 0x35,
  34836. 0x6a,
  34837. 0xd4,
  34838. 0xb3,
  34839. 0x7d,
  34840. 0xfa,
  34841. 0xef,
  34842. 0xc5,
  34843. 0x91,
  34844. 0x39,
  34845. 0x72,
  34846. 0xe4,
  34847. 0xd3,
  34848. 0xbd,
  34849. 0x61,
  34850. 0xc2,
  34851. 0x9f,
  34852. 0x25,
  34853. 0x4a,
  34854. 0x94,
  34855. 0x33,
  34856. 0x66,
  34857. 0xcc,
  34858. 0x83,
  34859. 0x1d,
  34860. 0x3a,
  34861. 0x74,
  34862. 0xe8,
  34863. 0xcb,
  34864. 0x8d,
  34865. 0x01,
  34866. 0x02,
  34867. 0x04,
  34868. 0x08,
  34869. 0x10,
  34870. 0x20,
  34871. 0x40,
  34872. 0x80,
  34873. 0x1b,
  34874. 0x36,
  34875. 0x6c,
  34876. 0xd8,
  34877. 0xab,
  34878. 0x4d,
  34879. 0x9a,
  34880. 0x2f,
  34881. 0x5e,
  34882. 0xbc,
  34883. 0x63,
  34884. 0xc6,
  34885. 0x97,
  34886. 0x35,
  34887. 0x6a,
  34888. 0xd4,
  34889. 0xb3,
  34890. 0x7d,
  34891. 0xfa,
  34892. 0xef,
  34893. 0xc5,
  34894. 0x91,
  34895. 0x39,
  34896. 0x72,
  34897. 0xe4,
  34898. 0xd3,
  34899. 0xbd,
  34900. 0x61,
  34901. 0xc2,
  34902. 0x9f,
  34903. 0x25,
  34904. 0x4a,
  34905. 0x94,
  34906. 0x33,
  34907. 0x66,
  34908. 0xcc,
  34909. 0x83,
  34910. 0x1d,
  34911. 0x3a,
  34912. 0x74,
  34913. 0xe8,
  34914. 0xcb,
  34915. 0x8d,
  34916. 0x01,
  34917. 0x02,
  34918. 0x04,
  34919. 0x08,
  34920. 0x10,
  34921. 0x20,
  34922. 0x40,
  34923. 0x80,
  34924. 0x1b,
  34925. 0x36,
  34926. 0x6c,
  34927. 0xd8,
  34928. 0xab,
  34929. 0x4d,
  34930. 0x9a,
  34931. 0x2f,
  34932. 0x5e,
  34933. 0xbc,
  34934. 0x63,
  34935. 0xc6,
  34936. 0x97,
  34937. 0x35,
  34938. 0x6a,
  34939. 0xd4,
  34940. 0xb3,
  34941. 0x7d,
  34942. 0xfa,
  34943. 0xef,
  34944. 0xc5,
  34945. 0x91,
  34946. 0x39,
  34947. 0x72,
  34948. 0xe4,
  34949. 0xd3,
  34950. 0xbd,
  34951. 0x61,
  34952. 0xc2,
  34953. 0x9f,
  34954. 0x25,
  34955. 0x4a,
  34956. 0x94,
  34957. 0x33,
  34958. 0x66,
  34959. 0xcc,
  34960. 0x83,
  34961. 0x1d,
  34962. 0x3a,
  34963. 0x74,
  34964. 0xe8,
  34965. 0xcb,
  34966. 0x8d
  34967. ]);
  34968. var s = new Uint8Array([
  34969. 0x63,
  34970. 0x7c,
  34971. 0x77,
  34972. 0x7b,
  34973. 0xf2,
  34974. 0x6b,
  34975. 0x6f,
  34976. 0xc5,
  34977. 0x30,
  34978. 0x01,
  34979. 0x67,
  34980. 0x2b,
  34981. 0xfe,
  34982. 0xd7,
  34983. 0xab,
  34984. 0x76,
  34985. 0xca,
  34986. 0x82,
  34987. 0xc9,
  34988. 0x7d,
  34989. 0xfa,
  34990. 0x59,
  34991. 0x47,
  34992. 0xf0,
  34993. 0xad,
  34994. 0xd4,
  34995. 0xa2,
  34996. 0xaf,
  34997. 0x9c,
  34998. 0xa4,
  34999. 0x72,
  35000. 0xc0,
  35001. 0xb7,
  35002. 0xfd,
  35003. 0x93,
  35004. 0x26,
  35005. 0x36,
  35006. 0x3f,
  35007. 0xf7,
  35008. 0xcc,
  35009. 0x34,
  35010. 0xa5,
  35011. 0xe5,
  35012. 0xf1,
  35013. 0x71,
  35014. 0xd8,
  35015. 0x31,
  35016. 0x15,
  35017. 0x04,
  35018. 0xc7,
  35019. 0x23,
  35020. 0xc3,
  35021. 0x18,
  35022. 0x96,
  35023. 0x05,
  35024. 0x9a,
  35025. 0x07,
  35026. 0x12,
  35027. 0x80,
  35028. 0xe2,
  35029. 0xeb,
  35030. 0x27,
  35031. 0xb2,
  35032. 0x75,
  35033. 0x09,
  35034. 0x83,
  35035. 0x2c,
  35036. 0x1a,
  35037. 0x1b,
  35038. 0x6e,
  35039. 0x5a,
  35040. 0xa0,
  35041. 0x52,
  35042. 0x3b,
  35043. 0xd6,
  35044. 0xb3,
  35045. 0x29,
  35046. 0xe3,
  35047. 0x2f,
  35048. 0x84,
  35049. 0x53,
  35050. 0xd1,
  35051. 0x00,
  35052. 0xed,
  35053. 0x20,
  35054. 0xfc,
  35055. 0xb1,
  35056. 0x5b,
  35057. 0x6a,
  35058. 0xcb,
  35059. 0xbe,
  35060. 0x39,
  35061. 0x4a,
  35062. 0x4c,
  35063. 0x58,
  35064. 0xcf,
  35065. 0xd0,
  35066. 0xef,
  35067. 0xaa,
  35068. 0xfb,
  35069. 0x43,
  35070. 0x4d,
  35071. 0x33,
  35072. 0x85,
  35073. 0x45,
  35074. 0xf9,
  35075. 0x02,
  35076. 0x7f,
  35077. 0x50,
  35078. 0x3c,
  35079. 0x9f,
  35080. 0xa8,
  35081. 0x51,
  35082. 0xa3,
  35083. 0x40,
  35084. 0x8f,
  35085. 0x92,
  35086. 0x9d,
  35087. 0x38,
  35088. 0xf5,
  35089. 0xbc,
  35090. 0xb6,
  35091. 0xda,
  35092. 0x21,
  35093. 0x10,
  35094. 0xff,
  35095. 0xf3,
  35096. 0xd2,
  35097. 0xcd,
  35098. 0x0c,
  35099. 0x13,
  35100. 0xec,
  35101. 0x5f,
  35102. 0x97,
  35103. 0x44,
  35104. 0x17,
  35105. 0xc4,
  35106. 0xa7,
  35107. 0x7e,
  35108. 0x3d,
  35109. 0x64,
  35110. 0x5d,
  35111. 0x19,
  35112. 0x73,
  35113. 0x60,
  35114. 0x81,
  35115. 0x4f,
  35116. 0xdc,
  35117. 0x22,
  35118. 0x2a,
  35119. 0x90,
  35120. 0x88,
  35121. 0x46,
  35122. 0xee,
  35123. 0xb8,
  35124. 0x14,
  35125. 0xde,
  35126. 0x5e,
  35127. 0x0b,
  35128. 0xdb,
  35129. 0xe0,
  35130. 0x32,
  35131. 0x3a,
  35132. 0x0a,
  35133. 0x49,
  35134. 0x06,
  35135. 0x24,
  35136. 0x5c,
  35137. 0xc2,
  35138. 0xd3,
  35139. 0xac,
  35140. 0x62,
  35141. 0x91,
  35142. 0x95,
  35143. 0xe4,
  35144. 0x79,
  35145. 0xe7,
  35146. 0xc8,
  35147. 0x37,
  35148. 0x6d,
  35149. 0x8d,
  35150. 0xd5,
  35151. 0x4e,
  35152. 0xa9,
  35153. 0x6c,
  35154. 0x56,
  35155. 0xf4,
  35156. 0xea,
  35157. 0x65,
  35158. 0x7a,
  35159. 0xae,
  35160. 0x08,
  35161. 0xba,
  35162. 0x78,
  35163. 0x25,
  35164. 0x2e,
  35165. 0x1c,
  35166. 0xa6,
  35167. 0xb4,
  35168. 0xc6,
  35169. 0xe8,
  35170. 0xdd,
  35171. 0x74,
  35172. 0x1f,
  35173. 0x4b,
  35174. 0xbd,
  35175. 0x8b,
  35176. 0x8a,
  35177. 0x70,
  35178. 0x3e,
  35179. 0xb5,
  35180. 0x66,
  35181. 0x48,
  35182. 0x03,
  35183. 0xf6,
  35184. 0x0e,
  35185. 0x61,
  35186. 0x35,
  35187. 0x57,
  35188. 0xb9,
  35189. 0x86,
  35190. 0xc1,
  35191. 0x1d,
  35192. 0x9e,
  35193. 0xe1,
  35194. 0xf8,
  35195. 0x98,
  35196. 0x11,
  35197. 0x69,
  35198. 0xd9,
  35199. 0x8e,
  35200. 0x94,
  35201. 0x9b,
  35202. 0x1e,
  35203. 0x87,
  35204. 0xe9,
  35205. 0xce,
  35206. 0x55,
  35207. 0x28,
  35208. 0xdf,
  35209. 0x8c,
  35210. 0xa1,
  35211. 0x89,
  35212. 0x0d,
  35213. 0xbf,
  35214. 0xe6,
  35215. 0x42,
  35216. 0x68,
  35217. 0x41,
  35218. 0x99,
  35219. 0x2d,
  35220. 0x0f,
  35221. 0xb0,
  35222. 0x54,
  35223. 0xbb,
  35224. 0x16
  35225. ]);
  35226. var inv_s = new Uint8Array([
  35227. 0x52,
  35228. 0x09,
  35229. 0x6a,
  35230. 0xd5,
  35231. 0x30,
  35232. 0x36,
  35233. 0xa5,
  35234. 0x38,
  35235. 0xbf,
  35236. 0x40,
  35237. 0xa3,
  35238. 0x9e,
  35239. 0x81,
  35240. 0xf3,
  35241. 0xd7,
  35242. 0xfb,
  35243. 0x7c,
  35244. 0xe3,
  35245. 0x39,
  35246. 0x82,
  35247. 0x9b,
  35248. 0x2f,
  35249. 0xff,
  35250. 0x87,
  35251. 0x34,
  35252. 0x8e,
  35253. 0x43,
  35254. 0x44,
  35255. 0xc4,
  35256. 0xde,
  35257. 0xe9,
  35258. 0xcb,
  35259. 0x54,
  35260. 0x7b,
  35261. 0x94,
  35262. 0x32,
  35263. 0xa6,
  35264. 0xc2,
  35265. 0x23,
  35266. 0x3d,
  35267. 0xee,
  35268. 0x4c,
  35269. 0x95,
  35270. 0x0b,
  35271. 0x42,
  35272. 0xfa,
  35273. 0xc3,
  35274. 0x4e,
  35275. 0x08,
  35276. 0x2e,
  35277. 0xa1,
  35278. 0x66,
  35279. 0x28,
  35280. 0xd9,
  35281. 0x24,
  35282. 0xb2,
  35283. 0x76,
  35284. 0x5b,
  35285. 0xa2,
  35286. 0x49,
  35287. 0x6d,
  35288. 0x8b,
  35289. 0xd1,
  35290. 0x25,
  35291. 0x72,
  35292. 0xf8,
  35293. 0xf6,
  35294. 0x64,
  35295. 0x86,
  35296. 0x68,
  35297. 0x98,
  35298. 0x16,
  35299. 0xd4,
  35300. 0xa4,
  35301. 0x5c,
  35302. 0xcc,
  35303. 0x5d,
  35304. 0x65,
  35305. 0xb6,
  35306. 0x92,
  35307. 0x6c,
  35308. 0x70,
  35309. 0x48,
  35310. 0x50,
  35311. 0xfd,
  35312. 0xed,
  35313. 0xb9,
  35314. 0xda,
  35315. 0x5e,
  35316. 0x15,
  35317. 0x46,
  35318. 0x57,
  35319. 0xa7,
  35320. 0x8d,
  35321. 0x9d,
  35322. 0x84,
  35323. 0x90,
  35324. 0xd8,
  35325. 0xab,
  35326. 0x00,
  35327. 0x8c,
  35328. 0xbc,
  35329. 0xd3,
  35330. 0x0a,
  35331. 0xf7,
  35332. 0xe4,
  35333. 0x58,
  35334. 0x05,
  35335. 0xb8,
  35336. 0xb3,
  35337. 0x45,
  35338. 0x06,
  35339. 0xd0,
  35340. 0x2c,
  35341. 0x1e,
  35342. 0x8f,
  35343. 0xca,
  35344. 0x3f,
  35345. 0x0f,
  35346. 0x02,
  35347. 0xc1,
  35348. 0xaf,
  35349. 0xbd,
  35350. 0x03,
  35351. 0x01,
  35352. 0x13,
  35353. 0x8a,
  35354. 0x6b,
  35355. 0x3a,
  35356. 0x91,
  35357. 0x11,
  35358. 0x41,
  35359. 0x4f,
  35360. 0x67,
  35361. 0xdc,
  35362. 0xea,
  35363. 0x97,
  35364. 0xf2,
  35365. 0xcf,
  35366. 0xce,
  35367. 0xf0,
  35368. 0xb4,
  35369. 0xe6,
  35370. 0x73,
  35371. 0x96,
  35372. 0xac,
  35373. 0x74,
  35374. 0x22,
  35375. 0xe7,
  35376. 0xad,
  35377. 0x35,
  35378. 0x85,
  35379. 0xe2,
  35380. 0xf9,
  35381. 0x37,
  35382. 0xe8,
  35383. 0x1c,
  35384. 0x75,
  35385. 0xdf,
  35386. 0x6e,
  35387. 0x47,
  35388. 0xf1,
  35389. 0x1a,
  35390. 0x71,
  35391. 0x1d,
  35392. 0x29,
  35393. 0xc5,
  35394. 0x89,
  35395. 0x6f,
  35396. 0xb7,
  35397. 0x62,
  35398. 0x0e,
  35399. 0xaa,
  35400. 0x18,
  35401. 0xbe,
  35402. 0x1b,
  35403. 0xfc,
  35404. 0x56,
  35405. 0x3e,
  35406. 0x4b,
  35407. 0xc6,
  35408. 0xd2,
  35409. 0x79,
  35410. 0x20,
  35411. 0x9a,
  35412. 0xdb,
  35413. 0xc0,
  35414. 0xfe,
  35415. 0x78,
  35416. 0xcd,
  35417. 0x5a,
  35418. 0xf4,
  35419. 0x1f,
  35420. 0xdd,
  35421. 0xa8,
  35422. 0x33,
  35423. 0x88,
  35424. 0x07,
  35425. 0xc7,
  35426. 0x31,
  35427. 0xb1,
  35428. 0x12,
  35429. 0x10,
  35430. 0x59,
  35431. 0x27,
  35432. 0x80,
  35433. 0xec,
  35434. 0x5f,
  35435. 0x60,
  35436. 0x51,
  35437. 0x7f,
  35438. 0xa9,
  35439. 0x19,
  35440. 0xb5,
  35441. 0x4a,
  35442. 0x0d,
  35443. 0x2d,
  35444. 0xe5,
  35445. 0x7a,
  35446. 0x9f,
  35447. 0x93,
  35448. 0xc9,
  35449. 0x9c,
  35450. 0xef,
  35451. 0xa0,
  35452. 0xe0,
  35453. 0x3b,
  35454. 0x4d,
  35455. 0xae,
  35456. 0x2a,
  35457. 0xf5,
  35458. 0xb0,
  35459. 0xc8,
  35460. 0xeb,
  35461. 0xbb,
  35462. 0x3c,
  35463. 0x83,
  35464. 0x53,
  35465. 0x99,
  35466. 0x61,
  35467. 0x17,
  35468. 0x2b,
  35469. 0x04,
  35470. 0x7e,
  35471. 0xba,
  35472. 0x77,
  35473. 0xd6,
  35474. 0x26,
  35475. 0xe1,
  35476. 0x69,
  35477. 0x14,
  35478. 0x63,
  35479. 0x55,
  35480. 0x21,
  35481. 0x0c,
  35482. 0x7d
  35483. ]);
  35484. var mixCol = new Uint8Array(256);
  35485. for (var i = 0; i < 256; i++) {
  35486. if (i < 128) {
  35487. mixCol[i] = i << 1;
  35488. } else {
  35489. mixCol[i] = i << 1 ^ 0x1b;
  35490. }
  35491. }
  35492. var mix = new Uint32Array([
  35493. 0x00000000,
  35494. 0x0e090d0b,
  35495. 0x1c121a16,
  35496. 0x121b171d,
  35497. 0x3824342c,
  35498. 0x362d3927,
  35499. 0x24362e3a,
  35500. 0x2a3f2331,
  35501. 0x70486858,
  35502. 0x7e416553,
  35503. 0x6c5a724e,
  35504. 0x62537f45,
  35505. 0x486c5c74,
  35506. 0x4665517f,
  35507. 0x547e4662,
  35508. 0x5a774b69,
  35509. 0xe090d0b0,
  35510. 0xee99ddbb,
  35511. 0xfc82caa6,
  35512. 0xf28bc7ad,
  35513. 0xd8b4e49c,
  35514. 0xd6bde997,
  35515. 0xc4a6fe8a,
  35516. 0xcaaff381,
  35517. 0x90d8b8e8,
  35518. 0x9ed1b5e3,
  35519. 0x8ccaa2fe,
  35520. 0x82c3aff5,
  35521. 0xa8fc8cc4,
  35522. 0xa6f581cf,
  35523. 0xb4ee96d2,
  35524. 0xbae79bd9,
  35525. 0xdb3bbb7b,
  35526. 0xd532b670,
  35527. 0xc729a16d,
  35528. 0xc920ac66,
  35529. 0xe31f8f57,
  35530. 0xed16825c,
  35531. 0xff0d9541,
  35532. 0xf104984a,
  35533. 0xab73d323,
  35534. 0xa57ade28,
  35535. 0xb761c935,
  35536. 0xb968c43e,
  35537. 0x9357e70f,
  35538. 0x9d5eea04,
  35539. 0x8f45fd19,
  35540. 0x814cf012,
  35541. 0x3bab6bcb,
  35542. 0x35a266c0,
  35543. 0x27b971dd,
  35544. 0x29b07cd6,
  35545. 0x038f5fe7,
  35546. 0x0d8652ec,
  35547. 0x1f9d45f1,
  35548. 0x119448fa,
  35549. 0x4be30393,
  35550. 0x45ea0e98,
  35551. 0x57f11985,
  35552. 0x59f8148e,
  35553. 0x73c737bf,
  35554. 0x7dce3ab4,
  35555. 0x6fd52da9,
  35556. 0x61dc20a2,
  35557. 0xad766df6,
  35558. 0xa37f60fd,
  35559. 0xb16477e0,
  35560. 0xbf6d7aeb,
  35561. 0x955259da,
  35562. 0x9b5b54d1,
  35563. 0x894043cc,
  35564. 0x87494ec7,
  35565. 0xdd3e05ae,
  35566. 0xd33708a5,
  35567. 0xc12c1fb8,
  35568. 0xcf2512b3,
  35569. 0xe51a3182,
  35570. 0xeb133c89,
  35571. 0xf9082b94,
  35572. 0xf701269f,
  35573. 0x4de6bd46,
  35574. 0x43efb04d,
  35575. 0x51f4a750,
  35576. 0x5ffdaa5b,
  35577. 0x75c2896a,
  35578. 0x7bcb8461,
  35579. 0x69d0937c,
  35580. 0x67d99e77,
  35581. 0x3daed51e,
  35582. 0x33a7d815,
  35583. 0x21bccf08,
  35584. 0x2fb5c203,
  35585. 0x058ae132,
  35586. 0x0b83ec39,
  35587. 0x1998fb24,
  35588. 0x1791f62f,
  35589. 0x764dd68d,
  35590. 0x7844db86,
  35591. 0x6a5fcc9b,
  35592. 0x6456c190,
  35593. 0x4e69e2a1,
  35594. 0x4060efaa,
  35595. 0x527bf8b7,
  35596. 0x5c72f5bc,
  35597. 0x0605bed5,
  35598. 0x080cb3de,
  35599. 0x1a17a4c3,
  35600. 0x141ea9c8,
  35601. 0x3e218af9,
  35602. 0x302887f2,
  35603. 0x223390ef,
  35604. 0x2c3a9de4,
  35605. 0x96dd063d,
  35606. 0x98d40b36,
  35607. 0x8acf1c2b,
  35608. 0x84c61120,
  35609. 0xaef93211,
  35610. 0xa0f03f1a,
  35611. 0xb2eb2807,
  35612. 0xbce2250c,
  35613. 0xe6956e65,
  35614. 0xe89c636e,
  35615. 0xfa877473,
  35616. 0xf48e7978,
  35617. 0xdeb15a49,
  35618. 0xd0b85742,
  35619. 0xc2a3405f,
  35620. 0xccaa4d54,
  35621. 0x41ecdaf7,
  35622. 0x4fe5d7fc,
  35623. 0x5dfec0e1,
  35624. 0x53f7cdea,
  35625. 0x79c8eedb,
  35626. 0x77c1e3d0,
  35627. 0x65daf4cd,
  35628. 0x6bd3f9c6,
  35629. 0x31a4b2af,
  35630. 0x3fadbfa4,
  35631. 0x2db6a8b9,
  35632. 0x23bfa5b2,
  35633. 0x09808683,
  35634. 0x07898b88,
  35635. 0x15929c95,
  35636. 0x1b9b919e,
  35637. 0xa17c0a47,
  35638. 0xaf75074c,
  35639. 0xbd6e1051,
  35640. 0xb3671d5a,
  35641. 0x99583e6b,
  35642. 0x97513360,
  35643. 0x854a247d,
  35644. 0x8b432976,
  35645. 0xd134621f,
  35646. 0xdf3d6f14,
  35647. 0xcd267809,
  35648. 0xc32f7502,
  35649. 0xe9105633,
  35650. 0xe7195b38,
  35651. 0xf5024c25,
  35652. 0xfb0b412e,
  35653. 0x9ad7618c,
  35654. 0x94de6c87,
  35655. 0x86c57b9a,
  35656. 0x88cc7691,
  35657. 0xa2f355a0,
  35658. 0xacfa58ab,
  35659. 0xbee14fb6,
  35660. 0xb0e842bd,
  35661. 0xea9f09d4,
  35662. 0xe49604df,
  35663. 0xf68d13c2,
  35664. 0xf8841ec9,
  35665. 0xd2bb3df8,
  35666. 0xdcb230f3,
  35667. 0xcea927ee,
  35668. 0xc0a02ae5,
  35669. 0x7a47b13c,
  35670. 0x744ebc37,
  35671. 0x6655ab2a,
  35672. 0x685ca621,
  35673. 0x42638510,
  35674. 0x4c6a881b,
  35675. 0x5e719f06,
  35676. 0x5078920d,
  35677. 0x0a0fd964,
  35678. 0x0406d46f,
  35679. 0x161dc372,
  35680. 0x1814ce79,
  35681. 0x322bed48,
  35682. 0x3c22e043,
  35683. 0x2e39f75e,
  35684. 0x2030fa55,
  35685. 0xec9ab701,
  35686. 0xe293ba0a,
  35687. 0xf088ad17,
  35688. 0xfe81a01c,
  35689. 0xd4be832d,
  35690. 0xdab78e26,
  35691. 0xc8ac993b,
  35692. 0xc6a59430,
  35693. 0x9cd2df59,
  35694. 0x92dbd252,
  35695. 0x80c0c54f,
  35696. 0x8ec9c844,
  35697. 0xa4f6eb75,
  35698. 0xaaffe67e,
  35699. 0xb8e4f163,
  35700. 0xb6edfc68,
  35701. 0x0c0a67b1,
  35702. 0x02036aba,
  35703. 0x10187da7,
  35704. 0x1e1170ac,
  35705. 0x342e539d,
  35706. 0x3a275e96,
  35707. 0x283c498b,
  35708. 0x26354480,
  35709. 0x7c420fe9,
  35710. 0x724b02e2,
  35711. 0x605015ff,
  35712. 0x6e5918f4,
  35713. 0x44663bc5,
  35714. 0x4a6f36ce,
  35715. 0x587421d3,
  35716. 0x567d2cd8,
  35717. 0x37a10c7a,
  35718. 0x39a80171,
  35719. 0x2bb3166c,
  35720. 0x25ba1b67,
  35721. 0x0f853856,
  35722. 0x018c355d,
  35723. 0x13972240,
  35724. 0x1d9e2f4b,
  35725. 0x47e96422,
  35726. 0x49e06929,
  35727. 0x5bfb7e34,
  35728. 0x55f2733f,
  35729. 0x7fcd500e,
  35730. 0x71c45d05,
  35731. 0x63df4a18,
  35732. 0x6dd64713,
  35733. 0xd731dcca,
  35734. 0xd938d1c1,
  35735. 0xcb23c6dc,
  35736. 0xc52acbd7,
  35737. 0xef15e8e6,
  35738. 0xe11ce5ed,
  35739. 0xf307f2f0,
  35740. 0xfd0efffb,
  35741. 0xa779b492,
  35742. 0xa970b999,
  35743. 0xbb6bae84,
  35744. 0xb562a38f,
  35745. 0x9f5d80be,
  35746. 0x91548db5,
  35747. 0x834f9aa8,
  35748. 0x8d4697a3
  35749. ]);
  35750. function expandKey256(cipherKey) {
  35751. var b = 240, result = new Uint8Array(b);
  35752. var r = 1;
  35753. result.set(cipherKey);
  35754. for (var j = 32, i = 1; j < b; ++i) {
  35755. if (j % 32 === 16) {
  35756. t1 = s[t1];
  35757. t2 = s[t2];
  35758. t3 = s[t3];
  35759. t4 = s[t4];
  35760. } else if (j % 32 === 0) {
  35761. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35762. t1 = s[t1];
  35763. t2 = s[t2];
  35764. t3 = s[t3];
  35765. t4 = s[t4];
  35766. t1 = t1 ^ r;
  35767. if ((r <<= 1) >= 256) {
  35768. r = (r ^ 0x1b) & 0xFF;
  35769. }
  35770. }
  35771. for (var n = 0; n < 4; ++n) {
  35772. result[j] = t1 ^= result[j - 32];
  35773. j++;
  35774. result[j] = t2 ^= result[j - 32];
  35775. j++;
  35776. result[j] = t3 ^= result[j - 32];
  35777. j++;
  35778. result[j] = t4 ^= result[j - 32];
  35779. j++;
  35780. }
  35781. }
  35782. return result;
  35783. }
  35784. function decrypt256(input, key) {
  35785. var state = new Uint8Array(16);
  35786. state.set(input);
  35787. var i, j, k;
  35788. var t, u, v;
  35789. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35790. state[j] ^= key[k];
  35791. }
  35792. for (i = 13; i >= 1; --i) {
  35793. t = state[13];
  35794. state[13] = state[9];
  35795. state[9] = state[5];
  35796. state[5] = state[1];
  35797. state[1] = t;
  35798. t = state[14];
  35799. u = state[10];
  35800. state[14] = state[6];
  35801. state[10] = state[2];
  35802. state[6] = t;
  35803. state[2] = u;
  35804. t = state[15];
  35805. u = state[11];
  35806. v = state[7];
  35807. state[15] = state[3];
  35808. state[11] = t;
  35809. state[7] = u;
  35810. state[3] = v;
  35811. for (j = 0; j < 16; ++j) {
  35812. state[j] = inv_s[state[j]];
  35813. }
  35814. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35815. state[j] ^= key[k];
  35816. }
  35817. for (j = 0; j < 16; j += 4) {
  35818. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35819. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35820. state[j] = t >>> 24 & 0xFF;
  35821. state[j + 1] = t >> 16 & 0xFF;
  35822. state[j + 2] = t >> 8 & 0xFF;
  35823. state[j + 3] = t & 0xFF;
  35824. }
  35825. }
  35826. t = state[13];
  35827. state[13] = state[9];
  35828. state[9] = state[5];
  35829. state[5] = state[1];
  35830. state[1] = t;
  35831. t = state[14];
  35832. u = state[10];
  35833. state[14] = state[6];
  35834. state[10] = state[2];
  35835. state[6] = t;
  35836. state[2] = u;
  35837. t = state[15];
  35838. u = state[11];
  35839. v = state[7];
  35840. state[15] = state[3];
  35841. state[11] = t;
  35842. state[7] = u;
  35843. state[3] = v;
  35844. for (j = 0; j < 16; ++j) {
  35845. state[j] = inv_s[state[j]];
  35846. state[j] ^= key[j];
  35847. }
  35848. return state;
  35849. }
  35850. function encrypt256(input, key) {
  35851. var t, u, v, k;
  35852. var state = new Uint8Array(16);
  35853. state.set(input);
  35854. for (j = 0; j < 16; ++j) {
  35855. state[j] ^= key[j];
  35856. }
  35857. for (i = 1; i < 14; i++) {
  35858. for (j = 0; j < 16; ++j) {
  35859. state[j] = s[state[j]];
  35860. }
  35861. v = state[1];
  35862. state[1] = state[5];
  35863. state[5] = state[9];
  35864. state[9] = state[13];
  35865. state[13] = v;
  35866. v = state[2];
  35867. u = state[6];
  35868. state[2] = state[10];
  35869. state[6] = state[14];
  35870. state[10] = v;
  35871. state[14] = u;
  35872. v = state[3];
  35873. u = state[7];
  35874. t = state[11];
  35875. state[3] = state[15];
  35876. state[7] = v;
  35877. state[11] = u;
  35878. state[15] = t;
  35879. for (var j = 0; j < 16; j += 4) {
  35880. var s0 = state[j + 0], s1 = state[j + 1];
  35881. var s2 = state[j + 2], s3 = state[j + 3];
  35882. t = s0 ^ s1 ^ s2 ^ s3;
  35883. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  35884. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  35885. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  35886. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  35887. }
  35888. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35889. state[j] ^= key[k];
  35890. }
  35891. }
  35892. for (j = 0; j < 16; ++j) {
  35893. state[j] = s[state[j]];
  35894. }
  35895. v = state[1];
  35896. state[1] = state[5];
  35897. state[5] = state[9];
  35898. state[9] = state[13];
  35899. state[13] = v;
  35900. v = state[2];
  35901. u = state[6];
  35902. state[2] = state[10];
  35903. state[6] = state[14];
  35904. state[10] = v;
  35905. state[14] = u;
  35906. v = state[3];
  35907. u = state[7];
  35908. t = state[11];
  35909. state[3] = state[15];
  35910. state[7] = v;
  35911. state[11] = u;
  35912. state[15] = t;
  35913. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35914. state[j] ^= key[k];
  35915. }
  35916. return state;
  35917. }
  35918. function AES256Cipher(key) {
  35919. this.key = expandKey256(key);
  35920. this.buffer = new Uint8Array(16);
  35921. this.bufferPosition = 0;
  35922. }
  35923. function decryptBlock2(data, finalize) {
  35924. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  35925. for (i = 0; i < sourceLength; ++i) {
  35926. buffer[bufferLength] = data[i];
  35927. ++bufferLength;
  35928. if (bufferLength < 16) {
  35929. continue;
  35930. }
  35931. var plain = decrypt256(buffer, this.key);
  35932. for (j = 0; j < 16; ++j) {
  35933. plain[j] ^= iv[j];
  35934. }
  35935. iv = buffer;
  35936. result.push(plain);
  35937. buffer = new Uint8Array(16);
  35938. bufferLength = 0;
  35939. }
  35940. this.buffer = buffer;
  35941. this.bufferLength = bufferLength;
  35942. this.iv = iv;
  35943. if (result.length === 0) {
  35944. return new Uint8Array([]);
  35945. }
  35946. var outputLength = 16 * result.length;
  35947. if (finalize) {
  35948. var lastBlock = result[result.length - 1];
  35949. var psLen = lastBlock[15];
  35950. if (psLen <= 16) {
  35951. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  35952. if (lastBlock[i] !== psLen) {
  35953. psLen = 0;
  35954. break;
  35955. }
  35956. }
  35957. outputLength -= psLen;
  35958. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  35959. }
  35960. }
  35961. var output = new Uint8Array(outputLength);
  35962. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35963. output.set(result[i], j);
  35964. }
  35965. return output;
  35966. }
  35967. AES256Cipher.prototype = {
  35968. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  35969. var i, sourceLength = data.length;
  35970. var buffer = this.buffer, bufferLength = this.bufferPosition;
  35971. if (iv) {
  35972. this.iv = iv;
  35973. } else {
  35974. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  35975. buffer[bufferLength] = data[i];
  35976. }
  35977. if (bufferLength < 16) {
  35978. this.bufferLength = bufferLength;
  35979. return new Uint8Array([]);
  35980. }
  35981. this.iv = buffer;
  35982. data = data.subarray(16);
  35983. }
  35984. this.buffer = new Uint8Array(16);
  35985. this.bufferLength = 0;
  35986. this.decryptBlock = decryptBlock2;
  35987. return this.decryptBlock(data, finalize);
  35988. },
  35989. encrypt: function AES256Cipher_encrypt(data, iv) {
  35990. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  35991. if (!iv) {
  35992. iv = new Uint8Array(16);
  35993. }
  35994. for (i = 0; i < sourceLength; ++i) {
  35995. buffer[bufferLength] = data[i];
  35996. ++bufferLength;
  35997. if (bufferLength < 16) {
  35998. continue;
  35999. }
  36000. for (j = 0; j < 16; ++j) {
  36001. buffer[j] ^= iv[j];
  36002. }
  36003. var cipher = encrypt256(buffer, this.key);
  36004. this.iv = cipher;
  36005. result.push(cipher);
  36006. buffer = new Uint8Array(16);
  36007. bufferLength = 0;
  36008. }
  36009. this.buffer = buffer;
  36010. this.bufferLength = bufferLength;
  36011. this.iv = iv;
  36012. if (result.length === 0) {
  36013. return new Uint8Array([]);
  36014. }
  36015. var outputLength = 16 * result.length;
  36016. var output = new Uint8Array(outputLength);
  36017. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36018. output.set(result[i], j);
  36019. }
  36020. return output;
  36021. }
  36022. };
  36023. return AES256Cipher;
  36024. }();
  36025. var PDF17 = function PDF17Closure() {
  36026. function compareByteArrays(array1, array2) {
  36027. if (array1.length !== array2.length) {
  36028. return false;
  36029. }
  36030. for (var i = 0; i < array1.length; i++) {
  36031. if (array1[i] !== array2[i]) {
  36032. return false;
  36033. }
  36034. }
  36035. return true;
  36036. }
  36037. function PDF17() {
  36038. }
  36039. PDF17.prototype = {
  36040. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36041. var hashData = new Uint8Array(password.length + 56);
  36042. hashData.set(password, 0);
  36043. hashData.set(ownerValidationSalt, password.length);
  36044. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36045. var result = calculateSHA256(hashData, 0, hashData.length);
  36046. return compareByteArrays(result, ownerPassword);
  36047. },
  36048. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36049. var hashData = new Uint8Array(password.length + 8);
  36050. hashData.set(password, 0);
  36051. hashData.set(userValidationSalt, password.length);
  36052. var result = calculateSHA256(hashData, 0, hashData.length);
  36053. return compareByteArrays(result, userPassword);
  36054. },
  36055. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36056. var hashData = new Uint8Array(password.length + 56);
  36057. hashData.set(password, 0);
  36058. hashData.set(ownerKeySalt, password.length);
  36059. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36060. var key = calculateSHA256(hashData, 0, hashData.length);
  36061. var cipher = new AES256Cipher(key);
  36062. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36063. },
  36064. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36065. var hashData = new Uint8Array(password.length + 8);
  36066. hashData.set(password, 0);
  36067. hashData.set(userKeySalt, password.length);
  36068. var key = calculateSHA256(hashData, 0, hashData.length);
  36069. var cipher = new AES256Cipher(key);
  36070. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36071. }
  36072. };
  36073. return PDF17;
  36074. }();
  36075. var PDF20 = function PDF20Closure() {
  36076. function concatArrays(array1, array2) {
  36077. var t = new Uint8Array(array1.length + array2.length);
  36078. t.set(array1, 0);
  36079. t.set(array2, array1.length);
  36080. return t;
  36081. }
  36082. function calculatePDF20Hash(password, input, userBytes) {
  36083. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36084. var e = [0];
  36085. var i = 0;
  36086. while (i < 64 || e[e.length - 1] > i - 32) {
  36087. var arrayLength = password.length + k.length + userBytes.length;
  36088. var k1 = new Uint8Array(arrayLength * 64);
  36089. var array = concatArrays(password, k);
  36090. array = concatArrays(array, userBytes);
  36091. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36092. k1.set(array, pos);
  36093. }
  36094. var cipher = new AES128Cipher(k.subarray(0, 16));
  36095. e = cipher.encrypt(k1, k.subarray(16, 32));
  36096. var remainder = 0;
  36097. for (var z = 0; z < 16; z++) {
  36098. remainder *= 256 % 3;
  36099. remainder %= 3;
  36100. remainder += (e[z] >>> 0) % 3;
  36101. remainder %= 3;
  36102. }
  36103. if (remainder === 0) {
  36104. k = calculateSHA256(e, 0, e.length);
  36105. } else if (remainder === 1) {
  36106. k = calculateSHA384(e, 0, e.length);
  36107. } else if (remainder === 2) {
  36108. k = calculateSHA512(e, 0, e.length);
  36109. }
  36110. i++;
  36111. }
  36112. return k.subarray(0, 32);
  36113. }
  36114. function PDF20() {
  36115. }
  36116. function compareByteArrays(array1, array2) {
  36117. if (array1.length !== array2.length) {
  36118. return false;
  36119. }
  36120. for (var i = 0; i < array1.length; i++) {
  36121. if (array1[i] !== array2[i]) {
  36122. return false;
  36123. }
  36124. }
  36125. return true;
  36126. }
  36127. PDF20.prototype = {
  36128. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36129. return calculatePDF20Hash(password, concatBytes, userBytes);
  36130. },
  36131. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36132. var hashData = new Uint8Array(password.length + 56);
  36133. hashData.set(password, 0);
  36134. hashData.set(ownerValidationSalt, password.length);
  36135. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36136. var result = calculatePDF20Hash(password, hashData, userBytes);
  36137. return compareByteArrays(result, ownerPassword);
  36138. },
  36139. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36140. var hashData = new Uint8Array(password.length + 8);
  36141. hashData.set(password, 0);
  36142. hashData.set(userValidationSalt, password.length);
  36143. var result = calculatePDF20Hash(password, hashData, []);
  36144. return compareByteArrays(result, userPassword);
  36145. },
  36146. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36147. var hashData = new Uint8Array(password.length + 56);
  36148. hashData.set(password, 0);
  36149. hashData.set(ownerKeySalt, password.length);
  36150. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36151. var key = calculatePDF20Hash(password, hashData, userBytes);
  36152. var cipher = new AES256Cipher(key);
  36153. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36154. },
  36155. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36156. var hashData = new Uint8Array(password.length + 8);
  36157. hashData.set(password, 0);
  36158. hashData.set(userKeySalt, password.length);
  36159. var key = calculatePDF20Hash(password, hashData, []);
  36160. var cipher = new AES256Cipher(key);
  36161. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36162. }
  36163. };
  36164. return PDF20;
  36165. }();
  36166. var CipherTransform = function CipherTransformClosure() {
  36167. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36168. this.stringCipherConstructor = stringCipherConstructor;
  36169. this.streamCipherConstructor = streamCipherConstructor;
  36170. }
  36171. CipherTransform.prototype = {
  36172. createStream: function CipherTransform_createStream(stream, length) {
  36173. var cipher = new this.streamCipherConstructor();
  36174. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36175. return cipher.decryptBlock(data, finalize);
  36176. });
  36177. },
  36178. decryptString: function CipherTransform_decryptString(s) {
  36179. var cipher = new this.stringCipherConstructor();
  36180. var data = stringToBytes(s);
  36181. data = cipher.decryptBlock(data, true);
  36182. return bytesToString(data);
  36183. }
  36184. };
  36185. return CipherTransform;
  36186. }();
  36187. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36188. var defaultPasswordBytes = new Uint8Array([
  36189. 0x28,
  36190. 0xBF,
  36191. 0x4E,
  36192. 0x5E,
  36193. 0x4E,
  36194. 0x75,
  36195. 0x8A,
  36196. 0x41,
  36197. 0x64,
  36198. 0x00,
  36199. 0x4E,
  36200. 0x56,
  36201. 0xFF,
  36202. 0xFA,
  36203. 0x01,
  36204. 0x08,
  36205. 0x2E,
  36206. 0x2E,
  36207. 0x00,
  36208. 0xB6,
  36209. 0xD0,
  36210. 0x68,
  36211. 0x3E,
  36212. 0x80,
  36213. 0x2F,
  36214. 0x0C,
  36215. 0xA9,
  36216. 0xFE,
  36217. 0x64,
  36218. 0x53,
  36219. 0x69,
  36220. 0x7A
  36221. ]);
  36222. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36223. if (password) {
  36224. var passwordLength = Math.min(127, password.length);
  36225. password = password.subarray(0, passwordLength);
  36226. } else {
  36227. password = [];
  36228. }
  36229. var pdfAlgorithm;
  36230. if (revision === 6) {
  36231. pdfAlgorithm = new PDF20();
  36232. } else {
  36233. pdfAlgorithm = new PDF17();
  36234. }
  36235. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36236. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36237. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36238. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36239. }
  36240. return null;
  36241. }
  36242. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36243. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36244. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36245. if (password) {
  36246. n = Math.min(32, password.length);
  36247. for (; i < n; ++i) {
  36248. hashData[i] = password[i];
  36249. }
  36250. }
  36251. j = 0;
  36252. while (i < 32) {
  36253. hashData[i++] = defaultPasswordBytes[j++];
  36254. }
  36255. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36256. hashData[i++] = ownerPassword[j];
  36257. }
  36258. hashData[i++] = flags & 0xFF;
  36259. hashData[i++] = flags >> 8 & 0xFF;
  36260. hashData[i++] = flags >> 16 & 0xFF;
  36261. hashData[i++] = flags >>> 24 & 0xFF;
  36262. for (j = 0, n = fileId.length; j < n; ++j) {
  36263. hashData[i++] = fileId[j];
  36264. }
  36265. if (revision >= 4 && !encryptMetadata) {
  36266. hashData[i++] = 0xFF;
  36267. hashData[i++] = 0xFF;
  36268. hashData[i++] = 0xFF;
  36269. hashData[i++] = 0xFF;
  36270. }
  36271. var hash = calculateMD5(hashData, 0, i);
  36272. var keyLengthInBytes = keyLength >> 3;
  36273. if (revision >= 3) {
  36274. for (j = 0; j < 50; ++j) {
  36275. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36276. }
  36277. }
  36278. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36279. var cipher, checkData;
  36280. if (revision >= 3) {
  36281. for (i = 0; i < 32; ++i) {
  36282. hashData[i] = defaultPasswordBytes[i];
  36283. }
  36284. for (j = 0, n = fileId.length; j < n; ++j) {
  36285. hashData[i++] = fileId[j];
  36286. }
  36287. cipher = new ARCFourCipher(encryptionKey);
  36288. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36289. n = encryptionKey.length;
  36290. var derivedKey = new Uint8Array(n), k;
  36291. for (j = 1; j <= 19; ++j) {
  36292. for (k = 0; k < n; ++k) {
  36293. derivedKey[k] = encryptionKey[k] ^ j;
  36294. }
  36295. cipher = new ARCFourCipher(derivedKey);
  36296. checkData = cipher.encryptBlock(checkData);
  36297. }
  36298. for (j = 0, n = checkData.length; j < n; ++j) {
  36299. if (userPassword[j] !== checkData[j]) {
  36300. return null;
  36301. }
  36302. }
  36303. } else {
  36304. cipher = new ARCFourCipher(encryptionKey);
  36305. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36306. for (j = 0, n = checkData.length; j < n; ++j) {
  36307. if (userPassword[j] !== checkData[j]) {
  36308. return null;
  36309. }
  36310. }
  36311. }
  36312. return encryptionKey;
  36313. }
  36314. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36315. var hashData = new Uint8Array(32), i = 0, j, n;
  36316. n = Math.min(32, password.length);
  36317. for (; i < n; ++i) {
  36318. hashData[i] = password[i];
  36319. }
  36320. j = 0;
  36321. while (i < 32) {
  36322. hashData[i++] = defaultPasswordBytes[j++];
  36323. }
  36324. var hash = calculateMD5(hashData, 0, i);
  36325. var keyLengthInBytes = keyLength >> 3;
  36326. if (revision >= 3) {
  36327. for (j = 0; j < 50; ++j) {
  36328. hash = calculateMD5(hash, 0, hash.length);
  36329. }
  36330. }
  36331. var cipher, userPassword;
  36332. if (revision >= 3) {
  36333. userPassword = ownerPassword;
  36334. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36335. for (j = 19; j >= 0; j--) {
  36336. for (k = 0; k < keyLengthInBytes; ++k) {
  36337. derivedKey[k] = hash[k] ^ j;
  36338. }
  36339. cipher = new ARCFourCipher(derivedKey);
  36340. userPassword = cipher.encryptBlock(userPassword);
  36341. }
  36342. } else {
  36343. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36344. userPassword = cipher.encryptBlock(ownerPassword);
  36345. }
  36346. return userPassword;
  36347. }
  36348. var identityName = Name.get('Identity');
  36349. function CipherTransformFactory(dict, fileId, password) {
  36350. var filter = dict.get('Filter');
  36351. if (!isName(filter, 'Standard')) {
  36352. error('unknown encryption method');
  36353. }
  36354. this.dict = dict;
  36355. var algorithm = dict.get('V');
  36356. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36357. error('unsupported encryption algorithm');
  36358. }
  36359. this.algorithm = algorithm;
  36360. var keyLength = dict.get('Length');
  36361. if (!keyLength) {
  36362. if (algorithm <= 3) {
  36363. keyLength = 40;
  36364. } else {
  36365. var cfDict = dict.get('CF');
  36366. var streamCryptoName = dict.get('StmF');
  36367. if (isDict(cfDict) && isName(streamCryptoName)) {
  36368. cfDict.suppressEncryption = true;
  36369. var handlerDict = cfDict.get(streamCryptoName.name);
  36370. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36371. if (keyLength < 40) {
  36372. keyLength <<= 3;
  36373. }
  36374. }
  36375. }
  36376. }
  36377. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36378. error('invalid key length');
  36379. }
  36380. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36381. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36382. var flags = dict.get('P');
  36383. var revision = dict.get('R');
  36384. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36385. this.encryptMetadata = encryptMetadata;
  36386. var fileIdBytes = stringToBytes(fileId);
  36387. var passwordBytes;
  36388. if (password) {
  36389. if (revision === 6) {
  36390. try {
  36391. password = utf8StringToString(password);
  36392. } catch (ex) {
  36393. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36394. }
  36395. }
  36396. passwordBytes = stringToBytes(password);
  36397. }
  36398. var encryptionKey;
  36399. if (algorithm !== 5) {
  36400. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36401. } else {
  36402. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36403. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36404. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36405. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36406. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36407. var ownerEncryption = stringToBytes(dict.get('OE'));
  36408. var userEncryption = stringToBytes(dict.get('UE'));
  36409. var perms = stringToBytes(dict.get('Perms'));
  36410. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36411. }
  36412. if (!encryptionKey && !password) {
  36413. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36414. } else if (!encryptionKey && password) {
  36415. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36416. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36417. }
  36418. if (!encryptionKey) {
  36419. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36420. }
  36421. this.encryptionKey = encryptionKey;
  36422. if (algorithm >= 4) {
  36423. var cf = dict.get('CF');
  36424. if (isDict(cf)) {
  36425. cf.suppressEncryption = true;
  36426. }
  36427. this.cf = cf;
  36428. this.stmf = dict.get('StmF') || identityName;
  36429. this.strf = dict.get('StrF') || identityName;
  36430. this.eff = dict.get('EFF') || this.stmf;
  36431. }
  36432. }
  36433. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36434. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36435. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36436. key[i] = encryptionKey[i];
  36437. }
  36438. key[i++] = num & 0xFF;
  36439. key[i++] = num >> 8 & 0xFF;
  36440. key[i++] = num >> 16 & 0xFF;
  36441. key[i++] = gen & 0xFF;
  36442. key[i++] = gen >> 8 & 0xFF;
  36443. if (isAes) {
  36444. key[i++] = 0x73;
  36445. key[i++] = 0x41;
  36446. key[i++] = 0x6C;
  36447. key[i++] = 0x54;
  36448. }
  36449. var hash = calculateMD5(key, 0, i);
  36450. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36451. }
  36452. function buildCipherConstructor(cf, name, num, gen, key) {
  36453. assert(isName(name), 'Invalid crypt filter name.');
  36454. var cryptFilter = cf.get(name.name);
  36455. var cfm;
  36456. if (cryptFilter !== null && cryptFilter !== undefined) {
  36457. cfm = cryptFilter.get('CFM');
  36458. }
  36459. if (!cfm || cfm.name === 'None') {
  36460. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36461. return new NullCipher();
  36462. };
  36463. }
  36464. if ('V2' === cfm.name) {
  36465. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36466. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36467. };
  36468. }
  36469. if ('AESV2' === cfm.name) {
  36470. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36471. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36472. };
  36473. }
  36474. if ('AESV3' === cfm.name) {
  36475. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36476. return new AES256Cipher(key);
  36477. };
  36478. }
  36479. error('Unknown crypto method');
  36480. }
  36481. CipherTransformFactory.prototype = {
  36482. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36483. if (this.algorithm === 4 || this.algorithm === 5) {
  36484. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36485. }
  36486. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36487. var cipherConstructor = function buildCipherCipherConstructor() {
  36488. return new ARCFourCipher(key);
  36489. };
  36490. return new CipherTransform(cipherConstructor, cipherConstructor);
  36491. }
  36492. };
  36493. return CipherTransformFactory;
  36494. }();
  36495. exports.AES128Cipher = AES128Cipher;
  36496. exports.AES256Cipher = AES256Cipher;
  36497. exports.ARCFourCipher = ARCFourCipher;
  36498. exports.CipherTransformFactory = CipherTransformFactory;
  36499. exports.PDF17 = PDF17;
  36500. exports.PDF20 = PDF20;
  36501. exports.calculateMD5 = calculateMD5;
  36502. exports.calculateSHA256 = calculateSHA256;
  36503. exports.calculateSHA384 = calculateSHA384;
  36504. exports.calculateSHA512 = calculateSHA512;
  36505. }));
  36506. (function (root, factory) {
  36507. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36508. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36509. var Util = sharedUtil.Util;
  36510. var bytesToString = sharedUtil.bytesToString;
  36511. var error = sharedUtil.error;
  36512. var Stream = coreStream.Stream;
  36513. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36514. var StandardEncoding = coreEncodings.StandardEncoding;
  36515. var CFFParser = coreCFFParser.CFFParser;
  36516. var FontRendererFactory = function FontRendererFactoryClosure() {
  36517. function getLong(data, offset) {
  36518. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36519. }
  36520. function getUshort(data, offset) {
  36521. return data[offset] << 8 | data[offset + 1];
  36522. }
  36523. function parseCmap(data, start, end) {
  36524. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36525. var format = getUshort(data, start + offset);
  36526. var length, ranges, p, i;
  36527. if (format === 4) {
  36528. length = getUshort(data, start + offset + 2);
  36529. var segCount = getUshort(data, start + offset + 6) >> 1;
  36530. p = start + offset + 14;
  36531. ranges = [];
  36532. for (i = 0; i < segCount; i++, p += 2) {
  36533. ranges[i] = { end: getUshort(data, p) };
  36534. }
  36535. p += 2;
  36536. for (i = 0; i < segCount; i++, p += 2) {
  36537. ranges[i].start = getUshort(data, p);
  36538. }
  36539. for (i = 0; i < segCount; i++, p += 2) {
  36540. ranges[i].idDelta = getUshort(data, p);
  36541. }
  36542. for (i = 0; i < segCount; i++, p += 2) {
  36543. var idOffset = getUshort(data, p);
  36544. if (idOffset === 0) {
  36545. continue;
  36546. }
  36547. ranges[i].ids = [];
  36548. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36549. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36550. idOffset += 2;
  36551. }
  36552. }
  36553. return ranges;
  36554. } else if (format === 12) {
  36555. length = getLong(data, start + offset + 4);
  36556. var groups = getLong(data, start + offset + 12);
  36557. p = start + offset + 16;
  36558. ranges = [];
  36559. for (i = 0; i < groups; i++) {
  36560. ranges.push({
  36561. start: getLong(data, p),
  36562. end: getLong(data, p + 4),
  36563. idDelta: getLong(data, p + 8) - getLong(data, p)
  36564. });
  36565. p += 12;
  36566. }
  36567. return ranges;
  36568. }
  36569. error('not supported cmap: ' + format);
  36570. }
  36571. function parseCff(data, start, end, seacAnalysisEnabled) {
  36572. var properties = {};
  36573. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36574. var cff = parser.parse();
  36575. return {
  36576. glyphs: cff.charStrings.objects,
  36577. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36578. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36579. };
  36580. }
  36581. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36582. var itemSize, itemDecode;
  36583. if (isGlyphLocationsLong) {
  36584. itemSize = 4;
  36585. itemDecode = function fontItemDecodeLong(data, offset) {
  36586. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36587. };
  36588. } else {
  36589. itemSize = 2;
  36590. itemDecode = function fontItemDecode(data, offset) {
  36591. return data[offset] << 9 | data[offset + 1] << 1;
  36592. };
  36593. }
  36594. var glyphs = [];
  36595. var startOffset = itemDecode(loca, 0);
  36596. for (var j = itemSize; j < loca.length; j += itemSize) {
  36597. var endOffset = itemDecode(loca, j);
  36598. glyphs.push(glyf.subarray(startOffset, endOffset));
  36599. startOffset = endOffset;
  36600. }
  36601. return glyphs;
  36602. }
  36603. function lookupCmap(ranges, unicode) {
  36604. var code = unicode.charCodeAt(0), gid = 0;
  36605. var l = 0, r = ranges.length - 1;
  36606. while (l < r) {
  36607. var c = l + r + 1 >> 1;
  36608. if (code < ranges[c].start) {
  36609. r = c - 1;
  36610. } else {
  36611. l = c;
  36612. }
  36613. }
  36614. if (ranges[l].start <= code && code <= ranges[l].end) {
  36615. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36616. }
  36617. return {
  36618. charCode: code,
  36619. glyphId: gid
  36620. };
  36621. }
  36622. function compileGlyf(code, cmds, font) {
  36623. function moveTo(x, y) {
  36624. cmds.push({
  36625. cmd: 'moveTo',
  36626. args: [
  36627. x,
  36628. y
  36629. ]
  36630. });
  36631. }
  36632. function lineTo(x, y) {
  36633. cmds.push({
  36634. cmd: 'lineTo',
  36635. args: [
  36636. x,
  36637. y
  36638. ]
  36639. });
  36640. }
  36641. function quadraticCurveTo(xa, ya, x, y) {
  36642. cmds.push({
  36643. cmd: 'quadraticCurveTo',
  36644. args: [
  36645. xa,
  36646. ya,
  36647. x,
  36648. y
  36649. ]
  36650. });
  36651. }
  36652. var i = 0;
  36653. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36654. var flags;
  36655. var x = 0, y = 0;
  36656. i += 10;
  36657. if (numberOfContours < 0) {
  36658. do {
  36659. flags = code[i] << 8 | code[i + 1];
  36660. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36661. i += 4;
  36662. var arg1, arg2;
  36663. if (flags & 0x01) {
  36664. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36665. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36666. i += 4;
  36667. } else {
  36668. arg1 = code[i++];
  36669. arg2 = code[i++];
  36670. }
  36671. if (flags & 0x02) {
  36672. x = arg1;
  36673. y = arg2;
  36674. } else {
  36675. x = 0;
  36676. y = 0;
  36677. }
  36678. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36679. if (flags & 0x08) {
  36680. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36681. i += 2;
  36682. } else if (flags & 0x40) {
  36683. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36684. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36685. i += 4;
  36686. } else if (flags & 0x80) {
  36687. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36688. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36689. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36690. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36691. i += 8;
  36692. }
  36693. var subglyph = font.glyphs[glyphIndex];
  36694. if (subglyph) {
  36695. cmds.push({ cmd: 'save' });
  36696. cmds.push({
  36697. cmd: 'transform',
  36698. args: [
  36699. scaleX,
  36700. scale01,
  36701. scale10,
  36702. scaleY,
  36703. x,
  36704. y
  36705. ]
  36706. });
  36707. compileGlyf(subglyph, cmds, font);
  36708. cmds.push({ cmd: 'restore' });
  36709. }
  36710. } while (flags & 0x20);
  36711. } else {
  36712. var endPtsOfContours = [];
  36713. var j, jj;
  36714. for (j = 0; j < numberOfContours; j++) {
  36715. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36716. i += 2;
  36717. }
  36718. var instructionLength = code[i] << 8 | code[i + 1];
  36719. i += 2 + instructionLength;
  36720. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36721. var points = [];
  36722. while (points.length < numberOfPoints) {
  36723. flags = code[i++];
  36724. var repeat = 1;
  36725. if (flags & 0x08) {
  36726. repeat += code[i++];
  36727. }
  36728. while (repeat-- > 0) {
  36729. points.push({ flags: flags });
  36730. }
  36731. }
  36732. for (j = 0; j < numberOfPoints; j++) {
  36733. switch (points[j].flags & 0x12) {
  36734. case 0x00:
  36735. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36736. i += 2;
  36737. break;
  36738. case 0x02:
  36739. x -= code[i++];
  36740. break;
  36741. case 0x12:
  36742. x += code[i++];
  36743. break;
  36744. }
  36745. points[j].x = x;
  36746. }
  36747. for (j = 0; j < numberOfPoints; j++) {
  36748. switch (points[j].flags & 0x24) {
  36749. case 0x00:
  36750. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36751. i += 2;
  36752. break;
  36753. case 0x04:
  36754. y -= code[i++];
  36755. break;
  36756. case 0x24:
  36757. y += code[i++];
  36758. break;
  36759. }
  36760. points[j].y = y;
  36761. }
  36762. var startPoint = 0;
  36763. for (i = 0; i < numberOfContours; i++) {
  36764. var endPoint = endPtsOfContours[i];
  36765. var contour = points.slice(startPoint, endPoint + 1);
  36766. if (contour[0].flags & 1) {
  36767. contour.push(contour[0]);
  36768. } else if (contour[contour.length - 1].flags & 1) {
  36769. contour.unshift(contour[contour.length - 1]);
  36770. } else {
  36771. var p = {
  36772. flags: 1,
  36773. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36774. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36775. };
  36776. contour.unshift(p);
  36777. contour.push(p);
  36778. }
  36779. moveTo(contour[0].x, contour[0].y);
  36780. for (j = 1, jj = contour.length; j < jj; j++) {
  36781. if (contour[j].flags & 1) {
  36782. lineTo(contour[j].x, contour[j].y);
  36783. } else if (contour[j + 1].flags & 1) {
  36784. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36785. j++;
  36786. } else {
  36787. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36788. }
  36789. }
  36790. startPoint = endPoint + 1;
  36791. }
  36792. }
  36793. }
  36794. function compileCharString(code, cmds, font) {
  36795. var stack = [];
  36796. var x = 0, y = 0;
  36797. var stems = 0;
  36798. function moveTo(x, y) {
  36799. cmds.push({
  36800. cmd: 'moveTo',
  36801. args: [
  36802. x,
  36803. y
  36804. ]
  36805. });
  36806. }
  36807. function lineTo(x, y) {
  36808. cmds.push({
  36809. cmd: 'lineTo',
  36810. args: [
  36811. x,
  36812. y
  36813. ]
  36814. });
  36815. }
  36816. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36817. cmds.push({
  36818. cmd: 'bezierCurveTo',
  36819. args: [
  36820. x1,
  36821. y1,
  36822. x2,
  36823. y2,
  36824. x,
  36825. y
  36826. ]
  36827. });
  36828. }
  36829. function parse(code) {
  36830. var i = 0;
  36831. while (i < code.length) {
  36832. var stackClean = false;
  36833. var v = code[i++];
  36834. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  36835. switch (v) {
  36836. case 1:
  36837. stems += stack.length >> 1;
  36838. stackClean = true;
  36839. break;
  36840. case 3:
  36841. stems += stack.length >> 1;
  36842. stackClean = true;
  36843. break;
  36844. case 4:
  36845. y += stack.pop();
  36846. moveTo(x, y);
  36847. stackClean = true;
  36848. break;
  36849. case 5:
  36850. while (stack.length > 0) {
  36851. x += stack.shift();
  36852. y += stack.shift();
  36853. lineTo(x, y);
  36854. }
  36855. break;
  36856. case 6:
  36857. while (stack.length > 0) {
  36858. x += stack.shift();
  36859. lineTo(x, y);
  36860. if (stack.length === 0) {
  36861. break;
  36862. }
  36863. y += stack.shift();
  36864. lineTo(x, y);
  36865. }
  36866. break;
  36867. case 7:
  36868. while (stack.length > 0) {
  36869. y += stack.shift();
  36870. lineTo(x, y);
  36871. if (stack.length === 0) {
  36872. break;
  36873. }
  36874. x += stack.shift();
  36875. lineTo(x, y);
  36876. }
  36877. break;
  36878. case 8:
  36879. while (stack.length > 0) {
  36880. xa = x + stack.shift();
  36881. ya = y + stack.shift();
  36882. xb = xa + stack.shift();
  36883. yb = ya + stack.shift();
  36884. x = xb + stack.shift();
  36885. y = yb + stack.shift();
  36886. bezierCurveTo(xa, ya, xb, yb, x, y);
  36887. }
  36888. break;
  36889. case 10:
  36890. n = stack.pop() + font.subrsBias;
  36891. subrCode = font.subrs[n];
  36892. if (subrCode) {
  36893. parse(subrCode);
  36894. }
  36895. break;
  36896. case 11:
  36897. return;
  36898. case 12:
  36899. v = code[i++];
  36900. switch (v) {
  36901. case 34:
  36902. xa = x + stack.shift();
  36903. xb = xa + stack.shift();
  36904. y1 = y + stack.shift();
  36905. x = xb + stack.shift();
  36906. bezierCurveTo(xa, y, xb, y1, x, y1);
  36907. xa = x + stack.shift();
  36908. xb = xa + stack.shift();
  36909. x = xb + stack.shift();
  36910. bezierCurveTo(xa, y1, xb, y, x, y);
  36911. break;
  36912. case 35:
  36913. xa = x + stack.shift();
  36914. ya = y + stack.shift();
  36915. xb = xa + stack.shift();
  36916. yb = ya + stack.shift();
  36917. x = xb + stack.shift();
  36918. y = yb + stack.shift();
  36919. bezierCurveTo(xa, ya, xb, yb, x, y);
  36920. xa = x + stack.shift();
  36921. ya = y + stack.shift();
  36922. xb = xa + stack.shift();
  36923. yb = ya + stack.shift();
  36924. x = xb + stack.shift();
  36925. y = yb + stack.shift();
  36926. bezierCurveTo(xa, ya, xb, yb, x, y);
  36927. stack.pop();
  36928. break;
  36929. case 36:
  36930. xa = x + stack.shift();
  36931. y1 = y + stack.shift();
  36932. xb = xa + stack.shift();
  36933. y2 = y1 + stack.shift();
  36934. x = xb + stack.shift();
  36935. bezierCurveTo(xa, y1, xb, y2, x, y2);
  36936. xa = x + stack.shift();
  36937. xb = xa + stack.shift();
  36938. y3 = y2 + stack.shift();
  36939. x = xb + stack.shift();
  36940. bezierCurveTo(xa, y2, xb, y3, x, y);
  36941. break;
  36942. case 37:
  36943. var x0 = x, y0 = y;
  36944. xa = x + stack.shift();
  36945. ya = y + stack.shift();
  36946. xb = xa + stack.shift();
  36947. yb = ya + stack.shift();
  36948. x = xb + stack.shift();
  36949. y = yb + stack.shift();
  36950. bezierCurveTo(xa, ya, xb, yb, x, y);
  36951. xa = x + stack.shift();
  36952. ya = y + stack.shift();
  36953. xb = xa + stack.shift();
  36954. yb = ya + stack.shift();
  36955. x = xb;
  36956. y = yb;
  36957. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  36958. x += stack.shift();
  36959. } else {
  36960. y += stack.shift();
  36961. }
  36962. bezierCurveTo(xa, ya, xb, yb, x, y);
  36963. break;
  36964. default:
  36965. error('unknown operator: 12 ' + v);
  36966. }
  36967. break;
  36968. case 14:
  36969. if (stack.length >= 4) {
  36970. var achar = stack.pop();
  36971. var bchar = stack.pop();
  36972. y = stack.pop();
  36973. x = stack.pop();
  36974. cmds.push({ cmd: 'save' });
  36975. cmds.push({
  36976. cmd: 'translate',
  36977. args: [
  36978. x,
  36979. y
  36980. ]
  36981. });
  36982. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  36983. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36984. cmds.push({ cmd: 'restore' });
  36985. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  36986. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36987. }
  36988. return;
  36989. case 18:
  36990. stems += stack.length >> 1;
  36991. stackClean = true;
  36992. break;
  36993. case 19:
  36994. stems += stack.length >> 1;
  36995. i += stems + 7 >> 3;
  36996. stackClean = true;
  36997. break;
  36998. case 20:
  36999. stems += stack.length >> 1;
  37000. i += stems + 7 >> 3;
  37001. stackClean = true;
  37002. break;
  37003. case 21:
  37004. y += stack.pop();
  37005. x += stack.pop();
  37006. moveTo(x, y);
  37007. stackClean = true;
  37008. break;
  37009. case 22:
  37010. x += stack.pop();
  37011. moveTo(x, y);
  37012. stackClean = true;
  37013. break;
  37014. case 23:
  37015. stems += stack.length >> 1;
  37016. stackClean = true;
  37017. break;
  37018. case 24:
  37019. while (stack.length > 2) {
  37020. xa = x + stack.shift();
  37021. ya = y + stack.shift();
  37022. xb = xa + stack.shift();
  37023. yb = ya + stack.shift();
  37024. x = xb + stack.shift();
  37025. y = yb + stack.shift();
  37026. bezierCurveTo(xa, ya, xb, yb, x, y);
  37027. }
  37028. x += stack.shift();
  37029. y += stack.shift();
  37030. lineTo(x, y);
  37031. break;
  37032. case 25:
  37033. while (stack.length > 6) {
  37034. x += stack.shift();
  37035. y += stack.shift();
  37036. lineTo(x, y);
  37037. }
  37038. xa = x + stack.shift();
  37039. ya = y + stack.shift();
  37040. xb = xa + stack.shift();
  37041. yb = ya + stack.shift();
  37042. x = xb + stack.shift();
  37043. y = yb + stack.shift();
  37044. bezierCurveTo(xa, ya, xb, yb, x, y);
  37045. break;
  37046. case 26:
  37047. if (stack.length % 2) {
  37048. x += stack.shift();
  37049. }
  37050. while (stack.length > 0) {
  37051. xa = x;
  37052. ya = y + stack.shift();
  37053. xb = xa + stack.shift();
  37054. yb = ya + stack.shift();
  37055. x = xb;
  37056. y = yb + stack.shift();
  37057. bezierCurveTo(xa, ya, xb, yb, x, y);
  37058. }
  37059. break;
  37060. case 27:
  37061. if (stack.length % 2) {
  37062. y += stack.shift();
  37063. }
  37064. while (stack.length > 0) {
  37065. xa = x + stack.shift();
  37066. ya = y;
  37067. xb = xa + stack.shift();
  37068. yb = ya + stack.shift();
  37069. x = xb + stack.shift();
  37070. y = yb;
  37071. bezierCurveTo(xa, ya, xb, yb, x, y);
  37072. }
  37073. break;
  37074. case 28:
  37075. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37076. i += 2;
  37077. break;
  37078. case 29:
  37079. n = stack.pop() + font.gsubrsBias;
  37080. subrCode = font.gsubrs[n];
  37081. if (subrCode) {
  37082. parse(subrCode);
  37083. }
  37084. break;
  37085. case 30:
  37086. while (stack.length > 0) {
  37087. xa = x;
  37088. ya = y + stack.shift();
  37089. xb = xa + stack.shift();
  37090. yb = ya + stack.shift();
  37091. x = xb + stack.shift();
  37092. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37093. bezierCurveTo(xa, ya, xb, yb, x, y);
  37094. if (stack.length === 0) {
  37095. break;
  37096. }
  37097. xa = x + stack.shift();
  37098. ya = y;
  37099. xb = xa + stack.shift();
  37100. yb = ya + stack.shift();
  37101. y = yb + stack.shift();
  37102. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37103. bezierCurveTo(xa, ya, xb, yb, x, y);
  37104. }
  37105. break;
  37106. case 31:
  37107. while (stack.length > 0) {
  37108. xa = x + stack.shift();
  37109. ya = y;
  37110. xb = xa + stack.shift();
  37111. yb = ya + stack.shift();
  37112. y = yb + stack.shift();
  37113. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37114. bezierCurveTo(xa, ya, xb, yb, x, y);
  37115. if (stack.length === 0) {
  37116. break;
  37117. }
  37118. xa = x;
  37119. ya = y + stack.shift();
  37120. xb = xa + stack.shift();
  37121. yb = ya + stack.shift();
  37122. x = xb + stack.shift();
  37123. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37124. bezierCurveTo(xa, ya, xb, yb, x, y);
  37125. }
  37126. break;
  37127. default:
  37128. if (v < 32) {
  37129. error('unknown operator: ' + v);
  37130. }
  37131. if (v < 247) {
  37132. stack.push(v - 139);
  37133. } else if (v < 251) {
  37134. stack.push((v - 247) * 256 + code[i++] + 108);
  37135. } else if (v < 255) {
  37136. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37137. } else {
  37138. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37139. i += 4;
  37140. }
  37141. break;
  37142. }
  37143. if (stackClean) {
  37144. stack.length = 0;
  37145. }
  37146. }
  37147. }
  37148. parse(code);
  37149. }
  37150. var noop = '';
  37151. function CompiledFont(fontMatrix) {
  37152. this.compiledGlyphs = Object.create(null);
  37153. this.compiledCharCodeToGlyphId = Object.create(null);
  37154. this.fontMatrix = fontMatrix;
  37155. }
  37156. CompiledFont.prototype = {
  37157. getPathJs: function (unicode) {
  37158. var cmap = lookupCmap(this.cmap, unicode);
  37159. var fn = this.compiledGlyphs[cmap.glyphId];
  37160. if (!fn) {
  37161. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37162. this.compiledGlyphs[cmap.glyphId] = fn;
  37163. }
  37164. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37165. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37166. }
  37167. return fn;
  37168. },
  37169. compileGlyph: function (code) {
  37170. if (!code || code.length === 0 || code[0] === 14) {
  37171. return noop;
  37172. }
  37173. var cmds = [];
  37174. cmds.push({ cmd: 'save' });
  37175. cmds.push({
  37176. cmd: 'transform',
  37177. args: this.fontMatrix.slice()
  37178. });
  37179. cmds.push({
  37180. cmd: 'scale',
  37181. args: [
  37182. 'size',
  37183. '-size'
  37184. ]
  37185. });
  37186. this.compileGlyphImpl(code, cmds);
  37187. cmds.push({ cmd: 'restore' });
  37188. return cmds;
  37189. },
  37190. compileGlyphImpl: function () {
  37191. error('Children classes should implement this.');
  37192. },
  37193. hasBuiltPath: function (unicode) {
  37194. var cmap = lookupCmap(this.cmap, unicode);
  37195. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37196. }
  37197. };
  37198. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37199. fontMatrix = fontMatrix || [
  37200. 0.000488,
  37201. 0,
  37202. 0,
  37203. 0.000488,
  37204. 0,
  37205. 0
  37206. ];
  37207. CompiledFont.call(this, fontMatrix);
  37208. this.glyphs = glyphs;
  37209. this.cmap = cmap;
  37210. }
  37211. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37212. compileGlyphImpl: function (code, cmds) {
  37213. compileGlyf(code, cmds, this);
  37214. }
  37215. });
  37216. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37217. fontMatrix = fontMatrix || [
  37218. 0.001,
  37219. 0,
  37220. 0,
  37221. 0.001,
  37222. 0,
  37223. 0
  37224. ];
  37225. CompiledFont.call(this, fontMatrix);
  37226. this.glyphs = cffInfo.glyphs;
  37227. this.gsubrs = cffInfo.gsubrs || [];
  37228. this.subrs = cffInfo.subrs || [];
  37229. this.cmap = cmap;
  37230. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37231. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37232. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37233. }
  37234. Util.inherit(Type2Compiled, CompiledFont, {
  37235. compileGlyphImpl: function (code, cmds) {
  37236. compileCharString(code, cmds, this);
  37237. }
  37238. });
  37239. return {
  37240. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37241. var data = new Uint8Array(font.data);
  37242. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37243. var numTables = getUshort(data, 4);
  37244. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37245. var tag = bytesToString(data.subarray(p, p + 4));
  37246. var offset = getLong(data, p + 8);
  37247. var length = getLong(data, p + 12);
  37248. switch (tag) {
  37249. case 'cmap':
  37250. cmap = parseCmap(data, offset, offset + length);
  37251. break;
  37252. case 'glyf':
  37253. glyf = data.subarray(offset, offset + length);
  37254. break;
  37255. case 'loca':
  37256. loca = data.subarray(offset, offset + length);
  37257. break;
  37258. case 'head':
  37259. unitsPerEm = getUshort(data, offset + 18);
  37260. indexToLocFormat = getUshort(data, offset + 50);
  37261. break;
  37262. case 'CFF ':
  37263. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37264. break;
  37265. }
  37266. }
  37267. if (glyf) {
  37268. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37269. 1 / unitsPerEm,
  37270. 0,
  37271. 0,
  37272. 1 / unitsPerEm,
  37273. 0,
  37274. 0
  37275. ];
  37276. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37277. } else {
  37278. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37279. }
  37280. }
  37281. };
  37282. }();
  37283. exports.FontRendererFactory = FontRendererFactory;
  37284. }));
  37285. (function (root, factory) {
  37286. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37287. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37288. var MissingDataException = sharedUtil.MissingDataException;
  37289. var StreamType = sharedUtil.StreamType;
  37290. var assert = sharedUtil.assert;
  37291. var error = sharedUtil.error;
  37292. var info = sharedUtil.info;
  37293. var isArray = sharedUtil.isArray;
  37294. var isInt = sharedUtil.isInt;
  37295. var isNum = sharedUtil.isNum;
  37296. var isString = sharedUtil.isString;
  37297. var warn = sharedUtil.warn;
  37298. var Cmd = corePrimitives.Cmd;
  37299. var Dict = corePrimitives.Dict;
  37300. var Name = corePrimitives.Name;
  37301. var Ref = corePrimitives.Ref;
  37302. var isCmd = corePrimitives.isCmd;
  37303. var isDict = corePrimitives.isDict;
  37304. var isName = corePrimitives.isName;
  37305. var Ascii85Stream = coreStream.Ascii85Stream;
  37306. var AsciiHexStream = coreStream.AsciiHexStream;
  37307. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37308. var FlateStream = coreStream.FlateStream;
  37309. var Jbig2Stream = coreStream.Jbig2Stream;
  37310. var JpegStream = coreStream.JpegStream;
  37311. var JpxStream = coreStream.JpxStream;
  37312. var LZWStream = coreStream.LZWStream;
  37313. var NullStream = coreStream.NullStream;
  37314. var PredictorStream = coreStream.PredictorStream;
  37315. var RunLengthStream = coreStream.RunLengthStream;
  37316. var EOF = {};
  37317. function isEOF(v) {
  37318. return v === EOF;
  37319. }
  37320. var MAX_LENGTH_TO_CACHE = 1000;
  37321. var Parser = function ParserClosure() {
  37322. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37323. this.lexer = lexer;
  37324. this.allowStreams = allowStreams;
  37325. this.xref = xref;
  37326. this.recoveryMode = recoveryMode || false;
  37327. this.imageCache = Object.create(null);
  37328. this.refill();
  37329. }
  37330. Parser.prototype = {
  37331. refill: function Parser_refill() {
  37332. this.buf1 = this.lexer.getObj();
  37333. this.buf2 = this.lexer.getObj();
  37334. },
  37335. shift: function Parser_shift() {
  37336. if (isCmd(this.buf2, 'ID')) {
  37337. this.buf1 = this.buf2;
  37338. this.buf2 = null;
  37339. } else {
  37340. this.buf1 = this.buf2;
  37341. this.buf2 = this.lexer.getObj();
  37342. }
  37343. },
  37344. tryShift: function Parser_tryShift() {
  37345. try {
  37346. this.shift();
  37347. return true;
  37348. } catch (e) {
  37349. if (e instanceof MissingDataException) {
  37350. throw e;
  37351. }
  37352. return false;
  37353. }
  37354. },
  37355. getObj: function Parser_getObj(cipherTransform) {
  37356. var buf1 = this.buf1;
  37357. this.shift();
  37358. if (buf1 instanceof Cmd) {
  37359. switch (buf1.cmd) {
  37360. case 'BI':
  37361. return this.makeInlineImage(cipherTransform);
  37362. case '[':
  37363. var array = [];
  37364. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37365. array.push(this.getObj(cipherTransform));
  37366. }
  37367. if (isEOF(this.buf1)) {
  37368. if (!this.recoveryMode) {
  37369. error('End of file inside array');
  37370. }
  37371. return array;
  37372. }
  37373. this.shift();
  37374. return array;
  37375. case '<<':
  37376. var dict = new Dict(this.xref);
  37377. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37378. if (!isName(this.buf1)) {
  37379. info('Malformed dictionary: key must be a name object');
  37380. this.shift();
  37381. continue;
  37382. }
  37383. var key = this.buf1.name;
  37384. this.shift();
  37385. if (isEOF(this.buf1)) {
  37386. break;
  37387. }
  37388. dict.set(key, this.getObj(cipherTransform));
  37389. }
  37390. if (isEOF(this.buf1)) {
  37391. if (!this.recoveryMode) {
  37392. error('End of file inside dictionary');
  37393. }
  37394. return dict;
  37395. }
  37396. if (isCmd(this.buf2, 'stream')) {
  37397. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37398. }
  37399. this.shift();
  37400. return dict;
  37401. default:
  37402. return buf1;
  37403. }
  37404. }
  37405. if (isInt(buf1)) {
  37406. var num = buf1;
  37407. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37408. var ref = new Ref(num, this.buf1);
  37409. this.shift();
  37410. this.shift();
  37411. return ref;
  37412. }
  37413. return num;
  37414. }
  37415. if (isString(buf1)) {
  37416. var str = buf1;
  37417. if (cipherTransform) {
  37418. str = cipherTransform.decryptString(str);
  37419. }
  37420. return str;
  37421. }
  37422. return buf1;
  37423. },
  37424. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37425. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37426. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37427. while ((ch = stream.getByte()) !== -1) {
  37428. if (state === 0) {
  37429. state = ch === E ? 1 : 0;
  37430. } else if (state === 1) {
  37431. state = ch === I ? 2 : 0;
  37432. } else {
  37433. assert(state === 2);
  37434. if (ch === SPACE || ch === LF || ch === CR) {
  37435. n = 5;
  37436. followingBytes = stream.peekBytes(n);
  37437. for (i = 0; i < n; i++) {
  37438. ch = followingBytes[i];
  37439. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37440. state = 0;
  37441. break;
  37442. }
  37443. }
  37444. if (state === 2) {
  37445. break;
  37446. }
  37447. } else
  37448. {
  37449. state = 0;
  37450. }
  37451. }
  37452. }
  37453. return stream.pos - 4 - startPos;
  37454. },
  37455. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37456. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37457. while ((b = stream.getByte()) !== -1) {
  37458. if (b !== 0xFF) {
  37459. continue;
  37460. }
  37461. switch (stream.getByte()) {
  37462. case 0x00:
  37463. break;
  37464. case 0xFF:
  37465. stream.skip(-1);
  37466. break;
  37467. case 0xD9:
  37468. foundEOI = true;
  37469. break;
  37470. case 0xC0:
  37471. case 0xC1:
  37472. case 0xC2:
  37473. case 0xC3:
  37474. case 0xC5:
  37475. case 0xC6:
  37476. case 0xC7:
  37477. case 0xC9:
  37478. case 0xCA:
  37479. case 0xCB:
  37480. case 0xCD:
  37481. case 0xCE:
  37482. case 0xCF:
  37483. case 0xC4:
  37484. case 0xCC:
  37485. case 0xDA:
  37486. case 0xDB:
  37487. case 0xDC:
  37488. case 0xDD:
  37489. case 0xDE:
  37490. case 0xDF:
  37491. case 0xE0:
  37492. case 0xE1:
  37493. case 0xE2:
  37494. case 0xE3:
  37495. case 0xE4:
  37496. case 0xE5:
  37497. case 0xE6:
  37498. case 0xE7:
  37499. case 0xE8:
  37500. case 0xE9:
  37501. case 0xEA:
  37502. case 0xEB:
  37503. case 0xEC:
  37504. case 0xED:
  37505. case 0xEE:
  37506. case 0xEF:
  37507. case 0xFE:
  37508. markerLength = stream.getUint16();
  37509. if (markerLength > 2) {
  37510. stream.skip(markerLength - 2);
  37511. } else
  37512. {
  37513. stream.skip(-2);
  37514. }
  37515. break;
  37516. }
  37517. if (foundEOI) {
  37518. break;
  37519. }
  37520. }
  37521. length = stream.pos - startPos;
  37522. if (b === -1) {
  37523. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37524. stream.skip(-length);
  37525. return this.findDefaultInlineStreamEnd(stream);
  37526. }
  37527. this.inlineStreamSkipEI(stream);
  37528. return length;
  37529. },
  37530. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37531. var TILDE = 0x7E, GT = 0x3E;
  37532. var startPos = stream.pos, ch, length;
  37533. while ((ch = stream.getByte()) !== -1) {
  37534. if (ch === TILDE && stream.peekByte() === GT) {
  37535. stream.skip();
  37536. break;
  37537. }
  37538. }
  37539. length = stream.pos - startPos;
  37540. if (ch === -1) {
  37541. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37542. stream.skip(-length);
  37543. return this.findDefaultInlineStreamEnd(stream);
  37544. }
  37545. this.inlineStreamSkipEI(stream);
  37546. return length;
  37547. },
  37548. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37549. var GT = 0x3E;
  37550. var startPos = stream.pos, ch, length;
  37551. while ((ch = stream.getByte()) !== -1) {
  37552. if (ch === GT) {
  37553. break;
  37554. }
  37555. }
  37556. length = stream.pos - startPos;
  37557. if (ch === -1) {
  37558. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37559. stream.skip(-length);
  37560. return this.findDefaultInlineStreamEnd(stream);
  37561. }
  37562. this.inlineStreamSkipEI(stream);
  37563. return length;
  37564. },
  37565. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37566. var E = 0x45, I = 0x49;
  37567. var state = 0, ch;
  37568. while ((ch = stream.getByte()) !== -1) {
  37569. if (state === 0) {
  37570. state = ch === E ? 1 : 0;
  37571. } else if (state === 1) {
  37572. state = ch === I ? 2 : 0;
  37573. } else if (state === 2) {
  37574. break;
  37575. }
  37576. }
  37577. },
  37578. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37579. var lexer = this.lexer;
  37580. var stream = lexer.stream;
  37581. var dict = new Dict(this.xref);
  37582. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37583. if (!isName(this.buf1)) {
  37584. error('Dictionary key must be a name object');
  37585. }
  37586. var key = this.buf1.name;
  37587. this.shift();
  37588. if (isEOF(this.buf1)) {
  37589. break;
  37590. }
  37591. dict.set(key, this.getObj(cipherTransform));
  37592. }
  37593. var filter = dict.get('Filter', 'F'), filterName;
  37594. if (isName(filter)) {
  37595. filterName = filter.name;
  37596. } else if (isArray(filter) && isName(filter[0])) {
  37597. filterName = filter[0].name;
  37598. }
  37599. var startPos = stream.pos, length, i, ii;
  37600. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37601. length = this.findDCTDecodeInlineStreamEnd(stream);
  37602. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37603. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37604. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37605. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37606. } else {
  37607. length = this.findDefaultInlineStreamEnd(stream);
  37608. }
  37609. var imageStream = stream.makeSubStream(startPos, length, dict);
  37610. var adler32;
  37611. if (length < MAX_LENGTH_TO_CACHE) {
  37612. var imageBytes = imageStream.getBytes();
  37613. imageStream.reset();
  37614. var a = 1;
  37615. var b = 0;
  37616. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37617. a += imageBytes[i] & 0xff;
  37618. b += a;
  37619. }
  37620. adler32 = b % 65521 << 16 | a % 65521;
  37621. if (this.imageCache.adler32 === adler32) {
  37622. this.buf2 = Cmd.get('EI');
  37623. this.shift();
  37624. this.imageCache[adler32].reset();
  37625. return this.imageCache[adler32];
  37626. }
  37627. }
  37628. if (cipherTransform) {
  37629. imageStream = cipherTransform.createStream(imageStream, length);
  37630. }
  37631. imageStream = this.filter(imageStream, dict, length);
  37632. imageStream.dict = dict;
  37633. if (adler32 !== undefined) {
  37634. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37635. this.imageCache[adler32] = imageStream;
  37636. }
  37637. this.buf2 = Cmd.get('EI');
  37638. this.shift();
  37639. return imageStream;
  37640. },
  37641. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37642. var lexer = this.lexer;
  37643. var stream = lexer.stream;
  37644. lexer.skipToNextLine();
  37645. var pos = stream.pos - 1;
  37646. var length = dict.get('Length');
  37647. if (!isInt(length)) {
  37648. info('Bad ' + length + ' attribute in stream');
  37649. length = 0;
  37650. }
  37651. stream.pos = pos + length;
  37652. lexer.nextChar();
  37653. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37654. this.shift();
  37655. } else
  37656. {
  37657. stream.pos = pos;
  37658. var SCAN_BLOCK_SIZE = 2048;
  37659. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37660. var ENDSTREAM_SIGNATURE = [
  37661. 0x65,
  37662. 0x6E,
  37663. 0x64,
  37664. 0x73,
  37665. 0x74,
  37666. 0x72,
  37667. 0x65,
  37668. 0x61,
  37669. 0x6D
  37670. ];
  37671. var skipped = 0, found = false, i, j;
  37672. while (stream.pos < stream.end) {
  37673. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37674. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37675. if (scanLength <= 0) {
  37676. break;
  37677. }
  37678. found = false;
  37679. i = 0;
  37680. while (i < scanLength) {
  37681. j = 0;
  37682. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37683. j++;
  37684. }
  37685. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37686. found = true;
  37687. break;
  37688. }
  37689. i++;
  37690. }
  37691. if (found) {
  37692. skipped += i;
  37693. stream.pos += i;
  37694. break;
  37695. }
  37696. skipped += scanLength;
  37697. stream.pos += scanLength;
  37698. }
  37699. if (!found) {
  37700. error('Missing endstream');
  37701. }
  37702. length = skipped;
  37703. lexer.nextChar();
  37704. this.shift();
  37705. this.shift();
  37706. }
  37707. this.shift();
  37708. stream = stream.makeSubStream(pos, length, dict);
  37709. if (cipherTransform) {
  37710. stream = cipherTransform.createStream(stream, length);
  37711. }
  37712. stream = this.filter(stream, dict, length);
  37713. stream.dict = dict;
  37714. return stream;
  37715. },
  37716. filter: function Parser_filter(stream, dict, length) {
  37717. var filter = dict.get('Filter', 'F');
  37718. var params = dict.get('DecodeParms', 'DP');
  37719. if (isName(filter)) {
  37720. if (isArray(params)) {
  37721. params = params[0];
  37722. }
  37723. return this.makeFilter(stream, filter.name, length, params);
  37724. }
  37725. var maybeLength = length;
  37726. if (isArray(filter)) {
  37727. var filterArray = filter;
  37728. var paramsArray = params;
  37729. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37730. filter = filterArray[i];
  37731. if (!isName(filter)) {
  37732. error('Bad filter name: ' + filter);
  37733. }
  37734. params = null;
  37735. if (isArray(paramsArray) && i in paramsArray) {
  37736. params = paramsArray[i];
  37737. }
  37738. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37739. maybeLength = null;
  37740. }
  37741. }
  37742. return stream;
  37743. },
  37744. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37745. if (maybeLength === 0) {
  37746. warn('Empty "' + name + '" stream.');
  37747. return new NullStream(stream);
  37748. }
  37749. try {
  37750. if (params && this.xref) {
  37751. params = this.xref.fetchIfRef(params);
  37752. }
  37753. var xrefStreamStats = this.xref.stats.streamTypes;
  37754. if (name === 'FlateDecode' || name === 'Fl') {
  37755. xrefStreamStats[StreamType.FLATE] = true;
  37756. if (params) {
  37757. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37758. }
  37759. return new FlateStream(stream, maybeLength);
  37760. }
  37761. if (name === 'LZWDecode' || name === 'LZW') {
  37762. xrefStreamStats[StreamType.LZW] = true;
  37763. var earlyChange = 1;
  37764. if (params) {
  37765. if (params.has('EarlyChange')) {
  37766. earlyChange = params.get('EarlyChange');
  37767. }
  37768. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37769. }
  37770. return new LZWStream(stream, maybeLength, earlyChange);
  37771. }
  37772. if (name === 'DCTDecode' || name === 'DCT') {
  37773. xrefStreamStats[StreamType.DCT] = true;
  37774. return new JpegStream(stream, maybeLength, stream.dict, params);
  37775. }
  37776. if (name === 'JPXDecode' || name === 'JPX') {
  37777. xrefStreamStats[StreamType.JPX] = true;
  37778. return new JpxStream(stream, maybeLength, stream.dict, params);
  37779. }
  37780. if (name === 'ASCII85Decode' || name === 'A85') {
  37781. xrefStreamStats[StreamType.A85] = true;
  37782. return new Ascii85Stream(stream, maybeLength);
  37783. }
  37784. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37785. xrefStreamStats[StreamType.AHX] = true;
  37786. return new AsciiHexStream(stream, maybeLength);
  37787. }
  37788. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37789. xrefStreamStats[StreamType.CCF] = true;
  37790. return new CCITTFaxStream(stream, maybeLength, params);
  37791. }
  37792. if (name === 'RunLengthDecode' || name === 'RL') {
  37793. xrefStreamStats[StreamType.RL] = true;
  37794. return new RunLengthStream(stream, maybeLength);
  37795. }
  37796. if (name === 'JBIG2Decode') {
  37797. xrefStreamStats[StreamType.JBIG] = true;
  37798. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37799. }
  37800. warn('filter "' + name + '" not supported yet');
  37801. return stream;
  37802. } catch (ex) {
  37803. if (ex instanceof MissingDataException) {
  37804. throw ex;
  37805. }
  37806. warn('Invalid stream: \"' + ex + '\"');
  37807. return new NullStream(stream);
  37808. }
  37809. }
  37810. };
  37811. return Parser;
  37812. }();
  37813. var Lexer = function LexerClosure() {
  37814. function Lexer(stream, knownCommands) {
  37815. this.stream = stream;
  37816. this.nextChar();
  37817. this.strBuf = [];
  37818. this.knownCommands = knownCommands;
  37819. }
  37820. var specialChars = [
  37821. 1,
  37822. 0,
  37823. 0,
  37824. 0,
  37825. 0,
  37826. 0,
  37827. 0,
  37828. 0,
  37829. 0,
  37830. 1,
  37831. 1,
  37832. 0,
  37833. 1,
  37834. 1,
  37835. 0,
  37836. 0,
  37837. 0,
  37838. 0,
  37839. 0,
  37840. 0,
  37841. 0,
  37842. 0,
  37843. 0,
  37844. 0,
  37845. 0,
  37846. 0,
  37847. 0,
  37848. 0,
  37849. 0,
  37850. 0,
  37851. 0,
  37852. 0,
  37853. 1,
  37854. 0,
  37855. 0,
  37856. 0,
  37857. 0,
  37858. 2,
  37859. 0,
  37860. 0,
  37861. 2,
  37862. 2,
  37863. 0,
  37864. 0,
  37865. 0,
  37866. 0,
  37867. 0,
  37868. 2,
  37869. 0,
  37870. 0,
  37871. 0,
  37872. 0,
  37873. 0,
  37874. 0,
  37875. 0,
  37876. 0,
  37877. 0,
  37878. 0,
  37879. 0,
  37880. 0,
  37881. 2,
  37882. 0,
  37883. 2,
  37884. 0,
  37885. 0,
  37886. 0,
  37887. 0,
  37888. 0,
  37889. 0,
  37890. 0,
  37891. 0,
  37892. 0,
  37893. 0,
  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. 2,
  37913. 0,
  37914. 2,
  37915. 0,
  37916. 0,
  37917. 0,
  37918. 0,
  37919. 0,
  37920. 0,
  37921. 0,
  37922. 0,
  37923. 0,
  37924. 0,
  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. 2,
  37945. 0,
  37946. 2,
  37947. 0,
  37948. 0,
  37949. 0,
  37950. 0,
  37951. 0,
  37952. 0,
  37953. 0,
  37954. 0,
  37955. 0,
  37956. 0,
  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. ];
  38078. function toHexDigit(ch) {
  38079. if (ch >= 0x30 && ch <= 0x39) {
  38080. return ch & 0x0F;
  38081. }
  38082. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38083. return (ch & 0x0F) + 9;
  38084. }
  38085. return -1;
  38086. }
  38087. Lexer.prototype = {
  38088. nextChar: function Lexer_nextChar() {
  38089. return this.currentChar = this.stream.getByte();
  38090. },
  38091. peekChar: function Lexer_peekChar() {
  38092. return this.stream.peekByte();
  38093. },
  38094. getNumber: function Lexer_getNumber() {
  38095. var ch = this.currentChar;
  38096. var eNotation = false;
  38097. var divideBy = 0;
  38098. var sign = 1;
  38099. if (ch === 0x2D) {
  38100. sign = -1;
  38101. ch = this.nextChar();
  38102. if (ch === 0x2D) {
  38103. ch = this.nextChar();
  38104. }
  38105. } else if (ch === 0x2B) {
  38106. ch = this.nextChar();
  38107. }
  38108. if (ch === 0x2E) {
  38109. divideBy = 10;
  38110. ch = this.nextChar();
  38111. }
  38112. if (ch < 0x30 || ch > 0x39) {
  38113. error('Invalid number: ' + String.fromCharCode(ch));
  38114. return 0;
  38115. }
  38116. var baseValue = ch - 0x30;
  38117. var powerValue = 0;
  38118. var powerValueSign = 1;
  38119. while ((ch = this.nextChar()) >= 0) {
  38120. if (0x30 <= ch && ch <= 0x39) {
  38121. var currentDigit = ch - 0x30;
  38122. if (eNotation) {
  38123. powerValue = powerValue * 10 + currentDigit;
  38124. } else {
  38125. if (divideBy !== 0) {
  38126. divideBy *= 10;
  38127. }
  38128. baseValue = baseValue * 10 + currentDigit;
  38129. }
  38130. } else if (ch === 0x2E) {
  38131. if (divideBy === 0) {
  38132. divideBy = 1;
  38133. } else {
  38134. break;
  38135. }
  38136. } else if (ch === 0x2D) {
  38137. warn('Badly formatted number');
  38138. } else if (ch === 0x45 || ch === 0x65) {
  38139. ch = this.peekChar();
  38140. if (ch === 0x2B || ch === 0x2D) {
  38141. powerValueSign = ch === 0x2D ? -1 : 1;
  38142. this.nextChar();
  38143. } else if (ch < 0x30 || ch > 0x39) {
  38144. break;
  38145. }
  38146. eNotation = true;
  38147. } else {
  38148. break;
  38149. }
  38150. }
  38151. if (divideBy !== 0) {
  38152. baseValue /= divideBy;
  38153. }
  38154. if (eNotation) {
  38155. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38156. }
  38157. return sign * baseValue;
  38158. },
  38159. getString: function Lexer_getString() {
  38160. var numParen = 1;
  38161. var done = false;
  38162. var strBuf = this.strBuf;
  38163. strBuf.length = 0;
  38164. var ch = this.nextChar();
  38165. while (true) {
  38166. var charBuffered = false;
  38167. switch (ch | 0) {
  38168. case -1:
  38169. warn('Unterminated string');
  38170. done = true;
  38171. break;
  38172. case 0x28:
  38173. ++numParen;
  38174. strBuf.push('(');
  38175. break;
  38176. case 0x29:
  38177. if (--numParen === 0) {
  38178. this.nextChar();
  38179. done = true;
  38180. } else {
  38181. strBuf.push(')');
  38182. }
  38183. break;
  38184. case 0x5C:
  38185. ch = this.nextChar();
  38186. switch (ch) {
  38187. case -1:
  38188. warn('Unterminated string');
  38189. done = true;
  38190. break;
  38191. case 0x6E:
  38192. strBuf.push('\n');
  38193. break;
  38194. case 0x72:
  38195. strBuf.push('\r');
  38196. break;
  38197. case 0x74:
  38198. strBuf.push('\t');
  38199. break;
  38200. case 0x62:
  38201. strBuf.push('\b');
  38202. break;
  38203. case 0x66:
  38204. strBuf.push('\f');
  38205. break;
  38206. case 0x5C:
  38207. case 0x28:
  38208. case 0x29:
  38209. strBuf.push(String.fromCharCode(ch));
  38210. break;
  38211. case 0x30:
  38212. case 0x31:
  38213. case 0x32:
  38214. case 0x33:
  38215. case 0x34:
  38216. case 0x35:
  38217. case 0x36:
  38218. case 0x37:
  38219. var x = ch & 0x0F;
  38220. ch = this.nextChar();
  38221. charBuffered = true;
  38222. if (ch >= 0x30 && ch <= 0x37) {
  38223. x = (x << 3) + (ch & 0x0F);
  38224. ch = this.nextChar();
  38225. if (ch >= 0x30 && ch <= 0x37) {
  38226. charBuffered = false;
  38227. x = (x << 3) + (ch & 0x0F);
  38228. }
  38229. }
  38230. strBuf.push(String.fromCharCode(x));
  38231. break;
  38232. case 0x0D:
  38233. if (this.peekChar() === 0x0A) {
  38234. this.nextChar();
  38235. }
  38236. break;
  38237. case 0x0A:
  38238. break;
  38239. default:
  38240. strBuf.push(String.fromCharCode(ch));
  38241. break;
  38242. }
  38243. break;
  38244. default:
  38245. strBuf.push(String.fromCharCode(ch));
  38246. break;
  38247. }
  38248. if (done) {
  38249. break;
  38250. }
  38251. if (!charBuffered) {
  38252. ch = this.nextChar();
  38253. }
  38254. }
  38255. return strBuf.join('');
  38256. },
  38257. getName: function Lexer_getName() {
  38258. var ch, previousCh;
  38259. var strBuf = this.strBuf;
  38260. strBuf.length = 0;
  38261. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38262. if (ch === 0x23) {
  38263. ch = this.nextChar();
  38264. if (specialChars[ch]) {
  38265. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38266. strBuf.push('#');
  38267. break;
  38268. }
  38269. var x = toHexDigit(ch);
  38270. if (x !== -1) {
  38271. previousCh = ch;
  38272. ch = this.nextChar();
  38273. var x2 = toHexDigit(ch);
  38274. if (x2 === -1) {
  38275. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38276. strBuf.push('#', String.fromCharCode(previousCh));
  38277. if (specialChars[ch]) {
  38278. break;
  38279. }
  38280. strBuf.push(String.fromCharCode(ch));
  38281. continue;
  38282. }
  38283. strBuf.push(String.fromCharCode(x << 4 | x2));
  38284. } else {
  38285. strBuf.push('#', String.fromCharCode(ch));
  38286. }
  38287. } else {
  38288. strBuf.push(String.fromCharCode(ch));
  38289. }
  38290. }
  38291. if (strBuf.length > 127) {
  38292. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38293. }
  38294. return Name.get(strBuf.join(''));
  38295. },
  38296. getHexString: function Lexer_getHexString() {
  38297. var strBuf = this.strBuf;
  38298. strBuf.length = 0;
  38299. var ch = this.currentChar;
  38300. var isFirstHex = true;
  38301. var firstDigit;
  38302. var secondDigit;
  38303. while (true) {
  38304. if (ch < 0) {
  38305. warn('Unterminated hex string');
  38306. break;
  38307. } else if (ch === 0x3E) {
  38308. this.nextChar();
  38309. break;
  38310. } else if (specialChars[ch] === 1) {
  38311. ch = this.nextChar();
  38312. continue;
  38313. } else {
  38314. if (isFirstHex) {
  38315. firstDigit = toHexDigit(ch);
  38316. if (firstDigit === -1) {
  38317. warn('Ignoring invalid character "' + ch + '" in hex string');
  38318. ch = this.nextChar();
  38319. continue;
  38320. }
  38321. } else {
  38322. secondDigit = toHexDigit(ch);
  38323. if (secondDigit === -1) {
  38324. warn('Ignoring invalid character "' + ch + '" in hex string');
  38325. ch = this.nextChar();
  38326. continue;
  38327. }
  38328. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38329. }
  38330. isFirstHex = !isFirstHex;
  38331. ch = this.nextChar();
  38332. }
  38333. }
  38334. return strBuf.join('');
  38335. },
  38336. getObj: function Lexer_getObj() {
  38337. var comment = false;
  38338. var ch = this.currentChar;
  38339. while (true) {
  38340. if (ch < 0) {
  38341. return EOF;
  38342. }
  38343. if (comment) {
  38344. if (ch === 0x0A || ch === 0x0D) {
  38345. comment = false;
  38346. }
  38347. } else if (ch === 0x25) {
  38348. comment = true;
  38349. } else if (specialChars[ch] !== 1) {
  38350. break;
  38351. }
  38352. ch = this.nextChar();
  38353. }
  38354. switch (ch | 0) {
  38355. case 0x30:
  38356. case 0x31:
  38357. case 0x32:
  38358. case 0x33:
  38359. case 0x34:
  38360. case 0x35:
  38361. case 0x36:
  38362. case 0x37:
  38363. case 0x38:
  38364. case 0x39:
  38365. case 0x2B:
  38366. case 0x2D:
  38367. case 0x2E:
  38368. return this.getNumber();
  38369. case 0x28:
  38370. return this.getString();
  38371. case 0x2F:
  38372. return this.getName();
  38373. case 0x5B:
  38374. this.nextChar();
  38375. return Cmd.get('[');
  38376. case 0x5D:
  38377. this.nextChar();
  38378. return Cmd.get(']');
  38379. case 0x3C:
  38380. ch = this.nextChar();
  38381. if (ch === 0x3C) {
  38382. this.nextChar();
  38383. return Cmd.get('<<');
  38384. }
  38385. return this.getHexString();
  38386. case 0x3E:
  38387. ch = this.nextChar();
  38388. if (ch === 0x3E) {
  38389. this.nextChar();
  38390. return Cmd.get('>>');
  38391. }
  38392. return Cmd.get('>');
  38393. case 0x7B:
  38394. this.nextChar();
  38395. return Cmd.get('{');
  38396. case 0x7D:
  38397. this.nextChar();
  38398. return Cmd.get('}');
  38399. case 0x29:
  38400. error('Illegal character: ' + ch);
  38401. break;
  38402. }
  38403. var str = String.fromCharCode(ch);
  38404. var knownCommands = this.knownCommands;
  38405. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38406. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38407. var possibleCommand = str + String.fromCharCode(ch);
  38408. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38409. break;
  38410. }
  38411. if (str.length === 128) {
  38412. error('Command token too long: ' + str.length);
  38413. }
  38414. str = possibleCommand;
  38415. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38416. }
  38417. if (str === 'true') {
  38418. return true;
  38419. }
  38420. if (str === 'false') {
  38421. return false;
  38422. }
  38423. if (str === 'null') {
  38424. return null;
  38425. }
  38426. return Cmd.get(str);
  38427. },
  38428. skipToNextLine: function Lexer_skipToNextLine() {
  38429. var ch = this.currentChar;
  38430. while (ch >= 0) {
  38431. if (ch === 0x0D) {
  38432. ch = this.nextChar();
  38433. if (ch === 0x0A) {
  38434. this.nextChar();
  38435. }
  38436. break;
  38437. } else if (ch === 0x0A) {
  38438. this.nextChar();
  38439. break;
  38440. }
  38441. ch = this.nextChar();
  38442. }
  38443. }
  38444. };
  38445. return Lexer;
  38446. }();
  38447. var Linearization = {
  38448. create: function LinearizationCreate(stream) {
  38449. function getInt(name, allowZeroValue) {
  38450. var obj = linDict.get(name);
  38451. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38452. return obj;
  38453. }
  38454. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38455. }
  38456. function getHints() {
  38457. var hints = linDict.get('H'), hintsLength, item;
  38458. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38459. for (var index = 0; index < hintsLength; index++) {
  38460. if (!(isInt(item = hints[index]) && item > 0)) {
  38461. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38462. }
  38463. }
  38464. return hints;
  38465. }
  38466. throw new Error('Hint array in the linearization dictionary is invalid.');
  38467. }
  38468. var parser = new Parser(new Lexer(stream), false, null);
  38469. var obj1 = parser.getObj();
  38470. var obj2 = parser.getObj();
  38471. var obj3 = parser.getObj();
  38472. var linDict = parser.getObj();
  38473. var obj, length;
  38474. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38475. return null;
  38476. } else if ((length = getInt('L')) !== stream.length) {
  38477. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38478. }
  38479. return {
  38480. length: length,
  38481. hints: getHints(),
  38482. objectNumberFirst: getInt('O'),
  38483. endFirst: getInt('E'),
  38484. numPages: getInt('N'),
  38485. mainXRefEntriesOffset: getInt('T'),
  38486. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38487. };
  38488. }
  38489. };
  38490. exports.EOF = EOF;
  38491. exports.Lexer = Lexer;
  38492. exports.Linearization = Linearization;
  38493. exports.Parser = Parser;
  38494. exports.isEOF = isEOF;
  38495. }));
  38496. (function (root, factory) {
  38497. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38498. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38499. var warn = sharedUtil.warn;
  38500. var isSpace = sharedUtil.isSpace;
  38501. var Stream = coreStream.Stream;
  38502. var getEncoding = coreEncodings.getEncoding;
  38503. var HINTING_ENABLED = false;
  38504. var Type1CharString = function Type1CharStringClosure() {
  38505. var COMMAND_MAP = {
  38506. 'hstem': [1],
  38507. 'vstem': [3],
  38508. 'vmoveto': [4],
  38509. 'rlineto': [5],
  38510. 'hlineto': [6],
  38511. 'vlineto': [7],
  38512. 'rrcurveto': [8],
  38513. 'callsubr': [10],
  38514. 'flex': [
  38515. 12,
  38516. 35
  38517. ],
  38518. 'drop': [
  38519. 12,
  38520. 18
  38521. ],
  38522. 'endchar': [14],
  38523. 'rmoveto': [21],
  38524. 'hmoveto': [22],
  38525. 'vhcurveto': [30],
  38526. 'hvcurveto': [31]
  38527. };
  38528. function Type1CharString() {
  38529. this.width = 0;
  38530. this.lsb = 0;
  38531. this.flexing = false;
  38532. this.output = [];
  38533. this.stack = [];
  38534. }
  38535. Type1CharString.prototype = {
  38536. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38537. var count = encoded.length;
  38538. var error = false;
  38539. var wx, sbx, subrNumber;
  38540. for (var i = 0; i < count; i++) {
  38541. var value = encoded[i];
  38542. if (value < 32) {
  38543. if (value === 12) {
  38544. value = (value << 8) + encoded[++i];
  38545. }
  38546. switch (value) {
  38547. case 1:
  38548. if (!HINTING_ENABLED) {
  38549. this.stack = [];
  38550. break;
  38551. }
  38552. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38553. break;
  38554. case 3:
  38555. if (!HINTING_ENABLED) {
  38556. this.stack = [];
  38557. break;
  38558. }
  38559. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38560. break;
  38561. case 4:
  38562. if (this.flexing) {
  38563. if (this.stack.length < 1) {
  38564. error = true;
  38565. break;
  38566. }
  38567. var dy = this.stack.pop();
  38568. this.stack.push(0, dy);
  38569. break;
  38570. }
  38571. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38572. break;
  38573. case 5:
  38574. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38575. break;
  38576. case 6:
  38577. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38578. break;
  38579. case 7:
  38580. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38581. break;
  38582. case 8:
  38583. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38584. break;
  38585. case 9:
  38586. this.stack = [];
  38587. break;
  38588. case 10:
  38589. if (this.stack.length < 1) {
  38590. error = true;
  38591. break;
  38592. }
  38593. subrNumber = this.stack.pop();
  38594. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38595. break;
  38596. case 11:
  38597. return error;
  38598. case 13:
  38599. if (this.stack.length < 2) {
  38600. error = true;
  38601. break;
  38602. }
  38603. wx = this.stack.pop();
  38604. sbx = this.stack.pop();
  38605. this.lsb = sbx;
  38606. this.width = wx;
  38607. this.stack.push(wx, sbx);
  38608. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38609. break;
  38610. case 14:
  38611. this.output.push(COMMAND_MAP.endchar[0]);
  38612. break;
  38613. case 21:
  38614. if (this.flexing) {
  38615. break;
  38616. }
  38617. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38618. break;
  38619. case 22:
  38620. if (this.flexing) {
  38621. this.stack.push(0);
  38622. break;
  38623. }
  38624. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38625. break;
  38626. case 30:
  38627. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38628. break;
  38629. case 31:
  38630. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38631. break;
  38632. case (12 << 8) + 0:
  38633. this.stack = [];
  38634. break;
  38635. case (12 << 8) + 1:
  38636. if (!HINTING_ENABLED) {
  38637. this.stack = [];
  38638. break;
  38639. }
  38640. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38641. break;
  38642. case (12 << 8) + 2:
  38643. if (!HINTING_ENABLED) {
  38644. this.stack = [];
  38645. break;
  38646. }
  38647. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38648. break;
  38649. case (12 << 8) + 6:
  38650. if (seacAnalysisEnabled) {
  38651. this.seac = this.stack.splice(-4, 4);
  38652. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38653. } else {
  38654. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38655. }
  38656. break;
  38657. case (12 << 8) + 7:
  38658. if (this.stack.length < 4) {
  38659. error = true;
  38660. break;
  38661. }
  38662. var wy = this.stack.pop();
  38663. wx = this.stack.pop();
  38664. var sby = this.stack.pop();
  38665. sbx = this.stack.pop();
  38666. this.lsb = sbx;
  38667. this.width = wx;
  38668. this.stack.push(wx, sbx, sby);
  38669. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38670. break;
  38671. case (12 << 8) + 12:
  38672. if (this.stack.length < 2) {
  38673. error = true;
  38674. break;
  38675. }
  38676. var num2 = this.stack.pop();
  38677. var num1 = this.stack.pop();
  38678. this.stack.push(num1 / num2);
  38679. break;
  38680. case (12 << 8) + 16:
  38681. if (this.stack.length < 2) {
  38682. error = true;
  38683. break;
  38684. }
  38685. subrNumber = this.stack.pop();
  38686. var numArgs = this.stack.pop();
  38687. if (subrNumber === 0 && numArgs === 3) {
  38688. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38689. 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]);
  38690. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38691. this.flexing = false;
  38692. this.stack.push(flexArgs[15], flexArgs[16]);
  38693. } else if (subrNumber === 1 && numArgs === 0) {
  38694. this.flexing = true;
  38695. }
  38696. break;
  38697. case (12 << 8) + 17:
  38698. break;
  38699. case (12 << 8) + 33:
  38700. this.stack = [];
  38701. break;
  38702. default:
  38703. warn('Unknown type 1 charstring command of "' + value + '"');
  38704. break;
  38705. }
  38706. if (error) {
  38707. break;
  38708. }
  38709. continue;
  38710. } else if (value <= 246) {
  38711. value = value - 139;
  38712. } else if (value <= 250) {
  38713. value = (value - 247) * 256 + encoded[++i] + 108;
  38714. } else if (value <= 254) {
  38715. value = -((value - 251) * 256) - encoded[++i] - 108;
  38716. } else {
  38717. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38718. }
  38719. this.stack.push(value);
  38720. }
  38721. return error;
  38722. },
  38723. executeCommand: function (howManyArgs, command, keepStack) {
  38724. var stackLength = this.stack.length;
  38725. if (howManyArgs > stackLength) {
  38726. return true;
  38727. }
  38728. var start = stackLength - howManyArgs;
  38729. for (var i = start; i < stackLength; i++) {
  38730. var value = this.stack[i];
  38731. if (value === (value | 0)) {
  38732. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38733. } else {
  38734. value = 65536 * value | 0;
  38735. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38736. }
  38737. }
  38738. this.output.push.apply(this.output, command);
  38739. if (keepStack) {
  38740. this.stack.splice(start, howManyArgs);
  38741. } else {
  38742. this.stack.length = 0;
  38743. }
  38744. return false;
  38745. }
  38746. };
  38747. return Type1CharString;
  38748. }();
  38749. var Type1Parser = function Type1ParserClosure() {
  38750. var EEXEC_ENCRYPT_KEY = 55665;
  38751. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38752. function isHexDigit(code) {
  38753. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38754. }
  38755. function decrypt(data, key, discardNumber) {
  38756. if (discardNumber >= data.length) {
  38757. return new Uint8Array(0);
  38758. }
  38759. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38760. for (i = 0; i < discardNumber; i++) {
  38761. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38762. }
  38763. var count = data.length - discardNumber;
  38764. var decrypted = new Uint8Array(count);
  38765. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38766. var value = data[i];
  38767. decrypted[j] = value ^ r >> 8;
  38768. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38769. }
  38770. return decrypted;
  38771. }
  38772. function decryptAscii(data, key, discardNumber) {
  38773. var r = key | 0, c1 = 52845, c2 = 22719;
  38774. var count = data.length, maybeLength = count >>> 1;
  38775. var decrypted = new Uint8Array(maybeLength);
  38776. var i, j;
  38777. for (i = 0, j = 0; i < count; i++) {
  38778. var digit1 = data[i];
  38779. if (!isHexDigit(digit1)) {
  38780. continue;
  38781. }
  38782. i++;
  38783. var digit2;
  38784. while (i < count && !isHexDigit(digit2 = data[i])) {
  38785. i++;
  38786. }
  38787. if (i < count) {
  38788. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38789. decrypted[j++] = value ^ r >> 8;
  38790. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38791. }
  38792. }
  38793. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38794. }
  38795. function isSpecial(c) {
  38796. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38797. }
  38798. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38799. if (encrypted) {
  38800. var data = stream.getBytes();
  38801. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38802. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38803. }
  38804. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38805. this.stream = stream;
  38806. this.nextChar();
  38807. }
  38808. Type1Parser.prototype = {
  38809. readNumberArray: function Type1Parser_readNumberArray() {
  38810. this.getToken();
  38811. var array = [];
  38812. while (true) {
  38813. var token = this.getToken();
  38814. if (token === null || token === ']' || token === '}') {
  38815. break;
  38816. }
  38817. array.push(parseFloat(token || 0));
  38818. }
  38819. return array;
  38820. },
  38821. readNumber: function Type1Parser_readNumber() {
  38822. var token = this.getToken();
  38823. return parseFloat(token || 0);
  38824. },
  38825. readInt: function Type1Parser_readInt() {
  38826. var token = this.getToken();
  38827. return parseInt(token || 0, 10) | 0;
  38828. },
  38829. readBoolean: function Type1Parser_readBoolean() {
  38830. var token = this.getToken();
  38831. return token === 'true' ? 1 : 0;
  38832. },
  38833. nextChar: function Type1_nextChar() {
  38834. return this.currentChar = this.stream.getByte();
  38835. },
  38836. getToken: function Type1Parser_getToken() {
  38837. var comment = false;
  38838. var ch = this.currentChar;
  38839. while (true) {
  38840. if (ch === -1) {
  38841. return null;
  38842. }
  38843. if (comment) {
  38844. if (ch === 0x0A || ch === 0x0D) {
  38845. comment = false;
  38846. }
  38847. } else if (ch === 0x25) {
  38848. comment = true;
  38849. } else if (!isSpace(ch)) {
  38850. break;
  38851. }
  38852. ch = this.nextChar();
  38853. }
  38854. if (isSpecial(ch)) {
  38855. this.nextChar();
  38856. return String.fromCharCode(ch);
  38857. }
  38858. var token = '';
  38859. do {
  38860. token += String.fromCharCode(ch);
  38861. ch = this.nextChar();
  38862. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  38863. return token;
  38864. },
  38865. extractFontProgram: function Type1Parser_extractFontProgram() {
  38866. var stream = this.stream;
  38867. var subrs = [], charstrings = [];
  38868. var privateData = Object.create(null);
  38869. privateData['lenIV'] = 4;
  38870. var program = {
  38871. subrs: [],
  38872. charstrings: [],
  38873. properties: { 'privateData': privateData }
  38874. };
  38875. var token, length, data, lenIV, encoded;
  38876. while ((token = this.getToken()) !== null) {
  38877. if (token !== '/') {
  38878. continue;
  38879. }
  38880. token = this.getToken();
  38881. switch (token) {
  38882. case 'CharStrings':
  38883. this.getToken();
  38884. this.getToken();
  38885. this.getToken();
  38886. this.getToken();
  38887. while (true) {
  38888. token = this.getToken();
  38889. if (token === null || token === 'end') {
  38890. break;
  38891. }
  38892. if (token !== '/') {
  38893. continue;
  38894. }
  38895. var glyph = this.getToken();
  38896. length = this.readInt();
  38897. this.getToken();
  38898. data = stream.makeSubStream(stream.pos, length);
  38899. lenIV = program.properties.privateData['lenIV'];
  38900. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38901. stream.skip(length);
  38902. this.nextChar();
  38903. token = this.getToken();
  38904. if (token === 'noaccess') {
  38905. this.getToken();
  38906. }
  38907. charstrings.push({
  38908. glyph: glyph,
  38909. encoded: encoded
  38910. });
  38911. }
  38912. break;
  38913. case 'Subrs':
  38914. var num = this.readInt();
  38915. this.getToken();
  38916. while ((token = this.getToken()) === 'dup') {
  38917. var index = this.readInt();
  38918. length = this.readInt();
  38919. this.getToken();
  38920. data = stream.makeSubStream(stream.pos, length);
  38921. lenIV = program.properties.privateData['lenIV'];
  38922. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38923. stream.skip(length);
  38924. this.nextChar();
  38925. token = this.getToken();
  38926. if (token === 'noaccess') {
  38927. this.getToken();
  38928. }
  38929. subrs[index] = encoded;
  38930. }
  38931. break;
  38932. case 'BlueValues':
  38933. case 'OtherBlues':
  38934. case 'FamilyBlues':
  38935. case 'FamilyOtherBlues':
  38936. var blueArray = this.readNumberArray();
  38937. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  38938. program.properties.privateData[token] = blueArray;
  38939. }
  38940. break;
  38941. case 'StemSnapH':
  38942. case 'StemSnapV':
  38943. program.properties.privateData[token] = this.readNumberArray();
  38944. break;
  38945. case 'StdHW':
  38946. case 'StdVW':
  38947. program.properties.privateData[token] = this.readNumberArray()[0];
  38948. break;
  38949. case 'BlueShift':
  38950. case 'lenIV':
  38951. case 'BlueFuzz':
  38952. case 'BlueScale':
  38953. case 'LanguageGroup':
  38954. case 'ExpansionFactor':
  38955. program.properties.privateData[token] = this.readNumber();
  38956. break;
  38957. case 'ForceBold':
  38958. program.properties.privateData[token] = this.readBoolean();
  38959. break;
  38960. }
  38961. }
  38962. for (var i = 0; i < charstrings.length; i++) {
  38963. glyph = charstrings[i].glyph;
  38964. encoded = charstrings[i].encoded;
  38965. var charString = new Type1CharString();
  38966. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  38967. var output = charString.output;
  38968. if (error) {
  38969. output = [14];
  38970. }
  38971. program.charstrings.push({
  38972. glyphName: glyph,
  38973. charstring: output,
  38974. width: charString.width,
  38975. lsb: charString.lsb,
  38976. seac: charString.seac
  38977. });
  38978. }
  38979. return program;
  38980. },
  38981. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  38982. var token;
  38983. while ((token = this.getToken()) !== null) {
  38984. if (token !== '/') {
  38985. continue;
  38986. }
  38987. token = this.getToken();
  38988. switch (token) {
  38989. case 'FontMatrix':
  38990. var matrix = this.readNumberArray();
  38991. properties.fontMatrix = matrix;
  38992. break;
  38993. case 'Encoding':
  38994. var encodingArg = this.getToken();
  38995. var encoding;
  38996. if (!/^\d+$/.test(encodingArg)) {
  38997. encoding = getEncoding(encodingArg);
  38998. } else {
  38999. encoding = [];
  39000. var size = parseInt(encodingArg, 10) | 0;
  39001. this.getToken();
  39002. for (var j = 0; j < size; j++) {
  39003. token = this.getToken();
  39004. while (token !== 'dup' && token !== 'def') {
  39005. token = this.getToken();
  39006. if (token === null) {
  39007. return;
  39008. }
  39009. }
  39010. if (token === 'def') {
  39011. break;
  39012. }
  39013. var index = this.readInt();
  39014. this.getToken();
  39015. var glyph = this.getToken();
  39016. encoding[index] = glyph;
  39017. this.getToken();
  39018. }
  39019. }
  39020. properties.builtInEncoding = encoding;
  39021. break;
  39022. case 'FontBBox':
  39023. var fontBBox = this.readNumberArray();
  39024. properties.ascent = fontBBox[3];
  39025. properties.descent = fontBBox[1];
  39026. properties.ascentScaled = true;
  39027. break;
  39028. }
  39029. }
  39030. }
  39031. };
  39032. return Type1Parser;
  39033. }();
  39034. exports.Type1Parser = Type1Parser;
  39035. }));
  39036. (function (root, factory) {
  39037. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39038. }(this, function (exports, sharedUtil, displayWebGL) {
  39039. var Util = sharedUtil.Util;
  39040. var info = sharedUtil.info;
  39041. var isArray = sharedUtil.isArray;
  39042. var error = sharedUtil.error;
  39043. var WebGLUtils = displayWebGL.WebGLUtils;
  39044. var ShadingIRs = {};
  39045. ShadingIRs.RadialAxial = {
  39046. fromIR: function RadialAxial_fromIR(raw) {
  39047. var type = raw[1];
  39048. var colorStops = raw[2];
  39049. var p0 = raw[3];
  39050. var p1 = raw[4];
  39051. var r0 = raw[5];
  39052. var r1 = raw[6];
  39053. return {
  39054. type: 'Pattern',
  39055. getPattern: function RadialAxial_getPattern(ctx) {
  39056. var grad;
  39057. if (type === 'axial') {
  39058. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39059. } else if (type === 'radial') {
  39060. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39061. }
  39062. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39063. var c = colorStops[i];
  39064. grad.addColorStop(c[0], c[1]);
  39065. }
  39066. return grad;
  39067. }
  39068. };
  39069. }
  39070. };
  39071. var createMeshCanvas = function createMeshCanvasClosure() {
  39072. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39073. var coords = context.coords, colors = context.colors;
  39074. var bytes = data.data, rowSize = data.width * 4;
  39075. var tmp;
  39076. if (coords[p1 + 1] > coords[p2 + 1]) {
  39077. tmp = p1;
  39078. p1 = p2;
  39079. p2 = tmp;
  39080. tmp = c1;
  39081. c1 = c2;
  39082. c2 = tmp;
  39083. }
  39084. if (coords[p2 + 1] > coords[p3 + 1]) {
  39085. tmp = p2;
  39086. p2 = p3;
  39087. p3 = tmp;
  39088. tmp = c2;
  39089. c2 = c3;
  39090. c3 = tmp;
  39091. }
  39092. if (coords[p1 + 1] > coords[p2 + 1]) {
  39093. tmp = p1;
  39094. p1 = p2;
  39095. p2 = tmp;
  39096. tmp = c1;
  39097. c1 = c2;
  39098. c2 = tmp;
  39099. }
  39100. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39101. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39102. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39103. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39104. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39105. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39106. if (y1 >= y3) {
  39107. return;
  39108. }
  39109. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39110. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39111. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39112. var minY = Math.round(y1), maxY = Math.round(y3);
  39113. var xa, car, cag, cab;
  39114. var xb, cbr, cbg, cbb;
  39115. var k;
  39116. for (var y = minY; y <= maxY; y++) {
  39117. if (y < y2) {
  39118. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39119. xa = x1 - (x1 - x2) * k;
  39120. car = c1r - (c1r - c2r) * k;
  39121. cag = c1g - (c1g - c2g) * k;
  39122. cab = c1b - (c1b - c2b) * k;
  39123. } else {
  39124. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39125. xa = x2 - (x2 - x3) * k;
  39126. car = c2r - (c2r - c3r) * k;
  39127. cag = c2g - (c2g - c3g) * k;
  39128. cab = c2b - (c2b - c3b) * k;
  39129. }
  39130. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39131. xb = x1 - (x1 - x3) * k;
  39132. cbr = c1r - (c1r - c3r) * k;
  39133. cbg = c1g - (c1g - c3g) * k;
  39134. cbb = c1b - (c1b - c3b) * k;
  39135. var x1_ = Math.round(Math.min(xa, xb));
  39136. var x2_ = Math.round(Math.max(xa, xb));
  39137. var j = rowSize * y + x1_ * 4;
  39138. for (var x = x1_; x <= x2_; x++) {
  39139. k = (xa - x) / (xa - xb);
  39140. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39141. bytes[j++] = car - (car - cbr) * k | 0;
  39142. bytes[j++] = cag - (cag - cbg) * k | 0;
  39143. bytes[j++] = cab - (cab - cbb) * k | 0;
  39144. bytes[j++] = 255;
  39145. }
  39146. }
  39147. }
  39148. function drawFigure(data, figure, context) {
  39149. var ps = figure.coords;
  39150. var cs = figure.colors;
  39151. var i, ii;
  39152. switch (figure.type) {
  39153. case 'lattice':
  39154. var verticesPerRow = figure.verticesPerRow;
  39155. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39156. var cols = verticesPerRow - 1;
  39157. for (i = 0; i < rows; i++) {
  39158. var q = i * verticesPerRow;
  39159. for (var j = 0; j < cols; j++, q++) {
  39160. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39161. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39162. }
  39163. }
  39164. break;
  39165. case 'triangles':
  39166. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39167. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39168. }
  39169. break;
  39170. default:
  39171. error('illigal figure');
  39172. break;
  39173. }
  39174. }
  39175. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39176. var EXPECTED_SCALE = 1.1;
  39177. var MAX_PATTERN_SIZE = 3000;
  39178. var BORDER_SIZE = 2;
  39179. var offsetX = Math.floor(bounds[0]);
  39180. var offsetY = Math.floor(bounds[1]);
  39181. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39182. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39183. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39184. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39185. var scaleX = boundsWidth / width;
  39186. var scaleY = boundsHeight / height;
  39187. var context = {
  39188. coords: coords,
  39189. colors: colors,
  39190. offsetX: -offsetX,
  39191. offsetY: -offsetY,
  39192. scaleX: 1 / scaleX,
  39193. scaleY: 1 / scaleY
  39194. };
  39195. var paddedWidth = width + BORDER_SIZE * 2;
  39196. var paddedHeight = height + BORDER_SIZE * 2;
  39197. var canvas, tmpCanvas, i, ii;
  39198. if (WebGLUtils.isEnabled) {
  39199. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39200. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39201. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39202. canvas = tmpCanvas.canvas;
  39203. } else {
  39204. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39205. var tmpCtx = tmpCanvas.context;
  39206. var data = tmpCtx.createImageData(width, height);
  39207. if (backgroundColor) {
  39208. var bytes = data.data;
  39209. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39210. bytes[i] = backgroundColor[0];
  39211. bytes[i + 1] = backgroundColor[1];
  39212. bytes[i + 2] = backgroundColor[2];
  39213. bytes[i + 3] = 255;
  39214. }
  39215. }
  39216. for (i = 0; i < figures.length; i++) {
  39217. drawFigure(data, figures[i], context);
  39218. }
  39219. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39220. canvas = tmpCanvas.canvas;
  39221. }
  39222. return {
  39223. canvas: canvas,
  39224. offsetX: offsetX - BORDER_SIZE * scaleX,
  39225. offsetY: offsetY - BORDER_SIZE * scaleY,
  39226. scaleX: scaleX,
  39227. scaleY: scaleY
  39228. };
  39229. }
  39230. return createMeshCanvas;
  39231. }();
  39232. ShadingIRs.Mesh = {
  39233. fromIR: function Mesh_fromIR(raw) {
  39234. var coords = raw[2];
  39235. var colors = raw[3];
  39236. var figures = raw[4];
  39237. var bounds = raw[5];
  39238. var matrix = raw[6];
  39239. var background = raw[8];
  39240. return {
  39241. type: 'Pattern',
  39242. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39243. var scale;
  39244. if (shadingFill) {
  39245. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39246. } else {
  39247. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39248. if (matrix) {
  39249. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39250. scale = [
  39251. scale[0] * matrixScale[0],
  39252. scale[1] * matrixScale[1]
  39253. ];
  39254. }
  39255. }
  39256. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39257. if (!shadingFill) {
  39258. ctx.setTransform.apply(ctx, owner.baseTransform);
  39259. if (matrix) {
  39260. ctx.transform.apply(ctx, matrix);
  39261. }
  39262. }
  39263. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39264. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39265. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39266. }
  39267. };
  39268. }
  39269. };
  39270. ShadingIRs.Dummy = {
  39271. fromIR: function Dummy_fromIR() {
  39272. return {
  39273. type: 'Pattern',
  39274. getPattern: function Dummy_fromIR_getPattern() {
  39275. return 'hotpink';
  39276. }
  39277. };
  39278. }
  39279. };
  39280. function getShadingPatternFromIR(raw) {
  39281. var shadingIR = ShadingIRs[raw[0]];
  39282. if (!shadingIR) {
  39283. error('Unknown IR type: ' + raw[0]);
  39284. }
  39285. return shadingIR.fromIR(raw);
  39286. }
  39287. var TilingPattern = function TilingPatternClosure() {
  39288. var PaintType = {
  39289. COLORED: 1,
  39290. UNCOLORED: 2
  39291. };
  39292. var MAX_PATTERN_SIZE = 3000;
  39293. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39294. this.operatorList = IR[2];
  39295. this.matrix = IR[3] || [
  39296. 1,
  39297. 0,
  39298. 0,
  39299. 1,
  39300. 0,
  39301. 0
  39302. ];
  39303. this.bbox = IR[4];
  39304. this.xstep = IR[5];
  39305. this.ystep = IR[6];
  39306. this.paintType = IR[7];
  39307. this.tilingType = IR[8];
  39308. this.color = color;
  39309. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39310. this.baseTransform = baseTransform;
  39311. this.type = 'Pattern';
  39312. this.ctx = ctx;
  39313. }
  39314. TilingPattern.prototype = {
  39315. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39316. var operatorList = this.operatorList;
  39317. var bbox = this.bbox;
  39318. var xstep = this.xstep;
  39319. var ystep = this.ystep;
  39320. var paintType = this.paintType;
  39321. var tilingType = this.tilingType;
  39322. var color = this.color;
  39323. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39324. info('TilingType: ' + tilingType);
  39325. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39326. var topLeft = [
  39327. x0,
  39328. y0
  39329. ];
  39330. var botRight = [
  39331. x0 + xstep,
  39332. y0 + ystep
  39333. ];
  39334. var width = botRight[0] - topLeft[0];
  39335. var height = botRight[1] - topLeft[1];
  39336. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39337. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39338. var combinedScale = [
  39339. matrixScale[0] * curMatrixScale[0],
  39340. matrixScale[1] * curMatrixScale[1]
  39341. ];
  39342. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39343. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39344. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39345. var tmpCtx = tmpCanvas.context;
  39346. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39347. graphics.groupLevel = owner.groupLevel;
  39348. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39349. this.setScale(width, height, xstep, ystep);
  39350. this.transformToScale(graphics);
  39351. var tmpTranslate = [
  39352. 1,
  39353. 0,
  39354. 0,
  39355. 1,
  39356. -topLeft[0],
  39357. -topLeft[1]
  39358. ];
  39359. graphics.transform.apply(graphics, tmpTranslate);
  39360. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39361. graphics.executeOperatorList(operatorList);
  39362. return tmpCanvas.canvas;
  39363. },
  39364. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39365. this.scale = [
  39366. width / xstep,
  39367. height / ystep
  39368. ];
  39369. },
  39370. transformToScale: function TilingPattern_transformToScale(graphics) {
  39371. var scale = this.scale;
  39372. var tmpScale = [
  39373. scale[0],
  39374. 0,
  39375. 0,
  39376. scale[1],
  39377. 0,
  39378. 0
  39379. ];
  39380. graphics.transform.apply(graphics, tmpScale);
  39381. },
  39382. scaleToContext: function TilingPattern_scaleToContext() {
  39383. var scale = this.scale;
  39384. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39385. },
  39386. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39387. if (bbox && isArray(bbox) && bbox.length === 4) {
  39388. var bboxWidth = x1 - x0;
  39389. var bboxHeight = y1 - y0;
  39390. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39391. graphics.clip();
  39392. graphics.endPath();
  39393. }
  39394. },
  39395. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39396. switch (paintType) {
  39397. case PaintType.COLORED:
  39398. var ctx = this.ctx;
  39399. context.fillStyle = ctx.fillStyle;
  39400. context.strokeStyle = ctx.strokeStyle;
  39401. break;
  39402. case PaintType.UNCOLORED:
  39403. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39404. context.fillStyle = cssColor;
  39405. context.strokeStyle = cssColor;
  39406. break;
  39407. default:
  39408. error('Unsupported paint type: ' + paintType);
  39409. }
  39410. },
  39411. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39412. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39413. ctx = this.ctx;
  39414. ctx.setTransform.apply(ctx, this.baseTransform);
  39415. ctx.transform.apply(ctx, this.matrix);
  39416. this.scaleToContext();
  39417. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39418. }
  39419. };
  39420. return TilingPattern;
  39421. }();
  39422. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39423. exports.TilingPattern = TilingPattern;
  39424. }));
  39425. (function (root, factory) {
  39426. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39427. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39428. var Util = sharedUtil.Util;
  39429. var assert = sharedUtil.assert;
  39430. var warn = sharedUtil.warn;
  39431. var error = sharedUtil.error;
  39432. var isInt = sharedUtil.isInt;
  39433. var isString = sharedUtil.isString;
  39434. var MissingDataException = sharedUtil.MissingDataException;
  39435. var isName = corePrimitives.isName;
  39436. var isCmd = corePrimitives.isCmd;
  39437. var isStream = corePrimitives.isStream;
  39438. var StringStream = coreStream.StringStream;
  39439. var Lexer = coreParser.Lexer;
  39440. var isEOF = coreParser.isEOF;
  39441. var BUILT_IN_CMAPS = [
  39442. 'Adobe-GB1-UCS2',
  39443. 'Adobe-CNS1-UCS2',
  39444. 'Adobe-Japan1-UCS2',
  39445. 'Adobe-Korea1-UCS2',
  39446. '78-EUC-H',
  39447. '78-EUC-V',
  39448. '78-H',
  39449. '78-RKSJ-H',
  39450. '78-RKSJ-V',
  39451. '78-V',
  39452. '78ms-RKSJ-H',
  39453. '78ms-RKSJ-V',
  39454. '83pv-RKSJ-H',
  39455. '90ms-RKSJ-H',
  39456. '90ms-RKSJ-V',
  39457. '90msp-RKSJ-H',
  39458. '90msp-RKSJ-V',
  39459. '90pv-RKSJ-H',
  39460. '90pv-RKSJ-V',
  39461. 'Add-H',
  39462. 'Add-RKSJ-H',
  39463. 'Add-RKSJ-V',
  39464. 'Add-V',
  39465. 'Adobe-CNS1-0',
  39466. 'Adobe-CNS1-1',
  39467. 'Adobe-CNS1-2',
  39468. 'Adobe-CNS1-3',
  39469. 'Adobe-CNS1-4',
  39470. 'Adobe-CNS1-5',
  39471. 'Adobe-CNS1-6',
  39472. 'Adobe-GB1-0',
  39473. 'Adobe-GB1-1',
  39474. 'Adobe-GB1-2',
  39475. 'Adobe-GB1-3',
  39476. 'Adobe-GB1-4',
  39477. 'Adobe-GB1-5',
  39478. 'Adobe-Japan1-0',
  39479. 'Adobe-Japan1-1',
  39480. 'Adobe-Japan1-2',
  39481. 'Adobe-Japan1-3',
  39482. 'Adobe-Japan1-4',
  39483. 'Adobe-Japan1-5',
  39484. 'Adobe-Japan1-6',
  39485. 'Adobe-Korea1-0',
  39486. 'Adobe-Korea1-1',
  39487. 'Adobe-Korea1-2',
  39488. 'B5-H',
  39489. 'B5-V',
  39490. 'B5pc-H',
  39491. 'B5pc-V',
  39492. 'CNS-EUC-H',
  39493. 'CNS-EUC-V',
  39494. 'CNS1-H',
  39495. 'CNS1-V',
  39496. 'CNS2-H',
  39497. 'CNS2-V',
  39498. 'ETHK-B5-H',
  39499. 'ETHK-B5-V',
  39500. 'ETen-B5-H',
  39501. 'ETen-B5-V',
  39502. 'ETenms-B5-H',
  39503. 'ETenms-B5-V',
  39504. 'EUC-H',
  39505. 'EUC-V',
  39506. 'Ext-H',
  39507. 'Ext-RKSJ-H',
  39508. 'Ext-RKSJ-V',
  39509. 'Ext-V',
  39510. 'GB-EUC-H',
  39511. 'GB-EUC-V',
  39512. 'GB-H',
  39513. 'GB-V',
  39514. 'GBK-EUC-H',
  39515. 'GBK-EUC-V',
  39516. 'GBK2K-H',
  39517. 'GBK2K-V',
  39518. 'GBKp-EUC-H',
  39519. 'GBKp-EUC-V',
  39520. 'GBT-EUC-H',
  39521. 'GBT-EUC-V',
  39522. 'GBT-H',
  39523. 'GBT-V',
  39524. 'GBTpc-EUC-H',
  39525. 'GBTpc-EUC-V',
  39526. 'GBpc-EUC-H',
  39527. 'GBpc-EUC-V',
  39528. 'H',
  39529. 'HKdla-B5-H',
  39530. 'HKdla-B5-V',
  39531. 'HKdlb-B5-H',
  39532. 'HKdlb-B5-V',
  39533. 'HKgccs-B5-H',
  39534. 'HKgccs-B5-V',
  39535. 'HKm314-B5-H',
  39536. 'HKm314-B5-V',
  39537. 'HKm471-B5-H',
  39538. 'HKm471-B5-V',
  39539. 'HKscs-B5-H',
  39540. 'HKscs-B5-V',
  39541. 'Hankaku',
  39542. 'Hiragana',
  39543. 'KSC-EUC-H',
  39544. 'KSC-EUC-V',
  39545. 'KSC-H',
  39546. 'KSC-Johab-H',
  39547. 'KSC-Johab-V',
  39548. 'KSC-V',
  39549. 'KSCms-UHC-H',
  39550. 'KSCms-UHC-HW-H',
  39551. 'KSCms-UHC-HW-V',
  39552. 'KSCms-UHC-V',
  39553. 'KSCpc-EUC-H',
  39554. 'KSCpc-EUC-V',
  39555. 'Katakana',
  39556. 'NWP-H',
  39557. 'NWP-V',
  39558. 'RKSJ-H',
  39559. 'RKSJ-V',
  39560. 'Roman',
  39561. 'UniCNS-UCS2-H',
  39562. 'UniCNS-UCS2-V',
  39563. 'UniCNS-UTF16-H',
  39564. 'UniCNS-UTF16-V',
  39565. 'UniCNS-UTF32-H',
  39566. 'UniCNS-UTF32-V',
  39567. 'UniCNS-UTF8-H',
  39568. 'UniCNS-UTF8-V',
  39569. 'UniGB-UCS2-H',
  39570. 'UniGB-UCS2-V',
  39571. 'UniGB-UTF16-H',
  39572. 'UniGB-UTF16-V',
  39573. 'UniGB-UTF32-H',
  39574. 'UniGB-UTF32-V',
  39575. 'UniGB-UTF8-H',
  39576. 'UniGB-UTF8-V',
  39577. 'UniJIS-UCS2-H',
  39578. 'UniJIS-UCS2-HW-H',
  39579. 'UniJIS-UCS2-HW-V',
  39580. 'UniJIS-UCS2-V',
  39581. 'UniJIS-UTF16-H',
  39582. 'UniJIS-UTF16-V',
  39583. 'UniJIS-UTF32-H',
  39584. 'UniJIS-UTF32-V',
  39585. 'UniJIS-UTF8-H',
  39586. 'UniJIS-UTF8-V',
  39587. 'UniJIS2004-UTF16-H',
  39588. 'UniJIS2004-UTF16-V',
  39589. 'UniJIS2004-UTF32-H',
  39590. 'UniJIS2004-UTF32-V',
  39591. 'UniJIS2004-UTF8-H',
  39592. 'UniJIS2004-UTF8-V',
  39593. 'UniJISPro-UCS2-HW-V',
  39594. 'UniJISPro-UCS2-V',
  39595. 'UniJISPro-UTF8-V',
  39596. 'UniJISX0213-UTF32-H',
  39597. 'UniJISX0213-UTF32-V',
  39598. 'UniJISX02132004-UTF32-H',
  39599. 'UniJISX02132004-UTF32-V',
  39600. 'UniKS-UCS2-H',
  39601. 'UniKS-UCS2-V',
  39602. 'UniKS-UTF16-H',
  39603. 'UniKS-UTF16-V',
  39604. 'UniKS-UTF32-H',
  39605. 'UniKS-UTF32-V',
  39606. 'UniKS-UTF8-H',
  39607. 'UniKS-UTF8-V',
  39608. 'V',
  39609. 'WP-Symbol'
  39610. ];
  39611. var CMap = function CMapClosure() {
  39612. function CMap(builtInCMap) {
  39613. this.codespaceRanges = [
  39614. [],
  39615. [],
  39616. [],
  39617. []
  39618. ];
  39619. this.numCodespaceRanges = 0;
  39620. this._map = [];
  39621. this.name = '';
  39622. this.vertical = false;
  39623. this.useCMap = null;
  39624. this.builtInCMap = builtInCMap;
  39625. }
  39626. CMap.prototype = {
  39627. addCodespaceRange: function (n, low, high) {
  39628. this.codespaceRanges[n - 1].push(low, high);
  39629. this.numCodespaceRanges++;
  39630. },
  39631. mapCidRange: function (low, high, dstLow) {
  39632. while (low <= high) {
  39633. this._map[low++] = dstLow++;
  39634. }
  39635. },
  39636. mapBfRange: function (low, high, dstLow) {
  39637. var lastByte = dstLow.length - 1;
  39638. while (low <= high) {
  39639. this._map[low++] = dstLow;
  39640. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39641. }
  39642. },
  39643. mapBfRangeToArray: function (low, high, array) {
  39644. var i = 0, ii = array.length;
  39645. while (low <= high && i < ii) {
  39646. this._map[low] = array[i++];
  39647. ++low;
  39648. }
  39649. },
  39650. mapOne: function (src, dst) {
  39651. this._map[src] = dst;
  39652. },
  39653. lookup: function (code) {
  39654. return this._map[code];
  39655. },
  39656. contains: function (code) {
  39657. return this._map[code] !== undefined;
  39658. },
  39659. forEach: function (callback) {
  39660. var map = this._map;
  39661. var length = map.length;
  39662. var i;
  39663. if (length <= 0x10000) {
  39664. for (i = 0; i < length; i++) {
  39665. if (map[i] !== undefined) {
  39666. callback(i, map[i]);
  39667. }
  39668. }
  39669. } else {
  39670. for (i in this._map) {
  39671. callback(i, map[i]);
  39672. }
  39673. }
  39674. },
  39675. charCodeOf: function (value) {
  39676. return this._map.indexOf(value);
  39677. },
  39678. getMap: function () {
  39679. return this._map;
  39680. },
  39681. readCharCode: function (str, offset, out) {
  39682. var c = 0;
  39683. var codespaceRanges = this.codespaceRanges;
  39684. var codespaceRangesLen = this.codespaceRanges.length;
  39685. for (var n = 0; n < codespaceRangesLen; n++) {
  39686. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39687. var codespaceRange = codespaceRanges[n];
  39688. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39689. var low = codespaceRange[k++];
  39690. var high = codespaceRange[k++];
  39691. if (c >= low && c <= high) {
  39692. out.charcode = c;
  39693. out.length = n + 1;
  39694. return;
  39695. }
  39696. }
  39697. }
  39698. out.charcode = 0;
  39699. out.length = 1;
  39700. },
  39701. get length() {
  39702. return this._map.length;
  39703. },
  39704. get isIdentityCMap() {
  39705. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39706. return false;
  39707. }
  39708. if (this._map.length !== 0x10000) {
  39709. return false;
  39710. }
  39711. for (var i = 0; i < 0x10000; i++) {
  39712. if (this._map[i] !== i) {
  39713. return false;
  39714. }
  39715. }
  39716. return true;
  39717. }
  39718. };
  39719. return CMap;
  39720. }();
  39721. var IdentityCMap = function IdentityCMapClosure() {
  39722. function IdentityCMap(vertical, n) {
  39723. CMap.call(this);
  39724. this.vertical = vertical;
  39725. this.addCodespaceRange(n, 0, 0xffff);
  39726. }
  39727. Util.inherit(IdentityCMap, CMap, {});
  39728. IdentityCMap.prototype = {
  39729. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39730. mapCidRange: function (low, high, dstLow) {
  39731. error('should not call mapCidRange');
  39732. },
  39733. mapBfRange: function (low, high, dstLow) {
  39734. error('should not call mapBfRange');
  39735. },
  39736. mapBfRangeToArray: function (low, high, array) {
  39737. error('should not call mapBfRangeToArray');
  39738. },
  39739. mapOne: function (src, dst) {
  39740. error('should not call mapCidOne');
  39741. },
  39742. lookup: function (code) {
  39743. return isInt(code) && code <= 0xffff ? code : undefined;
  39744. },
  39745. contains: function (code) {
  39746. return isInt(code) && code <= 0xffff;
  39747. },
  39748. forEach: function (callback) {
  39749. for (var i = 0; i <= 0xffff; i++) {
  39750. callback(i, i);
  39751. }
  39752. },
  39753. charCodeOf: function (value) {
  39754. return isInt(value) && value <= 0xffff ? value : -1;
  39755. },
  39756. getMap: function () {
  39757. var map = new Array(0x10000);
  39758. for (var i = 0; i <= 0xffff; i++) {
  39759. map[i] = i;
  39760. }
  39761. return map;
  39762. },
  39763. readCharCode: CMap.prototype.readCharCode,
  39764. get length() {
  39765. return 0x10000;
  39766. },
  39767. get isIdentityCMap() {
  39768. error('should not access .isIdentityCMap');
  39769. }
  39770. };
  39771. return IdentityCMap;
  39772. }();
  39773. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39774. function fetchBinaryData(url) {
  39775. return new Promise(function (resolve, reject) {
  39776. var request = new XMLHttpRequest();
  39777. request.open('GET', url, true);
  39778. request.responseType = 'arraybuffer';
  39779. request.onreadystatechange = function () {
  39780. if (request.readyState === XMLHttpRequest.DONE) {
  39781. if (!request.response || request.status !== 200 && request.status !== 0) {
  39782. reject(new Error('Unable to get binary cMap at: ' + url));
  39783. } else {
  39784. resolve(new Uint8Array(request.response));
  39785. }
  39786. }
  39787. };
  39788. request.send(null);
  39789. });
  39790. }
  39791. function hexToInt(a, size) {
  39792. var n = 0;
  39793. for (var i = 0; i <= size; i++) {
  39794. n = n << 8 | a[i];
  39795. }
  39796. return n >>> 0;
  39797. }
  39798. function hexToStr(a, size) {
  39799. if (size === 1) {
  39800. return String.fromCharCode(a[0], a[1]);
  39801. }
  39802. if (size === 3) {
  39803. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39804. }
  39805. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39806. }
  39807. function addHex(a, b, size) {
  39808. var c = 0;
  39809. for (var i = size; i >= 0; i--) {
  39810. c += a[i] + b[i];
  39811. a[i] = c & 255;
  39812. c >>= 8;
  39813. }
  39814. }
  39815. function incHex(a, size) {
  39816. var c = 1;
  39817. for (var i = size; i >= 0 && c > 0; i--) {
  39818. c += a[i];
  39819. a[i] = c & 255;
  39820. c >>= 8;
  39821. }
  39822. }
  39823. var MAX_NUM_SIZE = 16;
  39824. var MAX_ENCODED_NUM_SIZE = 19;
  39825. function BinaryCMapStream(data) {
  39826. this.buffer = data;
  39827. this.pos = 0;
  39828. this.end = data.length;
  39829. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  39830. }
  39831. BinaryCMapStream.prototype = {
  39832. readByte: function () {
  39833. if (this.pos >= this.end) {
  39834. return -1;
  39835. }
  39836. return this.buffer[this.pos++];
  39837. },
  39838. readNumber: function () {
  39839. var n = 0;
  39840. var last;
  39841. do {
  39842. var b = this.readByte();
  39843. if (b < 0) {
  39844. error('unexpected EOF in bcmap');
  39845. }
  39846. last = !(b & 0x80);
  39847. n = n << 7 | b & 0x7F;
  39848. } while (!last);
  39849. return n;
  39850. },
  39851. readSigned: function () {
  39852. var n = this.readNumber();
  39853. return n & 1 ? ~(n >>> 1) : n >>> 1;
  39854. },
  39855. readHex: function (num, size) {
  39856. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  39857. this.pos += size + 1;
  39858. },
  39859. readHexNumber: function (num, size) {
  39860. var last;
  39861. var stack = this.tmpBuf, sp = 0;
  39862. do {
  39863. var b = this.readByte();
  39864. if (b < 0) {
  39865. error('unexpected EOF in bcmap');
  39866. }
  39867. last = !(b & 0x80);
  39868. stack[sp++] = b & 0x7F;
  39869. } while (!last);
  39870. var i = size, buffer = 0, bufferSize = 0;
  39871. while (i >= 0) {
  39872. while (bufferSize < 8 && stack.length > 0) {
  39873. buffer = stack[--sp] << bufferSize | buffer;
  39874. bufferSize += 7;
  39875. }
  39876. num[i] = buffer & 255;
  39877. i--;
  39878. buffer >>= 8;
  39879. bufferSize -= 8;
  39880. }
  39881. },
  39882. readHexSigned: function (num, size) {
  39883. this.readHexNumber(num, size);
  39884. var sign = num[size] & 1 ? 255 : 0;
  39885. var c = 0;
  39886. for (var i = 0; i <= size; i++) {
  39887. c = (c & 1) << 8 | num[i];
  39888. num[i] = c >> 1 ^ sign;
  39889. }
  39890. },
  39891. readString: function () {
  39892. var len = this.readNumber();
  39893. var s = '';
  39894. for (var i = 0; i < len; i++) {
  39895. s += String.fromCharCode(this.readNumber());
  39896. }
  39897. return s;
  39898. }
  39899. };
  39900. function processBinaryCMap(url, cMap, extend) {
  39901. return fetchBinaryData(url).then(function (data) {
  39902. var stream = new BinaryCMapStream(data);
  39903. var header = stream.readByte();
  39904. cMap.vertical = !!(header & 1);
  39905. var useCMap = null;
  39906. var start = new Uint8Array(MAX_NUM_SIZE);
  39907. var end = new Uint8Array(MAX_NUM_SIZE);
  39908. var char = new Uint8Array(MAX_NUM_SIZE);
  39909. var charCode = new Uint8Array(MAX_NUM_SIZE);
  39910. var tmp = new Uint8Array(MAX_NUM_SIZE);
  39911. var code;
  39912. var b;
  39913. while ((b = stream.readByte()) >= 0) {
  39914. var type = b >> 5;
  39915. if (type === 7) {
  39916. switch (b & 0x1F) {
  39917. case 0:
  39918. stream.readString();
  39919. break;
  39920. case 1:
  39921. useCMap = stream.readString();
  39922. break;
  39923. }
  39924. continue;
  39925. }
  39926. var sequence = !!(b & 0x10);
  39927. var dataSize = b & 15;
  39928. assert(dataSize + 1 <= MAX_NUM_SIZE);
  39929. var ucs2DataSize = 1;
  39930. var subitemsCount = stream.readNumber();
  39931. var i;
  39932. switch (type) {
  39933. case 0:
  39934. stream.readHex(start, dataSize);
  39935. stream.readHexNumber(end, dataSize);
  39936. addHex(end, start, dataSize);
  39937. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39938. for (i = 1; i < subitemsCount; i++) {
  39939. incHex(end, dataSize);
  39940. stream.readHexNumber(start, dataSize);
  39941. addHex(start, end, dataSize);
  39942. stream.readHexNumber(end, dataSize);
  39943. addHex(end, start, dataSize);
  39944. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39945. }
  39946. break;
  39947. case 1:
  39948. stream.readHex(start, dataSize);
  39949. stream.readHexNumber(end, dataSize);
  39950. addHex(end, start, dataSize);
  39951. code = stream.readNumber();
  39952. for (i = 1; i < subitemsCount; i++) {
  39953. incHex(end, dataSize);
  39954. stream.readHexNumber(start, dataSize);
  39955. addHex(start, end, dataSize);
  39956. stream.readHexNumber(end, dataSize);
  39957. addHex(end, start, dataSize);
  39958. code = stream.readNumber();
  39959. }
  39960. break;
  39961. case 2:
  39962. stream.readHex(char, dataSize);
  39963. code = stream.readNumber();
  39964. cMap.mapOne(hexToInt(char, dataSize), code);
  39965. for (i = 1; i < subitemsCount; i++) {
  39966. incHex(char, dataSize);
  39967. if (!sequence) {
  39968. stream.readHexNumber(tmp, dataSize);
  39969. addHex(char, tmp, dataSize);
  39970. }
  39971. code = stream.readSigned() + (code + 1);
  39972. cMap.mapOne(hexToInt(char, dataSize), code);
  39973. }
  39974. break;
  39975. case 3:
  39976. stream.readHex(start, dataSize);
  39977. stream.readHexNumber(end, dataSize);
  39978. addHex(end, start, dataSize);
  39979. code = stream.readNumber();
  39980. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39981. for (i = 1; i < subitemsCount; i++) {
  39982. incHex(end, dataSize);
  39983. if (!sequence) {
  39984. stream.readHexNumber(start, dataSize);
  39985. addHex(start, end, dataSize);
  39986. } else {
  39987. start.set(end);
  39988. }
  39989. stream.readHexNumber(end, dataSize);
  39990. addHex(end, start, dataSize);
  39991. code = stream.readNumber();
  39992. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39993. }
  39994. break;
  39995. case 4:
  39996. stream.readHex(char, ucs2DataSize);
  39997. stream.readHex(charCode, dataSize);
  39998. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  39999. for (i = 1; i < subitemsCount; i++) {
  40000. incHex(char, ucs2DataSize);
  40001. if (!sequence) {
  40002. stream.readHexNumber(tmp, ucs2DataSize);
  40003. addHex(char, tmp, ucs2DataSize);
  40004. }
  40005. incHex(charCode, dataSize);
  40006. stream.readHexSigned(tmp, dataSize);
  40007. addHex(charCode, tmp, dataSize);
  40008. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40009. }
  40010. break;
  40011. case 5:
  40012. stream.readHex(start, ucs2DataSize);
  40013. stream.readHexNumber(end, ucs2DataSize);
  40014. addHex(end, start, ucs2DataSize);
  40015. stream.readHex(charCode, dataSize);
  40016. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40017. for (i = 1; i < subitemsCount; i++) {
  40018. incHex(end, ucs2DataSize);
  40019. if (!sequence) {
  40020. stream.readHexNumber(start, ucs2DataSize);
  40021. addHex(start, end, ucs2DataSize);
  40022. } else {
  40023. start.set(end);
  40024. }
  40025. stream.readHexNumber(end, ucs2DataSize);
  40026. addHex(end, start, ucs2DataSize);
  40027. stream.readHex(charCode, dataSize);
  40028. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40029. }
  40030. break;
  40031. default:
  40032. error('Unknown type: ' + type);
  40033. break;
  40034. }
  40035. }
  40036. if (useCMap) {
  40037. return extend(useCMap);
  40038. }
  40039. return cMap;
  40040. });
  40041. }
  40042. function BinaryCMapReader() {
  40043. }
  40044. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40045. return BinaryCMapReader;
  40046. }();
  40047. var CMapFactory = function CMapFactoryClosure() {
  40048. function strToInt(str) {
  40049. var a = 0;
  40050. for (var i = 0; i < str.length; i++) {
  40051. a = a << 8 | str.charCodeAt(i);
  40052. }
  40053. return a >>> 0;
  40054. }
  40055. function expectString(obj) {
  40056. if (!isString(obj)) {
  40057. error('Malformed CMap: expected string.');
  40058. }
  40059. }
  40060. function expectInt(obj) {
  40061. if (!isInt(obj)) {
  40062. error('Malformed CMap: expected int.');
  40063. }
  40064. }
  40065. function parseBfChar(cMap, lexer) {
  40066. while (true) {
  40067. var obj = lexer.getObj();
  40068. if (isEOF(obj)) {
  40069. break;
  40070. }
  40071. if (isCmd(obj, 'endbfchar')) {
  40072. return;
  40073. }
  40074. expectString(obj);
  40075. var src = strToInt(obj);
  40076. obj = lexer.getObj();
  40077. expectString(obj);
  40078. var dst = obj;
  40079. cMap.mapOne(src, dst);
  40080. }
  40081. }
  40082. function parseBfRange(cMap, lexer) {
  40083. while (true) {
  40084. var obj = lexer.getObj();
  40085. if (isEOF(obj)) {
  40086. break;
  40087. }
  40088. if (isCmd(obj, 'endbfrange')) {
  40089. return;
  40090. }
  40091. expectString(obj);
  40092. var low = strToInt(obj);
  40093. obj = lexer.getObj();
  40094. expectString(obj);
  40095. var high = strToInt(obj);
  40096. obj = lexer.getObj();
  40097. if (isInt(obj) || isString(obj)) {
  40098. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40099. cMap.mapBfRange(low, high, dstLow);
  40100. } else if (isCmd(obj, '[')) {
  40101. obj = lexer.getObj();
  40102. var array = [];
  40103. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40104. array.push(obj);
  40105. obj = lexer.getObj();
  40106. }
  40107. cMap.mapBfRangeToArray(low, high, array);
  40108. } else {
  40109. break;
  40110. }
  40111. }
  40112. error('Invalid bf range.');
  40113. }
  40114. function parseCidChar(cMap, lexer) {
  40115. while (true) {
  40116. var obj = lexer.getObj();
  40117. if (isEOF(obj)) {
  40118. break;
  40119. }
  40120. if (isCmd(obj, 'endcidchar')) {
  40121. return;
  40122. }
  40123. expectString(obj);
  40124. var src = strToInt(obj);
  40125. obj = lexer.getObj();
  40126. expectInt(obj);
  40127. var dst = obj;
  40128. cMap.mapOne(src, dst);
  40129. }
  40130. }
  40131. function parseCidRange(cMap, lexer) {
  40132. while (true) {
  40133. var obj = lexer.getObj();
  40134. if (isEOF(obj)) {
  40135. break;
  40136. }
  40137. if (isCmd(obj, 'endcidrange')) {
  40138. return;
  40139. }
  40140. expectString(obj);
  40141. var low = strToInt(obj);
  40142. obj = lexer.getObj();
  40143. expectString(obj);
  40144. var high = strToInt(obj);
  40145. obj = lexer.getObj();
  40146. expectInt(obj);
  40147. var dstLow = obj;
  40148. cMap.mapCidRange(low, high, dstLow);
  40149. }
  40150. }
  40151. function parseCodespaceRange(cMap, lexer) {
  40152. while (true) {
  40153. var obj = lexer.getObj();
  40154. if (isEOF(obj)) {
  40155. break;
  40156. }
  40157. if (isCmd(obj, 'endcodespacerange')) {
  40158. return;
  40159. }
  40160. if (!isString(obj)) {
  40161. break;
  40162. }
  40163. var low = strToInt(obj);
  40164. obj = lexer.getObj();
  40165. if (!isString(obj)) {
  40166. break;
  40167. }
  40168. var high = strToInt(obj);
  40169. cMap.addCodespaceRange(obj.length, low, high);
  40170. }
  40171. error('Invalid codespace range.');
  40172. }
  40173. function parseWMode(cMap, lexer) {
  40174. var obj = lexer.getObj();
  40175. if (isInt(obj)) {
  40176. cMap.vertical = !!obj;
  40177. }
  40178. }
  40179. function parseCMapName(cMap, lexer) {
  40180. var obj = lexer.getObj();
  40181. if (isName(obj) && isString(obj.name)) {
  40182. cMap.name = obj.name;
  40183. }
  40184. }
  40185. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40186. var previous;
  40187. var embededUseCMap;
  40188. objLoop:
  40189. while (true) {
  40190. try {
  40191. var obj = lexer.getObj();
  40192. if (isEOF(obj)) {
  40193. break;
  40194. } else if (isName(obj)) {
  40195. if (obj.name === 'WMode') {
  40196. parseWMode(cMap, lexer);
  40197. } else if (obj.name === 'CMapName') {
  40198. parseCMapName(cMap, lexer);
  40199. }
  40200. previous = obj;
  40201. } else if (isCmd(obj)) {
  40202. switch (obj.cmd) {
  40203. case 'endcmap':
  40204. break objLoop;
  40205. case 'usecmap':
  40206. if (isName(previous)) {
  40207. embededUseCMap = previous.name;
  40208. }
  40209. break;
  40210. case 'begincodespacerange':
  40211. parseCodespaceRange(cMap, lexer);
  40212. break;
  40213. case 'beginbfchar':
  40214. parseBfChar(cMap, lexer);
  40215. break;
  40216. case 'begincidchar':
  40217. parseCidChar(cMap, lexer);
  40218. break;
  40219. case 'beginbfrange':
  40220. parseBfRange(cMap, lexer);
  40221. break;
  40222. case 'begincidrange':
  40223. parseCidRange(cMap, lexer);
  40224. break;
  40225. }
  40226. }
  40227. } catch (ex) {
  40228. if (ex instanceof MissingDataException) {
  40229. throw ex;
  40230. }
  40231. warn('Invalid cMap data: ' + ex);
  40232. continue;
  40233. }
  40234. }
  40235. if (!useCMap && embededUseCMap) {
  40236. useCMap = embededUseCMap;
  40237. }
  40238. if (useCMap) {
  40239. return extendCMap(cMap, builtInCMapParams, useCMap);
  40240. }
  40241. return Promise.resolve(cMap);
  40242. }
  40243. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40244. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40245. cMap.useCMap = newCMap;
  40246. if (cMap.numCodespaceRanges === 0) {
  40247. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40248. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40249. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40250. }
  40251. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40252. }
  40253. cMap.useCMap.forEach(function (key, value) {
  40254. if (!cMap.contains(key)) {
  40255. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40256. }
  40257. });
  40258. return cMap;
  40259. });
  40260. }
  40261. function parseBinaryCMap(name, builtInCMapParams) {
  40262. var url = builtInCMapParams.url + name + '.bcmap';
  40263. var cMap = new CMap(true);
  40264. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40265. return extendCMap(cMap, builtInCMapParams, useCMap);
  40266. });
  40267. }
  40268. function createBuiltInCMap(name, builtInCMapParams) {
  40269. if (name === 'Identity-H') {
  40270. return Promise.resolve(new IdentityCMap(false, 2));
  40271. } else if (name === 'Identity-V') {
  40272. return Promise.resolve(new IdentityCMap(true, 2));
  40273. }
  40274. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40275. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40276. }
  40277. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40278. if (builtInCMapParams.packed) {
  40279. return parseBinaryCMap(name, builtInCMapParams);
  40280. }
  40281. return new Promise(function (resolve, reject) {
  40282. var url = builtInCMapParams.url + name;
  40283. var request = new XMLHttpRequest();
  40284. request.onreadystatechange = function () {
  40285. if (request.readyState === XMLHttpRequest.DONE) {
  40286. if (request.status === 200 || request.status === 0) {
  40287. var cMap = new CMap(true);
  40288. var lexer = new Lexer(new StringStream(request.responseText));
  40289. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40290. resolve(parsedCMap);
  40291. });
  40292. } else {
  40293. reject(new Error('Unable to get cMap at: ' + url));
  40294. }
  40295. }
  40296. };
  40297. request.open('GET', url, true);
  40298. request.send(null);
  40299. });
  40300. }
  40301. return {
  40302. create: function (encoding, builtInCMapParams, useCMap) {
  40303. if (isName(encoding)) {
  40304. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40305. } else if (isStream(encoding)) {
  40306. var cMap = new CMap();
  40307. var lexer = new Lexer(encoding);
  40308. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40309. if (parsedCMap.isIdentityCMap) {
  40310. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40311. }
  40312. return parsedCMap;
  40313. });
  40314. }
  40315. return Promise.reject(new Error('Encoding required.'));
  40316. }
  40317. };
  40318. }();
  40319. exports.CMap = CMap;
  40320. exports.CMapFactory = CMapFactory;
  40321. exports.IdentityCMap = IdentityCMap;
  40322. }));
  40323. (function (root, factory) {
  40324. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40325. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40326. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40327. var FontType = sharedUtil.FontType;
  40328. var assert = sharedUtil.assert;
  40329. var bytesToString = sharedUtil.bytesToString;
  40330. var error = sharedUtil.error;
  40331. var info = sharedUtil.info;
  40332. var isArray = sharedUtil.isArray;
  40333. var isInt = sharedUtil.isInt;
  40334. var isNum = sharedUtil.isNum;
  40335. var readUint32 = sharedUtil.readUint32;
  40336. var shadow = sharedUtil.shadow;
  40337. var string32 = sharedUtil.string32;
  40338. var warn = sharedUtil.warn;
  40339. var MissingDataException = sharedUtil.MissingDataException;
  40340. var isSpace = sharedUtil.isSpace;
  40341. var Stream = coreStream.Stream;
  40342. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40343. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40344. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40345. var StandardEncoding = coreEncodings.StandardEncoding;
  40346. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40347. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40348. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40349. var getEncoding = coreEncodings.getEncoding;
  40350. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40351. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40352. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40353. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40354. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40355. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40356. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40357. var Type1Parser = coreType1Parser.Type1Parser;
  40358. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40359. var CFFParser = coreCFFParser.CFFParser;
  40360. var CFFCompiler = coreCFFParser.CFFCompiler;
  40361. var CFF = coreCFFParser.CFF;
  40362. var CFFHeader = coreCFFParser.CFFHeader;
  40363. var CFFTopDict = coreCFFParser.CFFTopDict;
  40364. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40365. var CFFStrings = coreCFFParser.CFFStrings;
  40366. var CFFIndex = coreCFFParser.CFFIndex;
  40367. var CFFCharset = coreCFFParser.CFFCharset;
  40368. var PRIVATE_USE_OFFSET_START = 0xE000;
  40369. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40370. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40371. var PDF_GLYPH_SPACE_UNITS = 1000;
  40372. var SEAC_ANALYSIS_ENABLED = false;
  40373. var FontFlags = {
  40374. FixedPitch: 1,
  40375. Serif: 2,
  40376. Symbolic: 4,
  40377. Script: 8,
  40378. Nonsymbolic: 32,
  40379. Italic: 64,
  40380. AllCap: 65536,
  40381. SmallCap: 131072,
  40382. ForceBold: 262144
  40383. };
  40384. var MacStandardGlyphOrdering = [
  40385. '.notdef',
  40386. '.null',
  40387. 'nonmarkingreturn',
  40388. 'space',
  40389. 'exclam',
  40390. 'quotedbl',
  40391. 'numbersign',
  40392. 'dollar',
  40393. 'percent',
  40394. 'ampersand',
  40395. 'quotesingle',
  40396. 'parenleft',
  40397. 'parenright',
  40398. 'asterisk',
  40399. 'plus',
  40400. 'comma',
  40401. 'hyphen',
  40402. 'period',
  40403. 'slash',
  40404. 'zero',
  40405. 'one',
  40406. 'two',
  40407. 'three',
  40408. 'four',
  40409. 'five',
  40410. 'six',
  40411. 'seven',
  40412. 'eight',
  40413. 'nine',
  40414. 'colon',
  40415. 'semicolon',
  40416. 'less',
  40417. 'equal',
  40418. 'greater',
  40419. 'question',
  40420. 'at',
  40421. 'A',
  40422. 'B',
  40423. 'C',
  40424. 'D',
  40425. 'E',
  40426. 'F',
  40427. 'G',
  40428. 'H',
  40429. 'I',
  40430. 'J',
  40431. 'K',
  40432. 'L',
  40433. 'M',
  40434. 'N',
  40435. 'O',
  40436. 'P',
  40437. 'Q',
  40438. 'R',
  40439. 'S',
  40440. 'T',
  40441. 'U',
  40442. 'V',
  40443. 'W',
  40444. 'X',
  40445. 'Y',
  40446. 'Z',
  40447. 'bracketleft',
  40448. 'backslash',
  40449. 'bracketright',
  40450. 'asciicircum',
  40451. 'underscore',
  40452. 'grave',
  40453. 'a',
  40454. 'b',
  40455. 'c',
  40456. 'd',
  40457. 'e',
  40458. 'f',
  40459. 'g',
  40460. 'h',
  40461. 'i',
  40462. 'j',
  40463. 'k',
  40464. 'l',
  40465. 'm',
  40466. 'n',
  40467. 'o',
  40468. 'p',
  40469. 'q',
  40470. 'r',
  40471. 's',
  40472. 't',
  40473. 'u',
  40474. 'v',
  40475. 'w',
  40476. 'x',
  40477. 'y',
  40478. 'z',
  40479. 'braceleft',
  40480. 'bar',
  40481. 'braceright',
  40482. 'asciitilde',
  40483. 'Adieresis',
  40484. 'Aring',
  40485. 'Ccedilla',
  40486. 'Eacute',
  40487. 'Ntilde',
  40488. 'Odieresis',
  40489. 'Udieresis',
  40490. 'aacute',
  40491. 'agrave',
  40492. 'acircumflex',
  40493. 'adieresis',
  40494. 'atilde',
  40495. 'aring',
  40496. 'ccedilla',
  40497. 'eacute',
  40498. 'egrave',
  40499. 'ecircumflex',
  40500. 'edieresis',
  40501. 'iacute',
  40502. 'igrave',
  40503. 'icircumflex',
  40504. 'idieresis',
  40505. 'ntilde',
  40506. 'oacute',
  40507. 'ograve',
  40508. 'ocircumflex',
  40509. 'odieresis',
  40510. 'otilde',
  40511. 'uacute',
  40512. 'ugrave',
  40513. 'ucircumflex',
  40514. 'udieresis',
  40515. 'dagger',
  40516. 'degree',
  40517. 'cent',
  40518. 'sterling',
  40519. 'section',
  40520. 'bullet',
  40521. 'paragraph',
  40522. 'germandbls',
  40523. 'registered',
  40524. 'copyright',
  40525. 'trademark',
  40526. 'acute',
  40527. 'dieresis',
  40528. 'notequal',
  40529. 'AE',
  40530. 'Oslash',
  40531. 'infinity',
  40532. 'plusminus',
  40533. 'lessequal',
  40534. 'greaterequal',
  40535. 'yen',
  40536. 'mu',
  40537. 'partialdiff',
  40538. 'summation',
  40539. 'product',
  40540. 'pi',
  40541. 'integral',
  40542. 'ordfeminine',
  40543. 'ordmasculine',
  40544. 'Omega',
  40545. 'ae',
  40546. 'oslash',
  40547. 'questiondown',
  40548. 'exclamdown',
  40549. 'logicalnot',
  40550. 'radical',
  40551. 'florin',
  40552. 'approxequal',
  40553. 'Delta',
  40554. 'guillemotleft',
  40555. 'guillemotright',
  40556. 'ellipsis',
  40557. 'nonbreakingspace',
  40558. 'Agrave',
  40559. 'Atilde',
  40560. 'Otilde',
  40561. 'OE',
  40562. 'oe',
  40563. 'endash',
  40564. 'emdash',
  40565. 'quotedblleft',
  40566. 'quotedblright',
  40567. 'quoteleft',
  40568. 'quoteright',
  40569. 'divide',
  40570. 'lozenge',
  40571. 'ydieresis',
  40572. 'Ydieresis',
  40573. 'fraction',
  40574. 'currency',
  40575. 'guilsinglleft',
  40576. 'guilsinglright',
  40577. 'fi',
  40578. 'fl',
  40579. 'daggerdbl',
  40580. 'periodcentered',
  40581. 'quotesinglbase',
  40582. 'quotedblbase',
  40583. 'perthousand',
  40584. 'Acircumflex',
  40585. 'Ecircumflex',
  40586. 'Aacute',
  40587. 'Edieresis',
  40588. 'Egrave',
  40589. 'Iacute',
  40590. 'Icircumflex',
  40591. 'Idieresis',
  40592. 'Igrave',
  40593. 'Oacute',
  40594. 'Ocircumflex',
  40595. 'apple',
  40596. 'Ograve',
  40597. 'Uacute',
  40598. 'Ucircumflex',
  40599. 'Ugrave',
  40600. 'dotlessi',
  40601. 'circumflex',
  40602. 'tilde',
  40603. 'macron',
  40604. 'breve',
  40605. 'dotaccent',
  40606. 'ring',
  40607. 'cedilla',
  40608. 'hungarumlaut',
  40609. 'ogonek',
  40610. 'caron',
  40611. 'Lslash',
  40612. 'lslash',
  40613. 'Scaron',
  40614. 'scaron',
  40615. 'Zcaron',
  40616. 'zcaron',
  40617. 'brokenbar',
  40618. 'Eth',
  40619. 'eth',
  40620. 'Yacute',
  40621. 'yacute',
  40622. 'Thorn',
  40623. 'thorn',
  40624. 'minus',
  40625. 'multiply',
  40626. 'onesuperior',
  40627. 'twosuperior',
  40628. 'threesuperior',
  40629. 'onehalf',
  40630. 'onequarter',
  40631. 'threequarters',
  40632. 'franc',
  40633. 'Gbreve',
  40634. 'gbreve',
  40635. 'Idotaccent',
  40636. 'Scedilla',
  40637. 'scedilla',
  40638. 'Cacute',
  40639. 'cacute',
  40640. 'Ccaron',
  40641. 'ccaron',
  40642. 'dcroat'
  40643. ];
  40644. function adjustWidths(properties) {
  40645. if (!properties.fontMatrix) {
  40646. return;
  40647. }
  40648. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40649. return;
  40650. }
  40651. var scale = 0.001 / properties.fontMatrix[0];
  40652. var glyphsWidths = properties.widths;
  40653. for (var glyph in glyphsWidths) {
  40654. glyphsWidths[glyph] *= scale;
  40655. }
  40656. properties.defaultWidth *= scale;
  40657. }
  40658. function adjustToUnicode(properties, builtInEncoding) {
  40659. if (properties.hasIncludedToUnicodeMap) {
  40660. return;
  40661. }
  40662. if (properties.hasEncoding) {
  40663. return;
  40664. }
  40665. if (builtInEncoding === properties.defaultEncoding) {
  40666. return;
  40667. }
  40668. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40669. return;
  40670. }
  40671. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40672. for (var charCode in builtInEncoding) {
  40673. var glyphName = builtInEncoding[charCode];
  40674. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40675. if (unicode !== -1) {
  40676. toUnicode[charCode] = String.fromCharCode(unicode);
  40677. }
  40678. }
  40679. properties.toUnicode.amend(toUnicode);
  40680. }
  40681. function getFontType(type, subtype) {
  40682. switch (type) {
  40683. case 'Type1':
  40684. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40685. case 'CIDFontType0':
  40686. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40687. case 'OpenType':
  40688. return FontType.OPENTYPE;
  40689. case 'TrueType':
  40690. return FontType.TRUETYPE;
  40691. case 'CIDFontType2':
  40692. return FontType.CIDFONTTYPE2;
  40693. case 'MMType1':
  40694. return FontType.MMTYPE1;
  40695. case 'Type0':
  40696. return FontType.TYPE0;
  40697. default:
  40698. return FontType.UNKNOWN;
  40699. }
  40700. }
  40701. function recoverGlyphName(name, glyphsUnicodeMap) {
  40702. if (glyphsUnicodeMap[name] !== undefined) {
  40703. return name;
  40704. }
  40705. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40706. if (unicode !== -1) {
  40707. for (var key in glyphsUnicodeMap) {
  40708. if (glyphsUnicodeMap[key] === unicode) {
  40709. return key;
  40710. }
  40711. }
  40712. }
  40713. info('Unable to recover a standard glyph name for: ' + name);
  40714. return name;
  40715. }
  40716. var Glyph = function GlyphClosure() {
  40717. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40718. this.fontChar = fontChar;
  40719. this.unicode = unicode;
  40720. this.accent = accent;
  40721. this.width = width;
  40722. this.vmetric = vmetric;
  40723. this.operatorListId = operatorListId;
  40724. this.isSpace = isSpace;
  40725. this.isInFont = isInFont;
  40726. }
  40727. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40728. 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;
  40729. };
  40730. return Glyph;
  40731. }();
  40732. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40733. function ToUnicodeMap(cmap) {
  40734. this._map = cmap;
  40735. }
  40736. ToUnicodeMap.prototype = {
  40737. get length() {
  40738. return this._map.length;
  40739. },
  40740. forEach: function (callback) {
  40741. for (var charCode in this._map) {
  40742. callback(charCode, this._map[charCode].charCodeAt(0));
  40743. }
  40744. },
  40745. has: function (i) {
  40746. return this._map[i] !== undefined;
  40747. },
  40748. get: function (i) {
  40749. return this._map[i];
  40750. },
  40751. charCodeOf: function (v) {
  40752. return this._map.indexOf(v);
  40753. },
  40754. amend: function (map) {
  40755. for (var charCode in map) {
  40756. this._map[charCode] = map[charCode];
  40757. }
  40758. }
  40759. };
  40760. return ToUnicodeMap;
  40761. }();
  40762. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40763. function IdentityToUnicodeMap(firstChar, lastChar) {
  40764. this.firstChar = firstChar;
  40765. this.lastChar = lastChar;
  40766. }
  40767. IdentityToUnicodeMap.prototype = {
  40768. get length() {
  40769. return this.lastChar + 1 - this.firstChar;
  40770. },
  40771. forEach: function (callback) {
  40772. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40773. callback(i, i);
  40774. }
  40775. },
  40776. has: function (i) {
  40777. return this.firstChar <= i && i <= this.lastChar;
  40778. },
  40779. get: function (i) {
  40780. if (this.firstChar <= i && i <= this.lastChar) {
  40781. return String.fromCharCode(i);
  40782. }
  40783. return undefined;
  40784. },
  40785. charCodeOf: function (v) {
  40786. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40787. },
  40788. amend: function (map) {
  40789. error('Should not call amend()');
  40790. }
  40791. };
  40792. return IdentityToUnicodeMap;
  40793. }();
  40794. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40795. function writeInt16(dest, offset, num) {
  40796. dest[offset] = num >> 8 & 0xFF;
  40797. dest[offset + 1] = num & 0xFF;
  40798. }
  40799. function writeInt32(dest, offset, num) {
  40800. dest[offset] = num >> 24 & 0xFF;
  40801. dest[offset + 1] = num >> 16 & 0xFF;
  40802. dest[offset + 2] = num >> 8 & 0xFF;
  40803. dest[offset + 3] = num & 0xFF;
  40804. }
  40805. function writeData(dest, offset, data) {
  40806. var i, ii;
  40807. if (data instanceof Uint8Array) {
  40808. dest.set(data, offset);
  40809. } else if (typeof data === 'string') {
  40810. for (i = 0, ii = data.length; i < ii; i++) {
  40811. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40812. }
  40813. } else {
  40814. for (i = 0, ii = data.length; i < ii; i++) {
  40815. dest[offset++] = data[i] & 0xFF;
  40816. }
  40817. }
  40818. }
  40819. function OpenTypeFileBuilder(sfnt) {
  40820. this.sfnt = sfnt;
  40821. this.tables = Object.create(null);
  40822. }
  40823. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40824. var maxPower2 = 1, log2 = 0;
  40825. while ((maxPower2 ^ entriesCount) > maxPower2) {
  40826. maxPower2 <<= 1;
  40827. log2++;
  40828. }
  40829. var searchRange = maxPower2 * entrySize;
  40830. return {
  40831. range: searchRange,
  40832. entry: log2,
  40833. rangeShift: entrySize * entriesCount - searchRange
  40834. };
  40835. };
  40836. var OTF_HEADER_SIZE = 12;
  40837. var OTF_TABLE_ENTRY_SIZE = 16;
  40838. OpenTypeFileBuilder.prototype = {
  40839. toArray: function OpenTypeFileBuilder_toArray() {
  40840. var sfnt = this.sfnt;
  40841. var tables = this.tables;
  40842. var tablesNames = Object.keys(tables);
  40843. tablesNames.sort();
  40844. var numTables = tablesNames.length;
  40845. var i, j, jj, table, tableName;
  40846. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  40847. var tableOffsets = [offset];
  40848. for (i = 0; i < numTables; i++) {
  40849. table = tables[tablesNames[i]];
  40850. var paddedLength = (table.length + 3 & ~3) >>> 0;
  40851. offset += paddedLength;
  40852. tableOffsets.push(offset);
  40853. }
  40854. var file = new Uint8Array(offset);
  40855. for (i = 0; i < numTables; i++) {
  40856. table = tables[tablesNames[i]];
  40857. writeData(file, tableOffsets[i], table);
  40858. }
  40859. if (sfnt === 'true') {
  40860. sfnt = string32(0x00010000);
  40861. }
  40862. file[0] = sfnt.charCodeAt(0) & 0xFF;
  40863. file[1] = sfnt.charCodeAt(1) & 0xFF;
  40864. file[2] = sfnt.charCodeAt(2) & 0xFF;
  40865. file[3] = sfnt.charCodeAt(3) & 0xFF;
  40866. writeInt16(file, 4, numTables);
  40867. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  40868. writeInt16(file, 6, searchParams.range);
  40869. writeInt16(file, 8, searchParams.entry);
  40870. writeInt16(file, 10, searchParams.rangeShift);
  40871. offset = OTF_HEADER_SIZE;
  40872. for (i = 0; i < numTables; i++) {
  40873. tableName = tablesNames[i];
  40874. file[offset] = tableName.charCodeAt(0) & 0xFF;
  40875. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  40876. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  40877. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  40878. var checksum = 0;
  40879. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  40880. var quad = readUint32(file, j);
  40881. checksum = checksum + quad >>> 0;
  40882. }
  40883. writeInt32(file, offset + 4, checksum);
  40884. writeInt32(file, offset + 8, tableOffsets[i]);
  40885. writeInt32(file, offset + 12, tables[tableName].length);
  40886. offset += OTF_TABLE_ENTRY_SIZE;
  40887. }
  40888. return file;
  40889. },
  40890. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  40891. if (tag in this.tables) {
  40892. throw new Error('Table ' + tag + ' already exists');
  40893. }
  40894. this.tables[tag] = data;
  40895. }
  40896. };
  40897. return OpenTypeFileBuilder;
  40898. }();
  40899. var ProblematicCharRanges = new Int32Array([
  40900. 0x0000,
  40901. 0x0020,
  40902. 0x007F,
  40903. 0x00A1,
  40904. 0x00AD,
  40905. 0x00AE,
  40906. 0x0600,
  40907. 0x0780,
  40908. 0x08A0,
  40909. 0x10A0,
  40910. 0x1780,
  40911. 0x1800,
  40912. 0x1C00,
  40913. 0x1C50,
  40914. 0x2000,
  40915. 0x2010,
  40916. 0x2011,
  40917. 0x2012,
  40918. 0x2028,
  40919. 0x2030,
  40920. 0x205F,
  40921. 0x2070,
  40922. 0x25CC,
  40923. 0x25CD,
  40924. 0x3000,
  40925. 0x3001,
  40926. 0xAA60,
  40927. 0xAA80,
  40928. 0xFFF0,
  40929. 0x10000
  40930. ]);
  40931. var Font = function FontClosure() {
  40932. function Font(name, file, properties) {
  40933. var charCode, glyphName, unicode;
  40934. this.name = name;
  40935. this.loadedName = properties.loadedName;
  40936. this.isType3Font = properties.isType3Font;
  40937. this.sizes = [];
  40938. this.missingFile = false;
  40939. this.glyphCache = Object.create(null);
  40940. var names = name.split('+');
  40941. names = names.length > 1 ? names[1] : names[0];
  40942. names = names.split(/[-,_]/g)[0];
  40943. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  40944. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  40945. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  40946. var type = properties.type;
  40947. var subtype = properties.subtype;
  40948. this.type = type;
  40949. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  40950. this.differences = properties.differences;
  40951. this.widths = properties.widths;
  40952. this.defaultWidth = properties.defaultWidth;
  40953. this.composite = properties.composite;
  40954. this.wideChars = properties.wideChars;
  40955. this.cMap = properties.cMap;
  40956. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  40957. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  40958. this.fontMatrix = properties.fontMatrix;
  40959. this.bbox = properties.bbox;
  40960. this.toUnicode = properties.toUnicode;
  40961. this.toFontChar = [];
  40962. if (properties.type === 'Type3') {
  40963. for (charCode = 0; charCode < 256; charCode++) {
  40964. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  40965. }
  40966. this.fontType = FontType.TYPE3;
  40967. return;
  40968. }
  40969. this.cidEncoding = properties.cidEncoding;
  40970. this.vertical = properties.vertical;
  40971. if (this.vertical) {
  40972. this.vmetrics = properties.vmetrics;
  40973. this.defaultVMetrics = properties.defaultVMetrics;
  40974. }
  40975. var glyphsUnicodeMap;
  40976. if (!file || file.isEmpty) {
  40977. if (file) {
  40978. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  40979. }
  40980. this.missingFile = true;
  40981. var fontName = name.replace(/[,_]/g, '-');
  40982. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  40983. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  40984. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  40985. this.bold = fontName.search(/bold/gi) !== -1;
  40986. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  40987. this.black = name.search(/Black/g) !== -1;
  40988. this.remeasure = Object.keys(this.widths).length > 0;
  40989. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  40990. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  40991. var map = [];
  40992. for (charCode in GlyphMapForStandardFonts) {
  40993. map[+charCode] = GlyphMapForStandardFonts[charCode];
  40994. }
  40995. if (/ArialBlack/i.test(name)) {
  40996. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  40997. for (charCode in SupplementalGlyphMapForArialBlack) {
  40998. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  40999. }
  41000. }
  41001. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41002. if (!isIdentityUnicode) {
  41003. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41004. map[+charCode] = unicodeCharCode;
  41005. });
  41006. }
  41007. this.toFontChar = map;
  41008. this.toUnicode = new ToUnicodeMap(map);
  41009. } else if (/Symbol/i.test(fontName)) {
  41010. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41011. } else if (/Dingbats/i.test(fontName)) {
  41012. if (/Wingdings/i.test(name)) {
  41013. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41014. }
  41015. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41016. } else if (isStandardFont) {
  41017. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41018. } else {
  41019. glyphsUnicodeMap = getGlyphsUnicode();
  41020. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41021. if (!this.composite) {
  41022. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41023. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41024. if (unicode !== -1) {
  41025. unicodeCharCode = unicode;
  41026. }
  41027. }
  41028. this.toFontChar[charCode] = unicodeCharCode;
  41029. }.bind(this));
  41030. }
  41031. this.loadedName = fontName.split('-')[0];
  41032. this.loading = false;
  41033. this.fontType = getFontType(type, subtype);
  41034. return;
  41035. }
  41036. if (subtype === 'Type1C') {
  41037. if (type !== 'Type1' && type !== 'MMType1') {
  41038. if (isTrueTypeFile(file)) {
  41039. subtype = 'TrueType';
  41040. } else {
  41041. type = 'Type1';
  41042. }
  41043. } else if (isOpenTypeFile(file)) {
  41044. type = subtype = 'OpenType';
  41045. }
  41046. }
  41047. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41048. type = 'CIDFontType0';
  41049. }
  41050. if (subtype === 'OpenType') {
  41051. type = 'OpenType';
  41052. }
  41053. if (type === 'CIDFontType0') {
  41054. if (isType1File(file)) {
  41055. subtype = 'CIDFontType0';
  41056. } else if (isOpenTypeFile(file)) {
  41057. type = subtype = 'OpenType';
  41058. } else {
  41059. subtype = 'CIDFontType0C';
  41060. }
  41061. }
  41062. var data;
  41063. switch (type) {
  41064. case 'MMType1':
  41065. info('MMType1 font (' + name + '), falling back to Type1.');
  41066. case 'Type1':
  41067. case 'CIDFontType0':
  41068. this.mimetype = 'font/opentype';
  41069. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41070. adjustWidths(properties);
  41071. data = this.convert(name, cff, properties);
  41072. break;
  41073. case 'OpenType':
  41074. case 'TrueType':
  41075. case 'CIDFontType2':
  41076. this.mimetype = 'font/opentype';
  41077. data = this.checkAndRepair(name, file, properties);
  41078. if (this.isOpenType) {
  41079. adjustWidths(properties);
  41080. type = 'OpenType';
  41081. }
  41082. break;
  41083. default:
  41084. error('Font ' + type + ' is not supported');
  41085. break;
  41086. }
  41087. this.data = data;
  41088. this.fontType = getFontType(type, subtype);
  41089. this.fontMatrix = properties.fontMatrix;
  41090. this.widths = properties.widths;
  41091. this.defaultWidth = properties.defaultWidth;
  41092. this.toUnicode = properties.toUnicode;
  41093. this.encoding = properties.baseEncoding;
  41094. this.seacMap = properties.seacMap;
  41095. this.loading = true;
  41096. }
  41097. Font.getFontID = function () {
  41098. var ID = 1;
  41099. return function Font_getFontID() {
  41100. return String(ID++);
  41101. };
  41102. }();
  41103. function int16(b0, b1) {
  41104. return (b0 << 8) + b1;
  41105. }
  41106. function signedInt16(b0, b1) {
  41107. var value = (b0 << 8) + b1;
  41108. return value & 1 << 15 ? value - 0x10000 : value;
  41109. }
  41110. function int32(b0, b1, b2, b3) {
  41111. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41112. }
  41113. function string16(value) {
  41114. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41115. }
  41116. function safeString16(value) {
  41117. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41118. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41119. }
  41120. function isTrueTypeFile(file) {
  41121. var header = file.peekBytes(4);
  41122. return readUint32(header, 0) === 0x00010000;
  41123. }
  41124. function isOpenTypeFile(file) {
  41125. var header = file.peekBytes(4);
  41126. return bytesToString(header) === 'OTTO';
  41127. }
  41128. function isType1File(file) {
  41129. var header = file.peekBytes(2);
  41130. if (header[0] === 0x25 && header[1] === 0x21) {
  41131. return true;
  41132. }
  41133. if (header[0] === 0x80 && header[1] === 0x01) {
  41134. return true;
  41135. }
  41136. return false;
  41137. }
  41138. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41139. var toFontChar = [], unicode;
  41140. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41141. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41142. if (unicode !== -1) {
  41143. toFontChar[i] = unicode;
  41144. }
  41145. }
  41146. for (var charCode in differences) {
  41147. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41148. if (unicode !== -1) {
  41149. toFontChar[+charCode] = unicode;
  41150. }
  41151. }
  41152. return toFontChar;
  41153. }
  41154. function isProblematicUnicodeLocation(code) {
  41155. var i = 0, j = ProblematicCharRanges.length - 1;
  41156. while (i < j) {
  41157. var c = i + j + 1 >> 1;
  41158. if (code < ProblematicCharRanges[c]) {
  41159. j = c - 1;
  41160. } else {
  41161. i = c;
  41162. }
  41163. }
  41164. return !(i & 1);
  41165. }
  41166. function adjustMapping(charCodeToGlyphId, properties) {
  41167. var toUnicode = properties.toUnicode;
  41168. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41169. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41170. var newMap = Object.create(null);
  41171. var toFontChar = [];
  41172. var usedFontCharCodes = [];
  41173. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41174. for (var originalCharCode in charCodeToGlyphId) {
  41175. originalCharCode |= 0;
  41176. var glyphId = charCodeToGlyphId[originalCharCode];
  41177. var fontCharCode = originalCharCode;
  41178. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41179. var unicode = toUnicode.get(fontCharCode);
  41180. if (unicode.length === 1) {
  41181. fontCharCode = unicode.charCodeAt(0);
  41182. }
  41183. }
  41184. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && isIdentityUnicode) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41185. do {
  41186. fontCharCode = nextAvailableFontCharCode++;
  41187. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41188. fontCharCode = 0xF020;
  41189. nextAvailableFontCharCode = fontCharCode + 1;
  41190. }
  41191. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41192. }
  41193. newMap[fontCharCode] = glyphId;
  41194. toFontChar[originalCharCode] = fontCharCode;
  41195. usedFontCharCodes[fontCharCode] = true;
  41196. }
  41197. return {
  41198. toFontChar: toFontChar,
  41199. charCodeToGlyphId: newMap,
  41200. nextAvailableFontCharCode: nextAvailableFontCharCode
  41201. };
  41202. }
  41203. function getRanges(glyphs, numGlyphs) {
  41204. var codes = [];
  41205. for (var charCode in glyphs) {
  41206. if (glyphs[charCode] >= numGlyphs) {
  41207. continue;
  41208. }
  41209. codes.push({
  41210. fontCharCode: charCode | 0,
  41211. glyphId: glyphs[charCode]
  41212. });
  41213. }
  41214. codes.sort(function fontGetRangesSort(a, b) {
  41215. return a.fontCharCode - b.fontCharCode;
  41216. });
  41217. var ranges = [];
  41218. var length = codes.length;
  41219. for (var n = 0; n < length;) {
  41220. var start = codes[n].fontCharCode;
  41221. var codeIndices = [codes[n].glyphId];
  41222. ++n;
  41223. var end = start;
  41224. while (n < length && end + 1 === codes[n].fontCharCode) {
  41225. codeIndices.push(codes[n].glyphId);
  41226. ++end;
  41227. ++n;
  41228. if (end === 0xFFFF) {
  41229. break;
  41230. }
  41231. }
  41232. ranges.push([
  41233. start,
  41234. end,
  41235. codeIndices
  41236. ]);
  41237. }
  41238. return ranges;
  41239. }
  41240. function createCmapTable(glyphs, numGlyphs) {
  41241. var ranges = getRanges(glyphs, numGlyphs);
  41242. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41243. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41244. var i, ii, j, jj;
  41245. for (i = ranges.length - 1; i >= 0; --i) {
  41246. if (ranges[i][0] <= 0xFFFF) {
  41247. break;
  41248. }
  41249. }
  41250. var bmpLength = i + 1;
  41251. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41252. ranges[i][1] = 0xFFFE;
  41253. }
  41254. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41255. var segCount = bmpLength + trailingRangesCount;
  41256. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41257. var startCount = '';
  41258. var endCount = '';
  41259. var idDeltas = '';
  41260. var idRangeOffsets = '';
  41261. var glyphsIds = '';
  41262. var bias = 0;
  41263. var range, start, end, codes;
  41264. for (i = 0, ii = bmpLength; i < ii; i++) {
  41265. range = ranges[i];
  41266. start = range[0];
  41267. end = range[1];
  41268. startCount += string16(start);
  41269. endCount += string16(end);
  41270. codes = range[2];
  41271. var contiguous = true;
  41272. for (j = 1, jj = codes.length; j < jj; ++j) {
  41273. if (codes[j] !== codes[j - 1] + 1) {
  41274. contiguous = false;
  41275. break;
  41276. }
  41277. }
  41278. if (!contiguous) {
  41279. var offset = (segCount - i) * 2 + bias * 2;
  41280. bias += end - start + 1;
  41281. idDeltas += string16(0);
  41282. idRangeOffsets += string16(offset);
  41283. for (j = 0, jj = codes.length; j < jj; ++j) {
  41284. glyphsIds += string16(codes[j]);
  41285. }
  41286. } else {
  41287. var startCode = codes[0];
  41288. idDeltas += string16(startCode - start & 0xFFFF);
  41289. idRangeOffsets += string16(0);
  41290. }
  41291. }
  41292. if (trailingRangesCount > 0) {
  41293. endCount += '\xFF\xFF';
  41294. startCount += '\xFF\xFF';
  41295. idDeltas += '\x00\x01';
  41296. idRangeOffsets += '\x00\x00';
  41297. }
  41298. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41299. var format31012 = '';
  41300. var header31012 = '';
  41301. if (numTables > 1) {
  41302. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41303. format31012 = '';
  41304. for (i = 0, ii = ranges.length; i < ii; i++) {
  41305. range = ranges[i];
  41306. start = range[0];
  41307. codes = range[2];
  41308. var code = codes[0];
  41309. for (j = 1, jj = codes.length; j < jj; ++j) {
  41310. if (codes[j] !== codes[j - 1] + 1) {
  41311. end = range[0] + j - 1;
  41312. format31012 += string32(start) + string32(end) + string32(code);
  41313. start = end + 1;
  41314. code = codes[j];
  41315. }
  41316. }
  41317. format31012 += string32(start) + string32(range[1]) + string32(code);
  41318. }
  41319. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41320. }
  41321. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41322. }
  41323. function validateOS2Table(os2) {
  41324. var stream = new Stream(os2.data);
  41325. var version = stream.getUint16();
  41326. stream.getBytes(60);
  41327. var selection = stream.getUint16();
  41328. if (version < 4 && selection & 0x0300) {
  41329. return false;
  41330. }
  41331. var firstChar = stream.getUint16();
  41332. var lastChar = stream.getUint16();
  41333. if (firstChar > lastChar) {
  41334. return false;
  41335. }
  41336. stream.getBytes(6);
  41337. var usWinAscent = stream.getUint16();
  41338. if (usWinAscent === 0) {
  41339. return false;
  41340. }
  41341. os2.data[8] = os2.data[9] = 0;
  41342. return true;
  41343. }
  41344. function createOS2Table(properties, charstrings, override) {
  41345. override = override || {
  41346. unitsPerEm: 0,
  41347. yMax: 0,
  41348. yMin: 0,
  41349. ascent: 0,
  41350. descent: 0
  41351. };
  41352. var ulUnicodeRange1 = 0;
  41353. var ulUnicodeRange2 = 0;
  41354. var ulUnicodeRange3 = 0;
  41355. var ulUnicodeRange4 = 0;
  41356. var firstCharIndex = null;
  41357. var lastCharIndex = 0;
  41358. if (charstrings) {
  41359. for (var code in charstrings) {
  41360. code |= 0;
  41361. if (firstCharIndex > code || !firstCharIndex) {
  41362. firstCharIndex = code;
  41363. }
  41364. if (lastCharIndex < code) {
  41365. lastCharIndex = code;
  41366. }
  41367. var position = getUnicodeRangeFor(code);
  41368. if (position < 32) {
  41369. ulUnicodeRange1 |= 1 << position;
  41370. } else if (position < 64) {
  41371. ulUnicodeRange2 |= 1 << position - 32;
  41372. } else if (position < 96) {
  41373. ulUnicodeRange3 |= 1 << position - 64;
  41374. } else if (position < 123) {
  41375. ulUnicodeRange4 |= 1 << position - 96;
  41376. } else {
  41377. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41378. }
  41379. }
  41380. } else {
  41381. firstCharIndex = 0;
  41382. lastCharIndex = 255;
  41383. }
  41384. var bbox = properties.bbox || [
  41385. 0,
  41386. 0,
  41387. 0,
  41388. 0
  41389. ];
  41390. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41391. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41392. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41393. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41394. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41395. typoDescent = -typoDescent;
  41396. }
  41397. var winAscent = override.yMax || typoAscent;
  41398. var winDescent = -override.yMin || -typoDescent;
  41399. 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';
  41400. }
  41401. function createPostTable(properties) {
  41402. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41403. 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';
  41404. }
  41405. function createNameTable(name, proto) {
  41406. if (!proto) {
  41407. proto = [
  41408. [],
  41409. []
  41410. ];
  41411. }
  41412. var strings = [
  41413. proto[0][0] || 'Original licence',
  41414. proto[0][1] || name,
  41415. proto[0][2] || 'Unknown',
  41416. proto[0][3] || 'uniqueID',
  41417. proto[0][4] || name,
  41418. proto[0][5] || 'Version 0.11',
  41419. proto[0][6] || '',
  41420. proto[0][7] || 'Unknown',
  41421. proto[0][8] || 'Unknown',
  41422. proto[0][9] || 'Unknown'
  41423. ];
  41424. var stringsUnicode = [];
  41425. var i, ii, j, jj, str;
  41426. for (i = 0, ii = strings.length; i < ii; i++) {
  41427. str = proto[1][i] || strings[i];
  41428. var strBufUnicode = [];
  41429. for (j = 0, jj = str.length; j < jj; j++) {
  41430. strBufUnicode.push(string16(str.charCodeAt(j)));
  41431. }
  41432. stringsUnicode.push(strBufUnicode.join(''));
  41433. }
  41434. var names = [
  41435. strings,
  41436. stringsUnicode
  41437. ];
  41438. var platforms = [
  41439. '\x00\x01',
  41440. '\x00\x03'
  41441. ];
  41442. var encodings = [
  41443. '\x00\x00',
  41444. '\x00\x01'
  41445. ];
  41446. var languages = [
  41447. '\x00\x00',
  41448. '\x04\x09'
  41449. ];
  41450. var namesRecordCount = strings.length * platforms.length;
  41451. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41452. var strOffset = 0;
  41453. for (i = 0, ii = platforms.length; i < ii; i++) {
  41454. var strs = names[i];
  41455. for (j = 0, jj = strs.length; j < jj; j++) {
  41456. str = strs[j];
  41457. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41458. nameTable += nameRecord;
  41459. strOffset += str.length;
  41460. }
  41461. }
  41462. nameTable += strings.join('') + stringsUnicode.join('');
  41463. return nameTable;
  41464. }
  41465. Font.prototype = {
  41466. name: null,
  41467. font: null,
  41468. mimetype: null,
  41469. encoding: null,
  41470. get renderer() {
  41471. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41472. return shadow(this, 'renderer', renderer);
  41473. },
  41474. exportData: function Font_exportData() {
  41475. var data = {};
  41476. for (var i in this) {
  41477. if (this.hasOwnProperty(i)) {
  41478. data[i] = this[i];
  41479. }
  41480. }
  41481. return data;
  41482. },
  41483. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41484. function readTableEntry(file) {
  41485. var tag = bytesToString(file.getBytes(4));
  41486. var checksum = file.getInt32() >>> 0;
  41487. var offset = file.getInt32() >>> 0;
  41488. var length = file.getInt32() >>> 0;
  41489. var previousPosition = file.pos;
  41490. file.pos = file.start ? file.start : 0;
  41491. file.skip(offset);
  41492. var data = file.getBytes(length);
  41493. file.pos = previousPosition;
  41494. if (tag === 'head') {
  41495. data[8] = data[9] = data[10] = data[11] = 0;
  41496. data[17] |= 0x20;
  41497. }
  41498. return {
  41499. tag: tag,
  41500. checksum: checksum,
  41501. length: length,
  41502. offset: offset,
  41503. data: data
  41504. };
  41505. }
  41506. function readOpenTypeHeader(ttf) {
  41507. return {
  41508. version: bytesToString(ttf.getBytes(4)),
  41509. numTables: ttf.getUint16(),
  41510. searchRange: ttf.getUint16(),
  41511. entrySelector: ttf.getUint16(),
  41512. rangeShift: ttf.getUint16()
  41513. };
  41514. }
  41515. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41516. if (!cmap) {
  41517. warn('No cmap table available.');
  41518. return {
  41519. platformId: -1,
  41520. encodingId: -1,
  41521. mappings: [],
  41522. hasShortCmap: false
  41523. };
  41524. }
  41525. var segment;
  41526. var start = (font.start ? font.start : 0) + cmap.offset;
  41527. font.pos = start;
  41528. var version = font.getUint16();
  41529. var numTables = font.getUint16();
  41530. var potentialTable;
  41531. var canBreak = false;
  41532. for (var i = 0; i < numTables; i++) {
  41533. var platformId = font.getUint16();
  41534. var encodingId = font.getUint16();
  41535. var offset = font.getInt32() >>> 0;
  41536. var useTable = false;
  41537. if (platformId === 0 && encodingId === 0) {
  41538. useTable = true;
  41539. } else if (platformId === 1 && encodingId === 0) {
  41540. useTable = true;
  41541. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41542. useTable = true;
  41543. if (!isSymbolicFont) {
  41544. canBreak = true;
  41545. }
  41546. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41547. useTable = true;
  41548. canBreak = true;
  41549. }
  41550. if (useTable) {
  41551. potentialTable = {
  41552. platformId: platformId,
  41553. encodingId: encodingId,
  41554. offset: offset
  41555. };
  41556. }
  41557. if (canBreak) {
  41558. break;
  41559. }
  41560. }
  41561. if (potentialTable) {
  41562. font.pos = start + potentialTable.offset;
  41563. }
  41564. if (!potentialTable || font.peekByte() === -1) {
  41565. warn('Could not find a preferred cmap table.');
  41566. return {
  41567. platformId: -1,
  41568. encodingId: -1,
  41569. mappings: [],
  41570. hasShortCmap: false
  41571. };
  41572. }
  41573. var format = font.getUint16();
  41574. var length = font.getUint16();
  41575. var language = font.getUint16();
  41576. var hasShortCmap = false;
  41577. var mappings = [];
  41578. var j, glyphId;
  41579. if (format === 0) {
  41580. for (j = 0; j < 256; j++) {
  41581. var index = font.getByte();
  41582. if (!index) {
  41583. continue;
  41584. }
  41585. mappings.push({
  41586. charCode: j,
  41587. glyphId: index
  41588. });
  41589. }
  41590. hasShortCmap = true;
  41591. } else if (format === 4) {
  41592. var segCount = font.getUint16() >> 1;
  41593. font.getBytes(6);
  41594. var segIndex, segments = [];
  41595. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41596. segments.push({ end: font.getUint16() });
  41597. }
  41598. font.getUint16();
  41599. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41600. segments[segIndex].start = font.getUint16();
  41601. }
  41602. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41603. segments[segIndex].delta = font.getUint16();
  41604. }
  41605. var offsetsCount = 0;
  41606. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41607. segment = segments[segIndex];
  41608. var rangeOffset = font.getUint16();
  41609. if (!rangeOffset) {
  41610. segment.offsetIndex = -1;
  41611. continue;
  41612. }
  41613. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41614. segment.offsetIndex = offsetIndex;
  41615. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41616. }
  41617. var offsets = [];
  41618. for (j = 0; j < offsetsCount; j++) {
  41619. offsets.push(font.getUint16());
  41620. }
  41621. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41622. segment = segments[segIndex];
  41623. start = segment.start;
  41624. var end = segment.end;
  41625. var delta = segment.delta;
  41626. offsetIndex = segment.offsetIndex;
  41627. for (j = start; j <= end; j++) {
  41628. if (j === 0xFFFF) {
  41629. continue;
  41630. }
  41631. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41632. glyphId = glyphId + delta & 0xFFFF;
  41633. if (glyphId === 0) {
  41634. continue;
  41635. }
  41636. mappings.push({
  41637. charCode: j,
  41638. glyphId: glyphId
  41639. });
  41640. }
  41641. }
  41642. } else if (format === 6) {
  41643. var firstCode = font.getUint16();
  41644. var entryCount = font.getUint16();
  41645. for (j = 0; j < entryCount; j++) {
  41646. glyphId = font.getUint16();
  41647. var charCode = firstCode + j;
  41648. mappings.push({
  41649. charCode: charCode,
  41650. glyphId: glyphId
  41651. });
  41652. }
  41653. } else {
  41654. warn('cmap table has unsupported format: ' + format);
  41655. return {
  41656. platformId: -1,
  41657. encodingId: -1,
  41658. mappings: [],
  41659. hasShortCmap: false
  41660. };
  41661. }
  41662. mappings.sort(function (a, b) {
  41663. return a.charCode - b.charCode;
  41664. });
  41665. for (i = 1; i < mappings.length; i++) {
  41666. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41667. mappings.splice(i, 1);
  41668. i--;
  41669. }
  41670. }
  41671. return {
  41672. platformId: potentialTable.platformId,
  41673. encodingId: potentialTable.encodingId,
  41674. mappings: mappings,
  41675. hasShortCmap: hasShortCmap
  41676. };
  41677. }
  41678. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41679. if (!header) {
  41680. if (metrics) {
  41681. metrics.data = null;
  41682. }
  41683. return;
  41684. }
  41685. font.pos = (font.start ? font.start : 0) + header.offset;
  41686. font.pos += header.length - 2;
  41687. var numOfMetrics = font.getUint16();
  41688. if (numOfMetrics > numGlyphs) {
  41689. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41690. numOfMetrics = numGlyphs;
  41691. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41692. header.data[35] = numOfMetrics & 0x00ff;
  41693. }
  41694. var numOfSidebearings = numGlyphs - numOfMetrics;
  41695. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41696. if (numMissing > 0) {
  41697. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41698. entries.set(metrics.data);
  41699. metrics.data = entries;
  41700. }
  41701. }
  41702. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41703. if (sourceEnd - sourceStart <= 12) {
  41704. return 0;
  41705. }
  41706. var glyf = source.subarray(sourceStart, sourceEnd);
  41707. var contoursCount = glyf[0] << 8 | glyf[1];
  41708. if (contoursCount & 0x8000) {
  41709. dest.set(glyf, destStart);
  41710. return glyf.length;
  41711. }
  41712. var i, j = 10, flagsCount = 0;
  41713. for (i = 0; i < contoursCount; i++) {
  41714. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41715. flagsCount = endPoint + 1;
  41716. j += 2;
  41717. }
  41718. var instructionsStart = j;
  41719. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41720. j += 2 + instructionsLength;
  41721. var instructionsEnd = j;
  41722. var coordinatesLength = 0;
  41723. for (i = 0; i < flagsCount; i++) {
  41724. var flag = glyf[j++];
  41725. if (flag & 0xC0) {
  41726. glyf[j - 1] = flag & 0x3F;
  41727. }
  41728. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41729. coordinatesLength += xyLength;
  41730. if (flag & 8) {
  41731. var repeat = glyf[j++];
  41732. i += repeat;
  41733. coordinatesLength += repeat * xyLength;
  41734. }
  41735. }
  41736. if (coordinatesLength === 0) {
  41737. return 0;
  41738. }
  41739. var glyphDataLength = j + coordinatesLength;
  41740. if (glyphDataLength > glyf.length) {
  41741. return 0;
  41742. }
  41743. if (!hintsValid && instructionsLength > 0) {
  41744. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41745. dest.set([
  41746. 0,
  41747. 0
  41748. ], destStart + instructionsStart);
  41749. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41750. glyphDataLength -= instructionsLength;
  41751. if (glyf.length - glyphDataLength > 3) {
  41752. glyphDataLength = glyphDataLength + 3 & ~3;
  41753. }
  41754. return glyphDataLength;
  41755. }
  41756. if (glyf.length - glyphDataLength > 3) {
  41757. glyphDataLength = glyphDataLength + 3 & ~3;
  41758. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41759. return glyphDataLength;
  41760. }
  41761. dest.set(glyf, destStart);
  41762. return glyf.length;
  41763. }
  41764. function sanitizeHead(head, numGlyphs, locaLength) {
  41765. var data = head.data;
  41766. var version = int32(data[0], data[1], data[2], data[3]);
  41767. if (version >> 16 !== 1) {
  41768. info('Attempting to fix invalid version in head table: ' + version);
  41769. data[0] = 0;
  41770. data[1] = 1;
  41771. data[2] = 0;
  41772. data[3] = 0;
  41773. }
  41774. var indexToLocFormat = int16(data[50], data[51]);
  41775. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41776. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41777. var numGlyphsPlusOne = numGlyphs + 1;
  41778. if (locaLength === numGlyphsPlusOne << 1) {
  41779. data[50] = 0;
  41780. data[51] = 0;
  41781. } else if (locaLength === numGlyphsPlusOne << 2) {
  41782. data[50] = 0;
  41783. data[51] = 1;
  41784. } else {
  41785. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41786. }
  41787. }
  41788. }
  41789. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41790. var itemSize, itemDecode, itemEncode;
  41791. if (isGlyphLocationsLong) {
  41792. itemSize = 4;
  41793. itemDecode = function fontItemDecodeLong(data, offset) {
  41794. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41795. };
  41796. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41797. data[offset] = value >>> 24 & 0xFF;
  41798. data[offset + 1] = value >> 16 & 0xFF;
  41799. data[offset + 2] = value >> 8 & 0xFF;
  41800. data[offset + 3] = value & 0xFF;
  41801. };
  41802. } else {
  41803. itemSize = 2;
  41804. itemDecode = function fontItemDecode(data, offset) {
  41805. return data[offset] << 9 | data[offset + 1] << 1;
  41806. };
  41807. itemEncode = function fontItemEncode(data, offset, value) {
  41808. data[offset] = value >> 9 & 0xFF;
  41809. data[offset + 1] = value >> 1 & 0xFF;
  41810. };
  41811. }
  41812. var locaData = loca.data;
  41813. var locaDataSize = itemSize * (1 + numGlyphs);
  41814. if (locaData.length !== locaDataSize) {
  41815. locaData = new Uint8Array(locaDataSize);
  41816. locaData.set(loca.data.subarray(0, locaDataSize));
  41817. loca.data = locaData;
  41818. }
  41819. var oldGlyfData = glyf.data;
  41820. var oldGlyfDataLength = oldGlyfData.length;
  41821. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41822. var startOffset = itemDecode(locaData, 0);
  41823. var writeOffset = 0;
  41824. var missingGlyphData = Object.create(null);
  41825. itemEncode(locaData, 0, writeOffset);
  41826. var i, j;
  41827. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41828. var endOffset = itemDecode(locaData, j);
  41829. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  41830. endOffset = oldGlyfDataLength;
  41831. }
  41832. if (endOffset > oldGlyfDataLength) {
  41833. itemEncode(locaData, j, writeOffset);
  41834. startOffset = endOffset;
  41835. continue;
  41836. }
  41837. if (startOffset === endOffset) {
  41838. missingGlyphData[i] = true;
  41839. }
  41840. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  41841. writeOffset += newLength;
  41842. itemEncode(locaData, j, writeOffset);
  41843. startOffset = endOffset;
  41844. }
  41845. if (writeOffset === 0) {
  41846. var simpleGlyph = new Uint8Array([
  41847. 0,
  41848. 1,
  41849. 0,
  41850. 0,
  41851. 0,
  41852. 0,
  41853. 0,
  41854. 0,
  41855. 0,
  41856. 0,
  41857. 0,
  41858. 0,
  41859. 0,
  41860. 0,
  41861. 49,
  41862. 0
  41863. ]);
  41864. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41865. itemEncode(locaData, j, simpleGlyph.length);
  41866. }
  41867. glyf.data = simpleGlyph;
  41868. return missingGlyphData;
  41869. }
  41870. if (dupFirstEntry) {
  41871. var firstEntryLength = itemDecode(locaData, itemSize);
  41872. if (newGlyfData.length > firstEntryLength + writeOffset) {
  41873. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  41874. } else {
  41875. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  41876. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  41877. }
  41878. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  41879. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  41880. } else {
  41881. glyf.data = newGlyfData.subarray(0, writeOffset);
  41882. }
  41883. return missingGlyphData;
  41884. }
  41885. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  41886. var start = (font.start ? font.start : 0) + post.offset;
  41887. font.pos = start;
  41888. var length = post.length, end = start + length;
  41889. var version = font.getInt32();
  41890. font.getBytes(28);
  41891. var glyphNames;
  41892. var valid = true;
  41893. var i;
  41894. switch (version) {
  41895. case 0x00010000:
  41896. glyphNames = MacStandardGlyphOrdering;
  41897. break;
  41898. case 0x00020000:
  41899. var numGlyphs = font.getUint16();
  41900. if (numGlyphs !== maxpNumGlyphs) {
  41901. valid = false;
  41902. break;
  41903. }
  41904. var glyphNameIndexes = [];
  41905. for (i = 0; i < numGlyphs; ++i) {
  41906. var index = font.getUint16();
  41907. if (index >= 32768) {
  41908. valid = false;
  41909. break;
  41910. }
  41911. glyphNameIndexes.push(index);
  41912. }
  41913. if (!valid) {
  41914. break;
  41915. }
  41916. var customNames = [];
  41917. var strBuf = [];
  41918. while (font.pos < end) {
  41919. var stringLength = font.getByte();
  41920. strBuf.length = stringLength;
  41921. for (i = 0; i < stringLength; ++i) {
  41922. strBuf[i] = String.fromCharCode(font.getByte());
  41923. }
  41924. customNames.push(strBuf.join(''));
  41925. }
  41926. glyphNames = [];
  41927. for (i = 0; i < numGlyphs; ++i) {
  41928. var j = glyphNameIndexes[i];
  41929. if (j < 258) {
  41930. glyphNames.push(MacStandardGlyphOrdering[j]);
  41931. continue;
  41932. }
  41933. glyphNames.push(customNames[j - 258]);
  41934. }
  41935. break;
  41936. case 0x00030000:
  41937. break;
  41938. default:
  41939. warn('Unknown/unsupported post table version ' + version);
  41940. valid = false;
  41941. if (properties.defaultEncoding) {
  41942. glyphNames = properties.defaultEncoding;
  41943. }
  41944. break;
  41945. }
  41946. properties.glyphNames = glyphNames;
  41947. return valid;
  41948. }
  41949. function readNameTable(nameTable) {
  41950. var start = (font.start ? font.start : 0) + nameTable.offset;
  41951. font.pos = start;
  41952. var names = [
  41953. [],
  41954. []
  41955. ];
  41956. var length = nameTable.length, end = start + length;
  41957. var format = font.getUint16();
  41958. var FORMAT_0_HEADER_LENGTH = 6;
  41959. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  41960. return names;
  41961. }
  41962. var numRecords = font.getUint16();
  41963. var stringsStart = font.getUint16();
  41964. var records = [];
  41965. var NAME_RECORD_LENGTH = 12;
  41966. var i, ii;
  41967. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  41968. var r = {
  41969. platform: font.getUint16(),
  41970. encoding: font.getUint16(),
  41971. language: font.getUint16(),
  41972. name: font.getUint16(),
  41973. length: font.getUint16(),
  41974. offset: font.getUint16()
  41975. };
  41976. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  41977. records.push(r);
  41978. }
  41979. }
  41980. for (i = 0, ii = records.length; i < ii; i++) {
  41981. var record = records[i];
  41982. if (record.length <= 0) {
  41983. continue;
  41984. }
  41985. var pos = start + stringsStart + record.offset;
  41986. if (pos + record.length > end) {
  41987. continue;
  41988. }
  41989. font.pos = pos;
  41990. var nameIndex = record.name;
  41991. if (record.encoding) {
  41992. var str = '';
  41993. for (var j = 0, jj = record.length; j < jj; j += 2) {
  41994. str += String.fromCharCode(font.getUint16());
  41995. }
  41996. names[1][nameIndex] = str;
  41997. } else {
  41998. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  41999. }
  42000. }
  42001. return names;
  42002. }
  42003. var TTOpsStackDeltas = [
  42004. 0,
  42005. 0,
  42006. 0,
  42007. 0,
  42008. 0,
  42009. 0,
  42010. 0,
  42011. 0,
  42012. -2,
  42013. -2,
  42014. -2,
  42015. -2,
  42016. 0,
  42017. 0,
  42018. -2,
  42019. -5,
  42020. -1,
  42021. -1,
  42022. -1,
  42023. -1,
  42024. -1,
  42025. -1,
  42026. -1,
  42027. -1,
  42028. 0,
  42029. 0,
  42030. -1,
  42031. 0,
  42032. -1,
  42033. -1,
  42034. -1,
  42035. -1,
  42036. 1,
  42037. -1,
  42038. -999,
  42039. 0,
  42040. 1,
  42041. 0,
  42042. -1,
  42043. -2,
  42044. 0,
  42045. -1,
  42046. -2,
  42047. -1,
  42048. -1,
  42049. 0,
  42050. -1,
  42051. -1,
  42052. 0,
  42053. 0,
  42054. -999,
  42055. -999,
  42056. -1,
  42057. -1,
  42058. -1,
  42059. -1,
  42060. -2,
  42061. -999,
  42062. -2,
  42063. -2,
  42064. -999,
  42065. 0,
  42066. -2,
  42067. -2,
  42068. 0,
  42069. 0,
  42070. -2,
  42071. 0,
  42072. -2,
  42073. 0,
  42074. 0,
  42075. 0,
  42076. -2,
  42077. -1,
  42078. -1,
  42079. 1,
  42080. 1,
  42081. 0,
  42082. 0,
  42083. -1,
  42084. -1,
  42085. -1,
  42086. -1,
  42087. -1,
  42088. -1,
  42089. -1,
  42090. 0,
  42091. 0,
  42092. -1,
  42093. 0,
  42094. -1,
  42095. -1,
  42096. 0,
  42097. -999,
  42098. -1,
  42099. -1,
  42100. -1,
  42101. -1,
  42102. -1,
  42103. -1,
  42104. 0,
  42105. 0,
  42106. 0,
  42107. 0,
  42108. 0,
  42109. 0,
  42110. 0,
  42111. 0,
  42112. 0,
  42113. 0,
  42114. 0,
  42115. 0,
  42116. -2,
  42117. -999,
  42118. -999,
  42119. -999,
  42120. -999,
  42121. -999,
  42122. -1,
  42123. -1,
  42124. -2,
  42125. -2,
  42126. 0,
  42127. 0,
  42128. 0,
  42129. 0,
  42130. -1,
  42131. -1,
  42132. -999,
  42133. -2,
  42134. -2,
  42135. 0,
  42136. 0,
  42137. -1,
  42138. -2,
  42139. -2,
  42140. 0,
  42141. 0,
  42142. 0,
  42143. -1,
  42144. -1,
  42145. -1,
  42146. -2
  42147. ];
  42148. function sanitizeTTProgram(table, ttContext) {
  42149. var data = table.data;
  42150. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42151. var stack = [];
  42152. var callstack = [];
  42153. var functionsCalled = [];
  42154. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42155. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42156. for (var ii = data.length; i < ii;) {
  42157. var op = data[i++];
  42158. if (op === 0x40) {
  42159. n = data[i++];
  42160. if (inFDEF || inELSE) {
  42161. i += n;
  42162. } else {
  42163. for (j = 0; j < n; j++) {
  42164. stack.push(data[i++]);
  42165. }
  42166. }
  42167. } else if (op === 0x41) {
  42168. n = data[i++];
  42169. if (inFDEF || inELSE) {
  42170. i += n * 2;
  42171. } else {
  42172. for (j = 0; j < n; j++) {
  42173. b = data[i++];
  42174. stack.push(b << 8 | data[i++]);
  42175. }
  42176. }
  42177. } else if ((op & 0xF8) === 0xB0) {
  42178. n = op - 0xB0 + 1;
  42179. if (inFDEF || inELSE) {
  42180. i += n;
  42181. } else {
  42182. for (j = 0; j < n; j++) {
  42183. stack.push(data[i++]);
  42184. }
  42185. }
  42186. } else if ((op & 0xF8) === 0xB8) {
  42187. n = op - 0xB8 + 1;
  42188. if (inFDEF || inELSE) {
  42189. i += n * 2;
  42190. } else {
  42191. for (j = 0; j < n; j++) {
  42192. b = data[i++];
  42193. stack.push(b << 8 | data[i++]);
  42194. }
  42195. }
  42196. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42197. if (!inFDEF && !inELSE) {
  42198. funcId = stack[stack.length - 1];
  42199. ttContext.functionsUsed[funcId] = true;
  42200. if (funcId in ttContext.functionsStackDeltas) {
  42201. stack.length += ttContext.functionsStackDeltas[funcId];
  42202. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42203. callstack.push({
  42204. data: data,
  42205. i: i,
  42206. stackTop: stack.length - 1
  42207. });
  42208. functionsCalled.push(funcId);
  42209. pc = ttContext.functionsDefined[funcId];
  42210. if (!pc) {
  42211. warn('TT: CALL non-existent function');
  42212. ttContext.hintsValid = false;
  42213. return;
  42214. }
  42215. data = pc.data;
  42216. i = pc.i;
  42217. }
  42218. }
  42219. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42220. if (inFDEF || inELSE) {
  42221. warn('TT: nested FDEFs not allowed');
  42222. tooComplexToFollowFunctions = true;
  42223. }
  42224. inFDEF = true;
  42225. lastDeff = i;
  42226. funcId = stack.pop();
  42227. ttContext.functionsDefined[funcId] = {
  42228. data: data,
  42229. i: i
  42230. };
  42231. } else if (op === 0x2D) {
  42232. if (inFDEF) {
  42233. inFDEF = false;
  42234. lastEndf = i;
  42235. } else {
  42236. pc = callstack.pop();
  42237. if (!pc) {
  42238. warn('TT: ENDF bad stack');
  42239. ttContext.hintsValid = false;
  42240. return;
  42241. }
  42242. funcId = functionsCalled.pop();
  42243. data = pc.data;
  42244. i = pc.i;
  42245. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42246. }
  42247. } else if (op === 0x89) {
  42248. if (inFDEF || inELSE) {
  42249. warn('TT: nested IDEFs not allowed');
  42250. tooComplexToFollowFunctions = true;
  42251. }
  42252. inFDEF = true;
  42253. lastDeff = i;
  42254. } else if (op === 0x58) {
  42255. ++ifLevel;
  42256. } else if (op === 0x1B) {
  42257. inELSE = ifLevel;
  42258. } else if (op === 0x59) {
  42259. if (inELSE === ifLevel) {
  42260. inELSE = 0;
  42261. }
  42262. --ifLevel;
  42263. } else if (op === 0x1C) {
  42264. if (!inFDEF && !inELSE) {
  42265. var offset = stack[stack.length - 1];
  42266. if (offset > 0) {
  42267. i += offset - 1;
  42268. }
  42269. }
  42270. }
  42271. if (!inFDEF && !inELSE) {
  42272. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42273. if (op >= 0x71 && op <= 0x75) {
  42274. n = stack.pop();
  42275. if (n === n) {
  42276. stackDelta = -n * 2;
  42277. }
  42278. }
  42279. while (stackDelta < 0 && stack.length > 0) {
  42280. stack.pop();
  42281. stackDelta++;
  42282. }
  42283. while (stackDelta > 0) {
  42284. stack.push(NaN);
  42285. stackDelta--;
  42286. }
  42287. }
  42288. }
  42289. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42290. var content = [data];
  42291. if (i > data.length) {
  42292. content.push(new Uint8Array(i - data.length));
  42293. }
  42294. if (lastDeff > lastEndf) {
  42295. warn('TT: complementing a missing function tail');
  42296. content.push(new Uint8Array([
  42297. 0x22,
  42298. 0x2D
  42299. ]));
  42300. }
  42301. foldTTTable(table, content);
  42302. }
  42303. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42304. if (ttContext.tooComplexToFollowFunctions) {
  42305. return;
  42306. }
  42307. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42308. warn('TT: more functions defined than expected');
  42309. ttContext.hintsValid = false;
  42310. return;
  42311. }
  42312. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42313. if (j > maxFunctionDefs) {
  42314. warn('TT: invalid function id: ' + j);
  42315. ttContext.hintsValid = false;
  42316. return;
  42317. }
  42318. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42319. warn('TT: undefined function: ' + j);
  42320. ttContext.hintsValid = false;
  42321. return;
  42322. }
  42323. }
  42324. }
  42325. function foldTTTable(table, content) {
  42326. if (content.length > 1) {
  42327. var newLength = 0;
  42328. var j, jj;
  42329. for (j = 0, jj = content.length; j < jj; j++) {
  42330. newLength += content[j].length;
  42331. }
  42332. newLength = newLength + 3 & ~3;
  42333. var result = new Uint8Array(newLength);
  42334. var pos = 0;
  42335. for (j = 0, jj = content.length; j < jj; j++) {
  42336. result.set(content[j], pos);
  42337. pos += content[j].length;
  42338. }
  42339. table.data = result;
  42340. table.length = newLength;
  42341. }
  42342. }
  42343. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42344. var ttContext = {
  42345. functionsDefined: [],
  42346. functionsUsed: [],
  42347. functionsStackDeltas: [],
  42348. tooComplexToFollowFunctions: false,
  42349. hintsValid: true
  42350. };
  42351. if (fpgm) {
  42352. sanitizeTTProgram(fpgm, ttContext);
  42353. }
  42354. if (prep) {
  42355. sanitizeTTProgram(prep, ttContext);
  42356. }
  42357. if (fpgm) {
  42358. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42359. }
  42360. if (cvt && cvt.length & 1) {
  42361. var cvtData = new Uint8Array(cvt.length + 1);
  42362. cvtData.set(cvt.data);
  42363. cvt.data = cvtData;
  42364. }
  42365. return ttContext.hintsValid;
  42366. }
  42367. font = new Stream(new Uint8Array(font.getBytes()));
  42368. var VALID_TABLES = [
  42369. 'OS/2',
  42370. 'cmap',
  42371. 'head',
  42372. 'hhea',
  42373. 'hmtx',
  42374. 'maxp',
  42375. 'name',
  42376. 'post',
  42377. 'loca',
  42378. 'glyf',
  42379. 'fpgm',
  42380. 'prep',
  42381. 'cvt ',
  42382. 'CFF '
  42383. ];
  42384. var header = readOpenTypeHeader(font);
  42385. var numTables = header.numTables;
  42386. var cff, cffFile;
  42387. var tables = Object.create(null);
  42388. tables['OS/2'] = null;
  42389. tables['cmap'] = null;
  42390. tables['head'] = null;
  42391. tables['hhea'] = null;
  42392. tables['hmtx'] = null;
  42393. tables['maxp'] = null;
  42394. tables['name'] = null;
  42395. tables['post'] = null;
  42396. var table;
  42397. for (var i = 0; i < numTables; i++) {
  42398. table = readTableEntry(font);
  42399. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42400. continue;
  42401. }
  42402. if (table.length === 0) {
  42403. continue;
  42404. }
  42405. tables[table.tag] = table;
  42406. }
  42407. var isTrueType = !tables['CFF '];
  42408. if (!isTrueType) {
  42409. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42410. cffFile = new Stream(tables['CFF '].data);
  42411. cff = new CFFFont(cffFile, properties);
  42412. adjustWidths(properties);
  42413. return this.convert(name, cff, properties);
  42414. }
  42415. delete tables['glyf'];
  42416. delete tables['loca'];
  42417. delete tables['fpgm'];
  42418. delete tables['prep'];
  42419. delete tables['cvt '];
  42420. this.isOpenType = true;
  42421. } else {
  42422. if (!tables['loca']) {
  42423. error('Required "loca" table is not found');
  42424. }
  42425. if (!tables['glyf']) {
  42426. warn('Required "glyf" table is not found -- trying to recover.');
  42427. tables['glyf'] = {
  42428. tag: 'glyf',
  42429. data: new Uint8Array(0)
  42430. };
  42431. }
  42432. this.isOpenType = false;
  42433. }
  42434. if (!tables['maxp']) {
  42435. error('Required "maxp" table is not found');
  42436. }
  42437. font.pos = (font.start || 0) + tables['maxp'].offset;
  42438. var version = font.getInt32();
  42439. var numGlyphs = font.getUint16();
  42440. var maxFunctionDefs = 0;
  42441. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42442. font.pos += 8;
  42443. var maxZones = font.getUint16();
  42444. if (maxZones > 2) {
  42445. tables['maxp'].data[14] = 0;
  42446. tables['maxp'].data[15] = 2;
  42447. }
  42448. font.pos += 4;
  42449. maxFunctionDefs = font.getUint16();
  42450. }
  42451. var dupFirstEntry = false;
  42452. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42453. dupFirstEntry = true;
  42454. numGlyphs++;
  42455. tables['maxp'].data[4] = numGlyphs >> 8;
  42456. tables['maxp'].data[5] = numGlyphs & 255;
  42457. }
  42458. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42459. if (!hintsValid) {
  42460. delete tables['fpgm'];
  42461. delete tables['prep'];
  42462. delete tables['cvt '];
  42463. }
  42464. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42465. if (!tables['head']) {
  42466. error('Required "head" table is not found');
  42467. }
  42468. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42469. var missingGlyphs = Object.create(null);
  42470. if (isTrueType) {
  42471. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42472. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42473. }
  42474. if (!tables['hhea']) {
  42475. error('Required "hhea" table is not found');
  42476. }
  42477. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42478. tables['hhea'].data[10] = 0xFF;
  42479. tables['hhea'].data[11] = 0xFF;
  42480. }
  42481. var metricsOverride = {
  42482. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42483. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42484. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42485. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42486. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42487. };
  42488. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42489. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42490. if (tables['post']) {
  42491. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42492. if (!valid) {
  42493. tables['post'] = null;
  42494. }
  42495. }
  42496. var charCodeToGlyphId = [], charCode;
  42497. var toUnicode = properties.toUnicode, widths = properties.widths;
  42498. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42499. function hasGlyph(glyphId, charCode, widthCode) {
  42500. if (!missingGlyphs[glyphId]) {
  42501. return true;
  42502. }
  42503. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42504. return true;
  42505. }
  42506. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42507. return true;
  42508. }
  42509. return false;
  42510. }
  42511. if (properties.type === 'CIDFontType2') {
  42512. var cidToGidMap = properties.cidToGidMap || [];
  42513. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42514. properties.cMap.forEach(function (charCode, cid) {
  42515. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42516. var glyphId = -1;
  42517. if (isCidToGidMapEmpty) {
  42518. glyphId = cid;
  42519. } else if (cidToGidMap[cid] !== undefined) {
  42520. glyphId = cidToGidMap[cid];
  42521. }
  42522. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42523. charCodeToGlyphId[charCode] = glyphId;
  42524. }
  42525. });
  42526. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42527. charCodeToGlyphId[0] = numGlyphs - 1;
  42528. }
  42529. } else {
  42530. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42531. var cmapPlatformId = cmapTable.platformId;
  42532. var cmapEncodingId = cmapTable.encodingId;
  42533. var cmapMappings = cmapTable.mappings;
  42534. var cmapMappingsLength = cmapMappings.length;
  42535. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42536. var baseEncoding = [];
  42537. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42538. baseEncoding = getEncoding(properties.baseEncodingName);
  42539. }
  42540. var glyphsUnicodeMap = getGlyphsUnicode();
  42541. for (charCode = 0; charCode < 256; charCode++) {
  42542. var glyphName, standardGlyphName;
  42543. if (this.differences && charCode in this.differences) {
  42544. glyphName = this.differences[charCode];
  42545. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42546. glyphName = baseEncoding[charCode];
  42547. } else {
  42548. glyphName = StandardEncoding[charCode];
  42549. }
  42550. if (!glyphName) {
  42551. continue;
  42552. }
  42553. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42554. var unicodeOrCharCode, isUnicode = false;
  42555. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42556. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42557. isUnicode = true;
  42558. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42559. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42560. }
  42561. var found = false;
  42562. for (i = 0; i < cmapMappingsLength; ++i) {
  42563. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42564. continue;
  42565. }
  42566. var code = isUnicode ? charCode : unicodeOrCharCode;
  42567. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42568. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42569. found = true;
  42570. break;
  42571. }
  42572. }
  42573. if (!found && properties.glyphNames) {
  42574. var glyphId = properties.glyphNames.indexOf(glyphName);
  42575. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42576. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42577. }
  42578. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42579. charCodeToGlyphId[charCode] = glyphId;
  42580. found = true;
  42581. }
  42582. }
  42583. if (!found) {
  42584. charCodeToGlyphId[charCode] = 0;
  42585. }
  42586. }
  42587. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42588. for (i = 0; i < cmapMappingsLength; ++i) {
  42589. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42590. }
  42591. } else {
  42592. for (i = 0; i < cmapMappingsLength; ++i) {
  42593. charCode = cmapMappings[i].charCode & 0xFF;
  42594. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42595. }
  42596. }
  42597. }
  42598. if (charCodeToGlyphId.length === 0) {
  42599. charCodeToGlyphId[0] = 0;
  42600. }
  42601. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42602. this.toFontChar = newMapping.toFontChar;
  42603. tables['cmap'] = {
  42604. tag: 'cmap',
  42605. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42606. };
  42607. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42608. tables['OS/2'] = {
  42609. tag: 'OS/2',
  42610. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42611. };
  42612. }
  42613. if (!tables['post']) {
  42614. tables['post'] = {
  42615. tag: 'post',
  42616. data: createPostTable(properties)
  42617. };
  42618. }
  42619. if (!isTrueType) {
  42620. try {
  42621. cffFile = new Stream(tables['CFF '].data);
  42622. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42623. cff = parser.parse();
  42624. var compiler = new CFFCompiler(cff);
  42625. tables['CFF '].data = compiler.compile();
  42626. } catch (e) {
  42627. warn('Failed to compile font ' + properties.loadedName);
  42628. }
  42629. }
  42630. if (!tables['name']) {
  42631. tables['name'] = {
  42632. tag: 'name',
  42633. data: createNameTable(this.name)
  42634. };
  42635. } else {
  42636. var namePrototype = readNameTable(tables['name']);
  42637. tables['name'].data = createNameTable(name, namePrototype);
  42638. }
  42639. var builder = new OpenTypeFileBuilder(header.version);
  42640. for (var tableTag in tables) {
  42641. builder.addTable(tableTag, tables[tableTag].data);
  42642. }
  42643. return builder.toArray();
  42644. },
  42645. convert: function Font_convert(fontName, font, properties) {
  42646. properties.fixedPitch = false;
  42647. if (properties.builtInEncoding) {
  42648. adjustToUnicode(properties, properties.builtInEncoding);
  42649. }
  42650. var mapping = font.getGlyphMapping(properties);
  42651. var newMapping = adjustMapping(mapping, properties);
  42652. this.toFontChar = newMapping.toFontChar;
  42653. var numGlyphs = font.numGlyphs;
  42654. function getCharCodes(charCodeToGlyphId, glyphId) {
  42655. var charCodes = null;
  42656. for (var charCode in charCodeToGlyphId) {
  42657. if (glyphId === charCodeToGlyphId[charCode]) {
  42658. if (!charCodes) {
  42659. charCodes = [];
  42660. }
  42661. charCodes.push(charCode | 0);
  42662. }
  42663. }
  42664. return charCodes;
  42665. }
  42666. function createCharCode(charCodeToGlyphId, glyphId) {
  42667. for (var charCode in charCodeToGlyphId) {
  42668. if (glyphId === charCodeToGlyphId[charCode]) {
  42669. return charCode | 0;
  42670. }
  42671. }
  42672. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42673. return newMapping.nextAvailableFontCharCode++;
  42674. }
  42675. var seacs = font.seacs;
  42676. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42677. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42678. var charset = font.getCharset();
  42679. var seacMap = Object.create(null);
  42680. for (var glyphId in seacs) {
  42681. glyphId |= 0;
  42682. var seac = seacs[glyphId];
  42683. var baseGlyphName = StandardEncoding[seac[2]];
  42684. var accentGlyphName = StandardEncoding[seac[3]];
  42685. var baseGlyphId = charset.indexOf(baseGlyphName);
  42686. var accentGlyphId = charset.indexOf(accentGlyphName);
  42687. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42688. continue;
  42689. }
  42690. var accentOffset = {
  42691. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42692. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42693. };
  42694. var charCodes = getCharCodes(mapping, glyphId);
  42695. if (!charCodes) {
  42696. continue;
  42697. }
  42698. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42699. var charCode = charCodes[i];
  42700. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42701. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42702. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42703. seacMap[charCode] = {
  42704. baseFontCharCode: baseFontCharCode,
  42705. accentFontCharCode: accentFontCharCode,
  42706. accentOffset: accentOffset
  42707. };
  42708. }
  42709. }
  42710. properties.seacMap = seacMap;
  42711. }
  42712. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42713. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42714. builder.addTable('CFF ', font.data);
  42715. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42716. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42717. 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');
  42718. 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));
  42719. builder.addTable('hmtx', function fontFieldsHmtx() {
  42720. var charstrings = font.charstrings;
  42721. var cffWidths = font.cff ? font.cff.widths : null;
  42722. var hmtx = '\x00\x00\x00\x00';
  42723. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42724. var width = 0;
  42725. if (charstrings) {
  42726. var charstring = charstrings[i - 1];
  42727. width = 'width' in charstring ? charstring.width : 0;
  42728. } else if (cffWidths) {
  42729. width = Math.ceil(cffWidths[i] || 0);
  42730. }
  42731. hmtx += string16(width) + string16(0);
  42732. }
  42733. return hmtx;
  42734. }());
  42735. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42736. builder.addTable('name', createNameTable(fontName));
  42737. builder.addTable('post', createPostTable(properties));
  42738. return builder.toArray();
  42739. },
  42740. get spaceWidth() {
  42741. if ('_shadowWidth' in this) {
  42742. return this._shadowWidth;
  42743. }
  42744. var possibleSpaceReplacements = [
  42745. 'space',
  42746. 'minus',
  42747. 'one',
  42748. 'i',
  42749. 'I'
  42750. ];
  42751. var width;
  42752. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42753. var glyphName = possibleSpaceReplacements[i];
  42754. if (glyphName in this.widths) {
  42755. width = this.widths[glyphName];
  42756. break;
  42757. }
  42758. var glyphsUnicodeMap = getGlyphsUnicode();
  42759. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42760. var charcode = 0;
  42761. if (this.composite) {
  42762. if (this.cMap.contains(glyphUnicode)) {
  42763. charcode = this.cMap.lookup(glyphUnicode);
  42764. }
  42765. }
  42766. if (!charcode && this.toUnicode) {
  42767. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42768. }
  42769. if (charcode <= 0) {
  42770. charcode = glyphUnicode;
  42771. }
  42772. width = this.widths[charcode];
  42773. if (width) {
  42774. break;
  42775. }
  42776. }
  42777. width = width || this.defaultWidth;
  42778. this._shadowWidth = width;
  42779. return width;
  42780. },
  42781. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42782. var fontCharCode, width, operatorListId;
  42783. var widthCode = charcode;
  42784. if (this.cMap && this.cMap.contains(charcode)) {
  42785. widthCode = this.cMap.lookup(charcode);
  42786. }
  42787. width = this.widths[widthCode];
  42788. width = isNum(width) ? width : this.defaultWidth;
  42789. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42790. var unicode = this.toUnicode.get(charcode) || charcode;
  42791. if (typeof unicode === 'number') {
  42792. unicode = String.fromCharCode(unicode);
  42793. }
  42794. var isInFont = charcode in this.toFontChar;
  42795. fontCharCode = this.toFontChar[charcode] || charcode;
  42796. if (this.missingFile) {
  42797. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42798. }
  42799. if (this.isType3Font) {
  42800. operatorListId = fontCharCode;
  42801. }
  42802. var accent = null;
  42803. if (this.seacMap && this.seacMap[charcode]) {
  42804. isInFont = true;
  42805. var seac = this.seacMap[charcode];
  42806. fontCharCode = seac.baseFontCharCode;
  42807. accent = {
  42808. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42809. offset: seac.accentOffset
  42810. };
  42811. }
  42812. var fontChar = String.fromCharCode(fontCharCode);
  42813. var glyph = this.glyphCache[charcode];
  42814. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42815. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42816. this.glyphCache[charcode] = glyph;
  42817. }
  42818. return glyph;
  42819. },
  42820. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42821. var charsCache = this.charsCache;
  42822. var glyphs, glyph, charcode;
  42823. if (charsCache) {
  42824. glyphs = charsCache[chars];
  42825. if (glyphs) {
  42826. return glyphs;
  42827. }
  42828. }
  42829. if (!charsCache) {
  42830. charsCache = this.charsCache = Object.create(null);
  42831. }
  42832. glyphs = [];
  42833. var charsCacheKey = chars;
  42834. var i = 0, ii;
  42835. if (this.cMap) {
  42836. var c = Object.create(null);
  42837. while (i < chars.length) {
  42838. this.cMap.readCharCode(chars, i, c);
  42839. charcode = c.charcode;
  42840. var length = c.length;
  42841. i += length;
  42842. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  42843. glyph = this.charToGlyph(charcode, isSpace);
  42844. glyphs.push(glyph);
  42845. }
  42846. } else {
  42847. for (i = 0, ii = chars.length; i < ii; ++i) {
  42848. charcode = chars.charCodeAt(i);
  42849. glyph = this.charToGlyph(charcode, charcode === 0x20);
  42850. glyphs.push(glyph);
  42851. }
  42852. }
  42853. return charsCache[charsCacheKey] = glyphs;
  42854. }
  42855. };
  42856. return Font;
  42857. }();
  42858. var ErrorFont = function ErrorFontClosure() {
  42859. function ErrorFont(error) {
  42860. this.error = error;
  42861. this.loadedName = 'g_font_error';
  42862. this.loading = false;
  42863. }
  42864. ErrorFont.prototype = {
  42865. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  42866. return [];
  42867. },
  42868. exportData: function ErrorFont_exportData() {
  42869. return { error: this.error };
  42870. }
  42871. };
  42872. return ErrorFont;
  42873. }();
  42874. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  42875. var charCodeToGlyphId = Object.create(null);
  42876. var glyphId, charCode, baseEncoding;
  42877. if (properties.baseEncodingName) {
  42878. baseEncoding = getEncoding(properties.baseEncodingName);
  42879. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42880. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42881. if (glyphId >= 0) {
  42882. charCodeToGlyphId[charCode] = glyphId;
  42883. } else {
  42884. charCodeToGlyphId[charCode] = 0;
  42885. }
  42886. }
  42887. } else if (!!(properties.flags & FontFlags.Symbolic)) {
  42888. for (charCode in builtInEncoding) {
  42889. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  42890. }
  42891. } else {
  42892. baseEncoding = StandardEncoding;
  42893. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42894. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42895. if (glyphId >= 0) {
  42896. charCodeToGlyphId[charCode] = glyphId;
  42897. } else {
  42898. charCodeToGlyphId[charCode] = 0;
  42899. }
  42900. }
  42901. }
  42902. var differences = properties.differences, glyphsUnicodeMap;
  42903. if (differences) {
  42904. for (charCode in differences) {
  42905. var glyphName = differences[charCode];
  42906. glyphId = glyphNames.indexOf(glyphName);
  42907. if (glyphId === -1) {
  42908. if (!glyphsUnicodeMap) {
  42909. glyphsUnicodeMap = getGlyphsUnicode();
  42910. }
  42911. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42912. if (standardGlyphName !== glyphName) {
  42913. glyphId = glyphNames.indexOf(standardGlyphName);
  42914. }
  42915. }
  42916. if (glyphId >= 0) {
  42917. charCodeToGlyphId[charCode] = glyphId;
  42918. } else {
  42919. charCodeToGlyphId[charCode] = 0;
  42920. }
  42921. }
  42922. }
  42923. return charCodeToGlyphId;
  42924. }
  42925. var Type1Font = function Type1FontClosure() {
  42926. function findBlock(streamBytes, signature, startIndex) {
  42927. var streamBytesLength = streamBytes.length;
  42928. var signatureLength = signature.length;
  42929. var scanLength = streamBytesLength - signatureLength;
  42930. var i = startIndex, j, found = false;
  42931. while (i < scanLength) {
  42932. j = 0;
  42933. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  42934. j++;
  42935. }
  42936. if (j >= signatureLength) {
  42937. i += j;
  42938. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  42939. i++;
  42940. }
  42941. found = true;
  42942. break;
  42943. }
  42944. i++;
  42945. }
  42946. return {
  42947. found: found,
  42948. length: i
  42949. };
  42950. }
  42951. function getHeaderBlock(stream, suggestedLength) {
  42952. var EEXEC_SIGNATURE = [
  42953. 0x65,
  42954. 0x65,
  42955. 0x78,
  42956. 0x65,
  42957. 0x63
  42958. ];
  42959. var streamStartPos = stream.pos;
  42960. var headerBytes, headerBytesLength, block;
  42961. try {
  42962. headerBytes = stream.getBytes(suggestedLength);
  42963. headerBytesLength = headerBytes.length;
  42964. } catch (ex) {
  42965. if (ex instanceof MissingDataException) {
  42966. throw ex;
  42967. }
  42968. }
  42969. if (headerBytesLength === suggestedLength) {
  42970. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  42971. if (block.found && block.length === suggestedLength) {
  42972. return {
  42973. stream: new Stream(headerBytes),
  42974. length: suggestedLength
  42975. };
  42976. }
  42977. }
  42978. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  42979. stream.pos = streamStartPos;
  42980. var SCAN_BLOCK_LENGTH = 2048;
  42981. var actualLength;
  42982. while (true) {
  42983. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  42984. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  42985. if (block.length === 0) {
  42986. break;
  42987. }
  42988. stream.pos += block.length;
  42989. if (block.found) {
  42990. actualLength = stream.pos - streamStartPos;
  42991. break;
  42992. }
  42993. }
  42994. stream.pos = streamStartPos;
  42995. if (actualLength) {
  42996. return {
  42997. stream: new Stream(stream.getBytes(actualLength)),
  42998. length: actualLength
  42999. };
  43000. }
  43001. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43002. return {
  43003. stream: new Stream(stream.getBytes(suggestedLength)),
  43004. length: suggestedLength
  43005. };
  43006. }
  43007. function getEexecBlock(stream, suggestedLength) {
  43008. var eexecBytes = stream.getBytes();
  43009. return {
  43010. stream: new Stream(eexecBytes),
  43011. length: eexecBytes.length
  43012. };
  43013. }
  43014. function Type1Font(name, file, properties) {
  43015. var PFB_HEADER_SIZE = 6;
  43016. var headerBlockLength = properties.length1;
  43017. var eexecBlockLength = properties.length2;
  43018. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43019. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43020. if (pfbHeaderPresent) {
  43021. file.skip(PFB_HEADER_SIZE);
  43022. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43023. }
  43024. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43025. headerBlockLength = headerBlock.length;
  43026. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43027. headerBlockParser.extractFontHeader(properties);
  43028. if (pfbHeaderPresent) {
  43029. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43030. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43031. }
  43032. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43033. eexecBlockLength = eexecBlock.length;
  43034. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43035. var data = eexecBlockParser.extractFontProgram();
  43036. for (var info in data.properties) {
  43037. properties[info] = data.properties[info];
  43038. }
  43039. var charstrings = data.charstrings;
  43040. var type2Charstrings = this.getType2Charstrings(charstrings);
  43041. var subrs = this.getType2Subrs(data.subrs);
  43042. this.charstrings = charstrings;
  43043. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43044. this.seacs = this.getSeacs(data.charstrings);
  43045. }
  43046. Type1Font.prototype = {
  43047. get numGlyphs() {
  43048. return this.charstrings.length + 1;
  43049. },
  43050. getCharset: function Type1Font_getCharset() {
  43051. var charset = ['.notdef'];
  43052. var charstrings = this.charstrings;
  43053. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43054. charset.push(charstrings[glyphId].glyphName);
  43055. }
  43056. return charset;
  43057. },
  43058. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43059. var charstrings = this.charstrings;
  43060. var glyphNames = ['.notdef'], glyphId;
  43061. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43062. glyphNames.push(charstrings[glyphId].glyphName);
  43063. }
  43064. var encoding = properties.builtInEncoding;
  43065. if (encoding) {
  43066. var builtInEncoding = Object.create(null);
  43067. for (var charCode in encoding) {
  43068. glyphId = glyphNames.indexOf(encoding[charCode]);
  43069. if (glyphId >= 0) {
  43070. builtInEncoding[charCode] = glyphId;
  43071. }
  43072. }
  43073. }
  43074. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43075. },
  43076. getSeacs: function Type1Font_getSeacs(charstrings) {
  43077. var i, ii;
  43078. var seacMap = [];
  43079. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43080. var charstring = charstrings[i];
  43081. if (charstring.seac) {
  43082. seacMap[i + 1] = charstring.seac;
  43083. }
  43084. }
  43085. return seacMap;
  43086. },
  43087. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43088. var type2Charstrings = [];
  43089. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43090. type2Charstrings.push(type1Charstrings[i].charstring);
  43091. }
  43092. return type2Charstrings;
  43093. },
  43094. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43095. var bias = 0;
  43096. var count = type1Subrs.length;
  43097. if (count < 1133) {
  43098. bias = 107;
  43099. } else if (count < 33769) {
  43100. bias = 1131;
  43101. } else {
  43102. bias = 32768;
  43103. }
  43104. var type2Subrs = [];
  43105. var i;
  43106. for (i = 0; i < bias; i++) {
  43107. type2Subrs.push([0x0B]);
  43108. }
  43109. for (i = 0; i < count; i++) {
  43110. type2Subrs.push(type1Subrs[i]);
  43111. }
  43112. return type2Subrs;
  43113. },
  43114. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43115. var cff = new CFF();
  43116. cff.header = new CFFHeader(1, 0, 4, 4);
  43117. cff.names = [name];
  43118. var topDict = new CFFTopDict();
  43119. topDict.setByName('version', 391);
  43120. topDict.setByName('Notice', 392);
  43121. topDict.setByName('FullName', 393);
  43122. topDict.setByName('FamilyName', 394);
  43123. topDict.setByName('Weight', 395);
  43124. topDict.setByName('Encoding', null);
  43125. topDict.setByName('FontMatrix', properties.fontMatrix);
  43126. topDict.setByName('FontBBox', properties.bbox);
  43127. topDict.setByName('charset', null);
  43128. topDict.setByName('CharStrings', null);
  43129. topDict.setByName('Private', null);
  43130. cff.topDict = topDict;
  43131. var strings = new CFFStrings();
  43132. strings.add('Version 0.11');
  43133. strings.add('See original notice');
  43134. strings.add(name);
  43135. strings.add(name);
  43136. strings.add('Medium');
  43137. cff.strings = strings;
  43138. cff.globalSubrIndex = new CFFIndex();
  43139. var count = glyphs.length;
  43140. var charsetArray = [0];
  43141. var i, ii;
  43142. for (i = 0; i < count; i++) {
  43143. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43144. if (index === -1) {
  43145. index = 0;
  43146. }
  43147. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43148. }
  43149. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43150. var charStringsIndex = new CFFIndex();
  43151. charStringsIndex.add([
  43152. 0x8B,
  43153. 0x0E
  43154. ]);
  43155. for (i = 0; i < count; i++) {
  43156. var glyph = glyphs[i];
  43157. if (glyph.length === 0) {
  43158. charStringsIndex.add([
  43159. 0x8B,
  43160. 0x0E
  43161. ]);
  43162. continue;
  43163. }
  43164. charStringsIndex.add(glyph);
  43165. }
  43166. cff.charStrings = charStringsIndex;
  43167. var privateDict = new CFFPrivateDict();
  43168. privateDict.setByName('Subrs', null);
  43169. var fields = [
  43170. 'BlueValues',
  43171. 'OtherBlues',
  43172. 'FamilyBlues',
  43173. 'FamilyOtherBlues',
  43174. 'StemSnapH',
  43175. 'StemSnapV',
  43176. 'BlueShift',
  43177. 'BlueFuzz',
  43178. 'BlueScale',
  43179. 'LanguageGroup',
  43180. 'ExpansionFactor',
  43181. 'ForceBold',
  43182. 'StdHW',
  43183. 'StdVW'
  43184. ];
  43185. for (i = 0, ii = fields.length; i < ii; i++) {
  43186. var field = fields[i];
  43187. if (!(field in properties.privateData)) {
  43188. continue;
  43189. }
  43190. var value = properties.privateData[field];
  43191. if (isArray(value)) {
  43192. for (var j = value.length - 1; j > 0; j--) {
  43193. value[j] -= value[j - 1];
  43194. }
  43195. }
  43196. privateDict.setByName(field, value);
  43197. }
  43198. cff.topDict.privateDict = privateDict;
  43199. var subrIndex = new CFFIndex();
  43200. for (i = 0, ii = subrs.length; i < ii; i++) {
  43201. subrIndex.add(subrs[i]);
  43202. }
  43203. privateDict.subrsIndex = subrIndex;
  43204. var compiler = new CFFCompiler(cff);
  43205. return compiler.compile();
  43206. }
  43207. };
  43208. return Type1Font;
  43209. }();
  43210. var CFFFont = function CFFFontClosure() {
  43211. function CFFFont(file, properties) {
  43212. this.properties = properties;
  43213. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43214. this.cff = parser.parse();
  43215. var compiler = new CFFCompiler(this.cff);
  43216. this.seacs = this.cff.seacs;
  43217. try {
  43218. this.data = compiler.compile();
  43219. } catch (e) {
  43220. warn('Failed to compile font ' + properties.loadedName);
  43221. this.data = file;
  43222. }
  43223. }
  43224. CFFFont.prototype = {
  43225. get numGlyphs() {
  43226. return this.cff.charStrings.count;
  43227. },
  43228. getCharset: function CFFFont_getCharset() {
  43229. return this.cff.charset.charset;
  43230. },
  43231. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43232. var cff = this.cff;
  43233. var properties = this.properties;
  43234. var charsets = cff.charset.charset;
  43235. var charCodeToGlyphId;
  43236. var glyphId;
  43237. if (properties.composite) {
  43238. charCodeToGlyphId = Object.create(null);
  43239. if (cff.isCIDFont) {
  43240. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43241. var cid = charsets[glyphId];
  43242. var charCode = properties.cMap.charCodeOf(cid);
  43243. charCodeToGlyphId[charCode] = glyphId;
  43244. }
  43245. } else {
  43246. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43247. charCodeToGlyphId[glyphId] = glyphId;
  43248. }
  43249. }
  43250. return charCodeToGlyphId;
  43251. }
  43252. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43253. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43254. return charCodeToGlyphId;
  43255. }
  43256. };
  43257. return CFFFont;
  43258. }();
  43259. (function checkSeacSupport() {
  43260. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43261. SEAC_ANALYSIS_ENABLED = true;
  43262. }
  43263. }());
  43264. (function checkChromeWindows() {
  43265. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43266. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43267. }
  43268. }());
  43269. exports.ErrorFont = ErrorFont;
  43270. exports.Font = Font;
  43271. exports.FontFlags = FontFlags;
  43272. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43273. exports.ToUnicodeMap = ToUnicodeMap;
  43274. exports.getFontType = getFontType;
  43275. }));
  43276. (function (root, factory) {
  43277. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43278. }(this, function (exports, sharedUtil, coreParser) {
  43279. var error = sharedUtil.error;
  43280. var isSpace = sharedUtil.isSpace;
  43281. var EOF = coreParser.EOF;
  43282. var PostScriptParser = function PostScriptParserClosure() {
  43283. function PostScriptParser(lexer) {
  43284. this.lexer = lexer;
  43285. this.operators = [];
  43286. this.token = null;
  43287. this.prev = null;
  43288. }
  43289. PostScriptParser.prototype = {
  43290. nextToken: function PostScriptParser_nextToken() {
  43291. this.prev = this.token;
  43292. this.token = this.lexer.getToken();
  43293. },
  43294. accept: function PostScriptParser_accept(type) {
  43295. if (this.token.type === type) {
  43296. this.nextToken();
  43297. return true;
  43298. }
  43299. return false;
  43300. },
  43301. expect: function PostScriptParser_expect(type) {
  43302. if (this.accept(type)) {
  43303. return true;
  43304. }
  43305. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43306. },
  43307. parse: function PostScriptParser_parse() {
  43308. this.nextToken();
  43309. this.expect(PostScriptTokenTypes.LBRACE);
  43310. this.parseBlock();
  43311. this.expect(PostScriptTokenTypes.RBRACE);
  43312. return this.operators;
  43313. },
  43314. parseBlock: function PostScriptParser_parseBlock() {
  43315. while (true) {
  43316. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43317. this.operators.push(this.prev.value);
  43318. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43319. this.operators.push(this.prev.value);
  43320. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43321. this.parseCondition();
  43322. } else {
  43323. return;
  43324. }
  43325. }
  43326. },
  43327. parseCondition: function PostScriptParser_parseCondition() {
  43328. var conditionLocation = this.operators.length;
  43329. this.operators.push(null, null);
  43330. this.parseBlock();
  43331. this.expect(PostScriptTokenTypes.RBRACE);
  43332. if (this.accept(PostScriptTokenTypes.IF)) {
  43333. this.operators[conditionLocation] = this.operators.length;
  43334. this.operators[conditionLocation + 1] = 'jz';
  43335. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43336. var jumpLocation = this.operators.length;
  43337. this.operators.push(null, null);
  43338. var endOfTrue = this.operators.length;
  43339. this.parseBlock();
  43340. this.expect(PostScriptTokenTypes.RBRACE);
  43341. this.expect(PostScriptTokenTypes.IFELSE);
  43342. this.operators[jumpLocation] = this.operators.length;
  43343. this.operators[jumpLocation + 1] = 'j';
  43344. this.operators[conditionLocation] = endOfTrue;
  43345. this.operators[conditionLocation + 1] = 'jz';
  43346. } else {
  43347. error('PS Function: error parsing conditional.');
  43348. }
  43349. }
  43350. };
  43351. return PostScriptParser;
  43352. }();
  43353. var PostScriptTokenTypes = {
  43354. LBRACE: 0,
  43355. RBRACE: 1,
  43356. NUMBER: 2,
  43357. OPERATOR: 3,
  43358. IF: 4,
  43359. IFELSE: 5
  43360. };
  43361. var PostScriptToken = function PostScriptTokenClosure() {
  43362. function PostScriptToken(type, value) {
  43363. this.type = type;
  43364. this.value = value;
  43365. }
  43366. var opCache = Object.create(null);
  43367. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43368. var opValue = opCache[op];
  43369. if (opValue) {
  43370. return opValue;
  43371. }
  43372. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43373. };
  43374. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43375. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43376. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43377. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43378. return PostScriptToken;
  43379. }();
  43380. var PostScriptLexer = function PostScriptLexerClosure() {
  43381. function PostScriptLexer(stream) {
  43382. this.stream = stream;
  43383. this.nextChar();
  43384. this.strBuf = [];
  43385. }
  43386. PostScriptLexer.prototype = {
  43387. nextChar: function PostScriptLexer_nextChar() {
  43388. return this.currentChar = this.stream.getByte();
  43389. },
  43390. getToken: function PostScriptLexer_getToken() {
  43391. var comment = false;
  43392. var ch = this.currentChar;
  43393. while (true) {
  43394. if (ch < 0) {
  43395. return EOF;
  43396. }
  43397. if (comment) {
  43398. if (ch === 0x0A || ch === 0x0D) {
  43399. comment = false;
  43400. }
  43401. } else if (ch === 0x25) {
  43402. comment = true;
  43403. } else if (!isSpace(ch)) {
  43404. break;
  43405. }
  43406. ch = this.nextChar();
  43407. }
  43408. switch (ch | 0) {
  43409. case 0x30:
  43410. case 0x31:
  43411. case 0x32:
  43412. case 0x33:
  43413. case 0x34:
  43414. case 0x35:
  43415. case 0x36:
  43416. case 0x37:
  43417. case 0x38:
  43418. case 0x39:
  43419. case 0x2B:
  43420. case 0x2D:
  43421. case 0x2E:
  43422. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43423. case 0x7B:
  43424. this.nextChar();
  43425. return PostScriptToken.LBRACE;
  43426. case 0x7D:
  43427. this.nextChar();
  43428. return PostScriptToken.RBRACE;
  43429. }
  43430. var strBuf = this.strBuf;
  43431. strBuf.length = 0;
  43432. strBuf[0] = String.fromCharCode(ch);
  43433. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43434. strBuf.push(String.fromCharCode(ch));
  43435. }
  43436. var str = strBuf.join('');
  43437. switch (str.toLowerCase()) {
  43438. case 'if':
  43439. return PostScriptToken.IF;
  43440. case 'ifelse':
  43441. return PostScriptToken.IFELSE;
  43442. default:
  43443. return PostScriptToken.getOperator(str);
  43444. }
  43445. },
  43446. getNumber: function PostScriptLexer_getNumber() {
  43447. var ch = this.currentChar;
  43448. var strBuf = this.strBuf;
  43449. strBuf.length = 0;
  43450. strBuf[0] = String.fromCharCode(ch);
  43451. while ((ch = this.nextChar()) >= 0) {
  43452. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43453. strBuf.push(String.fromCharCode(ch));
  43454. } else {
  43455. break;
  43456. }
  43457. }
  43458. var value = parseFloat(strBuf.join(''));
  43459. if (isNaN(value)) {
  43460. error('Invalid floating point number: ' + value);
  43461. }
  43462. return value;
  43463. }
  43464. };
  43465. return PostScriptLexer;
  43466. }();
  43467. exports.PostScriptLexer = PostScriptLexer;
  43468. exports.PostScriptParser = PostScriptParser;
  43469. }));
  43470. (function (root, factory) {
  43471. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43472. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43473. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43474. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43475. var ImageKind = sharedUtil.ImageKind;
  43476. var OPS = sharedUtil.OPS;
  43477. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43478. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43479. var Util = sharedUtil.Util;
  43480. var assert = sharedUtil.assert;
  43481. var info = sharedUtil.info;
  43482. var isNum = sharedUtil.isNum;
  43483. var isArray = sharedUtil.isArray;
  43484. var isLittleEndian = sharedUtil.isLittleEndian;
  43485. var error = sharedUtil.error;
  43486. var shadow = sharedUtil.shadow;
  43487. var warn = sharedUtil.warn;
  43488. var TilingPattern = displayPatternHelper.TilingPattern;
  43489. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43490. var WebGLUtils = displayWebGL.WebGLUtils;
  43491. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43492. var MIN_FONT_SIZE = 16;
  43493. var MAX_FONT_SIZE = 100;
  43494. var MAX_GROUP_SIZE = 4096;
  43495. var MIN_WIDTH_FACTOR = 0.65;
  43496. var COMPILE_TYPE3_GLYPHS = true;
  43497. var MAX_SIZE_TO_COMPILE = 1000;
  43498. var FULL_CHUNK_HEIGHT = 16;
  43499. var HasCanvasTypedArraysCached = {
  43500. get value() {
  43501. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43502. }
  43503. };
  43504. var IsLittleEndianCached = {
  43505. get value() {
  43506. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43507. }
  43508. };
  43509. function createScratchCanvas(width, height) {
  43510. var canvas = document.createElement('canvas');
  43511. canvas.width = width;
  43512. canvas.height = height;
  43513. return canvas;
  43514. }
  43515. function addContextCurrentTransform(ctx) {
  43516. if (!ctx.mozCurrentTransform) {
  43517. ctx._originalSave = ctx.save;
  43518. ctx._originalRestore = ctx.restore;
  43519. ctx._originalRotate = ctx.rotate;
  43520. ctx._originalScale = ctx.scale;
  43521. ctx._originalTranslate = ctx.translate;
  43522. ctx._originalTransform = ctx.transform;
  43523. ctx._originalSetTransform = ctx.setTransform;
  43524. ctx._transformMatrix = ctx._transformMatrix || [
  43525. 1,
  43526. 0,
  43527. 0,
  43528. 1,
  43529. 0,
  43530. 0
  43531. ];
  43532. ctx._transformStack = [];
  43533. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43534. get: function getCurrentTransform() {
  43535. return this._transformMatrix;
  43536. }
  43537. });
  43538. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43539. get: function getCurrentTransformInverse() {
  43540. var m = this._transformMatrix;
  43541. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43542. var ad_bc = a * d - b * c;
  43543. var bc_ad = b * c - a * d;
  43544. return [
  43545. d / ad_bc,
  43546. b / bc_ad,
  43547. c / bc_ad,
  43548. a / ad_bc,
  43549. (d * e - c * f) / bc_ad,
  43550. (b * e - a * f) / ad_bc
  43551. ];
  43552. }
  43553. });
  43554. ctx.save = function ctxSave() {
  43555. var old = this._transformMatrix;
  43556. this._transformStack.push(old);
  43557. this._transformMatrix = old.slice(0, 6);
  43558. this._originalSave();
  43559. };
  43560. ctx.restore = function ctxRestore() {
  43561. var prev = this._transformStack.pop();
  43562. if (prev) {
  43563. this._transformMatrix = prev;
  43564. this._originalRestore();
  43565. }
  43566. };
  43567. ctx.translate = function ctxTranslate(x, y) {
  43568. var m = this._transformMatrix;
  43569. m[4] = m[0] * x + m[2] * y + m[4];
  43570. m[5] = m[1] * x + m[3] * y + m[5];
  43571. this._originalTranslate(x, y);
  43572. };
  43573. ctx.scale = function ctxScale(x, y) {
  43574. var m = this._transformMatrix;
  43575. m[0] = m[0] * x;
  43576. m[1] = m[1] * x;
  43577. m[2] = m[2] * y;
  43578. m[3] = m[3] * y;
  43579. this._originalScale(x, y);
  43580. };
  43581. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43582. var m = this._transformMatrix;
  43583. this._transformMatrix = [
  43584. m[0] * a + m[2] * b,
  43585. m[1] * a + m[3] * b,
  43586. m[0] * c + m[2] * d,
  43587. m[1] * c + m[3] * d,
  43588. m[0] * e + m[2] * f + m[4],
  43589. m[1] * e + m[3] * f + m[5]
  43590. ];
  43591. ctx._originalTransform(a, b, c, d, e, f);
  43592. };
  43593. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43594. this._transformMatrix = [
  43595. a,
  43596. b,
  43597. c,
  43598. d,
  43599. e,
  43600. f
  43601. ];
  43602. ctx._originalSetTransform(a, b, c, d, e, f);
  43603. };
  43604. ctx.rotate = function ctxRotate(angle) {
  43605. var cosValue = Math.cos(angle);
  43606. var sinValue = Math.sin(angle);
  43607. var m = this._transformMatrix;
  43608. this._transformMatrix = [
  43609. m[0] * cosValue + m[2] * sinValue,
  43610. m[1] * cosValue + m[3] * sinValue,
  43611. m[0] * -sinValue + m[2] * cosValue,
  43612. m[1] * -sinValue + m[3] * cosValue,
  43613. m[4],
  43614. m[5]
  43615. ];
  43616. this._originalRotate(angle);
  43617. };
  43618. }
  43619. }
  43620. var CachedCanvases = function CachedCanvasesClosure() {
  43621. function CachedCanvases() {
  43622. this.cache = Object.create(null);
  43623. }
  43624. CachedCanvases.prototype = {
  43625. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43626. var canvasEntry;
  43627. if (this.cache[id] !== undefined) {
  43628. canvasEntry = this.cache[id];
  43629. canvasEntry.canvas.width = width;
  43630. canvasEntry.canvas.height = height;
  43631. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43632. } else {
  43633. var canvas = createScratchCanvas(width, height);
  43634. var ctx = canvas.getContext('2d');
  43635. if (trackTransform) {
  43636. addContextCurrentTransform(ctx);
  43637. }
  43638. this.cache[id] = canvasEntry = {
  43639. canvas: canvas,
  43640. context: ctx
  43641. };
  43642. }
  43643. return canvasEntry;
  43644. },
  43645. clear: function () {
  43646. for (var id in this.cache) {
  43647. var canvasEntry = this.cache[id];
  43648. canvasEntry.canvas.width = 0;
  43649. canvasEntry.canvas.height = 0;
  43650. delete this.cache[id];
  43651. }
  43652. }
  43653. };
  43654. return CachedCanvases;
  43655. }();
  43656. function compileType3Glyph(imgData) {
  43657. var POINT_TO_PROCESS_LIMIT = 1000;
  43658. var width = imgData.width, height = imgData.height;
  43659. var i, j, j0, width1 = width + 1;
  43660. var points = new Uint8Array(width1 * (height + 1));
  43661. var POINT_TYPES = new Uint8Array([
  43662. 0,
  43663. 2,
  43664. 4,
  43665. 0,
  43666. 1,
  43667. 0,
  43668. 5,
  43669. 4,
  43670. 8,
  43671. 10,
  43672. 0,
  43673. 8,
  43674. 0,
  43675. 2,
  43676. 1,
  43677. 0
  43678. ]);
  43679. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43680. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43681. for (i = 0, ii = data0.length; i < ii; i++) {
  43682. var mask = 128, elem = data0[i];
  43683. while (mask > 0) {
  43684. data[pos++] = elem & mask ? 0 : 255;
  43685. mask >>= 1;
  43686. }
  43687. }
  43688. var count = 0;
  43689. pos = 0;
  43690. if (data[pos] !== 0) {
  43691. points[0] = 1;
  43692. ++count;
  43693. }
  43694. for (j = 1; j < width; j++) {
  43695. if (data[pos] !== data[pos + 1]) {
  43696. points[j] = data[pos] ? 2 : 1;
  43697. ++count;
  43698. }
  43699. pos++;
  43700. }
  43701. if (data[pos] !== 0) {
  43702. points[j] = 2;
  43703. ++count;
  43704. }
  43705. for (i = 1; i < height; i++) {
  43706. pos = i * lineSize;
  43707. j0 = i * width1;
  43708. if (data[pos - lineSize] !== data[pos]) {
  43709. points[j0] = data[pos] ? 1 : 8;
  43710. ++count;
  43711. }
  43712. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43713. for (j = 1; j < width; j++) {
  43714. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43715. if (POINT_TYPES[sum]) {
  43716. points[j0 + j] = POINT_TYPES[sum];
  43717. ++count;
  43718. }
  43719. pos++;
  43720. }
  43721. if (data[pos - lineSize] !== data[pos]) {
  43722. points[j0 + j] = data[pos] ? 2 : 4;
  43723. ++count;
  43724. }
  43725. if (count > POINT_TO_PROCESS_LIMIT) {
  43726. return null;
  43727. }
  43728. }
  43729. pos = lineSize * (height - 1);
  43730. j0 = i * width1;
  43731. if (data[pos] !== 0) {
  43732. points[j0] = 8;
  43733. ++count;
  43734. }
  43735. for (j = 1; j < width; j++) {
  43736. if (data[pos] !== data[pos + 1]) {
  43737. points[j0 + j] = data[pos] ? 4 : 8;
  43738. ++count;
  43739. }
  43740. pos++;
  43741. }
  43742. if (data[pos] !== 0) {
  43743. points[j0 + j] = 4;
  43744. ++count;
  43745. }
  43746. if (count > POINT_TO_PROCESS_LIMIT) {
  43747. return null;
  43748. }
  43749. var steps = new Int32Array([
  43750. 0,
  43751. width1,
  43752. -1,
  43753. 0,
  43754. -width1,
  43755. 0,
  43756. 0,
  43757. 0,
  43758. 1
  43759. ]);
  43760. var outlines = [];
  43761. for (i = 0; count && i <= height; i++) {
  43762. var p = i * width1;
  43763. var end = p + width;
  43764. while (p < end && !points[p]) {
  43765. p++;
  43766. }
  43767. if (p === end) {
  43768. continue;
  43769. }
  43770. var coords = [
  43771. p % width1,
  43772. i
  43773. ];
  43774. var type = points[p], p0 = p, pp;
  43775. do {
  43776. var step = steps[type];
  43777. do {
  43778. p += step;
  43779. } while (!points[p]);
  43780. pp = points[p];
  43781. if (pp !== 5 && pp !== 10) {
  43782. type = pp;
  43783. points[p] = 0;
  43784. } else {
  43785. type = pp & 0x33 * type >> 4;
  43786. points[p] &= type >> 2 | type << 2;
  43787. }
  43788. coords.push(p % width1);
  43789. coords.push(p / width1 | 0);
  43790. --count;
  43791. } while (p0 !== p);
  43792. outlines.push(coords);
  43793. --i;
  43794. }
  43795. var drawOutline = function (c) {
  43796. c.save();
  43797. c.scale(1 / width, -1 / height);
  43798. c.translate(0, -height);
  43799. c.beginPath();
  43800. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43801. var o = outlines[i];
  43802. c.moveTo(o[0], o[1]);
  43803. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43804. c.lineTo(o[j], o[j + 1]);
  43805. }
  43806. }
  43807. c.fill();
  43808. c.beginPath();
  43809. c.restore();
  43810. };
  43811. return drawOutline;
  43812. }
  43813. var CanvasExtraState = function CanvasExtraStateClosure() {
  43814. function CanvasExtraState(old) {
  43815. this.alphaIsShape = false;
  43816. this.fontSize = 0;
  43817. this.fontSizeScale = 1;
  43818. this.textMatrix = IDENTITY_MATRIX;
  43819. this.textMatrixScale = 1;
  43820. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43821. this.leading = 0;
  43822. this.x = 0;
  43823. this.y = 0;
  43824. this.lineX = 0;
  43825. this.lineY = 0;
  43826. this.charSpacing = 0;
  43827. this.wordSpacing = 0;
  43828. this.textHScale = 1;
  43829. this.textRenderingMode = TextRenderingMode.FILL;
  43830. this.textRise = 0;
  43831. this.fillColor = '#000000';
  43832. this.strokeColor = '#000000';
  43833. this.patternFill = false;
  43834. this.fillAlpha = 1;
  43835. this.strokeAlpha = 1;
  43836. this.lineWidth = 1;
  43837. this.activeSMask = null;
  43838. this.resumeSMaskCtx = null;
  43839. this.old = old;
  43840. }
  43841. CanvasExtraState.prototype = {
  43842. clone: function CanvasExtraState_clone() {
  43843. return Object.create(this);
  43844. },
  43845. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  43846. this.x = x;
  43847. this.y = y;
  43848. }
  43849. };
  43850. return CanvasExtraState;
  43851. }();
  43852. var CanvasGraphics = function CanvasGraphicsClosure() {
  43853. var EXECUTION_TIME = 15;
  43854. var EXECUTION_STEPS = 10;
  43855. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  43856. this.ctx = canvasCtx;
  43857. this.current = new CanvasExtraState();
  43858. this.stateStack = [];
  43859. this.pendingClip = null;
  43860. this.pendingEOFill = false;
  43861. this.res = null;
  43862. this.xobjs = null;
  43863. this.commonObjs = commonObjs;
  43864. this.objs = objs;
  43865. this.imageLayer = imageLayer;
  43866. this.groupStack = [];
  43867. this.processingType3 = null;
  43868. this.baseTransform = null;
  43869. this.baseTransformStack = [];
  43870. this.groupLevel = 0;
  43871. this.smaskStack = [];
  43872. this.smaskCounter = 0;
  43873. this.tempSMask = null;
  43874. this.cachedCanvases = new CachedCanvases();
  43875. if (canvasCtx) {
  43876. addContextCurrentTransform(canvasCtx);
  43877. }
  43878. this.cachedGetSinglePixelWidth = null;
  43879. }
  43880. function putBinaryImageData(ctx, imgData) {
  43881. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  43882. ctx.putImageData(imgData, 0, 0);
  43883. return;
  43884. }
  43885. var height = imgData.height, width = imgData.width;
  43886. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43887. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43888. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43889. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43890. var srcPos = 0, destPos;
  43891. var src = imgData.data;
  43892. var dest = chunkImgData.data;
  43893. var i, j, thisChunkHeight, elemsInThisChunk;
  43894. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  43895. var srcLength = src.byteLength;
  43896. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  43897. var dest32DataLength = dest32.length;
  43898. var fullSrcDiff = width + 7 >> 3;
  43899. var white = 0xFFFFFFFF;
  43900. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  43901. for (i = 0; i < totalChunks; i++) {
  43902. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43903. destPos = 0;
  43904. for (j = 0; j < thisChunkHeight; j++) {
  43905. var srcDiff = srcLength - srcPos;
  43906. var k = 0;
  43907. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  43908. var kEndUnrolled = kEnd & ~7;
  43909. var mask = 0;
  43910. var srcByte = 0;
  43911. for (; k < kEndUnrolled; k += 8) {
  43912. srcByte = src[srcPos++];
  43913. dest32[destPos++] = srcByte & 128 ? white : black;
  43914. dest32[destPos++] = srcByte & 64 ? white : black;
  43915. dest32[destPos++] = srcByte & 32 ? white : black;
  43916. dest32[destPos++] = srcByte & 16 ? white : black;
  43917. dest32[destPos++] = srcByte & 8 ? white : black;
  43918. dest32[destPos++] = srcByte & 4 ? white : black;
  43919. dest32[destPos++] = srcByte & 2 ? white : black;
  43920. dest32[destPos++] = srcByte & 1 ? white : black;
  43921. }
  43922. for (; k < kEnd; k++) {
  43923. if (mask === 0) {
  43924. srcByte = src[srcPos++];
  43925. mask = 128;
  43926. }
  43927. dest32[destPos++] = srcByte & mask ? white : black;
  43928. mask >>= 1;
  43929. }
  43930. }
  43931. while (destPos < dest32DataLength) {
  43932. dest32[destPos++] = 0;
  43933. }
  43934. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43935. }
  43936. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  43937. j = 0;
  43938. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  43939. for (i = 0; i < fullChunks; i++) {
  43940. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43941. srcPos += elemsInThisChunk;
  43942. ctx.putImageData(chunkImgData, 0, j);
  43943. j += FULL_CHUNK_HEIGHT;
  43944. }
  43945. if (i < totalChunks) {
  43946. elemsInThisChunk = width * partialChunkHeight * 4;
  43947. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43948. ctx.putImageData(chunkImgData, 0, j);
  43949. }
  43950. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  43951. thisChunkHeight = FULL_CHUNK_HEIGHT;
  43952. elemsInThisChunk = width * thisChunkHeight;
  43953. for (i = 0; i < totalChunks; i++) {
  43954. if (i >= fullChunks) {
  43955. thisChunkHeight = partialChunkHeight;
  43956. elemsInThisChunk = width * thisChunkHeight;
  43957. }
  43958. destPos = 0;
  43959. for (j = elemsInThisChunk; j--;) {
  43960. dest[destPos++] = src[srcPos++];
  43961. dest[destPos++] = src[srcPos++];
  43962. dest[destPos++] = src[srcPos++];
  43963. dest[destPos++] = 255;
  43964. }
  43965. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43966. }
  43967. } else {
  43968. error('bad image kind: ' + imgData.kind);
  43969. }
  43970. }
  43971. function putBinaryImageMask(ctx, imgData) {
  43972. var height = imgData.height, width = imgData.width;
  43973. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43974. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43975. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43976. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43977. var srcPos = 0;
  43978. var src = imgData.data;
  43979. var dest = chunkImgData.data;
  43980. for (var i = 0; i < totalChunks; i++) {
  43981. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43982. var destPos = 3;
  43983. for (var j = 0; j < thisChunkHeight; j++) {
  43984. var mask = 0;
  43985. for (var k = 0; k < width; k++) {
  43986. if (!mask) {
  43987. var elem = src[srcPos++];
  43988. mask = 128;
  43989. }
  43990. dest[destPos] = elem & mask ? 0 : 255;
  43991. destPos += 4;
  43992. mask >>= 1;
  43993. }
  43994. }
  43995. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43996. }
  43997. }
  43998. function copyCtxState(sourceCtx, destCtx) {
  43999. var properties = [
  44000. 'strokeStyle',
  44001. 'fillStyle',
  44002. 'fillRule',
  44003. 'globalAlpha',
  44004. 'lineWidth',
  44005. 'lineCap',
  44006. 'lineJoin',
  44007. 'miterLimit',
  44008. 'globalCompositeOperation',
  44009. 'font'
  44010. ];
  44011. for (var i = 0, ii = properties.length; i < ii; i++) {
  44012. var property = properties[i];
  44013. if (sourceCtx[property] !== undefined) {
  44014. destCtx[property] = sourceCtx[property];
  44015. }
  44016. }
  44017. if (sourceCtx.setLineDash !== undefined) {
  44018. destCtx.setLineDash(sourceCtx.getLineDash());
  44019. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44020. }
  44021. }
  44022. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44023. var length = bytes.length;
  44024. for (var i = 3; i < length; i += 4) {
  44025. var alpha = bytes[i];
  44026. if (alpha === 0) {
  44027. bytes[i - 3] = r0;
  44028. bytes[i - 2] = g0;
  44029. bytes[i - 1] = b0;
  44030. } else if (alpha < 255) {
  44031. var alpha_ = 255 - alpha;
  44032. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44033. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44034. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44035. }
  44036. }
  44037. }
  44038. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44039. var length = maskData.length;
  44040. var scale = 1 / 255;
  44041. for (var i = 3; i < length; i += 4) {
  44042. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44043. layerData[i] = layerData[i] * alpha * scale | 0;
  44044. }
  44045. }
  44046. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44047. var length = maskData.length;
  44048. for (var i = 3; i < length; i += 4) {
  44049. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44050. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44051. }
  44052. }
  44053. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44054. var hasBackdrop = !!backdrop;
  44055. var r0 = hasBackdrop ? backdrop[0] : 0;
  44056. var g0 = hasBackdrop ? backdrop[1] : 0;
  44057. var b0 = hasBackdrop ? backdrop[2] : 0;
  44058. var composeFn;
  44059. if (subtype === 'Luminosity') {
  44060. composeFn = composeSMaskLuminosity;
  44061. } else {
  44062. composeFn = composeSMaskAlpha;
  44063. }
  44064. var PIXELS_TO_PROCESS = 1048576;
  44065. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44066. for (var row = 0; row < height; row += chunkSize) {
  44067. var chunkHeight = Math.min(chunkSize, height - row);
  44068. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44069. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44070. if (hasBackdrop) {
  44071. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44072. }
  44073. composeFn(maskData.data, layerData.data, transferMap);
  44074. maskCtx.putImageData(layerData, 0, row);
  44075. }
  44076. }
  44077. function composeSMask(ctx, smask, layerCtx) {
  44078. var mask = smask.canvas;
  44079. var maskCtx = smask.context;
  44080. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44081. var backdrop = smask.backdrop || null;
  44082. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44083. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44084. subtype: smask.subtype,
  44085. backdrop: backdrop
  44086. });
  44087. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44088. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44089. return;
  44090. }
  44091. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44092. ctx.drawImage(mask, 0, 0);
  44093. }
  44094. var LINE_CAP_STYLES = [
  44095. 'butt',
  44096. 'round',
  44097. 'square'
  44098. ];
  44099. var LINE_JOIN_STYLES = [
  44100. 'miter',
  44101. 'round',
  44102. 'bevel'
  44103. ];
  44104. var NORMAL_CLIP = {};
  44105. var EO_CLIP = {};
  44106. CanvasGraphics.prototype = {
  44107. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44108. var width = this.ctx.canvas.width;
  44109. var height = this.ctx.canvas.height;
  44110. this.ctx.save();
  44111. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44112. this.ctx.fillRect(0, 0, width, height);
  44113. this.ctx.restore();
  44114. if (transparency) {
  44115. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44116. this.compositeCtx = this.ctx;
  44117. this.transparentCanvas = transparentCanvas.canvas;
  44118. this.ctx = transparentCanvas.context;
  44119. this.ctx.save();
  44120. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44121. }
  44122. this.ctx.save();
  44123. if (transform) {
  44124. this.ctx.transform.apply(this.ctx, transform);
  44125. }
  44126. this.ctx.transform.apply(this.ctx, viewport.transform);
  44127. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44128. if (this.imageLayer) {
  44129. this.imageLayer.beginLayout();
  44130. }
  44131. },
  44132. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44133. var argsArray = operatorList.argsArray;
  44134. var fnArray = operatorList.fnArray;
  44135. var i = executionStartIdx || 0;
  44136. var argsArrayLen = argsArray.length;
  44137. if (argsArrayLen === i) {
  44138. return i;
  44139. }
  44140. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44141. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44142. var steps = 0;
  44143. var commonObjs = this.commonObjs;
  44144. var objs = this.objs;
  44145. var fnId;
  44146. while (true) {
  44147. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44148. stepper.breakIt(i, continueCallback);
  44149. return i;
  44150. }
  44151. fnId = fnArray[i];
  44152. if (fnId !== OPS.dependency) {
  44153. this[fnId].apply(this, argsArray[i]);
  44154. } else {
  44155. var deps = argsArray[i];
  44156. for (var n = 0, nn = deps.length; n < nn; n++) {
  44157. var depObjId = deps[n];
  44158. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44159. var objsPool = common ? commonObjs : objs;
  44160. if (!objsPool.isResolved(depObjId)) {
  44161. objsPool.get(depObjId, continueCallback);
  44162. return i;
  44163. }
  44164. }
  44165. }
  44166. i++;
  44167. if (i === argsArrayLen) {
  44168. return i;
  44169. }
  44170. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44171. if (Date.now() > endTime) {
  44172. continueCallback();
  44173. return i;
  44174. }
  44175. steps = 0;
  44176. }
  44177. }
  44178. },
  44179. endDrawing: function CanvasGraphics_endDrawing() {
  44180. if (this.current.activeSMask !== null) {
  44181. this.endSMaskGroup();
  44182. }
  44183. this.ctx.restore();
  44184. if (this.transparentCanvas) {
  44185. this.ctx = this.compositeCtx;
  44186. this.ctx.save();
  44187. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44188. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44189. this.ctx.restore();
  44190. this.transparentCanvas = null;
  44191. }
  44192. this.cachedCanvases.clear();
  44193. WebGLUtils.clear();
  44194. if (this.imageLayer) {
  44195. this.imageLayer.endLayout();
  44196. }
  44197. },
  44198. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44199. this.current.lineWidth = width;
  44200. this.ctx.lineWidth = width;
  44201. },
  44202. setLineCap: function CanvasGraphics_setLineCap(style) {
  44203. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44204. },
  44205. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44206. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44207. },
  44208. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44209. this.ctx.miterLimit = limit;
  44210. },
  44211. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44212. var ctx = this.ctx;
  44213. if (ctx.setLineDash !== undefined) {
  44214. ctx.setLineDash(dashArray);
  44215. ctx.lineDashOffset = dashPhase;
  44216. }
  44217. },
  44218. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44219. },
  44220. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44221. },
  44222. setGState: function CanvasGraphics_setGState(states) {
  44223. for (var i = 0, ii = states.length; i < ii; i++) {
  44224. var state = states[i];
  44225. var key = state[0];
  44226. var value = state[1];
  44227. switch (key) {
  44228. case 'LW':
  44229. this.setLineWidth(value);
  44230. break;
  44231. case 'LC':
  44232. this.setLineCap(value);
  44233. break;
  44234. case 'LJ':
  44235. this.setLineJoin(value);
  44236. break;
  44237. case 'ML':
  44238. this.setMiterLimit(value);
  44239. break;
  44240. case 'D':
  44241. this.setDash(value[0], value[1]);
  44242. break;
  44243. case 'RI':
  44244. this.setRenderingIntent(value);
  44245. break;
  44246. case 'FL':
  44247. this.setFlatness(value);
  44248. break;
  44249. case 'Font':
  44250. this.setFont(value[0], value[1]);
  44251. break;
  44252. case 'CA':
  44253. this.current.strokeAlpha = state[1];
  44254. break;
  44255. case 'ca':
  44256. this.current.fillAlpha = state[1];
  44257. this.ctx.globalAlpha = state[1];
  44258. break;
  44259. case 'BM':
  44260. if (value && value.name && value.name !== 'Normal') {
  44261. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44262. return '-' + c.toLowerCase();
  44263. }).substring(1);
  44264. this.ctx.globalCompositeOperation = mode;
  44265. if (this.ctx.globalCompositeOperation !== mode) {
  44266. warn('globalCompositeOperation "' + mode + '" is not supported');
  44267. }
  44268. } else {
  44269. this.ctx.globalCompositeOperation = 'source-over';
  44270. }
  44271. break;
  44272. case 'SMask':
  44273. if (this.current.activeSMask) {
  44274. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44275. this.suspendSMaskGroup();
  44276. } else {
  44277. this.endSMaskGroup();
  44278. }
  44279. }
  44280. this.current.activeSMask = value ? this.tempSMask : null;
  44281. if (this.current.activeSMask) {
  44282. this.beginSMaskGroup();
  44283. }
  44284. this.tempSMask = null;
  44285. break;
  44286. }
  44287. }
  44288. },
  44289. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44290. var activeSMask = this.current.activeSMask;
  44291. var drawnWidth = activeSMask.canvas.width;
  44292. var drawnHeight = activeSMask.canvas.height;
  44293. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44294. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44295. var currentCtx = this.ctx;
  44296. var currentTransform = currentCtx.mozCurrentTransform;
  44297. this.ctx.save();
  44298. var groupCtx = scratchCanvas.context;
  44299. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44300. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44301. groupCtx.transform.apply(groupCtx, currentTransform);
  44302. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44303. copyCtxState(currentCtx, groupCtx);
  44304. this.ctx = groupCtx;
  44305. this.setGState([
  44306. [
  44307. 'BM',
  44308. 'Normal'
  44309. ],
  44310. [
  44311. 'ca',
  44312. 1
  44313. ],
  44314. [
  44315. 'CA',
  44316. 1
  44317. ]
  44318. ]);
  44319. this.groupStack.push(currentCtx);
  44320. this.groupLevel++;
  44321. },
  44322. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44323. var groupCtx = this.ctx;
  44324. this.groupLevel--;
  44325. this.ctx = this.groupStack.pop();
  44326. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44327. this.ctx.restore();
  44328. this.ctx.save();
  44329. copyCtxState(groupCtx, this.ctx);
  44330. this.current.resumeSMaskCtx = groupCtx;
  44331. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44332. this.ctx.transform.apply(this.ctx, deltaTransform);
  44333. groupCtx.save();
  44334. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44335. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44336. groupCtx.restore();
  44337. },
  44338. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44339. var groupCtx = this.current.resumeSMaskCtx;
  44340. var currentCtx = this.ctx;
  44341. this.ctx = groupCtx;
  44342. this.groupStack.push(currentCtx);
  44343. this.groupLevel++;
  44344. },
  44345. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44346. var groupCtx = this.ctx;
  44347. this.groupLevel--;
  44348. this.ctx = this.groupStack.pop();
  44349. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44350. this.ctx.restore();
  44351. copyCtxState(groupCtx, this.ctx);
  44352. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44353. this.ctx.transform.apply(this.ctx, deltaTransform);
  44354. },
  44355. save: function CanvasGraphics_save() {
  44356. this.ctx.save();
  44357. var old = this.current;
  44358. this.stateStack.push(old);
  44359. this.current = old.clone();
  44360. this.current.resumeSMaskCtx = null;
  44361. },
  44362. restore: function CanvasGraphics_restore() {
  44363. if (this.current.resumeSMaskCtx) {
  44364. this.resumeSMaskGroup();
  44365. }
  44366. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44367. this.endSMaskGroup();
  44368. }
  44369. if (this.stateStack.length !== 0) {
  44370. this.current = this.stateStack.pop();
  44371. this.ctx.restore();
  44372. this.pendingClip = null;
  44373. this.cachedGetSinglePixelWidth = null;
  44374. }
  44375. },
  44376. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44377. this.ctx.transform(a, b, c, d, e, f);
  44378. this.cachedGetSinglePixelWidth = null;
  44379. },
  44380. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44381. var ctx = this.ctx;
  44382. var current = this.current;
  44383. var x = current.x, y = current.y;
  44384. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44385. switch (ops[i] | 0) {
  44386. case OPS.rectangle:
  44387. x = args[j++];
  44388. y = args[j++];
  44389. var width = args[j++];
  44390. var height = args[j++];
  44391. if (width === 0) {
  44392. width = this.getSinglePixelWidth();
  44393. }
  44394. if (height === 0) {
  44395. height = this.getSinglePixelWidth();
  44396. }
  44397. var xw = x + width;
  44398. var yh = y + height;
  44399. this.ctx.moveTo(x, y);
  44400. this.ctx.lineTo(xw, y);
  44401. this.ctx.lineTo(xw, yh);
  44402. this.ctx.lineTo(x, yh);
  44403. this.ctx.lineTo(x, y);
  44404. this.ctx.closePath();
  44405. break;
  44406. case OPS.moveTo:
  44407. x = args[j++];
  44408. y = args[j++];
  44409. ctx.moveTo(x, y);
  44410. break;
  44411. case OPS.lineTo:
  44412. x = args[j++];
  44413. y = args[j++];
  44414. ctx.lineTo(x, y);
  44415. break;
  44416. case OPS.curveTo:
  44417. x = args[j + 4];
  44418. y = args[j + 5];
  44419. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44420. j += 6;
  44421. break;
  44422. case OPS.curveTo2:
  44423. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44424. x = args[j + 2];
  44425. y = args[j + 3];
  44426. j += 4;
  44427. break;
  44428. case OPS.curveTo3:
  44429. x = args[j + 2];
  44430. y = args[j + 3];
  44431. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44432. j += 4;
  44433. break;
  44434. case OPS.closePath:
  44435. ctx.closePath();
  44436. break;
  44437. }
  44438. }
  44439. current.setCurrentPoint(x, y);
  44440. },
  44441. closePath: function CanvasGraphics_closePath() {
  44442. this.ctx.closePath();
  44443. },
  44444. stroke: function CanvasGraphics_stroke(consumePath) {
  44445. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44446. var ctx = this.ctx;
  44447. var strokeColor = this.current.strokeColor;
  44448. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44449. ctx.globalAlpha = this.current.strokeAlpha;
  44450. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44451. ctx.save();
  44452. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44453. ctx.stroke();
  44454. ctx.restore();
  44455. } else {
  44456. ctx.stroke();
  44457. }
  44458. if (consumePath) {
  44459. this.consumePath();
  44460. }
  44461. ctx.globalAlpha = this.current.fillAlpha;
  44462. },
  44463. closeStroke: function CanvasGraphics_closeStroke() {
  44464. this.closePath();
  44465. this.stroke();
  44466. },
  44467. fill: function CanvasGraphics_fill(consumePath) {
  44468. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44469. var ctx = this.ctx;
  44470. var fillColor = this.current.fillColor;
  44471. var isPatternFill = this.current.patternFill;
  44472. var needRestore = false;
  44473. if (isPatternFill) {
  44474. ctx.save();
  44475. if (this.baseTransform) {
  44476. ctx.setTransform.apply(ctx, this.baseTransform);
  44477. }
  44478. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44479. needRestore = true;
  44480. }
  44481. if (this.pendingEOFill) {
  44482. if (ctx.mozFillRule !== undefined) {
  44483. ctx.mozFillRule = 'evenodd';
  44484. ctx.fill();
  44485. ctx.mozFillRule = 'nonzero';
  44486. } else {
  44487. ctx.fill('evenodd');
  44488. }
  44489. this.pendingEOFill = false;
  44490. } else {
  44491. ctx.fill();
  44492. }
  44493. if (needRestore) {
  44494. ctx.restore();
  44495. }
  44496. if (consumePath) {
  44497. this.consumePath();
  44498. }
  44499. },
  44500. eoFill: function CanvasGraphics_eoFill() {
  44501. this.pendingEOFill = true;
  44502. this.fill();
  44503. },
  44504. fillStroke: function CanvasGraphics_fillStroke() {
  44505. this.fill(false);
  44506. this.stroke(false);
  44507. this.consumePath();
  44508. },
  44509. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44510. this.pendingEOFill = true;
  44511. this.fillStroke();
  44512. },
  44513. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44514. this.closePath();
  44515. this.fillStroke();
  44516. },
  44517. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44518. this.pendingEOFill = true;
  44519. this.closePath();
  44520. this.fillStroke();
  44521. },
  44522. endPath: function CanvasGraphics_endPath() {
  44523. this.consumePath();
  44524. },
  44525. clip: function CanvasGraphics_clip() {
  44526. this.pendingClip = NORMAL_CLIP;
  44527. },
  44528. eoClip: function CanvasGraphics_eoClip() {
  44529. this.pendingClip = EO_CLIP;
  44530. },
  44531. beginText: function CanvasGraphics_beginText() {
  44532. this.current.textMatrix = IDENTITY_MATRIX;
  44533. this.current.textMatrixScale = 1;
  44534. this.current.x = this.current.lineX = 0;
  44535. this.current.y = this.current.lineY = 0;
  44536. },
  44537. endText: function CanvasGraphics_endText() {
  44538. var paths = this.pendingTextPaths;
  44539. var ctx = this.ctx;
  44540. if (paths === undefined) {
  44541. ctx.beginPath();
  44542. return;
  44543. }
  44544. ctx.save();
  44545. ctx.beginPath();
  44546. for (var i = 0; i < paths.length; i++) {
  44547. var path = paths[i];
  44548. ctx.setTransform.apply(ctx, path.transform);
  44549. ctx.translate(path.x, path.y);
  44550. path.addToPath(ctx, path.fontSize);
  44551. }
  44552. ctx.restore();
  44553. ctx.clip();
  44554. ctx.beginPath();
  44555. delete this.pendingTextPaths;
  44556. },
  44557. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44558. this.current.charSpacing = spacing;
  44559. },
  44560. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44561. this.current.wordSpacing = spacing;
  44562. },
  44563. setHScale: function CanvasGraphics_setHScale(scale) {
  44564. this.current.textHScale = scale / 100;
  44565. },
  44566. setLeading: function CanvasGraphics_setLeading(leading) {
  44567. this.current.leading = -leading;
  44568. },
  44569. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44570. var fontObj = this.commonObjs.get(fontRefName);
  44571. var current = this.current;
  44572. if (!fontObj) {
  44573. error('Can\'t find font for ' + fontRefName);
  44574. }
  44575. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44576. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44577. warn('Invalid font matrix for font ' + fontRefName);
  44578. }
  44579. if (size < 0) {
  44580. size = -size;
  44581. current.fontDirection = -1;
  44582. } else {
  44583. current.fontDirection = 1;
  44584. }
  44585. this.current.font = fontObj;
  44586. this.current.fontSize = size;
  44587. if (fontObj.isType3Font) {
  44588. return;
  44589. }
  44590. var name = fontObj.loadedName || 'sans-serif';
  44591. var bold = fontObj.black ? fontObj.bold ? '900' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  44592. var italic = fontObj.italic ? 'italic' : 'normal';
  44593. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44594. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44595. this.current.fontSizeScale = size / browserFontSize;
  44596. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44597. this.ctx.font = rule;
  44598. },
  44599. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44600. this.current.textRenderingMode = mode;
  44601. },
  44602. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44603. this.current.textRise = rise;
  44604. },
  44605. moveText: function CanvasGraphics_moveText(x, y) {
  44606. this.current.x = this.current.lineX += x;
  44607. this.current.y = this.current.lineY += y;
  44608. },
  44609. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44610. this.setLeading(-y);
  44611. this.moveText(x, y);
  44612. },
  44613. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44614. this.current.textMatrix = [
  44615. a,
  44616. b,
  44617. c,
  44618. d,
  44619. e,
  44620. f
  44621. ];
  44622. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44623. this.current.x = this.current.lineX = 0;
  44624. this.current.y = this.current.lineY = 0;
  44625. },
  44626. nextLine: function CanvasGraphics_nextLine() {
  44627. this.moveText(0, this.current.leading);
  44628. },
  44629. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44630. var ctx = this.ctx;
  44631. var current = this.current;
  44632. var font = current.font;
  44633. var textRenderingMode = current.textRenderingMode;
  44634. var fontSize = current.fontSize / current.fontSizeScale;
  44635. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44636. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44637. var addToPath;
  44638. if (font.disableFontFace || isAddToPathSet) {
  44639. addToPath = font.getPathGenerator(this.commonObjs, character);
  44640. }
  44641. if (font.disableFontFace) {
  44642. ctx.save();
  44643. ctx.translate(x, y);
  44644. ctx.beginPath();
  44645. addToPath(ctx, fontSize);
  44646. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44647. ctx.fill();
  44648. }
  44649. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44650. ctx.stroke();
  44651. }
  44652. ctx.restore();
  44653. } else {
  44654. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44655. ctx.fillText(character, x, y);
  44656. }
  44657. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44658. ctx.strokeText(character, x, y);
  44659. }
  44660. }
  44661. if (isAddToPathSet) {
  44662. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44663. paths.push({
  44664. transform: ctx.mozCurrentTransform,
  44665. x: x,
  44666. y: y,
  44667. fontSize: fontSize,
  44668. addToPath: addToPath
  44669. });
  44670. }
  44671. },
  44672. get isFontSubpixelAAEnabled() {
  44673. var ctx = document.createElement('canvas').getContext('2d');
  44674. ctx.scale(1.5, 1);
  44675. ctx.fillText('I', 0, 10);
  44676. var data = ctx.getImageData(0, 0, 10, 10).data;
  44677. var enabled = false;
  44678. for (var i = 3; i < data.length; i += 4) {
  44679. if (data[i] > 0 && data[i] < 255) {
  44680. enabled = true;
  44681. break;
  44682. }
  44683. }
  44684. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44685. },
  44686. showText: function CanvasGraphics_showText(glyphs) {
  44687. var current = this.current;
  44688. var font = current.font;
  44689. if (font.isType3Font) {
  44690. return this.showType3Text(glyphs);
  44691. }
  44692. var fontSize = current.fontSize;
  44693. if (fontSize === 0) {
  44694. return;
  44695. }
  44696. var ctx = this.ctx;
  44697. var fontSizeScale = current.fontSizeScale;
  44698. var charSpacing = current.charSpacing;
  44699. var wordSpacing = current.wordSpacing;
  44700. var fontDirection = current.fontDirection;
  44701. var textHScale = current.textHScale * fontDirection;
  44702. var glyphsLength = glyphs.length;
  44703. var vertical = font.vertical;
  44704. var spacingDir = vertical ? 1 : -1;
  44705. var defaultVMetrics = font.defaultVMetrics;
  44706. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44707. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44708. ctx.save();
  44709. ctx.transform.apply(ctx, current.textMatrix);
  44710. ctx.translate(current.x, current.y + current.textRise);
  44711. if (current.patternFill) {
  44712. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44713. }
  44714. if (fontDirection > 0) {
  44715. ctx.scale(textHScale, -1);
  44716. } else {
  44717. ctx.scale(textHScale, 1);
  44718. }
  44719. var lineWidth = current.lineWidth;
  44720. var scale = current.textMatrixScale;
  44721. if (scale === 0 || lineWidth === 0) {
  44722. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44723. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44724. this.cachedGetSinglePixelWidth = null;
  44725. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44726. }
  44727. } else {
  44728. lineWidth /= scale;
  44729. }
  44730. if (fontSizeScale !== 1.0) {
  44731. ctx.scale(fontSizeScale, fontSizeScale);
  44732. lineWidth /= fontSizeScale;
  44733. }
  44734. ctx.lineWidth = lineWidth;
  44735. var x = 0, i;
  44736. for (i = 0; i < glyphsLength; ++i) {
  44737. var glyph = glyphs[i];
  44738. if (isNum(glyph)) {
  44739. x += spacingDir * glyph * fontSize / 1000;
  44740. continue;
  44741. }
  44742. var restoreNeeded = false;
  44743. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44744. var character = glyph.fontChar;
  44745. var accent = glyph.accent;
  44746. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44747. var width = glyph.width;
  44748. if (vertical) {
  44749. var vmetric, vx, vy;
  44750. vmetric = glyph.vmetric || defaultVMetrics;
  44751. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44752. vx = -vx * widthAdvanceScale;
  44753. vy = vmetric[2] * widthAdvanceScale;
  44754. width = vmetric ? -vmetric[0] : width;
  44755. scaledX = vx / fontSizeScale;
  44756. scaledY = (x + vy) / fontSizeScale;
  44757. } else {
  44758. scaledX = x / fontSizeScale;
  44759. scaledY = 0;
  44760. }
  44761. if (font.remeasure && width > 0) {
  44762. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44763. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44764. var characterScaleX = width / measuredWidth;
  44765. restoreNeeded = true;
  44766. ctx.save();
  44767. ctx.scale(characterScaleX, 1);
  44768. scaledX /= characterScaleX;
  44769. } else if (width !== measuredWidth) {
  44770. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44771. }
  44772. }
  44773. if (glyph.isInFont || font.missingFile) {
  44774. if (simpleFillText && !accent) {
  44775. ctx.fillText(character, scaledX, scaledY);
  44776. } else {
  44777. this.paintChar(character, scaledX, scaledY);
  44778. if (accent) {
  44779. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44780. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44781. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44782. }
  44783. }
  44784. }
  44785. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44786. x += charWidth;
  44787. if (restoreNeeded) {
  44788. ctx.restore();
  44789. }
  44790. }
  44791. if (vertical) {
  44792. current.y -= x * textHScale;
  44793. } else {
  44794. current.x += x * textHScale;
  44795. }
  44796. ctx.restore();
  44797. },
  44798. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44799. var ctx = this.ctx;
  44800. var current = this.current;
  44801. var font = current.font;
  44802. var fontSize = current.fontSize;
  44803. var fontDirection = current.fontDirection;
  44804. var spacingDir = font.vertical ? 1 : -1;
  44805. var charSpacing = current.charSpacing;
  44806. var wordSpacing = current.wordSpacing;
  44807. var textHScale = current.textHScale * fontDirection;
  44808. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44809. var glyphsLength = glyphs.length;
  44810. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44811. var i, glyph, width, spacingLength;
  44812. if (isTextInvisible || fontSize === 0) {
  44813. return;
  44814. }
  44815. this.cachedGetSinglePixelWidth = null;
  44816. ctx.save();
  44817. ctx.transform.apply(ctx, current.textMatrix);
  44818. ctx.translate(current.x, current.y);
  44819. ctx.scale(textHScale, fontDirection);
  44820. for (i = 0; i < glyphsLength; ++i) {
  44821. glyph = glyphs[i];
  44822. if (isNum(glyph)) {
  44823. spacingLength = spacingDir * glyph * fontSize / 1000;
  44824. this.ctx.translate(spacingLength, 0);
  44825. current.x += spacingLength * textHScale;
  44826. continue;
  44827. }
  44828. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44829. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  44830. if (!operatorList) {
  44831. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  44832. continue;
  44833. }
  44834. this.processingType3 = glyph;
  44835. this.save();
  44836. ctx.scale(fontSize, fontSize);
  44837. ctx.transform.apply(ctx, fontMatrix);
  44838. this.executeOperatorList(operatorList);
  44839. this.restore();
  44840. var transformed = Util.applyTransform([
  44841. glyph.width,
  44842. 0
  44843. ], fontMatrix);
  44844. width = transformed[0] * fontSize + spacing;
  44845. ctx.translate(width, 0);
  44846. current.x += width * textHScale;
  44847. }
  44848. ctx.restore();
  44849. this.processingType3 = null;
  44850. },
  44851. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  44852. },
  44853. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  44854. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  44855. this.clip();
  44856. this.endPath();
  44857. },
  44858. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  44859. var pattern;
  44860. if (IR[0] === 'TilingPattern') {
  44861. var color = IR[1];
  44862. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  44863. var self = this;
  44864. var canvasGraphicsFactory = {
  44865. createCanvasGraphics: function (ctx) {
  44866. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  44867. }
  44868. };
  44869. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  44870. } else {
  44871. pattern = getShadingPatternFromIR(IR);
  44872. }
  44873. return pattern;
  44874. },
  44875. setStrokeColorN: function CanvasGraphics_setStrokeColorN()
  44876. {
  44877. this.current.strokeColor = this.getColorN_Pattern(arguments);
  44878. },
  44879. setFillColorN: function CanvasGraphics_setFillColorN()
  44880. {
  44881. this.current.fillColor = this.getColorN_Pattern(arguments);
  44882. this.current.patternFill = true;
  44883. },
  44884. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  44885. var color = Util.makeCssRgb(r, g, b);
  44886. this.ctx.strokeStyle = color;
  44887. this.current.strokeColor = color;
  44888. },
  44889. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  44890. var color = Util.makeCssRgb(r, g, b);
  44891. this.ctx.fillStyle = color;
  44892. this.current.fillColor = color;
  44893. this.current.patternFill = false;
  44894. },
  44895. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  44896. var ctx = this.ctx;
  44897. this.save();
  44898. var pattern = getShadingPatternFromIR(patternIR);
  44899. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  44900. var inv = ctx.mozCurrentTransformInverse;
  44901. if (inv) {
  44902. var canvas = ctx.canvas;
  44903. var width = canvas.width;
  44904. var height = canvas.height;
  44905. var bl = Util.applyTransform([
  44906. 0,
  44907. 0
  44908. ], inv);
  44909. var br = Util.applyTransform([
  44910. 0,
  44911. height
  44912. ], inv);
  44913. var ul = Util.applyTransform([
  44914. width,
  44915. 0
  44916. ], inv);
  44917. var ur = Util.applyTransform([
  44918. width,
  44919. height
  44920. ], inv);
  44921. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  44922. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  44923. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  44924. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  44925. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  44926. } else {
  44927. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  44928. }
  44929. this.restore();
  44930. },
  44931. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  44932. error('Should not call beginInlineImage');
  44933. },
  44934. beginImageData: function CanvasGraphics_beginImageData() {
  44935. error('Should not call beginImageData');
  44936. },
  44937. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  44938. this.save();
  44939. this.baseTransformStack.push(this.baseTransform);
  44940. if (isArray(matrix) && 6 === matrix.length) {
  44941. this.transform.apply(this, matrix);
  44942. }
  44943. this.baseTransform = this.ctx.mozCurrentTransform;
  44944. if (isArray(bbox) && 4 === bbox.length) {
  44945. var width = bbox[2] - bbox[0];
  44946. var height = bbox[3] - bbox[1];
  44947. this.ctx.rect(bbox[0], bbox[1], width, height);
  44948. this.clip();
  44949. this.endPath();
  44950. }
  44951. },
  44952. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  44953. this.restore();
  44954. this.baseTransform = this.baseTransformStack.pop();
  44955. },
  44956. beginGroup: function CanvasGraphics_beginGroup(group) {
  44957. this.save();
  44958. var currentCtx = this.ctx;
  44959. if (!group.isolated) {
  44960. info('TODO: Support non-isolated groups.');
  44961. }
  44962. if (group.knockout) {
  44963. warn('Knockout groups not supported.');
  44964. }
  44965. var currentTransform = currentCtx.mozCurrentTransform;
  44966. if (group.matrix) {
  44967. currentCtx.transform.apply(currentCtx, group.matrix);
  44968. }
  44969. assert(group.bbox, 'Bounding box is required.');
  44970. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  44971. var canvasBounds = [
  44972. 0,
  44973. 0,
  44974. currentCtx.canvas.width,
  44975. currentCtx.canvas.height
  44976. ];
  44977. bounds = Util.intersect(bounds, canvasBounds) || [
  44978. 0,
  44979. 0,
  44980. 0,
  44981. 0
  44982. ];
  44983. var offsetX = Math.floor(bounds[0]);
  44984. var offsetY = Math.floor(bounds[1]);
  44985. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  44986. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  44987. var scaleX = 1, scaleY = 1;
  44988. if (drawnWidth > MAX_GROUP_SIZE) {
  44989. scaleX = drawnWidth / MAX_GROUP_SIZE;
  44990. drawnWidth = MAX_GROUP_SIZE;
  44991. }
  44992. if (drawnHeight > MAX_GROUP_SIZE) {
  44993. scaleY = drawnHeight / MAX_GROUP_SIZE;
  44994. drawnHeight = MAX_GROUP_SIZE;
  44995. }
  44996. var cacheId = 'groupAt' + this.groupLevel;
  44997. if (group.smask) {
  44998. cacheId += '_smask_' + this.smaskCounter++ % 2;
  44999. }
  45000. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45001. var groupCtx = scratchCanvas.context;
  45002. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45003. groupCtx.translate(-offsetX, -offsetY);
  45004. groupCtx.transform.apply(groupCtx, currentTransform);
  45005. if (group.smask) {
  45006. this.smaskStack.push({
  45007. canvas: scratchCanvas.canvas,
  45008. context: groupCtx,
  45009. offsetX: offsetX,
  45010. offsetY: offsetY,
  45011. scaleX: scaleX,
  45012. scaleY: scaleY,
  45013. subtype: group.smask.subtype,
  45014. backdrop: group.smask.backdrop,
  45015. transferMap: group.smask.transferMap || null,
  45016. startTransformInverse: null
  45017. });
  45018. } else
  45019. {
  45020. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45021. currentCtx.translate(offsetX, offsetY);
  45022. currentCtx.scale(scaleX, scaleY);
  45023. }
  45024. copyCtxState(currentCtx, groupCtx);
  45025. this.ctx = groupCtx;
  45026. this.setGState([
  45027. [
  45028. 'BM',
  45029. 'Normal'
  45030. ],
  45031. [
  45032. 'ca',
  45033. 1
  45034. ],
  45035. [
  45036. 'CA',
  45037. 1
  45038. ]
  45039. ]);
  45040. this.groupStack.push(currentCtx);
  45041. this.groupLevel++;
  45042. this.current.activeSMask = null;
  45043. },
  45044. endGroup: function CanvasGraphics_endGroup(group) {
  45045. this.groupLevel--;
  45046. var groupCtx = this.ctx;
  45047. this.ctx = this.groupStack.pop();
  45048. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45049. this.ctx.imageSmoothingEnabled = false;
  45050. } else {
  45051. this.ctx.mozImageSmoothingEnabled = false;
  45052. }
  45053. if (group.smask) {
  45054. this.tempSMask = this.smaskStack.pop();
  45055. } else {
  45056. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45057. }
  45058. this.restore();
  45059. },
  45060. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45061. this.save();
  45062. this.current = new CanvasExtraState();
  45063. if (this.baseTransform) {
  45064. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45065. }
  45066. },
  45067. endAnnotations: function CanvasGraphics_endAnnotations() {
  45068. this.restore();
  45069. },
  45070. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45071. this.save();
  45072. if (isArray(rect) && 4 === rect.length) {
  45073. var width = rect[2] - rect[0];
  45074. var height = rect[3] - rect[1];
  45075. this.ctx.rect(rect[0], rect[1], width, height);
  45076. this.clip();
  45077. this.endPath();
  45078. }
  45079. this.transform.apply(this, transform);
  45080. this.transform.apply(this, matrix);
  45081. },
  45082. endAnnotation: function CanvasGraphics_endAnnotation() {
  45083. this.restore();
  45084. },
  45085. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45086. var domImage = this.objs.get(objId);
  45087. if (!domImage) {
  45088. warn('Dependent image isn\'t ready yet');
  45089. return;
  45090. }
  45091. this.save();
  45092. var ctx = this.ctx;
  45093. ctx.scale(1 / w, -1 / h);
  45094. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45095. if (this.imageLayer) {
  45096. var currentTransform = ctx.mozCurrentTransformInverse;
  45097. var position = this.getCanvasPosition(0, 0);
  45098. this.imageLayer.appendImage({
  45099. objId: objId,
  45100. left: position[0],
  45101. top: position[1],
  45102. width: w / currentTransform[0],
  45103. height: h / currentTransform[3]
  45104. });
  45105. }
  45106. this.restore();
  45107. },
  45108. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45109. var ctx = this.ctx;
  45110. var width = img.width, height = img.height;
  45111. var fillColor = this.current.fillColor;
  45112. var isPatternFill = this.current.patternFill;
  45113. var glyph = this.processingType3;
  45114. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45115. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45116. glyph.compiled = compileType3Glyph({
  45117. data: img.data,
  45118. width: width,
  45119. height: height
  45120. });
  45121. } else {
  45122. glyph.compiled = null;
  45123. }
  45124. }
  45125. if (glyph && glyph.compiled) {
  45126. glyph.compiled(ctx);
  45127. return;
  45128. }
  45129. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45130. var maskCtx = maskCanvas.context;
  45131. maskCtx.save();
  45132. putBinaryImageMask(maskCtx, img);
  45133. maskCtx.globalCompositeOperation = 'source-in';
  45134. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45135. maskCtx.fillRect(0, 0, width, height);
  45136. maskCtx.restore();
  45137. this.paintInlineImageXObject(maskCanvas.canvas);
  45138. },
  45139. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45140. var width = imgData.width;
  45141. var height = imgData.height;
  45142. var fillColor = this.current.fillColor;
  45143. var isPatternFill = this.current.patternFill;
  45144. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45145. var maskCtx = maskCanvas.context;
  45146. maskCtx.save();
  45147. putBinaryImageMask(maskCtx, imgData);
  45148. maskCtx.globalCompositeOperation = 'source-in';
  45149. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45150. maskCtx.fillRect(0, 0, width, height);
  45151. maskCtx.restore();
  45152. var ctx = this.ctx;
  45153. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45154. ctx.save();
  45155. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45156. ctx.scale(1, -1);
  45157. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45158. ctx.restore();
  45159. }
  45160. },
  45161. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45162. var ctx = this.ctx;
  45163. var fillColor = this.current.fillColor;
  45164. var isPatternFill = this.current.patternFill;
  45165. for (var i = 0, ii = images.length; i < ii; i++) {
  45166. var image = images[i];
  45167. var width = image.width, height = image.height;
  45168. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45169. var maskCtx = maskCanvas.context;
  45170. maskCtx.save();
  45171. putBinaryImageMask(maskCtx, image);
  45172. maskCtx.globalCompositeOperation = 'source-in';
  45173. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45174. maskCtx.fillRect(0, 0, width, height);
  45175. maskCtx.restore();
  45176. ctx.save();
  45177. ctx.transform.apply(ctx, image.transform);
  45178. ctx.scale(1, -1);
  45179. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45180. ctx.restore();
  45181. }
  45182. },
  45183. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45184. var imgData = this.objs.get(objId);
  45185. if (!imgData) {
  45186. warn('Dependent image isn\'t ready yet');
  45187. return;
  45188. }
  45189. this.paintInlineImageXObject(imgData);
  45190. },
  45191. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45192. var imgData = this.objs.get(objId);
  45193. if (!imgData) {
  45194. warn('Dependent image isn\'t ready yet');
  45195. return;
  45196. }
  45197. var width = imgData.width;
  45198. var height = imgData.height;
  45199. var map = [];
  45200. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45201. map.push({
  45202. transform: [
  45203. scaleX,
  45204. 0,
  45205. 0,
  45206. scaleY,
  45207. positions[i],
  45208. positions[i + 1]
  45209. ],
  45210. x: 0,
  45211. y: 0,
  45212. w: width,
  45213. h: height
  45214. });
  45215. }
  45216. this.paintInlineImageXObjectGroup(imgData, map);
  45217. },
  45218. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45219. var width = imgData.width;
  45220. var height = imgData.height;
  45221. var ctx = this.ctx;
  45222. this.save();
  45223. ctx.scale(1 / width, -1 / height);
  45224. var currentTransform = ctx.mozCurrentTransformInverse;
  45225. var a = currentTransform[0], b = currentTransform[1];
  45226. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45227. var c = currentTransform[2], d = currentTransform[3];
  45228. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45229. var imgToPaint, tmpCanvas;
  45230. if (imgData instanceof HTMLElement || !imgData.data) {
  45231. imgToPaint = imgData;
  45232. } else {
  45233. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45234. var tmpCtx = tmpCanvas.context;
  45235. putBinaryImageData(tmpCtx, imgData);
  45236. imgToPaint = tmpCanvas.canvas;
  45237. }
  45238. var paintWidth = width, paintHeight = height;
  45239. var tmpCanvasId = 'prescale1';
  45240. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45241. var newWidth = paintWidth, newHeight = paintHeight;
  45242. if (widthScale > 2 && paintWidth > 1) {
  45243. newWidth = Math.ceil(paintWidth / 2);
  45244. widthScale /= paintWidth / newWidth;
  45245. }
  45246. if (heightScale > 2 && paintHeight > 1) {
  45247. newHeight = Math.ceil(paintHeight / 2);
  45248. heightScale /= paintHeight / newHeight;
  45249. }
  45250. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45251. tmpCtx = tmpCanvas.context;
  45252. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45253. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45254. imgToPaint = tmpCanvas.canvas;
  45255. paintWidth = newWidth;
  45256. paintHeight = newHeight;
  45257. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45258. }
  45259. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45260. if (this.imageLayer) {
  45261. var position = this.getCanvasPosition(0, -height);
  45262. this.imageLayer.appendImage({
  45263. imgData: imgData,
  45264. left: position[0],
  45265. top: position[1],
  45266. width: width / currentTransform[0],
  45267. height: height / currentTransform[3]
  45268. });
  45269. }
  45270. this.restore();
  45271. },
  45272. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45273. var ctx = this.ctx;
  45274. var w = imgData.width;
  45275. var h = imgData.height;
  45276. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45277. var tmpCtx = tmpCanvas.context;
  45278. putBinaryImageData(tmpCtx, imgData);
  45279. for (var i = 0, ii = map.length; i < ii; i++) {
  45280. var entry = map[i];
  45281. ctx.save();
  45282. ctx.transform.apply(ctx, entry.transform);
  45283. ctx.scale(1, -1);
  45284. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45285. if (this.imageLayer) {
  45286. var position = this.getCanvasPosition(entry.x, entry.y);
  45287. this.imageLayer.appendImage({
  45288. imgData: imgData,
  45289. left: position[0],
  45290. top: position[1],
  45291. width: w,
  45292. height: h
  45293. });
  45294. }
  45295. ctx.restore();
  45296. }
  45297. },
  45298. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45299. this.ctx.fillRect(0, 0, 1, 1);
  45300. },
  45301. paintXObject: function CanvasGraphics_paintXObject() {
  45302. warn('Unsupported \'paintXObject\' command.');
  45303. },
  45304. markPoint: function CanvasGraphics_markPoint(tag) {
  45305. },
  45306. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45307. },
  45308. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45309. },
  45310. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45311. },
  45312. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45313. },
  45314. beginCompat: function CanvasGraphics_beginCompat() {
  45315. },
  45316. endCompat: function CanvasGraphics_endCompat() {
  45317. },
  45318. consumePath: function CanvasGraphics_consumePath() {
  45319. var ctx = this.ctx;
  45320. if (this.pendingClip) {
  45321. if (this.pendingClip === EO_CLIP) {
  45322. if (ctx.mozFillRule !== undefined) {
  45323. ctx.mozFillRule = 'evenodd';
  45324. ctx.clip();
  45325. ctx.mozFillRule = 'nonzero';
  45326. } else {
  45327. ctx.clip('evenodd');
  45328. }
  45329. } else {
  45330. ctx.clip();
  45331. }
  45332. this.pendingClip = null;
  45333. }
  45334. ctx.beginPath();
  45335. },
  45336. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45337. if (this.cachedGetSinglePixelWidth === null) {
  45338. this.ctx.save();
  45339. var inverse = this.ctx.mozCurrentTransformInverse;
  45340. this.ctx.restore();
  45341. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45342. }
  45343. return this.cachedGetSinglePixelWidth;
  45344. },
  45345. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45346. var transform = this.ctx.mozCurrentTransform;
  45347. return [
  45348. transform[0] * x + transform[2] * y + transform[4],
  45349. transform[1] * x + transform[3] * y + transform[5]
  45350. ];
  45351. }
  45352. };
  45353. for (var op in OPS) {
  45354. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45355. }
  45356. return CanvasGraphics;
  45357. }();
  45358. exports.CanvasGraphics = CanvasGraphics;
  45359. exports.createScratchCanvas = createScratchCanvas;
  45360. }));
  45361. (function (root, factory) {
  45362. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45363. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45364. var error = sharedUtil.error;
  45365. var info = sharedUtil.info;
  45366. var isArray = sharedUtil.isArray;
  45367. var isBool = sharedUtil.isBool;
  45368. var isDict = corePrimitives.isDict;
  45369. var isStream = corePrimitives.isStream;
  45370. var PostScriptLexer = corePsParser.PostScriptLexer;
  45371. var PostScriptParser = corePsParser.PostScriptParser;
  45372. var PDFFunction = function PDFFunctionClosure() {
  45373. var CONSTRUCT_SAMPLED = 0;
  45374. var CONSTRUCT_INTERPOLATED = 2;
  45375. var CONSTRUCT_STICHED = 3;
  45376. var CONSTRUCT_POSTSCRIPT = 4;
  45377. return {
  45378. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45379. var i, ii;
  45380. var length = 1;
  45381. for (i = 0, ii = size.length; i < ii; i++) {
  45382. length *= size[i];
  45383. }
  45384. length *= outputSize;
  45385. var array = new Array(length);
  45386. var codeSize = 0;
  45387. var codeBuf = 0;
  45388. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45389. var strBytes = str.getBytes((length * bps + 7) / 8);
  45390. var strIdx = 0;
  45391. for (i = 0; i < length; i++) {
  45392. while (codeSize < bps) {
  45393. codeBuf <<= 8;
  45394. codeBuf |= strBytes[strIdx++];
  45395. codeSize += 8;
  45396. }
  45397. codeSize -= bps;
  45398. array[i] = (codeBuf >> codeSize) * sampleMul;
  45399. codeBuf &= (1 << codeSize) - 1;
  45400. }
  45401. return array;
  45402. },
  45403. getIR: function PDFFunction_getIR(xref, fn) {
  45404. var dict = fn.dict;
  45405. if (!dict) {
  45406. dict = fn;
  45407. }
  45408. var types = [
  45409. this.constructSampled,
  45410. null,
  45411. this.constructInterpolated,
  45412. this.constructStiched,
  45413. this.constructPostScript
  45414. ];
  45415. var typeNum = dict.get('FunctionType');
  45416. var typeFn = types[typeNum];
  45417. if (!typeFn) {
  45418. error('Unknown type of function');
  45419. }
  45420. return typeFn.call(this, fn, dict, xref);
  45421. },
  45422. fromIR: function PDFFunction_fromIR(IR) {
  45423. var type = IR[0];
  45424. switch (type) {
  45425. case CONSTRUCT_SAMPLED:
  45426. return this.constructSampledFromIR(IR);
  45427. case CONSTRUCT_INTERPOLATED:
  45428. return this.constructInterpolatedFromIR(IR);
  45429. case CONSTRUCT_STICHED:
  45430. return this.constructStichedFromIR(IR);
  45431. default:
  45432. return this.constructPostScriptFromIR(IR);
  45433. }
  45434. },
  45435. parse: function PDFFunction_parse(xref, fn) {
  45436. var IR = this.getIR(xref, fn);
  45437. return this.fromIR(IR);
  45438. },
  45439. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45440. if (!isArray(fnObj)) {
  45441. return this.parse(xref, fnObj);
  45442. }
  45443. var fnArray = [];
  45444. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45445. var obj = xref.fetchIfRef(fnObj[j]);
  45446. fnArray.push(PDFFunction.parse(xref, obj));
  45447. }
  45448. return function (src, srcOffset, dest, destOffset) {
  45449. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45450. fnArray[i](src, srcOffset, dest, destOffset + i);
  45451. }
  45452. };
  45453. },
  45454. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45455. function toMultiArray(arr) {
  45456. var inputLength = arr.length;
  45457. var out = [];
  45458. var index = 0;
  45459. for (var i = 0; i < inputLength; i += 2) {
  45460. out[index] = [
  45461. arr[i],
  45462. arr[i + 1]
  45463. ];
  45464. ++index;
  45465. }
  45466. return out;
  45467. }
  45468. var domain = dict.getArray('Domain');
  45469. var range = dict.getArray('Range');
  45470. if (!domain || !range) {
  45471. error('No domain or range');
  45472. }
  45473. var inputSize = domain.length / 2;
  45474. var outputSize = range.length / 2;
  45475. domain = toMultiArray(domain);
  45476. range = toMultiArray(range);
  45477. var size = dict.get('Size');
  45478. var bps = dict.get('BitsPerSample');
  45479. var order = dict.get('Order') || 1;
  45480. if (order !== 1) {
  45481. info('No support for cubic spline interpolation: ' + order);
  45482. }
  45483. var encode = dict.getArray('Encode');
  45484. if (!encode) {
  45485. encode = [];
  45486. for (var i = 0; i < inputSize; ++i) {
  45487. encode.push(0);
  45488. encode.push(size[i] - 1);
  45489. }
  45490. }
  45491. encode = toMultiArray(encode);
  45492. var decode = dict.getArray('Decode');
  45493. if (!decode) {
  45494. decode = range;
  45495. } else {
  45496. decode = toMultiArray(decode);
  45497. }
  45498. var samples = this.getSampleArray(size, outputSize, bps, str);
  45499. return [
  45500. CONSTRUCT_SAMPLED,
  45501. inputSize,
  45502. domain,
  45503. encode,
  45504. decode,
  45505. samples,
  45506. size,
  45507. outputSize,
  45508. Math.pow(2, bps) - 1,
  45509. range
  45510. ];
  45511. },
  45512. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45513. function interpolate(x, xmin, xmax, ymin, ymax) {
  45514. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45515. }
  45516. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45517. var m = IR[1];
  45518. var domain = IR[2];
  45519. var encode = IR[3];
  45520. var decode = IR[4];
  45521. var samples = IR[5];
  45522. var size = IR[6];
  45523. var n = IR[7];
  45524. var range = IR[9];
  45525. var cubeVertices = 1 << m;
  45526. var cubeN = new Float64Array(cubeVertices);
  45527. var cubeVertex = new Uint32Array(cubeVertices);
  45528. var i, j;
  45529. for (j = 0; j < cubeVertices; j++) {
  45530. cubeN[j] = 1;
  45531. }
  45532. var k = n, pos = 1;
  45533. for (i = 0; i < m; ++i) {
  45534. var domain_2i = domain[i][0];
  45535. var domain_2i_1 = domain[i][1];
  45536. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45537. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45538. var size_i = size[i];
  45539. e = Math.min(Math.max(e, 0), size_i - 1);
  45540. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45541. var n0 = e0 + 1 - e;
  45542. var n1 = e - e0;
  45543. var offset0 = e0 * k;
  45544. var offset1 = offset0 + k;
  45545. for (j = 0; j < cubeVertices; j++) {
  45546. if (j & pos) {
  45547. cubeN[j] *= n1;
  45548. cubeVertex[j] += offset1;
  45549. } else {
  45550. cubeN[j] *= n0;
  45551. cubeVertex[j] += offset0;
  45552. }
  45553. }
  45554. k *= size_i;
  45555. pos <<= 1;
  45556. }
  45557. for (j = 0; j < n; ++j) {
  45558. var rj = 0;
  45559. for (i = 0; i < cubeVertices; i++) {
  45560. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45561. }
  45562. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45563. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45564. }
  45565. };
  45566. },
  45567. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45568. var c0 = dict.getArray('C0') || [0];
  45569. var c1 = dict.getArray('C1') || [1];
  45570. var n = dict.get('N');
  45571. if (!isArray(c0) || !isArray(c1)) {
  45572. error('Illegal dictionary for interpolated function');
  45573. }
  45574. var length = c0.length;
  45575. var diff = [];
  45576. for (var i = 0; i < length; ++i) {
  45577. diff.push(c1[i] - c0[i]);
  45578. }
  45579. return [
  45580. CONSTRUCT_INTERPOLATED,
  45581. c0,
  45582. diff,
  45583. n
  45584. ];
  45585. },
  45586. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45587. var c0 = IR[1];
  45588. var diff = IR[2];
  45589. var n = IR[3];
  45590. var length = diff.length;
  45591. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45592. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45593. for (var j = 0; j < length; ++j) {
  45594. dest[destOffset + j] = c0[j] + x * diff[j];
  45595. }
  45596. };
  45597. },
  45598. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45599. var domain = dict.getArray('Domain');
  45600. if (!domain) {
  45601. error('No domain');
  45602. }
  45603. var inputSize = domain.length / 2;
  45604. if (inputSize !== 1) {
  45605. error('Bad domain for stiched function');
  45606. }
  45607. var fnRefs = dict.get('Functions');
  45608. var fns = [];
  45609. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45610. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45611. }
  45612. var bounds = dict.getArray('Bounds');
  45613. var encode = dict.getArray('Encode');
  45614. return [
  45615. CONSTRUCT_STICHED,
  45616. domain,
  45617. bounds,
  45618. encode,
  45619. fns
  45620. ];
  45621. },
  45622. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45623. var domain = IR[1];
  45624. var bounds = IR[2];
  45625. var encode = IR[3];
  45626. var fnsIR = IR[4];
  45627. var fns = [];
  45628. var tmpBuf = new Float32Array(1);
  45629. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45630. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45631. }
  45632. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45633. var clip = function constructStichedFromIRClip(v, min, max) {
  45634. if (v > max) {
  45635. v = max;
  45636. } else if (v < min) {
  45637. v = min;
  45638. }
  45639. return v;
  45640. };
  45641. var v = clip(src[srcOffset], domain[0], domain[1]);
  45642. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45643. if (v < bounds[i]) {
  45644. break;
  45645. }
  45646. }
  45647. var dmin = domain[0];
  45648. if (i > 0) {
  45649. dmin = bounds[i - 1];
  45650. }
  45651. var dmax = domain[1];
  45652. if (i < bounds.length) {
  45653. dmax = bounds[i];
  45654. }
  45655. var rmin = encode[2 * i];
  45656. var rmax = encode[2 * i + 1];
  45657. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45658. fns[i](tmpBuf, 0, dest, destOffset);
  45659. };
  45660. },
  45661. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45662. var domain = dict.getArray('Domain');
  45663. var range = dict.getArray('Range');
  45664. if (!domain) {
  45665. error('No domain.');
  45666. }
  45667. if (!range) {
  45668. error('No range.');
  45669. }
  45670. var lexer = new PostScriptLexer(fn);
  45671. var parser = new PostScriptParser(lexer);
  45672. var code = parser.parse();
  45673. return [
  45674. CONSTRUCT_POSTSCRIPT,
  45675. domain,
  45676. range,
  45677. code
  45678. ];
  45679. },
  45680. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45681. var domain = IR[1];
  45682. var range = IR[2];
  45683. var code = IR[3];
  45684. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45685. if (compiled) {
  45686. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45687. }
  45688. info('Unable to compile PS function');
  45689. var numOutputs = range.length >> 1;
  45690. var numInputs = domain.length >> 1;
  45691. var evaluator = new PostScriptEvaluator(code);
  45692. var cache = Object.create(null);
  45693. var MAX_CACHE_SIZE = 2048 * 4;
  45694. var cache_available = MAX_CACHE_SIZE;
  45695. var tmpBuf = new Float32Array(numInputs);
  45696. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45697. var i, value;
  45698. var key = '';
  45699. var input = tmpBuf;
  45700. for (i = 0; i < numInputs; i++) {
  45701. value = src[srcOffset + i];
  45702. input[i] = value;
  45703. key += value + '_';
  45704. }
  45705. var cachedValue = cache[key];
  45706. if (cachedValue !== undefined) {
  45707. dest.set(cachedValue, destOffset);
  45708. return;
  45709. }
  45710. var output = new Float32Array(numOutputs);
  45711. var stack = evaluator.execute(input);
  45712. var stackIndex = stack.length - numOutputs;
  45713. for (i = 0; i < numOutputs; i++) {
  45714. value = stack[stackIndex + i];
  45715. var bound = range[i * 2];
  45716. if (value < bound) {
  45717. value = bound;
  45718. } else {
  45719. bound = range[i * 2 + 1];
  45720. if (value > bound) {
  45721. value = bound;
  45722. }
  45723. }
  45724. output[i] = value;
  45725. }
  45726. if (cache_available > 0) {
  45727. cache_available--;
  45728. cache[key] = output;
  45729. }
  45730. dest.set(output, destOffset);
  45731. };
  45732. }
  45733. };
  45734. }();
  45735. function isPDFFunction(v) {
  45736. var fnDict;
  45737. if (typeof v !== 'object') {
  45738. return false;
  45739. } else if (isDict(v)) {
  45740. fnDict = v;
  45741. } else if (isStream(v)) {
  45742. fnDict = v.dict;
  45743. } else {
  45744. return false;
  45745. }
  45746. return fnDict.has('FunctionType');
  45747. }
  45748. var PostScriptStack = function PostScriptStackClosure() {
  45749. var MAX_STACK_SIZE = 100;
  45750. function PostScriptStack(initialStack) {
  45751. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45752. }
  45753. PostScriptStack.prototype = {
  45754. push: function PostScriptStack_push(value) {
  45755. if (this.stack.length >= MAX_STACK_SIZE) {
  45756. error('PostScript function stack overflow.');
  45757. }
  45758. this.stack.push(value);
  45759. },
  45760. pop: function PostScriptStack_pop() {
  45761. if (this.stack.length <= 0) {
  45762. error('PostScript function stack underflow.');
  45763. }
  45764. return this.stack.pop();
  45765. },
  45766. copy: function PostScriptStack_copy(n) {
  45767. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45768. error('PostScript function stack overflow.');
  45769. }
  45770. var stack = this.stack;
  45771. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45772. stack.push(stack[i]);
  45773. }
  45774. },
  45775. index: function PostScriptStack_index(n) {
  45776. this.push(this.stack[this.stack.length - n - 1]);
  45777. },
  45778. roll: function PostScriptStack_roll(n, p) {
  45779. var stack = this.stack;
  45780. var l = stack.length - n;
  45781. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45782. for (i = l, j = r; i < j; i++, j--) {
  45783. t = stack[i];
  45784. stack[i] = stack[j];
  45785. stack[j] = t;
  45786. }
  45787. for (i = l, j = c - 1; i < j; i++, j--) {
  45788. t = stack[i];
  45789. stack[i] = stack[j];
  45790. stack[j] = t;
  45791. }
  45792. for (i = c, j = r; i < j; i++, j--) {
  45793. t = stack[i];
  45794. stack[i] = stack[j];
  45795. stack[j] = t;
  45796. }
  45797. }
  45798. };
  45799. return PostScriptStack;
  45800. }();
  45801. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45802. function PostScriptEvaluator(operators) {
  45803. this.operators = operators;
  45804. }
  45805. PostScriptEvaluator.prototype = {
  45806. execute: function PostScriptEvaluator_execute(initialStack) {
  45807. var stack = new PostScriptStack(initialStack);
  45808. var counter = 0;
  45809. var operators = this.operators;
  45810. var length = operators.length;
  45811. var operator, a, b;
  45812. while (counter < length) {
  45813. operator = operators[counter++];
  45814. if (typeof operator === 'number') {
  45815. stack.push(operator);
  45816. continue;
  45817. }
  45818. switch (operator) {
  45819. case 'jz':
  45820. b = stack.pop();
  45821. a = stack.pop();
  45822. if (!a) {
  45823. counter = b;
  45824. }
  45825. break;
  45826. case 'j':
  45827. a = stack.pop();
  45828. counter = a;
  45829. break;
  45830. case 'abs':
  45831. a = stack.pop();
  45832. stack.push(Math.abs(a));
  45833. break;
  45834. case 'add':
  45835. b = stack.pop();
  45836. a = stack.pop();
  45837. stack.push(a + b);
  45838. break;
  45839. case 'and':
  45840. b = stack.pop();
  45841. a = stack.pop();
  45842. if (isBool(a) && isBool(b)) {
  45843. stack.push(a && b);
  45844. } else {
  45845. stack.push(a & b);
  45846. }
  45847. break;
  45848. case 'atan':
  45849. a = stack.pop();
  45850. stack.push(Math.atan(a));
  45851. break;
  45852. case 'bitshift':
  45853. b = stack.pop();
  45854. a = stack.pop();
  45855. if (a > 0) {
  45856. stack.push(a << b);
  45857. } else {
  45858. stack.push(a >> b);
  45859. }
  45860. break;
  45861. case 'ceiling':
  45862. a = stack.pop();
  45863. stack.push(Math.ceil(a));
  45864. break;
  45865. case 'copy':
  45866. a = stack.pop();
  45867. stack.copy(a);
  45868. break;
  45869. case 'cos':
  45870. a = stack.pop();
  45871. stack.push(Math.cos(a));
  45872. break;
  45873. case 'cvi':
  45874. a = stack.pop() | 0;
  45875. stack.push(a);
  45876. break;
  45877. case 'cvr':
  45878. break;
  45879. case 'div':
  45880. b = stack.pop();
  45881. a = stack.pop();
  45882. stack.push(a / b);
  45883. break;
  45884. case 'dup':
  45885. stack.copy(1);
  45886. break;
  45887. case 'eq':
  45888. b = stack.pop();
  45889. a = stack.pop();
  45890. stack.push(a === b);
  45891. break;
  45892. case 'exch':
  45893. stack.roll(2, 1);
  45894. break;
  45895. case 'exp':
  45896. b = stack.pop();
  45897. a = stack.pop();
  45898. stack.push(Math.pow(a, b));
  45899. break;
  45900. case 'false':
  45901. stack.push(false);
  45902. break;
  45903. case 'floor':
  45904. a = stack.pop();
  45905. stack.push(Math.floor(a));
  45906. break;
  45907. case 'ge':
  45908. b = stack.pop();
  45909. a = stack.pop();
  45910. stack.push(a >= b);
  45911. break;
  45912. case 'gt':
  45913. b = stack.pop();
  45914. a = stack.pop();
  45915. stack.push(a > b);
  45916. break;
  45917. case 'idiv':
  45918. b = stack.pop();
  45919. a = stack.pop();
  45920. stack.push(a / b | 0);
  45921. break;
  45922. case 'index':
  45923. a = stack.pop();
  45924. stack.index(a);
  45925. break;
  45926. case 'le':
  45927. b = stack.pop();
  45928. a = stack.pop();
  45929. stack.push(a <= b);
  45930. break;
  45931. case 'ln':
  45932. a = stack.pop();
  45933. stack.push(Math.log(a));
  45934. break;
  45935. case 'log':
  45936. a = stack.pop();
  45937. stack.push(Math.log(a) / Math.LN10);
  45938. break;
  45939. case 'lt':
  45940. b = stack.pop();
  45941. a = stack.pop();
  45942. stack.push(a < b);
  45943. break;
  45944. case 'mod':
  45945. b = stack.pop();
  45946. a = stack.pop();
  45947. stack.push(a % b);
  45948. break;
  45949. case 'mul':
  45950. b = stack.pop();
  45951. a = stack.pop();
  45952. stack.push(a * b);
  45953. break;
  45954. case 'ne':
  45955. b = stack.pop();
  45956. a = stack.pop();
  45957. stack.push(a !== b);
  45958. break;
  45959. case 'neg':
  45960. a = stack.pop();
  45961. stack.push(-a);
  45962. break;
  45963. case 'not':
  45964. a = stack.pop();
  45965. if (isBool(a)) {
  45966. stack.push(!a);
  45967. } else {
  45968. stack.push(~a);
  45969. }
  45970. break;
  45971. case 'or':
  45972. b = stack.pop();
  45973. a = stack.pop();
  45974. if (isBool(a) && isBool(b)) {
  45975. stack.push(a || b);
  45976. } else {
  45977. stack.push(a | b);
  45978. }
  45979. break;
  45980. case 'pop':
  45981. stack.pop();
  45982. break;
  45983. case 'roll':
  45984. b = stack.pop();
  45985. a = stack.pop();
  45986. stack.roll(a, b);
  45987. break;
  45988. case 'round':
  45989. a = stack.pop();
  45990. stack.push(Math.round(a));
  45991. break;
  45992. case 'sin':
  45993. a = stack.pop();
  45994. stack.push(Math.sin(a));
  45995. break;
  45996. case 'sqrt':
  45997. a = stack.pop();
  45998. stack.push(Math.sqrt(a));
  45999. break;
  46000. case 'sub':
  46001. b = stack.pop();
  46002. a = stack.pop();
  46003. stack.push(a - b);
  46004. break;
  46005. case 'true':
  46006. stack.push(true);
  46007. break;
  46008. case 'truncate':
  46009. a = stack.pop();
  46010. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46011. stack.push(a);
  46012. break;
  46013. case 'xor':
  46014. b = stack.pop();
  46015. a = stack.pop();
  46016. if (isBool(a) && isBool(b)) {
  46017. stack.push(a !== b);
  46018. } else {
  46019. stack.push(a ^ b);
  46020. }
  46021. break;
  46022. default:
  46023. error('Unknown operator ' + operator);
  46024. break;
  46025. }
  46026. }
  46027. return stack.stack;
  46028. }
  46029. };
  46030. return PostScriptEvaluator;
  46031. }();
  46032. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46033. function AstNode(type) {
  46034. this.type = type;
  46035. }
  46036. AstNode.prototype.visit = function (visitor) {
  46037. throw new Error('abstract method');
  46038. };
  46039. function AstArgument(index, min, max) {
  46040. AstNode.call(this, 'args');
  46041. this.index = index;
  46042. this.min = min;
  46043. this.max = max;
  46044. }
  46045. AstArgument.prototype = Object.create(AstNode.prototype);
  46046. AstArgument.prototype.visit = function (visitor) {
  46047. visitor.visitArgument(this);
  46048. };
  46049. function AstLiteral(number) {
  46050. AstNode.call(this, 'literal');
  46051. this.number = number;
  46052. this.min = number;
  46053. this.max = number;
  46054. }
  46055. AstLiteral.prototype = Object.create(AstNode.prototype);
  46056. AstLiteral.prototype.visit = function (visitor) {
  46057. visitor.visitLiteral(this);
  46058. };
  46059. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46060. AstNode.call(this, 'binary');
  46061. this.op = op;
  46062. this.arg1 = arg1;
  46063. this.arg2 = arg2;
  46064. this.min = min;
  46065. this.max = max;
  46066. }
  46067. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46068. AstBinaryOperation.prototype.visit = function (visitor) {
  46069. visitor.visitBinaryOperation(this);
  46070. };
  46071. function AstMin(arg, max) {
  46072. AstNode.call(this, 'max');
  46073. this.arg = arg;
  46074. this.min = arg.min;
  46075. this.max = max;
  46076. }
  46077. AstMin.prototype = Object.create(AstNode.prototype);
  46078. AstMin.prototype.visit = function (visitor) {
  46079. visitor.visitMin(this);
  46080. };
  46081. function AstVariable(index, min, max) {
  46082. AstNode.call(this, 'var');
  46083. this.index = index;
  46084. this.min = min;
  46085. this.max = max;
  46086. }
  46087. AstVariable.prototype = Object.create(AstNode.prototype);
  46088. AstVariable.prototype.visit = function (visitor) {
  46089. visitor.visitVariable(this);
  46090. };
  46091. function AstVariableDefinition(variable, arg) {
  46092. AstNode.call(this, 'definition');
  46093. this.variable = variable;
  46094. this.arg = arg;
  46095. }
  46096. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46097. AstVariableDefinition.prototype.visit = function (visitor) {
  46098. visitor.visitVariableDefinition(this);
  46099. };
  46100. function ExpressionBuilderVisitor() {
  46101. this.parts = [];
  46102. }
  46103. ExpressionBuilderVisitor.prototype = {
  46104. visitArgument: function (arg) {
  46105. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46106. },
  46107. visitVariable: function (variable) {
  46108. this.parts.push('v', variable.index);
  46109. },
  46110. visitLiteral: function (literal) {
  46111. this.parts.push(literal.number);
  46112. },
  46113. visitBinaryOperation: function (operation) {
  46114. this.parts.push('(');
  46115. operation.arg1.visit(this);
  46116. this.parts.push(' ', operation.op, ' ');
  46117. operation.arg2.visit(this);
  46118. this.parts.push(')');
  46119. },
  46120. visitVariableDefinition: function (definition) {
  46121. this.parts.push('var ');
  46122. definition.variable.visit(this);
  46123. this.parts.push(' = ');
  46124. definition.arg.visit(this);
  46125. this.parts.push(';');
  46126. },
  46127. visitMin: function (max) {
  46128. this.parts.push('Math.min(');
  46129. max.arg.visit(this);
  46130. this.parts.push(', ', max.max, ')');
  46131. },
  46132. toString: function () {
  46133. return this.parts.join('');
  46134. }
  46135. };
  46136. function buildAddOperation(num1, num2) {
  46137. if (num2.type === 'literal' && num2.number === 0) {
  46138. return num1;
  46139. }
  46140. if (num1.type === 'literal' && num1.number === 0) {
  46141. return num2;
  46142. }
  46143. if (num2.type === 'literal' && num1.type === 'literal') {
  46144. return new AstLiteral(num1.number + num2.number);
  46145. }
  46146. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46147. }
  46148. function buildMulOperation(num1, num2) {
  46149. if (num2.type === 'literal') {
  46150. if (num2.number === 0) {
  46151. return new AstLiteral(0);
  46152. } else if (num2.number === 1) {
  46153. return num1;
  46154. } else if (num1.type === 'literal') {
  46155. return new AstLiteral(num1.number * num2.number);
  46156. }
  46157. }
  46158. if (num1.type === 'literal') {
  46159. if (num1.number === 0) {
  46160. return new AstLiteral(0);
  46161. } else if (num1.number === 1) {
  46162. return num2;
  46163. }
  46164. }
  46165. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46166. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46167. return new AstBinaryOperation('*', num1, num2, min, max);
  46168. }
  46169. function buildSubOperation(num1, num2) {
  46170. if (num2.type === 'literal') {
  46171. if (num2.number === 0) {
  46172. return num1;
  46173. } else if (num1.type === 'literal') {
  46174. return new AstLiteral(num1.number - num2.number);
  46175. }
  46176. }
  46177. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46178. return num2.arg2;
  46179. }
  46180. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46181. }
  46182. function buildMinOperation(num1, max) {
  46183. if (num1.min >= max) {
  46184. return new AstLiteral(max);
  46185. } else if (num1.max <= max) {
  46186. return num1;
  46187. }
  46188. return new AstMin(num1, max);
  46189. }
  46190. function PostScriptCompiler() {
  46191. }
  46192. PostScriptCompiler.prototype = {
  46193. compile: function PostScriptCompiler_compile(code, domain, range) {
  46194. var stack = [];
  46195. var i, ii;
  46196. var instructions = [];
  46197. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46198. var lastRegister = 0;
  46199. var n, j;
  46200. var num1, num2, ast1, ast2, tmpVar, item;
  46201. for (i = 0; i < inputSize; i++) {
  46202. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46203. }
  46204. for (i = 0, ii = code.length; i < ii; i++) {
  46205. item = code[i];
  46206. if (typeof item === 'number') {
  46207. stack.push(new AstLiteral(item));
  46208. continue;
  46209. }
  46210. switch (item) {
  46211. case 'add':
  46212. if (stack.length < 2) {
  46213. return null;
  46214. }
  46215. num2 = stack.pop();
  46216. num1 = stack.pop();
  46217. stack.push(buildAddOperation(num1, num2));
  46218. break;
  46219. case 'cvr':
  46220. if (stack.length < 1) {
  46221. return null;
  46222. }
  46223. break;
  46224. case 'mul':
  46225. if (stack.length < 2) {
  46226. return null;
  46227. }
  46228. num2 = stack.pop();
  46229. num1 = stack.pop();
  46230. stack.push(buildMulOperation(num1, num2));
  46231. break;
  46232. case 'sub':
  46233. if (stack.length < 2) {
  46234. return null;
  46235. }
  46236. num2 = stack.pop();
  46237. num1 = stack.pop();
  46238. stack.push(buildSubOperation(num1, num2));
  46239. break;
  46240. case 'exch':
  46241. if (stack.length < 2) {
  46242. return null;
  46243. }
  46244. ast1 = stack.pop();
  46245. ast2 = stack.pop();
  46246. stack.push(ast1, ast2);
  46247. break;
  46248. case 'pop':
  46249. if (stack.length < 1) {
  46250. return null;
  46251. }
  46252. stack.pop();
  46253. break;
  46254. case 'index':
  46255. if (stack.length < 1) {
  46256. return null;
  46257. }
  46258. num1 = stack.pop();
  46259. if (num1.type !== 'literal') {
  46260. return null;
  46261. }
  46262. n = num1.number;
  46263. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46264. return null;
  46265. }
  46266. ast1 = stack[stack.length - n - 1];
  46267. if (ast1.type === 'literal' || ast1.type === 'var') {
  46268. stack.push(ast1);
  46269. break;
  46270. }
  46271. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46272. stack[stack.length - n - 1] = tmpVar;
  46273. stack.push(tmpVar);
  46274. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46275. break;
  46276. case 'dup':
  46277. if (stack.length < 1) {
  46278. return null;
  46279. }
  46280. 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]) {
  46281. num1 = stack.pop();
  46282. stack.push(buildMinOperation(num1, code[i + 1]));
  46283. i += 6;
  46284. break;
  46285. }
  46286. ast1 = stack[stack.length - 1];
  46287. if (ast1.type === 'literal' || ast1.type === 'var') {
  46288. stack.push(ast1);
  46289. break;
  46290. }
  46291. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46292. stack[stack.length - 1] = tmpVar;
  46293. stack.push(tmpVar);
  46294. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46295. break;
  46296. case 'roll':
  46297. if (stack.length < 2) {
  46298. return null;
  46299. }
  46300. num2 = stack.pop();
  46301. num1 = stack.pop();
  46302. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46303. return null;
  46304. }
  46305. j = num2.number;
  46306. n = num1.number;
  46307. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46308. return null;
  46309. }
  46310. j = (j % n + n) % n;
  46311. if (j === 0) {
  46312. break;
  46313. }
  46314. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46315. break;
  46316. default:
  46317. return null;
  46318. }
  46319. }
  46320. if (stack.length !== outputSize) {
  46321. return null;
  46322. }
  46323. var result = [];
  46324. instructions.forEach(function (instruction) {
  46325. var statementBuilder = new ExpressionBuilderVisitor();
  46326. instruction.visit(statementBuilder);
  46327. result.push(statementBuilder.toString());
  46328. });
  46329. stack.forEach(function (expr, i) {
  46330. var statementBuilder = new ExpressionBuilderVisitor();
  46331. expr.visit(statementBuilder);
  46332. var min = range[i * 2], max = range[i * 2 + 1];
  46333. var out = [statementBuilder.toString()];
  46334. if (min > expr.min) {
  46335. out.unshift('Math.max(', min, ', ');
  46336. out.push(')');
  46337. }
  46338. if (max < expr.max) {
  46339. out.unshift('Math.min(', max, ', ');
  46340. out.push(')');
  46341. }
  46342. out.unshift('dest[destOffset + ', i, '] = ');
  46343. out.push(';');
  46344. result.push(out.join(''));
  46345. });
  46346. return result.join('\n');
  46347. }
  46348. };
  46349. return PostScriptCompiler;
  46350. }();
  46351. exports.isPDFFunction = isPDFFunction;
  46352. exports.PDFFunction = PDFFunction;
  46353. exports.PostScriptEvaluator = PostScriptEvaluator;
  46354. exports.PostScriptCompiler = PostScriptCompiler;
  46355. }));
  46356. (function (root, factory) {
  46357. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46358. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46359. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46360. var MessageHandler = sharedUtil.MessageHandler;
  46361. var MissingPDFException = sharedUtil.MissingPDFException;
  46362. var PageViewport = sharedUtil.PageViewport;
  46363. var PasswordResponses = sharedUtil.PasswordResponses;
  46364. var PasswordException = sharedUtil.PasswordException;
  46365. var StatTimer = sharedUtil.StatTimer;
  46366. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46367. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46368. var Util = sharedUtil.Util;
  46369. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46370. var error = sharedUtil.error;
  46371. var deprecated = sharedUtil.deprecated;
  46372. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46373. var info = sharedUtil.info;
  46374. var isInt = sharedUtil.isInt;
  46375. var isArray = sharedUtil.isArray;
  46376. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46377. var isSameOrigin = sharedUtil.isSameOrigin;
  46378. var loadJpegStream = sharedUtil.loadJpegStream;
  46379. var stringToBytes = sharedUtil.stringToBytes;
  46380. var globalScope = sharedUtil.globalScope;
  46381. var warn = sharedUtil.warn;
  46382. var FontFaceObject = displayFontLoader.FontFaceObject;
  46383. var FontLoader = displayFontLoader.FontLoader;
  46384. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46385. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46386. var Metadata = displayMetadata.Metadata;
  46387. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46388. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46389. var isWorkerDisabled = false;
  46390. var workerSrc;
  46391. var isPostMessageTransfersDisabled = false;
  46392. var fakeWorkerFilesLoader = null;
  46393. var useRequireEnsure = false;
  46394. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46395. var task = new PDFDocumentLoadingTask();
  46396. if (arguments.length > 1) {
  46397. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46398. }
  46399. if (pdfDataRangeTransport) {
  46400. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46401. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46402. pdfDataRangeTransport.length = src.length;
  46403. pdfDataRangeTransport.initialData = src.initialData;
  46404. if (!pdfDataRangeTransport.abort) {
  46405. pdfDataRangeTransport.abort = function () {
  46406. };
  46407. }
  46408. }
  46409. src = Object.create(src);
  46410. src.range = pdfDataRangeTransport;
  46411. }
  46412. task.onPassword = passwordCallback || null;
  46413. task.onProgress = progressCallback || null;
  46414. var source;
  46415. if (typeof src === 'string') {
  46416. source = { url: src };
  46417. } else if (isArrayBuffer(src)) {
  46418. source = { data: src };
  46419. } else if (src instanceof PDFDataRangeTransport) {
  46420. source = { range: src };
  46421. } else {
  46422. if (typeof src !== 'object') {
  46423. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46424. }
  46425. if (!src.url && !src.data && !src.range) {
  46426. error('Invalid parameter object: need either .data, .range or .url');
  46427. }
  46428. source = src;
  46429. }
  46430. var params = {};
  46431. var rangeTransport = null;
  46432. var worker = null;
  46433. for (var key in source) {
  46434. if (key === 'url' && typeof window !== 'undefined') {
  46435. params[key] = new URL(source[key], window.location).href;
  46436. continue;
  46437. } else if (key === 'range') {
  46438. rangeTransport = source[key];
  46439. continue;
  46440. } else if (key === 'worker') {
  46441. worker = source[key];
  46442. continue;
  46443. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46444. var pdfBytes = source[key];
  46445. if (typeof pdfBytes === 'string') {
  46446. params[key] = stringToBytes(pdfBytes);
  46447. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46448. params[key] = new Uint8Array(pdfBytes);
  46449. } else if (isArrayBuffer(pdfBytes)) {
  46450. params[key] = new Uint8Array(pdfBytes);
  46451. } else {
  46452. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46453. }
  46454. continue;
  46455. }
  46456. params[key] = source[key];
  46457. }
  46458. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46459. if (!worker) {
  46460. worker = new PDFWorker();
  46461. task._worker = worker;
  46462. }
  46463. var docId = task.docId;
  46464. worker.promise.then(function () {
  46465. if (task.destroyed) {
  46466. throw new Error('Loading aborted');
  46467. }
  46468. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46469. if (task.destroyed) {
  46470. throw new Error('Loading aborted');
  46471. }
  46472. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46473. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46474. task._transport = transport;
  46475. messageHandler.send('Ready', null);
  46476. });
  46477. }).catch(task._capability.reject);
  46478. return task;
  46479. }
  46480. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46481. if (worker.destroyed) {
  46482. return Promise.reject(new Error('Worker was destroyed'));
  46483. }
  46484. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46485. source.disableStream = getDefaultSetting('disableStream');
  46486. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46487. if (pdfDataRangeTransport) {
  46488. source.length = pdfDataRangeTransport.length;
  46489. source.initialData = pdfDataRangeTransport.initialData;
  46490. }
  46491. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46492. docId: docId,
  46493. source: source,
  46494. disableRange: getDefaultSetting('disableRange'),
  46495. maxImageSize: getDefaultSetting('maxImageSize'),
  46496. cMapUrl: getDefaultSetting('cMapUrl'),
  46497. cMapPacked: getDefaultSetting('cMapPacked'),
  46498. disableFontFace: getDefaultSetting('disableFontFace'),
  46499. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46500. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46501. docBaseUrl: source.docBaseUrl
  46502. }).then(function (workerId) {
  46503. if (worker.destroyed) {
  46504. throw new Error('Worker was destroyed');
  46505. }
  46506. return workerId;
  46507. });
  46508. }
  46509. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46510. var nextDocumentId = 0;
  46511. function PDFDocumentLoadingTask() {
  46512. this._capability = createPromiseCapability();
  46513. this._transport = null;
  46514. this._worker = null;
  46515. this.docId = 'd' + nextDocumentId++;
  46516. this.destroyed = false;
  46517. this.onPassword = null;
  46518. this.onProgress = null;
  46519. this.onUnsupportedFeature = null;
  46520. }
  46521. PDFDocumentLoadingTask.prototype = {
  46522. get promise() {
  46523. return this._capability.promise;
  46524. },
  46525. destroy: function () {
  46526. this.destroyed = true;
  46527. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46528. return transportDestroyed.then(function () {
  46529. this._transport = null;
  46530. if (this._worker) {
  46531. this._worker.destroy();
  46532. this._worker = null;
  46533. }
  46534. }.bind(this));
  46535. },
  46536. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46537. return this.promise.then.apply(this.promise, arguments);
  46538. }
  46539. };
  46540. return PDFDocumentLoadingTask;
  46541. }();
  46542. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46543. function PDFDataRangeTransport(length, initialData) {
  46544. this.length = length;
  46545. this.initialData = initialData;
  46546. this._rangeListeners = [];
  46547. this._progressListeners = [];
  46548. this._progressiveReadListeners = [];
  46549. this._readyCapability = createPromiseCapability();
  46550. }
  46551. PDFDataRangeTransport.prototype = {
  46552. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46553. this._rangeListeners.push(listener);
  46554. },
  46555. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46556. this._progressListeners.push(listener);
  46557. },
  46558. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46559. this._progressiveReadListeners.push(listener);
  46560. },
  46561. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46562. var listeners = this._rangeListeners;
  46563. for (var i = 0, n = listeners.length; i < n; ++i) {
  46564. listeners[i](begin, chunk);
  46565. }
  46566. },
  46567. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46568. this._readyCapability.promise.then(function () {
  46569. var listeners = this._progressListeners;
  46570. for (var i = 0, n = listeners.length; i < n; ++i) {
  46571. listeners[i](loaded);
  46572. }
  46573. }.bind(this));
  46574. },
  46575. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46576. this._readyCapability.promise.then(function () {
  46577. var listeners = this._progressiveReadListeners;
  46578. for (var i = 0, n = listeners.length; i < n; ++i) {
  46579. listeners[i](chunk);
  46580. }
  46581. }.bind(this));
  46582. },
  46583. transportReady: function PDFDataRangeTransport_transportReady() {
  46584. this._readyCapability.resolve();
  46585. },
  46586. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46587. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46588. },
  46589. abort: function PDFDataRangeTransport_abort() {
  46590. }
  46591. };
  46592. return PDFDataRangeTransport;
  46593. }();
  46594. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46595. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46596. this.pdfInfo = pdfInfo;
  46597. this.transport = transport;
  46598. this.loadingTask = loadingTask;
  46599. }
  46600. PDFDocumentProxy.prototype = {
  46601. get numPages() {
  46602. return this.pdfInfo.numPages;
  46603. },
  46604. get fingerprint() {
  46605. return this.pdfInfo.fingerprint;
  46606. },
  46607. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46608. return this.transport.getPage(pageNumber);
  46609. },
  46610. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46611. return this.transport.getPageIndex(ref);
  46612. },
  46613. getDestinations: function PDFDocumentProxy_getDestinations() {
  46614. return this.transport.getDestinations();
  46615. },
  46616. getDestination: function PDFDocumentProxy_getDestination(id) {
  46617. return this.transport.getDestination(id);
  46618. },
  46619. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46620. return this.transport.getPageLabels();
  46621. },
  46622. getAttachments: function PDFDocumentProxy_getAttachments() {
  46623. return this.transport.getAttachments();
  46624. },
  46625. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46626. return this.transport.getJavaScript();
  46627. },
  46628. getOutline: function PDFDocumentProxy_getOutline() {
  46629. return this.transport.getOutline();
  46630. },
  46631. getMetadata: function PDFDocumentProxy_getMetadata() {
  46632. return this.transport.getMetadata();
  46633. },
  46634. getData: function PDFDocumentProxy_getData() {
  46635. return this.transport.getData();
  46636. },
  46637. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46638. return this.transport.downloadInfoCapability.promise;
  46639. },
  46640. getStats: function PDFDocumentProxy_getStats() {
  46641. return this.transport.getStats();
  46642. },
  46643. cleanup: function PDFDocumentProxy_cleanup() {
  46644. this.transport.startCleanup();
  46645. },
  46646. destroy: function PDFDocumentProxy_destroy() {
  46647. return this.loadingTask.destroy();
  46648. }
  46649. };
  46650. return PDFDocumentProxy;
  46651. }();
  46652. var PDFPageProxy = function PDFPageProxyClosure() {
  46653. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46654. this.pageIndex = pageIndex;
  46655. this.pageInfo = pageInfo;
  46656. this.transport = transport;
  46657. this.stats = new StatTimer();
  46658. this.stats.enabled = getDefaultSetting('enableStats');
  46659. this.commonObjs = transport.commonObjs;
  46660. this.objs = new PDFObjects();
  46661. this.cleanupAfterRender = false;
  46662. this.pendingCleanup = false;
  46663. this.intentStates = Object.create(null);
  46664. this.destroyed = false;
  46665. }
  46666. PDFPageProxy.prototype = {
  46667. get pageNumber() {
  46668. return this.pageIndex + 1;
  46669. },
  46670. get rotate() {
  46671. return this.pageInfo.rotate;
  46672. },
  46673. get ref() {
  46674. return this.pageInfo.ref;
  46675. },
  46676. get view() {
  46677. return this.pageInfo.view;
  46678. },
  46679. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46680. if (arguments.length < 2) {
  46681. rotate = this.rotate;
  46682. }
  46683. return new PageViewport(this.view, scale, rotate, 0, 0);
  46684. },
  46685. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46686. var intent = params && params.intent || null;
  46687. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46688. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46689. this.annotationsIntent = intent;
  46690. }
  46691. return this.annotationsPromise;
  46692. },
  46693. render: function PDFPageProxy_render(params) {
  46694. var stats = this.stats;
  46695. stats.time('Overall');
  46696. this.pendingCleanup = false;
  46697. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46698. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46699. if (!this.intentStates[renderingIntent]) {
  46700. this.intentStates[renderingIntent] = Object.create(null);
  46701. }
  46702. var intentState = this.intentStates[renderingIntent];
  46703. if (!intentState.displayReadyCapability) {
  46704. intentState.receivingOperatorList = true;
  46705. intentState.displayReadyCapability = createPromiseCapability();
  46706. intentState.operatorList = {
  46707. fnArray: [],
  46708. argsArray: [],
  46709. lastChunk: false
  46710. };
  46711. this.stats.time('Page Request');
  46712. this.transport.messageHandler.send('RenderPageRequest', {
  46713. pageIndex: this.pageNumber - 1,
  46714. intent: renderingIntent,
  46715. renderInteractiveForms: renderInteractiveForms
  46716. });
  46717. }
  46718. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46719. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46720. if (!intentState.renderTasks) {
  46721. intentState.renderTasks = [];
  46722. }
  46723. intentState.renderTasks.push(internalRenderTask);
  46724. var renderTask = internalRenderTask.task;
  46725. if (params.continueCallback) {
  46726. deprecated('render is used with continueCallback parameter');
  46727. renderTask.onContinue = params.continueCallback;
  46728. }
  46729. var self = this;
  46730. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46731. if (self.pendingCleanup) {
  46732. complete();
  46733. return;
  46734. }
  46735. stats.time('Rendering');
  46736. internalRenderTask.initializeGraphics(transparency);
  46737. internalRenderTask.operatorListChanged();
  46738. }, function pageDisplayReadPromiseError(reason) {
  46739. complete(reason);
  46740. });
  46741. function complete(error) {
  46742. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46743. if (i >= 0) {
  46744. intentState.renderTasks.splice(i, 1);
  46745. }
  46746. if (self.cleanupAfterRender) {
  46747. self.pendingCleanup = true;
  46748. }
  46749. self._tryCleanup();
  46750. if (error) {
  46751. internalRenderTask.capability.reject(error);
  46752. } else {
  46753. internalRenderTask.capability.resolve();
  46754. }
  46755. stats.timeEnd('Rendering');
  46756. stats.timeEnd('Overall');
  46757. }
  46758. return renderTask;
  46759. },
  46760. getOperatorList: function PDFPageProxy_getOperatorList() {
  46761. function operatorListChanged() {
  46762. if (intentState.operatorList.lastChunk) {
  46763. intentState.opListReadCapability.resolve(intentState.operatorList);
  46764. var i = intentState.renderTasks.indexOf(opListTask);
  46765. if (i >= 0) {
  46766. intentState.renderTasks.splice(i, 1);
  46767. }
  46768. }
  46769. }
  46770. var renderingIntent = 'oplist';
  46771. if (!this.intentStates[renderingIntent]) {
  46772. this.intentStates[renderingIntent] = Object.create(null);
  46773. }
  46774. var intentState = this.intentStates[renderingIntent];
  46775. var opListTask;
  46776. if (!intentState.opListReadCapability) {
  46777. opListTask = {};
  46778. opListTask.operatorListChanged = operatorListChanged;
  46779. intentState.receivingOperatorList = true;
  46780. intentState.opListReadCapability = createPromiseCapability();
  46781. intentState.renderTasks = [];
  46782. intentState.renderTasks.push(opListTask);
  46783. intentState.operatorList = {
  46784. fnArray: [],
  46785. argsArray: [],
  46786. lastChunk: false
  46787. };
  46788. this.transport.messageHandler.send('RenderPageRequest', {
  46789. pageIndex: this.pageIndex,
  46790. intent: renderingIntent
  46791. });
  46792. }
  46793. return intentState.opListReadCapability.promise;
  46794. },
  46795. getTextContent: function PDFPageProxy_getTextContent(params) {
  46796. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46797. pageIndex: this.pageNumber - 1,
  46798. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46799. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46800. });
  46801. },
  46802. _destroy: function PDFPageProxy_destroy() {
  46803. this.destroyed = true;
  46804. this.transport.pageCache[this.pageIndex] = null;
  46805. var waitOn = [];
  46806. Object.keys(this.intentStates).forEach(function (intent) {
  46807. if (intent === 'oplist') {
  46808. return;
  46809. }
  46810. var intentState = this.intentStates[intent];
  46811. intentState.renderTasks.forEach(function (renderTask) {
  46812. var renderCompleted = renderTask.capability.promise.catch(function () {
  46813. });
  46814. waitOn.push(renderCompleted);
  46815. renderTask.cancel();
  46816. });
  46817. }, this);
  46818. this.objs.clear();
  46819. this.annotationsPromise = null;
  46820. this.pendingCleanup = false;
  46821. return Promise.all(waitOn);
  46822. },
  46823. destroy: function () {
  46824. deprecated('page destroy method, use cleanup() instead');
  46825. this.cleanup();
  46826. },
  46827. cleanup: function PDFPageProxy_cleanup() {
  46828. this.pendingCleanup = true;
  46829. this._tryCleanup();
  46830. },
  46831. _tryCleanup: function PDFPageProxy_tryCleanup() {
  46832. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  46833. var intentState = this.intentStates[intent];
  46834. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  46835. }, this)) {
  46836. return;
  46837. }
  46838. Object.keys(this.intentStates).forEach(function (intent) {
  46839. delete this.intentStates[intent];
  46840. }, this);
  46841. this.objs.clear();
  46842. this.annotationsPromise = null;
  46843. this.pendingCleanup = false;
  46844. },
  46845. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  46846. var intentState = this.intentStates[intent];
  46847. if (intentState.displayReadyCapability) {
  46848. intentState.displayReadyCapability.resolve(transparency);
  46849. }
  46850. },
  46851. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  46852. var intentState = this.intentStates[intent];
  46853. var i, ii;
  46854. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  46855. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  46856. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  46857. }
  46858. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  46859. for (i = 0; i < intentState.renderTasks.length; i++) {
  46860. intentState.renderTasks[i].operatorListChanged();
  46861. }
  46862. if (operatorListChunk.lastChunk) {
  46863. intentState.receivingOperatorList = false;
  46864. this._tryCleanup();
  46865. }
  46866. }
  46867. };
  46868. return PDFPageProxy;
  46869. }();
  46870. var PDFWorker = function PDFWorkerClosure() {
  46871. var nextFakeWorkerId = 0;
  46872. function getWorkerSrc() {
  46873. if (typeof workerSrc !== 'undefined') {
  46874. return workerSrc;
  46875. }
  46876. if (getDefaultSetting('workerSrc')) {
  46877. return getDefaultSetting('workerSrc');
  46878. }
  46879. if (pdfjsFilePath) {
  46880. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  46881. }
  46882. error('No PDFJS.workerSrc specified');
  46883. }
  46884. var fakeWorkerFilesLoadedCapability;
  46885. function setupFakeWorkerGlobal() {
  46886. var WorkerMessageHandler;
  46887. if (fakeWorkerFilesLoadedCapability) {
  46888. return fakeWorkerFilesLoadedCapability.promise;
  46889. }
  46890. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  46891. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  46892. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  46893. return fakeWorkerFilesLoadedCapability.promise;
  46894. }
  46895. function FakeWorkerPort(defer) {
  46896. this._listeners = [];
  46897. this._defer = defer;
  46898. this._deferred = Promise.resolve(undefined);
  46899. }
  46900. FakeWorkerPort.prototype = {
  46901. postMessage: function (obj, transfers) {
  46902. function cloneValue(value) {
  46903. if (typeof value !== 'object' || value === null) {
  46904. return value;
  46905. }
  46906. if (cloned.has(value)) {
  46907. return cloned.get(value);
  46908. }
  46909. var result;
  46910. var buffer;
  46911. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  46912. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  46913. if (value === buffer) {
  46914. result = value;
  46915. } else if (transferable) {
  46916. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  46917. } else {
  46918. result = new value.constructor(value);
  46919. }
  46920. cloned.set(value, result);
  46921. return result;
  46922. }
  46923. result = isArray(value) ? [] : {};
  46924. cloned.set(value, result);
  46925. for (var i in value) {
  46926. var desc, p = value;
  46927. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  46928. p = Object.getPrototypeOf(p);
  46929. }
  46930. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  46931. continue;
  46932. }
  46933. result[i] = cloneValue(desc.value);
  46934. }
  46935. return result;
  46936. }
  46937. if (!this._defer) {
  46938. this._listeners.forEach(function (listener) {
  46939. listener.call(this, { data: obj });
  46940. }, this);
  46941. return;
  46942. }
  46943. var cloned = new WeakMap();
  46944. var e = { data: cloneValue(obj) };
  46945. this._deferred.then(function () {
  46946. this._listeners.forEach(function (listener) {
  46947. listener.call(this, e);
  46948. }, this);
  46949. }.bind(this));
  46950. },
  46951. addEventListener: function (name, listener) {
  46952. this._listeners.push(listener);
  46953. },
  46954. removeEventListener: function (name, listener) {
  46955. var i = this._listeners.indexOf(listener);
  46956. this._listeners.splice(i, 1);
  46957. },
  46958. terminate: function () {
  46959. this._listeners = [];
  46960. }
  46961. };
  46962. function createCDNWrapper(url) {
  46963. var wrapper = 'importScripts(\'' + url + '\');';
  46964. return URL.createObjectURL(new Blob([wrapper]));
  46965. }
  46966. function PDFWorker(name) {
  46967. this.name = name;
  46968. this.destroyed = false;
  46969. this._readyCapability = createPromiseCapability();
  46970. this._port = null;
  46971. this._webWorker = null;
  46972. this._messageHandler = null;
  46973. this._initialize();
  46974. }
  46975. PDFWorker.prototype = {
  46976. get promise() {
  46977. return this._readyCapability.promise;
  46978. },
  46979. get port() {
  46980. return this._port;
  46981. },
  46982. get messageHandler() {
  46983. return this._messageHandler;
  46984. },
  46985. _initialize: function PDFWorker_initialize() {
  46986. this._setupFakeWorker();
  46987. },
  46988. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  46989. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  46990. warn('Setting up fake worker.');
  46991. isWorkerDisabled = true;
  46992. }
  46993. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  46994. if (this.destroyed) {
  46995. this._readyCapability.reject(new Error('Worker was destroyed'));
  46996. return;
  46997. }
  46998. var isTypedArraysPresent = Uint8Array !== Float32Array;
  46999. var port = new FakeWorkerPort(isTypedArraysPresent);
  47000. this._port = port;
  47001. var id = 'fake' + nextFakeWorkerId++;
  47002. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47003. WorkerMessageHandler.setup(workerHandler, port);
  47004. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47005. this._messageHandler = messageHandler;
  47006. this._readyCapability.resolve();
  47007. }.bind(this));
  47008. },
  47009. destroy: function PDFWorker_destroy() {
  47010. this.destroyed = true;
  47011. if (this._webWorker) {
  47012. this._webWorker.terminate();
  47013. this._webWorker = null;
  47014. }
  47015. this._port = null;
  47016. if (this._messageHandler) {
  47017. this._messageHandler.destroy();
  47018. this._messageHandler = null;
  47019. }
  47020. }
  47021. };
  47022. return PDFWorker;
  47023. }();
  47024. var WorkerTransport = function WorkerTransportClosure() {
  47025. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47026. this.messageHandler = messageHandler;
  47027. this.loadingTask = loadingTask;
  47028. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47029. this.commonObjs = new PDFObjects();
  47030. this.fontLoader = new FontLoader(loadingTask.docId);
  47031. this.destroyed = false;
  47032. this.destroyCapability = null;
  47033. this.pageCache = [];
  47034. this.pagePromises = [];
  47035. this.downloadInfoCapability = createPromiseCapability();
  47036. this.setupMessageHandler();
  47037. }
  47038. WorkerTransport.prototype = {
  47039. destroy: function WorkerTransport_destroy() {
  47040. if (this.destroyCapability) {
  47041. return this.destroyCapability.promise;
  47042. }
  47043. this.destroyed = true;
  47044. this.destroyCapability = createPromiseCapability();
  47045. var waitOn = [];
  47046. this.pageCache.forEach(function (page) {
  47047. if (page) {
  47048. waitOn.push(page._destroy());
  47049. }
  47050. });
  47051. this.pageCache = [];
  47052. this.pagePromises = [];
  47053. var self = this;
  47054. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  47055. waitOn.push(terminated);
  47056. Promise.all(waitOn).then(function () {
  47057. self.fontLoader.clear();
  47058. if (self.pdfDataRangeTransport) {
  47059. self.pdfDataRangeTransport.abort();
  47060. self.pdfDataRangeTransport = null;
  47061. }
  47062. if (self.messageHandler) {
  47063. self.messageHandler.destroy();
  47064. self.messageHandler = null;
  47065. }
  47066. self.destroyCapability.resolve();
  47067. }, this.destroyCapability.reject);
  47068. return this.destroyCapability.promise;
  47069. },
  47070. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  47071. var messageHandler = this.messageHandler;
  47072. function updatePassword(password) {
  47073. messageHandler.send('UpdatePassword', password);
  47074. }
  47075. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47076. if (pdfDataRangeTransport) {
  47077. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47078. messageHandler.send('OnDataRange', {
  47079. begin: begin,
  47080. chunk: chunk
  47081. });
  47082. });
  47083. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47084. messageHandler.send('OnDataProgress', { loaded: loaded });
  47085. });
  47086. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47087. messageHandler.send('OnDataRange', { chunk: chunk });
  47088. });
  47089. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47090. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47091. }, this);
  47092. }
  47093. messageHandler.on('GetDoc', function transportDoc(data) {
  47094. var pdfInfo = data.pdfInfo;
  47095. this.numPages = data.pdfInfo.numPages;
  47096. var loadingTask = this.loadingTask;
  47097. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47098. this.pdfDocument = pdfDocument;
  47099. loadingTask._capability.resolve(pdfDocument);
  47100. }, this);
  47101. messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
  47102. var loadingTask = this.loadingTask;
  47103. if (loadingTask.onPassword) {
  47104. return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
  47105. }
  47106. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47107. }, this);
  47108. messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
  47109. var loadingTask = this.loadingTask;
  47110. if (loadingTask.onPassword) {
  47111. return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
  47112. }
  47113. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47114. }, this);
  47115. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47116. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47117. }, this);
  47118. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47119. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47120. }, this);
  47121. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47122. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47123. }, this);
  47124. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47125. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47126. }, this);
  47127. messageHandler.on('DataLoaded', function transportPage(data) {
  47128. this.downloadInfoCapability.resolve(data);
  47129. }, this);
  47130. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47131. if (this.pdfDataRangeTransport) {
  47132. this.pdfDataRangeTransport.transportReady();
  47133. }
  47134. }, this);
  47135. messageHandler.on('StartRenderPage', function transportRender(data) {
  47136. if (this.destroyed) {
  47137. return;
  47138. }
  47139. var page = this.pageCache[data.pageIndex];
  47140. page.stats.timeEnd('Page Request');
  47141. page._startRenderPage(data.transparency, data.intent);
  47142. }, this);
  47143. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47144. if (this.destroyed) {
  47145. return;
  47146. }
  47147. var page = this.pageCache[data.pageIndex];
  47148. page._renderPageChunk(data.operatorList, data.intent);
  47149. }, this);
  47150. messageHandler.on('commonobj', function transportObj(data) {
  47151. if (this.destroyed) {
  47152. return;
  47153. }
  47154. var id = data[0];
  47155. var type = data[1];
  47156. if (this.commonObjs.hasData(id)) {
  47157. return;
  47158. }
  47159. switch (type) {
  47160. case 'Font':
  47161. var exportedData = data[2];
  47162. if ('error' in exportedData) {
  47163. var exportedError = exportedData.error;
  47164. warn('Error during font loading: ' + exportedError);
  47165. this.commonObjs.resolve(id, exportedError);
  47166. break;
  47167. }
  47168. var fontRegistry = null;
  47169. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47170. fontRegistry = {
  47171. registerFont: function (font, url) {
  47172. globalScope['FontInspector'].fontAdded(font, url);
  47173. }
  47174. };
  47175. }
  47176. var font = new FontFaceObject(exportedData, {
  47177. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47178. disableFontFace: getDefaultSetting('disableFontFace'),
  47179. fontRegistry: fontRegistry
  47180. });
  47181. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47182. this.commonObjs.resolve(id, font);
  47183. }.bind(this));
  47184. break;
  47185. case 'FontPath':
  47186. this.commonObjs.resolve(id, data[2]);
  47187. break;
  47188. default:
  47189. error('Got unknown common object type ' + type);
  47190. }
  47191. }, this);
  47192. messageHandler.on('obj', function transportObj(data) {
  47193. if (this.destroyed) {
  47194. return;
  47195. }
  47196. var id = data[0];
  47197. var pageIndex = data[1];
  47198. var type = data[2];
  47199. var pageProxy = this.pageCache[pageIndex];
  47200. var imageData;
  47201. if (pageProxy.objs.hasData(id)) {
  47202. return;
  47203. }
  47204. switch (type) {
  47205. case 'JpegStream':
  47206. imageData = data[3];
  47207. loadJpegStream(id, imageData, pageProxy.objs);
  47208. break;
  47209. case 'Image':
  47210. imageData = data[3];
  47211. pageProxy.objs.resolve(id, imageData);
  47212. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47213. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47214. pageProxy.cleanupAfterRender = true;
  47215. }
  47216. break;
  47217. default:
  47218. error('Got unknown object type ' + type);
  47219. }
  47220. }, this);
  47221. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47222. if (this.destroyed) {
  47223. return;
  47224. }
  47225. var loadingTask = this.loadingTask;
  47226. if (loadingTask.onProgress) {
  47227. loadingTask.onProgress({
  47228. loaded: data.loaded,
  47229. total: data.total
  47230. });
  47231. }
  47232. }, this);
  47233. messageHandler.on('PageError', function transportError(data) {
  47234. if (this.destroyed) {
  47235. return;
  47236. }
  47237. var page = this.pageCache[data.pageNum - 1];
  47238. var intentState = page.intentStates[data.intent];
  47239. if (intentState.displayReadyCapability) {
  47240. intentState.displayReadyCapability.reject(data.error);
  47241. } else {
  47242. error(data.error);
  47243. }
  47244. if (intentState.operatorList) {
  47245. intentState.operatorList.lastChunk = true;
  47246. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47247. intentState.renderTasks[i].operatorListChanged();
  47248. }
  47249. }
  47250. }, this);
  47251. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47252. if (this.destroyed) {
  47253. return;
  47254. }
  47255. var featureId = data.featureId;
  47256. var loadingTask = this.loadingTask;
  47257. if (loadingTask.onUnsupportedFeature) {
  47258. loadingTask.onUnsupportedFeature(featureId);
  47259. }
  47260. _UnsupportedManager.notify(featureId);
  47261. }, this);
  47262. messageHandler.on('JpegDecode', function (data) {
  47263. if (this.destroyed) {
  47264. return Promise.reject(new Error('Worker was destroyed'));
  47265. }
  47266. var imageUrl = data[0];
  47267. var components = data[1];
  47268. if (components !== 3 && components !== 1) {
  47269. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47270. }
  47271. return new Promise(function (resolve, reject) {
  47272. var img = new Image();
  47273. img.onload = function () {
  47274. var width = img.width;
  47275. var height = img.height;
  47276. var size = width * height;
  47277. var rgbaLength = size * 4;
  47278. var buf = new Uint8Array(size * components);
  47279. var tmpCanvas = createScratchCanvas(width, height);
  47280. var tmpCtx = tmpCanvas.getContext('2d');
  47281. tmpCtx.drawImage(img, 0, 0);
  47282. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47283. var i, j;
  47284. if (components === 3) {
  47285. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47286. buf[j] = data[i];
  47287. buf[j + 1] = data[i + 1];
  47288. buf[j + 2] = data[i + 2];
  47289. }
  47290. } else if (components === 1) {
  47291. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47292. buf[j] = data[i];
  47293. }
  47294. }
  47295. resolve({
  47296. data: buf,
  47297. width: width,
  47298. height: height
  47299. });
  47300. };
  47301. img.onerror = function () {
  47302. reject(new Error('JpegDecode failed to load image'));
  47303. };
  47304. img.src = imageUrl;
  47305. });
  47306. }, this);
  47307. },
  47308. getData: function WorkerTransport_getData() {
  47309. return this.messageHandler.sendWithPromise('GetData', null);
  47310. },
  47311. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47312. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47313. return Promise.reject(new Error('Invalid page request'));
  47314. }
  47315. var pageIndex = pageNumber - 1;
  47316. if (pageIndex in this.pagePromises) {
  47317. return this.pagePromises[pageIndex];
  47318. }
  47319. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47320. if (this.destroyed) {
  47321. throw new Error('Transport destroyed');
  47322. }
  47323. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47324. this.pageCache[pageIndex] = page;
  47325. return page;
  47326. }.bind(this));
  47327. this.pagePromises[pageIndex] = promise;
  47328. return promise;
  47329. },
  47330. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47331. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47332. return Promise.reject(new Error(reason));
  47333. });
  47334. },
  47335. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47336. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47337. pageIndex: pageIndex,
  47338. intent: intent
  47339. });
  47340. },
  47341. getDestinations: function WorkerTransport_getDestinations() {
  47342. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47343. },
  47344. getDestination: function WorkerTransport_getDestination(id) {
  47345. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47346. },
  47347. getPageLabels: function WorkerTransport_getPageLabels() {
  47348. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47349. },
  47350. getAttachments: function WorkerTransport_getAttachments() {
  47351. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47352. },
  47353. getJavaScript: function WorkerTransport_getJavaScript() {
  47354. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47355. },
  47356. getOutline: function WorkerTransport_getOutline() {
  47357. return this.messageHandler.sendWithPromise('GetOutline', null);
  47358. },
  47359. getMetadata: function WorkerTransport_getMetadata() {
  47360. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47361. return {
  47362. info: results[0],
  47363. metadata: results[1] ? new Metadata(results[1]) : null
  47364. };
  47365. });
  47366. },
  47367. getStats: function WorkerTransport_getStats() {
  47368. return this.messageHandler.sendWithPromise('GetStats', null);
  47369. },
  47370. startCleanup: function WorkerTransport_startCleanup() {
  47371. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47372. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47373. var page = this.pageCache[i];
  47374. if (page) {
  47375. page.cleanup();
  47376. }
  47377. }
  47378. this.commonObjs.clear();
  47379. this.fontLoader.clear();
  47380. }.bind(this));
  47381. }
  47382. };
  47383. return WorkerTransport;
  47384. }();
  47385. var PDFObjects = function PDFObjectsClosure() {
  47386. function PDFObjects() {
  47387. this.objs = Object.create(null);
  47388. }
  47389. PDFObjects.prototype = {
  47390. ensureObj: function PDFObjects_ensureObj(objId) {
  47391. if (this.objs[objId]) {
  47392. return this.objs[objId];
  47393. }
  47394. var obj = {
  47395. capability: createPromiseCapability(),
  47396. data: null,
  47397. resolved: false
  47398. };
  47399. this.objs[objId] = obj;
  47400. return obj;
  47401. },
  47402. get: function PDFObjects_get(objId, callback) {
  47403. if (callback) {
  47404. this.ensureObj(objId).capability.promise.then(callback);
  47405. return null;
  47406. }
  47407. var obj = this.objs[objId];
  47408. if (!obj || !obj.resolved) {
  47409. error('Requesting object that isn\'t resolved yet ' + objId);
  47410. }
  47411. return obj.data;
  47412. },
  47413. resolve: function PDFObjects_resolve(objId, data) {
  47414. var obj = this.ensureObj(objId);
  47415. obj.resolved = true;
  47416. obj.data = data;
  47417. obj.capability.resolve(data);
  47418. },
  47419. isResolved: function PDFObjects_isResolved(objId) {
  47420. var objs = this.objs;
  47421. if (!objs[objId]) {
  47422. return false;
  47423. } else {
  47424. return objs[objId].resolved;
  47425. }
  47426. },
  47427. hasData: function PDFObjects_hasData(objId) {
  47428. return this.isResolved(objId);
  47429. },
  47430. getData: function PDFObjects_getData(objId) {
  47431. var objs = this.objs;
  47432. if (!objs[objId] || !objs[objId].resolved) {
  47433. return null;
  47434. } else {
  47435. return objs[objId].data;
  47436. }
  47437. },
  47438. clear: function PDFObjects_clear() {
  47439. this.objs = Object.create(null);
  47440. }
  47441. };
  47442. return PDFObjects;
  47443. }();
  47444. var RenderTask = function RenderTaskClosure() {
  47445. function RenderTask(internalRenderTask) {
  47446. this._internalRenderTask = internalRenderTask;
  47447. this.onContinue = null;
  47448. }
  47449. RenderTask.prototype = {
  47450. get promise() {
  47451. return this._internalRenderTask.capability.promise;
  47452. },
  47453. cancel: function RenderTask_cancel() {
  47454. this._internalRenderTask.cancel();
  47455. },
  47456. then: function RenderTask_then(onFulfilled, onRejected) {
  47457. return this.promise.then.apply(this.promise, arguments);
  47458. }
  47459. };
  47460. return RenderTask;
  47461. }();
  47462. var InternalRenderTask = function InternalRenderTaskClosure() {
  47463. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47464. this.callback = callback;
  47465. this.params = params;
  47466. this.objs = objs;
  47467. this.commonObjs = commonObjs;
  47468. this.operatorListIdx = null;
  47469. this.operatorList = operatorList;
  47470. this.pageNumber = pageNumber;
  47471. this.running = false;
  47472. this.graphicsReadyCallback = null;
  47473. this.graphicsReady = false;
  47474. this.useRequestAnimationFrame = false;
  47475. this.cancelled = false;
  47476. this.capability = createPromiseCapability();
  47477. this.task = new RenderTask(this);
  47478. this._continueBound = this._continue.bind(this);
  47479. this._scheduleNextBound = this._scheduleNext.bind(this);
  47480. this._nextBound = this._next.bind(this);
  47481. }
  47482. InternalRenderTask.prototype = {
  47483. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47484. if (this.cancelled) {
  47485. return;
  47486. }
  47487. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47488. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47489. this.stepper.init(this.operatorList);
  47490. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47491. }
  47492. var params = this.params;
  47493. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47494. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47495. this.operatorListIdx = 0;
  47496. this.graphicsReady = true;
  47497. if (this.graphicsReadyCallback) {
  47498. this.graphicsReadyCallback();
  47499. }
  47500. },
  47501. cancel: function InternalRenderTask_cancel() {
  47502. this.running = false;
  47503. this.cancelled = true;
  47504. this.callback('cancelled');
  47505. },
  47506. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47507. if (!this.graphicsReady) {
  47508. if (!this.graphicsReadyCallback) {
  47509. this.graphicsReadyCallback = this._continueBound;
  47510. }
  47511. return;
  47512. }
  47513. if (this.stepper) {
  47514. this.stepper.updateOperatorList(this.operatorList);
  47515. }
  47516. if (this.running) {
  47517. return;
  47518. }
  47519. this._continue();
  47520. },
  47521. _continue: function InternalRenderTask__continue() {
  47522. this.running = true;
  47523. if (this.cancelled) {
  47524. return;
  47525. }
  47526. if (this.task.onContinue) {
  47527. this.task.onContinue.call(this.task, this._scheduleNextBound);
  47528. } else {
  47529. this._scheduleNext();
  47530. }
  47531. },
  47532. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47533. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47534. window.requestAnimationFrame(this._nextBound);
  47535. } else {
  47536. Promise.resolve(undefined).then(this._nextBound);
  47537. }
  47538. },
  47539. _next: function InternalRenderTask__next() {
  47540. if (this.cancelled) {
  47541. return;
  47542. }
  47543. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47544. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47545. this.running = false;
  47546. if (this.operatorList.lastChunk) {
  47547. this.gfx.endDrawing();
  47548. this.callback();
  47549. }
  47550. }
  47551. }
  47552. };
  47553. return InternalRenderTask;
  47554. }();
  47555. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47556. var listeners = [];
  47557. return {
  47558. listen: function (cb) {
  47559. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47560. listeners.push(cb);
  47561. },
  47562. notify: function (featureId) {
  47563. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47564. listeners[i](featureId);
  47565. }
  47566. }
  47567. };
  47568. }();
  47569. if (typeof pdfjsVersion !== 'undefined') {
  47570. exports.version = pdfjsVersion;
  47571. }
  47572. if (typeof pdfjsBuild !== 'undefined') {
  47573. exports.build = pdfjsBuild;
  47574. }
  47575. exports.getDocument = getDocument;
  47576. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47577. exports.PDFWorker = PDFWorker;
  47578. exports.PDFDocumentProxy = PDFDocumentProxy;
  47579. exports.PDFPageProxy = PDFPageProxy;
  47580. exports._UnsupportedManager = _UnsupportedManager;
  47581. }));
  47582. (function (root, factory) {
  47583. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47584. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47585. var error = sharedUtil.error;
  47586. var info = sharedUtil.info;
  47587. var isArray = sharedUtil.isArray;
  47588. var isString = sharedUtil.isString;
  47589. var shadow = sharedUtil.shadow;
  47590. var warn = sharedUtil.warn;
  47591. var isDict = corePrimitives.isDict;
  47592. var isName = corePrimitives.isName;
  47593. var isStream = corePrimitives.isStream;
  47594. var PDFFunction = coreFunction.PDFFunction;
  47595. var ColorSpace = function ColorSpaceClosure() {
  47596. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47597. var COMPONENTS = 3;
  47598. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47599. var xRatio = w1 / w2;
  47600. var yRatio = h1 / h2;
  47601. var i, j, py, newIndex = 0, oldIndex;
  47602. var xScaled = new Uint16Array(w2);
  47603. var w1Scanline = w1 * COMPONENTS;
  47604. for (i = 0; i < w2; i++) {
  47605. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47606. }
  47607. for (i = 0; i < h2; i++) {
  47608. py = Math.floor(i * yRatio) * w1Scanline;
  47609. for (j = 0; j < w2; j++) {
  47610. oldIndex = py + xScaled[j];
  47611. dest[newIndex++] = src[oldIndex++];
  47612. dest[newIndex++] = src[oldIndex++];
  47613. dest[newIndex++] = src[oldIndex++];
  47614. newIndex += alpha01;
  47615. }
  47616. }
  47617. }
  47618. function ColorSpace() {
  47619. error('should not call ColorSpace constructor');
  47620. }
  47621. ColorSpace.prototype = {
  47622. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47623. var rgb = new Uint8Array(3);
  47624. this.getRgbItem(src, srcOffset, rgb, 0);
  47625. return rgb;
  47626. },
  47627. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47628. error('Should not call ColorSpace.getRgbItem');
  47629. },
  47630. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47631. error('Should not call ColorSpace.getRgbBuffer');
  47632. },
  47633. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47634. error('Should not call ColorSpace.getOutputLength');
  47635. },
  47636. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47637. return false;
  47638. },
  47639. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47640. var count = originalWidth * originalHeight;
  47641. var rgbBuf = null;
  47642. var numComponentColors = 1 << bpc;
  47643. var needsResizing = originalHeight !== height || originalWidth !== width;
  47644. var i, ii;
  47645. if (this.isPassthrough(bpc)) {
  47646. rgbBuf = comps;
  47647. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47648. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47649. var key;
  47650. for (i = 0; i < numComponentColors; i++) {
  47651. allColors[i] = i;
  47652. }
  47653. var colorMap = new Uint8Array(numComponentColors * 3);
  47654. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47655. var destPos, rgbPos;
  47656. if (!needsResizing) {
  47657. destPos = 0;
  47658. for (i = 0; i < count; ++i) {
  47659. key = comps[i] * 3;
  47660. dest[destPos++] = colorMap[key];
  47661. dest[destPos++] = colorMap[key + 1];
  47662. dest[destPos++] = colorMap[key + 2];
  47663. destPos += alpha01;
  47664. }
  47665. } else {
  47666. rgbBuf = new Uint8Array(count * 3);
  47667. rgbPos = 0;
  47668. for (i = 0; i < count; ++i) {
  47669. key = comps[i] * 3;
  47670. rgbBuf[rgbPos++] = colorMap[key];
  47671. rgbBuf[rgbPos++] = colorMap[key + 1];
  47672. rgbBuf[rgbPos++] = colorMap[key + 2];
  47673. }
  47674. }
  47675. } else {
  47676. if (!needsResizing) {
  47677. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47678. } else {
  47679. rgbBuf = new Uint8Array(count * 3);
  47680. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47681. }
  47682. }
  47683. if (rgbBuf) {
  47684. if (needsResizing) {
  47685. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47686. } else {
  47687. rgbPos = 0;
  47688. destPos = 0;
  47689. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47690. dest[destPos++] = rgbBuf[rgbPos++];
  47691. dest[destPos++] = rgbBuf[rgbPos++];
  47692. dest[destPos++] = rgbBuf[rgbPos++];
  47693. destPos += alpha01;
  47694. }
  47695. }
  47696. }
  47697. },
  47698. usesZeroToOneRange: true
  47699. };
  47700. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47701. var IR = ColorSpace.parseToIR(cs, xref, res);
  47702. if (IR instanceof AlternateCS) {
  47703. return IR;
  47704. }
  47705. return ColorSpace.fromIR(IR);
  47706. };
  47707. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47708. var name = isArray(IR) ? IR[0] : IR;
  47709. var whitePoint, blackPoint, gamma;
  47710. switch (name) {
  47711. case 'DeviceGrayCS':
  47712. return this.singletons.gray;
  47713. case 'DeviceRgbCS':
  47714. return this.singletons.rgb;
  47715. case 'DeviceCmykCS':
  47716. return this.singletons.cmyk;
  47717. case 'CalGrayCS':
  47718. whitePoint = IR[1];
  47719. blackPoint = IR[2];
  47720. gamma = IR[3];
  47721. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47722. case 'CalRGBCS':
  47723. whitePoint = IR[1];
  47724. blackPoint = IR[2];
  47725. gamma = IR[3];
  47726. var matrix = IR[4];
  47727. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47728. case 'PatternCS':
  47729. var basePatternCS = IR[1];
  47730. if (basePatternCS) {
  47731. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47732. }
  47733. return new PatternCS(basePatternCS);
  47734. case 'IndexedCS':
  47735. var baseIndexedCS = IR[1];
  47736. var hiVal = IR[2];
  47737. var lookup = IR[3];
  47738. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47739. case 'AlternateCS':
  47740. var numComps = IR[1];
  47741. var alt = IR[2];
  47742. var tintFnIR = IR[3];
  47743. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47744. case 'LabCS':
  47745. whitePoint = IR[1];
  47746. blackPoint = IR[2];
  47747. var range = IR[3];
  47748. return new LabCS(whitePoint, blackPoint, range);
  47749. default:
  47750. error('Unknown name ' + name);
  47751. }
  47752. return null;
  47753. };
  47754. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47755. if (isName(cs)) {
  47756. var colorSpaces = res.get('ColorSpace');
  47757. if (isDict(colorSpaces)) {
  47758. var refcs = colorSpaces.get(cs.name);
  47759. if (refcs) {
  47760. cs = refcs;
  47761. }
  47762. }
  47763. }
  47764. cs = xref.fetchIfRef(cs);
  47765. var mode;
  47766. if (isName(cs)) {
  47767. mode = cs.name;
  47768. this.mode = mode;
  47769. switch (mode) {
  47770. case 'DeviceGray':
  47771. case 'G':
  47772. return 'DeviceGrayCS';
  47773. case 'DeviceRGB':
  47774. case 'RGB':
  47775. return 'DeviceRgbCS';
  47776. case 'DeviceCMYK':
  47777. case 'CMYK':
  47778. return 'DeviceCmykCS';
  47779. case 'Pattern':
  47780. return [
  47781. 'PatternCS',
  47782. null
  47783. ];
  47784. default:
  47785. error('unrecognized colorspace ' + mode);
  47786. }
  47787. } else if (isArray(cs)) {
  47788. mode = xref.fetchIfRef(cs[0]).name;
  47789. this.mode = mode;
  47790. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47791. switch (mode) {
  47792. case 'DeviceGray':
  47793. case 'G':
  47794. return 'DeviceGrayCS';
  47795. case 'DeviceRGB':
  47796. case 'RGB':
  47797. return 'DeviceRgbCS';
  47798. case 'DeviceCMYK':
  47799. case 'CMYK':
  47800. return 'DeviceCmykCS';
  47801. case 'CalGray':
  47802. params = xref.fetchIfRef(cs[1]);
  47803. whitePoint = params.getArray('WhitePoint');
  47804. blackPoint = params.getArray('BlackPoint');
  47805. gamma = params.get('Gamma');
  47806. return [
  47807. 'CalGrayCS',
  47808. whitePoint,
  47809. blackPoint,
  47810. gamma
  47811. ];
  47812. case 'CalRGB':
  47813. params = xref.fetchIfRef(cs[1]);
  47814. whitePoint = params.getArray('WhitePoint');
  47815. blackPoint = params.getArray('BlackPoint');
  47816. gamma = params.getArray('Gamma');
  47817. var matrix = params.getArray('Matrix');
  47818. return [
  47819. 'CalRGBCS',
  47820. whitePoint,
  47821. blackPoint,
  47822. gamma,
  47823. matrix
  47824. ];
  47825. case 'ICCBased':
  47826. var stream = xref.fetchIfRef(cs[1]);
  47827. var dict = stream.dict;
  47828. numComps = dict.get('N');
  47829. alt = dict.get('Alternate');
  47830. if (alt) {
  47831. var altIR = ColorSpace.parseToIR(alt, xref, res);
  47832. var altCS = ColorSpace.fromIR(altIR);
  47833. if (altCS.numComps === numComps) {
  47834. return altIR;
  47835. }
  47836. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  47837. }
  47838. if (numComps === 1) {
  47839. return 'DeviceGrayCS';
  47840. } else if (numComps === 3) {
  47841. return 'DeviceRgbCS';
  47842. } else if (numComps === 4) {
  47843. return 'DeviceCmykCS';
  47844. }
  47845. break;
  47846. case 'Pattern':
  47847. var basePatternCS = cs[1] || null;
  47848. if (basePatternCS) {
  47849. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  47850. }
  47851. return [
  47852. 'PatternCS',
  47853. basePatternCS
  47854. ];
  47855. case 'Indexed':
  47856. case 'I':
  47857. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  47858. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  47859. var lookup = xref.fetchIfRef(cs[3]);
  47860. if (isStream(lookup)) {
  47861. lookup = lookup.getBytes();
  47862. }
  47863. return [
  47864. 'IndexedCS',
  47865. baseIndexedCS,
  47866. hiVal,
  47867. lookup
  47868. ];
  47869. case 'Separation':
  47870. case 'DeviceN':
  47871. var name = xref.fetchIfRef(cs[1]);
  47872. numComps = 1;
  47873. if (isName(name)) {
  47874. numComps = 1;
  47875. } else if (isArray(name)) {
  47876. numComps = name.length;
  47877. }
  47878. alt = ColorSpace.parseToIR(cs[2], xref, res);
  47879. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  47880. return [
  47881. 'AlternateCS',
  47882. numComps,
  47883. alt,
  47884. tintFnIR
  47885. ];
  47886. case 'Lab':
  47887. params = xref.fetchIfRef(cs[1]);
  47888. whitePoint = params.getArray('WhitePoint');
  47889. blackPoint = params.getArray('BlackPoint');
  47890. var range = params.getArray('Range');
  47891. return [
  47892. 'LabCS',
  47893. whitePoint,
  47894. blackPoint,
  47895. range
  47896. ];
  47897. default:
  47898. error('unimplemented color space object "' + mode + '"');
  47899. }
  47900. } else {
  47901. error('unrecognized color space object: "' + cs + '"');
  47902. }
  47903. return null;
  47904. };
  47905. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  47906. if (!isArray(decode)) {
  47907. return true;
  47908. }
  47909. if (n * 2 !== decode.length) {
  47910. warn('The decode map is not the correct length');
  47911. return true;
  47912. }
  47913. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  47914. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  47915. return false;
  47916. }
  47917. }
  47918. return true;
  47919. };
  47920. ColorSpace.singletons = {
  47921. get gray() {
  47922. return shadow(this, 'gray', new DeviceGrayCS());
  47923. },
  47924. get rgb() {
  47925. return shadow(this, 'rgb', new DeviceRgbCS());
  47926. },
  47927. get cmyk() {
  47928. return shadow(this, 'cmyk', new DeviceCmykCS());
  47929. }
  47930. };
  47931. return ColorSpace;
  47932. }();
  47933. var AlternateCS = function AlternateCSClosure() {
  47934. function AlternateCS(numComps, base, tintFn) {
  47935. this.name = 'Alternate';
  47936. this.numComps = numComps;
  47937. this.defaultColor = new Float32Array(numComps);
  47938. for (var i = 0; i < numComps; ++i) {
  47939. this.defaultColor[i] = 1;
  47940. }
  47941. this.base = base;
  47942. this.tintFn = tintFn;
  47943. this.tmpBuf = new Float32Array(base.numComps);
  47944. }
  47945. AlternateCS.prototype = {
  47946. getRgb: ColorSpace.prototype.getRgb,
  47947. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  47948. var tmpBuf = this.tmpBuf;
  47949. this.tintFn(src, srcOffset, tmpBuf, 0);
  47950. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  47951. },
  47952. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47953. var tintFn = this.tintFn;
  47954. var base = this.base;
  47955. var scale = 1 / ((1 << bits) - 1);
  47956. var baseNumComps = base.numComps;
  47957. var usesZeroToOneRange = base.usesZeroToOneRange;
  47958. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  47959. var pos = isPassthrough ? destOffset : 0;
  47960. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  47961. var numComps = this.numComps;
  47962. var scaled = new Float32Array(numComps);
  47963. var tinted = new Float32Array(baseNumComps);
  47964. var i, j;
  47965. if (usesZeroToOneRange) {
  47966. for (i = 0; i < count; i++) {
  47967. for (j = 0; j < numComps; j++) {
  47968. scaled[j] = src[srcOffset++] * scale;
  47969. }
  47970. tintFn(scaled, 0, tinted, 0);
  47971. for (j = 0; j < baseNumComps; j++) {
  47972. baseBuf[pos++] = tinted[j] * 255;
  47973. }
  47974. }
  47975. } else {
  47976. for (i = 0; i < count; i++) {
  47977. for (j = 0; j < numComps; j++) {
  47978. scaled[j] = src[srcOffset++] * scale;
  47979. }
  47980. tintFn(scaled, 0, tinted, 0);
  47981. base.getRgbItem(tinted, 0, baseBuf, pos);
  47982. pos += baseNumComps;
  47983. }
  47984. }
  47985. if (!isPassthrough) {
  47986. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  47987. }
  47988. },
  47989. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  47990. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  47991. },
  47992. isPassthrough: ColorSpace.prototype.isPassthrough,
  47993. fillRgb: ColorSpace.prototype.fillRgb,
  47994. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  47995. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  47996. },
  47997. usesZeroToOneRange: true
  47998. };
  47999. return AlternateCS;
  48000. }();
  48001. var PatternCS = function PatternCSClosure() {
  48002. function PatternCS(baseCS) {
  48003. this.name = 'Pattern';
  48004. this.base = baseCS;
  48005. }
  48006. PatternCS.prototype = {};
  48007. return PatternCS;
  48008. }();
  48009. var IndexedCS = function IndexedCSClosure() {
  48010. function IndexedCS(base, highVal, lookup) {
  48011. this.name = 'Indexed';
  48012. this.numComps = 1;
  48013. this.defaultColor = new Uint8Array([0]);
  48014. this.base = base;
  48015. this.highVal = highVal;
  48016. var baseNumComps = base.numComps;
  48017. var length = baseNumComps * highVal;
  48018. var lookupArray;
  48019. if (isStream(lookup)) {
  48020. lookupArray = new Uint8Array(length);
  48021. var bytes = lookup.getBytes(length);
  48022. lookupArray.set(bytes);
  48023. } else if (isString(lookup)) {
  48024. lookupArray = new Uint8Array(length);
  48025. for (var i = 0; i < length; ++i) {
  48026. lookupArray[i] = lookup.charCodeAt(i);
  48027. }
  48028. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48029. lookupArray = lookup;
  48030. } else {
  48031. error('Unrecognized lookup table: ' + lookup);
  48032. }
  48033. this.lookup = lookupArray;
  48034. }
  48035. IndexedCS.prototype = {
  48036. getRgb: ColorSpace.prototype.getRgb,
  48037. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48038. var numComps = this.base.numComps;
  48039. var start = src[srcOffset] * numComps;
  48040. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48041. },
  48042. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48043. var base = this.base;
  48044. var numComps = base.numComps;
  48045. var outputDelta = base.getOutputLength(numComps, alpha01);
  48046. var lookup = this.lookup;
  48047. for (var i = 0; i < count; ++i) {
  48048. var lookupPos = src[srcOffset++] * numComps;
  48049. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48050. destOffset += outputDelta;
  48051. }
  48052. },
  48053. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48054. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48055. },
  48056. isPassthrough: ColorSpace.prototype.isPassthrough,
  48057. fillRgb: ColorSpace.prototype.fillRgb,
  48058. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48059. return true;
  48060. },
  48061. usesZeroToOneRange: true
  48062. };
  48063. return IndexedCS;
  48064. }();
  48065. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48066. function DeviceGrayCS() {
  48067. this.name = 'DeviceGray';
  48068. this.numComps = 1;
  48069. this.defaultColor = new Float32Array([0]);
  48070. }
  48071. DeviceGrayCS.prototype = {
  48072. getRgb: ColorSpace.prototype.getRgb,
  48073. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48074. var c = src[srcOffset] * 255 | 0;
  48075. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48076. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48077. },
  48078. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48079. var scale = 255 / ((1 << bits) - 1);
  48080. var j = srcOffset, q = destOffset;
  48081. for (var i = 0; i < count; ++i) {
  48082. var c = scale * src[j++] | 0;
  48083. dest[q++] = c;
  48084. dest[q++] = c;
  48085. dest[q++] = c;
  48086. q += alpha01;
  48087. }
  48088. },
  48089. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48090. return inputLength * (3 + alpha01);
  48091. },
  48092. isPassthrough: ColorSpace.prototype.isPassthrough,
  48093. fillRgb: ColorSpace.prototype.fillRgb,
  48094. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48095. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48096. },
  48097. usesZeroToOneRange: true
  48098. };
  48099. return DeviceGrayCS;
  48100. }();
  48101. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48102. function DeviceRgbCS() {
  48103. this.name = 'DeviceRGB';
  48104. this.numComps = 3;
  48105. this.defaultColor = new Float32Array([
  48106. 0,
  48107. 0,
  48108. 0
  48109. ]);
  48110. }
  48111. DeviceRgbCS.prototype = {
  48112. getRgb: ColorSpace.prototype.getRgb,
  48113. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48114. var r = src[srcOffset] * 255 | 0;
  48115. var g = src[srcOffset + 1] * 255 | 0;
  48116. var b = src[srcOffset + 2] * 255 | 0;
  48117. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48118. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48119. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48120. },
  48121. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48122. if (bits === 8 && alpha01 === 0) {
  48123. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48124. return;
  48125. }
  48126. var scale = 255 / ((1 << bits) - 1);
  48127. var j = srcOffset, q = destOffset;
  48128. for (var i = 0; i < count; ++i) {
  48129. dest[q++] = scale * src[j++] | 0;
  48130. dest[q++] = scale * src[j++] | 0;
  48131. dest[q++] = scale * src[j++] | 0;
  48132. q += alpha01;
  48133. }
  48134. },
  48135. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48136. return inputLength * (3 + alpha01) / 3 | 0;
  48137. },
  48138. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48139. return bits === 8;
  48140. },
  48141. fillRgb: ColorSpace.prototype.fillRgb,
  48142. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48143. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48144. },
  48145. usesZeroToOneRange: true
  48146. };
  48147. return DeviceRgbCS;
  48148. }();
  48149. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48150. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48151. var c = src[srcOffset + 0] * srcScale;
  48152. var m = src[srcOffset + 1] * srcScale;
  48153. var y = src[srcOffset + 2] * srcScale;
  48154. var k = src[srcOffset + 3] * srcScale;
  48155. 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;
  48156. 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;
  48157. 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;
  48158. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48159. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48160. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48161. }
  48162. function DeviceCmykCS() {
  48163. this.name = 'DeviceCMYK';
  48164. this.numComps = 4;
  48165. this.defaultColor = new Float32Array([
  48166. 0,
  48167. 0,
  48168. 0,
  48169. 1
  48170. ]);
  48171. }
  48172. DeviceCmykCS.prototype = {
  48173. getRgb: ColorSpace.prototype.getRgb,
  48174. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48175. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48176. },
  48177. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48178. var scale = 1 / ((1 << bits) - 1);
  48179. for (var i = 0; i < count; i++) {
  48180. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48181. srcOffset += 4;
  48182. destOffset += 3 + alpha01;
  48183. }
  48184. },
  48185. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48186. return inputLength / 4 * (3 + alpha01) | 0;
  48187. },
  48188. isPassthrough: ColorSpace.prototype.isPassthrough,
  48189. fillRgb: ColorSpace.prototype.fillRgb,
  48190. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48191. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48192. },
  48193. usesZeroToOneRange: true
  48194. };
  48195. return DeviceCmykCS;
  48196. }();
  48197. var CalGrayCS = function CalGrayCSClosure() {
  48198. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48199. this.name = 'CalGray';
  48200. this.numComps = 1;
  48201. this.defaultColor = new Float32Array([0]);
  48202. if (!whitePoint) {
  48203. error('WhitePoint missing - required for color space CalGray');
  48204. }
  48205. blackPoint = blackPoint || [
  48206. 0,
  48207. 0,
  48208. 0
  48209. ];
  48210. gamma = gamma || 1;
  48211. this.XW = whitePoint[0];
  48212. this.YW = whitePoint[1];
  48213. this.ZW = whitePoint[2];
  48214. this.XB = blackPoint[0];
  48215. this.YB = blackPoint[1];
  48216. this.ZB = blackPoint[2];
  48217. this.G = gamma;
  48218. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48219. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48220. }
  48221. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48222. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48223. this.XB = this.YB = this.ZB = 0;
  48224. }
  48225. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48226. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48227. }
  48228. if (this.G < 1) {
  48229. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48230. this.G = 1;
  48231. }
  48232. }
  48233. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48234. var A = src[srcOffset] * scale;
  48235. var AG = Math.pow(A, cs.G);
  48236. var L = cs.YW * AG;
  48237. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48238. dest[destOffset] = val;
  48239. dest[destOffset + 1] = val;
  48240. dest[destOffset + 2] = val;
  48241. }
  48242. CalGrayCS.prototype = {
  48243. getRgb: ColorSpace.prototype.getRgb,
  48244. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48245. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48246. },
  48247. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48248. var scale = 1 / ((1 << bits) - 1);
  48249. for (var i = 0; i < count; ++i) {
  48250. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48251. srcOffset += 1;
  48252. destOffset += 3 + alpha01;
  48253. }
  48254. },
  48255. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48256. return inputLength * (3 + alpha01);
  48257. },
  48258. isPassthrough: ColorSpace.prototype.isPassthrough,
  48259. fillRgb: ColorSpace.prototype.fillRgb,
  48260. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48261. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48262. },
  48263. usesZeroToOneRange: true
  48264. };
  48265. return CalGrayCS;
  48266. }();
  48267. var CalRGBCS = function CalRGBCSClosure() {
  48268. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48269. 0.8951,
  48270. 0.2664,
  48271. -0.1614,
  48272. -0.7502,
  48273. 1.7135,
  48274. 0.0367,
  48275. 0.0389,
  48276. -0.0685,
  48277. 1.0296
  48278. ]);
  48279. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48280. 0.9869929,
  48281. -0.1470543,
  48282. 0.1599627,
  48283. 0.4323053,
  48284. 0.5183603,
  48285. 0.0492912,
  48286. -0.0085287,
  48287. 0.0400428,
  48288. 0.9684867
  48289. ]);
  48290. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48291. 3.2404542,
  48292. -1.5371385,
  48293. -0.4985314,
  48294. -0.9692660,
  48295. 1.8760108,
  48296. 0.0415560,
  48297. 0.0556434,
  48298. -0.2040259,
  48299. 1.0572252
  48300. ]);
  48301. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48302. 1,
  48303. 1,
  48304. 1
  48305. ]);
  48306. var tempNormalizeMatrix = new Float32Array(3);
  48307. var tempConvertMatrix1 = new Float32Array(3);
  48308. var tempConvertMatrix2 = new Float32Array(3);
  48309. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48310. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48311. this.name = 'CalRGB';
  48312. this.numComps = 3;
  48313. this.defaultColor = new Float32Array(3);
  48314. if (!whitePoint) {
  48315. error('WhitePoint missing - required for color space CalRGB');
  48316. }
  48317. blackPoint = blackPoint || new Float32Array(3);
  48318. gamma = gamma || new Float32Array([
  48319. 1,
  48320. 1,
  48321. 1
  48322. ]);
  48323. matrix = matrix || new Float32Array([
  48324. 1,
  48325. 0,
  48326. 0,
  48327. 0,
  48328. 1,
  48329. 0,
  48330. 0,
  48331. 0,
  48332. 1
  48333. ]);
  48334. var XW = whitePoint[0];
  48335. var YW = whitePoint[1];
  48336. var ZW = whitePoint[2];
  48337. this.whitePoint = whitePoint;
  48338. var XB = blackPoint[0];
  48339. var YB = blackPoint[1];
  48340. var ZB = blackPoint[2];
  48341. this.blackPoint = blackPoint;
  48342. this.GR = gamma[0];
  48343. this.GG = gamma[1];
  48344. this.GB = gamma[2];
  48345. this.MXA = matrix[0];
  48346. this.MYA = matrix[1];
  48347. this.MZA = matrix[2];
  48348. this.MXB = matrix[3];
  48349. this.MYB = matrix[4];
  48350. this.MZB = matrix[5];
  48351. this.MXC = matrix[6];
  48352. this.MYC = matrix[7];
  48353. this.MZC = matrix[8];
  48354. if (XW < 0 || ZW < 0 || YW !== 1) {
  48355. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48356. }
  48357. if (XB < 0 || YB < 0 || ZB < 0) {
  48358. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48359. this.blackPoint = new Float32Array(3);
  48360. }
  48361. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48362. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48363. this.GR = this.GG = this.GB = 1;
  48364. }
  48365. 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) {
  48366. 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');
  48367. this.MXA = this.MYB = this.MZC = 1;
  48368. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48369. }
  48370. }
  48371. function matrixProduct(a, b, result) {
  48372. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48373. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48374. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48375. }
  48376. function convertToFlat(sourceWhitePoint, LMS, result) {
  48377. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48378. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48379. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48380. }
  48381. function convertToD65(sourceWhitePoint, LMS, result) {
  48382. var D65X = 0.95047;
  48383. var D65Y = 1;
  48384. var D65Z = 1.08883;
  48385. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48386. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48387. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48388. }
  48389. function sRGBTransferFunction(color) {
  48390. if (color <= 0.0031308) {
  48391. return adjustToRange(0, 1, 12.92 * color);
  48392. }
  48393. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48394. }
  48395. function adjustToRange(min, max, value) {
  48396. return Math.max(min, Math.min(max, value));
  48397. }
  48398. function decodeL(L) {
  48399. if (L < 0) {
  48400. return -decodeL(-L);
  48401. }
  48402. if (L > 8.0) {
  48403. return Math.pow((L + 16) / 116, 3);
  48404. }
  48405. return L * DECODE_L_CONSTANT;
  48406. }
  48407. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48408. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48409. result[0] = XYZ_Flat[0];
  48410. result[1] = XYZ_Flat[1];
  48411. result[2] = XYZ_Flat[2];
  48412. return;
  48413. }
  48414. var zeroDecodeL = decodeL(0);
  48415. var X_DST = zeroDecodeL;
  48416. var X_SRC = decodeL(sourceBlackPoint[0]);
  48417. var Y_DST = zeroDecodeL;
  48418. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48419. var Z_DST = zeroDecodeL;
  48420. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48421. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48422. var X_Offset = 1 - X_Scale;
  48423. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48424. var Y_Offset = 1 - Y_Scale;
  48425. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48426. var Z_Offset = 1 - Z_Scale;
  48427. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48428. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48429. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48430. }
  48431. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48432. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48433. result[0] = XYZ_In[0];
  48434. result[1] = XYZ_In[1];
  48435. result[2] = XYZ_In[2];
  48436. return;
  48437. }
  48438. var LMS = result;
  48439. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48440. var LMS_Flat = tempNormalizeMatrix;
  48441. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48442. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48443. }
  48444. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48445. var LMS = result;
  48446. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48447. var LMS_D65 = tempNormalizeMatrix;
  48448. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48449. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48450. }
  48451. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48452. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48453. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48454. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48455. var AGR = Math.pow(A, cs.GR);
  48456. var BGG = Math.pow(B, cs.GG);
  48457. var CGB = Math.pow(C, cs.GB);
  48458. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48459. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48460. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48461. var XYZ = tempConvertMatrix1;
  48462. XYZ[0] = X;
  48463. XYZ[1] = Y;
  48464. XYZ[2] = Z;
  48465. var XYZ_Flat = tempConvertMatrix2;
  48466. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48467. var XYZ_Black = tempConvertMatrix1;
  48468. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48469. var XYZ_D65 = tempConvertMatrix2;
  48470. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48471. var SRGB = tempConvertMatrix1;
  48472. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48473. var sR = sRGBTransferFunction(SRGB[0]);
  48474. var sG = sRGBTransferFunction(SRGB[1]);
  48475. var sB = sRGBTransferFunction(SRGB[2]);
  48476. dest[destOffset] = Math.round(sR * 255);
  48477. dest[destOffset + 1] = Math.round(sG * 255);
  48478. dest[destOffset + 2] = Math.round(sB * 255);
  48479. }
  48480. CalRGBCS.prototype = {
  48481. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48482. var rgb = new Uint8Array(3);
  48483. this.getRgbItem(src, srcOffset, rgb, 0);
  48484. return rgb;
  48485. },
  48486. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48487. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48488. },
  48489. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48490. var scale = 1 / ((1 << bits) - 1);
  48491. for (var i = 0; i < count; ++i) {
  48492. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48493. srcOffset += 3;
  48494. destOffset += 3 + alpha01;
  48495. }
  48496. },
  48497. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48498. return inputLength * (3 + alpha01) / 3 | 0;
  48499. },
  48500. isPassthrough: ColorSpace.prototype.isPassthrough,
  48501. fillRgb: ColorSpace.prototype.fillRgb,
  48502. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48503. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48504. },
  48505. usesZeroToOneRange: true
  48506. };
  48507. return CalRGBCS;
  48508. }();
  48509. var LabCS = function LabCSClosure() {
  48510. function LabCS(whitePoint, blackPoint, range) {
  48511. this.name = 'Lab';
  48512. this.numComps = 3;
  48513. this.defaultColor = new Float32Array([
  48514. 0,
  48515. 0,
  48516. 0
  48517. ]);
  48518. if (!whitePoint) {
  48519. error('WhitePoint missing - required for color space Lab');
  48520. }
  48521. blackPoint = blackPoint || [
  48522. 0,
  48523. 0,
  48524. 0
  48525. ];
  48526. range = range || [
  48527. -100,
  48528. 100,
  48529. -100,
  48530. 100
  48531. ];
  48532. this.XW = whitePoint[0];
  48533. this.YW = whitePoint[1];
  48534. this.ZW = whitePoint[2];
  48535. this.amin = range[0];
  48536. this.amax = range[1];
  48537. this.bmin = range[2];
  48538. this.bmax = range[3];
  48539. this.XB = blackPoint[0];
  48540. this.YB = blackPoint[1];
  48541. this.ZB = blackPoint[2];
  48542. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48543. error('Invalid WhitePoint components, no fallback available');
  48544. }
  48545. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48546. info('Invalid BlackPoint, falling back to default');
  48547. this.XB = this.YB = this.ZB = 0;
  48548. }
  48549. if (this.amin > this.amax || this.bmin > this.bmax) {
  48550. info('Invalid Range, falling back to defaults');
  48551. this.amin = -100;
  48552. this.amax = 100;
  48553. this.bmin = -100;
  48554. this.bmax = 100;
  48555. }
  48556. }
  48557. function fn_g(x) {
  48558. if (x >= 6 / 29) {
  48559. return x * x * x;
  48560. } else {
  48561. return 108 / 841 * (x - 4 / 29);
  48562. }
  48563. }
  48564. function decode(value, high1, low2, high2) {
  48565. return low2 + value * (high2 - low2) / high1;
  48566. }
  48567. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48568. var Ls = src[srcOffset];
  48569. var as = src[srcOffset + 1];
  48570. var bs = src[srcOffset + 2];
  48571. if (maxVal !== false) {
  48572. Ls = decode(Ls, maxVal, 0, 100);
  48573. as = decode(as, maxVal, cs.amin, cs.amax);
  48574. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48575. }
  48576. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48577. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48578. var M = (Ls + 16) / 116;
  48579. var L = M + as / 500;
  48580. var N = M - bs / 200;
  48581. var X = cs.XW * fn_g(L);
  48582. var Y = cs.YW * fn_g(M);
  48583. var Z = cs.ZW * fn_g(N);
  48584. var r, g, b;
  48585. if (cs.ZW < 1) {
  48586. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48587. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48588. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48589. } else {
  48590. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48591. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48592. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48593. }
  48594. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48595. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48596. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48597. }
  48598. LabCS.prototype = {
  48599. getRgb: ColorSpace.prototype.getRgb,
  48600. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48601. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48602. },
  48603. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48604. var maxVal = (1 << bits) - 1;
  48605. for (var i = 0; i < count; i++) {
  48606. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48607. srcOffset += 3;
  48608. destOffset += 3 + alpha01;
  48609. }
  48610. },
  48611. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48612. return inputLength * (3 + alpha01) / 3 | 0;
  48613. },
  48614. isPassthrough: ColorSpace.prototype.isPassthrough,
  48615. fillRgb: ColorSpace.prototype.fillRgb,
  48616. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48617. return true;
  48618. },
  48619. usesZeroToOneRange: false
  48620. };
  48621. return LabCS;
  48622. }();
  48623. exports.ColorSpace = ColorSpace;
  48624. }));
  48625. (function (root, factory) {
  48626. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48627. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48628. var globalScope = sharedUtil.globalScope;
  48629. var deprecated = sharedUtil.deprecated;
  48630. var warn = sharedUtil.warn;
  48631. var LinkTarget = displayDOMUtils.LinkTarget;
  48632. var isWorker = typeof window === 'undefined';
  48633. if (!globalScope.PDFJS) {
  48634. globalScope.PDFJS = {};
  48635. }
  48636. var PDFJS = globalScope.PDFJS;
  48637. if (typeof pdfjsVersion !== 'undefined') {
  48638. PDFJS.version = pdfjsVersion;
  48639. }
  48640. if (typeof pdfjsBuild !== 'undefined') {
  48641. PDFJS.build = pdfjsBuild;
  48642. }
  48643. PDFJS.pdfBug = false;
  48644. if (PDFJS.verbosity !== undefined) {
  48645. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  48646. }
  48647. delete PDFJS.verbosity;
  48648. Object.defineProperty(PDFJS, 'verbosity', {
  48649. get: function () {
  48650. return sharedUtil.getVerbosityLevel();
  48651. },
  48652. set: function (level) {
  48653. sharedUtil.setVerbosityLevel(level);
  48654. },
  48655. enumerable: true,
  48656. configurable: true
  48657. });
  48658. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  48659. PDFJS.OPS = sharedUtil.OPS;
  48660. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  48661. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  48662. PDFJS.shadow = sharedUtil.shadow;
  48663. PDFJS.createBlob = sharedUtil.createBlob;
  48664. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  48665. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  48666. };
  48667. Object.defineProperty(PDFJS, 'isLittleEndian', {
  48668. configurable: true,
  48669. get: function PDFJS_isLittleEndian() {
  48670. var value = sharedUtil.isLittleEndian();
  48671. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  48672. }
  48673. });
  48674. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  48675. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  48676. PDFJS.PasswordException = sharedUtil.PasswordException;
  48677. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  48678. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  48679. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  48680. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  48681. PDFJS.Util = sharedUtil.Util;
  48682. PDFJS.PageViewport = sharedUtil.PageViewport;
  48683. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  48684. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  48685. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  48686. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  48687. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  48688. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  48689. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  48690. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  48691. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  48692. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  48693. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  48694. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  48695. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  48696. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  48697. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  48698. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  48699. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? 'noreferrer' : PDFJS.externalLinkRel;
  48700. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  48701. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  48702. delete PDFJS.openExternalLinksInNewWindow;
  48703. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  48704. get: function () {
  48705. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  48706. },
  48707. set: function (value) {
  48708. if (value) {
  48709. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  48710. }
  48711. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  48712. warn('PDFJS.externalLinkTarget is already initialized');
  48713. return;
  48714. }
  48715. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  48716. },
  48717. enumerable: true,
  48718. configurable: true
  48719. });
  48720. if (savedOpenExternalLinksInNewWindow) {
  48721. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  48722. }
  48723. PDFJS.getDocument = displayAPI.getDocument;
  48724. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  48725. PDFJS.PDFWorker = displayAPI.PDFWorker;
  48726. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  48727. configurable: true,
  48728. get: function PDFJS_hasCanvasTypedArrays() {
  48729. var value = displayDOMUtils.hasCanvasTypedArrays();
  48730. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  48731. }
  48732. });
  48733. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  48734. PDFJS.LinkTarget = LinkTarget;
  48735. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  48736. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  48737. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  48738. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  48739. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  48740. PDFJS.Metadata = displayMetadata.Metadata;
  48741. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  48742. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  48743. exports.globalScope = globalScope;
  48744. exports.isWorker = isWorker;
  48745. exports.PDFJS = globalScope.PDFJS;
  48746. }));
  48747. (function (root, factory) {
  48748. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  48749. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  48750. var ImageKind = sharedUtil.ImageKind;
  48751. var assert = sharedUtil.assert;
  48752. var error = sharedUtil.error;
  48753. var info = sharedUtil.info;
  48754. var isArray = sharedUtil.isArray;
  48755. var warn = sharedUtil.warn;
  48756. var Name = corePrimitives.Name;
  48757. var isStream = corePrimitives.isStream;
  48758. var ColorSpace = coreColorSpace.ColorSpace;
  48759. var DecodeStream = coreStream.DecodeStream;
  48760. var JpegStream = coreStream.JpegStream;
  48761. var JpxImage = coreJpx.JpxImage;
  48762. var PDFImage = function PDFImageClosure() {
  48763. function handleImageData(image, nativeDecoder) {
  48764. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  48765. return nativeDecoder.decode(image);
  48766. } else {
  48767. return Promise.resolve(image);
  48768. }
  48769. }
  48770. function decodeAndClamp(value, addend, coefficient, max) {
  48771. value = addend + value * coefficient;
  48772. return value < 0 ? 0 : value > max ? max : value;
  48773. }
  48774. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48775. var length = w2 * h2;
  48776. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48777. var xRatio = w1 / w2;
  48778. var yRatio = h1 / h2;
  48779. var i, j, py, newIndex = 0, oldIndex;
  48780. var xScaled = new Uint16Array(w2);
  48781. var w1Scanline = w1;
  48782. for (i = 0; i < w2; i++) {
  48783. xScaled[i] = Math.floor(i * xRatio);
  48784. }
  48785. for (i = 0; i < h2; i++) {
  48786. py = Math.floor(i * yRatio) * w1Scanline;
  48787. for (j = 0; j < w2; j++) {
  48788. oldIndex = py + xScaled[j];
  48789. dest[newIndex++] = src[oldIndex];
  48790. }
  48791. }
  48792. return dest;
  48793. }
  48794. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48795. this.image = image;
  48796. var dict = image.dict;
  48797. if (dict.has('Filter')) {
  48798. var filter = dict.get('Filter').name;
  48799. if (filter === 'JPXDecode') {
  48800. var jpxImage = new JpxImage();
  48801. jpxImage.parseImageProperties(image.stream);
  48802. image.stream.reset();
  48803. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48804. image.numComps = jpxImage.componentsCount;
  48805. } else if (filter === 'JBIG2Decode') {
  48806. image.bitsPerComponent = 1;
  48807. image.numComps = 1;
  48808. }
  48809. }
  48810. this.width = dict.get('Width', 'W');
  48811. this.height = dict.get('Height', 'H');
  48812. if (this.width < 1 || this.height < 1) {
  48813. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48814. }
  48815. this.interpolate = dict.get('Interpolate', 'I') || false;
  48816. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48817. this.matte = dict.get('Matte') || false;
  48818. var bitsPerComponent = image.bitsPerComponent;
  48819. if (!bitsPerComponent) {
  48820. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48821. if (!bitsPerComponent) {
  48822. if (this.imageMask) {
  48823. bitsPerComponent = 1;
  48824. } else {
  48825. error('Bits per component missing in image: ' + this.imageMask);
  48826. }
  48827. }
  48828. }
  48829. this.bpc = bitsPerComponent;
  48830. if (!this.imageMask) {
  48831. var colorSpace = dict.get('ColorSpace', 'CS');
  48832. if (!colorSpace) {
  48833. info('JPX images (which do not require color spaces)');
  48834. switch (image.numComps) {
  48835. case 1:
  48836. colorSpace = Name.get('DeviceGray');
  48837. break;
  48838. case 3:
  48839. colorSpace = Name.get('DeviceRGB');
  48840. break;
  48841. case 4:
  48842. colorSpace = Name.get('DeviceCMYK');
  48843. break;
  48844. default:
  48845. error('JPX images with ' + this.numComps + ' color components not supported.');
  48846. }
  48847. }
  48848. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  48849. this.numComps = this.colorSpace.numComps;
  48850. }
  48851. this.decode = dict.getArray('Decode', 'D');
  48852. this.needsDecode = false;
  48853. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  48854. this.needsDecode = true;
  48855. var max = (1 << bitsPerComponent) - 1;
  48856. this.decodeCoefficients = [];
  48857. this.decodeAddends = [];
  48858. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  48859. var dmin = this.decode[i];
  48860. var dmax = this.decode[i + 1];
  48861. this.decodeCoefficients[j] = dmax - dmin;
  48862. this.decodeAddends[j] = max * dmin;
  48863. }
  48864. }
  48865. if (smask) {
  48866. this.smask = new PDFImage(xref, res, smask, false);
  48867. } else if (mask) {
  48868. if (isStream(mask)) {
  48869. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  48870. if (!imageMask) {
  48871. warn('Ignoring /Mask in image without /ImageMask.');
  48872. } else {
  48873. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  48874. }
  48875. } else {
  48876. this.mask = mask;
  48877. }
  48878. }
  48879. }
  48880. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  48881. var imagePromise = handleImageData(image, nativeDecoder);
  48882. var smaskPromise;
  48883. var maskPromise;
  48884. var smask = image.dict.get('SMask');
  48885. var mask = image.dict.get('Mask');
  48886. if (smask) {
  48887. smaskPromise = handleImageData(smask, nativeDecoder);
  48888. maskPromise = Promise.resolve(null);
  48889. } else {
  48890. smaskPromise = Promise.resolve(null);
  48891. if (mask) {
  48892. if (isStream(mask)) {
  48893. maskPromise = handleImageData(mask, nativeDecoder);
  48894. } else if (isArray(mask)) {
  48895. maskPromise = Promise.resolve(mask);
  48896. } else {
  48897. warn('Unsupported mask format.');
  48898. maskPromise = Promise.resolve(null);
  48899. }
  48900. } else {
  48901. maskPromise = Promise.resolve(null);
  48902. }
  48903. }
  48904. return Promise.all([
  48905. imagePromise,
  48906. smaskPromise,
  48907. maskPromise
  48908. ]).then(function (results) {
  48909. var imageData = results[0];
  48910. var smaskData = results[1];
  48911. var maskData = results[2];
  48912. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  48913. });
  48914. };
  48915. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  48916. var computedLength = (width + 7 >> 3) * height;
  48917. var actualLength = imgArray.byteLength;
  48918. var haveFullData = computedLength === actualLength;
  48919. var data, i;
  48920. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  48921. data = imgArray;
  48922. } else if (!inverseDecode) {
  48923. data = new Uint8Array(actualLength);
  48924. data.set(imgArray);
  48925. } else {
  48926. data = new Uint8Array(computedLength);
  48927. data.set(imgArray);
  48928. for (i = actualLength; i < computedLength; i++) {
  48929. data[i] = 0xff;
  48930. }
  48931. }
  48932. if (inverseDecode) {
  48933. for (i = 0; i < actualLength; i++) {
  48934. data[i] = ~data[i];
  48935. }
  48936. }
  48937. return {
  48938. data: data,
  48939. width: width,
  48940. height: height
  48941. };
  48942. };
  48943. PDFImage.prototype = {
  48944. get drawWidth() {
  48945. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  48946. },
  48947. get drawHeight() {
  48948. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  48949. },
  48950. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  48951. var bpc = this.bpc;
  48952. var numComps = this.numComps;
  48953. var decodeAddends = this.decodeAddends;
  48954. var decodeCoefficients = this.decodeCoefficients;
  48955. var max = (1 << bpc) - 1;
  48956. var i, ii;
  48957. if (bpc === 1) {
  48958. for (i = 0, ii = buffer.length; i < ii; i++) {
  48959. buffer[i] = +!buffer[i];
  48960. }
  48961. return;
  48962. }
  48963. var index = 0;
  48964. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  48965. for (var j = 0; j < numComps; j++) {
  48966. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  48967. index++;
  48968. }
  48969. }
  48970. },
  48971. getComponents: function PDFImage_getComponents(buffer) {
  48972. var bpc = this.bpc;
  48973. if (bpc === 8) {
  48974. return buffer;
  48975. }
  48976. var width = this.width;
  48977. var height = this.height;
  48978. var numComps = this.numComps;
  48979. var length = width * height * numComps;
  48980. var bufferPos = 0;
  48981. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48982. var rowComps = width * numComps;
  48983. var max = (1 << bpc) - 1;
  48984. var i = 0, ii, buf;
  48985. if (bpc === 1) {
  48986. var mask, loop1End, loop2End;
  48987. for (var j = 0; j < height; j++) {
  48988. loop1End = i + (rowComps & ~7);
  48989. loop2End = i + rowComps;
  48990. while (i < loop1End) {
  48991. buf = buffer[bufferPos++];
  48992. output[i] = buf >> 7 & 1;
  48993. output[i + 1] = buf >> 6 & 1;
  48994. output[i + 2] = buf >> 5 & 1;
  48995. output[i + 3] = buf >> 4 & 1;
  48996. output[i + 4] = buf >> 3 & 1;
  48997. output[i + 5] = buf >> 2 & 1;
  48998. output[i + 6] = buf >> 1 & 1;
  48999. output[i + 7] = buf & 1;
  49000. i += 8;
  49001. }
  49002. if (i < loop2End) {
  49003. buf = buffer[bufferPos++];
  49004. mask = 128;
  49005. while (i < loop2End) {
  49006. output[i++] = +!!(buf & mask);
  49007. mask >>= 1;
  49008. }
  49009. }
  49010. }
  49011. } else {
  49012. var bits = 0;
  49013. buf = 0;
  49014. for (i = 0, ii = length; i < ii; ++i) {
  49015. if (i % rowComps === 0) {
  49016. buf = 0;
  49017. bits = 0;
  49018. }
  49019. while (bits < bpc) {
  49020. buf = buf << 8 | buffer[bufferPos++];
  49021. bits += 8;
  49022. }
  49023. var remainingBits = bits - bpc;
  49024. var value = buf >> remainingBits;
  49025. output[i] = value < 0 ? 0 : value > max ? max : value;
  49026. buf = buf & (1 << remainingBits) - 1;
  49027. bits = remainingBits;
  49028. }
  49029. }
  49030. return output;
  49031. },
  49032. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49033. var smask = this.smask;
  49034. var mask = this.mask;
  49035. var alphaBuf, sw, sh, i, ii, j;
  49036. if (smask) {
  49037. sw = smask.width;
  49038. sh = smask.height;
  49039. alphaBuf = new Uint8Array(sw * sh);
  49040. smask.fillGrayBuffer(alphaBuf);
  49041. if (sw !== width || sh !== height) {
  49042. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49043. }
  49044. } else if (mask) {
  49045. if (mask instanceof PDFImage) {
  49046. sw = mask.width;
  49047. sh = mask.height;
  49048. alphaBuf = new Uint8Array(sw * sh);
  49049. mask.numComps = 1;
  49050. mask.fillGrayBuffer(alphaBuf);
  49051. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49052. alphaBuf[i] = 255 - alphaBuf[i];
  49053. }
  49054. if (sw !== width || sh !== height) {
  49055. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49056. }
  49057. } else if (isArray(mask)) {
  49058. alphaBuf = new Uint8Array(width * height);
  49059. var numComps = this.numComps;
  49060. for (i = 0, ii = width * height; i < ii; ++i) {
  49061. var opacity = 0;
  49062. var imageOffset = i * numComps;
  49063. for (j = 0; j < numComps; ++j) {
  49064. var color = image[imageOffset + j];
  49065. var maskOffset = j * 2;
  49066. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49067. opacity = 255;
  49068. break;
  49069. }
  49070. }
  49071. alphaBuf[i] = opacity;
  49072. }
  49073. } else {
  49074. error('Unknown mask format.');
  49075. }
  49076. }
  49077. if (alphaBuf) {
  49078. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49079. rgbaBuf[j] = alphaBuf[i];
  49080. }
  49081. } else {
  49082. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49083. rgbaBuf[j] = 255;
  49084. }
  49085. }
  49086. },
  49087. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49088. var matte = this.smask && this.smask.matte;
  49089. if (!matte) {
  49090. return;
  49091. }
  49092. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49093. var matteR = matteRgb[0];
  49094. var matteG = matteRgb[1];
  49095. var matteB = matteRgb[2];
  49096. var length = width * height * 4;
  49097. var r, g, b;
  49098. for (var i = 0; i < length; i += 4) {
  49099. var alpha = buffer[i + 3];
  49100. if (alpha === 0) {
  49101. buffer[i] = 255;
  49102. buffer[i + 1] = 255;
  49103. buffer[i + 2] = 255;
  49104. continue;
  49105. }
  49106. var k = 255 / alpha;
  49107. r = (buffer[i] - matteR) * k + matteR;
  49108. g = (buffer[i + 1] - matteG) * k + matteG;
  49109. b = (buffer[i + 2] - matteB) * k + matteB;
  49110. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49111. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49112. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49113. }
  49114. },
  49115. createImageData: function PDFImage_createImageData(forceRGBA) {
  49116. var drawWidth = this.drawWidth;
  49117. var drawHeight = this.drawHeight;
  49118. var imgData = {
  49119. width: drawWidth,
  49120. height: drawHeight
  49121. };
  49122. var numComps = this.numComps;
  49123. var originalWidth = this.width;
  49124. var originalHeight = this.height;
  49125. var bpc = this.bpc;
  49126. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49127. var imgArray;
  49128. if (!forceRGBA) {
  49129. var kind;
  49130. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49131. kind = ImageKind.GRAYSCALE_1BPP;
  49132. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49133. kind = ImageKind.RGB_24BPP;
  49134. }
  49135. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49136. imgData.kind = kind;
  49137. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49138. if (this.image instanceof DecodeStream) {
  49139. imgData.data = imgArray;
  49140. } else {
  49141. var newArray = new Uint8Array(imgArray.length);
  49142. newArray.set(imgArray);
  49143. imgData.data = newArray;
  49144. }
  49145. if (this.needsDecode) {
  49146. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49147. var buffer = imgData.data;
  49148. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49149. buffer[i] ^= 0xff;
  49150. }
  49151. }
  49152. return imgData;
  49153. }
  49154. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49155. imgData.kind = ImageKind.RGB_24BPP;
  49156. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49157. return imgData;
  49158. }
  49159. }
  49160. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49161. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49162. var comps = this.getComponents(imgArray);
  49163. var alpha01, maybeUndoPreblend;
  49164. if (!forceRGBA && !this.smask && !this.mask) {
  49165. imgData.kind = ImageKind.RGB_24BPP;
  49166. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49167. alpha01 = 0;
  49168. maybeUndoPreblend = false;
  49169. } else {
  49170. imgData.kind = ImageKind.RGBA_32BPP;
  49171. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49172. alpha01 = 1;
  49173. maybeUndoPreblend = true;
  49174. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49175. }
  49176. if (this.needsDecode) {
  49177. this.decodeBuffer(comps);
  49178. }
  49179. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49180. if (maybeUndoPreblend) {
  49181. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49182. }
  49183. return imgData;
  49184. },
  49185. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49186. var numComps = this.numComps;
  49187. if (numComps !== 1) {
  49188. error('Reading gray scale from a color image: ' + numComps);
  49189. }
  49190. var width = this.width;
  49191. var height = this.height;
  49192. var bpc = this.bpc;
  49193. var rowBytes = width * numComps * bpc + 7 >> 3;
  49194. var imgArray = this.getImageBytes(height * rowBytes);
  49195. var comps = this.getComponents(imgArray);
  49196. var i, length;
  49197. if (bpc === 1) {
  49198. length = width * height;
  49199. if (this.needsDecode) {
  49200. for (i = 0; i < length; ++i) {
  49201. buffer[i] = comps[i] - 1 & 255;
  49202. }
  49203. } else {
  49204. for (i = 0; i < length; ++i) {
  49205. buffer[i] = -comps[i] & 255;
  49206. }
  49207. }
  49208. return;
  49209. }
  49210. if (this.needsDecode) {
  49211. this.decodeBuffer(comps);
  49212. }
  49213. length = width * height;
  49214. var scale = 255 / ((1 << bpc) - 1);
  49215. for (i = 0; i < length; ++i) {
  49216. buffer[i] = scale * comps[i] | 0;
  49217. }
  49218. },
  49219. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49220. this.image.reset();
  49221. this.image.drawWidth = drawWidth || this.width;
  49222. this.image.drawHeight = drawHeight || this.height;
  49223. this.image.forceRGB = !!forceRGB;
  49224. return this.image.getBytes(length);
  49225. }
  49226. };
  49227. return PDFImage;
  49228. }();
  49229. exports.PDFImage = PDFImage;
  49230. }));
  49231. (function (root, factory) {
  49232. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49233. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49234. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49235. var MissingDataException = sharedUtil.MissingDataException;
  49236. var XRefParseException = sharedUtil.XRefParseException;
  49237. var assert = sharedUtil.assert;
  49238. var bytesToString = sharedUtil.bytesToString;
  49239. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49240. var error = sharedUtil.error;
  49241. var info = sharedUtil.info;
  49242. var isArray = sharedUtil.isArray;
  49243. var isBool = sharedUtil.isBool;
  49244. var isInt = sharedUtil.isInt;
  49245. var isString = sharedUtil.isString;
  49246. var shadow = sharedUtil.shadow;
  49247. var stringToPDFString = sharedUtil.stringToPDFString;
  49248. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49249. var warn = sharedUtil.warn;
  49250. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49251. var Util = sharedUtil.Util;
  49252. var Ref = corePrimitives.Ref;
  49253. var RefSet = corePrimitives.RefSet;
  49254. var RefSetCache = corePrimitives.RefSetCache;
  49255. var isName = corePrimitives.isName;
  49256. var isCmd = corePrimitives.isCmd;
  49257. var isDict = corePrimitives.isDict;
  49258. var isRef = corePrimitives.isRef;
  49259. var isRefsEqual = corePrimitives.isRefsEqual;
  49260. var isStream = corePrimitives.isStream;
  49261. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49262. var Lexer = coreParser.Lexer;
  49263. var Parser = coreParser.Parser;
  49264. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49265. var ColorSpace = coreColorSpace.ColorSpace;
  49266. var Catalog = function CatalogClosure() {
  49267. function Catalog(pdfManager, xref, pageFactory) {
  49268. this.pdfManager = pdfManager;
  49269. this.xref = xref;
  49270. this.catDict = xref.getCatalogObj();
  49271. this.fontCache = new RefSetCache();
  49272. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49273. this.pageFactory = pageFactory;
  49274. this.pagePromises = [];
  49275. }
  49276. Catalog.prototype = {
  49277. get metadata() {
  49278. var streamRef = this.catDict.getRaw('Metadata');
  49279. if (!isRef(streamRef)) {
  49280. return shadow(this, 'metadata', null);
  49281. }
  49282. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49283. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49284. var metadata;
  49285. if (stream && isDict(stream.dict)) {
  49286. var type = stream.dict.get('Type');
  49287. var subtype = stream.dict.get('Subtype');
  49288. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49289. try {
  49290. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49291. } catch (e) {
  49292. info('Skipping invalid metadata.');
  49293. }
  49294. }
  49295. }
  49296. return shadow(this, 'metadata', metadata);
  49297. },
  49298. get toplevelPagesDict() {
  49299. var pagesObj = this.catDict.get('Pages');
  49300. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49301. return shadow(this, 'toplevelPagesDict', pagesObj);
  49302. },
  49303. get documentOutline() {
  49304. var obj = null;
  49305. try {
  49306. obj = this.readDocumentOutline();
  49307. } catch (ex) {
  49308. if (ex instanceof MissingDataException) {
  49309. throw ex;
  49310. }
  49311. warn('Unable to read document outline');
  49312. }
  49313. return shadow(this, 'documentOutline', obj);
  49314. },
  49315. readDocumentOutline: function Catalog_readDocumentOutline() {
  49316. var obj = this.catDict.get('Outlines');
  49317. if (!isDict(obj)) {
  49318. return null;
  49319. }
  49320. obj = obj.getRaw('First');
  49321. if (!isRef(obj)) {
  49322. return null;
  49323. }
  49324. var root = { items: [] };
  49325. var queue = [{
  49326. obj: obj,
  49327. parent: root
  49328. }];
  49329. var processed = new RefSet();
  49330. processed.put(obj);
  49331. var xref = this.xref, blackColor = new Uint8Array(3);
  49332. while (queue.length > 0) {
  49333. var i = queue.shift();
  49334. var outlineDict = xref.fetchIfRef(i.obj);
  49335. if (outlineDict === null) {
  49336. continue;
  49337. }
  49338. assert(outlineDict.has('Title'), 'Invalid outline item');
  49339. var data = {
  49340. url: null,
  49341. dest: null
  49342. };
  49343. Catalog.parseDestDictionary({
  49344. destDict: outlineDict,
  49345. resultObj: data,
  49346. docBaseUrl: this.pdfManager.docBaseUrl
  49347. });
  49348. var title = outlineDict.get('Title');
  49349. var flags = outlineDict.get('F') || 0;
  49350. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49351. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49352. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49353. }
  49354. var outlineItem = {
  49355. dest: data.dest,
  49356. url: data.url,
  49357. unsafeUrl: data.unsafeUrl,
  49358. newWindow: data.newWindow,
  49359. title: stringToPDFString(title),
  49360. color: rgbColor,
  49361. count: outlineDict.get('Count'),
  49362. bold: !!(flags & 2),
  49363. italic: !!(flags & 1),
  49364. items: []
  49365. };
  49366. i.parent.items.push(outlineItem);
  49367. obj = outlineDict.getRaw('First');
  49368. if (isRef(obj) && !processed.has(obj)) {
  49369. queue.push({
  49370. obj: obj,
  49371. parent: outlineItem
  49372. });
  49373. processed.put(obj);
  49374. }
  49375. obj = outlineDict.getRaw('Next');
  49376. if (isRef(obj) && !processed.has(obj)) {
  49377. queue.push({
  49378. obj: obj,
  49379. parent: i.parent
  49380. });
  49381. processed.put(obj);
  49382. }
  49383. }
  49384. return root.items.length > 0 ? root.items : null;
  49385. },
  49386. get numPages() {
  49387. var obj = this.toplevelPagesDict.get('Count');
  49388. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49389. return shadow(this, 'num', obj);
  49390. },
  49391. get destinations() {
  49392. function fetchDestination(dest) {
  49393. return isDict(dest) ? dest.get('D') : dest;
  49394. }
  49395. var xref = this.xref;
  49396. var dests = {}, nameTreeRef, nameDictionaryRef;
  49397. var obj = this.catDict.get('Names');
  49398. if (obj && obj.has('Dests')) {
  49399. nameTreeRef = obj.getRaw('Dests');
  49400. } else if (this.catDict.has('Dests')) {
  49401. nameDictionaryRef = this.catDict.get('Dests');
  49402. }
  49403. if (nameDictionaryRef) {
  49404. obj = nameDictionaryRef;
  49405. obj.forEach(function catalogForEach(key, value) {
  49406. if (!value) {
  49407. return;
  49408. }
  49409. dests[key] = fetchDestination(value);
  49410. });
  49411. }
  49412. if (nameTreeRef) {
  49413. var nameTree = new NameTree(nameTreeRef, xref);
  49414. var names = nameTree.getAll();
  49415. for (var name in names) {
  49416. dests[name] = fetchDestination(names[name]);
  49417. }
  49418. }
  49419. return shadow(this, 'destinations', dests);
  49420. },
  49421. getDestination: function Catalog_getDestination(destinationId) {
  49422. function fetchDestination(dest) {
  49423. return isDict(dest) ? dest.get('D') : dest;
  49424. }
  49425. var xref = this.xref;
  49426. var dest = null, nameTreeRef, nameDictionaryRef;
  49427. var obj = this.catDict.get('Names');
  49428. if (obj && obj.has('Dests')) {
  49429. nameTreeRef = obj.getRaw('Dests');
  49430. } else if (this.catDict.has('Dests')) {
  49431. nameDictionaryRef = this.catDict.get('Dests');
  49432. }
  49433. if (nameDictionaryRef) {
  49434. var value = nameDictionaryRef.get(destinationId);
  49435. if (value) {
  49436. dest = fetchDestination(value);
  49437. }
  49438. }
  49439. if (nameTreeRef) {
  49440. var nameTree = new NameTree(nameTreeRef, xref);
  49441. dest = fetchDestination(nameTree.get(destinationId));
  49442. }
  49443. return dest;
  49444. },
  49445. get pageLabels() {
  49446. var obj = null;
  49447. try {
  49448. obj = this.readPageLabels();
  49449. } catch (ex) {
  49450. if (ex instanceof MissingDataException) {
  49451. throw ex;
  49452. }
  49453. warn('Unable to read page labels.');
  49454. }
  49455. return shadow(this, 'pageLabels', obj);
  49456. },
  49457. readPageLabels: function Catalog_readPageLabels() {
  49458. var obj = this.catDict.getRaw('PageLabels');
  49459. if (!obj) {
  49460. return null;
  49461. }
  49462. var pageLabels = new Array(this.numPages);
  49463. var style = null;
  49464. var prefix = '';
  49465. var numberTree = new NumberTree(obj, this.xref);
  49466. var nums = numberTree.getAll();
  49467. var currentLabel = '', currentIndex = 1;
  49468. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49469. if (i in nums) {
  49470. var labelDict = nums[i];
  49471. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49472. var type = labelDict.get('Type');
  49473. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49474. var s = labelDict.get('S');
  49475. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49476. style = s ? s.name : null;
  49477. var p = labelDict.get('P');
  49478. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49479. prefix = p ? stringToPDFString(p) : '';
  49480. var st = labelDict.get('St');
  49481. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49482. currentIndex = st || 1;
  49483. }
  49484. switch (style) {
  49485. case 'D':
  49486. currentLabel = currentIndex;
  49487. break;
  49488. case 'R':
  49489. case 'r':
  49490. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49491. break;
  49492. case 'A':
  49493. case 'a':
  49494. var LIMIT = 26;
  49495. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49496. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49497. var letterIndex = currentIndex - 1;
  49498. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49499. var charBuf = [];
  49500. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49501. charBuf.push(character);
  49502. }
  49503. currentLabel = charBuf.join('');
  49504. break;
  49505. default:
  49506. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49507. }
  49508. pageLabels[i] = prefix + currentLabel;
  49509. currentLabel = '';
  49510. currentIndex++;
  49511. }
  49512. return pageLabels;
  49513. },
  49514. get attachments() {
  49515. var xref = this.xref;
  49516. var attachments = null, nameTreeRef;
  49517. var obj = this.catDict.get('Names');
  49518. if (obj) {
  49519. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49520. }
  49521. if (nameTreeRef) {
  49522. var nameTree = new NameTree(nameTreeRef, xref);
  49523. var names = nameTree.getAll();
  49524. for (var name in names) {
  49525. var fs = new FileSpec(names[name], xref);
  49526. if (!attachments) {
  49527. attachments = Object.create(null);
  49528. }
  49529. attachments[stringToPDFString(name)] = fs.serializable;
  49530. }
  49531. }
  49532. return shadow(this, 'attachments', attachments);
  49533. },
  49534. get javaScript() {
  49535. var xref = this.xref;
  49536. var obj = this.catDict.get('Names');
  49537. var javaScript = [];
  49538. function appendIfJavaScriptDict(jsDict) {
  49539. var type = jsDict.get('S');
  49540. if (!isName(type, 'JavaScript')) {
  49541. return;
  49542. }
  49543. var js = jsDict.get('JS');
  49544. if (isStream(js)) {
  49545. js = bytesToString(js.getBytes());
  49546. } else if (!isString(js)) {
  49547. return;
  49548. }
  49549. javaScript.push(stringToPDFString(js));
  49550. }
  49551. if (obj && obj.has('JavaScript')) {
  49552. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49553. var names = nameTree.getAll();
  49554. for (var name in names) {
  49555. var jsDict = names[name];
  49556. if (isDict(jsDict)) {
  49557. appendIfJavaScriptDict(jsDict);
  49558. }
  49559. }
  49560. }
  49561. var openactionDict = this.catDict.get('OpenAction');
  49562. if (isDict(openactionDict, 'Action')) {
  49563. var actionType = openactionDict.get('S');
  49564. if (isName(actionType, 'Named')) {
  49565. var action = openactionDict.get('N');
  49566. if (isName(action, 'Print')) {
  49567. javaScript.push('print({});');
  49568. }
  49569. } else {
  49570. appendIfJavaScriptDict(openactionDict);
  49571. }
  49572. }
  49573. return shadow(this, 'javaScript', javaScript);
  49574. },
  49575. cleanup: function Catalog_cleanup() {
  49576. var promises = [];
  49577. this.fontCache.forEach(function (promise) {
  49578. promises.push(promise);
  49579. });
  49580. return Promise.all(promises).then(function (translatedFonts) {
  49581. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49582. var font = translatedFonts[i].dict;
  49583. delete font.translated;
  49584. }
  49585. this.fontCache.clear();
  49586. }.bind(this));
  49587. },
  49588. getPage: function Catalog_getPage(pageIndex) {
  49589. if (!(pageIndex in this.pagePromises)) {
  49590. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49591. var dict = a[0];
  49592. var ref = a[1];
  49593. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49594. }.bind(this));
  49595. }
  49596. return this.pagePromises[pageIndex];
  49597. },
  49598. getPageDict: function Catalog_getPageDict(pageIndex) {
  49599. var capability = createPromiseCapability();
  49600. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49601. var currentPageIndex = 0;
  49602. var xref = this.xref;
  49603. var checkAllKids = false;
  49604. function next() {
  49605. while (nodesToVisit.length) {
  49606. var currentNode = nodesToVisit.pop();
  49607. if (isRef(currentNode)) {
  49608. xref.fetchAsync(currentNode).then(function (obj) {
  49609. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49610. if (pageIndex === currentPageIndex) {
  49611. capability.resolve([
  49612. obj,
  49613. currentNode
  49614. ]);
  49615. } else {
  49616. currentPageIndex++;
  49617. next();
  49618. }
  49619. return;
  49620. }
  49621. nodesToVisit.push(obj);
  49622. next();
  49623. }, capability.reject);
  49624. return;
  49625. }
  49626. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49627. var count = currentNode.get('Count');
  49628. if (count === 0) {
  49629. checkAllKids = true;
  49630. }
  49631. if (currentPageIndex + count <= pageIndex) {
  49632. currentPageIndex += count;
  49633. continue;
  49634. }
  49635. var kids = currentNode.get('Kids');
  49636. assert(isArray(kids), 'page dictionary kids object is not an array');
  49637. if (!checkAllKids && count === kids.length) {
  49638. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49639. currentPageIndex = pageIndex;
  49640. continue;
  49641. } else {
  49642. for (var last = kids.length - 1; last >= 0; last--) {
  49643. nodesToVisit.push(kids[last]);
  49644. }
  49645. }
  49646. }
  49647. capability.reject('Page index ' + pageIndex + ' not found.');
  49648. }
  49649. next();
  49650. return capability.promise;
  49651. },
  49652. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49653. var xref = this.xref;
  49654. function pagesBeforeRef(kidRef) {
  49655. var total = 0;
  49656. var parentRef;
  49657. return xref.fetchAsync(kidRef).then(function (node) {
  49658. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49659. throw new Error('The reference does not point to a /Page Dict.');
  49660. }
  49661. if (!node) {
  49662. return null;
  49663. }
  49664. assert(isDict(node), 'node must be a Dict.');
  49665. parentRef = node.getRaw('Parent');
  49666. return node.getAsync('Parent');
  49667. }).then(function (parent) {
  49668. if (!parent) {
  49669. return null;
  49670. }
  49671. assert(isDict(parent), 'parent must be a Dict.');
  49672. return parent.getAsync('Kids');
  49673. }).then(function (kids) {
  49674. if (!kids) {
  49675. return null;
  49676. }
  49677. var kidPromises = [];
  49678. var found = false;
  49679. for (var i = 0; i < kids.length; i++) {
  49680. var kid = kids[i];
  49681. assert(isRef(kid), 'kid must be a Ref.');
  49682. if (kid.num === kidRef.num) {
  49683. found = true;
  49684. break;
  49685. }
  49686. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49687. if (kid.has('Count')) {
  49688. var count = kid.get('Count');
  49689. total += count;
  49690. } else {
  49691. total++;
  49692. }
  49693. }));
  49694. }
  49695. if (!found) {
  49696. error('kid ref not found in parents kids');
  49697. }
  49698. return Promise.all(kidPromises).then(function () {
  49699. return [
  49700. total,
  49701. parentRef
  49702. ];
  49703. });
  49704. });
  49705. }
  49706. var total = 0;
  49707. function next(ref) {
  49708. return pagesBeforeRef(ref).then(function (args) {
  49709. if (!args) {
  49710. return total;
  49711. }
  49712. var count = args[0];
  49713. var parentRef = args[1];
  49714. total += count;
  49715. return next(parentRef);
  49716. });
  49717. }
  49718. return next(pageRef);
  49719. }
  49720. };
  49721. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49722. function addDefaultProtocolToUrl(url) {
  49723. if (url.indexOf('www.') === 0) {
  49724. return 'http://' + url;
  49725. }
  49726. return url;
  49727. }
  49728. function tryConvertUrlEncoding(url) {
  49729. try {
  49730. return stringToUTF8String(url);
  49731. } catch (e) {
  49732. return url;
  49733. }
  49734. }
  49735. var destDict = params.destDict;
  49736. if (!isDict(destDict)) {
  49737. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49738. return;
  49739. }
  49740. var resultObj = params.resultObj;
  49741. if (typeof resultObj !== 'object') {
  49742. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49743. return;
  49744. }
  49745. var docBaseUrl = params.docBaseUrl || null;
  49746. var action = destDict.get('A'), url, dest;
  49747. if (isDict(action)) {
  49748. var linkType = action.get('S').name;
  49749. switch (linkType) {
  49750. case 'URI':
  49751. url = action.get('URI');
  49752. if (isName(url)) {
  49753. url = '/' + url.name;
  49754. } else if (isString(url)) {
  49755. url = addDefaultProtocolToUrl(url);
  49756. }
  49757. break;
  49758. case 'GoTo':
  49759. dest = action.get('D');
  49760. break;
  49761. case 'Launch':
  49762. case 'GoToR':
  49763. var urlDict = action.get('F');
  49764. if (isDict(urlDict)) {
  49765. url = urlDict.get('F') || null;
  49766. } else if (isString(urlDict)) {
  49767. url = urlDict;
  49768. }
  49769. var remoteDest = action.get('D');
  49770. if (remoteDest) {
  49771. if (isName(remoteDest)) {
  49772. remoteDest = remoteDest.name;
  49773. }
  49774. if (isString(url)) {
  49775. var baseUrl = url.split('#')[0];
  49776. if (isString(remoteDest)) {
  49777. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49778. } else if (isArray(remoteDest)) {
  49779. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49780. }
  49781. }
  49782. }
  49783. var newWindow = action.get('NewWindow');
  49784. if (isBool(newWindow)) {
  49785. resultObj.newWindow = newWindow;
  49786. }
  49787. break;
  49788. case 'Named':
  49789. var namedAction = action.get('N');
  49790. if (isName(namedAction)) {
  49791. resultObj.action = namedAction.name;
  49792. }
  49793. break;
  49794. case 'JavaScript':
  49795. var jsAction = action.get('JS'), js;
  49796. if (isStream(jsAction)) {
  49797. js = bytesToString(jsAction.getBytes());
  49798. } else if (isString(jsAction)) {
  49799. js = jsAction;
  49800. }
  49801. if (js) {
  49802. var URL_OPEN_METHODS = [
  49803. 'app.launchURL',
  49804. 'window.open'
  49805. ];
  49806. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49807. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49808. if (jsUrl && jsUrl[1]) {
  49809. url = jsUrl[1];
  49810. break;
  49811. }
  49812. }
  49813. default:
  49814. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49815. break;
  49816. }
  49817. } else if (destDict.has('Dest')) {
  49818. dest = destDict.get('Dest');
  49819. }
  49820. if (isString(url)) {
  49821. url = tryConvertUrlEncoding(url);
  49822. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49823. if (absoluteUrl) {
  49824. resultObj.url = absoluteUrl.href;
  49825. }
  49826. resultObj.unsafeUrl = url;
  49827. }
  49828. if (dest) {
  49829. if (isName(dest)) {
  49830. dest = dest.name;
  49831. }
  49832. if (isString(dest) || isArray(dest)) {
  49833. resultObj.dest = dest;
  49834. }
  49835. }
  49836. };
  49837. return Catalog;
  49838. }();
  49839. var XRef = function XRefClosure() {
  49840. function XRef(stream, password) {
  49841. this.stream = stream;
  49842. this.entries = [];
  49843. this.xrefstms = Object.create(null);
  49844. this.cache = [];
  49845. this.password = password;
  49846. this.stats = {
  49847. streamTypes: [],
  49848. fontTypes: []
  49849. };
  49850. }
  49851. XRef.prototype = {
  49852. setStartXRef: function XRef_setStartXRef(startXRef) {
  49853. this.startXRefQueue = [startXRef];
  49854. },
  49855. parse: function XRef_parse(recoveryMode) {
  49856. var trailerDict;
  49857. if (!recoveryMode) {
  49858. trailerDict = this.readXRef();
  49859. } else {
  49860. warn('Indexing all PDF objects');
  49861. trailerDict = this.indexObjects();
  49862. }
  49863. trailerDict.assignXref(this);
  49864. this.trailer = trailerDict;
  49865. var encrypt = trailerDict.get('Encrypt');
  49866. if (encrypt) {
  49867. var ids = trailerDict.get('ID');
  49868. var fileId = ids && ids.length ? ids[0] : '';
  49869. encrypt.suppressEncryption = true;
  49870. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  49871. }
  49872. if (!(this.root = trailerDict.get('Root'))) {
  49873. error('Invalid root reference');
  49874. }
  49875. },
  49876. processXRefTable: function XRef_processXRefTable(parser) {
  49877. if (!('tableState' in this)) {
  49878. this.tableState = {
  49879. entryNum: 0,
  49880. streamPos: parser.lexer.stream.pos,
  49881. parserBuf1: parser.buf1,
  49882. parserBuf2: parser.buf2
  49883. };
  49884. }
  49885. var obj = this.readXRefTable(parser);
  49886. if (!isCmd(obj, 'trailer')) {
  49887. error('Invalid XRef table: could not find trailer dictionary');
  49888. }
  49889. var dict = parser.getObj();
  49890. if (!isDict(dict) && dict.dict) {
  49891. dict = dict.dict;
  49892. }
  49893. if (!isDict(dict)) {
  49894. error('Invalid XRef table: could not parse trailer dictionary');
  49895. }
  49896. delete this.tableState;
  49897. return dict;
  49898. },
  49899. readXRefTable: function XRef_readXRefTable(parser) {
  49900. var stream = parser.lexer.stream;
  49901. var tableState = this.tableState;
  49902. stream.pos = tableState.streamPos;
  49903. parser.buf1 = tableState.parserBuf1;
  49904. parser.buf2 = tableState.parserBuf2;
  49905. var obj;
  49906. while (true) {
  49907. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  49908. if (isCmd(obj = parser.getObj(), 'trailer')) {
  49909. break;
  49910. }
  49911. tableState.firstEntryNum = obj;
  49912. tableState.entryCount = parser.getObj();
  49913. }
  49914. var first = tableState.firstEntryNum;
  49915. var count = tableState.entryCount;
  49916. if (!isInt(first) || !isInt(count)) {
  49917. error('Invalid XRef table: wrong types in subsection header');
  49918. }
  49919. for (var i = tableState.entryNum; i < count; i++) {
  49920. tableState.streamPos = stream.pos;
  49921. tableState.entryNum = i;
  49922. tableState.parserBuf1 = parser.buf1;
  49923. tableState.parserBuf2 = parser.buf2;
  49924. var entry = {};
  49925. entry.offset = parser.getObj();
  49926. entry.gen = parser.getObj();
  49927. var type = parser.getObj();
  49928. if (isCmd(type, 'f')) {
  49929. entry.free = true;
  49930. } else if (isCmd(type, 'n')) {
  49931. entry.uncompressed = true;
  49932. }
  49933. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  49934. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  49935. }
  49936. if (i === 0 && entry.free && first === 1) {
  49937. first = 0;
  49938. }
  49939. if (!this.entries[i + first]) {
  49940. this.entries[i + first] = entry;
  49941. }
  49942. }
  49943. tableState.entryNum = 0;
  49944. tableState.streamPos = stream.pos;
  49945. tableState.parserBuf1 = parser.buf1;
  49946. tableState.parserBuf2 = parser.buf2;
  49947. delete tableState.firstEntryNum;
  49948. delete tableState.entryCount;
  49949. }
  49950. if (this.entries[0] && !this.entries[0].free) {
  49951. error('Invalid XRef table: unexpected first object');
  49952. }
  49953. return obj;
  49954. },
  49955. processXRefStream: function XRef_processXRefStream(stream) {
  49956. if (!('streamState' in this)) {
  49957. var streamParameters = stream.dict;
  49958. var byteWidths = streamParameters.get('W');
  49959. var range = streamParameters.get('Index');
  49960. if (!range) {
  49961. range = [
  49962. 0,
  49963. streamParameters.get('Size')
  49964. ];
  49965. }
  49966. this.streamState = {
  49967. entryRanges: range,
  49968. byteWidths: byteWidths,
  49969. entryNum: 0,
  49970. streamPos: stream.pos
  49971. };
  49972. }
  49973. this.readXRefStream(stream);
  49974. delete this.streamState;
  49975. return stream.dict;
  49976. },
  49977. readXRefStream: function XRef_readXRefStream(stream) {
  49978. var i, j;
  49979. var streamState = this.streamState;
  49980. stream.pos = streamState.streamPos;
  49981. var byteWidths = streamState.byteWidths;
  49982. var typeFieldWidth = byteWidths[0];
  49983. var offsetFieldWidth = byteWidths[1];
  49984. var generationFieldWidth = byteWidths[2];
  49985. var entryRanges = streamState.entryRanges;
  49986. while (entryRanges.length > 0) {
  49987. var first = entryRanges[0];
  49988. var n = entryRanges[1];
  49989. if (!isInt(first) || !isInt(n)) {
  49990. error('Invalid XRef range fields: ' + first + ', ' + n);
  49991. }
  49992. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  49993. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  49994. }
  49995. for (i = streamState.entryNum; i < n; ++i) {
  49996. streamState.entryNum = i;
  49997. streamState.streamPos = stream.pos;
  49998. var type = 0, offset = 0, generation = 0;
  49999. for (j = 0; j < typeFieldWidth; ++j) {
  50000. type = type << 8 | stream.getByte();
  50001. }
  50002. if (typeFieldWidth === 0) {
  50003. type = 1;
  50004. }
  50005. for (j = 0; j < offsetFieldWidth; ++j) {
  50006. offset = offset << 8 | stream.getByte();
  50007. }
  50008. for (j = 0; j < generationFieldWidth; ++j) {
  50009. generation = generation << 8 | stream.getByte();
  50010. }
  50011. var entry = {};
  50012. entry.offset = offset;
  50013. entry.gen = generation;
  50014. switch (type) {
  50015. case 0:
  50016. entry.free = true;
  50017. break;
  50018. case 1:
  50019. entry.uncompressed = true;
  50020. break;
  50021. case 2:
  50022. break;
  50023. default:
  50024. error('Invalid XRef entry type: ' + type);
  50025. }
  50026. if (!this.entries[first + i]) {
  50027. this.entries[first + i] = entry;
  50028. }
  50029. }
  50030. streamState.entryNum = 0;
  50031. streamState.streamPos = stream.pos;
  50032. entryRanges.splice(0, 2);
  50033. }
  50034. },
  50035. indexObjects: function XRef_indexObjects() {
  50036. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50037. var PERCENT = 0x25, LT = 0x3C;
  50038. function readToken(data, offset) {
  50039. var token = '', ch = data[offset];
  50040. while (ch !== LF && ch !== CR && ch !== LT) {
  50041. if (++offset >= data.length) {
  50042. break;
  50043. }
  50044. token += String.fromCharCode(ch);
  50045. ch = data[offset];
  50046. }
  50047. return token;
  50048. }
  50049. function skipUntil(data, offset, what) {
  50050. var length = what.length, dataLength = data.length;
  50051. var skipped = 0;
  50052. while (offset < dataLength) {
  50053. var i = 0;
  50054. while (i < length && data[offset + i] === what[i]) {
  50055. ++i;
  50056. }
  50057. if (i >= length) {
  50058. break;
  50059. }
  50060. offset++;
  50061. skipped++;
  50062. }
  50063. return skipped;
  50064. }
  50065. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50066. var trailerBytes = new Uint8Array([
  50067. 116,
  50068. 114,
  50069. 97,
  50070. 105,
  50071. 108,
  50072. 101,
  50073. 114
  50074. ]);
  50075. var startxrefBytes = new Uint8Array([
  50076. 115,
  50077. 116,
  50078. 97,
  50079. 114,
  50080. 116,
  50081. 120,
  50082. 114,
  50083. 101,
  50084. 102
  50085. ]);
  50086. var endobjBytes = new Uint8Array([
  50087. 101,
  50088. 110,
  50089. 100,
  50090. 111,
  50091. 98,
  50092. 106
  50093. ]);
  50094. var xrefBytes = new Uint8Array([
  50095. 47,
  50096. 88,
  50097. 82,
  50098. 101,
  50099. 102
  50100. ]);
  50101. this.entries.length = 0;
  50102. var stream = this.stream;
  50103. stream.pos = 0;
  50104. var buffer = stream.getBytes();
  50105. var position = stream.start, length = buffer.length;
  50106. var trailers = [], xrefStms = [];
  50107. while (position < length) {
  50108. var ch = buffer[position];
  50109. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50110. ++position;
  50111. continue;
  50112. }
  50113. if (ch === PERCENT) {
  50114. do {
  50115. ++position;
  50116. if (position >= length) {
  50117. break;
  50118. }
  50119. ch = buffer[position];
  50120. } while (ch !== LF && ch !== CR);
  50121. continue;
  50122. }
  50123. var token = readToken(buffer, position);
  50124. var m;
  50125. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50126. position += skipUntil(buffer, position, trailerBytes);
  50127. trailers.push(position);
  50128. position += skipUntil(buffer, position, startxrefBytes);
  50129. } else if (m = objRegExp.exec(token)) {
  50130. if (typeof this.entries[m[1]] === 'undefined') {
  50131. this.entries[m[1]] = {
  50132. offset: position - stream.start,
  50133. gen: m[2] | 0,
  50134. uncompressed: true
  50135. };
  50136. }
  50137. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50138. var content = buffer.subarray(position, position + contentLength);
  50139. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50140. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50141. xrefStms.push(position - stream.start);
  50142. this.xrefstms[position - stream.start] = 1;
  50143. }
  50144. position += contentLength;
  50145. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50146. trailers.push(position);
  50147. position += skipUntil(buffer, position, startxrefBytes);
  50148. } else {
  50149. position += token.length + 1;
  50150. }
  50151. }
  50152. var i, ii;
  50153. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50154. this.startXRefQueue.push(xrefStms[i]);
  50155. this.readXRef(true);
  50156. }
  50157. var dict;
  50158. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50159. stream.pos = trailers[i];
  50160. var parser = new Parser(new Lexer(stream), true, this, true);
  50161. var obj = parser.getObj();
  50162. if (!isCmd(obj, 'trailer')) {
  50163. continue;
  50164. }
  50165. dict = parser.getObj();
  50166. if (!isDict(dict)) {
  50167. continue;
  50168. }
  50169. if (dict.has('ID')) {
  50170. return dict;
  50171. }
  50172. }
  50173. if (dict) {
  50174. return dict;
  50175. }
  50176. throw new InvalidPDFException('Invalid PDF structure');
  50177. },
  50178. readXRef: function XRef_readXRef(recoveryMode) {
  50179. var stream = this.stream;
  50180. try {
  50181. while (this.startXRefQueue.length) {
  50182. var startXRef = this.startXRefQueue[0];
  50183. stream.pos = startXRef + stream.start;
  50184. var parser = new Parser(new Lexer(stream), true, this);
  50185. var obj = parser.getObj();
  50186. var dict;
  50187. if (isCmd(obj, 'xref')) {
  50188. dict = this.processXRefTable(parser);
  50189. if (!this.topDict) {
  50190. this.topDict = dict;
  50191. }
  50192. obj = dict.get('XRefStm');
  50193. if (isInt(obj)) {
  50194. var pos = obj;
  50195. if (!(pos in this.xrefstms)) {
  50196. this.xrefstms[pos] = 1;
  50197. this.startXRefQueue.push(pos);
  50198. }
  50199. }
  50200. } else if (isInt(obj)) {
  50201. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50202. error('Invalid XRef stream');
  50203. }
  50204. dict = this.processXRefStream(obj);
  50205. if (!this.topDict) {
  50206. this.topDict = dict;
  50207. }
  50208. if (!dict) {
  50209. error('Failed to read XRef stream');
  50210. }
  50211. } else {
  50212. error('Invalid XRef stream header');
  50213. }
  50214. obj = dict.get('Prev');
  50215. if (isInt(obj)) {
  50216. this.startXRefQueue.push(obj);
  50217. } else if (isRef(obj)) {
  50218. this.startXRefQueue.push(obj.num);
  50219. }
  50220. this.startXRefQueue.shift();
  50221. }
  50222. return this.topDict;
  50223. } catch (e) {
  50224. if (e instanceof MissingDataException) {
  50225. throw e;
  50226. }
  50227. info('(while reading XRef): ' + e);
  50228. }
  50229. if (recoveryMode) {
  50230. return;
  50231. }
  50232. throw new XRefParseException();
  50233. },
  50234. getEntry: function XRef_getEntry(i) {
  50235. var xrefEntry = this.entries[i];
  50236. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50237. return xrefEntry;
  50238. }
  50239. return null;
  50240. },
  50241. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50242. if (!isRef(obj)) {
  50243. return obj;
  50244. }
  50245. return this.fetch(obj, suppressEncryption);
  50246. },
  50247. fetch: function XRef_fetch(ref, suppressEncryption) {
  50248. assert(isRef(ref), 'ref object is not a reference');
  50249. var num = ref.num;
  50250. if (num in this.cache) {
  50251. var cacheEntry = this.cache[num];
  50252. return cacheEntry;
  50253. }
  50254. var xrefEntry = this.getEntry(num);
  50255. if (xrefEntry === null) {
  50256. return this.cache[num] = null;
  50257. }
  50258. if (xrefEntry.uncompressed) {
  50259. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50260. } else {
  50261. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50262. }
  50263. if (isDict(xrefEntry)) {
  50264. xrefEntry.objId = ref.toString();
  50265. } else if (isStream(xrefEntry)) {
  50266. xrefEntry.dict.objId = ref.toString();
  50267. }
  50268. return xrefEntry;
  50269. },
  50270. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50271. var gen = ref.gen;
  50272. var num = ref.num;
  50273. if (xrefEntry.gen !== gen) {
  50274. error('inconsistent generation in XRef');
  50275. }
  50276. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50277. var parser = new Parser(new Lexer(stream), true, this);
  50278. var obj1 = parser.getObj();
  50279. var obj2 = parser.getObj();
  50280. var obj3 = parser.getObj();
  50281. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50282. error('bad XRef entry');
  50283. }
  50284. if (!isCmd(obj3, 'obj')) {
  50285. if (obj3.cmd.indexOf('obj') === 0) {
  50286. num = parseInt(obj3.cmd.substring(3), 10);
  50287. if (!isNaN(num)) {
  50288. return num;
  50289. }
  50290. }
  50291. error('bad XRef entry');
  50292. }
  50293. if (this.encrypt && !suppressEncryption) {
  50294. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50295. } else {
  50296. xrefEntry = parser.getObj();
  50297. }
  50298. if (!isStream(xrefEntry)) {
  50299. this.cache[num] = xrefEntry;
  50300. }
  50301. return xrefEntry;
  50302. },
  50303. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50304. var tableOffset = xrefEntry.offset;
  50305. var stream = this.fetch(new Ref(tableOffset, 0));
  50306. if (!isStream(stream)) {
  50307. error('bad ObjStm stream');
  50308. }
  50309. var first = stream.dict.get('First');
  50310. var n = stream.dict.get('N');
  50311. if (!isInt(first) || !isInt(n)) {
  50312. error('invalid first and n parameters for ObjStm stream');
  50313. }
  50314. var parser = new Parser(new Lexer(stream), false, this);
  50315. parser.allowStreams = true;
  50316. var i, entries = [], num, nums = [];
  50317. for (i = 0; i < n; ++i) {
  50318. num = parser.getObj();
  50319. if (!isInt(num)) {
  50320. error('invalid object number in the ObjStm stream: ' + num);
  50321. }
  50322. nums.push(num);
  50323. var offset = parser.getObj();
  50324. if (!isInt(offset)) {
  50325. error('invalid object offset in the ObjStm stream: ' + offset);
  50326. }
  50327. }
  50328. for (i = 0; i < n; ++i) {
  50329. entries.push(parser.getObj());
  50330. if (isCmd(parser.buf1, 'endobj')) {
  50331. parser.shift();
  50332. }
  50333. num = nums[i];
  50334. var entry = this.entries[num];
  50335. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50336. this.cache[num] = entries[i];
  50337. }
  50338. }
  50339. xrefEntry = entries[xrefEntry.gen];
  50340. if (xrefEntry === undefined) {
  50341. error('bad XRef entry for compressed object');
  50342. }
  50343. return xrefEntry;
  50344. },
  50345. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50346. if (!isRef(obj)) {
  50347. return Promise.resolve(obj);
  50348. }
  50349. return this.fetchAsync(obj, suppressEncryption);
  50350. },
  50351. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50352. var streamManager = this.stream.manager;
  50353. var xref = this;
  50354. return new Promise(function tryFetch(resolve, reject) {
  50355. try {
  50356. resolve(xref.fetch(ref, suppressEncryption));
  50357. } catch (e) {
  50358. if (e instanceof MissingDataException) {
  50359. streamManager.requestRange(e.begin, e.end).then(function () {
  50360. tryFetch(resolve, reject);
  50361. }, reject);
  50362. return;
  50363. }
  50364. reject(e);
  50365. }
  50366. });
  50367. },
  50368. getCatalogObj: function XRef_getCatalogObj() {
  50369. return this.root;
  50370. }
  50371. };
  50372. return XRef;
  50373. }();
  50374. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50375. function NameOrNumberTree(root, xref) {
  50376. throw new Error('Cannot initialize NameOrNumberTree.');
  50377. }
  50378. NameOrNumberTree.prototype = {
  50379. getAll: function NameOrNumberTree_getAll() {
  50380. var dict = Object.create(null);
  50381. if (!this.root) {
  50382. return dict;
  50383. }
  50384. var xref = this.xref;
  50385. var processed = new RefSet();
  50386. processed.put(this.root);
  50387. var queue = [this.root];
  50388. while (queue.length > 0) {
  50389. var i, n;
  50390. var obj = xref.fetchIfRef(queue.shift());
  50391. if (!isDict(obj)) {
  50392. continue;
  50393. }
  50394. if (obj.has('Kids')) {
  50395. var kids = obj.get('Kids');
  50396. for (i = 0, n = kids.length; i < n; i++) {
  50397. var kid = kids[i];
  50398. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50399. queue.push(kid);
  50400. processed.put(kid);
  50401. }
  50402. continue;
  50403. }
  50404. var entries = obj.get(this._type);
  50405. if (isArray(entries)) {
  50406. for (i = 0, n = entries.length; i < n; i += 2) {
  50407. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50408. }
  50409. }
  50410. }
  50411. return dict;
  50412. },
  50413. get: function NameOrNumberTree_get(key) {
  50414. if (!this.root) {
  50415. return null;
  50416. }
  50417. var xref = this.xref;
  50418. var kidsOrEntries = xref.fetchIfRef(this.root);
  50419. var loopCount = 0;
  50420. var MAX_LEVELS = 10;
  50421. var l, r, m;
  50422. while (kidsOrEntries.has('Kids')) {
  50423. if (++loopCount > MAX_LEVELS) {
  50424. warn('Search depth limit reached for "' + this._type + '" tree.');
  50425. return null;
  50426. }
  50427. var kids = kidsOrEntries.get('Kids');
  50428. if (!isArray(kids)) {
  50429. return null;
  50430. }
  50431. l = 0;
  50432. r = kids.length - 1;
  50433. while (l <= r) {
  50434. m = l + r >> 1;
  50435. var kid = xref.fetchIfRef(kids[m]);
  50436. var limits = kid.get('Limits');
  50437. if (key < xref.fetchIfRef(limits[0])) {
  50438. r = m - 1;
  50439. } else if (key > xref.fetchIfRef(limits[1])) {
  50440. l = m + 1;
  50441. } else {
  50442. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50443. break;
  50444. }
  50445. }
  50446. if (l > r) {
  50447. return null;
  50448. }
  50449. }
  50450. var entries = kidsOrEntries.get(this._type);
  50451. if (isArray(entries)) {
  50452. l = 0;
  50453. r = entries.length - 2;
  50454. while (l <= r) {
  50455. m = l + r & ~1;
  50456. var currentKey = xref.fetchIfRef(entries[m]);
  50457. if (key < currentKey) {
  50458. r = m - 2;
  50459. } else if (key > currentKey) {
  50460. l = m + 2;
  50461. } else {
  50462. return xref.fetchIfRef(entries[m + 1]);
  50463. }
  50464. }
  50465. }
  50466. return null;
  50467. }
  50468. };
  50469. return NameOrNumberTree;
  50470. }();
  50471. var NameTree = function NameTreeClosure() {
  50472. function NameTree(root, xref) {
  50473. this.root = root;
  50474. this.xref = xref;
  50475. this._type = 'Names';
  50476. }
  50477. Util.inherit(NameTree, NameOrNumberTree, {});
  50478. return NameTree;
  50479. }();
  50480. var NumberTree = function NumberTreeClosure() {
  50481. function NumberTree(root, xref) {
  50482. this.root = root;
  50483. this.xref = xref;
  50484. this._type = 'Nums';
  50485. }
  50486. Util.inherit(NumberTree, NameOrNumberTree, {});
  50487. return NumberTree;
  50488. }();
  50489. var FileSpec = function FileSpecClosure() {
  50490. function FileSpec(root, xref) {
  50491. if (!root || !isDict(root)) {
  50492. return;
  50493. }
  50494. this.xref = xref;
  50495. this.root = root;
  50496. if (root.has('FS')) {
  50497. this.fs = root.get('FS');
  50498. }
  50499. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50500. if (root.has('RF')) {
  50501. warn('Related file specifications are not supported');
  50502. }
  50503. this.contentAvailable = true;
  50504. if (!root.has('EF')) {
  50505. this.contentAvailable = false;
  50506. warn('Non-embedded file specifications are not supported');
  50507. }
  50508. }
  50509. function pickPlatformItem(dict) {
  50510. if (dict.has('UF')) {
  50511. return dict.get('UF');
  50512. } else if (dict.has('F')) {
  50513. return dict.get('F');
  50514. } else if (dict.has('Unix')) {
  50515. return dict.get('Unix');
  50516. } else if (dict.has('Mac')) {
  50517. return dict.get('Mac');
  50518. } else if (dict.has('DOS')) {
  50519. return dict.get('DOS');
  50520. } else {
  50521. return null;
  50522. }
  50523. }
  50524. FileSpec.prototype = {
  50525. get filename() {
  50526. if (!this._filename && this.root) {
  50527. var filename = pickPlatformItem(this.root) || 'unnamed';
  50528. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50529. }
  50530. return this._filename;
  50531. },
  50532. get content() {
  50533. if (!this.contentAvailable) {
  50534. return null;
  50535. }
  50536. if (!this.contentRef && this.root) {
  50537. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50538. }
  50539. var content = null;
  50540. if (this.contentRef) {
  50541. var xref = this.xref;
  50542. var fileObj = xref.fetchIfRef(this.contentRef);
  50543. if (fileObj && isStream(fileObj)) {
  50544. content = fileObj.getBytes();
  50545. } else {
  50546. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50547. }
  50548. } else {
  50549. warn('Embedded file specification does not have a content');
  50550. }
  50551. return content;
  50552. },
  50553. get serializable() {
  50554. return {
  50555. filename: this.filename,
  50556. content: this.content
  50557. };
  50558. }
  50559. };
  50560. return FileSpec;
  50561. }();
  50562. var ObjectLoader = function () {
  50563. function mayHaveChildren(value) {
  50564. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50565. }
  50566. function addChildren(node, nodesToVisit) {
  50567. var value;
  50568. if (isDict(node) || isStream(node)) {
  50569. var map;
  50570. if (isDict(node)) {
  50571. map = node.map;
  50572. } else {
  50573. map = node.dict.map;
  50574. }
  50575. for (var key in map) {
  50576. value = map[key];
  50577. if (mayHaveChildren(value)) {
  50578. nodesToVisit.push(value);
  50579. }
  50580. }
  50581. } else if (isArray(node)) {
  50582. for (var i = 0, ii = node.length; i < ii; i++) {
  50583. value = node[i];
  50584. if (mayHaveChildren(value)) {
  50585. nodesToVisit.push(value);
  50586. }
  50587. }
  50588. }
  50589. }
  50590. function ObjectLoader(obj, keys, xref) {
  50591. this.obj = obj;
  50592. this.keys = keys;
  50593. this.xref = xref;
  50594. this.refSet = null;
  50595. this.capability = null;
  50596. }
  50597. ObjectLoader.prototype = {
  50598. load: function ObjectLoader_load() {
  50599. var keys = this.keys;
  50600. this.capability = createPromiseCapability();
  50601. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50602. this.capability.resolve();
  50603. return this.capability.promise;
  50604. }
  50605. this.refSet = new RefSet();
  50606. var nodesToVisit = [];
  50607. for (var i = 0; i < keys.length; i++) {
  50608. nodesToVisit.push(this.obj[keys[i]]);
  50609. }
  50610. this._walk(nodesToVisit);
  50611. return this.capability.promise;
  50612. },
  50613. _walk: function ObjectLoader_walk(nodesToVisit) {
  50614. var nodesToRevisit = [];
  50615. var pendingRequests = [];
  50616. while (nodesToVisit.length) {
  50617. var currentNode = nodesToVisit.pop();
  50618. if (isRef(currentNode)) {
  50619. if (this.refSet.has(currentNode)) {
  50620. continue;
  50621. }
  50622. try {
  50623. var ref = currentNode;
  50624. this.refSet.put(ref);
  50625. currentNode = this.xref.fetch(currentNode);
  50626. } catch (e) {
  50627. if (!(e instanceof MissingDataException)) {
  50628. throw e;
  50629. }
  50630. nodesToRevisit.push(currentNode);
  50631. pendingRequests.push({
  50632. begin: e.begin,
  50633. end: e.end
  50634. });
  50635. }
  50636. }
  50637. if (currentNode && currentNode.getBaseStreams) {
  50638. var baseStreams = currentNode.getBaseStreams();
  50639. var foundMissingData = false;
  50640. for (var i = 0; i < baseStreams.length; i++) {
  50641. var stream = baseStreams[i];
  50642. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50643. foundMissingData = true;
  50644. pendingRequests.push({
  50645. begin: stream.start,
  50646. end: stream.end
  50647. });
  50648. }
  50649. }
  50650. if (foundMissingData) {
  50651. nodesToRevisit.push(currentNode);
  50652. }
  50653. }
  50654. addChildren(currentNode, nodesToVisit);
  50655. }
  50656. if (pendingRequests.length) {
  50657. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50658. nodesToVisit = nodesToRevisit;
  50659. for (var i = 0; i < nodesToRevisit.length; i++) {
  50660. var node = nodesToRevisit[i];
  50661. if (isRef(node)) {
  50662. this.refSet.remove(node);
  50663. }
  50664. }
  50665. this._walk(nodesToVisit);
  50666. }.bind(this), this.capability.reject);
  50667. return;
  50668. }
  50669. this.refSet = null;
  50670. this.capability.resolve();
  50671. }
  50672. };
  50673. return ObjectLoader;
  50674. }();
  50675. exports.Catalog = Catalog;
  50676. exports.ObjectLoader = ObjectLoader;
  50677. exports.XRef = XRef;
  50678. exports.FileSpec = FileSpec;
  50679. }));
  50680. (function (root, factory) {
  50681. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50682. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50683. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50684. var MissingDataException = sharedUtil.MissingDataException;
  50685. var Util = sharedUtil.Util;
  50686. var assert = sharedUtil.assert;
  50687. var error = sharedUtil.error;
  50688. var info = sharedUtil.info;
  50689. var warn = sharedUtil.warn;
  50690. var isStream = corePrimitives.isStream;
  50691. var PDFFunction = coreFunction.PDFFunction;
  50692. var ColorSpace = coreColorSpace.ColorSpace;
  50693. var ShadingType = {
  50694. FUNCTION_BASED: 1,
  50695. AXIAL: 2,
  50696. RADIAL: 3,
  50697. FREE_FORM_MESH: 4,
  50698. LATTICE_FORM_MESH: 5,
  50699. COONS_PATCH_MESH: 6,
  50700. TENSOR_PATCH_MESH: 7
  50701. };
  50702. var Pattern = function PatternClosure() {
  50703. function Pattern() {
  50704. error('should not call Pattern constructor');
  50705. }
  50706. Pattern.prototype = {
  50707. getPattern: function Pattern_getPattern(ctx) {
  50708. error('Should not call Pattern.getStyle: ' + ctx);
  50709. }
  50710. };
  50711. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50712. var dict = isStream(shading) ? shading.dict : shading;
  50713. var type = dict.get('ShadingType');
  50714. try {
  50715. switch (type) {
  50716. case ShadingType.AXIAL:
  50717. case ShadingType.RADIAL:
  50718. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50719. case ShadingType.FREE_FORM_MESH:
  50720. case ShadingType.LATTICE_FORM_MESH:
  50721. case ShadingType.COONS_PATCH_MESH:
  50722. case ShadingType.TENSOR_PATCH_MESH:
  50723. return new Shadings.Mesh(shading, matrix, xref, res);
  50724. default:
  50725. throw new Error('Unsupported ShadingType: ' + type);
  50726. }
  50727. } catch (ex) {
  50728. if (ex instanceof MissingDataException) {
  50729. throw ex;
  50730. }
  50731. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50732. warn(ex);
  50733. return new Shadings.Dummy();
  50734. }
  50735. };
  50736. return Pattern;
  50737. }();
  50738. var Shadings = {};
  50739. Shadings.SMALL_NUMBER = 1e-6;
  50740. Shadings.RadialAxial = function RadialAxialClosure() {
  50741. function RadialAxial(dict, matrix, xref, res) {
  50742. this.matrix = matrix;
  50743. this.coordsArr = dict.getArray('Coords');
  50744. this.shadingType = dict.get('ShadingType');
  50745. this.type = 'Pattern';
  50746. var cs = dict.get('ColorSpace', 'CS');
  50747. cs = ColorSpace.parse(cs, xref, res);
  50748. this.cs = cs;
  50749. var t0 = 0.0, t1 = 1.0;
  50750. if (dict.has('Domain')) {
  50751. var domainArr = dict.getArray('Domain');
  50752. t0 = domainArr[0];
  50753. t1 = domainArr[1];
  50754. }
  50755. var extendStart = false, extendEnd = false;
  50756. if (dict.has('Extend')) {
  50757. var extendArr = dict.getArray('Extend');
  50758. extendStart = extendArr[0];
  50759. extendEnd = extendArr[1];
  50760. }
  50761. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50762. var x1 = this.coordsArr[0];
  50763. var y1 = this.coordsArr[1];
  50764. var r1 = this.coordsArr[2];
  50765. var x2 = this.coordsArr[3];
  50766. var y2 = this.coordsArr[4];
  50767. var r2 = this.coordsArr[5];
  50768. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50769. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50770. warn('Unsupported radial gradient.');
  50771. }
  50772. }
  50773. this.extendStart = extendStart;
  50774. this.extendEnd = extendEnd;
  50775. var fnObj = dict.get('Function');
  50776. var fn = PDFFunction.parseArray(xref, fnObj);
  50777. var diff = t1 - t0;
  50778. var step = diff / 10;
  50779. var colorStops = this.colorStops = [];
  50780. if (t0 >= t1 || step <= 0) {
  50781. info('Bad shading domain.');
  50782. return;
  50783. }
  50784. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50785. var rgbColor;
  50786. for (var i = t0; i <= t1; i += step) {
  50787. ratio[0] = i;
  50788. fn(ratio, 0, color, 0);
  50789. rgbColor = cs.getRgb(color, 0);
  50790. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50791. colorStops.push([
  50792. (i - t0) / diff,
  50793. cssColor
  50794. ]);
  50795. }
  50796. var background = 'transparent';
  50797. if (dict.has('Background')) {
  50798. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50799. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50800. }
  50801. if (!extendStart) {
  50802. colorStops.unshift([
  50803. 0,
  50804. background
  50805. ]);
  50806. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50807. }
  50808. if (!extendEnd) {
  50809. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50810. colorStops.push([
  50811. 1,
  50812. background
  50813. ]);
  50814. }
  50815. this.colorStops = colorStops;
  50816. }
  50817. RadialAxial.prototype = {
  50818. getIR: function RadialAxial_getIR() {
  50819. var coordsArr = this.coordsArr;
  50820. var shadingType = this.shadingType;
  50821. var type, p0, p1, r0, r1;
  50822. if (shadingType === ShadingType.AXIAL) {
  50823. p0 = [
  50824. coordsArr[0],
  50825. coordsArr[1]
  50826. ];
  50827. p1 = [
  50828. coordsArr[2],
  50829. coordsArr[3]
  50830. ];
  50831. r0 = null;
  50832. r1 = null;
  50833. type = 'axial';
  50834. } else if (shadingType === ShadingType.RADIAL) {
  50835. p0 = [
  50836. coordsArr[0],
  50837. coordsArr[1]
  50838. ];
  50839. p1 = [
  50840. coordsArr[3],
  50841. coordsArr[4]
  50842. ];
  50843. r0 = coordsArr[2];
  50844. r1 = coordsArr[5];
  50845. type = 'radial';
  50846. } else {
  50847. error('getPattern type unknown: ' + shadingType);
  50848. }
  50849. var matrix = this.matrix;
  50850. if (matrix) {
  50851. p0 = Util.applyTransform(p0, matrix);
  50852. p1 = Util.applyTransform(p1, matrix);
  50853. if (shadingType === ShadingType.RADIAL) {
  50854. var scale = Util.singularValueDecompose2dScale(matrix);
  50855. r0 *= scale[0];
  50856. r1 *= scale[1];
  50857. }
  50858. }
  50859. return [
  50860. 'RadialAxial',
  50861. type,
  50862. this.colorStops,
  50863. p0,
  50864. p1,
  50865. r0,
  50866. r1
  50867. ];
  50868. }
  50869. };
  50870. return RadialAxial;
  50871. }();
  50872. Shadings.Mesh = function MeshClosure() {
  50873. function MeshStreamReader(stream, context) {
  50874. this.stream = stream;
  50875. this.context = context;
  50876. this.buffer = 0;
  50877. this.bufferLength = 0;
  50878. var numComps = context.numComps;
  50879. this.tmpCompsBuf = new Float32Array(numComps);
  50880. var csNumComps = context.colorSpace.numComps;
  50881. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  50882. }
  50883. MeshStreamReader.prototype = {
  50884. get hasData() {
  50885. if (this.stream.end) {
  50886. return this.stream.pos < this.stream.end;
  50887. }
  50888. if (this.bufferLength > 0) {
  50889. return true;
  50890. }
  50891. var nextByte = this.stream.getByte();
  50892. if (nextByte < 0) {
  50893. return false;
  50894. }
  50895. this.buffer = nextByte;
  50896. this.bufferLength = 8;
  50897. return true;
  50898. },
  50899. readBits: function MeshStreamReader_readBits(n) {
  50900. var buffer = this.buffer;
  50901. var bufferLength = this.bufferLength;
  50902. if (n === 32) {
  50903. if (bufferLength === 0) {
  50904. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  50905. }
  50906. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  50907. var nextByte = this.stream.getByte();
  50908. this.buffer = nextByte & (1 << bufferLength) - 1;
  50909. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  50910. }
  50911. if (n === 8 && bufferLength === 0) {
  50912. return this.stream.getByte();
  50913. }
  50914. while (bufferLength < n) {
  50915. buffer = buffer << 8 | this.stream.getByte();
  50916. bufferLength += 8;
  50917. }
  50918. bufferLength -= n;
  50919. this.bufferLength = bufferLength;
  50920. this.buffer = buffer & (1 << bufferLength) - 1;
  50921. return buffer >> bufferLength;
  50922. },
  50923. align: function MeshStreamReader_align() {
  50924. this.buffer = 0;
  50925. this.bufferLength = 0;
  50926. },
  50927. readFlag: function MeshStreamReader_readFlag() {
  50928. return this.readBits(this.context.bitsPerFlag);
  50929. },
  50930. readCoordinate: function MeshStreamReader_readCoordinate() {
  50931. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  50932. var xi = this.readBits(bitsPerCoordinate);
  50933. var yi = this.readBits(bitsPerCoordinate);
  50934. var decode = this.context.decode;
  50935. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  50936. return [
  50937. xi * scale * (decode[1] - decode[0]) + decode[0],
  50938. yi * scale * (decode[3] - decode[2]) + decode[2]
  50939. ];
  50940. },
  50941. readComponents: function MeshStreamReader_readComponents() {
  50942. var numComps = this.context.numComps;
  50943. var bitsPerComponent = this.context.bitsPerComponent;
  50944. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  50945. var decode = this.context.decode;
  50946. var components = this.tmpCompsBuf;
  50947. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  50948. var ci = this.readBits(bitsPerComponent);
  50949. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  50950. }
  50951. var color = this.tmpCsCompsBuf;
  50952. if (this.context.colorFn) {
  50953. this.context.colorFn(components, 0, color, 0);
  50954. }
  50955. return this.context.colorSpace.getRgb(color, 0);
  50956. }
  50957. };
  50958. function decodeType4Shading(mesh, reader) {
  50959. var coords = mesh.coords;
  50960. var colors = mesh.colors;
  50961. var operators = [];
  50962. var ps = [];
  50963. var verticesLeft = 0;
  50964. while (reader.hasData) {
  50965. var f = reader.readFlag();
  50966. var coord = reader.readCoordinate();
  50967. var color = reader.readComponents();
  50968. if (verticesLeft === 0) {
  50969. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  50970. switch (f) {
  50971. case 0:
  50972. verticesLeft = 3;
  50973. break;
  50974. case 1:
  50975. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  50976. verticesLeft = 1;
  50977. break;
  50978. case 2:
  50979. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  50980. verticesLeft = 1;
  50981. break;
  50982. }
  50983. operators.push(f);
  50984. }
  50985. ps.push(coords.length);
  50986. coords.push(coord);
  50987. colors.push(color);
  50988. verticesLeft--;
  50989. reader.align();
  50990. }
  50991. mesh.figures.push({
  50992. type: 'triangles',
  50993. coords: new Int32Array(ps),
  50994. colors: new Int32Array(ps)
  50995. });
  50996. }
  50997. function decodeType5Shading(mesh, reader, verticesPerRow) {
  50998. var coords = mesh.coords;
  50999. var colors = mesh.colors;
  51000. var ps = [];
  51001. while (reader.hasData) {
  51002. var coord = reader.readCoordinate();
  51003. var color = reader.readComponents();
  51004. ps.push(coords.length);
  51005. coords.push(coord);
  51006. colors.push(color);
  51007. }
  51008. mesh.figures.push({
  51009. type: 'lattice',
  51010. coords: new Int32Array(ps),
  51011. colors: new Int32Array(ps),
  51012. verticesPerRow: verticesPerRow
  51013. });
  51014. }
  51015. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51016. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51017. var TRIANGLE_DENSITY = 20;
  51018. var getB = function getBClosure() {
  51019. function buildB(count) {
  51020. var lut = [];
  51021. for (var i = 0; i <= count; i++) {
  51022. var t = i / count, t_ = 1 - t;
  51023. lut.push(new Float32Array([
  51024. t_ * t_ * t_,
  51025. 3 * t * t_ * t_,
  51026. 3 * t * t * t_,
  51027. t * t * t
  51028. ]));
  51029. }
  51030. return lut;
  51031. }
  51032. var cache = [];
  51033. return function getB(count) {
  51034. if (!cache[count]) {
  51035. cache[count] = buildB(count);
  51036. }
  51037. return cache[count];
  51038. };
  51039. }();
  51040. function buildFigureFromPatch(mesh, index) {
  51041. var figure = mesh.figures[index];
  51042. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51043. var coords = mesh.coords, colors = mesh.colors;
  51044. var pi = figure.coords;
  51045. var ci = figure.colors;
  51046. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51047. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51048. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51049. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51050. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51051. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51052. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51053. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51054. var verticesPerRow = splitXBy + 1;
  51055. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51056. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51057. var k = 0;
  51058. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51059. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51060. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51061. for (var row = 0; row <= splitYBy; row++) {
  51062. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51063. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51064. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51065. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51066. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51067. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51068. for (var col = 0; col <= splitXBy; col++, k++) {
  51069. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51070. continue;
  51071. }
  51072. var x = 0, y = 0;
  51073. var q = 0;
  51074. for (var i = 0; i <= 3; i++) {
  51075. for (var j = 0; j <= 3; j++, q++) {
  51076. var m = bRow[row][i] * bCol[col][j];
  51077. x += coords[pi[q]][0] * m;
  51078. y += coords[pi[q]][1] * m;
  51079. }
  51080. }
  51081. figureCoords[k] = coords.length;
  51082. coords.push([
  51083. x,
  51084. y
  51085. ]);
  51086. figureColors[k] = colors.length;
  51087. var newColor = new Uint8Array(3);
  51088. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51089. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51090. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51091. colors.push(newColor);
  51092. }
  51093. }
  51094. figureCoords[0] = pi[0];
  51095. figureColors[0] = ci[0];
  51096. figureCoords[splitXBy] = pi[3];
  51097. figureColors[splitXBy] = ci[1];
  51098. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51099. figureColors[verticesPerRow * splitYBy] = ci[2];
  51100. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51101. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51102. mesh.figures[index] = {
  51103. type: 'lattice',
  51104. coords: figureCoords,
  51105. colors: figureColors,
  51106. verticesPerRow: verticesPerRow
  51107. };
  51108. }
  51109. function decodeType6Shading(mesh, reader) {
  51110. var coords = mesh.coords;
  51111. var colors = mesh.colors;
  51112. var ps = new Int32Array(16);
  51113. var cs = new Int32Array(4);
  51114. while (reader.hasData) {
  51115. var f = reader.readFlag();
  51116. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51117. var i, ii;
  51118. var pi = coords.length;
  51119. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51120. coords.push(reader.readCoordinate());
  51121. }
  51122. var ci = colors.length;
  51123. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51124. colors.push(reader.readComponents());
  51125. }
  51126. var tmp1, tmp2, tmp3, tmp4;
  51127. switch (f) {
  51128. case 0:
  51129. ps[12] = pi + 3;
  51130. ps[13] = pi + 4;
  51131. ps[14] = pi + 5;
  51132. ps[15] = pi + 6;
  51133. ps[8] = pi + 2;
  51134. ps[11] = pi + 7;
  51135. ps[4] = pi + 1;
  51136. ps[7] = pi + 8;
  51137. ps[0] = pi;
  51138. ps[1] = pi + 11;
  51139. ps[2] = pi + 10;
  51140. ps[3] = pi + 9;
  51141. cs[2] = ci + 1;
  51142. cs[3] = ci + 2;
  51143. cs[0] = ci;
  51144. cs[1] = ci + 3;
  51145. break;
  51146. case 1:
  51147. tmp1 = ps[12];
  51148. tmp2 = ps[13];
  51149. tmp3 = ps[14];
  51150. tmp4 = ps[15];
  51151. ps[12] = tmp4;
  51152. ps[13] = pi + 0;
  51153. ps[14] = pi + 1;
  51154. ps[15] = pi + 2;
  51155. ps[8] = tmp3;
  51156. ps[11] = pi + 3;
  51157. ps[4] = tmp2;
  51158. ps[7] = pi + 4;
  51159. ps[0] = tmp1;
  51160. ps[1] = pi + 7;
  51161. ps[2] = pi + 6;
  51162. ps[3] = pi + 5;
  51163. tmp1 = cs[2];
  51164. tmp2 = cs[3];
  51165. cs[2] = tmp2;
  51166. cs[3] = ci;
  51167. cs[0] = tmp1;
  51168. cs[1] = ci + 1;
  51169. break;
  51170. case 2:
  51171. tmp1 = ps[15];
  51172. tmp2 = ps[11];
  51173. ps[12] = ps[3];
  51174. ps[13] = pi + 0;
  51175. ps[14] = pi + 1;
  51176. ps[15] = pi + 2;
  51177. ps[8] = ps[7];
  51178. ps[11] = pi + 3;
  51179. ps[4] = tmp2;
  51180. ps[7] = pi + 4;
  51181. ps[0] = tmp1;
  51182. ps[1] = pi + 7;
  51183. ps[2] = pi + 6;
  51184. ps[3] = pi + 5;
  51185. tmp1 = cs[3];
  51186. cs[2] = cs[1];
  51187. cs[3] = ci;
  51188. cs[0] = tmp1;
  51189. cs[1] = ci + 1;
  51190. break;
  51191. case 3:
  51192. ps[12] = ps[0];
  51193. ps[13] = pi + 0;
  51194. ps[14] = pi + 1;
  51195. ps[15] = pi + 2;
  51196. ps[8] = ps[1];
  51197. ps[11] = pi + 3;
  51198. ps[4] = ps[2];
  51199. ps[7] = pi + 4;
  51200. ps[0] = ps[3];
  51201. ps[1] = pi + 7;
  51202. ps[2] = pi + 6;
  51203. ps[3] = pi + 5;
  51204. cs[2] = cs[0];
  51205. cs[3] = ci;
  51206. cs[0] = cs[1];
  51207. cs[1] = ci + 1;
  51208. break;
  51209. }
  51210. ps[5] = coords.length;
  51211. coords.push([
  51212. (-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,
  51213. (-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
  51214. ]);
  51215. ps[6] = coords.length;
  51216. coords.push([
  51217. (-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,
  51218. (-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
  51219. ]);
  51220. ps[9] = coords.length;
  51221. coords.push([
  51222. (-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,
  51223. (-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
  51224. ]);
  51225. ps[10] = coords.length;
  51226. coords.push([
  51227. (-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,
  51228. (-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
  51229. ]);
  51230. mesh.figures.push({
  51231. type: 'patch',
  51232. coords: new Int32Array(ps),
  51233. colors: new Int32Array(cs)
  51234. });
  51235. }
  51236. }
  51237. function decodeType7Shading(mesh, reader) {
  51238. var coords = mesh.coords;
  51239. var colors = mesh.colors;
  51240. var ps = new Int32Array(16);
  51241. var cs = new Int32Array(4);
  51242. while (reader.hasData) {
  51243. var f = reader.readFlag();
  51244. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51245. var i, ii;
  51246. var pi = coords.length;
  51247. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51248. coords.push(reader.readCoordinate());
  51249. }
  51250. var ci = colors.length;
  51251. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51252. colors.push(reader.readComponents());
  51253. }
  51254. var tmp1, tmp2, tmp3, tmp4;
  51255. switch (f) {
  51256. case 0:
  51257. ps[12] = pi + 3;
  51258. ps[13] = pi + 4;
  51259. ps[14] = pi + 5;
  51260. ps[15] = pi + 6;
  51261. ps[8] = pi + 2;
  51262. ps[9] = pi + 13;
  51263. ps[10] = pi + 14;
  51264. ps[11] = pi + 7;
  51265. ps[4] = pi + 1;
  51266. ps[5] = pi + 12;
  51267. ps[6] = pi + 15;
  51268. ps[7] = pi + 8;
  51269. ps[0] = pi;
  51270. ps[1] = pi + 11;
  51271. ps[2] = pi + 10;
  51272. ps[3] = pi + 9;
  51273. cs[2] = ci + 1;
  51274. cs[3] = ci + 2;
  51275. cs[0] = ci;
  51276. cs[1] = ci + 3;
  51277. break;
  51278. case 1:
  51279. tmp1 = ps[12];
  51280. tmp2 = ps[13];
  51281. tmp3 = ps[14];
  51282. tmp4 = ps[15];
  51283. ps[12] = tmp4;
  51284. ps[13] = pi + 0;
  51285. ps[14] = pi + 1;
  51286. ps[15] = pi + 2;
  51287. ps[8] = tmp3;
  51288. ps[9] = pi + 9;
  51289. ps[10] = pi + 10;
  51290. ps[11] = pi + 3;
  51291. ps[4] = tmp2;
  51292. ps[5] = pi + 8;
  51293. ps[6] = pi + 11;
  51294. ps[7] = pi + 4;
  51295. ps[0] = tmp1;
  51296. ps[1] = pi + 7;
  51297. ps[2] = pi + 6;
  51298. ps[3] = pi + 5;
  51299. tmp1 = cs[2];
  51300. tmp2 = cs[3];
  51301. cs[2] = tmp2;
  51302. cs[3] = ci;
  51303. cs[0] = tmp1;
  51304. cs[1] = ci + 1;
  51305. break;
  51306. case 2:
  51307. tmp1 = ps[15];
  51308. tmp2 = ps[11];
  51309. ps[12] = ps[3];
  51310. ps[13] = pi + 0;
  51311. ps[14] = pi + 1;
  51312. ps[15] = pi + 2;
  51313. ps[8] = ps[7];
  51314. ps[9] = pi + 9;
  51315. ps[10] = pi + 10;
  51316. ps[11] = pi + 3;
  51317. ps[4] = tmp2;
  51318. ps[5] = pi + 8;
  51319. ps[6] = pi + 11;
  51320. ps[7] = pi + 4;
  51321. ps[0] = tmp1;
  51322. ps[1] = pi + 7;
  51323. ps[2] = pi + 6;
  51324. ps[3] = pi + 5;
  51325. tmp1 = cs[3];
  51326. cs[2] = cs[1];
  51327. cs[3] = ci;
  51328. cs[0] = tmp1;
  51329. cs[1] = ci + 1;
  51330. break;
  51331. case 3:
  51332. ps[12] = ps[0];
  51333. ps[13] = pi + 0;
  51334. ps[14] = pi + 1;
  51335. ps[15] = pi + 2;
  51336. ps[8] = ps[1];
  51337. ps[9] = pi + 9;
  51338. ps[10] = pi + 10;
  51339. ps[11] = pi + 3;
  51340. ps[4] = ps[2];
  51341. ps[5] = pi + 8;
  51342. ps[6] = pi + 11;
  51343. ps[7] = pi + 4;
  51344. ps[0] = ps[3];
  51345. ps[1] = pi + 7;
  51346. ps[2] = pi + 6;
  51347. ps[3] = pi + 5;
  51348. cs[2] = cs[0];
  51349. cs[3] = ci;
  51350. cs[0] = cs[1];
  51351. cs[1] = ci + 1;
  51352. break;
  51353. }
  51354. mesh.figures.push({
  51355. type: 'patch',
  51356. coords: new Int32Array(ps),
  51357. colors: new Int32Array(cs)
  51358. });
  51359. }
  51360. }
  51361. function updateBounds(mesh) {
  51362. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51363. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51364. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51365. minX = minX > x ? x : minX;
  51366. minY = minY > y ? y : minY;
  51367. maxX = maxX < x ? x : maxX;
  51368. maxY = maxY < y ? y : maxY;
  51369. }
  51370. mesh.bounds = [
  51371. minX,
  51372. minY,
  51373. maxX,
  51374. maxY
  51375. ];
  51376. }
  51377. function packData(mesh) {
  51378. var i, ii, j, jj;
  51379. var coords = mesh.coords;
  51380. var coordsPacked = new Float32Array(coords.length * 2);
  51381. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51382. var xy = coords[i];
  51383. coordsPacked[j++] = xy[0];
  51384. coordsPacked[j++] = xy[1];
  51385. }
  51386. mesh.coords = coordsPacked;
  51387. var colors = mesh.colors;
  51388. var colorsPacked = new Uint8Array(colors.length * 3);
  51389. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51390. var c = colors[i];
  51391. colorsPacked[j++] = c[0];
  51392. colorsPacked[j++] = c[1];
  51393. colorsPacked[j++] = c[2];
  51394. }
  51395. mesh.colors = colorsPacked;
  51396. var figures = mesh.figures;
  51397. for (i = 0, ii = figures.length; i < ii; i++) {
  51398. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51399. for (j = 0, jj = ps.length; j < jj; j++) {
  51400. ps[j] *= 2;
  51401. cs[j] *= 3;
  51402. }
  51403. }
  51404. }
  51405. function Mesh(stream, matrix, xref, res) {
  51406. assert(isStream(stream), 'Mesh data is not a stream');
  51407. var dict = stream.dict;
  51408. this.matrix = matrix;
  51409. this.shadingType = dict.get('ShadingType');
  51410. this.type = 'Pattern';
  51411. this.bbox = dict.getArray('BBox');
  51412. var cs = dict.get('ColorSpace', 'CS');
  51413. cs = ColorSpace.parse(cs, xref, res);
  51414. this.cs = cs;
  51415. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51416. var fnObj = dict.get('Function');
  51417. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51418. this.coords = [];
  51419. this.colors = [];
  51420. this.figures = [];
  51421. var decodeContext = {
  51422. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51423. bitsPerComponent: dict.get('BitsPerComponent'),
  51424. bitsPerFlag: dict.get('BitsPerFlag'),
  51425. decode: dict.getArray('Decode'),
  51426. colorFn: fn,
  51427. colorSpace: cs,
  51428. numComps: fn ? 1 : cs.numComps
  51429. };
  51430. var reader = new MeshStreamReader(stream, decodeContext);
  51431. var patchMesh = false;
  51432. switch (this.shadingType) {
  51433. case ShadingType.FREE_FORM_MESH:
  51434. decodeType4Shading(this, reader);
  51435. break;
  51436. case ShadingType.LATTICE_FORM_MESH:
  51437. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51438. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51439. decodeType5Shading(this, reader, verticesPerRow);
  51440. break;
  51441. case ShadingType.COONS_PATCH_MESH:
  51442. decodeType6Shading(this, reader);
  51443. patchMesh = true;
  51444. break;
  51445. case ShadingType.TENSOR_PATCH_MESH:
  51446. decodeType7Shading(this, reader);
  51447. patchMesh = true;
  51448. break;
  51449. default:
  51450. error('Unsupported mesh type.');
  51451. break;
  51452. }
  51453. if (patchMesh) {
  51454. updateBounds(this);
  51455. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51456. buildFigureFromPatch(this, i);
  51457. }
  51458. }
  51459. updateBounds(this);
  51460. packData(this);
  51461. }
  51462. Mesh.prototype = {
  51463. getIR: function Mesh_getIR() {
  51464. return [
  51465. 'Mesh',
  51466. this.shadingType,
  51467. this.coords,
  51468. this.colors,
  51469. this.figures,
  51470. this.bounds,
  51471. this.matrix,
  51472. this.bbox,
  51473. this.background
  51474. ];
  51475. }
  51476. };
  51477. return Mesh;
  51478. }();
  51479. Shadings.Dummy = function DummyClosure() {
  51480. function Dummy() {
  51481. this.type = 'Pattern';
  51482. }
  51483. Dummy.prototype = {
  51484. getIR: function Dummy_getIR() {
  51485. return ['Dummy'];
  51486. }
  51487. };
  51488. return Dummy;
  51489. }();
  51490. function getTilingPatternIR(operatorList, dict, args) {
  51491. var matrix = dict.getArray('Matrix');
  51492. var bbox = dict.getArray('BBox');
  51493. var xstep = dict.get('XStep');
  51494. var ystep = dict.get('YStep');
  51495. var paintType = dict.get('PaintType');
  51496. var tilingType = dict.get('TilingType');
  51497. return [
  51498. 'TilingPattern',
  51499. args,
  51500. operatorList,
  51501. matrix,
  51502. bbox,
  51503. xstep,
  51504. ystep,
  51505. paintType,
  51506. tilingType
  51507. ];
  51508. }
  51509. exports.Pattern = Pattern;
  51510. exports.getTilingPatternIR = getTilingPatternIR;
  51511. }));
  51512. (function (root, factory) {
  51513. 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);
  51514. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51515. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51516. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51517. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51518. var ImageKind = sharedUtil.ImageKind;
  51519. var OPS = sharedUtil.OPS;
  51520. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51521. var Util = sharedUtil.Util;
  51522. var assert = sharedUtil.assert;
  51523. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51524. var error = sharedUtil.error;
  51525. var info = sharedUtil.info;
  51526. var isArray = sharedUtil.isArray;
  51527. var isNum = sharedUtil.isNum;
  51528. var isString = sharedUtil.isString;
  51529. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51530. var warn = sharedUtil.warn;
  51531. var Dict = corePrimitives.Dict;
  51532. var Name = corePrimitives.Name;
  51533. var isCmd = corePrimitives.isCmd;
  51534. var isDict = corePrimitives.isDict;
  51535. var isName = corePrimitives.isName;
  51536. var isRef = corePrimitives.isRef;
  51537. var isStream = corePrimitives.isStream;
  51538. var DecodeStream = coreStream.DecodeStream;
  51539. var JpegStream = coreStream.JpegStream;
  51540. var Stream = coreStream.Stream;
  51541. var Lexer = coreParser.Lexer;
  51542. var Parser = coreParser.Parser;
  51543. var isEOF = coreParser.isEOF;
  51544. var PDFImage = coreImage.PDFImage;
  51545. var ColorSpace = coreColorSpace.ColorSpace;
  51546. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51547. var ErrorFont = coreFonts.ErrorFont;
  51548. var FontFlags = coreFonts.FontFlags;
  51549. var Font = coreFonts.Font;
  51550. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51551. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51552. var getFontType = coreFonts.getFontType;
  51553. var isPDFFunction = coreFunction.isPDFFunction;
  51554. var PDFFunction = coreFunction.PDFFunction;
  51555. var Pattern = corePattern.Pattern;
  51556. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51557. var CMapFactory = coreCMap.CMapFactory;
  51558. var IdentityCMap = coreCMap.IdentityCMap;
  51559. var getMetrics = coreMetrics.getMetrics;
  51560. var bidi = coreBidi.bidi;
  51561. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51562. var StandardEncoding = coreEncodings.StandardEncoding;
  51563. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51564. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51565. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51566. var getEncoding = coreEncodings.getEncoding;
  51567. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51568. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51569. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51570. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51571. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51572. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51573. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51574. var PartialEvaluator = function PartialEvaluatorClosure() {
  51575. var DefaultPartialEvaluatorOptions = {
  51576. forceDataSchema: false,
  51577. maxImageSize: -1,
  51578. disableFontFace: false,
  51579. cMapOptions: {
  51580. url: null,
  51581. packed: false
  51582. }
  51583. };
  51584. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51585. this.xref = xref;
  51586. this.resources = resources;
  51587. this.handler = handler;
  51588. this.forceDataSchema = forceDataSchema;
  51589. }
  51590. NativeImageDecoder.prototype = {
  51591. canDecode: function (image) {
  51592. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51593. },
  51594. decode: function (image) {
  51595. var dict = image.dict;
  51596. var colorSpace = dict.get('ColorSpace', 'CS');
  51597. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51598. var numComps = colorSpace.numComps;
  51599. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51600. image.getIR(this.forceDataSchema),
  51601. numComps
  51602. ]);
  51603. return decodePromise.then(function (message) {
  51604. var data = message.data;
  51605. return new Stream(data, 0, data.length, image.dict);
  51606. });
  51607. }
  51608. };
  51609. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51610. var dict = image.dict;
  51611. if (dict.has('DecodeParms') || dict.has('DP')) {
  51612. return false;
  51613. }
  51614. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51615. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51616. };
  51617. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51618. var dict = image.dict;
  51619. if (dict.has('DecodeParms') || dict.has('DP')) {
  51620. return false;
  51621. }
  51622. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51623. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51624. };
  51625. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  51626. this.pdfManager = pdfManager;
  51627. this.xref = xref;
  51628. this.handler = handler;
  51629. this.pageIndex = pageIndex;
  51630. this.uniquePrefix = uniquePrefix;
  51631. this.idCounters = idCounters;
  51632. this.fontCache = fontCache;
  51633. this.options = options || DefaultPartialEvaluatorOptions;
  51634. }
  51635. var TIME_SLOT_DURATION_MS = 20;
  51636. var CHECK_TIME_EVERY = 100;
  51637. function TimeSlotManager() {
  51638. this.reset();
  51639. }
  51640. TimeSlotManager.prototype = {
  51641. check: function TimeSlotManager_check() {
  51642. if (++this.checked < CHECK_TIME_EVERY) {
  51643. return false;
  51644. }
  51645. this.checked = 0;
  51646. return this.endTime <= Date.now();
  51647. },
  51648. reset: function TimeSlotManager_reset() {
  51649. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51650. this.checked = 0;
  51651. }
  51652. };
  51653. var deferred = Promise.resolve();
  51654. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51655. PartialEvaluator.prototype = {
  51656. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51657. if (!isDict(resources)) {
  51658. return false;
  51659. }
  51660. var processed = Object.create(null);
  51661. if (resources.objId) {
  51662. processed[resources.objId] = true;
  51663. }
  51664. var nodes = [resources], xref = this.xref;
  51665. while (nodes.length) {
  51666. var key, i, ii;
  51667. var node = nodes.shift();
  51668. var graphicStates = node.get('ExtGState');
  51669. if (isDict(graphicStates)) {
  51670. var graphicStatesKeys = graphicStates.getKeys();
  51671. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51672. key = graphicStatesKeys[i];
  51673. var graphicState = graphicStates.get(key);
  51674. var bm = graphicState.get('BM');
  51675. if (isName(bm) && bm.name !== 'Normal') {
  51676. return true;
  51677. }
  51678. }
  51679. }
  51680. var xObjects = node.get('XObject');
  51681. if (!isDict(xObjects)) {
  51682. continue;
  51683. }
  51684. var xObjectsKeys = xObjects.getKeys();
  51685. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51686. key = xObjectsKeys[i];
  51687. var xObject = xObjects.getRaw(key);
  51688. if (isRef(xObject)) {
  51689. if (processed[xObject.toString()]) {
  51690. continue;
  51691. }
  51692. xObject = xref.fetch(xObject);
  51693. }
  51694. if (!isStream(xObject)) {
  51695. continue;
  51696. }
  51697. if (xObject.dict.objId) {
  51698. if (processed[xObject.dict.objId]) {
  51699. continue;
  51700. }
  51701. processed[xObject.dict.objId] = true;
  51702. }
  51703. var xResources = xObject.dict.get('Resources');
  51704. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51705. nodes.push(xResources);
  51706. if (xResources.objId) {
  51707. processed[xResources.objId] = true;
  51708. }
  51709. }
  51710. }
  51711. }
  51712. return false;
  51713. },
  51714. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51715. var matrix = xobj.dict.getArray('Matrix');
  51716. var bbox = xobj.dict.getArray('BBox');
  51717. var group = xobj.dict.get('Group');
  51718. if (group) {
  51719. var groupOptions = {
  51720. matrix: matrix,
  51721. bbox: bbox,
  51722. smask: smask,
  51723. isolated: false,
  51724. knockout: false
  51725. };
  51726. var groupSubtype = group.get('S');
  51727. var colorSpace;
  51728. if (isName(groupSubtype, 'Transparency')) {
  51729. groupOptions.isolated = group.get('I') || false;
  51730. groupOptions.knockout = group.get('K') || false;
  51731. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51732. }
  51733. if (smask && smask.backdrop) {
  51734. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51735. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51736. }
  51737. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51738. }
  51739. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51740. matrix,
  51741. bbox
  51742. ]);
  51743. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51744. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51745. if (group) {
  51746. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51747. }
  51748. });
  51749. },
  51750. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51751. var self = this;
  51752. var dict = image.dict;
  51753. var w = dict.get('Width', 'W');
  51754. var h = dict.get('Height', 'H');
  51755. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51756. warn('Image dimensions are missing, or not numbers.');
  51757. return;
  51758. }
  51759. var maxImageSize = this.options.maxImageSize;
  51760. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51761. warn('Image exceeded maximum allowed size and was removed.');
  51762. return;
  51763. }
  51764. var imageMask = dict.get('ImageMask', 'IM') || false;
  51765. var imgData, args;
  51766. if (imageMask) {
  51767. var width = dict.get('Width', 'W');
  51768. var height = dict.get('Height', 'H');
  51769. var bitStrideLength = width + 7 >> 3;
  51770. var imgArray = image.getBytes(bitStrideLength * height);
  51771. var decode = dict.getArray('Decode', 'D');
  51772. var inverseDecode = !!decode && decode[0] > 0;
  51773. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51774. imgData.cached = true;
  51775. args = [imgData];
  51776. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51777. if (cacheKey) {
  51778. imageCache[cacheKey] = {
  51779. fn: OPS.paintImageMaskXObject,
  51780. args: args
  51781. };
  51782. }
  51783. return;
  51784. }
  51785. var softMask = dict.get('SMask', 'SM') || false;
  51786. var mask = dict.get('Mask') || false;
  51787. var SMALL_IMAGE_DIMENSIONS = 200;
  51788. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51789. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51790. imgData = imageObj.createImageData(true);
  51791. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51792. return;
  51793. }
  51794. var uniquePrefix = this.uniquePrefix || '';
  51795. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  51796. operatorList.addDependency(objId);
  51797. args = [
  51798. objId,
  51799. w,
  51800. h
  51801. ];
  51802. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51803. operatorList.addOp(OPS.paintJpegXObject, args);
  51804. this.handler.send('obj', [
  51805. objId,
  51806. this.pageIndex,
  51807. 'JpegStream',
  51808. image.getIR(this.options.forceDataSchema)
  51809. ]);
  51810. return;
  51811. }
  51812. var nativeImageDecoder = null;
  51813. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51814. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51815. }
  51816. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51817. var imgData = imageObj.createImageData(false);
  51818. self.handler.send('obj', [
  51819. objId,
  51820. self.pageIndex,
  51821. 'Image',
  51822. imgData
  51823. ], [imgData.data.buffer]);
  51824. }).then(undefined, function (reason) {
  51825. warn('Unable to decode image: ' + reason);
  51826. self.handler.send('obj', [
  51827. objId,
  51828. self.pageIndex,
  51829. 'Image',
  51830. null
  51831. ]);
  51832. });
  51833. operatorList.addOp(OPS.paintImageXObject, args);
  51834. if (cacheKey) {
  51835. imageCache[cacheKey] = {
  51836. fn: OPS.paintImageXObject,
  51837. args: args
  51838. };
  51839. }
  51840. },
  51841. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51842. var smaskContent = smask.get('G');
  51843. var smaskOptions = {
  51844. subtype: smask.get('S').name,
  51845. backdrop: smask.get('BC')
  51846. };
  51847. var transferObj = smask.get('TR');
  51848. if (isPDFFunction(transferObj)) {
  51849. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51850. var transferMap = new Uint8Array(256);
  51851. var tmp = new Float32Array(1);
  51852. for (var i = 0; i < 256; i++) {
  51853. tmp[0] = i / 255;
  51854. transferFn(tmp, 0, tmp, 0);
  51855. transferMap[i] = tmp[0] * 255 | 0;
  51856. }
  51857. smaskOptions.transferMap = transferMap;
  51858. }
  51859. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  51860. },
  51861. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  51862. var tilingOpList = new OperatorList();
  51863. var resourcesArray = [
  51864. patternDict.get('Resources'),
  51865. resources
  51866. ];
  51867. var patternResources = Dict.merge(this.xref, resourcesArray);
  51868. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  51869. operatorList.addDependencies(tilingOpList.dependencies);
  51870. operatorList.addOp(fn, getTilingPatternIR({
  51871. fnArray: tilingOpList.fnArray,
  51872. argsArray: tilingOpList.argsArray
  51873. }, patternDict, args));
  51874. });
  51875. },
  51876. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  51877. var fontName;
  51878. if (fontArgs) {
  51879. fontArgs = fontArgs.slice();
  51880. fontName = fontArgs[0].name;
  51881. }
  51882. var self = this;
  51883. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  51884. if (!translated.font.isType3Font) {
  51885. return translated;
  51886. }
  51887. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  51888. return translated;
  51889. }, function (reason) {
  51890. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51891. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  51892. });
  51893. }).then(function (translated) {
  51894. state.font = translated.font;
  51895. translated.send(self.handler);
  51896. return translated.loadedName;
  51897. });
  51898. },
  51899. handleText: function PartialEvaluator_handleText(chars, state) {
  51900. var font = state.font;
  51901. var glyphs = font.charsToGlyphs(chars);
  51902. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  51903. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  51904. var buildPath = function (fontChar) {
  51905. if (!font.renderer.hasBuiltPath(fontChar)) {
  51906. var path = font.renderer.getPathJs(fontChar);
  51907. this.handler.send('commonobj', [
  51908. font.loadedName + '_path_' + fontChar,
  51909. 'FontPath',
  51910. path
  51911. ]);
  51912. }
  51913. }.bind(this);
  51914. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  51915. var glyph = glyphs[i];
  51916. buildPath(glyph.fontChar);
  51917. var accent = glyph.accent;
  51918. if (accent && accent.fontChar) {
  51919. buildPath(accent.fontChar);
  51920. }
  51921. }
  51922. }
  51923. return glyphs;
  51924. },
  51925. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  51926. var gStateObj = [];
  51927. var gStateKeys = gState.getKeys();
  51928. var self = this;
  51929. var promise = Promise.resolve();
  51930. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  51931. var key = gStateKeys[i];
  51932. var value = gState.get(key);
  51933. switch (key) {
  51934. case 'Type':
  51935. break;
  51936. case 'LW':
  51937. case 'LC':
  51938. case 'LJ':
  51939. case 'ML':
  51940. case 'D':
  51941. case 'RI':
  51942. case 'FL':
  51943. case 'CA':
  51944. case 'ca':
  51945. gStateObj.push([
  51946. key,
  51947. value
  51948. ]);
  51949. break;
  51950. case 'Font':
  51951. promise = promise.then(function () {
  51952. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  51953. operatorList.addDependency(loadedName);
  51954. gStateObj.push([
  51955. key,
  51956. [
  51957. loadedName,
  51958. value[1]
  51959. ]
  51960. ]);
  51961. });
  51962. });
  51963. break;
  51964. case 'BM':
  51965. gStateObj.push([
  51966. key,
  51967. value
  51968. ]);
  51969. break;
  51970. case 'SMask':
  51971. if (isName(value, 'None')) {
  51972. gStateObj.push([
  51973. key,
  51974. false
  51975. ]);
  51976. break;
  51977. }
  51978. if (isDict(value)) {
  51979. promise = promise.then(function (dict) {
  51980. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  51981. }.bind(this, value));
  51982. gStateObj.push([
  51983. key,
  51984. true
  51985. ]);
  51986. } else {
  51987. warn('Unsupported SMask type');
  51988. }
  51989. break;
  51990. case 'OP':
  51991. case 'op':
  51992. case 'OPM':
  51993. case 'BG':
  51994. case 'BG2':
  51995. case 'UCR':
  51996. case 'UCR2':
  51997. case 'TR':
  51998. case 'TR2':
  51999. case 'HT':
  52000. case 'SM':
  52001. case 'SA':
  52002. case 'AIS':
  52003. case 'TK':
  52004. info('graphic state operator ' + key);
  52005. break;
  52006. default:
  52007. info('Unknown graphic state operator ' + key);
  52008. break;
  52009. }
  52010. }
  52011. return promise.then(function () {
  52012. if (gStateObj.length > 0) {
  52013. operatorList.addOp(OPS.setGState, [gStateObj]);
  52014. }
  52015. });
  52016. },
  52017. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52018. function errorFont() {
  52019. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52020. }
  52021. var fontRef;
  52022. if (font) {
  52023. assert(isRef(font));
  52024. fontRef = font;
  52025. } else {
  52026. var fontRes = resources.get('Font');
  52027. if (fontRes) {
  52028. fontRef = fontRes.getRaw(fontName);
  52029. } else {
  52030. warn('fontRes not available');
  52031. return errorFont();
  52032. }
  52033. }
  52034. if (!fontRef) {
  52035. warn('fontRef not available');
  52036. return errorFont();
  52037. }
  52038. if (this.fontCache.has(fontRef)) {
  52039. return this.fontCache.get(fontRef);
  52040. }
  52041. font = xref.fetchIfRef(fontRef);
  52042. if (!isDict(font)) {
  52043. return errorFont();
  52044. }
  52045. if (font.translated) {
  52046. return font.translated;
  52047. }
  52048. var fontCapability = createPromiseCapability();
  52049. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52050. var descriptor = preEvaluatedFont.descriptor;
  52051. var fontRefIsRef = isRef(fontRef), fontID;
  52052. if (fontRefIsRef) {
  52053. fontID = fontRef.toString();
  52054. }
  52055. if (isDict(descriptor)) {
  52056. if (!descriptor.fontAliases) {
  52057. descriptor.fontAliases = Object.create(null);
  52058. }
  52059. var fontAliases = descriptor.fontAliases;
  52060. var hash = preEvaluatedFont.hash;
  52061. if (fontAliases[hash]) {
  52062. var aliasFontRef = fontAliases[hash].aliasRef;
  52063. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52064. this.fontCache.putAlias(fontRef, aliasFontRef);
  52065. return this.fontCache.get(fontRef);
  52066. }
  52067. } else {
  52068. fontAliases[hash] = { fontID: Font.getFontID() };
  52069. }
  52070. if (fontRefIsRef) {
  52071. fontAliases[hash].aliasRef = fontRef;
  52072. }
  52073. fontID = fontAliases[hash].fontID;
  52074. }
  52075. if (fontRefIsRef) {
  52076. this.fontCache.put(fontRef, fontCapability.promise);
  52077. } else {
  52078. if (!fontID) {
  52079. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  52080. }
  52081. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52082. }
  52083. assert(fontID, 'The "fontID" must be defined.');
  52084. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52085. font.translated = fontCapability.promise;
  52086. var translatedPromise;
  52087. try {
  52088. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52089. } catch (e) {
  52090. translatedPromise = Promise.reject(e);
  52091. }
  52092. var self = this;
  52093. translatedPromise.then(function (translatedFont) {
  52094. if (translatedFont.fontType !== undefined) {
  52095. var xrefFontStats = xref.stats.fontTypes;
  52096. xrefFontStats[translatedFont.fontType] = true;
  52097. }
  52098. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52099. }, function (reason) {
  52100. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52101. try {
  52102. var descriptor = preEvaluatedFont.descriptor;
  52103. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52104. var subtype = fontFile3 && fontFile3.get('Subtype');
  52105. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52106. var xrefFontStats = xref.stats.fontTypes;
  52107. xrefFontStats[fontType] = true;
  52108. } catch (ex) {
  52109. }
  52110. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52111. });
  52112. return fontCapability.promise;
  52113. },
  52114. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52115. var lastIndex = operatorList.length - 1;
  52116. if (!args) {
  52117. args = [];
  52118. }
  52119. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52120. operatorList.addOp(OPS.constructPath, [
  52121. [fn],
  52122. args
  52123. ]);
  52124. } else {
  52125. var opArgs = operatorList.argsArray[lastIndex];
  52126. opArgs[0].push(fn);
  52127. Array.prototype.push.apply(opArgs[1], args);
  52128. }
  52129. },
  52130. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52131. var patternName = args[args.length - 1];
  52132. var pattern;
  52133. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52134. var dict = isStream(pattern) ? pattern.dict : pattern;
  52135. var typeNum = dict.get('PatternType');
  52136. if (typeNum === TILING_PATTERN) {
  52137. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52138. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52139. } else if (typeNum === SHADING_PATTERN) {
  52140. var shading = dict.get('Shading');
  52141. var matrix = dict.getArray('Matrix');
  52142. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52143. operatorList.addOp(fn, pattern.getIR());
  52144. return Promise.resolve();
  52145. } else {
  52146. return Promise.reject('Unknown PatternType: ' + typeNum);
  52147. }
  52148. }
  52149. operatorList.addOp(fn, args);
  52150. return Promise.resolve();
  52151. },
  52152. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52153. var self = this;
  52154. var xref = this.xref;
  52155. var imageCache = Object.create(null);
  52156. assert(operatorList);
  52157. resources = resources || Dict.empty;
  52158. var xobjs = resources.get('XObject') || Dict.empty;
  52159. var patterns = resources.get('Pattern') || Dict.empty;
  52160. var stateManager = new StateManager(initialState || new EvalState());
  52161. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52162. var timeSlotManager = new TimeSlotManager();
  52163. return new Promise(function promiseBody(resolve, reject) {
  52164. var next = function (promise) {
  52165. promise.then(function () {
  52166. try {
  52167. promiseBody(resolve, reject);
  52168. } catch (ex) {
  52169. reject(ex);
  52170. }
  52171. }, reject);
  52172. };
  52173. task.ensureNotTerminated();
  52174. timeSlotManager.reset();
  52175. var stop, operation = {}, i, ii, cs;
  52176. while (!(stop = timeSlotManager.check())) {
  52177. operation.args = null;
  52178. if (!preprocessor.read(operation)) {
  52179. break;
  52180. }
  52181. var args = operation.args;
  52182. var fn = operation.fn;
  52183. switch (fn | 0) {
  52184. case OPS.paintXObject:
  52185. if (args[0].code) {
  52186. break;
  52187. }
  52188. var name = args[0].name;
  52189. if (!name) {
  52190. warn('XObject must be referred to by name.');
  52191. continue;
  52192. }
  52193. if (imageCache[name] !== undefined) {
  52194. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52195. args = null;
  52196. continue;
  52197. }
  52198. var xobj = xobjs.get(name);
  52199. if (xobj) {
  52200. assert(isStream(xobj), 'XObject should be a stream');
  52201. var type = xobj.dict.get('Subtype');
  52202. assert(isName(type), 'XObject should have a Name subtype');
  52203. if (type.name === 'Form') {
  52204. stateManager.save();
  52205. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52206. stateManager.restore();
  52207. }));
  52208. return;
  52209. } else if (type.name === 'Image') {
  52210. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52211. args = null;
  52212. continue;
  52213. } else if (type.name === 'PS') {
  52214. info('Ignored XObject subtype PS');
  52215. continue;
  52216. } else {
  52217. error('Unhandled XObject subtype ' + type.name);
  52218. }
  52219. }
  52220. break;
  52221. case OPS.setFont:
  52222. var fontSize = args[1];
  52223. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52224. operatorList.addDependency(loadedName);
  52225. operatorList.addOp(OPS.setFont, [
  52226. loadedName,
  52227. fontSize
  52228. ]);
  52229. }));
  52230. return;
  52231. case OPS.endInlineImage:
  52232. var cacheKey = args[0].cacheKey;
  52233. if (cacheKey) {
  52234. var cacheEntry = imageCache[cacheKey];
  52235. if (cacheEntry !== undefined) {
  52236. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52237. args = null;
  52238. continue;
  52239. }
  52240. }
  52241. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52242. args = null;
  52243. continue;
  52244. case OPS.showText:
  52245. args[0] = self.handleText(args[0], stateManager.state);
  52246. break;
  52247. case OPS.showSpacedText:
  52248. var arr = args[0];
  52249. var combinedGlyphs = [];
  52250. var arrLength = arr.length;
  52251. var state = stateManager.state;
  52252. for (i = 0; i < arrLength; ++i) {
  52253. var arrItem = arr[i];
  52254. if (isString(arrItem)) {
  52255. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52256. } else if (isNum(arrItem)) {
  52257. combinedGlyphs.push(arrItem);
  52258. }
  52259. }
  52260. args[0] = combinedGlyphs;
  52261. fn = OPS.showText;
  52262. break;
  52263. case OPS.nextLineShowText:
  52264. operatorList.addOp(OPS.nextLine);
  52265. args[0] = self.handleText(args[0], stateManager.state);
  52266. fn = OPS.showText;
  52267. break;
  52268. case OPS.nextLineSetSpacingShowText:
  52269. operatorList.addOp(OPS.nextLine);
  52270. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52271. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52272. args[0] = self.handleText(args[0], stateManager.state);
  52273. fn = OPS.showText;
  52274. break;
  52275. case OPS.setTextRenderingMode:
  52276. stateManager.state.textRenderingMode = args[0];
  52277. break;
  52278. case OPS.setFillColorSpace:
  52279. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52280. continue;
  52281. case OPS.setStrokeColorSpace:
  52282. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52283. continue;
  52284. case OPS.setFillColor:
  52285. cs = stateManager.state.fillColorSpace;
  52286. args = cs.getRgb(args, 0);
  52287. fn = OPS.setFillRGBColor;
  52288. break;
  52289. case OPS.setStrokeColor:
  52290. cs = stateManager.state.strokeColorSpace;
  52291. args = cs.getRgb(args, 0);
  52292. fn = OPS.setStrokeRGBColor;
  52293. break;
  52294. case OPS.setFillGray:
  52295. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52296. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52297. fn = OPS.setFillRGBColor;
  52298. break;
  52299. case OPS.setStrokeGray:
  52300. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52301. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52302. fn = OPS.setStrokeRGBColor;
  52303. break;
  52304. case OPS.setFillCMYKColor:
  52305. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52306. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52307. fn = OPS.setFillRGBColor;
  52308. break;
  52309. case OPS.setStrokeCMYKColor:
  52310. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52311. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52312. fn = OPS.setStrokeRGBColor;
  52313. break;
  52314. case OPS.setFillRGBColor:
  52315. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52316. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52317. break;
  52318. case OPS.setStrokeRGBColor:
  52319. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52320. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52321. break;
  52322. case OPS.setFillColorN:
  52323. cs = stateManager.state.fillColorSpace;
  52324. if (cs.name === 'Pattern') {
  52325. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52326. return;
  52327. }
  52328. args = cs.getRgb(args, 0);
  52329. fn = OPS.setFillRGBColor;
  52330. break;
  52331. case OPS.setStrokeColorN:
  52332. cs = stateManager.state.strokeColorSpace;
  52333. if (cs.name === 'Pattern') {
  52334. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52335. return;
  52336. }
  52337. args = cs.getRgb(args, 0);
  52338. fn = OPS.setStrokeRGBColor;
  52339. break;
  52340. case OPS.shadingFill:
  52341. var shadingRes = resources.get('Shading');
  52342. if (!shadingRes) {
  52343. error('No shading resource found');
  52344. }
  52345. var shading = shadingRes.get(args[0].name);
  52346. if (!shading) {
  52347. error('No shading object found');
  52348. }
  52349. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52350. var patternIR = shadingFill.getIR();
  52351. args = [patternIR];
  52352. fn = OPS.shadingFill;
  52353. break;
  52354. case OPS.setGState:
  52355. var dictName = args[0];
  52356. var extGState = resources.get('ExtGState');
  52357. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52358. break;
  52359. }
  52360. var gState = extGState.get(dictName.name);
  52361. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52362. return;
  52363. case OPS.moveTo:
  52364. case OPS.lineTo:
  52365. case OPS.curveTo:
  52366. case OPS.curveTo2:
  52367. case OPS.curveTo3:
  52368. case OPS.closePath:
  52369. self.buildPath(operatorList, fn, args);
  52370. continue;
  52371. case OPS.rectangle:
  52372. self.buildPath(operatorList, fn, args);
  52373. continue;
  52374. case OPS.markPoint:
  52375. case OPS.markPointProps:
  52376. case OPS.beginMarkedContent:
  52377. case OPS.beginMarkedContentProps:
  52378. case OPS.endMarkedContent:
  52379. case OPS.beginCompat:
  52380. case OPS.endCompat:
  52381. continue;
  52382. default:
  52383. if (args !== null) {
  52384. for (i = 0, ii = args.length; i < ii; i++) {
  52385. if (args[i] instanceof Dict) {
  52386. break;
  52387. }
  52388. }
  52389. if (i < ii) {
  52390. warn('getOperatorList - ignoring operator: ' + fn);
  52391. continue;
  52392. }
  52393. }
  52394. }
  52395. operatorList.addOp(fn, args);
  52396. }
  52397. if (stop) {
  52398. next(deferred);
  52399. return;
  52400. }
  52401. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52402. operatorList.addOp(OPS.restore, []);
  52403. }
  52404. resolve();
  52405. });
  52406. },
  52407. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52408. stateManager = stateManager || new StateManager(new TextState());
  52409. var WhitespaceRegexp = /\s/g;
  52410. var textContent = {
  52411. items: [],
  52412. styles: Object.create(null)
  52413. };
  52414. var textContentItem = {
  52415. initialized: false,
  52416. str: [],
  52417. width: 0,
  52418. height: 0,
  52419. vertical: false,
  52420. lastAdvanceWidth: 0,
  52421. lastAdvanceHeight: 0,
  52422. textAdvanceScale: 0,
  52423. spaceWidth: 0,
  52424. fakeSpaceMin: Infinity,
  52425. fakeMultiSpaceMin: Infinity,
  52426. fakeMultiSpaceMax: -0,
  52427. textRunBreakAllowed: false,
  52428. transform: null,
  52429. fontName: null
  52430. };
  52431. var SPACE_FACTOR = 0.3;
  52432. var MULTI_SPACE_FACTOR = 1.5;
  52433. var MULTI_SPACE_FACTOR_MAX = 4;
  52434. var self = this;
  52435. var xref = this.xref;
  52436. resources = xref.fetchIfRef(resources) || Dict.empty;
  52437. var xobjs = null;
  52438. var xobjsCache = Object.create(null);
  52439. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52440. var textState;
  52441. function ensureTextContentItem() {
  52442. if (textContentItem.initialized) {
  52443. return textContentItem;
  52444. }
  52445. var font = textState.font;
  52446. if (!(font.loadedName in textContent.styles)) {
  52447. textContent.styles[font.loadedName] = {
  52448. fontFamily: font.fallbackName,
  52449. ascent: font.ascent,
  52450. descent: font.descent,
  52451. vertical: font.vertical
  52452. };
  52453. }
  52454. textContentItem.fontName = font.loadedName;
  52455. var tsm = [
  52456. textState.fontSize * textState.textHScale,
  52457. 0,
  52458. 0,
  52459. textState.fontSize,
  52460. 0,
  52461. textState.textRise
  52462. ];
  52463. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52464. var glyphHeight = font.bbox[3] - font.bbox[1];
  52465. if (glyphHeight > 0) {
  52466. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52467. tsm[3] *= glyphHeight;
  52468. }
  52469. }
  52470. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52471. textContentItem.transform = trm;
  52472. if (!font.vertical) {
  52473. textContentItem.width = 0;
  52474. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52475. textContentItem.vertical = false;
  52476. } else {
  52477. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52478. textContentItem.height = 0;
  52479. textContentItem.vertical = true;
  52480. }
  52481. var a = textState.textLineMatrix[0];
  52482. var b = textState.textLineMatrix[1];
  52483. var scaleLineX = Math.sqrt(a * a + b * b);
  52484. a = textState.ctm[0];
  52485. b = textState.ctm[1];
  52486. var scaleCtmX = Math.sqrt(a * a + b * b);
  52487. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52488. textContentItem.lastAdvanceWidth = 0;
  52489. textContentItem.lastAdvanceHeight = 0;
  52490. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52491. if (spaceWidth) {
  52492. textContentItem.spaceWidth = spaceWidth;
  52493. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52494. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52495. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52496. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52497. } else {
  52498. textContentItem.spaceWidth = 0;
  52499. textContentItem.fakeSpaceMin = Infinity;
  52500. textContentItem.fakeMultiSpaceMin = Infinity;
  52501. textContentItem.fakeMultiSpaceMax = 0;
  52502. textContentItem.textRunBreakAllowed = false;
  52503. }
  52504. textContentItem.initialized = true;
  52505. return textContentItem;
  52506. }
  52507. function replaceWhitespace(str) {
  52508. var i = 0, ii = str.length, code;
  52509. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52510. i++;
  52511. }
  52512. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52513. }
  52514. function runBidiTransform(textChunk) {
  52515. var str = textChunk.str.join('');
  52516. var bidiResult = bidi(str, -1, textChunk.vertical);
  52517. return {
  52518. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52519. dir: bidiResult.dir,
  52520. width: textChunk.width,
  52521. height: textChunk.height,
  52522. transform: textChunk.transform,
  52523. fontName: textChunk.fontName
  52524. };
  52525. }
  52526. function handleSetFont(fontName, fontRef) {
  52527. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52528. textState.font = translated.font;
  52529. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52530. });
  52531. }
  52532. function buildTextContentItem(chars) {
  52533. var font = textState.font;
  52534. var textChunk = ensureTextContentItem();
  52535. var width = 0;
  52536. var height = 0;
  52537. var glyphs = font.charsToGlyphs(chars);
  52538. var defaultVMetrics = font.defaultVMetrics;
  52539. for (var i = 0; i < glyphs.length; i++) {
  52540. var glyph = glyphs[i];
  52541. var vMetricX = null;
  52542. var vMetricY = null;
  52543. var glyphWidth = null;
  52544. if (font.vertical) {
  52545. if (glyph.vmetric) {
  52546. glyphWidth = glyph.vmetric[0];
  52547. vMetricX = glyph.vmetric[1];
  52548. vMetricY = glyph.vmetric[2];
  52549. } else {
  52550. glyphWidth = glyph.width;
  52551. vMetricX = glyph.width * 0.5;
  52552. vMetricY = defaultVMetrics[2];
  52553. }
  52554. } else {
  52555. glyphWidth = glyph.width;
  52556. }
  52557. var glyphUnicode = glyph.unicode;
  52558. var NormalizedUnicodes = getNormalizedUnicodes();
  52559. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52560. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52561. }
  52562. glyphUnicode = reverseIfRtl(glyphUnicode);
  52563. var charSpacing = textState.charSpacing;
  52564. if (glyph.isSpace) {
  52565. var wordSpacing = textState.wordSpacing;
  52566. charSpacing += wordSpacing;
  52567. if (wordSpacing > 0) {
  52568. addFakeSpaces(wordSpacing, textChunk.str);
  52569. }
  52570. }
  52571. var tx = 0;
  52572. var ty = 0;
  52573. if (!font.vertical) {
  52574. var w0 = glyphWidth * textState.fontMatrix[0];
  52575. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52576. width += tx;
  52577. } else {
  52578. var w1 = glyphWidth * textState.fontMatrix[0];
  52579. ty = w1 * textState.fontSize + charSpacing;
  52580. height += ty;
  52581. }
  52582. textState.translateTextMatrix(tx, ty);
  52583. textChunk.str.push(glyphUnicode);
  52584. }
  52585. if (!font.vertical) {
  52586. textChunk.lastAdvanceWidth = width;
  52587. textChunk.width += width * textChunk.textAdvanceScale;
  52588. } else {
  52589. textChunk.lastAdvanceHeight = height;
  52590. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  52591. }
  52592. return textChunk;
  52593. }
  52594. function addFakeSpaces(width, strBuf) {
  52595. if (width < textContentItem.fakeSpaceMin) {
  52596. return;
  52597. }
  52598. if (width < textContentItem.fakeMultiSpaceMin) {
  52599. strBuf.push(' ');
  52600. return;
  52601. }
  52602. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52603. while (fakeSpaces-- > 0) {
  52604. strBuf.push(' ');
  52605. }
  52606. }
  52607. function flushTextContentItem() {
  52608. if (!textContentItem.initialized) {
  52609. return;
  52610. }
  52611. textContent.items.push(runBidiTransform(textContentItem));
  52612. textContentItem.initialized = false;
  52613. textContentItem.str.length = 0;
  52614. }
  52615. var timeSlotManager = new TimeSlotManager();
  52616. return new Promise(function promiseBody(resolve, reject) {
  52617. var next = function (promise) {
  52618. promise.then(function () {
  52619. try {
  52620. promiseBody(resolve, reject);
  52621. } catch (ex) {
  52622. reject(ex);
  52623. }
  52624. }, reject);
  52625. };
  52626. task.ensureNotTerminated();
  52627. timeSlotManager.reset();
  52628. var stop, operation = {}, args = [];
  52629. while (!(stop = timeSlotManager.check())) {
  52630. args.length = 0;
  52631. operation.args = args;
  52632. if (!preprocessor.read(operation)) {
  52633. break;
  52634. }
  52635. textState = stateManager.state;
  52636. var fn = operation.fn;
  52637. args = operation.args;
  52638. var advance, diff;
  52639. switch (fn | 0) {
  52640. case OPS.setFont:
  52641. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52642. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52643. break;
  52644. }
  52645. flushTextContentItem();
  52646. textState.fontName = fontNameArg;
  52647. textState.fontSize = fontSizeArg;
  52648. next(handleSetFont(fontNameArg, null));
  52649. return;
  52650. case OPS.setTextRise:
  52651. flushTextContentItem();
  52652. textState.textRise = args[0];
  52653. break;
  52654. case OPS.setHScale:
  52655. flushTextContentItem();
  52656. textState.textHScale = args[0] / 100;
  52657. break;
  52658. case OPS.setLeading:
  52659. flushTextContentItem();
  52660. textState.leading = args[0];
  52661. break;
  52662. case OPS.moveText:
  52663. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52664. advance = args[0] - args[1];
  52665. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52666. textState.translateTextLineMatrix(args[0], args[1]);
  52667. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52668. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52669. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52670. addFakeSpaces(diff, textContentItem.str);
  52671. break;
  52672. }
  52673. flushTextContentItem();
  52674. textState.translateTextLineMatrix(args[0], args[1]);
  52675. textState.textMatrix = textState.textLineMatrix.slice();
  52676. break;
  52677. case OPS.setLeadingMoveText:
  52678. flushTextContentItem();
  52679. textState.leading = -args[1];
  52680. textState.translateTextLineMatrix(args[0], args[1]);
  52681. textState.textMatrix = textState.textLineMatrix.slice();
  52682. break;
  52683. case OPS.nextLine:
  52684. flushTextContentItem();
  52685. textState.carriageReturn();
  52686. break;
  52687. case OPS.setTextMatrix:
  52688. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52689. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52690. textState.translateTextLineMatrix(advance.width, advance.height);
  52691. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52692. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52693. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52694. addFakeSpaces(diff, textContentItem.str);
  52695. break;
  52696. }
  52697. flushTextContentItem();
  52698. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52699. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52700. break;
  52701. case OPS.setCharSpacing:
  52702. textState.charSpacing = args[0];
  52703. break;
  52704. case OPS.setWordSpacing:
  52705. textState.wordSpacing = args[0];
  52706. break;
  52707. case OPS.beginText:
  52708. flushTextContentItem();
  52709. textState.textMatrix = IDENTITY_MATRIX.slice();
  52710. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52711. break;
  52712. case OPS.showSpacedText:
  52713. var items = args[0];
  52714. var offset;
  52715. for (var j = 0, jj = items.length; j < jj; j++) {
  52716. if (typeof items[j] === 'string') {
  52717. buildTextContentItem(items[j]);
  52718. } else if (isNum(items[j])) {
  52719. ensureTextContentItem();
  52720. advance = items[j] * textState.fontSize / 1000;
  52721. var breakTextRun = false;
  52722. if (textState.font.vertical) {
  52723. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  52724. textState.translateTextMatrix(0, advance);
  52725. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52726. if (!breakTextRun) {
  52727. textContentItem.height += offset;
  52728. }
  52729. } else {
  52730. advance = -advance;
  52731. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  52732. textState.translateTextMatrix(advance, 0);
  52733. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52734. if (!breakTextRun) {
  52735. textContentItem.width += offset;
  52736. }
  52737. }
  52738. if (breakTextRun) {
  52739. flushTextContentItem();
  52740. } else if (advance > 0) {
  52741. addFakeSpaces(advance, textContentItem.str);
  52742. }
  52743. }
  52744. }
  52745. break;
  52746. case OPS.showText:
  52747. buildTextContentItem(args[0]);
  52748. break;
  52749. case OPS.nextLineShowText:
  52750. flushTextContentItem();
  52751. textState.carriageReturn();
  52752. buildTextContentItem(args[0]);
  52753. break;
  52754. case OPS.nextLineSetSpacingShowText:
  52755. flushTextContentItem();
  52756. textState.wordSpacing = args[0];
  52757. textState.charSpacing = args[1];
  52758. textState.carriageReturn();
  52759. buildTextContentItem(args[2]);
  52760. break;
  52761. case OPS.paintXObject:
  52762. flushTextContentItem();
  52763. if (args[0].code) {
  52764. break;
  52765. }
  52766. if (!xobjs) {
  52767. xobjs = resources.get('XObject') || Dict.empty;
  52768. }
  52769. var name = args[0].name;
  52770. if (xobjsCache.key === name) {
  52771. if (xobjsCache.texts) {
  52772. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52773. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52774. }
  52775. break;
  52776. }
  52777. var xobj = xobjs.get(name);
  52778. if (!xobj) {
  52779. break;
  52780. }
  52781. assert(isStream(xobj), 'XObject should be a stream');
  52782. var type = xobj.dict.get('Subtype');
  52783. assert(isName(type), 'XObject should have a Name subtype');
  52784. if ('Form' !== type.name) {
  52785. xobjsCache.key = name;
  52786. xobjsCache.texts = null;
  52787. break;
  52788. }
  52789. stateManager.save();
  52790. var matrix = xobj.dict.getArray('Matrix');
  52791. if (isArray(matrix) && matrix.length === 6) {
  52792. stateManager.transform(matrix);
  52793. }
  52794. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52795. Util.appendToArray(textContent.items, formTextContent.items);
  52796. Util.extendObj(textContent.styles, formTextContent.styles);
  52797. stateManager.restore();
  52798. xobjsCache.key = name;
  52799. xobjsCache.texts = formTextContent;
  52800. }));
  52801. return;
  52802. case OPS.setGState:
  52803. flushTextContentItem();
  52804. var dictName = args[0];
  52805. var extGState = resources.get('ExtGState');
  52806. if (!isDict(extGState) || !isName(dictName)) {
  52807. break;
  52808. }
  52809. var gState = extGState.get(dictName.name);
  52810. if (!isDict(gState)) {
  52811. break;
  52812. }
  52813. var gStateFont = gState.get('Font');
  52814. if (gStateFont) {
  52815. textState.fontName = null;
  52816. textState.fontSize = gStateFont[1];
  52817. next(handleSetFont(null, gStateFont[0]));
  52818. return;
  52819. }
  52820. break;
  52821. }
  52822. }
  52823. if (stop) {
  52824. next(deferred);
  52825. return;
  52826. }
  52827. flushTextContentItem();
  52828. resolve(textContent);
  52829. });
  52830. },
  52831. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52832. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52833. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52834. if (properties.composite) {
  52835. var cidSystemInfo = dict.get('CIDSystemInfo');
  52836. if (isDict(cidSystemInfo)) {
  52837. properties.cidSystemInfo = {
  52838. registry: cidSystemInfo.get('Registry'),
  52839. ordering: cidSystemInfo.get('Ordering'),
  52840. supplement: cidSystemInfo.get('Supplement')
  52841. };
  52842. }
  52843. var cidToGidMap = dict.get('CIDToGIDMap');
  52844. if (isStream(cidToGidMap)) {
  52845. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52846. }
  52847. }
  52848. var differences = [];
  52849. var baseEncodingName = null;
  52850. var encoding;
  52851. if (dict.has('Encoding')) {
  52852. encoding = dict.get('Encoding');
  52853. if (isDict(encoding)) {
  52854. baseEncodingName = encoding.get('BaseEncoding');
  52855. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  52856. if (encoding.has('Differences')) {
  52857. var diffEncoding = encoding.get('Differences');
  52858. var index = 0;
  52859. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  52860. var data = xref.fetchIfRef(diffEncoding[j]);
  52861. if (isNum(data)) {
  52862. index = data;
  52863. } else if (isName(data)) {
  52864. differences[index++] = data.name;
  52865. } else {
  52866. error('Invalid entry in \'Differences\' array: ' + data);
  52867. }
  52868. }
  52869. }
  52870. } else if (isName(encoding)) {
  52871. baseEncodingName = encoding.name;
  52872. } else {
  52873. error('Encoding is not a Name nor a Dict');
  52874. }
  52875. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  52876. baseEncodingName = null;
  52877. }
  52878. }
  52879. if (baseEncodingName) {
  52880. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  52881. } else {
  52882. encoding = properties.type === 'TrueType' ? WinAnsiEncoding : StandardEncoding;
  52883. if (!!(properties.flags & FontFlags.Symbolic)) {
  52884. encoding = MacRomanEncoding;
  52885. if (!properties.file) {
  52886. if (/Symbol/i.test(properties.name)) {
  52887. encoding = SymbolSetEncoding;
  52888. } else if (/Dingbats/i.test(properties.name)) {
  52889. encoding = ZapfDingbatsEncoding;
  52890. }
  52891. }
  52892. }
  52893. properties.defaultEncoding = encoding;
  52894. }
  52895. properties.differences = differences;
  52896. properties.baseEncodingName = baseEncodingName;
  52897. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  52898. properties.dict = dict;
  52899. return toUnicodePromise.then(function (toUnicode) {
  52900. properties.toUnicode = toUnicode;
  52901. return this.buildToUnicode(properties);
  52902. }.bind(this)).then(function (toUnicode) {
  52903. properties.toUnicode = toUnicode;
  52904. return properties;
  52905. });
  52906. },
  52907. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  52908. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  52909. if (properties.hasIncludedToUnicodeMap) {
  52910. return Promise.resolve(properties.toUnicode);
  52911. }
  52912. var toUnicode, charcode, glyphName;
  52913. if (!properties.composite)
  52914. {
  52915. toUnicode = [];
  52916. var encoding = properties.defaultEncoding.slice();
  52917. var baseEncodingName = properties.baseEncodingName;
  52918. var differences = properties.differences;
  52919. for (charcode in differences) {
  52920. glyphName = differences[charcode];
  52921. if (glyphName === '.notdef') {
  52922. continue;
  52923. }
  52924. encoding[charcode] = glyphName;
  52925. }
  52926. var glyphsUnicodeMap = getGlyphsUnicode();
  52927. for (charcode in encoding) {
  52928. glyphName = encoding[charcode];
  52929. if (glyphName === '') {
  52930. continue;
  52931. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  52932. var code = 0;
  52933. switch (glyphName[0]) {
  52934. case 'G':
  52935. if (glyphName.length === 3) {
  52936. code = parseInt(glyphName.substr(1), 16);
  52937. }
  52938. break;
  52939. case 'g':
  52940. if (glyphName.length === 5) {
  52941. code = parseInt(glyphName.substr(1), 16);
  52942. }
  52943. break;
  52944. case 'C':
  52945. case 'c':
  52946. if (glyphName.length >= 3) {
  52947. code = +glyphName.substr(1);
  52948. }
  52949. break;
  52950. default:
  52951. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  52952. if (unicode !== -1) {
  52953. code = unicode;
  52954. }
  52955. }
  52956. if (code) {
  52957. if (baseEncodingName && code === +charcode) {
  52958. var baseEncoding = getEncoding(baseEncodingName);
  52959. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  52960. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52961. continue;
  52962. }
  52963. }
  52964. toUnicode[charcode] = String.fromCharCode(code);
  52965. }
  52966. continue;
  52967. }
  52968. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52969. }
  52970. return Promise.resolve(new ToUnicodeMap(toUnicode));
  52971. }
  52972. 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'))) {
  52973. var registry = properties.cidSystemInfo.registry;
  52974. var ordering = properties.cidSystemInfo.ordering;
  52975. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  52976. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  52977. var cMap = properties.cMap;
  52978. toUnicode = [];
  52979. cMap.forEach(function (charcode, cid) {
  52980. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  52981. var ucs2 = ucs2CMap.lookup(cid);
  52982. if (ucs2) {
  52983. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  52984. }
  52985. });
  52986. return new ToUnicodeMap(toUnicode);
  52987. });
  52988. }
  52989. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  52990. },
  52991. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  52992. var cmapObj = toUnicode;
  52993. if (isName(cmapObj)) {
  52994. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  52995. if (cmap instanceof IdentityCMap) {
  52996. return new IdentityToUnicodeMap(0, 0xFFFF);
  52997. }
  52998. return new ToUnicodeMap(cmap.getMap());
  52999. });
  53000. } else if (isStream(cmapObj)) {
  53001. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53002. if (cmap instanceof IdentityCMap) {
  53003. return new IdentityToUnicodeMap(0, 0xFFFF);
  53004. }
  53005. var map = new Array(cmap.length);
  53006. cmap.forEach(function (charCode, token) {
  53007. var str = [];
  53008. for (var k = 0; k < token.length; k += 2) {
  53009. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53010. if ((w1 & 0xF800) !== 0xD800) {
  53011. str.push(w1);
  53012. continue;
  53013. }
  53014. k += 2;
  53015. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53016. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53017. }
  53018. map[charCode] = String.fromCharCode.apply(String, str);
  53019. });
  53020. return new ToUnicodeMap(map);
  53021. });
  53022. }
  53023. return Promise.resolve(null);
  53024. },
  53025. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53026. var glyphsData = cidToGidStream.getBytes();
  53027. var result = [];
  53028. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53029. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53030. if (glyphID === 0) {
  53031. continue;
  53032. }
  53033. var code = j >> 1;
  53034. result[code] = glyphID;
  53035. }
  53036. return result;
  53037. },
  53038. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53039. var glyphsWidths = [];
  53040. var defaultWidth = 0;
  53041. var glyphsVMetrics = [];
  53042. var defaultVMetrics;
  53043. var i, ii, j, jj, start, code, widths;
  53044. if (properties.composite) {
  53045. defaultWidth = dict.get('DW') || 1000;
  53046. widths = dict.get('W');
  53047. if (widths) {
  53048. for (i = 0, ii = widths.length; i < ii; i++) {
  53049. start = widths[i++];
  53050. code = xref.fetchIfRef(widths[i]);
  53051. if (isArray(code)) {
  53052. for (j = 0, jj = code.length; j < jj; j++) {
  53053. glyphsWidths[start++] = code[j];
  53054. }
  53055. } else {
  53056. var width = widths[++i];
  53057. for (j = start; j <= code; j++) {
  53058. glyphsWidths[j] = width;
  53059. }
  53060. }
  53061. }
  53062. }
  53063. if (properties.vertical) {
  53064. var vmetrics = dict.get('DW2') || [
  53065. 880,
  53066. -1000
  53067. ];
  53068. defaultVMetrics = [
  53069. vmetrics[1],
  53070. defaultWidth * 0.5,
  53071. vmetrics[0]
  53072. ];
  53073. vmetrics = dict.get('W2');
  53074. if (vmetrics) {
  53075. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53076. start = vmetrics[i++];
  53077. code = xref.fetchIfRef(vmetrics[i]);
  53078. if (isArray(code)) {
  53079. for (j = 0, jj = code.length; j < jj; j++) {
  53080. glyphsVMetrics[start++] = [
  53081. code[j++],
  53082. code[j++],
  53083. code[j]
  53084. ];
  53085. }
  53086. } else {
  53087. var vmetric = [
  53088. vmetrics[++i],
  53089. vmetrics[++i],
  53090. vmetrics[++i]
  53091. ];
  53092. for (j = start; j <= code; j++) {
  53093. glyphsVMetrics[j] = vmetric;
  53094. }
  53095. }
  53096. }
  53097. }
  53098. }
  53099. } else {
  53100. var firstChar = properties.firstChar;
  53101. widths = dict.get('Widths');
  53102. if (widths) {
  53103. j = firstChar;
  53104. for (i = 0, ii = widths.length; i < ii; i++) {
  53105. glyphsWidths[j++] = widths[i];
  53106. }
  53107. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53108. } else {
  53109. var baseFontName = dict.get('BaseFont');
  53110. if (isName(baseFontName)) {
  53111. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53112. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53113. defaultWidth = metrics.defaultWidth;
  53114. }
  53115. }
  53116. }
  53117. var isMonospace = true;
  53118. var firstWidth = defaultWidth;
  53119. for (var glyph in glyphsWidths) {
  53120. var glyphWidth = glyphsWidths[glyph];
  53121. if (!glyphWidth) {
  53122. continue;
  53123. }
  53124. if (!firstWidth) {
  53125. firstWidth = glyphWidth;
  53126. continue;
  53127. }
  53128. if (firstWidth !== glyphWidth) {
  53129. isMonospace = false;
  53130. break;
  53131. }
  53132. }
  53133. if (isMonospace) {
  53134. properties.flags |= FontFlags.FixedPitch;
  53135. }
  53136. properties.defaultWidth = defaultWidth;
  53137. properties.widths = glyphsWidths;
  53138. properties.defaultVMetrics = defaultVMetrics;
  53139. properties.vmetrics = glyphsVMetrics;
  53140. },
  53141. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53142. var fontNameWoStyle = baseFontName.split('-')[0];
  53143. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53144. },
  53145. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53146. var defaultWidth = 0;
  53147. var widths = [];
  53148. var monospace = false;
  53149. var stdFontMap = getStdFontMap();
  53150. var lookupName = stdFontMap[name] || name;
  53151. var Metrics = getMetrics();
  53152. if (!(lookupName in Metrics)) {
  53153. if (this.isSerifFont(name)) {
  53154. lookupName = 'Times-Roman';
  53155. } else {
  53156. lookupName = 'Helvetica';
  53157. }
  53158. }
  53159. var glyphWidths = Metrics[lookupName];
  53160. if (isNum(glyphWidths)) {
  53161. defaultWidth = glyphWidths;
  53162. monospace = true;
  53163. } else {
  53164. widths = glyphWidths();
  53165. }
  53166. return {
  53167. defaultWidth: defaultWidth,
  53168. monospace: monospace,
  53169. widths: widths
  53170. };
  53171. },
  53172. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53173. var widths = Object.create(null);
  53174. var differences = properties.differences;
  53175. var encoding = properties.defaultEncoding;
  53176. for (var charCode = 0; charCode < 256; charCode++) {
  53177. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53178. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53179. continue;
  53180. }
  53181. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53182. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53183. continue;
  53184. }
  53185. }
  53186. return widths;
  53187. },
  53188. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53189. var baseDict = dict;
  53190. var type = dict.get('Subtype');
  53191. assert(isName(type), 'invalid font Subtype');
  53192. var composite = false;
  53193. var uint8array;
  53194. if (type.name === 'Type0') {
  53195. var df = dict.get('DescendantFonts');
  53196. if (!df) {
  53197. error('Descendant fonts are not specified');
  53198. }
  53199. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53200. type = dict.get('Subtype');
  53201. assert(isName(type), 'invalid font Subtype');
  53202. composite = true;
  53203. }
  53204. var descriptor = dict.get('FontDescriptor');
  53205. if (descriptor) {
  53206. var hash = new MurmurHash3_64();
  53207. var encoding = baseDict.getRaw('Encoding');
  53208. if (isName(encoding)) {
  53209. hash.update(encoding.name);
  53210. } else if (isRef(encoding)) {
  53211. hash.update(encoding.toString());
  53212. } else if (isDict(encoding)) {
  53213. var keys = encoding.getKeys();
  53214. for (var i = 0, ii = keys.length; i < ii; i++) {
  53215. var entry = encoding.getRaw(keys[i]);
  53216. if (isName(entry)) {
  53217. hash.update(entry.name);
  53218. } else if (isRef(entry)) {
  53219. hash.update(entry.toString());
  53220. } else if (isArray(entry)) {
  53221. hash.update(entry.length.toString());
  53222. }
  53223. }
  53224. }
  53225. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53226. if (isStream(toUnicode)) {
  53227. var stream = toUnicode.str || toUnicode;
  53228. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53229. hash.update(uint8array);
  53230. } else if (isName(toUnicode)) {
  53231. hash.update(toUnicode.name);
  53232. }
  53233. var widths = dict.get('Widths') || baseDict.get('Widths');
  53234. if (widths) {
  53235. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53236. hash.update(uint8array);
  53237. }
  53238. }
  53239. return {
  53240. descriptor: descriptor,
  53241. dict: dict,
  53242. baseDict: baseDict,
  53243. composite: composite,
  53244. type: type.name,
  53245. hash: hash ? hash.hexdigest() : ''
  53246. };
  53247. },
  53248. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53249. var baseDict = preEvaluatedFont.baseDict;
  53250. var dict = preEvaluatedFont.dict;
  53251. var composite = preEvaluatedFont.composite;
  53252. var descriptor = preEvaluatedFont.descriptor;
  53253. var type = preEvaluatedFont.type;
  53254. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53255. var cMapOptions = this.options.cMapOptions;
  53256. var properties;
  53257. if (!descriptor) {
  53258. if (type === 'Type3') {
  53259. descriptor = new Dict(null);
  53260. descriptor.set('FontName', Name.get(type));
  53261. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53262. } else {
  53263. var baseFontName = dict.get('BaseFont');
  53264. if (!isName(baseFontName)) {
  53265. error('Base font is not specified');
  53266. }
  53267. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53268. var metrics = this.getBaseFontMetrics(baseFontName);
  53269. var fontNameWoStyle = baseFontName.split('-')[0];
  53270. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53271. properties = {
  53272. type: type,
  53273. name: baseFontName,
  53274. widths: metrics.widths,
  53275. defaultWidth: metrics.defaultWidth,
  53276. flags: flags,
  53277. firstChar: 0,
  53278. lastChar: maxCharIndex
  53279. };
  53280. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53281. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53282. return new Font(baseFontName, null, properties);
  53283. }.bind(this));
  53284. }
  53285. }
  53286. var firstChar = dict.get('FirstChar') || 0;
  53287. var lastChar = dict.get('LastChar') || maxCharIndex;
  53288. var fontName = descriptor.get('FontName');
  53289. var baseFont = dict.get('BaseFont');
  53290. if (isString(fontName)) {
  53291. fontName = Name.get(fontName);
  53292. }
  53293. if (isString(baseFont)) {
  53294. baseFont = Name.get(baseFont);
  53295. }
  53296. if (type !== 'Type3') {
  53297. var fontNameStr = fontName && fontName.name;
  53298. var baseFontStr = baseFont && baseFont.name;
  53299. if (fontNameStr !== baseFontStr) {
  53300. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53301. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53302. fontName = baseFont;
  53303. }
  53304. }
  53305. }
  53306. fontName = fontName || baseFont;
  53307. assert(isName(fontName), 'invalid font name');
  53308. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53309. if (fontFile) {
  53310. if (fontFile.dict) {
  53311. var subtype = fontFile.dict.get('Subtype');
  53312. if (subtype) {
  53313. subtype = subtype.name;
  53314. }
  53315. var length1 = fontFile.dict.get('Length1');
  53316. var length2 = fontFile.dict.get('Length2');
  53317. var length3 = fontFile.dict.get('Length3');
  53318. }
  53319. }
  53320. properties = {
  53321. type: type,
  53322. name: fontName.name,
  53323. subtype: subtype,
  53324. file: fontFile,
  53325. length1: length1,
  53326. length2: length2,
  53327. length3: length3,
  53328. loadedName: baseDict.loadedName,
  53329. composite: composite,
  53330. wideChars: composite,
  53331. fixedPitch: false,
  53332. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53333. firstChar: firstChar || 0,
  53334. lastChar: lastChar || maxCharIndex,
  53335. bbox: descriptor.getArray('FontBBox'),
  53336. ascent: descriptor.get('Ascent'),
  53337. descent: descriptor.get('Descent'),
  53338. xHeight: descriptor.get('XHeight'),
  53339. capHeight: descriptor.get('CapHeight'),
  53340. flags: descriptor.get('Flags'),
  53341. italicAngle: descriptor.get('ItalicAngle'),
  53342. coded: false
  53343. };
  53344. var cMapPromise;
  53345. if (composite) {
  53346. var cidEncoding = baseDict.get('Encoding');
  53347. if (isName(cidEncoding)) {
  53348. properties.cidEncoding = cidEncoding.name;
  53349. }
  53350. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53351. properties.cMap = cMap;
  53352. properties.vertical = properties.cMap.vertical;
  53353. });
  53354. } else {
  53355. cMapPromise = Promise.resolve(undefined);
  53356. }
  53357. return cMapPromise.then(function () {
  53358. return this.extractDataStructures(dict, baseDict, xref, properties);
  53359. }.bind(this)).then(function (properties) {
  53360. this.extractWidths(dict, xref, descriptor, properties);
  53361. if (type === 'Type3') {
  53362. properties.isType3Font = true;
  53363. }
  53364. return new Font(fontName.name, fontFile, properties);
  53365. }.bind(this));
  53366. }
  53367. };
  53368. return PartialEvaluator;
  53369. }();
  53370. var TranslatedFont = function TranslatedFontClosure() {
  53371. function TranslatedFont(loadedName, font, dict) {
  53372. this.loadedName = loadedName;
  53373. this.font = font;
  53374. this.dict = dict;
  53375. this.type3Loaded = null;
  53376. this.sent = false;
  53377. }
  53378. TranslatedFont.prototype = {
  53379. send: function (handler) {
  53380. if (this.sent) {
  53381. return;
  53382. }
  53383. var fontData = this.font.exportData();
  53384. handler.send('commonobj', [
  53385. this.loadedName,
  53386. 'Font',
  53387. fontData
  53388. ]);
  53389. this.sent = true;
  53390. },
  53391. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53392. assert(this.font.isType3Font);
  53393. if (this.type3Loaded) {
  53394. return this.type3Loaded;
  53395. }
  53396. var translatedFont = this.font;
  53397. var loadCharProcsPromise = Promise.resolve();
  53398. var charProcs = this.dict.get('CharProcs');
  53399. var fontResources = this.dict.get('Resources') || resources;
  53400. var charProcKeys = charProcs.getKeys();
  53401. var charProcOperatorList = Object.create(null);
  53402. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53403. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53404. var glyphStream = charProcs.get(key);
  53405. var operatorList = new OperatorList();
  53406. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53407. charProcOperatorList[key] = operatorList.getIR();
  53408. parentOperatorList.addDependencies(operatorList.dependencies);
  53409. }, function (reason) {
  53410. warn('Type3 font resource \"' + key + '\" is not available');
  53411. var operatorList = new OperatorList();
  53412. charProcOperatorList[key] = operatorList.getIR();
  53413. });
  53414. }.bind(this, charProcKeys[i]));
  53415. }
  53416. this.type3Loaded = loadCharProcsPromise.then(function () {
  53417. translatedFont.charProcOperatorList = charProcOperatorList;
  53418. });
  53419. return this.type3Loaded;
  53420. }
  53421. };
  53422. return TranslatedFont;
  53423. }();
  53424. var OperatorList = function OperatorListClosure() {
  53425. var CHUNK_SIZE = 1000;
  53426. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53427. function getTransfers(queue) {
  53428. var transfers = [];
  53429. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53430. for (var i = 0, ii = queue.length; i < ii; i++) {
  53431. switch (fnArray[i]) {
  53432. case OPS.paintInlineImageXObject:
  53433. case OPS.paintInlineImageXObjectGroup:
  53434. case OPS.paintImageMaskXObject:
  53435. var arg = argsArray[i][0];
  53436. if (!arg.cached) {
  53437. transfers.push(arg.data.buffer);
  53438. }
  53439. break;
  53440. }
  53441. }
  53442. return transfers;
  53443. }
  53444. function OperatorList(intent, messageHandler, pageIndex) {
  53445. this.messageHandler = messageHandler;
  53446. this.fnArray = [];
  53447. this.argsArray = [];
  53448. this.dependencies = Object.create(null);
  53449. this._totalLength = 0;
  53450. this.pageIndex = pageIndex;
  53451. this.intent = intent;
  53452. }
  53453. OperatorList.prototype = {
  53454. get length() {
  53455. return this.argsArray.length;
  53456. },
  53457. get totalLength() {
  53458. return this._totalLength + this.length;
  53459. },
  53460. addOp: function (fn, args) {
  53461. this.fnArray.push(fn);
  53462. this.argsArray.push(args);
  53463. if (this.messageHandler) {
  53464. if (this.fnArray.length >= CHUNK_SIZE) {
  53465. this.flush();
  53466. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53467. this.flush();
  53468. }
  53469. }
  53470. },
  53471. addDependency: function (dependency) {
  53472. if (dependency in this.dependencies) {
  53473. return;
  53474. }
  53475. this.dependencies[dependency] = true;
  53476. this.addOp(OPS.dependency, [dependency]);
  53477. },
  53478. addDependencies: function (dependencies) {
  53479. for (var key in dependencies) {
  53480. this.addDependency(key);
  53481. }
  53482. },
  53483. addOpList: function (opList) {
  53484. Util.extendObj(this.dependencies, opList.dependencies);
  53485. for (var i = 0, ii = opList.length; i < ii; i++) {
  53486. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53487. }
  53488. },
  53489. getIR: function () {
  53490. return {
  53491. fnArray: this.fnArray,
  53492. argsArray: this.argsArray,
  53493. length: this.length
  53494. };
  53495. },
  53496. flush: function (lastChunk) {
  53497. if (this.intent !== 'oplist') {
  53498. new QueueOptimizer().optimize(this);
  53499. }
  53500. var transfers = getTransfers(this);
  53501. var length = this.length;
  53502. this._totalLength += length;
  53503. this.messageHandler.send('RenderPageChunk', {
  53504. operatorList: {
  53505. fnArray: this.fnArray,
  53506. argsArray: this.argsArray,
  53507. lastChunk: lastChunk,
  53508. length: length
  53509. },
  53510. pageIndex: this.pageIndex,
  53511. intent: this.intent
  53512. }, transfers);
  53513. this.dependencies = Object.create(null);
  53514. this.fnArray.length = 0;
  53515. this.argsArray.length = 0;
  53516. }
  53517. };
  53518. return OperatorList;
  53519. }();
  53520. var StateManager = function StateManagerClosure() {
  53521. function StateManager(initialState) {
  53522. this.state = initialState;
  53523. this.stateStack = [];
  53524. }
  53525. StateManager.prototype = {
  53526. save: function () {
  53527. var old = this.state;
  53528. this.stateStack.push(this.state);
  53529. this.state = old.clone();
  53530. },
  53531. restore: function () {
  53532. var prev = this.stateStack.pop();
  53533. if (prev) {
  53534. this.state = prev;
  53535. }
  53536. },
  53537. transform: function (args) {
  53538. this.state.ctm = Util.transform(this.state.ctm, args);
  53539. }
  53540. };
  53541. return StateManager;
  53542. }();
  53543. var TextState = function TextStateClosure() {
  53544. function TextState() {
  53545. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53546. this.fontName = null;
  53547. this.fontSize = 0;
  53548. this.font = null;
  53549. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53550. this.textMatrix = IDENTITY_MATRIX.slice();
  53551. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53552. this.charSpacing = 0;
  53553. this.wordSpacing = 0;
  53554. this.leading = 0;
  53555. this.textHScale = 1;
  53556. this.textRise = 0;
  53557. }
  53558. TextState.prototype = {
  53559. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53560. var m = this.textMatrix;
  53561. m[0] = a;
  53562. m[1] = b;
  53563. m[2] = c;
  53564. m[3] = d;
  53565. m[4] = e;
  53566. m[5] = f;
  53567. },
  53568. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53569. var m = this.textLineMatrix;
  53570. m[0] = a;
  53571. m[1] = b;
  53572. m[2] = c;
  53573. m[3] = d;
  53574. m[4] = e;
  53575. m[5] = f;
  53576. },
  53577. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53578. var m = this.textMatrix;
  53579. m[4] = m[0] * x + m[2] * y + m[4];
  53580. m[5] = m[1] * x + m[3] * y + m[5];
  53581. },
  53582. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53583. var m = this.textLineMatrix;
  53584. m[4] = m[0] * x + m[2] * y + m[4];
  53585. m[5] = m[1] * x + m[3] * y + m[5];
  53586. },
  53587. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53588. var font = this.font;
  53589. if (!font) {
  53590. return null;
  53591. }
  53592. var m = this.textLineMatrix;
  53593. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53594. return null;
  53595. }
  53596. var txDiff = e - m[4], tyDiff = f - m[5];
  53597. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53598. return null;
  53599. }
  53600. var tx, ty, denominator = a * d - b * c;
  53601. if (font.vertical) {
  53602. tx = -tyDiff * c / denominator;
  53603. ty = tyDiff * a / denominator;
  53604. } else {
  53605. tx = txDiff * d / denominator;
  53606. ty = -txDiff * b / denominator;
  53607. }
  53608. return {
  53609. width: tx,
  53610. height: ty,
  53611. value: font.vertical ? ty : tx
  53612. };
  53613. },
  53614. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53615. var tsm = [
  53616. this.fontSize * this.textHScale,
  53617. 0,
  53618. 0,
  53619. this.fontSize,
  53620. 0,
  53621. this.textRise
  53622. ];
  53623. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53624. },
  53625. carriageReturn: function TextState_carriageReturn() {
  53626. this.translateTextLineMatrix(0, -this.leading);
  53627. this.textMatrix = this.textLineMatrix.slice();
  53628. },
  53629. clone: function TextState_clone() {
  53630. var clone = Object.create(this);
  53631. clone.textMatrix = this.textMatrix.slice();
  53632. clone.textLineMatrix = this.textLineMatrix.slice();
  53633. clone.fontMatrix = this.fontMatrix.slice();
  53634. return clone;
  53635. }
  53636. };
  53637. return TextState;
  53638. }();
  53639. var EvalState = function EvalStateClosure() {
  53640. function EvalState() {
  53641. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53642. this.font = null;
  53643. this.textRenderingMode = TextRenderingMode.FILL;
  53644. this.fillColorSpace = ColorSpace.singletons.gray;
  53645. this.strokeColorSpace = ColorSpace.singletons.gray;
  53646. }
  53647. EvalState.prototype = {
  53648. clone: function CanvasExtraState_clone() {
  53649. return Object.create(this);
  53650. }
  53651. };
  53652. return EvalState;
  53653. }();
  53654. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53655. var getOPMap = getLookupTableFactory(function (t) {
  53656. t['w'] = {
  53657. id: OPS.setLineWidth,
  53658. numArgs: 1,
  53659. variableArgs: false
  53660. };
  53661. t['J'] = {
  53662. id: OPS.setLineCap,
  53663. numArgs: 1,
  53664. variableArgs: false
  53665. };
  53666. t['j'] = {
  53667. id: OPS.setLineJoin,
  53668. numArgs: 1,
  53669. variableArgs: false
  53670. };
  53671. t['M'] = {
  53672. id: OPS.setMiterLimit,
  53673. numArgs: 1,
  53674. variableArgs: false
  53675. };
  53676. t['d'] = {
  53677. id: OPS.setDash,
  53678. numArgs: 2,
  53679. variableArgs: false
  53680. };
  53681. t['ri'] = {
  53682. id: OPS.setRenderingIntent,
  53683. numArgs: 1,
  53684. variableArgs: false
  53685. };
  53686. t['i'] = {
  53687. id: OPS.setFlatness,
  53688. numArgs: 1,
  53689. variableArgs: false
  53690. };
  53691. t['gs'] = {
  53692. id: OPS.setGState,
  53693. numArgs: 1,
  53694. variableArgs: false
  53695. };
  53696. t['q'] = {
  53697. id: OPS.save,
  53698. numArgs: 0,
  53699. variableArgs: false
  53700. };
  53701. t['Q'] = {
  53702. id: OPS.restore,
  53703. numArgs: 0,
  53704. variableArgs: false
  53705. };
  53706. t['cm'] = {
  53707. id: OPS.transform,
  53708. numArgs: 6,
  53709. variableArgs: false
  53710. };
  53711. t['m'] = {
  53712. id: OPS.moveTo,
  53713. numArgs: 2,
  53714. variableArgs: false
  53715. };
  53716. t['l'] = {
  53717. id: OPS.lineTo,
  53718. numArgs: 2,
  53719. variableArgs: false
  53720. };
  53721. t['c'] = {
  53722. id: OPS.curveTo,
  53723. numArgs: 6,
  53724. variableArgs: false
  53725. };
  53726. t['v'] = {
  53727. id: OPS.curveTo2,
  53728. numArgs: 4,
  53729. variableArgs: false
  53730. };
  53731. t['y'] = {
  53732. id: OPS.curveTo3,
  53733. numArgs: 4,
  53734. variableArgs: false
  53735. };
  53736. t['h'] = {
  53737. id: OPS.closePath,
  53738. numArgs: 0,
  53739. variableArgs: false
  53740. };
  53741. t['re'] = {
  53742. id: OPS.rectangle,
  53743. numArgs: 4,
  53744. variableArgs: false
  53745. };
  53746. t['S'] = {
  53747. id: OPS.stroke,
  53748. numArgs: 0,
  53749. variableArgs: false
  53750. };
  53751. t['s'] = {
  53752. id: OPS.closeStroke,
  53753. numArgs: 0,
  53754. variableArgs: false
  53755. };
  53756. t['f'] = {
  53757. id: OPS.fill,
  53758. numArgs: 0,
  53759. variableArgs: false
  53760. };
  53761. t['F'] = {
  53762. id: OPS.fill,
  53763. numArgs: 0,
  53764. variableArgs: false
  53765. };
  53766. t['f*'] = {
  53767. id: OPS.eoFill,
  53768. numArgs: 0,
  53769. variableArgs: false
  53770. };
  53771. t['B'] = {
  53772. id: OPS.fillStroke,
  53773. numArgs: 0,
  53774. variableArgs: false
  53775. };
  53776. t['B*'] = {
  53777. id: OPS.eoFillStroke,
  53778. numArgs: 0,
  53779. variableArgs: false
  53780. };
  53781. t['b'] = {
  53782. id: OPS.closeFillStroke,
  53783. numArgs: 0,
  53784. variableArgs: false
  53785. };
  53786. t['b*'] = {
  53787. id: OPS.closeEOFillStroke,
  53788. numArgs: 0,
  53789. variableArgs: false
  53790. };
  53791. t['n'] = {
  53792. id: OPS.endPath,
  53793. numArgs: 0,
  53794. variableArgs: false
  53795. };
  53796. t['W'] = {
  53797. id: OPS.clip,
  53798. numArgs: 0,
  53799. variableArgs: false
  53800. };
  53801. t['W*'] = {
  53802. id: OPS.eoClip,
  53803. numArgs: 0,
  53804. variableArgs: false
  53805. };
  53806. t['BT'] = {
  53807. id: OPS.beginText,
  53808. numArgs: 0,
  53809. variableArgs: false
  53810. };
  53811. t['ET'] = {
  53812. id: OPS.endText,
  53813. numArgs: 0,
  53814. variableArgs: false
  53815. };
  53816. t['Tc'] = {
  53817. id: OPS.setCharSpacing,
  53818. numArgs: 1,
  53819. variableArgs: false
  53820. };
  53821. t['Tw'] = {
  53822. id: OPS.setWordSpacing,
  53823. numArgs: 1,
  53824. variableArgs: false
  53825. };
  53826. t['Tz'] = {
  53827. id: OPS.setHScale,
  53828. numArgs: 1,
  53829. variableArgs: false
  53830. };
  53831. t['TL'] = {
  53832. id: OPS.setLeading,
  53833. numArgs: 1,
  53834. variableArgs: false
  53835. };
  53836. t['Tf'] = {
  53837. id: OPS.setFont,
  53838. numArgs: 2,
  53839. variableArgs: false
  53840. };
  53841. t['Tr'] = {
  53842. id: OPS.setTextRenderingMode,
  53843. numArgs: 1,
  53844. variableArgs: false
  53845. };
  53846. t['Ts'] = {
  53847. id: OPS.setTextRise,
  53848. numArgs: 1,
  53849. variableArgs: false
  53850. };
  53851. t['Td'] = {
  53852. id: OPS.moveText,
  53853. numArgs: 2,
  53854. variableArgs: false
  53855. };
  53856. t['TD'] = {
  53857. id: OPS.setLeadingMoveText,
  53858. numArgs: 2,
  53859. variableArgs: false
  53860. };
  53861. t['Tm'] = {
  53862. id: OPS.setTextMatrix,
  53863. numArgs: 6,
  53864. variableArgs: false
  53865. };
  53866. t['T*'] = {
  53867. id: OPS.nextLine,
  53868. numArgs: 0,
  53869. variableArgs: false
  53870. };
  53871. t['Tj'] = {
  53872. id: OPS.showText,
  53873. numArgs: 1,
  53874. variableArgs: false
  53875. };
  53876. t['TJ'] = {
  53877. id: OPS.showSpacedText,
  53878. numArgs: 1,
  53879. variableArgs: false
  53880. };
  53881. t['\''] = {
  53882. id: OPS.nextLineShowText,
  53883. numArgs: 1,
  53884. variableArgs: false
  53885. };
  53886. t['"'] = {
  53887. id: OPS.nextLineSetSpacingShowText,
  53888. numArgs: 3,
  53889. variableArgs: false
  53890. };
  53891. t['d0'] = {
  53892. id: OPS.setCharWidth,
  53893. numArgs: 2,
  53894. variableArgs: false
  53895. };
  53896. t['d1'] = {
  53897. id: OPS.setCharWidthAndBounds,
  53898. numArgs: 6,
  53899. variableArgs: false
  53900. };
  53901. t['CS'] = {
  53902. id: OPS.setStrokeColorSpace,
  53903. numArgs: 1,
  53904. variableArgs: false
  53905. };
  53906. t['cs'] = {
  53907. id: OPS.setFillColorSpace,
  53908. numArgs: 1,
  53909. variableArgs: false
  53910. };
  53911. t['SC'] = {
  53912. id: OPS.setStrokeColor,
  53913. numArgs: 4,
  53914. variableArgs: true
  53915. };
  53916. t['SCN'] = {
  53917. id: OPS.setStrokeColorN,
  53918. numArgs: 33,
  53919. variableArgs: true
  53920. };
  53921. t['sc'] = {
  53922. id: OPS.setFillColor,
  53923. numArgs: 4,
  53924. variableArgs: true
  53925. };
  53926. t['scn'] = {
  53927. id: OPS.setFillColorN,
  53928. numArgs: 33,
  53929. variableArgs: true
  53930. };
  53931. t['G'] = {
  53932. id: OPS.setStrokeGray,
  53933. numArgs: 1,
  53934. variableArgs: false
  53935. };
  53936. t['g'] = {
  53937. id: OPS.setFillGray,
  53938. numArgs: 1,
  53939. variableArgs: false
  53940. };
  53941. t['RG'] = {
  53942. id: OPS.setStrokeRGBColor,
  53943. numArgs: 3,
  53944. variableArgs: false
  53945. };
  53946. t['rg'] = {
  53947. id: OPS.setFillRGBColor,
  53948. numArgs: 3,
  53949. variableArgs: false
  53950. };
  53951. t['K'] = {
  53952. id: OPS.setStrokeCMYKColor,
  53953. numArgs: 4,
  53954. variableArgs: false
  53955. };
  53956. t['k'] = {
  53957. id: OPS.setFillCMYKColor,
  53958. numArgs: 4,
  53959. variableArgs: false
  53960. };
  53961. t['sh'] = {
  53962. id: OPS.shadingFill,
  53963. numArgs: 1,
  53964. variableArgs: false
  53965. };
  53966. t['BI'] = {
  53967. id: OPS.beginInlineImage,
  53968. numArgs: 0,
  53969. variableArgs: false
  53970. };
  53971. t['ID'] = {
  53972. id: OPS.beginImageData,
  53973. numArgs: 0,
  53974. variableArgs: false
  53975. };
  53976. t['EI'] = {
  53977. id: OPS.endInlineImage,
  53978. numArgs: 1,
  53979. variableArgs: false
  53980. };
  53981. t['Do'] = {
  53982. id: OPS.paintXObject,
  53983. numArgs: 1,
  53984. variableArgs: false
  53985. };
  53986. t['MP'] = {
  53987. id: OPS.markPoint,
  53988. numArgs: 1,
  53989. variableArgs: false
  53990. };
  53991. t['DP'] = {
  53992. id: OPS.markPointProps,
  53993. numArgs: 2,
  53994. variableArgs: false
  53995. };
  53996. t['BMC'] = {
  53997. id: OPS.beginMarkedContent,
  53998. numArgs: 1,
  53999. variableArgs: false
  54000. };
  54001. t['BDC'] = {
  54002. id: OPS.beginMarkedContentProps,
  54003. numArgs: 2,
  54004. variableArgs: false
  54005. };
  54006. t['EMC'] = {
  54007. id: OPS.endMarkedContent,
  54008. numArgs: 0,
  54009. variableArgs: false
  54010. };
  54011. t['BX'] = {
  54012. id: OPS.beginCompat,
  54013. numArgs: 0,
  54014. variableArgs: false
  54015. };
  54016. t['EX'] = {
  54017. id: OPS.endCompat,
  54018. numArgs: 0,
  54019. variableArgs: false
  54020. };
  54021. t['BM'] = null;
  54022. t['BD'] = null;
  54023. t['true'] = null;
  54024. t['fa'] = null;
  54025. t['fal'] = null;
  54026. t['fals'] = null;
  54027. t['false'] = null;
  54028. t['nu'] = null;
  54029. t['nul'] = null;
  54030. t['null'] = null;
  54031. });
  54032. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54033. this.opMap = getOPMap();
  54034. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54035. this.stateManager = stateManager;
  54036. this.nonProcessedArgs = [];
  54037. }
  54038. EvaluatorPreprocessor.prototype = {
  54039. get savedStatesDepth() {
  54040. return this.stateManager.stateStack.length;
  54041. },
  54042. read: function EvaluatorPreprocessor_read(operation) {
  54043. var args = operation.args;
  54044. while (true) {
  54045. var obj = this.parser.getObj();
  54046. if (isCmd(obj)) {
  54047. var cmd = obj.cmd;
  54048. var opSpec = this.opMap[cmd];
  54049. if (!opSpec) {
  54050. warn('Unknown command "' + cmd + '"');
  54051. continue;
  54052. }
  54053. var fn = opSpec.id;
  54054. var numArgs = opSpec.numArgs;
  54055. var argsLength = args !== null ? args.length : 0;
  54056. if (!opSpec.variableArgs) {
  54057. if (argsLength !== numArgs) {
  54058. var nonProcessedArgs = this.nonProcessedArgs;
  54059. while (argsLength > numArgs) {
  54060. nonProcessedArgs.push(args.shift());
  54061. argsLength--;
  54062. }
  54063. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54064. if (args === null) {
  54065. args = [];
  54066. }
  54067. args.unshift(nonProcessedArgs.pop());
  54068. argsLength++;
  54069. }
  54070. }
  54071. if (argsLength < numArgs) {
  54072. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54073. if (args !== null) {
  54074. args.length = 0;
  54075. }
  54076. continue;
  54077. }
  54078. } else if (argsLength > numArgs) {
  54079. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54080. }
  54081. this.preprocessCommand(fn, args);
  54082. operation.fn = fn;
  54083. operation.args = args;
  54084. return true;
  54085. } else {
  54086. if (isEOF(obj)) {
  54087. return false;
  54088. }
  54089. if (obj !== null) {
  54090. if (args === null) {
  54091. args = [];
  54092. }
  54093. args.push(obj);
  54094. assert(args.length <= 33, 'Too many arguments');
  54095. }
  54096. }
  54097. }
  54098. },
  54099. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54100. switch (fn | 0) {
  54101. case OPS.save:
  54102. this.stateManager.save();
  54103. break;
  54104. case OPS.restore:
  54105. this.stateManager.restore();
  54106. break;
  54107. case OPS.transform:
  54108. this.stateManager.transform(args);
  54109. break;
  54110. }
  54111. }
  54112. };
  54113. return EvaluatorPreprocessor;
  54114. }();
  54115. var QueueOptimizer = function QueueOptimizerClosure() {
  54116. function addState(parentState, pattern, fn) {
  54117. var state = parentState;
  54118. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54119. var item = pattern[i];
  54120. state = state[item] || (state[item] = []);
  54121. }
  54122. state[pattern[pattern.length - 1]] = fn;
  54123. }
  54124. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54125. var iFirstPIMXO = iFirstSave + 2;
  54126. for (var i = 0; i < count; i++) {
  54127. var arg = argsArray[iFirstPIMXO + 4 * i];
  54128. var imageMask = arg.length === 1 && arg[0];
  54129. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54130. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54131. continue;
  54132. }
  54133. break;
  54134. }
  54135. return count - i;
  54136. }
  54137. var InitialState = [];
  54138. addState(InitialState, [
  54139. OPS.save,
  54140. OPS.transform,
  54141. OPS.paintInlineImageXObject,
  54142. OPS.restore
  54143. ], function foundInlineImageGroup(context) {
  54144. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54145. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54146. var MAX_WIDTH = 1000;
  54147. var IMAGE_PADDING = 1;
  54148. var fnArray = context.fnArray, argsArray = context.argsArray;
  54149. var curr = context.iCurr;
  54150. var iFirstSave = curr - 3;
  54151. var iFirstTransform = curr - 2;
  54152. var iFirstPIIXO = curr - 1;
  54153. var i = iFirstSave + 4;
  54154. var ii = fnArray.length;
  54155. while (i + 3 < ii) {
  54156. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54157. break;
  54158. }
  54159. i += 4;
  54160. }
  54161. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54162. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54163. return i;
  54164. }
  54165. var maxX = 0;
  54166. var map = [], maxLineHeight = 0;
  54167. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54168. var q;
  54169. for (q = 0; q < count; q++) {
  54170. var transform = argsArray[iFirstTransform + (q << 2)];
  54171. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54172. if (currentX + img.width > MAX_WIDTH) {
  54173. maxX = Math.max(maxX, currentX);
  54174. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54175. currentX = 0;
  54176. maxLineHeight = 0;
  54177. }
  54178. map.push({
  54179. transform: transform,
  54180. x: currentX,
  54181. y: currentY,
  54182. w: img.width,
  54183. h: img.height
  54184. });
  54185. currentX += img.width + 2 * IMAGE_PADDING;
  54186. maxLineHeight = Math.max(maxLineHeight, img.height);
  54187. }
  54188. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54189. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54190. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54191. var imgRowSize = imgWidth << 2;
  54192. for (q = 0; q < count; q++) {
  54193. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54194. var rowSize = map[q].w << 2;
  54195. var dataOffset = 0;
  54196. var offset = map[q].x + map[q].y * imgWidth << 2;
  54197. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54198. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54199. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54200. dataOffset += rowSize;
  54201. offset += imgRowSize;
  54202. }
  54203. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54204. while (offset >= 0) {
  54205. data[offset - 4] = data[offset];
  54206. data[offset - 3] = data[offset + 1];
  54207. data[offset - 2] = data[offset + 2];
  54208. data[offset - 1] = data[offset + 3];
  54209. data[offset + rowSize] = data[offset + rowSize - 4];
  54210. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54211. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54212. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54213. offset -= imgRowSize;
  54214. }
  54215. }
  54216. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54217. argsArray.splice(iFirstSave, count * 4, [
  54218. {
  54219. width: imgWidth,
  54220. height: imgHeight,
  54221. kind: ImageKind.RGBA_32BPP,
  54222. data: imgData
  54223. },
  54224. map
  54225. ]);
  54226. return iFirstSave + 1;
  54227. });
  54228. addState(InitialState, [
  54229. OPS.save,
  54230. OPS.transform,
  54231. OPS.paintImageMaskXObject,
  54232. OPS.restore
  54233. ], function foundImageMaskGroup(context) {
  54234. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54235. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54236. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54237. var fnArray = context.fnArray, argsArray = context.argsArray;
  54238. var curr = context.iCurr;
  54239. var iFirstSave = curr - 3;
  54240. var iFirstTransform = curr - 2;
  54241. var iFirstPIMXO = curr - 1;
  54242. var i = iFirstSave + 4;
  54243. var ii = fnArray.length;
  54244. while (i + 3 < ii) {
  54245. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54246. break;
  54247. }
  54248. i += 4;
  54249. }
  54250. var count = (i - iFirstSave) / 4;
  54251. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54252. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54253. return i;
  54254. }
  54255. var q;
  54256. var isSameImage = false;
  54257. var iTransform, transformArgs;
  54258. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54259. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54260. isSameImage = true;
  54261. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54262. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54263. iTransform = iFirstTransform + 4;
  54264. var iPIMXO = iFirstPIMXO + 4;
  54265. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54266. transformArgs = argsArray[iTransform];
  54267. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54268. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54269. isSameImage = false;
  54270. } else {
  54271. count = q;
  54272. }
  54273. break;
  54274. }
  54275. }
  54276. }
  54277. if (isSameImage) {
  54278. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54279. var positions = new Float32Array(count * 2);
  54280. iTransform = iFirstTransform;
  54281. for (q = 0; q < count; q++, iTransform += 4) {
  54282. transformArgs = argsArray[iTransform];
  54283. positions[q << 1] = transformArgs[4];
  54284. positions[(q << 1) + 1] = transformArgs[5];
  54285. }
  54286. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54287. argsArray.splice(iFirstSave, count * 4, [
  54288. firstPIMXOArg0,
  54289. firstTransformArg0,
  54290. firstTransformArg3,
  54291. positions
  54292. ]);
  54293. } else {
  54294. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54295. var images = [];
  54296. for (q = 0; q < count; q++) {
  54297. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54298. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54299. images.push({
  54300. data: maskParams.data,
  54301. width: maskParams.width,
  54302. height: maskParams.height,
  54303. transform: transformArgs
  54304. });
  54305. }
  54306. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54307. argsArray.splice(iFirstSave, count * 4, [images]);
  54308. }
  54309. return iFirstSave + 1;
  54310. });
  54311. addState(InitialState, [
  54312. OPS.save,
  54313. OPS.transform,
  54314. OPS.paintImageXObject,
  54315. OPS.restore
  54316. ], function (context) {
  54317. var MIN_IMAGES_IN_BLOCK = 3;
  54318. var MAX_IMAGES_IN_BLOCK = 1000;
  54319. var fnArray = context.fnArray, argsArray = context.argsArray;
  54320. var curr = context.iCurr;
  54321. var iFirstSave = curr - 3;
  54322. var iFirstTransform = curr - 2;
  54323. var iFirstPIXO = curr - 1;
  54324. var iFirstRestore = curr;
  54325. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54326. return iFirstRestore + 1;
  54327. }
  54328. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54329. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54330. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54331. var i = iFirstSave + 4;
  54332. var ii = fnArray.length;
  54333. while (i + 3 < ii) {
  54334. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54335. break;
  54336. }
  54337. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54338. break;
  54339. }
  54340. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54341. break;
  54342. }
  54343. i += 4;
  54344. }
  54345. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54346. if (count < MIN_IMAGES_IN_BLOCK) {
  54347. return i;
  54348. }
  54349. var positions = new Float32Array(count * 2);
  54350. var iTransform = iFirstTransform;
  54351. for (var q = 0; q < count; q++, iTransform += 4) {
  54352. var transformArgs = argsArray[iTransform];
  54353. positions[q << 1] = transformArgs[4];
  54354. positions[(q << 1) + 1] = transformArgs[5];
  54355. }
  54356. var args = [
  54357. firstPIXOArg0,
  54358. firstTransformArg0,
  54359. firstTransformArg3,
  54360. positions
  54361. ];
  54362. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54363. argsArray.splice(iFirstSave, count * 4, args);
  54364. return iFirstSave + 1;
  54365. });
  54366. addState(InitialState, [
  54367. OPS.beginText,
  54368. OPS.setFont,
  54369. OPS.setTextMatrix,
  54370. OPS.showText,
  54371. OPS.endText
  54372. ], function (context) {
  54373. var MIN_CHARS_IN_BLOCK = 3;
  54374. var MAX_CHARS_IN_BLOCK = 1000;
  54375. var fnArray = context.fnArray, argsArray = context.argsArray;
  54376. var curr = context.iCurr;
  54377. var iFirstBeginText = curr - 4;
  54378. var iFirstSetFont = curr - 3;
  54379. var iFirstSetTextMatrix = curr - 2;
  54380. var iFirstShowText = curr - 1;
  54381. var iFirstEndText = curr;
  54382. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54383. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54384. var i = iFirstBeginText + 5;
  54385. var ii = fnArray.length;
  54386. while (i + 4 < ii) {
  54387. 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) {
  54388. break;
  54389. }
  54390. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54391. break;
  54392. }
  54393. i += 5;
  54394. }
  54395. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54396. if (count < MIN_CHARS_IN_BLOCK) {
  54397. return i;
  54398. }
  54399. var iFirst = iFirstBeginText;
  54400. 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) {
  54401. count++;
  54402. iFirst -= 5;
  54403. }
  54404. var iEndText = iFirst + 4;
  54405. for (var q = 1; q < count; q++) {
  54406. fnArray.splice(iEndText, 3);
  54407. argsArray.splice(iEndText, 3);
  54408. iEndText += 2;
  54409. }
  54410. return iEndText + 1;
  54411. });
  54412. function QueueOptimizer() {
  54413. }
  54414. QueueOptimizer.prototype = {
  54415. optimize: function QueueOptimizer_optimize(queue) {
  54416. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54417. var context = {
  54418. iCurr: 0,
  54419. fnArray: fnArray,
  54420. argsArray: argsArray
  54421. };
  54422. var state;
  54423. var i = 0, ii = fnArray.length;
  54424. while (i < ii) {
  54425. state = (state || InitialState)[fnArray[i]];
  54426. if (typeof state === 'function') {
  54427. context.iCurr = i;
  54428. i = state(context);
  54429. state = undefined;
  54430. ii = context.fnArray.length;
  54431. } else {
  54432. i++;
  54433. }
  54434. }
  54435. }
  54436. };
  54437. return QueueOptimizer;
  54438. }();
  54439. exports.OperatorList = OperatorList;
  54440. exports.PartialEvaluator = PartialEvaluator;
  54441. }));
  54442. (function (root, factory) {
  54443. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54444. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54445. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54446. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54447. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54448. var AnnotationType = sharedUtil.AnnotationType;
  54449. var OPS = sharedUtil.OPS;
  54450. var Util = sharedUtil.Util;
  54451. var isString = sharedUtil.isString;
  54452. var isArray = sharedUtil.isArray;
  54453. var isInt = sharedUtil.isInt;
  54454. var stringToBytes = sharedUtil.stringToBytes;
  54455. var stringToPDFString = sharedUtil.stringToPDFString;
  54456. var warn = sharedUtil.warn;
  54457. var Dict = corePrimitives.Dict;
  54458. var isDict = corePrimitives.isDict;
  54459. var isName = corePrimitives.isName;
  54460. var isRef = corePrimitives.isRef;
  54461. var Stream = coreStream.Stream;
  54462. var ColorSpace = coreColorSpace.ColorSpace;
  54463. var Catalog = coreObj.Catalog;
  54464. var ObjectLoader = coreObj.ObjectLoader;
  54465. var FileSpec = coreObj.FileSpec;
  54466. var OperatorList = coreEvaluator.OperatorList;
  54467. function AnnotationFactory() {
  54468. }
  54469. AnnotationFactory.prototype = {
  54470. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  54471. var dict = xref.fetchIfRef(ref);
  54472. if (!isDict(dict)) {
  54473. return;
  54474. }
  54475. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  54476. var subtype = dict.get('Subtype');
  54477. subtype = isName(subtype) ? subtype.name : null;
  54478. var parameters = {
  54479. xref: xref,
  54480. dict: dict,
  54481. ref: isRef(ref) ? ref : null,
  54482. subtype: subtype,
  54483. id: id,
  54484. pdfManager: pdfManager
  54485. };
  54486. switch (subtype) {
  54487. case 'Link':
  54488. return new LinkAnnotation(parameters);
  54489. case 'Text':
  54490. return new TextAnnotation(parameters);
  54491. case 'Widget':
  54492. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54493. fieldType = isName(fieldType) ? fieldType.name : null;
  54494. switch (fieldType) {
  54495. case 'Tx':
  54496. return new TextWidgetAnnotation(parameters);
  54497. case 'Ch':
  54498. return new ChoiceWidgetAnnotation(parameters);
  54499. }
  54500. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54501. return new WidgetAnnotation(parameters);
  54502. case 'Popup':
  54503. return new PopupAnnotation(parameters);
  54504. case 'Highlight':
  54505. return new HighlightAnnotation(parameters);
  54506. case 'Underline':
  54507. return new UnderlineAnnotation(parameters);
  54508. case 'Squiggly':
  54509. return new SquigglyAnnotation(parameters);
  54510. case 'StrikeOut':
  54511. return new StrikeOutAnnotation(parameters);
  54512. case 'FileAttachment':
  54513. return new FileAttachmentAnnotation(parameters);
  54514. default:
  54515. if (!subtype) {
  54516. warn('Annotation is missing the required /Subtype.');
  54517. } else {
  54518. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54519. }
  54520. return new Annotation(parameters);
  54521. }
  54522. }
  54523. };
  54524. var Annotation = function AnnotationClosure() {
  54525. function getTransformMatrix(rect, bbox, matrix) {
  54526. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54527. var minX = bounds[0];
  54528. var minY = bounds[1];
  54529. var maxX = bounds[2];
  54530. var maxY = bounds[3];
  54531. if (minX === maxX || minY === maxY) {
  54532. return [
  54533. 1,
  54534. 0,
  54535. 0,
  54536. 1,
  54537. rect[0],
  54538. rect[1]
  54539. ];
  54540. }
  54541. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54542. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54543. return [
  54544. xRatio,
  54545. 0,
  54546. 0,
  54547. yRatio,
  54548. rect[0] - minX * xRatio,
  54549. rect[1] - minY * yRatio
  54550. ];
  54551. }
  54552. function getDefaultAppearance(dict) {
  54553. var appearanceState = dict.get('AP');
  54554. if (!isDict(appearanceState)) {
  54555. return;
  54556. }
  54557. var appearance;
  54558. var appearances = appearanceState.get('N');
  54559. if (isDict(appearances)) {
  54560. var as = dict.get('AS');
  54561. if (as && appearances.has(as.name)) {
  54562. appearance = appearances.get(as.name);
  54563. }
  54564. } else {
  54565. appearance = appearances;
  54566. }
  54567. return appearance;
  54568. }
  54569. function Annotation(params) {
  54570. var dict = params.dict;
  54571. this.setFlags(dict.get('F'));
  54572. this.setRectangle(dict.getArray('Rect'));
  54573. this.setColor(dict.getArray('C'));
  54574. this.setBorderStyle(dict);
  54575. this.appearance = getDefaultAppearance(dict);
  54576. this.data = {};
  54577. this.data.id = params.id;
  54578. this.data.subtype = params.subtype;
  54579. this.data.annotationFlags = this.flags;
  54580. this.data.rect = this.rectangle;
  54581. this.data.color = this.color;
  54582. this.data.borderStyle = this.borderStyle;
  54583. this.data.hasAppearance = !!this.appearance;
  54584. }
  54585. Annotation.prototype = {
  54586. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54587. return !!(flags & flag);
  54588. },
  54589. _isViewable: function Annotation_isViewable(flags) {
  54590. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54591. },
  54592. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54593. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54594. },
  54595. get viewable() {
  54596. if (this.flags === 0) {
  54597. return true;
  54598. }
  54599. return this._isViewable(this.flags);
  54600. },
  54601. get printable() {
  54602. if (this.flags === 0) {
  54603. return false;
  54604. }
  54605. return this._isPrintable(this.flags);
  54606. },
  54607. setFlags: function Annotation_setFlags(flags) {
  54608. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54609. },
  54610. hasFlag: function Annotation_hasFlag(flag) {
  54611. return this._hasFlag(this.flags, flag);
  54612. },
  54613. setRectangle: function Annotation_setRectangle(rectangle) {
  54614. if (isArray(rectangle) && rectangle.length === 4) {
  54615. this.rectangle = Util.normalizeRect(rectangle);
  54616. } else {
  54617. this.rectangle = [
  54618. 0,
  54619. 0,
  54620. 0,
  54621. 0
  54622. ];
  54623. }
  54624. },
  54625. setColor: function Annotation_setColor(color) {
  54626. var rgbColor = new Uint8Array(3);
  54627. if (!isArray(color)) {
  54628. this.color = rgbColor;
  54629. return;
  54630. }
  54631. switch (color.length) {
  54632. case 0:
  54633. this.color = null;
  54634. break;
  54635. case 1:
  54636. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54637. this.color = rgbColor;
  54638. break;
  54639. case 3:
  54640. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54641. this.color = rgbColor;
  54642. break;
  54643. case 4:
  54644. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54645. this.color = rgbColor;
  54646. break;
  54647. default:
  54648. this.color = rgbColor;
  54649. break;
  54650. }
  54651. },
  54652. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54653. this.borderStyle = new AnnotationBorderStyle();
  54654. if (!isDict(borderStyle)) {
  54655. return;
  54656. }
  54657. if (borderStyle.has('BS')) {
  54658. var dict = borderStyle.get('BS');
  54659. var dictType = dict.get('Type');
  54660. if (!dictType || isName(dictType, 'Border')) {
  54661. this.borderStyle.setWidth(dict.get('W'));
  54662. this.borderStyle.setStyle(dict.get('S'));
  54663. this.borderStyle.setDashArray(dict.getArray('D'));
  54664. }
  54665. } else if (borderStyle.has('Border')) {
  54666. var array = borderStyle.getArray('Border');
  54667. if (isArray(array) && array.length >= 3) {
  54668. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54669. this.borderStyle.setVerticalCornerRadius(array[1]);
  54670. this.borderStyle.setWidth(array[2]);
  54671. if (array.length === 4) {
  54672. this.borderStyle.setDashArray(array[3]);
  54673. }
  54674. }
  54675. } else {
  54676. this.borderStyle.setWidth(0);
  54677. }
  54678. },
  54679. _preparePopup: function Annotation_preparePopup(dict) {
  54680. if (!dict.has('C')) {
  54681. this.data.color = null;
  54682. }
  54683. this.data.hasPopup = dict.has('Popup');
  54684. this.data.title = stringToPDFString(dict.get('T') || '');
  54685. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54686. },
  54687. loadResources: function Annotation_loadResources(keys) {
  54688. return new Promise(function (resolve, reject) {
  54689. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54690. if (!resources) {
  54691. resolve();
  54692. return;
  54693. }
  54694. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54695. objectLoader.load().then(function () {
  54696. resolve(resources);
  54697. }, reject);
  54698. }, reject);
  54699. }.bind(this));
  54700. },
  54701. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54702. if (!this.appearance) {
  54703. return Promise.resolve(new OperatorList());
  54704. }
  54705. var data = this.data;
  54706. var appearanceDict = this.appearance.dict;
  54707. var resourcesPromise = this.loadResources([
  54708. 'ExtGState',
  54709. 'ColorSpace',
  54710. 'Pattern',
  54711. 'Shading',
  54712. 'XObject',
  54713. 'Font'
  54714. ]);
  54715. var bbox = appearanceDict.getArray('BBox') || [
  54716. 0,
  54717. 0,
  54718. 1,
  54719. 1
  54720. ];
  54721. var matrix = appearanceDict.getArray('Matrix') || [
  54722. 1,
  54723. 0,
  54724. 0,
  54725. 1,
  54726. 0,
  54727. 0
  54728. ];
  54729. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54730. var self = this;
  54731. return resourcesPromise.then(function (resources) {
  54732. var opList = new OperatorList();
  54733. opList.addOp(OPS.beginAnnotation, [
  54734. data.rect,
  54735. transform,
  54736. matrix
  54737. ]);
  54738. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54739. opList.addOp(OPS.endAnnotation, []);
  54740. self.appearance.reset();
  54741. return opList;
  54742. });
  54743. });
  54744. }
  54745. };
  54746. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54747. var annotationPromises = [];
  54748. for (var i = 0, n = annotations.length; i < n; ++i) {
  54749. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54750. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54751. }
  54752. }
  54753. return Promise.all(annotationPromises).then(function (operatorLists) {
  54754. opList.addOp(OPS.beginAnnotations, []);
  54755. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54756. opList.addOpList(operatorLists[i]);
  54757. }
  54758. opList.addOp(OPS.endAnnotations, []);
  54759. });
  54760. };
  54761. return Annotation;
  54762. }();
  54763. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54764. function AnnotationBorderStyle() {
  54765. this.width = 1;
  54766. this.style = AnnotationBorderStyleType.SOLID;
  54767. this.dashArray = [3];
  54768. this.horizontalCornerRadius = 0;
  54769. this.verticalCornerRadius = 0;
  54770. }
  54771. AnnotationBorderStyle.prototype = {
  54772. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54773. if (width === (width | 0)) {
  54774. this.width = width;
  54775. }
  54776. },
  54777. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54778. if (!style) {
  54779. return;
  54780. }
  54781. switch (style.name) {
  54782. case 'S':
  54783. this.style = AnnotationBorderStyleType.SOLID;
  54784. break;
  54785. case 'D':
  54786. this.style = AnnotationBorderStyleType.DASHED;
  54787. break;
  54788. case 'B':
  54789. this.style = AnnotationBorderStyleType.BEVELED;
  54790. break;
  54791. case 'I':
  54792. this.style = AnnotationBorderStyleType.INSET;
  54793. break;
  54794. case 'U':
  54795. this.style = AnnotationBorderStyleType.UNDERLINE;
  54796. break;
  54797. default:
  54798. break;
  54799. }
  54800. },
  54801. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54802. if (isArray(dashArray) && dashArray.length > 0) {
  54803. var isValid = true;
  54804. var allZeros = true;
  54805. for (var i = 0, len = dashArray.length; i < len; i++) {
  54806. var element = dashArray[i];
  54807. var validNumber = +element >= 0;
  54808. if (!validNumber) {
  54809. isValid = false;
  54810. break;
  54811. } else if (element > 0) {
  54812. allZeros = false;
  54813. }
  54814. }
  54815. if (isValid && !allZeros) {
  54816. this.dashArray = dashArray;
  54817. } else {
  54818. this.width = 0;
  54819. }
  54820. } else if (dashArray) {
  54821. this.width = 0;
  54822. }
  54823. },
  54824. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54825. if (radius === (radius | 0)) {
  54826. this.horizontalCornerRadius = radius;
  54827. }
  54828. },
  54829. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54830. if (radius === (radius | 0)) {
  54831. this.verticalCornerRadius = radius;
  54832. }
  54833. }
  54834. };
  54835. return AnnotationBorderStyle;
  54836. }();
  54837. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54838. function WidgetAnnotation(params) {
  54839. Annotation.call(this, params);
  54840. var dict = params.dict;
  54841. var data = this.data;
  54842. data.annotationType = AnnotationType.WIDGET;
  54843. data.fieldName = this._constructFieldName(dict);
  54844. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  54845. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  54846. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  54847. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54848. data.fieldType = isName(fieldType) ? fieldType.name : null;
  54849. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  54850. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  54851. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  54852. data.fieldFlags = 0;
  54853. }
  54854. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  54855. if (data.fieldType === 'Sig') {
  54856. this.setFlags(AnnotationFlag.HIDDEN);
  54857. }
  54858. }
  54859. Util.inherit(WidgetAnnotation, Annotation, {
  54860. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  54861. if (!dict.has('T') && !dict.has('Parent')) {
  54862. warn('Unknown field name, falling back to empty field name.');
  54863. return '';
  54864. }
  54865. if (!dict.has('Parent')) {
  54866. return stringToPDFString(dict.get('T'));
  54867. }
  54868. var fieldName = [];
  54869. if (dict.has('T')) {
  54870. fieldName.unshift(stringToPDFString(dict.get('T')));
  54871. }
  54872. var loopDict = dict;
  54873. while (loopDict.has('Parent')) {
  54874. loopDict = loopDict.get('Parent');
  54875. if (loopDict.has('T')) {
  54876. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  54877. }
  54878. }
  54879. return fieldName.join('.');
  54880. },
  54881. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  54882. return !!(this.data.fieldFlags & flag);
  54883. }
  54884. });
  54885. return WidgetAnnotation;
  54886. }();
  54887. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  54888. function TextWidgetAnnotation(params) {
  54889. WidgetAnnotation.call(this, params);
  54890. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  54891. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  54892. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  54893. alignment = null;
  54894. }
  54895. this.data.textAlignment = alignment;
  54896. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  54897. if (!isInt(maximumLength) || maximumLength < 0) {
  54898. maximumLength = null;
  54899. }
  54900. this.data.maxLen = maximumLength;
  54901. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  54902. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  54903. }
  54904. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  54905. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54906. var operatorList = new OperatorList();
  54907. if (renderForms) {
  54908. return Promise.resolve(operatorList);
  54909. }
  54910. if (this.appearance) {
  54911. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54912. }
  54913. if (!this.data.defaultAppearance) {
  54914. return Promise.resolve(operatorList);
  54915. }
  54916. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  54917. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  54918. return operatorList;
  54919. });
  54920. }
  54921. });
  54922. return TextWidgetAnnotation;
  54923. }();
  54924. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  54925. function ChoiceWidgetAnnotation(params) {
  54926. WidgetAnnotation.call(this, params);
  54927. this.data.options = [];
  54928. var options = params.dict.getArray('Opt');
  54929. if (isArray(options)) {
  54930. for (var i = 0, ii = options.length; i < ii; i++) {
  54931. var option = options[i];
  54932. this.data.options[i] = {
  54933. exportValue: isArray(option) ? option[0] : option,
  54934. displayValue: isArray(option) ? option[1] : option
  54935. };
  54936. }
  54937. }
  54938. if (!isArray(this.data.fieldValue)) {
  54939. this.data.fieldValue = [this.data.fieldValue];
  54940. }
  54941. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  54942. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  54943. }
  54944. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  54945. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54946. var operatorList = new OperatorList();
  54947. if (renderForms) {
  54948. return Promise.resolve(operatorList);
  54949. }
  54950. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54951. }
  54952. });
  54953. return ChoiceWidgetAnnotation;
  54954. }();
  54955. var TextAnnotation = function TextAnnotationClosure() {
  54956. var DEFAULT_ICON_SIZE = 22;
  54957. function TextAnnotation(parameters) {
  54958. Annotation.call(this, parameters);
  54959. this.data.annotationType = AnnotationType.TEXT;
  54960. if (this.data.hasAppearance) {
  54961. this.data.name = 'NoIcon';
  54962. } else {
  54963. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  54964. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  54965. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  54966. }
  54967. this._preparePopup(parameters.dict);
  54968. }
  54969. Util.inherit(TextAnnotation, Annotation, {});
  54970. return TextAnnotation;
  54971. }();
  54972. var LinkAnnotation = function LinkAnnotationClosure() {
  54973. function LinkAnnotation(params) {
  54974. Annotation.call(this, params);
  54975. var data = this.data;
  54976. data.annotationType = AnnotationType.LINK;
  54977. Catalog.parseDestDictionary({
  54978. destDict: params.dict,
  54979. resultObj: data,
  54980. docBaseUrl: params.pdfManager.docBaseUrl
  54981. });
  54982. }
  54983. Util.inherit(LinkAnnotation, Annotation, {});
  54984. return LinkAnnotation;
  54985. }();
  54986. var PopupAnnotation = function PopupAnnotationClosure() {
  54987. function PopupAnnotation(parameters) {
  54988. Annotation.call(this, parameters);
  54989. this.data.annotationType = AnnotationType.POPUP;
  54990. var dict = parameters.dict;
  54991. var parentItem = dict.get('Parent');
  54992. if (!parentItem) {
  54993. warn('Popup annotation has a missing or invalid parent annotation.');
  54994. return;
  54995. }
  54996. this.data.parentId = dict.getRaw('Parent').toString();
  54997. this.data.title = stringToPDFString(parentItem.get('T') || '');
  54998. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  54999. if (!parentItem.has('C')) {
  55000. this.data.color = null;
  55001. } else {
  55002. this.setColor(parentItem.getArray('C'));
  55003. this.data.color = this.color;
  55004. }
  55005. if (!this.viewable) {
  55006. var parentFlags = parentItem.get('F');
  55007. if (this._isViewable(parentFlags)) {
  55008. this.setFlags(parentFlags);
  55009. }
  55010. }
  55011. }
  55012. Util.inherit(PopupAnnotation, Annotation, {});
  55013. return PopupAnnotation;
  55014. }();
  55015. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55016. function HighlightAnnotation(parameters) {
  55017. Annotation.call(this, parameters);
  55018. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55019. this._preparePopup(parameters.dict);
  55020. this.data.borderStyle.setWidth(0);
  55021. }
  55022. Util.inherit(HighlightAnnotation, Annotation, {});
  55023. return HighlightAnnotation;
  55024. }();
  55025. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55026. function UnderlineAnnotation(parameters) {
  55027. Annotation.call(this, parameters);
  55028. this.data.annotationType = AnnotationType.UNDERLINE;
  55029. this._preparePopup(parameters.dict);
  55030. this.data.borderStyle.setWidth(0);
  55031. }
  55032. Util.inherit(UnderlineAnnotation, Annotation, {});
  55033. return UnderlineAnnotation;
  55034. }();
  55035. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55036. function SquigglyAnnotation(parameters) {
  55037. Annotation.call(this, parameters);
  55038. this.data.annotationType = AnnotationType.SQUIGGLY;
  55039. this._preparePopup(parameters.dict);
  55040. this.data.borderStyle.setWidth(0);
  55041. }
  55042. Util.inherit(SquigglyAnnotation, Annotation, {});
  55043. return SquigglyAnnotation;
  55044. }();
  55045. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55046. function StrikeOutAnnotation(parameters) {
  55047. Annotation.call(this, parameters);
  55048. this.data.annotationType = AnnotationType.STRIKEOUT;
  55049. this._preparePopup(parameters.dict);
  55050. this.data.borderStyle.setWidth(0);
  55051. }
  55052. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55053. return StrikeOutAnnotation;
  55054. }();
  55055. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55056. function FileAttachmentAnnotation(parameters) {
  55057. Annotation.call(this, parameters);
  55058. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55059. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55060. this.data.file = file.serializable;
  55061. this._preparePopup(parameters.dict);
  55062. }
  55063. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55064. return FileAttachmentAnnotation;
  55065. }();
  55066. exports.Annotation = Annotation;
  55067. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55068. exports.AnnotationFactory = AnnotationFactory;
  55069. }));
  55070. (function (root, factory) {
  55071. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55072. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55073. var MissingDataException = sharedUtil.MissingDataException;
  55074. var Util = sharedUtil.Util;
  55075. var assert = sharedUtil.assert;
  55076. var error = sharedUtil.error;
  55077. var info = sharedUtil.info;
  55078. var isArray = sharedUtil.isArray;
  55079. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55080. var isString = sharedUtil.isString;
  55081. var shadow = sharedUtil.shadow;
  55082. var stringToBytes = sharedUtil.stringToBytes;
  55083. var stringToPDFString = sharedUtil.stringToPDFString;
  55084. var warn = sharedUtil.warn;
  55085. var isSpace = sharedUtil.isSpace;
  55086. var Dict = corePrimitives.Dict;
  55087. var isDict = corePrimitives.isDict;
  55088. var isName = corePrimitives.isName;
  55089. var isStream = corePrimitives.isStream;
  55090. var NullStream = coreStream.NullStream;
  55091. var Stream = coreStream.Stream;
  55092. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55093. var Catalog = coreObj.Catalog;
  55094. var ObjectLoader = coreObj.ObjectLoader;
  55095. var XRef = coreObj.XRef;
  55096. var Linearization = coreParser.Linearization;
  55097. var calculateMD5 = coreCrypto.calculateMD5;
  55098. var OperatorList = coreEvaluator.OperatorList;
  55099. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55100. var Annotation = coreAnnotation.Annotation;
  55101. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55102. var Page = function PageClosure() {
  55103. var LETTER_SIZE_MEDIABOX = [
  55104. 0,
  55105. 0,
  55106. 612,
  55107. 792
  55108. ];
  55109. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55110. this.pdfManager = pdfManager;
  55111. this.pageIndex = pageIndex;
  55112. this.pageDict = pageDict;
  55113. this.xref = xref;
  55114. this.ref = ref;
  55115. this.fontCache = fontCache;
  55116. this.uniquePrefix = 'p' + this.pageIndex + '_';
  55117. this.idCounters = { obj: 0 };
  55118. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55119. this.resourcesPromise = null;
  55120. }
  55121. Page.prototype = {
  55122. getPageProp: function Page_getPageProp(key) {
  55123. return this.pageDict.get(key);
  55124. },
  55125. getInheritedPageProp: function Page_getInheritedPageProp(key) {
  55126. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55127. var MAX_LOOP_COUNT = 100;
  55128. while (dict) {
  55129. var value = dict.get(key);
  55130. if (value) {
  55131. if (!valueArray) {
  55132. valueArray = [];
  55133. }
  55134. valueArray.push(value);
  55135. }
  55136. if (++loopCount > MAX_LOOP_COUNT) {
  55137. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55138. break;
  55139. }
  55140. dict = dict.get('Parent');
  55141. }
  55142. if (!valueArray) {
  55143. return Dict.empty;
  55144. }
  55145. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55146. return valueArray[0];
  55147. }
  55148. return Dict.merge(this.xref, valueArray);
  55149. },
  55150. get content() {
  55151. return this.getPageProp('Contents');
  55152. },
  55153. get resources() {
  55154. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55155. },
  55156. get mediaBox() {
  55157. var obj = this.getInheritedPageProp('MediaBox');
  55158. if (!isArray(obj) || obj.length !== 4) {
  55159. obj = LETTER_SIZE_MEDIABOX;
  55160. }
  55161. return shadow(this, 'mediaBox', obj);
  55162. },
  55163. get view() {
  55164. var mediaBox = this.mediaBox;
  55165. var cropBox = this.getInheritedPageProp('CropBox');
  55166. if (!isArray(cropBox) || cropBox.length !== 4) {
  55167. return shadow(this, 'view', mediaBox);
  55168. }
  55169. cropBox = Util.intersect(cropBox, mediaBox);
  55170. if (!cropBox) {
  55171. return shadow(this, 'view', mediaBox);
  55172. }
  55173. return shadow(this, 'view', cropBox);
  55174. },
  55175. get rotate() {
  55176. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55177. if (rotate % 90 !== 0) {
  55178. rotate = 0;
  55179. } else if (rotate >= 360) {
  55180. rotate = rotate % 360;
  55181. } else if (rotate < 0) {
  55182. rotate = (rotate % 360 + 360) % 360;
  55183. }
  55184. return shadow(this, 'rotate', rotate);
  55185. },
  55186. getContentStream: function Page_getContentStream() {
  55187. var content = this.content;
  55188. var stream;
  55189. if (isArray(content)) {
  55190. var xref = this.xref;
  55191. var i, n = content.length;
  55192. var streams = [];
  55193. for (i = 0; i < n; ++i) {
  55194. streams.push(xref.fetchIfRef(content[i]));
  55195. }
  55196. stream = new StreamsSequenceStream(streams);
  55197. } else if (isStream(content)) {
  55198. stream = content;
  55199. } else {
  55200. stream = new NullStream();
  55201. }
  55202. return stream;
  55203. },
  55204. loadResources: function Page_loadResources(keys) {
  55205. if (!this.resourcesPromise) {
  55206. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55207. }
  55208. return this.resourcesPromise.then(function resourceSuccess() {
  55209. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55210. return objectLoader.load();
  55211. }.bind(this));
  55212. },
  55213. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55214. var self = this;
  55215. var pdfManager = this.pdfManager;
  55216. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55217. var resourcesPromise = this.loadResources([
  55218. 'ExtGState',
  55219. 'ColorSpace',
  55220. 'Pattern',
  55221. 'Shading',
  55222. 'XObject',
  55223. 'Font'
  55224. ]);
  55225. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  55226. var dataPromises = Promise.all([
  55227. contentStreamPromise,
  55228. resourcesPromise
  55229. ]);
  55230. var pageListPromise = dataPromises.then(function (data) {
  55231. var contentStream = data[0];
  55232. var opList = new OperatorList(intent, handler, self.pageIndex);
  55233. handler.send('StartRenderPage', {
  55234. transparency: partialEvaluator.hasBlendModes(self.resources),
  55235. pageIndex: self.pageIndex,
  55236. intent: intent
  55237. });
  55238. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55239. return opList;
  55240. });
  55241. });
  55242. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55243. return Promise.all([
  55244. pageListPromise,
  55245. annotationsPromise
  55246. ]).then(function (datas) {
  55247. var pageOpList = datas[0];
  55248. var annotations = datas[1];
  55249. if (annotations.length === 0) {
  55250. pageOpList.flush(true);
  55251. return pageOpList;
  55252. }
  55253. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55254. return annotationsReadyPromise.then(function () {
  55255. pageOpList.flush(true);
  55256. return pageOpList;
  55257. });
  55258. });
  55259. },
  55260. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55261. var handler = {
  55262. on: function nullHandlerOn() {
  55263. },
  55264. send: function nullHandlerSend() {
  55265. }
  55266. };
  55267. var self = this;
  55268. var pdfManager = this.pdfManager;
  55269. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55270. var resourcesPromise = this.loadResources([
  55271. 'ExtGState',
  55272. 'XObject',
  55273. 'Font'
  55274. ]);
  55275. var dataPromises = Promise.all([
  55276. contentStreamPromise,
  55277. resourcesPromise
  55278. ]);
  55279. return dataPromises.then(function (data) {
  55280. var contentStream = data[0];
  55281. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  55282. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55283. });
  55284. },
  55285. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55286. var annotations = this.annotations;
  55287. var annotationsData = [];
  55288. for (var i = 0, n = annotations.length; i < n; ++i) {
  55289. if (intent) {
  55290. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55291. continue;
  55292. }
  55293. }
  55294. annotationsData.push(annotations[i].data);
  55295. }
  55296. return annotationsData;
  55297. },
  55298. get annotations() {
  55299. var annotations = [];
  55300. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55301. var annotationFactory = new AnnotationFactory();
  55302. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55303. var annotationRef = annotationRefs[i];
  55304. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  55305. if (annotation) {
  55306. annotations.push(annotation);
  55307. }
  55308. }
  55309. return shadow(this, 'annotations', annotations);
  55310. }
  55311. };
  55312. return Page;
  55313. }();
  55314. var PDFDocument = function PDFDocumentClosure() {
  55315. var FINGERPRINT_FIRST_BYTES = 1024;
  55316. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55317. function PDFDocument(pdfManager, arg, password) {
  55318. if (isStream(arg)) {
  55319. init.call(this, pdfManager, arg, password);
  55320. } else if (isArrayBuffer(arg)) {
  55321. init.call(this, pdfManager, new Stream(arg), password);
  55322. } else {
  55323. error('PDFDocument: Unknown argument type');
  55324. }
  55325. }
  55326. function init(pdfManager, stream, password) {
  55327. assert(stream.length > 0, 'stream must have data');
  55328. this.pdfManager = pdfManager;
  55329. this.stream = stream;
  55330. var xref = new XRef(this.stream, password, pdfManager);
  55331. this.xref = xref;
  55332. }
  55333. function find(stream, needle, limit, backwards) {
  55334. var pos = stream.pos;
  55335. var end = stream.end;
  55336. var strBuf = [];
  55337. if (pos + limit > end) {
  55338. limit = end - pos;
  55339. }
  55340. for (var n = 0; n < limit; ++n) {
  55341. strBuf.push(String.fromCharCode(stream.getByte()));
  55342. }
  55343. var str = strBuf.join('');
  55344. stream.pos = pos;
  55345. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55346. if (index === -1) {
  55347. return false;
  55348. }
  55349. stream.pos += index;
  55350. return true;
  55351. }
  55352. var DocumentInfoValidators = {
  55353. get entries() {
  55354. return shadow(this, 'entries', {
  55355. Title: isString,
  55356. Author: isString,
  55357. Subject: isString,
  55358. Keywords: isString,
  55359. Creator: isString,
  55360. Producer: isString,
  55361. CreationDate: isString,
  55362. ModDate: isString,
  55363. Trapped: isName
  55364. });
  55365. }
  55366. };
  55367. PDFDocument.prototype = {
  55368. parse: function PDFDocument_parse(recoveryMode) {
  55369. this.setup(recoveryMode);
  55370. var version = this.catalog.catDict.get('Version');
  55371. if (isName(version)) {
  55372. this.pdfFormatVersion = version.name;
  55373. }
  55374. try {
  55375. this.acroForm = this.catalog.catDict.get('AcroForm');
  55376. if (this.acroForm) {
  55377. this.xfa = this.acroForm.get('XFA');
  55378. var fields = this.acroForm.get('Fields');
  55379. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55380. this.acroForm = null;
  55381. }
  55382. }
  55383. } catch (ex) {
  55384. info('Something wrong with AcroForm entry');
  55385. this.acroForm = null;
  55386. }
  55387. },
  55388. get linearization() {
  55389. var linearization = null;
  55390. if (this.stream.length) {
  55391. try {
  55392. linearization = Linearization.create(this.stream);
  55393. } catch (err) {
  55394. if (err instanceof MissingDataException) {
  55395. throw err;
  55396. }
  55397. info(err);
  55398. }
  55399. }
  55400. return shadow(this, 'linearization', linearization);
  55401. },
  55402. get startXRef() {
  55403. var stream = this.stream;
  55404. var startXRef = 0;
  55405. var linearization = this.linearization;
  55406. if (linearization) {
  55407. stream.reset();
  55408. if (find(stream, 'endobj', 1024)) {
  55409. startXRef = stream.pos + 6;
  55410. }
  55411. } else {
  55412. var step = 1024;
  55413. var found = false, pos = stream.end;
  55414. while (!found && pos > 0) {
  55415. pos -= step - 'startxref'.length;
  55416. if (pos < 0) {
  55417. pos = 0;
  55418. }
  55419. stream.pos = pos;
  55420. found = find(stream, 'startxref', step, true);
  55421. }
  55422. if (found) {
  55423. stream.skip(9);
  55424. var ch;
  55425. do {
  55426. ch = stream.getByte();
  55427. } while (isSpace(ch));
  55428. var str = '';
  55429. while (ch >= 0x20 && ch <= 0x39) {
  55430. str += String.fromCharCode(ch);
  55431. ch = stream.getByte();
  55432. }
  55433. startXRef = parseInt(str, 10);
  55434. if (isNaN(startXRef)) {
  55435. startXRef = 0;
  55436. }
  55437. }
  55438. }
  55439. return shadow(this, 'startXRef', startXRef);
  55440. },
  55441. get mainXRefEntriesOffset() {
  55442. var mainXRefEntriesOffset = 0;
  55443. var linearization = this.linearization;
  55444. if (linearization) {
  55445. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55446. }
  55447. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55448. },
  55449. checkHeader: function PDFDocument_checkHeader() {
  55450. var stream = this.stream;
  55451. stream.reset();
  55452. if (find(stream, '%PDF-', 1024)) {
  55453. stream.moveStart();
  55454. var MAX_VERSION_LENGTH = 12;
  55455. var version = '', ch;
  55456. while ((ch = stream.getByte()) > 0x20) {
  55457. if (version.length >= MAX_VERSION_LENGTH) {
  55458. break;
  55459. }
  55460. version += String.fromCharCode(ch);
  55461. }
  55462. if (!this.pdfFormatVersion) {
  55463. this.pdfFormatVersion = version.substring(5);
  55464. }
  55465. return;
  55466. }
  55467. },
  55468. parseStartXRef: function PDFDocument_parseStartXRef() {
  55469. var startXRef = this.startXRef;
  55470. this.xref.setStartXRef(startXRef);
  55471. },
  55472. setup: function PDFDocument_setup(recoveryMode) {
  55473. this.xref.parse(recoveryMode);
  55474. var self = this;
  55475. var pageFactory = {
  55476. createPage: function (pageIndex, dict, ref, fontCache) {
  55477. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55478. }
  55479. };
  55480. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55481. },
  55482. get numPages() {
  55483. var linearization = this.linearization;
  55484. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55485. return shadow(this, 'numPages', num);
  55486. },
  55487. get documentInfo() {
  55488. var docInfo = {
  55489. PDFFormatVersion: this.pdfFormatVersion,
  55490. IsAcroFormPresent: !!this.acroForm,
  55491. IsXFAPresent: !!this.xfa
  55492. };
  55493. var infoDict;
  55494. try {
  55495. infoDict = this.xref.trailer.get('Info');
  55496. } catch (err) {
  55497. info('The document information dictionary is invalid.');
  55498. }
  55499. if (infoDict) {
  55500. var validEntries = DocumentInfoValidators.entries;
  55501. for (var key in validEntries) {
  55502. if (infoDict.has(key)) {
  55503. var value = infoDict.get(key);
  55504. if (validEntries[key](value)) {
  55505. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55506. } else {
  55507. info('Bad value in document info for "' + key + '"');
  55508. }
  55509. }
  55510. }
  55511. }
  55512. return shadow(this, 'documentInfo', docInfo);
  55513. },
  55514. get fingerprint() {
  55515. var xref = this.xref, hash, fileID = '';
  55516. var idArray = xref.trailer.get('ID');
  55517. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55518. hash = stringToBytes(idArray[0]);
  55519. } else {
  55520. if (this.stream.ensureRange) {
  55521. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55522. }
  55523. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55524. }
  55525. for (var i = 0, n = hash.length; i < n; i++) {
  55526. var hex = hash[i].toString(16);
  55527. fileID += hex.length === 1 ? '0' + hex : hex;
  55528. }
  55529. return shadow(this, 'fingerprint', fileID);
  55530. },
  55531. getPage: function PDFDocument_getPage(pageIndex) {
  55532. return this.catalog.getPage(pageIndex);
  55533. },
  55534. cleanup: function PDFDocument_cleanup() {
  55535. return this.catalog.cleanup();
  55536. }
  55537. };
  55538. return PDFDocument;
  55539. }();
  55540. exports.Page = Page;
  55541. exports.PDFDocument = PDFDocument;
  55542. }));
  55543. (function (root, factory) {
  55544. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55545. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55546. var warn = sharedUtil.warn;
  55547. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55548. var shadow = sharedUtil.shadow;
  55549. var NotImplementedException = sharedUtil.NotImplementedException;
  55550. var MissingDataException = sharedUtil.MissingDataException;
  55551. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55552. var Util = sharedUtil.Util;
  55553. var Stream = coreStream.Stream;
  55554. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55555. var PDFDocument = coreDocument.PDFDocument;
  55556. var BasePdfManager = function BasePdfManagerClosure() {
  55557. function BasePdfManager() {
  55558. throw new Error('Cannot initialize BaseManagerManager');
  55559. }
  55560. BasePdfManager.prototype = {
  55561. get docId() {
  55562. return this._docId;
  55563. },
  55564. get docBaseUrl() {
  55565. var docBaseUrl = null;
  55566. if (this._docBaseUrl) {
  55567. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55568. if (absoluteUrl) {
  55569. docBaseUrl = absoluteUrl.href;
  55570. } else {
  55571. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55572. }
  55573. }
  55574. return shadow(this, 'docBaseUrl', docBaseUrl);
  55575. },
  55576. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55577. throw new NotImplementedException();
  55578. },
  55579. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55580. return this.ensure(this.pdfDocument, prop, args);
  55581. },
  55582. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55583. return this.ensure(this.pdfDocument.xref, prop, args);
  55584. },
  55585. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55586. return this.ensure(this.pdfDocument.catalog, prop, args);
  55587. },
  55588. getPage: function BasePdfManager_getPage(pageIndex) {
  55589. return this.pdfDocument.getPage(pageIndex);
  55590. },
  55591. cleanup: function BasePdfManager_cleanup() {
  55592. return this.pdfDocument.cleanup();
  55593. },
  55594. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55595. return new NotImplementedException();
  55596. },
  55597. requestRange: function BasePdfManager_requestRange(begin, end) {
  55598. return new NotImplementedException();
  55599. },
  55600. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55601. return new NotImplementedException();
  55602. },
  55603. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55604. return new NotImplementedException();
  55605. },
  55606. updatePassword: function BasePdfManager_updatePassword(password) {
  55607. this.pdfDocument.xref.password = this.password = password;
  55608. if (this._passwordChangedCapability) {
  55609. this._passwordChangedCapability.resolve();
  55610. }
  55611. },
  55612. passwordChanged: function BasePdfManager_passwordChanged() {
  55613. this._passwordChangedCapability = createPromiseCapability();
  55614. return this._passwordChangedCapability.promise;
  55615. },
  55616. terminate: function BasePdfManager_terminate() {
  55617. return new NotImplementedException();
  55618. }
  55619. };
  55620. return BasePdfManager;
  55621. }();
  55622. var LocalPdfManager = function LocalPdfManagerClosure() {
  55623. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55624. this._docId = docId;
  55625. this._docBaseUrl = docBaseUrl;
  55626. this.evaluatorOptions = evaluatorOptions;
  55627. var stream = new Stream(data);
  55628. this.pdfDocument = new PDFDocument(this, stream, password);
  55629. this._loadedStreamCapability = createPromiseCapability();
  55630. this._loadedStreamCapability.resolve(stream);
  55631. }
  55632. Util.inherit(LocalPdfManager, BasePdfManager, {
  55633. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55634. return new Promise(function (resolve, reject) {
  55635. try {
  55636. var value = obj[prop];
  55637. var result;
  55638. if (typeof value === 'function') {
  55639. result = value.apply(obj, args);
  55640. } else {
  55641. result = value;
  55642. }
  55643. resolve(result);
  55644. } catch (e) {
  55645. reject(e);
  55646. }
  55647. });
  55648. },
  55649. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55650. return Promise.resolve();
  55651. },
  55652. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55653. return;
  55654. },
  55655. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55656. return this._loadedStreamCapability.promise;
  55657. },
  55658. terminate: function LocalPdfManager_terminate() {
  55659. return;
  55660. }
  55661. });
  55662. return LocalPdfManager;
  55663. }();
  55664. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55665. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55666. this._docId = docId;
  55667. this._docBaseUrl = docBaseUrl;
  55668. this.msgHandler = args.msgHandler;
  55669. this.evaluatorOptions = evaluatorOptions;
  55670. var params = {
  55671. msgHandler: args.msgHandler,
  55672. url: args.url,
  55673. length: args.length,
  55674. disableAutoFetch: args.disableAutoFetch,
  55675. rangeChunkSize: args.rangeChunkSize
  55676. };
  55677. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55678. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  55679. }
  55680. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55681. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55682. var pdfManager = this;
  55683. return new Promise(function (resolve, reject) {
  55684. function ensureHelper() {
  55685. try {
  55686. var result;
  55687. var value = obj[prop];
  55688. if (typeof value === 'function') {
  55689. result = value.apply(obj, args);
  55690. } else {
  55691. result = value;
  55692. }
  55693. resolve(result);
  55694. } catch (e) {
  55695. if (!(e instanceof MissingDataException)) {
  55696. reject(e);
  55697. return;
  55698. }
  55699. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55700. }
  55701. }
  55702. ensureHelper();
  55703. });
  55704. },
  55705. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55706. return this.streamManager.requestRange(begin, end);
  55707. },
  55708. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55709. this.streamManager.requestAllChunks();
  55710. },
  55711. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55712. this.streamManager.onReceiveData({ chunk: chunk });
  55713. },
  55714. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55715. return this.streamManager.onLoadedStream();
  55716. },
  55717. terminate: function NetworkPdfManager_terminate() {
  55718. this.streamManager.abort();
  55719. }
  55720. });
  55721. return NetworkPdfManager;
  55722. }();
  55723. exports.LocalPdfManager = LocalPdfManager;
  55724. exports.NetworkPdfManager = NetworkPdfManager;
  55725. }));
  55726. (function (root, factory) {
  55727. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55728. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55729. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55730. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55731. var MessageHandler = sharedUtil.MessageHandler;
  55732. var MissingPDFException = sharedUtil.MissingPDFException;
  55733. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55734. var PasswordException = sharedUtil.PasswordException;
  55735. var PasswordResponses = sharedUtil.PasswordResponses;
  55736. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55737. var XRefParseException = sharedUtil.XRefParseException;
  55738. var arrayByteLength = sharedUtil.arrayByteLength;
  55739. var arraysToBytes = sharedUtil.arraysToBytes;
  55740. var assert = sharedUtil.assert;
  55741. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55742. var error = sharedUtil.error;
  55743. var info = sharedUtil.info;
  55744. var warn = sharedUtil.warn;
  55745. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55746. var Ref = corePrimitives.Ref;
  55747. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55748. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55749. var globalScope = sharedUtil.globalScope;
  55750. var WorkerTask = function WorkerTaskClosure() {
  55751. function WorkerTask(name) {
  55752. this.name = name;
  55753. this.terminated = false;
  55754. this._capability = createPromiseCapability();
  55755. }
  55756. WorkerTask.prototype = {
  55757. get finished() {
  55758. return this._capability.promise;
  55759. },
  55760. finish: function () {
  55761. this._capability.resolve();
  55762. },
  55763. terminate: function () {
  55764. this.terminated = true;
  55765. },
  55766. ensureNotTerminated: function () {
  55767. if (this.terminated) {
  55768. throw new Error('Worker task was terminated');
  55769. }
  55770. }
  55771. };
  55772. return WorkerTask;
  55773. }();
  55774. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  55775. function PDFWorkerStream(params, msgHandler) {
  55776. this._queuedChunks = [];
  55777. var initialData = params.initialData;
  55778. if (initialData && initialData.length > 0) {
  55779. this._queuedChunks.push(initialData);
  55780. }
  55781. this._msgHandler = msgHandler;
  55782. this._isRangeSupported = !params.disableRange;
  55783. this._isStreamingSupported = !params.disableStream;
  55784. this._contentLength = params.length;
  55785. this._fullRequestReader = null;
  55786. this._rangeReaders = [];
  55787. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  55788. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  55789. }
  55790. PDFWorkerStream.prototype = {
  55791. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  55792. if (args.begin === undefined) {
  55793. if (this._fullRequestReader) {
  55794. this._fullRequestReader._enqueue(args.chunk);
  55795. } else {
  55796. this._queuedChunks.push(args.chunk);
  55797. }
  55798. } else {
  55799. var found = this._rangeReaders.some(function (rangeReader) {
  55800. if (rangeReader._begin !== args.begin) {
  55801. return false;
  55802. }
  55803. rangeReader._enqueue(args.chunk);
  55804. return true;
  55805. });
  55806. assert(found);
  55807. }
  55808. },
  55809. _onProgress: function PDFWorkerStream_onProgress(evt) {
  55810. if (this._rangeReaders.length > 0) {
  55811. var firstReader = this._rangeReaders[0];
  55812. if (firstReader.onProgress) {
  55813. firstReader.onProgress({ loaded: evt.loaded });
  55814. }
  55815. }
  55816. },
  55817. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  55818. var i = this._rangeReaders.indexOf(reader);
  55819. if (i >= 0) {
  55820. this._rangeReaders.splice(i, 1);
  55821. }
  55822. },
  55823. getFullReader: function PDFWorkerStream_getFullReader() {
  55824. assert(!this._fullRequestReader);
  55825. var queuedChunks = this._queuedChunks;
  55826. this._queuedChunks = null;
  55827. return new PDFWorkerStreamReader(this, queuedChunks);
  55828. },
  55829. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  55830. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  55831. this._msgHandler.send('RequestDataRange', {
  55832. begin: begin,
  55833. end: end
  55834. });
  55835. this._rangeReaders.push(reader);
  55836. return reader;
  55837. },
  55838. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  55839. if (this._fullRequestReader) {
  55840. this._fullRequestReader.cancel(reason);
  55841. }
  55842. var readers = this._rangeReaders.slice(0);
  55843. readers.forEach(function (rangeReader) {
  55844. rangeReader.cancel(reason);
  55845. });
  55846. }
  55847. };
  55848. function PDFWorkerStreamReader(stream, queuedChunks) {
  55849. this._stream = stream;
  55850. this._done = false;
  55851. this._queuedChunks = queuedChunks || [];
  55852. this._requests = [];
  55853. this._headersReady = Promise.resolve();
  55854. stream._fullRequestReader = this;
  55855. this.onProgress = null;
  55856. }
  55857. PDFWorkerStreamReader.prototype = {
  55858. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  55859. if (this._done) {
  55860. return;
  55861. }
  55862. if (this._requests.length > 0) {
  55863. var requestCapability = this._requests.shift();
  55864. requestCapability.resolve({
  55865. value: chunk,
  55866. done: false
  55867. });
  55868. return;
  55869. }
  55870. this._queuedChunks.push(chunk);
  55871. },
  55872. get headersReady() {
  55873. return this._headersReady;
  55874. },
  55875. get isRangeSupported() {
  55876. return this._stream._isRangeSupported;
  55877. },
  55878. get isStreamingSupported() {
  55879. return this._stream._isStreamingSupported;
  55880. },
  55881. get contentLength() {
  55882. return this._stream._contentLength;
  55883. },
  55884. read: function PDFWorkerStreamReader_read() {
  55885. if (this._queuedChunks.length > 0) {
  55886. var chunk = this._queuedChunks.shift();
  55887. return Promise.resolve({
  55888. value: chunk,
  55889. done: false
  55890. });
  55891. }
  55892. if (this._done) {
  55893. return Promise.resolve({
  55894. value: undefined,
  55895. done: true
  55896. });
  55897. }
  55898. var requestCapability = createPromiseCapability();
  55899. this._requests.push(requestCapability);
  55900. return requestCapability.promise;
  55901. },
  55902. cancel: function PDFWorkerStreamReader_cancel(reason) {
  55903. this._done = true;
  55904. this._requests.forEach(function (requestCapability) {
  55905. requestCapability.resolve({
  55906. value: undefined,
  55907. done: true
  55908. });
  55909. });
  55910. this._requests = [];
  55911. }
  55912. };
  55913. function PDFWorkerStreamRangeReader(stream, begin, end) {
  55914. this._stream = stream;
  55915. this._begin = begin;
  55916. this._end = end;
  55917. this._queuedChunk = null;
  55918. this._requests = [];
  55919. this._done = false;
  55920. this.onProgress = null;
  55921. }
  55922. PDFWorkerStreamRangeReader.prototype = {
  55923. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  55924. if (this._done) {
  55925. return;
  55926. }
  55927. if (this._requests.length === 0) {
  55928. this._queuedChunk = chunk;
  55929. } else {
  55930. var requestsCapability = this._requests.shift();
  55931. requestsCapability.resolve({
  55932. value: chunk,
  55933. done: false
  55934. });
  55935. this._requests.forEach(function (requestCapability) {
  55936. requestCapability.resolve({
  55937. value: undefined,
  55938. done: true
  55939. });
  55940. });
  55941. this._requests = [];
  55942. }
  55943. this._done = true;
  55944. this._stream._removeRangeReader(this);
  55945. },
  55946. get isStreamingSupported() {
  55947. return false;
  55948. },
  55949. read: function PDFWorkerStreamRangeReader_read() {
  55950. if (this._queuedChunk) {
  55951. return Promise.resolve({
  55952. value: this._queuedChunk,
  55953. done: false
  55954. });
  55955. }
  55956. if (this._done) {
  55957. return Promise.resolve({
  55958. value: undefined,
  55959. done: true
  55960. });
  55961. }
  55962. var requestCapability = createPromiseCapability();
  55963. this._requests.push(requestCapability);
  55964. return requestCapability.promise;
  55965. },
  55966. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  55967. this._done = true;
  55968. this._requests.forEach(function (requestCapability) {
  55969. requestCapability.resolve({
  55970. value: undefined,
  55971. done: true
  55972. });
  55973. });
  55974. this._requests = [];
  55975. this._stream._removeRangeReader(this);
  55976. }
  55977. };
  55978. return PDFWorkerStream;
  55979. }();
  55980. var PDFNetworkStream;
  55981. function setPDFNetworkStreamClass(cls) {
  55982. PDFNetworkStream = cls;
  55983. }
  55984. var WorkerMessageHandler = {
  55985. setup: function wphSetup(handler, port) {
  55986. var testMessageProcessed = false;
  55987. handler.on('test', function wphSetupTest(data) {
  55988. if (testMessageProcessed) {
  55989. return;
  55990. }
  55991. testMessageProcessed = true;
  55992. if (!(data instanceof Uint8Array)) {
  55993. handler.send('test', 'main', false);
  55994. return;
  55995. }
  55996. var supportTransfers = data[0] === 255;
  55997. handler.postMessageTransfers = supportTransfers;
  55998. var xhr = new XMLHttpRequest();
  55999. var responseExists = 'response' in xhr;
  56000. try {
  56001. var dummy = xhr.responseType;
  56002. } catch (e) {
  56003. responseExists = false;
  56004. }
  56005. if (!responseExists) {
  56006. handler.send('test', false);
  56007. return;
  56008. }
  56009. handler.send('test', {
  56010. supportTypedArray: true,
  56011. supportTransfers: supportTransfers
  56012. });
  56013. });
  56014. handler.on('configure', function wphConfigure(data) {
  56015. setVerbosityLevel(data.verbosity);
  56016. });
  56017. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56018. return WorkerMessageHandler.createDocumentHandler(data, port);
  56019. });
  56020. },
  56021. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56022. var pdfManager;
  56023. var terminated = false;
  56024. var cancelXHRs = null;
  56025. var WorkerTasks = [];
  56026. var docId = docParams.docId;
  56027. var docBaseUrl = docParams.docBaseUrl;
  56028. var workerHandlerName = docParams.docId + '_worker';
  56029. var handler = new MessageHandler(workerHandlerName, docId, port);
  56030. handler.postMessageTransfers = docParams.postMessageTransfers;
  56031. function ensureNotTerminated() {
  56032. if (terminated) {
  56033. throw new Error('Worker was terminated');
  56034. }
  56035. }
  56036. function startWorkerTask(task) {
  56037. WorkerTasks.push(task);
  56038. }
  56039. function finishWorkerTask(task) {
  56040. task.finish();
  56041. var i = WorkerTasks.indexOf(task);
  56042. WorkerTasks.splice(i, 1);
  56043. }
  56044. function loadDocument(recoveryMode) {
  56045. var loadDocumentCapability = createPromiseCapability();
  56046. var parseSuccess = function parseSuccess() {
  56047. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56048. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56049. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56050. Promise.all([
  56051. numPagesPromise,
  56052. fingerprintPromise,
  56053. encryptedPromise
  56054. ]).then(function onDocReady(results) {
  56055. var doc = {
  56056. numPages: results[0],
  56057. fingerprint: results[1],
  56058. encrypted: !!results[2]
  56059. };
  56060. loadDocumentCapability.resolve(doc);
  56061. }, parseFailure);
  56062. };
  56063. var parseFailure = function parseFailure(e) {
  56064. loadDocumentCapability.reject(e);
  56065. };
  56066. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56067. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56068. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56069. }, parseFailure);
  56070. }, parseFailure);
  56071. return loadDocumentCapability.promise;
  56072. }
  56073. function getPdfManager(data, evaluatorOptions) {
  56074. var pdfManagerCapability = createPromiseCapability();
  56075. var pdfManager;
  56076. var source = data.source;
  56077. if (source.data) {
  56078. try {
  56079. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56080. pdfManagerCapability.resolve(pdfManager);
  56081. } catch (ex) {
  56082. pdfManagerCapability.reject(ex);
  56083. }
  56084. return pdfManagerCapability.promise;
  56085. }
  56086. var pdfStream;
  56087. try {
  56088. if (source.chunkedViewerLoading) {
  56089. pdfStream = new PDFWorkerStream(source, handler);
  56090. } else {
  56091. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56092. pdfStream = new PDFNetworkStream(data);
  56093. }
  56094. } catch (ex) {
  56095. pdfManagerCapability.reject(ex);
  56096. return pdfManagerCapability.promise;
  56097. }
  56098. var fullRequest = pdfStream.getFullReader();
  56099. fullRequest.headersReady.then(function () {
  56100. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56101. fullRequest.onProgress = function (evt) {
  56102. handler.send('DocProgress', {
  56103. loaded: evt.loaded,
  56104. total: evt.total
  56105. });
  56106. };
  56107. }
  56108. if (!fullRequest.isRangeSupported) {
  56109. return;
  56110. }
  56111. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56112. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56113. msgHandler: handler,
  56114. url: source.url,
  56115. password: source.password,
  56116. length: fullRequest.contentLength,
  56117. disableAutoFetch: disableAutoFetch,
  56118. rangeChunkSize: source.rangeChunkSize
  56119. }, evaluatorOptions, docBaseUrl);
  56120. pdfManagerCapability.resolve(pdfManager);
  56121. cancelXHRs = null;
  56122. }).catch(function (reason) {
  56123. pdfManagerCapability.reject(reason);
  56124. cancelXHRs = null;
  56125. });
  56126. var cachedChunks = [], loaded = 0;
  56127. var flushChunks = function () {
  56128. var pdfFile = arraysToBytes(cachedChunks);
  56129. if (source.length && pdfFile.length !== source.length) {
  56130. warn('reported HTTP length is different from actual');
  56131. }
  56132. try {
  56133. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56134. pdfManagerCapability.resolve(pdfManager);
  56135. } catch (ex) {
  56136. pdfManagerCapability.reject(ex);
  56137. }
  56138. cachedChunks = [];
  56139. };
  56140. var readPromise = new Promise(function (resolve, reject) {
  56141. var readChunk = function (chunk) {
  56142. try {
  56143. ensureNotTerminated();
  56144. if (chunk.done) {
  56145. if (!pdfManager) {
  56146. flushChunks();
  56147. }
  56148. cancelXHRs = null;
  56149. return;
  56150. }
  56151. var data = chunk.value;
  56152. loaded += arrayByteLength(data);
  56153. if (!fullRequest.isStreamingSupported) {
  56154. handler.send('DocProgress', {
  56155. loaded: loaded,
  56156. total: Math.max(loaded, fullRequest.contentLength || 0)
  56157. });
  56158. }
  56159. if (pdfManager) {
  56160. pdfManager.sendProgressiveData(data);
  56161. } else {
  56162. cachedChunks.push(data);
  56163. }
  56164. fullRequest.read().then(readChunk, reject);
  56165. } catch (e) {
  56166. reject(e);
  56167. }
  56168. };
  56169. fullRequest.read().then(readChunk, reject);
  56170. });
  56171. readPromise.catch(function (e) {
  56172. pdfManagerCapability.reject(e);
  56173. cancelXHRs = null;
  56174. });
  56175. cancelXHRs = function () {
  56176. pdfStream.cancelAllRequests('abort');
  56177. };
  56178. return pdfManagerCapability.promise;
  56179. }
  56180. var setupDoc = function (data) {
  56181. var onSuccess = function (doc) {
  56182. ensureNotTerminated();
  56183. handler.send('GetDoc', { pdfInfo: doc });
  56184. };
  56185. var onFailure = function (e) {
  56186. if (e instanceof PasswordException) {
  56187. if (e.code === PasswordResponses.NEED_PASSWORD) {
  56188. handler.send('NeedPassword', e);
  56189. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  56190. handler.send('IncorrectPassword', e);
  56191. }
  56192. } else if (e instanceof InvalidPDFException) {
  56193. handler.send('InvalidPDF', e);
  56194. } else if (e instanceof MissingPDFException) {
  56195. handler.send('MissingPDF', e);
  56196. } else if (e instanceof UnexpectedResponseException) {
  56197. handler.send('UnexpectedResponse', e);
  56198. } else {
  56199. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56200. }
  56201. };
  56202. ensureNotTerminated();
  56203. var cMapOptions = {
  56204. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56205. packed: data.cMapPacked === true
  56206. };
  56207. var evaluatorOptions = {
  56208. forceDataSchema: data.disableCreateObjectURL,
  56209. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56210. disableFontFace: data.disableFontFace,
  56211. cMapOptions: cMapOptions
  56212. };
  56213. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56214. if (terminated) {
  56215. newPdfManager.terminate();
  56216. throw new Error('Worker was terminated');
  56217. }
  56218. pdfManager = newPdfManager;
  56219. handler.send('PDFManagerReady', null);
  56220. pdfManager.onLoadedStream().then(function (stream) {
  56221. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56222. });
  56223. }).then(function pdfManagerReady() {
  56224. ensureNotTerminated();
  56225. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56226. ensureNotTerminated();
  56227. if (!(ex instanceof XRefParseException)) {
  56228. if (ex instanceof PasswordException) {
  56229. pdfManager.passwordChanged().then(pdfManagerReady);
  56230. }
  56231. onFailure(ex);
  56232. return;
  56233. }
  56234. pdfManager.requestLoadedStream();
  56235. pdfManager.onLoadedStream().then(function () {
  56236. ensureNotTerminated();
  56237. loadDocument(true).then(onSuccess, onFailure);
  56238. });
  56239. }, onFailure);
  56240. }, onFailure);
  56241. };
  56242. handler.on('GetPage', function wphSetupGetPage(data) {
  56243. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56244. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56245. var refPromise = pdfManager.ensure(page, 'ref');
  56246. var viewPromise = pdfManager.ensure(page, 'view');
  56247. return Promise.all([
  56248. rotatePromise,
  56249. refPromise,
  56250. viewPromise
  56251. ]).then(function (results) {
  56252. return {
  56253. rotate: results[0],
  56254. ref: results[1],
  56255. view: results[2]
  56256. };
  56257. });
  56258. });
  56259. });
  56260. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56261. var ref = new Ref(data.ref.num, data.ref.gen);
  56262. var catalog = pdfManager.pdfDocument.catalog;
  56263. return catalog.getPageIndex(ref);
  56264. });
  56265. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56266. return pdfManager.ensureCatalog('destinations');
  56267. });
  56268. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56269. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56270. });
  56271. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56272. return pdfManager.ensureCatalog('pageLabels');
  56273. });
  56274. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56275. return pdfManager.ensureCatalog('attachments');
  56276. });
  56277. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56278. return pdfManager.ensureCatalog('javaScript');
  56279. });
  56280. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56281. return pdfManager.ensureCatalog('documentOutline');
  56282. });
  56283. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56284. return Promise.all([
  56285. pdfManager.ensureDoc('documentInfo'),
  56286. pdfManager.ensureCatalog('metadata')
  56287. ]);
  56288. });
  56289. handler.on('GetData', function wphSetupGetData(data) {
  56290. pdfManager.requestLoadedStream();
  56291. return pdfManager.onLoadedStream().then(function (stream) {
  56292. return stream.bytes;
  56293. });
  56294. });
  56295. handler.on('GetStats', function wphSetupGetStats(data) {
  56296. return pdfManager.pdfDocument.xref.stats;
  56297. });
  56298. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  56299. pdfManager.updatePassword(data);
  56300. });
  56301. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56302. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56303. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56304. });
  56305. });
  56306. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56307. var pageIndex = data.pageIndex;
  56308. pdfManager.getPage(pageIndex).then(function (page) {
  56309. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56310. startWorkerTask(task);
  56311. var pageNum = pageIndex + 1;
  56312. var start = Date.now();
  56313. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56314. finishWorkerTask(task);
  56315. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56316. }, function (e) {
  56317. finishWorkerTask(task);
  56318. if (task.terminated) {
  56319. return;
  56320. }
  56321. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56322. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56323. var wrappedException;
  56324. if (typeof e === 'string') {
  56325. wrappedException = {
  56326. message: e,
  56327. stack: minimumStackMessage
  56328. };
  56329. } else if (typeof e === 'object') {
  56330. wrappedException = {
  56331. message: e.message || e.toString(),
  56332. stack: e.stack || minimumStackMessage
  56333. };
  56334. } else {
  56335. wrappedException = {
  56336. message: 'Unknown exception type: ' + typeof e,
  56337. stack: minimumStackMessage
  56338. };
  56339. }
  56340. handler.send('PageError', {
  56341. pageNum: pageNum,
  56342. error: wrappedException,
  56343. intent: data.intent
  56344. });
  56345. });
  56346. });
  56347. }, this);
  56348. handler.on('GetTextContent', function wphExtractText(data) {
  56349. var pageIndex = data.pageIndex;
  56350. var normalizeWhitespace = data.normalizeWhitespace;
  56351. var combineTextItems = data.combineTextItems;
  56352. return pdfManager.getPage(pageIndex).then(function (page) {
  56353. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56354. startWorkerTask(task);
  56355. var pageNum = pageIndex + 1;
  56356. var start = Date.now();
  56357. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56358. finishWorkerTask(task);
  56359. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56360. return textContent;
  56361. }, function (reason) {
  56362. finishWorkerTask(task);
  56363. if (task.terminated) {
  56364. return;
  56365. }
  56366. throw reason;
  56367. });
  56368. });
  56369. });
  56370. handler.on('Cleanup', function wphCleanup(data) {
  56371. return pdfManager.cleanup();
  56372. });
  56373. handler.on('Terminate', function wphTerminate(data) {
  56374. terminated = true;
  56375. if (pdfManager) {
  56376. pdfManager.terminate();
  56377. pdfManager = null;
  56378. }
  56379. if (cancelXHRs) {
  56380. cancelXHRs();
  56381. }
  56382. var waitOn = [];
  56383. WorkerTasks.forEach(function (task) {
  56384. waitOn.push(task.finished);
  56385. task.terminate();
  56386. });
  56387. return Promise.all(waitOn).then(function () {
  56388. handler.destroy();
  56389. handler = null;
  56390. });
  56391. });
  56392. handler.on('Ready', function wphReady(data) {
  56393. setupDoc(docParams);
  56394. docParams = null;
  56395. });
  56396. return workerHandlerName;
  56397. }
  56398. };
  56399. function initializeWorker() {
  56400. if (!('console' in globalScope)) {
  56401. var consoleTimer = {};
  56402. var workerConsole = {
  56403. log: function log() {
  56404. var args = Array.prototype.slice.call(arguments);
  56405. globalScope.postMessage({
  56406. targetName: 'main',
  56407. action: 'console_log',
  56408. data: args
  56409. });
  56410. },
  56411. error: function error() {
  56412. var args = Array.prototype.slice.call(arguments);
  56413. globalScope.postMessage({
  56414. targetName: 'main',
  56415. action: 'console_error',
  56416. data: args
  56417. });
  56418. throw 'pdf.js execution error';
  56419. },
  56420. time: function time(name) {
  56421. consoleTimer[name] = Date.now();
  56422. },
  56423. timeEnd: function timeEnd(name) {
  56424. var time = consoleTimer[name];
  56425. if (!time) {
  56426. error('Unknown timer name ' + name);
  56427. }
  56428. this.log('Timer:', name, Date.now() - time);
  56429. }
  56430. };
  56431. globalScope.console = workerConsole;
  56432. }
  56433. var handler = new MessageHandler('worker', 'main', self);
  56434. WorkerMessageHandler.setup(handler, self);
  56435. handler.send('ready', null);
  56436. }
  56437. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56438. initializeWorker();
  56439. }
  56440. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56441. exports.WorkerTask = WorkerTask;
  56442. exports.WorkerMessageHandler = WorkerMessageHandler;
  56443. }));
  56444. (function (root, factory) {
  56445. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56446. }(this, function (exports, sharedUtil, coreWorker) {
  56447. var OK_RESPONSE = 200;
  56448. var PARTIAL_CONTENT_RESPONSE = 206;
  56449. function NetworkManager(url, args) {
  56450. this.url = url;
  56451. args = args || {};
  56452. this.isHttp = /^https?:/i.test(url);
  56453. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56454. this.withCredentials = args.withCredentials || false;
  56455. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56456. return new XMLHttpRequest();
  56457. };
  56458. this.currXhrId = 0;
  56459. this.pendingRequests = Object.create(null);
  56460. this.loadedRequests = Object.create(null);
  56461. }
  56462. function getArrayBuffer(xhr) {
  56463. var data = xhr.response;
  56464. if (typeof data !== 'string') {
  56465. return data;
  56466. }
  56467. var length = data.length;
  56468. var array = new Uint8Array(length);
  56469. for (var i = 0; i < length; i++) {
  56470. array[i] = data.charCodeAt(i) & 0xFF;
  56471. }
  56472. return array.buffer;
  56473. }
  56474. var supportsMozChunked = function supportsMozChunkedClosure() {
  56475. try {
  56476. var x = new XMLHttpRequest();
  56477. x.open('GET', 'https://example.com');
  56478. x.responseType = 'moz-chunked-arraybuffer';
  56479. return x.responseType === 'moz-chunked-arraybuffer';
  56480. } catch (e) {
  56481. return false;
  56482. }
  56483. }();
  56484. NetworkManager.prototype = {
  56485. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56486. var args = {
  56487. begin: begin,
  56488. end: end
  56489. };
  56490. for (var prop in listeners) {
  56491. args[prop] = listeners[prop];
  56492. }
  56493. return this.request(args);
  56494. },
  56495. requestFull: function NetworkManager_requestFull(listeners) {
  56496. return this.request(listeners);
  56497. },
  56498. request: function NetworkManager_request(args) {
  56499. var xhr = this.getXhr();
  56500. var xhrId = this.currXhrId++;
  56501. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56502. xhr.open('GET', this.url);
  56503. xhr.withCredentials = this.withCredentials;
  56504. for (var property in this.httpHeaders) {
  56505. var value = this.httpHeaders[property];
  56506. if (typeof value === 'undefined') {
  56507. continue;
  56508. }
  56509. xhr.setRequestHeader(property, value);
  56510. }
  56511. if (this.isHttp && 'begin' in args && 'end' in args) {
  56512. var rangeStr = args.begin + '-' + (args.end - 1);
  56513. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56514. pendingRequest.expectedStatus = 206;
  56515. } else {
  56516. pendingRequest.expectedStatus = 200;
  56517. }
  56518. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56519. if (useMozChunkedLoading) {
  56520. xhr.responseType = 'moz-chunked-arraybuffer';
  56521. pendingRequest.onProgressiveData = args.onProgressiveData;
  56522. pendingRequest.mozChunked = true;
  56523. } else {
  56524. xhr.responseType = 'arraybuffer';
  56525. }
  56526. if (args.onError) {
  56527. xhr.onerror = function (evt) {
  56528. args.onError(xhr.status);
  56529. };
  56530. }
  56531. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56532. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56533. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56534. pendingRequest.onDone = args.onDone;
  56535. pendingRequest.onError = args.onError;
  56536. pendingRequest.onProgress = args.onProgress;
  56537. xhr.send(null);
  56538. return xhrId;
  56539. },
  56540. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56541. var pendingRequest = this.pendingRequests[xhrId];
  56542. if (!pendingRequest) {
  56543. return;
  56544. }
  56545. if (pendingRequest.mozChunked) {
  56546. var chunk = getArrayBuffer(pendingRequest.xhr);
  56547. pendingRequest.onProgressiveData(chunk);
  56548. }
  56549. var onProgress = pendingRequest.onProgress;
  56550. if (onProgress) {
  56551. onProgress(evt);
  56552. }
  56553. },
  56554. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56555. var pendingRequest = this.pendingRequests[xhrId];
  56556. if (!pendingRequest) {
  56557. return;
  56558. }
  56559. var xhr = pendingRequest.xhr;
  56560. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56561. pendingRequest.onHeadersReceived();
  56562. delete pendingRequest.onHeadersReceived;
  56563. }
  56564. if (xhr.readyState !== 4) {
  56565. return;
  56566. }
  56567. if (!(xhrId in this.pendingRequests)) {
  56568. return;
  56569. }
  56570. delete this.pendingRequests[xhrId];
  56571. if (xhr.status === 0 && this.isHttp) {
  56572. if (pendingRequest.onError) {
  56573. pendingRequest.onError(xhr.status);
  56574. }
  56575. return;
  56576. }
  56577. var xhrStatus = xhr.status || OK_RESPONSE;
  56578. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56579. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56580. if (pendingRequest.onError) {
  56581. pendingRequest.onError(xhr.status);
  56582. }
  56583. return;
  56584. }
  56585. this.loadedRequests[xhrId] = true;
  56586. var chunk = getArrayBuffer(xhr);
  56587. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56588. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56589. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56590. var begin = parseInt(matches[1], 10);
  56591. pendingRequest.onDone({
  56592. begin: begin,
  56593. chunk: chunk
  56594. });
  56595. } else if (pendingRequest.onProgressiveData) {
  56596. pendingRequest.onDone(null);
  56597. } else if (chunk) {
  56598. pendingRequest.onDone({
  56599. begin: 0,
  56600. chunk: chunk
  56601. });
  56602. } else if (pendingRequest.onError) {
  56603. pendingRequest.onError(xhr.status);
  56604. }
  56605. },
  56606. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56607. for (var xhrId in this.pendingRequests) {
  56608. return true;
  56609. }
  56610. return false;
  56611. },
  56612. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56613. return this.pendingRequests[xhrId].xhr;
  56614. },
  56615. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56616. return !!this.pendingRequests[xhrId].onProgressiveData;
  56617. },
  56618. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56619. return xhrId in this.pendingRequests;
  56620. },
  56621. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56622. return xhrId in this.loadedRequests;
  56623. },
  56624. abortAllRequests: function NetworkManager_abortAllRequests() {
  56625. for (var xhrId in this.pendingRequests) {
  56626. this.abortRequest(xhrId | 0);
  56627. }
  56628. },
  56629. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56630. var xhr = this.pendingRequests[xhrId].xhr;
  56631. delete this.pendingRequests[xhrId];
  56632. xhr.abort();
  56633. }
  56634. };
  56635. var assert = sharedUtil.assert;
  56636. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56637. var isInt = sharedUtil.isInt;
  56638. var MissingPDFException = sharedUtil.MissingPDFException;
  56639. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56640. function PDFNetworkStream(options) {
  56641. this._options = options;
  56642. var source = options.source;
  56643. this._manager = new NetworkManager(source.url, {
  56644. httpHeaders: source.httpHeaders,
  56645. withCredentials: source.withCredentials
  56646. });
  56647. this._rangeChunkSize = source.rangeChunkSize;
  56648. this._fullRequestReader = null;
  56649. this._rangeRequestReaders = [];
  56650. }
  56651. PDFNetworkStream.prototype = {
  56652. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56653. var i = this._rangeRequestReaders.indexOf(reader);
  56654. if (i >= 0) {
  56655. this._rangeRequestReaders.splice(i, 1);
  56656. }
  56657. },
  56658. getFullReader: function PDFNetworkStream_getFullReader() {
  56659. assert(!this._fullRequestReader);
  56660. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56661. return this._fullRequestReader;
  56662. },
  56663. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56664. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56665. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56666. this._rangeRequestReaders.push(reader);
  56667. return reader;
  56668. },
  56669. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56670. if (this._fullRequestReader) {
  56671. this._fullRequestReader.cancel(reason);
  56672. }
  56673. var readers = this._rangeRequestReaders.slice(0);
  56674. readers.forEach(function (reader) {
  56675. reader.cancel(reason);
  56676. });
  56677. }
  56678. };
  56679. function PDFNetworkStreamFullRequestReader(manager, options) {
  56680. this._manager = manager;
  56681. var source = options.source;
  56682. var args = {
  56683. onHeadersReceived: this._onHeadersReceived.bind(this),
  56684. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56685. onDone: this._onDone.bind(this),
  56686. onError: this._onError.bind(this),
  56687. onProgress: this._onProgress.bind(this)
  56688. };
  56689. this._url = source.url;
  56690. this._fullRequestId = manager.requestFull(args);
  56691. this._headersReceivedCapability = createPromiseCapability();
  56692. this._disableRange = options.disableRange || false;
  56693. this._contentLength = source.length;
  56694. this._rangeChunkSize = source.rangeChunkSize;
  56695. if (!this._rangeChunkSize && !this._disableRange) {
  56696. this._disableRange = true;
  56697. }
  56698. this._isStreamingSupported = false;
  56699. this._isRangeSupported = false;
  56700. this._cachedChunks = [];
  56701. this._requests = [];
  56702. this._done = false;
  56703. this._storedError = undefined;
  56704. this.onProgress = null;
  56705. }
  56706. PDFNetworkStreamFullRequestReader.prototype = {
  56707. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56708. if (this._disableRange) {
  56709. return false;
  56710. }
  56711. var networkManager = this._manager;
  56712. if (!networkManager.isHttp) {
  56713. return false;
  56714. }
  56715. var fullRequestXhrId = this._fullRequestId;
  56716. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56717. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56718. return false;
  56719. }
  56720. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56721. if (contentEncoding !== 'identity') {
  56722. return false;
  56723. }
  56724. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56725. length = parseInt(length, 10);
  56726. if (!isInt(length)) {
  56727. return false;
  56728. }
  56729. this._contentLength = length;
  56730. if (length <= 2 * this._rangeChunkSize) {
  56731. return false;
  56732. }
  56733. return true;
  56734. },
  56735. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56736. if (this._validateRangeRequestCapabilities()) {
  56737. this._isRangeSupported = true;
  56738. }
  56739. var networkManager = this._manager;
  56740. var fullRequestXhrId = this._fullRequestId;
  56741. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56742. this._isStreamingSupported = true;
  56743. } else if (this._isRangeSupported) {
  56744. networkManager.abortRequest(fullRequestXhrId);
  56745. }
  56746. this._headersReceivedCapability.resolve();
  56747. },
  56748. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56749. if (this._requests.length > 0) {
  56750. var requestCapability = this._requests.shift();
  56751. requestCapability.resolve({
  56752. value: chunk,
  56753. done: false
  56754. });
  56755. } else {
  56756. this._cachedChunks.push(chunk);
  56757. }
  56758. },
  56759. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56760. if (args) {
  56761. this._onProgressiveData(args.chunk);
  56762. }
  56763. this._done = true;
  56764. if (this._cachedChunks.length > 0) {
  56765. return;
  56766. }
  56767. this._requests.forEach(function (requestCapability) {
  56768. requestCapability.resolve({
  56769. value: undefined,
  56770. done: true
  56771. });
  56772. });
  56773. this._requests = [];
  56774. },
  56775. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  56776. var url = this._url;
  56777. var exception;
  56778. if (status === 404 || status === 0 && /^file:/.test(url)) {
  56779. exception = new MissingPDFException('Missing PDF "' + url + '".');
  56780. } else {
  56781. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  56782. }
  56783. this._storedError = exception;
  56784. this._headersReceivedCapability.reject(exception);
  56785. this._requests.forEach(function (requestCapability) {
  56786. requestCapability.reject(exception);
  56787. });
  56788. this._requests = [];
  56789. this._cachedChunks = [];
  56790. },
  56791. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  56792. if (this.onProgress) {
  56793. this.onProgress({
  56794. loaded: data.loaded,
  56795. total: data.lengthComputable ? data.total : this._contentLength
  56796. });
  56797. }
  56798. },
  56799. get isRangeSupported() {
  56800. return this._isRangeSupported;
  56801. },
  56802. get isStreamingSupported() {
  56803. return this._isStreamingSupported;
  56804. },
  56805. get contentLength() {
  56806. return this._contentLength;
  56807. },
  56808. get headersReady() {
  56809. return this._headersReceivedCapability.promise;
  56810. },
  56811. read: function PDFNetworkStreamFullRequestReader_read() {
  56812. if (this._storedError) {
  56813. return Promise.reject(this._storedError);
  56814. }
  56815. if (this._cachedChunks.length > 0) {
  56816. var chunk = this._cachedChunks.shift();
  56817. return Promise.resolve(chunk);
  56818. }
  56819. if (this._done) {
  56820. return Promise.resolve({
  56821. value: undefined,
  56822. done: true
  56823. });
  56824. }
  56825. var requestCapability = createPromiseCapability();
  56826. this._requests.push(requestCapability);
  56827. return requestCapability.promise;
  56828. },
  56829. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  56830. this._done = true;
  56831. this._headersReceivedCapability.reject(reason);
  56832. this._requests.forEach(function (requestCapability) {
  56833. requestCapability.resolve({
  56834. value: undefined,
  56835. done: true
  56836. });
  56837. });
  56838. this._requests = [];
  56839. if (this._manager.isPendingRequest(this._fullRequestId)) {
  56840. this._manager.abortRequest(this._fullRequestId);
  56841. }
  56842. this._fullRequestReader = null;
  56843. }
  56844. };
  56845. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  56846. this._manager = manager;
  56847. var args = {
  56848. onDone: this._onDone.bind(this),
  56849. onProgress: this._onProgress.bind(this)
  56850. };
  56851. this._requestId = manager.requestRange(begin, end, args);
  56852. this._requests = [];
  56853. this._queuedChunk = null;
  56854. this._done = false;
  56855. this.onProgress = null;
  56856. this.onClosed = null;
  56857. }
  56858. PDFNetworkStreamRangeRequestReader.prototype = {
  56859. _close: function PDFNetworkStreamRangeRequestReader_close() {
  56860. if (this.onClosed) {
  56861. this.onClosed(this);
  56862. }
  56863. },
  56864. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  56865. var chunk = data.chunk;
  56866. if (this._requests.length > 0) {
  56867. var requestCapability = this._requests.shift();
  56868. requestCapability.resolve({
  56869. value: chunk,
  56870. done: false
  56871. });
  56872. } else {
  56873. this._queuedChunk = chunk;
  56874. }
  56875. this._done = true;
  56876. this._requests.forEach(function (requestCapability) {
  56877. requestCapability.resolve({
  56878. value: undefined,
  56879. done: true
  56880. });
  56881. });
  56882. this._requests = [];
  56883. this._close();
  56884. },
  56885. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  56886. if (!this.isStreamingSupported && this.onProgress) {
  56887. this.onProgress({ loaded: evt.loaded });
  56888. }
  56889. },
  56890. get isStreamingSupported() {
  56891. return false;
  56892. },
  56893. read: function PDFNetworkStreamRangeRequestReader_read() {
  56894. if (this._queuedChunk !== null) {
  56895. var chunk = this._queuedChunk;
  56896. this._queuedChunk = null;
  56897. return Promise.resolve({
  56898. value: chunk,
  56899. done: false
  56900. });
  56901. }
  56902. if (this._done) {
  56903. return Promise.resolve({
  56904. value: undefined,
  56905. done: true
  56906. });
  56907. }
  56908. var requestCapability = createPromiseCapability();
  56909. this._requests.push(requestCapability);
  56910. return requestCapability.promise;
  56911. },
  56912. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  56913. this._done = true;
  56914. this._requests.forEach(function (requestCapability) {
  56915. requestCapability.resolve({
  56916. value: undefined,
  56917. done: true
  56918. });
  56919. });
  56920. this._requests = [];
  56921. if (this._manager.isPendingRequest(this._requestId)) {
  56922. this._manager.abortRequest(this._requestId);
  56923. }
  56924. this._close();
  56925. }
  56926. };
  56927. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  56928. exports.PDFNetworkStream = PDFNetworkStream;
  56929. exports.NetworkManager = NetworkManager;
  56930. }));
  56931. }.call(pdfjsLibs));
  56932. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  56933. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  56934. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  56935. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  56936. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  56937. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  56938. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  56939. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56940. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  56941. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  56942. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  56943. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  56944. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  56945. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  56946. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  56947. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56948. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  56949. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  56950. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  56951. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  56952. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  56953. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  56954. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56955. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  56956. }));