pdf.combined.js 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955
  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.324';
  27. var pdfjsBuild = 'f6a8d9c';
  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, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24545. var definitions = document.createElementNS(NS, 'svg:defs');
  24546. svg.appendChild(definitions);
  24547. this.defs = definitions;
  24548. var rootGroup = document.createElementNS(NS, 'svg:g');
  24549. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24550. svg.appendChild(rootGroup);
  24551. this.svg = rootGroup;
  24552. return svg;
  24553. },
  24554. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24555. if (!this.current.clipGroup) {
  24556. var clipGroup = document.createElementNS(NS, 'svg:g');
  24557. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24558. this.svg.appendChild(clipGroup);
  24559. this.current.clipGroup = clipGroup;
  24560. }
  24561. return this.current.clipGroup;
  24562. },
  24563. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24564. if (!this.tgrp) {
  24565. this.tgrp = document.createElementNS(NS, 'svg:g');
  24566. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24567. if (this.current.activeClipUrl) {
  24568. this._ensureClipGroup().appendChild(this.tgrp);
  24569. } else {
  24570. this.svg.appendChild(this.tgrp);
  24571. }
  24572. }
  24573. return this.tgrp;
  24574. }
  24575. };
  24576. return SVGGraphics;
  24577. }();
  24578. exports.SVGGraphics = SVGGraphics;
  24579. }));
  24580. (function (root, factory) {
  24581. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24582. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24583. var Util = sharedUtil.Util;
  24584. var error = sharedUtil.error;
  24585. var info = sharedUtil.info;
  24586. var isInt = sharedUtil.isInt;
  24587. var isArray = sharedUtil.isArray;
  24588. var createObjectURL = sharedUtil.createObjectURL;
  24589. var shadow = sharedUtil.shadow;
  24590. var warn = sharedUtil.warn;
  24591. var isSpace = sharedUtil.isSpace;
  24592. var Dict = corePrimitives.Dict;
  24593. var isDict = corePrimitives.isDict;
  24594. var isStream = corePrimitives.isStream;
  24595. var Jbig2Image = coreJbig2.Jbig2Image;
  24596. var JpegImage = coreJpg.JpegImage;
  24597. var JpxImage = coreJpx.JpxImage;
  24598. var Stream = function StreamClosure() {
  24599. function Stream(arrayBuffer, start, length, dict) {
  24600. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24601. this.start = start || 0;
  24602. this.pos = this.start;
  24603. this.end = start + length || this.bytes.length;
  24604. this.dict = dict;
  24605. }
  24606. Stream.prototype = {
  24607. get length() {
  24608. return this.end - this.start;
  24609. },
  24610. get isEmpty() {
  24611. return this.length === 0;
  24612. },
  24613. getByte: function Stream_getByte() {
  24614. if (this.pos >= this.end) {
  24615. return -1;
  24616. }
  24617. return this.bytes[this.pos++];
  24618. },
  24619. getUint16: function Stream_getUint16() {
  24620. var b0 = this.getByte();
  24621. var b1 = this.getByte();
  24622. if (b0 === -1 || b1 === -1) {
  24623. return -1;
  24624. }
  24625. return (b0 << 8) + b1;
  24626. },
  24627. getInt32: function Stream_getInt32() {
  24628. var b0 = this.getByte();
  24629. var b1 = this.getByte();
  24630. var b2 = this.getByte();
  24631. var b3 = this.getByte();
  24632. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24633. },
  24634. getBytes: function Stream_getBytes(length) {
  24635. var bytes = this.bytes;
  24636. var pos = this.pos;
  24637. var strEnd = this.end;
  24638. if (!length) {
  24639. return bytes.subarray(pos, strEnd);
  24640. }
  24641. var end = pos + length;
  24642. if (end > strEnd) {
  24643. end = strEnd;
  24644. }
  24645. this.pos = end;
  24646. return bytes.subarray(pos, end);
  24647. },
  24648. peekByte: function Stream_peekByte() {
  24649. var peekedByte = this.getByte();
  24650. this.pos--;
  24651. return peekedByte;
  24652. },
  24653. peekBytes: function Stream_peekBytes(length) {
  24654. var bytes = this.getBytes(length);
  24655. this.pos -= bytes.length;
  24656. return bytes;
  24657. },
  24658. skip: function Stream_skip(n) {
  24659. if (!n) {
  24660. n = 1;
  24661. }
  24662. this.pos += n;
  24663. },
  24664. reset: function Stream_reset() {
  24665. this.pos = this.start;
  24666. },
  24667. moveStart: function Stream_moveStart() {
  24668. this.start = this.pos;
  24669. },
  24670. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24671. return new Stream(this.bytes.buffer, start, length, dict);
  24672. },
  24673. isStream: true
  24674. };
  24675. return Stream;
  24676. }();
  24677. var StringStream = function StringStreamClosure() {
  24678. function StringStream(str) {
  24679. var length = str.length;
  24680. var bytes = new Uint8Array(length);
  24681. for (var n = 0; n < length; ++n) {
  24682. bytes[n] = str.charCodeAt(n);
  24683. }
  24684. Stream.call(this, bytes);
  24685. }
  24686. StringStream.prototype = Stream.prototype;
  24687. return StringStream;
  24688. }();
  24689. var DecodeStream = function DecodeStreamClosure() {
  24690. var emptyBuffer = new Uint8Array(0);
  24691. function DecodeStream(maybeMinBufferLength) {
  24692. this.pos = 0;
  24693. this.bufferLength = 0;
  24694. this.eof = false;
  24695. this.buffer = emptyBuffer;
  24696. this.minBufferLength = 512;
  24697. if (maybeMinBufferLength) {
  24698. while (this.minBufferLength < maybeMinBufferLength) {
  24699. this.minBufferLength *= 2;
  24700. }
  24701. }
  24702. }
  24703. DecodeStream.prototype = {
  24704. get isEmpty() {
  24705. while (!this.eof && this.bufferLength === 0) {
  24706. this.readBlock();
  24707. }
  24708. return this.bufferLength === 0;
  24709. },
  24710. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24711. var buffer = this.buffer;
  24712. if (requested <= buffer.byteLength) {
  24713. return buffer;
  24714. }
  24715. var size = this.minBufferLength;
  24716. while (size < requested) {
  24717. size *= 2;
  24718. }
  24719. var buffer2 = new Uint8Array(size);
  24720. buffer2.set(buffer);
  24721. return this.buffer = buffer2;
  24722. },
  24723. getByte: function DecodeStream_getByte() {
  24724. var pos = this.pos;
  24725. while (this.bufferLength <= pos) {
  24726. if (this.eof) {
  24727. return -1;
  24728. }
  24729. this.readBlock();
  24730. }
  24731. return this.buffer[this.pos++];
  24732. },
  24733. getUint16: function DecodeStream_getUint16() {
  24734. var b0 = this.getByte();
  24735. var b1 = this.getByte();
  24736. if (b0 === -1 || b1 === -1) {
  24737. return -1;
  24738. }
  24739. return (b0 << 8) + b1;
  24740. },
  24741. getInt32: function DecodeStream_getInt32() {
  24742. var b0 = this.getByte();
  24743. var b1 = this.getByte();
  24744. var b2 = this.getByte();
  24745. var b3 = this.getByte();
  24746. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24747. },
  24748. getBytes: function DecodeStream_getBytes(length) {
  24749. var end, pos = this.pos;
  24750. if (length) {
  24751. this.ensureBuffer(pos + length);
  24752. end = pos + length;
  24753. while (!this.eof && this.bufferLength < end) {
  24754. this.readBlock();
  24755. }
  24756. var bufEnd = this.bufferLength;
  24757. if (end > bufEnd) {
  24758. end = bufEnd;
  24759. }
  24760. } else {
  24761. while (!this.eof) {
  24762. this.readBlock();
  24763. }
  24764. end = this.bufferLength;
  24765. }
  24766. this.pos = end;
  24767. return this.buffer.subarray(pos, end);
  24768. },
  24769. peekByte: function DecodeStream_peekByte() {
  24770. var peekedByte = this.getByte();
  24771. this.pos--;
  24772. return peekedByte;
  24773. },
  24774. peekBytes: function DecodeStream_peekBytes(length) {
  24775. var bytes = this.getBytes(length);
  24776. this.pos -= bytes.length;
  24777. return bytes;
  24778. },
  24779. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24780. var end = start + length;
  24781. while (this.bufferLength <= end && !this.eof) {
  24782. this.readBlock();
  24783. }
  24784. return new Stream(this.buffer, start, length, dict);
  24785. },
  24786. skip: function DecodeStream_skip(n) {
  24787. if (!n) {
  24788. n = 1;
  24789. }
  24790. this.pos += n;
  24791. },
  24792. reset: function DecodeStream_reset() {
  24793. this.pos = 0;
  24794. },
  24795. getBaseStreams: function DecodeStream_getBaseStreams() {
  24796. if (this.str && this.str.getBaseStreams) {
  24797. return this.str.getBaseStreams();
  24798. }
  24799. return [];
  24800. }
  24801. };
  24802. return DecodeStream;
  24803. }();
  24804. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24805. function StreamsSequenceStream(streams) {
  24806. this.streams = streams;
  24807. DecodeStream.call(this, null);
  24808. }
  24809. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24810. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24811. var streams = this.streams;
  24812. if (streams.length === 0) {
  24813. this.eof = true;
  24814. return;
  24815. }
  24816. var stream = streams.shift();
  24817. var chunk = stream.getBytes();
  24818. var bufferLength = this.bufferLength;
  24819. var newLength = bufferLength + chunk.length;
  24820. var buffer = this.ensureBuffer(newLength);
  24821. buffer.set(chunk, bufferLength);
  24822. this.bufferLength = newLength;
  24823. };
  24824. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24825. var baseStreams = [];
  24826. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24827. var stream = this.streams[i];
  24828. if (stream.getBaseStreams) {
  24829. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24830. }
  24831. }
  24832. return baseStreams;
  24833. };
  24834. return StreamsSequenceStream;
  24835. }();
  24836. var FlateStream = function FlateStreamClosure() {
  24837. var codeLenCodeMap = new Int32Array([
  24838. 16,
  24839. 17,
  24840. 18,
  24841. 0,
  24842. 8,
  24843. 7,
  24844. 9,
  24845. 6,
  24846. 10,
  24847. 5,
  24848. 11,
  24849. 4,
  24850. 12,
  24851. 3,
  24852. 13,
  24853. 2,
  24854. 14,
  24855. 1,
  24856. 15
  24857. ]);
  24858. var lengthDecode = new Int32Array([
  24859. 0x00003,
  24860. 0x00004,
  24861. 0x00005,
  24862. 0x00006,
  24863. 0x00007,
  24864. 0x00008,
  24865. 0x00009,
  24866. 0x0000a,
  24867. 0x1000b,
  24868. 0x1000d,
  24869. 0x1000f,
  24870. 0x10011,
  24871. 0x20013,
  24872. 0x20017,
  24873. 0x2001b,
  24874. 0x2001f,
  24875. 0x30023,
  24876. 0x3002b,
  24877. 0x30033,
  24878. 0x3003b,
  24879. 0x40043,
  24880. 0x40053,
  24881. 0x40063,
  24882. 0x40073,
  24883. 0x50083,
  24884. 0x500a3,
  24885. 0x500c3,
  24886. 0x500e3,
  24887. 0x00102,
  24888. 0x00102,
  24889. 0x00102
  24890. ]);
  24891. var distDecode = new Int32Array([
  24892. 0x00001,
  24893. 0x00002,
  24894. 0x00003,
  24895. 0x00004,
  24896. 0x10005,
  24897. 0x10007,
  24898. 0x20009,
  24899. 0x2000d,
  24900. 0x30011,
  24901. 0x30019,
  24902. 0x40021,
  24903. 0x40031,
  24904. 0x50041,
  24905. 0x50061,
  24906. 0x60081,
  24907. 0x600c1,
  24908. 0x70101,
  24909. 0x70181,
  24910. 0x80201,
  24911. 0x80301,
  24912. 0x90401,
  24913. 0x90601,
  24914. 0xa0801,
  24915. 0xa0c01,
  24916. 0xb1001,
  24917. 0xb1801,
  24918. 0xc2001,
  24919. 0xc3001,
  24920. 0xd4001,
  24921. 0xd6001
  24922. ]);
  24923. var fixedLitCodeTab = [
  24924. new Int32Array([
  24925. 0x70100,
  24926. 0x80050,
  24927. 0x80010,
  24928. 0x80118,
  24929. 0x70110,
  24930. 0x80070,
  24931. 0x80030,
  24932. 0x900c0,
  24933. 0x70108,
  24934. 0x80060,
  24935. 0x80020,
  24936. 0x900a0,
  24937. 0x80000,
  24938. 0x80080,
  24939. 0x80040,
  24940. 0x900e0,
  24941. 0x70104,
  24942. 0x80058,
  24943. 0x80018,
  24944. 0x90090,
  24945. 0x70114,
  24946. 0x80078,
  24947. 0x80038,
  24948. 0x900d0,
  24949. 0x7010c,
  24950. 0x80068,
  24951. 0x80028,
  24952. 0x900b0,
  24953. 0x80008,
  24954. 0x80088,
  24955. 0x80048,
  24956. 0x900f0,
  24957. 0x70102,
  24958. 0x80054,
  24959. 0x80014,
  24960. 0x8011c,
  24961. 0x70112,
  24962. 0x80074,
  24963. 0x80034,
  24964. 0x900c8,
  24965. 0x7010a,
  24966. 0x80064,
  24967. 0x80024,
  24968. 0x900a8,
  24969. 0x80004,
  24970. 0x80084,
  24971. 0x80044,
  24972. 0x900e8,
  24973. 0x70106,
  24974. 0x8005c,
  24975. 0x8001c,
  24976. 0x90098,
  24977. 0x70116,
  24978. 0x8007c,
  24979. 0x8003c,
  24980. 0x900d8,
  24981. 0x7010e,
  24982. 0x8006c,
  24983. 0x8002c,
  24984. 0x900b8,
  24985. 0x8000c,
  24986. 0x8008c,
  24987. 0x8004c,
  24988. 0x900f8,
  24989. 0x70101,
  24990. 0x80052,
  24991. 0x80012,
  24992. 0x8011a,
  24993. 0x70111,
  24994. 0x80072,
  24995. 0x80032,
  24996. 0x900c4,
  24997. 0x70109,
  24998. 0x80062,
  24999. 0x80022,
  25000. 0x900a4,
  25001. 0x80002,
  25002. 0x80082,
  25003. 0x80042,
  25004. 0x900e4,
  25005. 0x70105,
  25006. 0x8005a,
  25007. 0x8001a,
  25008. 0x90094,
  25009. 0x70115,
  25010. 0x8007a,
  25011. 0x8003a,
  25012. 0x900d4,
  25013. 0x7010d,
  25014. 0x8006a,
  25015. 0x8002a,
  25016. 0x900b4,
  25017. 0x8000a,
  25018. 0x8008a,
  25019. 0x8004a,
  25020. 0x900f4,
  25021. 0x70103,
  25022. 0x80056,
  25023. 0x80016,
  25024. 0x8011e,
  25025. 0x70113,
  25026. 0x80076,
  25027. 0x80036,
  25028. 0x900cc,
  25029. 0x7010b,
  25030. 0x80066,
  25031. 0x80026,
  25032. 0x900ac,
  25033. 0x80006,
  25034. 0x80086,
  25035. 0x80046,
  25036. 0x900ec,
  25037. 0x70107,
  25038. 0x8005e,
  25039. 0x8001e,
  25040. 0x9009c,
  25041. 0x70117,
  25042. 0x8007e,
  25043. 0x8003e,
  25044. 0x900dc,
  25045. 0x7010f,
  25046. 0x8006e,
  25047. 0x8002e,
  25048. 0x900bc,
  25049. 0x8000e,
  25050. 0x8008e,
  25051. 0x8004e,
  25052. 0x900fc,
  25053. 0x70100,
  25054. 0x80051,
  25055. 0x80011,
  25056. 0x80119,
  25057. 0x70110,
  25058. 0x80071,
  25059. 0x80031,
  25060. 0x900c2,
  25061. 0x70108,
  25062. 0x80061,
  25063. 0x80021,
  25064. 0x900a2,
  25065. 0x80001,
  25066. 0x80081,
  25067. 0x80041,
  25068. 0x900e2,
  25069. 0x70104,
  25070. 0x80059,
  25071. 0x80019,
  25072. 0x90092,
  25073. 0x70114,
  25074. 0x80079,
  25075. 0x80039,
  25076. 0x900d2,
  25077. 0x7010c,
  25078. 0x80069,
  25079. 0x80029,
  25080. 0x900b2,
  25081. 0x80009,
  25082. 0x80089,
  25083. 0x80049,
  25084. 0x900f2,
  25085. 0x70102,
  25086. 0x80055,
  25087. 0x80015,
  25088. 0x8011d,
  25089. 0x70112,
  25090. 0x80075,
  25091. 0x80035,
  25092. 0x900ca,
  25093. 0x7010a,
  25094. 0x80065,
  25095. 0x80025,
  25096. 0x900aa,
  25097. 0x80005,
  25098. 0x80085,
  25099. 0x80045,
  25100. 0x900ea,
  25101. 0x70106,
  25102. 0x8005d,
  25103. 0x8001d,
  25104. 0x9009a,
  25105. 0x70116,
  25106. 0x8007d,
  25107. 0x8003d,
  25108. 0x900da,
  25109. 0x7010e,
  25110. 0x8006d,
  25111. 0x8002d,
  25112. 0x900ba,
  25113. 0x8000d,
  25114. 0x8008d,
  25115. 0x8004d,
  25116. 0x900fa,
  25117. 0x70101,
  25118. 0x80053,
  25119. 0x80013,
  25120. 0x8011b,
  25121. 0x70111,
  25122. 0x80073,
  25123. 0x80033,
  25124. 0x900c6,
  25125. 0x70109,
  25126. 0x80063,
  25127. 0x80023,
  25128. 0x900a6,
  25129. 0x80003,
  25130. 0x80083,
  25131. 0x80043,
  25132. 0x900e6,
  25133. 0x70105,
  25134. 0x8005b,
  25135. 0x8001b,
  25136. 0x90096,
  25137. 0x70115,
  25138. 0x8007b,
  25139. 0x8003b,
  25140. 0x900d6,
  25141. 0x7010d,
  25142. 0x8006b,
  25143. 0x8002b,
  25144. 0x900b6,
  25145. 0x8000b,
  25146. 0x8008b,
  25147. 0x8004b,
  25148. 0x900f6,
  25149. 0x70103,
  25150. 0x80057,
  25151. 0x80017,
  25152. 0x8011f,
  25153. 0x70113,
  25154. 0x80077,
  25155. 0x80037,
  25156. 0x900ce,
  25157. 0x7010b,
  25158. 0x80067,
  25159. 0x80027,
  25160. 0x900ae,
  25161. 0x80007,
  25162. 0x80087,
  25163. 0x80047,
  25164. 0x900ee,
  25165. 0x70107,
  25166. 0x8005f,
  25167. 0x8001f,
  25168. 0x9009e,
  25169. 0x70117,
  25170. 0x8007f,
  25171. 0x8003f,
  25172. 0x900de,
  25173. 0x7010f,
  25174. 0x8006f,
  25175. 0x8002f,
  25176. 0x900be,
  25177. 0x8000f,
  25178. 0x8008f,
  25179. 0x8004f,
  25180. 0x900fe,
  25181. 0x70100,
  25182. 0x80050,
  25183. 0x80010,
  25184. 0x80118,
  25185. 0x70110,
  25186. 0x80070,
  25187. 0x80030,
  25188. 0x900c1,
  25189. 0x70108,
  25190. 0x80060,
  25191. 0x80020,
  25192. 0x900a1,
  25193. 0x80000,
  25194. 0x80080,
  25195. 0x80040,
  25196. 0x900e1,
  25197. 0x70104,
  25198. 0x80058,
  25199. 0x80018,
  25200. 0x90091,
  25201. 0x70114,
  25202. 0x80078,
  25203. 0x80038,
  25204. 0x900d1,
  25205. 0x7010c,
  25206. 0x80068,
  25207. 0x80028,
  25208. 0x900b1,
  25209. 0x80008,
  25210. 0x80088,
  25211. 0x80048,
  25212. 0x900f1,
  25213. 0x70102,
  25214. 0x80054,
  25215. 0x80014,
  25216. 0x8011c,
  25217. 0x70112,
  25218. 0x80074,
  25219. 0x80034,
  25220. 0x900c9,
  25221. 0x7010a,
  25222. 0x80064,
  25223. 0x80024,
  25224. 0x900a9,
  25225. 0x80004,
  25226. 0x80084,
  25227. 0x80044,
  25228. 0x900e9,
  25229. 0x70106,
  25230. 0x8005c,
  25231. 0x8001c,
  25232. 0x90099,
  25233. 0x70116,
  25234. 0x8007c,
  25235. 0x8003c,
  25236. 0x900d9,
  25237. 0x7010e,
  25238. 0x8006c,
  25239. 0x8002c,
  25240. 0x900b9,
  25241. 0x8000c,
  25242. 0x8008c,
  25243. 0x8004c,
  25244. 0x900f9,
  25245. 0x70101,
  25246. 0x80052,
  25247. 0x80012,
  25248. 0x8011a,
  25249. 0x70111,
  25250. 0x80072,
  25251. 0x80032,
  25252. 0x900c5,
  25253. 0x70109,
  25254. 0x80062,
  25255. 0x80022,
  25256. 0x900a5,
  25257. 0x80002,
  25258. 0x80082,
  25259. 0x80042,
  25260. 0x900e5,
  25261. 0x70105,
  25262. 0x8005a,
  25263. 0x8001a,
  25264. 0x90095,
  25265. 0x70115,
  25266. 0x8007a,
  25267. 0x8003a,
  25268. 0x900d5,
  25269. 0x7010d,
  25270. 0x8006a,
  25271. 0x8002a,
  25272. 0x900b5,
  25273. 0x8000a,
  25274. 0x8008a,
  25275. 0x8004a,
  25276. 0x900f5,
  25277. 0x70103,
  25278. 0x80056,
  25279. 0x80016,
  25280. 0x8011e,
  25281. 0x70113,
  25282. 0x80076,
  25283. 0x80036,
  25284. 0x900cd,
  25285. 0x7010b,
  25286. 0x80066,
  25287. 0x80026,
  25288. 0x900ad,
  25289. 0x80006,
  25290. 0x80086,
  25291. 0x80046,
  25292. 0x900ed,
  25293. 0x70107,
  25294. 0x8005e,
  25295. 0x8001e,
  25296. 0x9009d,
  25297. 0x70117,
  25298. 0x8007e,
  25299. 0x8003e,
  25300. 0x900dd,
  25301. 0x7010f,
  25302. 0x8006e,
  25303. 0x8002e,
  25304. 0x900bd,
  25305. 0x8000e,
  25306. 0x8008e,
  25307. 0x8004e,
  25308. 0x900fd,
  25309. 0x70100,
  25310. 0x80051,
  25311. 0x80011,
  25312. 0x80119,
  25313. 0x70110,
  25314. 0x80071,
  25315. 0x80031,
  25316. 0x900c3,
  25317. 0x70108,
  25318. 0x80061,
  25319. 0x80021,
  25320. 0x900a3,
  25321. 0x80001,
  25322. 0x80081,
  25323. 0x80041,
  25324. 0x900e3,
  25325. 0x70104,
  25326. 0x80059,
  25327. 0x80019,
  25328. 0x90093,
  25329. 0x70114,
  25330. 0x80079,
  25331. 0x80039,
  25332. 0x900d3,
  25333. 0x7010c,
  25334. 0x80069,
  25335. 0x80029,
  25336. 0x900b3,
  25337. 0x80009,
  25338. 0x80089,
  25339. 0x80049,
  25340. 0x900f3,
  25341. 0x70102,
  25342. 0x80055,
  25343. 0x80015,
  25344. 0x8011d,
  25345. 0x70112,
  25346. 0x80075,
  25347. 0x80035,
  25348. 0x900cb,
  25349. 0x7010a,
  25350. 0x80065,
  25351. 0x80025,
  25352. 0x900ab,
  25353. 0x80005,
  25354. 0x80085,
  25355. 0x80045,
  25356. 0x900eb,
  25357. 0x70106,
  25358. 0x8005d,
  25359. 0x8001d,
  25360. 0x9009b,
  25361. 0x70116,
  25362. 0x8007d,
  25363. 0x8003d,
  25364. 0x900db,
  25365. 0x7010e,
  25366. 0x8006d,
  25367. 0x8002d,
  25368. 0x900bb,
  25369. 0x8000d,
  25370. 0x8008d,
  25371. 0x8004d,
  25372. 0x900fb,
  25373. 0x70101,
  25374. 0x80053,
  25375. 0x80013,
  25376. 0x8011b,
  25377. 0x70111,
  25378. 0x80073,
  25379. 0x80033,
  25380. 0x900c7,
  25381. 0x70109,
  25382. 0x80063,
  25383. 0x80023,
  25384. 0x900a7,
  25385. 0x80003,
  25386. 0x80083,
  25387. 0x80043,
  25388. 0x900e7,
  25389. 0x70105,
  25390. 0x8005b,
  25391. 0x8001b,
  25392. 0x90097,
  25393. 0x70115,
  25394. 0x8007b,
  25395. 0x8003b,
  25396. 0x900d7,
  25397. 0x7010d,
  25398. 0x8006b,
  25399. 0x8002b,
  25400. 0x900b7,
  25401. 0x8000b,
  25402. 0x8008b,
  25403. 0x8004b,
  25404. 0x900f7,
  25405. 0x70103,
  25406. 0x80057,
  25407. 0x80017,
  25408. 0x8011f,
  25409. 0x70113,
  25410. 0x80077,
  25411. 0x80037,
  25412. 0x900cf,
  25413. 0x7010b,
  25414. 0x80067,
  25415. 0x80027,
  25416. 0x900af,
  25417. 0x80007,
  25418. 0x80087,
  25419. 0x80047,
  25420. 0x900ef,
  25421. 0x70107,
  25422. 0x8005f,
  25423. 0x8001f,
  25424. 0x9009f,
  25425. 0x70117,
  25426. 0x8007f,
  25427. 0x8003f,
  25428. 0x900df,
  25429. 0x7010f,
  25430. 0x8006f,
  25431. 0x8002f,
  25432. 0x900bf,
  25433. 0x8000f,
  25434. 0x8008f,
  25435. 0x8004f,
  25436. 0x900ff
  25437. ]),
  25438. 9
  25439. ];
  25440. var fixedDistCodeTab = [
  25441. new Int32Array([
  25442. 0x50000,
  25443. 0x50010,
  25444. 0x50008,
  25445. 0x50018,
  25446. 0x50004,
  25447. 0x50014,
  25448. 0x5000c,
  25449. 0x5001c,
  25450. 0x50002,
  25451. 0x50012,
  25452. 0x5000a,
  25453. 0x5001a,
  25454. 0x50006,
  25455. 0x50016,
  25456. 0x5000e,
  25457. 0x00000,
  25458. 0x50001,
  25459. 0x50011,
  25460. 0x50009,
  25461. 0x50019,
  25462. 0x50005,
  25463. 0x50015,
  25464. 0x5000d,
  25465. 0x5001d,
  25466. 0x50003,
  25467. 0x50013,
  25468. 0x5000b,
  25469. 0x5001b,
  25470. 0x50007,
  25471. 0x50017,
  25472. 0x5000f,
  25473. 0x00000
  25474. ]),
  25475. 5
  25476. ];
  25477. function FlateStream(str, maybeLength) {
  25478. this.str = str;
  25479. this.dict = str.dict;
  25480. var cmf = str.getByte();
  25481. var flg = str.getByte();
  25482. if (cmf === -1 || flg === -1) {
  25483. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25484. }
  25485. if ((cmf & 0x0f) !== 0x08) {
  25486. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25487. }
  25488. if (((cmf << 8) + flg) % 31 !== 0) {
  25489. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25490. }
  25491. if (flg & 0x20) {
  25492. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25493. }
  25494. this.codeSize = 0;
  25495. this.codeBuf = 0;
  25496. DecodeStream.call(this, maybeLength);
  25497. }
  25498. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25499. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25500. var str = this.str;
  25501. var codeSize = this.codeSize;
  25502. var codeBuf = this.codeBuf;
  25503. var b;
  25504. while (codeSize < bits) {
  25505. if ((b = str.getByte()) === -1) {
  25506. error('Bad encoding in flate stream');
  25507. }
  25508. codeBuf |= b << codeSize;
  25509. codeSize += 8;
  25510. }
  25511. b = codeBuf & (1 << bits) - 1;
  25512. this.codeBuf = codeBuf >> bits;
  25513. this.codeSize = codeSize -= bits;
  25514. return b;
  25515. };
  25516. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25517. var str = this.str;
  25518. var codes = table[0];
  25519. var maxLen = table[1];
  25520. var codeSize = this.codeSize;
  25521. var codeBuf = this.codeBuf;
  25522. var b;
  25523. while (codeSize < maxLen) {
  25524. if ((b = str.getByte()) === -1) {
  25525. break;
  25526. }
  25527. codeBuf |= b << codeSize;
  25528. codeSize += 8;
  25529. }
  25530. var code = codes[codeBuf & (1 << maxLen) - 1];
  25531. var codeLen = code >> 16;
  25532. var codeVal = code & 0xffff;
  25533. if (codeLen < 1 || codeSize < codeLen) {
  25534. error('Bad encoding in flate stream');
  25535. }
  25536. this.codeBuf = codeBuf >> codeLen;
  25537. this.codeSize = codeSize - codeLen;
  25538. return codeVal;
  25539. };
  25540. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25541. var n = lengths.length;
  25542. var maxLen = 0;
  25543. var i;
  25544. for (i = 0; i < n; ++i) {
  25545. if (lengths[i] > maxLen) {
  25546. maxLen = lengths[i];
  25547. }
  25548. }
  25549. var size = 1 << maxLen;
  25550. var codes = new Int32Array(size);
  25551. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25552. for (var val = 0; val < n; ++val) {
  25553. if (lengths[val] === len) {
  25554. var code2 = 0;
  25555. var t = code;
  25556. for (i = 0; i < len; ++i) {
  25557. code2 = code2 << 1 | t & 1;
  25558. t >>= 1;
  25559. }
  25560. for (i = code2; i < size; i += skip) {
  25561. codes[i] = len << 16 | val;
  25562. }
  25563. ++code;
  25564. }
  25565. }
  25566. }
  25567. return [
  25568. codes,
  25569. maxLen
  25570. ];
  25571. };
  25572. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25573. var buffer, len;
  25574. var str = this.str;
  25575. var hdr = this.getBits(3);
  25576. if (hdr & 1) {
  25577. this.eof = true;
  25578. }
  25579. hdr >>= 1;
  25580. if (hdr === 0) {
  25581. var b;
  25582. if ((b = str.getByte()) === -1) {
  25583. error('Bad block header in flate stream');
  25584. }
  25585. var blockLen = b;
  25586. if ((b = str.getByte()) === -1) {
  25587. error('Bad block header in flate stream');
  25588. }
  25589. blockLen |= b << 8;
  25590. if ((b = str.getByte()) === -1) {
  25591. error('Bad block header in flate stream');
  25592. }
  25593. var check = b;
  25594. if ((b = str.getByte()) === -1) {
  25595. error('Bad block header in flate stream');
  25596. }
  25597. check |= b << 8;
  25598. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25599. error('Bad uncompressed block length in flate stream');
  25600. }
  25601. this.codeBuf = 0;
  25602. this.codeSize = 0;
  25603. var bufferLength = this.bufferLength;
  25604. buffer = this.ensureBuffer(bufferLength + blockLen);
  25605. var end = bufferLength + blockLen;
  25606. this.bufferLength = end;
  25607. if (blockLen === 0) {
  25608. if (str.peekByte() === -1) {
  25609. this.eof = true;
  25610. }
  25611. } else {
  25612. for (var n = bufferLength; n < end; ++n) {
  25613. if ((b = str.getByte()) === -1) {
  25614. this.eof = true;
  25615. break;
  25616. }
  25617. buffer[n] = b;
  25618. }
  25619. }
  25620. return;
  25621. }
  25622. var litCodeTable;
  25623. var distCodeTable;
  25624. if (hdr === 1) {
  25625. litCodeTable = fixedLitCodeTab;
  25626. distCodeTable = fixedDistCodeTab;
  25627. } else if (hdr === 2) {
  25628. var numLitCodes = this.getBits(5) + 257;
  25629. var numDistCodes = this.getBits(5) + 1;
  25630. var numCodeLenCodes = this.getBits(4) + 4;
  25631. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25632. var i;
  25633. for (i = 0; i < numCodeLenCodes; ++i) {
  25634. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25635. }
  25636. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25637. len = 0;
  25638. i = 0;
  25639. var codes = numLitCodes + numDistCodes;
  25640. var codeLengths = new Uint8Array(codes);
  25641. var bitsLength, bitsOffset, what;
  25642. while (i < codes) {
  25643. var code = this.getCode(codeLenCodeTab);
  25644. if (code === 16) {
  25645. bitsLength = 2;
  25646. bitsOffset = 3;
  25647. what = len;
  25648. } else if (code === 17) {
  25649. bitsLength = 3;
  25650. bitsOffset = 3;
  25651. what = len = 0;
  25652. } else if (code === 18) {
  25653. bitsLength = 7;
  25654. bitsOffset = 11;
  25655. what = len = 0;
  25656. } else {
  25657. codeLengths[i++] = len = code;
  25658. continue;
  25659. }
  25660. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25661. while (repeatLength-- > 0) {
  25662. codeLengths[i++] = what;
  25663. }
  25664. }
  25665. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25666. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25667. } else {
  25668. error('Unknown block type in flate stream');
  25669. }
  25670. buffer = this.buffer;
  25671. var limit = buffer ? buffer.length : 0;
  25672. var pos = this.bufferLength;
  25673. while (true) {
  25674. var code1 = this.getCode(litCodeTable);
  25675. if (code1 < 256) {
  25676. if (pos + 1 >= limit) {
  25677. buffer = this.ensureBuffer(pos + 1);
  25678. limit = buffer.length;
  25679. }
  25680. buffer[pos++] = code1;
  25681. continue;
  25682. }
  25683. if (code1 === 256) {
  25684. this.bufferLength = pos;
  25685. return;
  25686. }
  25687. code1 -= 257;
  25688. code1 = lengthDecode[code1];
  25689. var code2 = code1 >> 16;
  25690. if (code2 > 0) {
  25691. code2 = this.getBits(code2);
  25692. }
  25693. len = (code1 & 0xffff) + code2;
  25694. code1 = this.getCode(distCodeTable);
  25695. code1 = distDecode[code1];
  25696. code2 = code1 >> 16;
  25697. if (code2 > 0) {
  25698. code2 = this.getBits(code2);
  25699. }
  25700. var dist = (code1 & 0xffff) + code2;
  25701. if (pos + len >= limit) {
  25702. buffer = this.ensureBuffer(pos + len);
  25703. limit = buffer.length;
  25704. }
  25705. for (var k = 0; k < len; ++k, ++pos) {
  25706. buffer[pos] = buffer[pos - dist];
  25707. }
  25708. }
  25709. };
  25710. return FlateStream;
  25711. }();
  25712. var PredictorStream = function PredictorStreamClosure() {
  25713. function PredictorStream(str, maybeLength, params) {
  25714. if (!isDict(params)) {
  25715. return str;
  25716. }
  25717. var predictor = this.predictor = params.get('Predictor') || 1;
  25718. if (predictor <= 1) {
  25719. return str;
  25720. }
  25721. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25722. error('Unsupported predictor: ' + predictor);
  25723. }
  25724. if (predictor === 2) {
  25725. this.readBlock = this.readBlockTiff;
  25726. } else {
  25727. this.readBlock = this.readBlockPng;
  25728. }
  25729. this.str = str;
  25730. this.dict = str.dict;
  25731. var colors = this.colors = params.get('Colors') || 1;
  25732. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25733. var columns = this.columns = params.get('Columns') || 1;
  25734. this.pixBytes = colors * bits + 7 >> 3;
  25735. this.rowBytes = columns * colors * bits + 7 >> 3;
  25736. DecodeStream.call(this, maybeLength);
  25737. return this;
  25738. }
  25739. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25740. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25741. var rowBytes = this.rowBytes;
  25742. var bufferLength = this.bufferLength;
  25743. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25744. var bits = this.bits;
  25745. var colors = this.colors;
  25746. var rawBytes = this.str.getBytes(rowBytes);
  25747. this.eof = !rawBytes.length;
  25748. if (this.eof) {
  25749. return;
  25750. }
  25751. var inbuf = 0, outbuf = 0;
  25752. var inbits = 0, outbits = 0;
  25753. var pos = bufferLength;
  25754. var i;
  25755. if (bits === 1) {
  25756. for (i = 0; i < rowBytes; ++i) {
  25757. var c = rawBytes[i];
  25758. inbuf = inbuf << 8 | c;
  25759. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  25760. inbuf &= 0xFFFF;
  25761. }
  25762. } else if (bits === 8) {
  25763. for (i = 0; i < colors; ++i) {
  25764. buffer[pos++] = rawBytes[i];
  25765. }
  25766. for (; i < rowBytes; ++i) {
  25767. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  25768. pos++;
  25769. }
  25770. } else {
  25771. var compArray = new Uint8Array(colors + 1);
  25772. var bitMask = (1 << bits) - 1;
  25773. var j = 0, k = bufferLength;
  25774. var columns = this.columns;
  25775. for (i = 0; i < columns; ++i) {
  25776. for (var kk = 0; kk < colors; ++kk) {
  25777. if (inbits < bits) {
  25778. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  25779. inbits += 8;
  25780. }
  25781. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  25782. inbits -= bits;
  25783. outbuf = outbuf << bits | compArray[kk];
  25784. outbits += bits;
  25785. if (outbits >= 8) {
  25786. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  25787. outbits -= 8;
  25788. }
  25789. }
  25790. }
  25791. if (outbits > 0) {
  25792. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  25793. }
  25794. }
  25795. this.bufferLength += rowBytes;
  25796. };
  25797. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  25798. var rowBytes = this.rowBytes;
  25799. var pixBytes = this.pixBytes;
  25800. var predictor = this.str.getByte();
  25801. var rawBytes = this.str.getBytes(rowBytes);
  25802. this.eof = !rawBytes.length;
  25803. if (this.eof) {
  25804. return;
  25805. }
  25806. var bufferLength = this.bufferLength;
  25807. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25808. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  25809. if (prevRow.length === 0) {
  25810. prevRow = new Uint8Array(rowBytes);
  25811. }
  25812. var i, j = bufferLength, up, c;
  25813. switch (predictor) {
  25814. case 0:
  25815. for (i = 0; i < rowBytes; ++i) {
  25816. buffer[j++] = rawBytes[i];
  25817. }
  25818. break;
  25819. case 1:
  25820. for (i = 0; i < pixBytes; ++i) {
  25821. buffer[j++] = rawBytes[i];
  25822. }
  25823. for (; i < rowBytes; ++i) {
  25824. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  25825. j++;
  25826. }
  25827. break;
  25828. case 2:
  25829. for (i = 0; i < rowBytes; ++i) {
  25830. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  25831. }
  25832. break;
  25833. case 3:
  25834. for (i = 0; i < pixBytes; ++i) {
  25835. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  25836. }
  25837. for (; i < rowBytes; ++i) {
  25838. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  25839. j++;
  25840. }
  25841. break;
  25842. case 4:
  25843. for (i = 0; i < pixBytes; ++i) {
  25844. up = prevRow[i];
  25845. c = rawBytes[i];
  25846. buffer[j++] = up + c;
  25847. }
  25848. for (; i < rowBytes; ++i) {
  25849. up = prevRow[i];
  25850. var upLeft = prevRow[i - pixBytes];
  25851. var left = buffer[j - pixBytes];
  25852. var p = left + up - upLeft;
  25853. var pa = p - left;
  25854. if (pa < 0) {
  25855. pa = -pa;
  25856. }
  25857. var pb = p - up;
  25858. if (pb < 0) {
  25859. pb = -pb;
  25860. }
  25861. var pc = p - upLeft;
  25862. if (pc < 0) {
  25863. pc = -pc;
  25864. }
  25865. c = rawBytes[i];
  25866. if (pa <= pb && pa <= pc) {
  25867. buffer[j++] = left + c;
  25868. } else if (pb <= pc) {
  25869. buffer[j++] = up + c;
  25870. } else {
  25871. buffer[j++] = upLeft + c;
  25872. }
  25873. }
  25874. break;
  25875. default:
  25876. error('Unsupported predictor: ' + predictor);
  25877. }
  25878. this.bufferLength += rowBytes;
  25879. };
  25880. return PredictorStream;
  25881. }();
  25882. var JpegStream = function JpegStreamClosure() {
  25883. function JpegStream(stream, maybeLength, dict, params) {
  25884. var ch;
  25885. while ((ch = stream.getByte()) !== -1) {
  25886. if (ch === 0xFF) {
  25887. stream.skip(-1);
  25888. break;
  25889. }
  25890. }
  25891. this.stream = stream;
  25892. this.maybeLength = maybeLength;
  25893. this.dict = dict;
  25894. this.params = params;
  25895. DecodeStream.call(this, maybeLength);
  25896. }
  25897. JpegStream.prototype = Object.create(DecodeStream.prototype);
  25898. Object.defineProperty(JpegStream.prototype, 'bytes', {
  25899. get: function JpegStream_bytes() {
  25900. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25901. },
  25902. configurable: true
  25903. });
  25904. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  25905. if (this.bufferLength) {
  25906. return;
  25907. }
  25908. var jpegImage = new JpegImage();
  25909. var decodeArr = this.dict.getArray('Decode', 'D');
  25910. if (this.forceRGB && isArray(decodeArr)) {
  25911. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  25912. var decodeArrLength = decodeArr.length;
  25913. var transform = new Int32Array(decodeArrLength);
  25914. var transformNeeded = false;
  25915. var maxValue = (1 << bitsPerComponent) - 1;
  25916. for (var i = 0; i < decodeArrLength; i += 2) {
  25917. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  25918. transform[i + 1] = decodeArr[i] * maxValue | 0;
  25919. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  25920. transformNeeded = true;
  25921. }
  25922. }
  25923. if (transformNeeded) {
  25924. jpegImage.decodeTransform = transform;
  25925. }
  25926. }
  25927. if (isDict(this.params)) {
  25928. var colorTransform = this.params.get('ColorTransform');
  25929. if (isInt(colorTransform)) {
  25930. jpegImage.colorTransform = colorTransform;
  25931. }
  25932. }
  25933. jpegImage.parse(this.bytes);
  25934. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  25935. this.buffer = data;
  25936. this.bufferLength = data.length;
  25937. this.eof = true;
  25938. };
  25939. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  25940. this.ensureBuffer();
  25941. return this.buffer;
  25942. };
  25943. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  25944. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  25945. };
  25946. return JpegStream;
  25947. }();
  25948. var JpxStream = function JpxStreamClosure() {
  25949. function JpxStream(stream, maybeLength, dict, params) {
  25950. this.stream = stream;
  25951. this.maybeLength = maybeLength;
  25952. this.dict = dict;
  25953. this.params = params;
  25954. DecodeStream.call(this, maybeLength);
  25955. }
  25956. JpxStream.prototype = Object.create(DecodeStream.prototype);
  25957. Object.defineProperty(JpxStream.prototype, 'bytes', {
  25958. get: function JpxStream_bytes() {
  25959. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25960. },
  25961. configurable: true
  25962. });
  25963. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  25964. if (this.bufferLength) {
  25965. return;
  25966. }
  25967. var jpxImage = new JpxImage();
  25968. jpxImage.parse(this.bytes);
  25969. var width = jpxImage.width;
  25970. var height = jpxImage.height;
  25971. var componentsCount = jpxImage.componentsCount;
  25972. var tileCount = jpxImage.tiles.length;
  25973. if (tileCount === 1) {
  25974. this.buffer = jpxImage.tiles[0].items;
  25975. } else {
  25976. var data = new Uint8Array(width * height * componentsCount);
  25977. for (var k = 0; k < tileCount; k++) {
  25978. var tileComponents = jpxImage.tiles[k];
  25979. var tileWidth = tileComponents.width;
  25980. var tileHeight = tileComponents.height;
  25981. var tileLeft = tileComponents.left;
  25982. var tileTop = tileComponents.top;
  25983. var src = tileComponents.items;
  25984. var srcPosition = 0;
  25985. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  25986. var imgRowSize = width * componentsCount;
  25987. var tileRowSize = tileWidth * componentsCount;
  25988. for (var j = 0; j < tileHeight; j++) {
  25989. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  25990. data.set(rowBytes, dataPosition);
  25991. srcPosition += tileRowSize;
  25992. dataPosition += imgRowSize;
  25993. }
  25994. }
  25995. this.buffer = data;
  25996. }
  25997. this.bufferLength = this.buffer.length;
  25998. this.eof = true;
  25999. };
  26000. return JpxStream;
  26001. }();
  26002. var Jbig2Stream = function Jbig2StreamClosure() {
  26003. function Jbig2Stream(stream, maybeLength, dict, params) {
  26004. this.stream = stream;
  26005. this.maybeLength = maybeLength;
  26006. this.dict = dict;
  26007. this.params = params;
  26008. DecodeStream.call(this, maybeLength);
  26009. }
  26010. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26011. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26012. get: function Jbig2Stream_bytes() {
  26013. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26014. },
  26015. configurable: true
  26016. });
  26017. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26018. if (this.bufferLength) {
  26019. return;
  26020. }
  26021. var jbig2Image = new Jbig2Image();
  26022. var chunks = [];
  26023. if (isDict(this.params)) {
  26024. var globalsStream = this.params.get('JBIG2Globals');
  26025. if (isStream(globalsStream)) {
  26026. var globals = globalsStream.getBytes();
  26027. chunks.push({
  26028. data: globals,
  26029. start: 0,
  26030. end: globals.length
  26031. });
  26032. }
  26033. }
  26034. chunks.push({
  26035. data: this.bytes,
  26036. start: 0,
  26037. end: this.bytes.length
  26038. });
  26039. var data = jbig2Image.parseChunks(chunks);
  26040. var dataLength = data.length;
  26041. for (var i = 0; i < dataLength; i++) {
  26042. data[i] ^= 0xFF;
  26043. }
  26044. this.buffer = data;
  26045. this.bufferLength = dataLength;
  26046. this.eof = true;
  26047. };
  26048. return Jbig2Stream;
  26049. }();
  26050. var DecryptStream = function DecryptStreamClosure() {
  26051. function DecryptStream(str, maybeLength, decrypt) {
  26052. this.str = str;
  26053. this.dict = str.dict;
  26054. this.decrypt = decrypt;
  26055. this.nextChunk = null;
  26056. this.initialized = false;
  26057. DecodeStream.call(this, maybeLength);
  26058. }
  26059. var chunkSize = 512;
  26060. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26061. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26062. var chunk;
  26063. if (this.initialized) {
  26064. chunk = this.nextChunk;
  26065. } else {
  26066. chunk = this.str.getBytes(chunkSize);
  26067. this.initialized = true;
  26068. }
  26069. if (!chunk || chunk.length === 0) {
  26070. this.eof = true;
  26071. return;
  26072. }
  26073. this.nextChunk = this.str.getBytes(chunkSize);
  26074. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26075. var decrypt = this.decrypt;
  26076. chunk = decrypt(chunk, !hasMoreData);
  26077. var bufferLength = this.bufferLength;
  26078. var i, n = chunk.length;
  26079. var buffer = this.ensureBuffer(bufferLength + n);
  26080. for (i = 0; i < n; i++) {
  26081. buffer[bufferLength++] = chunk[i];
  26082. }
  26083. this.bufferLength = bufferLength;
  26084. };
  26085. return DecryptStream;
  26086. }();
  26087. var Ascii85Stream = function Ascii85StreamClosure() {
  26088. function Ascii85Stream(str, maybeLength) {
  26089. this.str = str;
  26090. this.dict = str.dict;
  26091. this.input = new Uint8Array(5);
  26092. if (maybeLength) {
  26093. maybeLength = 0.8 * maybeLength;
  26094. }
  26095. DecodeStream.call(this, maybeLength);
  26096. }
  26097. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26098. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26099. var TILDA_CHAR = 0x7E;
  26100. var Z_LOWER_CHAR = 0x7A;
  26101. var EOF = -1;
  26102. var str = this.str;
  26103. var c = str.getByte();
  26104. while (isSpace(c)) {
  26105. c = str.getByte();
  26106. }
  26107. if (c === EOF || c === TILDA_CHAR) {
  26108. this.eof = true;
  26109. return;
  26110. }
  26111. var bufferLength = this.bufferLength, buffer;
  26112. var i;
  26113. if (c === Z_LOWER_CHAR) {
  26114. buffer = this.ensureBuffer(bufferLength + 4);
  26115. for (i = 0; i < 4; ++i) {
  26116. buffer[bufferLength + i] = 0;
  26117. }
  26118. this.bufferLength += 4;
  26119. } else {
  26120. var input = this.input;
  26121. input[0] = c;
  26122. for (i = 1; i < 5; ++i) {
  26123. c = str.getByte();
  26124. while (isSpace(c)) {
  26125. c = str.getByte();
  26126. }
  26127. input[i] = c;
  26128. if (c === EOF || c === TILDA_CHAR) {
  26129. break;
  26130. }
  26131. }
  26132. buffer = this.ensureBuffer(bufferLength + i - 1);
  26133. this.bufferLength += i - 1;
  26134. if (i < 5) {
  26135. for (; i < 5; ++i) {
  26136. input[i] = 0x21 + 84;
  26137. }
  26138. this.eof = true;
  26139. }
  26140. var t = 0;
  26141. for (i = 0; i < 5; ++i) {
  26142. t = t * 85 + (input[i] - 0x21);
  26143. }
  26144. for (i = 3; i >= 0; --i) {
  26145. buffer[bufferLength + i] = t & 0xFF;
  26146. t >>= 8;
  26147. }
  26148. }
  26149. };
  26150. return Ascii85Stream;
  26151. }();
  26152. var AsciiHexStream = function AsciiHexStreamClosure() {
  26153. function AsciiHexStream(str, maybeLength) {
  26154. this.str = str;
  26155. this.dict = str.dict;
  26156. this.firstDigit = -1;
  26157. if (maybeLength) {
  26158. maybeLength = 0.5 * maybeLength;
  26159. }
  26160. DecodeStream.call(this, maybeLength);
  26161. }
  26162. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26163. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26164. var UPSTREAM_BLOCK_SIZE = 8000;
  26165. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26166. if (!bytes.length) {
  26167. this.eof = true;
  26168. return;
  26169. }
  26170. var maxDecodeLength = bytes.length + 1 >> 1;
  26171. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26172. var bufferLength = this.bufferLength;
  26173. var firstDigit = this.firstDigit;
  26174. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26175. var ch = bytes[i], digit;
  26176. if (ch >= 0x30 && ch <= 0x39) {
  26177. digit = ch & 0x0F;
  26178. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26179. digit = (ch & 0x0F) + 9;
  26180. } else if (ch === 0x3E) {
  26181. this.eof = true;
  26182. break;
  26183. } else {
  26184. continue;
  26185. }
  26186. if (firstDigit < 0) {
  26187. firstDigit = digit;
  26188. } else {
  26189. buffer[bufferLength++] = firstDigit << 4 | digit;
  26190. firstDigit = -1;
  26191. }
  26192. }
  26193. if (firstDigit >= 0 && this.eof) {
  26194. buffer[bufferLength++] = firstDigit << 4;
  26195. firstDigit = -1;
  26196. }
  26197. this.firstDigit = firstDigit;
  26198. this.bufferLength = bufferLength;
  26199. };
  26200. return AsciiHexStream;
  26201. }();
  26202. var RunLengthStream = function RunLengthStreamClosure() {
  26203. function RunLengthStream(str, maybeLength) {
  26204. this.str = str;
  26205. this.dict = str.dict;
  26206. DecodeStream.call(this, maybeLength);
  26207. }
  26208. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26209. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26210. var repeatHeader = this.str.getBytes(2);
  26211. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26212. this.eof = true;
  26213. return;
  26214. }
  26215. var buffer;
  26216. var bufferLength = this.bufferLength;
  26217. var n = repeatHeader[0];
  26218. if (n < 128) {
  26219. buffer = this.ensureBuffer(bufferLength + n + 1);
  26220. buffer[bufferLength++] = repeatHeader[1];
  26221. if (n > 0) {
  26222. var source = this.str.getBytes(n);
  26223. buffer.set(source, bufferLength);
  26224. bufferLength += n;
  26225. }
  26226. } else {
  26227. n = 257 - n;
  26228. var b = repeatHeader[1];
  26229. buffer = this.ensureBuffer(bufferLength + n + 1);
  26230. for (var i = 0; i < n; i++) {
  26231. buffer[bufferLength++] = b;
  26232. }
  26233. }
  26234. this.bufferLength = bufferLength;
  26235. };
  26236. return RunLengthStream;
  26237. }();
  26238. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26239. var ccittEOL = -2;
  26240. var ccittEOF = -1;
  26241. var twoDimPass = 0;
  26242. var twoDimHoriz = 1;
  26243. var twoDimVert0 = 2;
  26244. var twoDimVertR1 = 3;
  26245. var twoDimVertL1 = 4;
  26246. var twoDimVertR2 = 5;
  26247. var twoDimVertL2 = 6;
  26248. var twoDimVertR3 = 7;
  26249. var twoDimVertL3 = 8;
  26250. var twoDimTable = [
  26251. [
  26252. -1,
  26253. -1
  26254. ],
  26255. [
  26256. -1,
  26257. -1
  26258. ],
  26259. [
  26260. 7,
  26261. twoDimVertL3
  26262. ],
  26263. [
  26264. 7,
  26265. twoDimVertR3
  26266. ],
  26267. [
  26268. 6,
  26269. twoDimVertL2
  26270. ],
  26271. [
  26272. 6,
  26273. twoDimVertL2
  26274. ],
  26275. [
  26276. 6,
  26277. twoDimVertR2
  26278. ],
  26279. [
  26280. 6,
  26281. twoDimVertR2
  26282. ],
  26283. [
  26284. 4,
  26285. twoDimPass
  26286. ],
  26287. [
  26288. 4,
  26289. twoDimPass
  26290. ],
  26291. [
  26292. 4,
  26293. twoDimPass
  26294. ],
  26295. [
  26296. 4,
  26297. twoDimPass
  26298. ],
  26299. [
  26300. 4,
  26301. twoDimPass
  26302. ],
  26303. [
  26304. 4,
  26305. twoDimPass
  26306. ],
  26307. [
  26308. 4,
  26309. twoDimPass
  26310. ],
  26311. [
  26312. 4,
  26313. twoDimPass
  26314. ],
  26315. [
  26316. 3,
  26317. twoDimHoriz
  26318. ],
  26319. [
  26320. 3,
  26321. twoDimHoriz
  26322. ],
  26323. [
  26324. 3,
  26325. twoDimHoriz
  26326. ],
  26327. [
  26328. 3,
  26329. twoDimHoriz
  26330. ],
  26331. [
  26332. 3,
  26333. twoDimHoriz
  26334. ],
  26335. [
  26336. 3,
  26337. twoDimHoriz
  26338. ],
  26339. [
  26340. 3,
  26341. twoDimHoriz
  26342. ],
  26343. [
  26344. 3,
  26345. twoDimHoriz
  26346. ],
  26347. [
  26348. 3,
  26349. twoDimHoriz
  26350. ],
  26351. [
  26352. 3,
  26353. twoDimHoriz
  26354. ],
  26355. [
  26356. 3,
  26357. twoDimHoriz
  26358. ],
  26359. [
  26360. 3,
  26361. twoDimHoriz
  26362. ],
  26363. [
  26364. 3,
  26365. twoDimHoriz
  26366. ],
  26367. [
  26368. 3,
  26369. twoDimHoriz
  26370. ],
  26371. [
  26372. 3,
  26373. twoDimHoriz
  26374. ],
  26375. [
  26376. 3,
  26377. twoDimHoriz
  26378. ],
  26379. [
  26380. 3,
  26381. twoDimVertL1
  26382. ],
  26383. [
  26384. 3,
  26385. twoDimVertL1
  26386. ],
  26387. [
  26388. 3,
  26389. twoDimVertL1
  26390. ],
  26391. [
  26392. 3,
  26393. twoDimVertL1
  26394. ],
  26395. [
  26396. 3,
  26397. twoDimVertL1
  26398. ],
  26399. [
  26400. 3,
  26401. twoDimVertL1
  26402. ],
  26403. [
  26404. 3,
  26405. twoDimVertL1
  26406. ],
  26407. [
  26408. 3,
  26409. twoDimVertL1
  26410. ],
  26411. [
  26412. 3,
  26413. twoDimVertL1
  26414. ],
  26415. [
  26416. 3,
  26417. twoDimVertL1
  26418. ],
  26419. [
  26420. 3,
  26421. twoDimVertL1
  26422. ],
  26423. [
  26424. 3,
  26425. twoDimVertL1
  26426. ],
  26427. [
  26428. 3,
  26429. twoDimVertL1
  26430. ],
  26431. [
  26432. 3,
  26433. twoDimVertL1
  26434. ],
  26435. [
  26436. 3,
  26437. twoDimVertL1
  26438. ],
  26439. [
  26440. 3,
  26441. twoDimVertL1
  26442. ],
  26443. [
  26444. 3,
  26445. twoDimVertR1
  26446. ],
  26447. [
  26448. 3,
  26449. twoDimVertR1
  26450. ],
  26451. [
  26452. 3,
  26453. twoDimVertR1
  26454. ],
  26455. [
  26456. 3,
  26457. twoDimVertR1
  26458. ],
  26459. [
  26460. 3,
  26461. twoDimVertR1
  26462. ],
  26463. [
  26464. 3,
  26465. twoDimVertR1
  26466. ],
  26467. [
  26468. 3,
  26469. twoDimVertR1
  26470. ],
  26471. [
  26472. 3,
  26473. twoDimVertR1
  26474. ],
  26475. [
  26476. 3,
  26477. twoDimVertR1
  26478. ],
  26479. [
  26480. 3,
  26481. twoDimVertR1
  26482. ],
  26483. [
  26484. 3,
  26485. twoDimVertR1
  26486. ],
  26487. [
  26488. 3,
  26489. twoDimVertR1
  26490. ],
  26491. [
  26492. 3,
  26493. twoDimVertR1
  26494. ],
  26495. [
  26496. 3,
  26497. twoDimVertR1
  26498. ],
  26499. [
  26500. 3,
  26501. twoDimVertR1
  26502. ],
  26503. [
  26504. 3,
  26505. twoDimVertR1
  26506. ],
  26507. [
  26508. 1,
  26509. twoDimVert0
  26510. ],
  26511. [
  26512. 1,
  26513. twoDimVert0
  26514. ],
  26515. [
  26516. 1,
  26517. twoDimVert0
  26518. ],
  26519. [
  26520. 1,
  26521. twoDimVert0
  26522. ],
  26523. [
  26524. 1,
  26525. twoDimVert0
  26526. ],
  26527. [
  26528. 1,
  26529. twoDimVert0
  26530. ],
  26531. [
  26532. 1,
  26533. twoDimVert0
  26534. ],
  26535. [
  26536. 1,
  26537. twoDimVert0
  26538. ],
  26539. [
  26540. 1,
  26541. twoDimVert0
  26542. ],
  26543. [
  26544. 1,
  26545. twoDimVert0
  26546. ],
  26547. [
  26548. 1,
  26549. twoDimVert0
  26550. ],
  26551. [
  26552. 1,
  26553. twoDimVert0
  26554. ],
  26555. [
  26556. 1,
  26557. twoDimVert0
  26558. ],
  26559. [
  26560. 1,
  26561. twoDimVert0
  26562. ],
  26563. [
  26564. 1,
  26565. twoDimVert0
  26566. ],
  26567. [
  26568. 1,
  26569. twoDimVert0
  26570. ],
  26571. [
  26572. 1,
  26573. twoDimVert0
  26574. ],
  26575. [
  26576. 1,
  26577. twoDimVert0
  26578. ],
  26579. [
  26580. 1,
  26581. twoDimVert0
  26582. ],
  26583. [
  26584. 1,
  26585. twoDimVert0
  26586. ],
  26587. [
  26588. 1,
  26589. twoDimVert0
  26590. ],
  26591. [
  26592. 1,
  26593. twoDimVert0
  26594. ],
  26595. [
  26596. 1,
  26597. twoDimVert0
  26598. ],
  26599. [
  26600. 1,
  26601. twoDimVert0
  26602. ],
  26603. [
  26604. 1,
  26605. twoDimVert0
  26606. ],
  26607. [
  26608. 1,
  26609. twoDimVert0
  26610. ],
  26611. [
  26612. 1,
  26613. twoDimVert0
  26614. ],
  26615. [
  26616. 1,
  26617. twoDimVert0
  26618. ],
  26619. [
  26620. 1,
  26621. twoDimVert0
  26622. ],
  26623. [
  26624. 1,
  26625. twoDimVert0
  26626. ],
  26627. [
  26628. 1,
  26629. twoDimVert0
  26630. ],
  26631. [
  26632. 1,
  26633. twoDimVert0
  26634. ],
  26635. [
  26636. 1,
  26637. twoDimVert0
  26638. ],
  26639. [
  26640. 1,
  26641. twoDimVert0
  26642. ],
  26643. [
  26644. 1,
  26645. twoDimVert0
  26646. ],
  26647. [
  26648. 1,
  26649. twoDimVert0
  26650. ],
  26651. [
  26652. 1,
  26653. twoDimVert0
  26654. ],
  26655. [
  26656. 1,
  26657. twoDimVert0
  26658. ],
  26659. [
  26660. 1,
  26661. twoDimVert0
  26662. ],
  26663. [
  26664. 1,
  26665. twoDimVert0
  26666. ],
  26667. [
  26668. 1,
  26669. twoDimVert0
  26670. ],
  26671. [
  26672. 1,
  26673. twoDimVert0
  26674. ],
  26675. [
  26676. 1,
  26677. twoDimVert0
  26678. ],
  26679. [
  26680. 1,
  26681. twoDimVert0
  26682. ],
  26683. [
  26684. 1,
  26685. twoDimVert0
  26686. ],
  26687. [
  26688. 1,
  26689. twoDimVert0
  26690. ],
  26691. [
  26692. 1,
  26693. twoDimVert0
  26694. ],
  26695. [
  26696. 1,
  26697. twoDimVert0
  26698. ],
  26699. [
  26700. 1,
  26701. twoDimVert0
  26702. ],
  26703. [
  26704. 1,
  26705. twoDimVert0
  26706. ],
  26707. [
  26708. 1,
  26709. twoDimVert0
  26710. ],
  26711. [
  26712. 1,
  26713. twoDimVert0
  26714. ],
  26715. [
  26716. 1,
  26717. twoDimVert0
  26718. ],
  26719. [
  26720. 1,
  26721. twoDimVert0
  26722. ],
  26723. [
  26724. 1,
  26725. twoDimVert0
  26726. ],
  26727. [
  26728. 1,
  26729. twoDimVert0
  26730. ],
  26731. [
  26732. 1,
  26733. twoDimVert0
  26734. ],
  26735. [
  26736. 1,
  26737. twoDimVert0
  26738. ],
  26739. [
  26740. 1,
  26741. twoDimVert0
  26742. ],
  26743. [
  26744. 1,
  26745. twoDimVert0
  26746. ],
  26747. [
  26748. 1,
  26749. twoDimVert0
  26750. ],
  26751. [
  26752. 1,
  26753. twoDimVert0
  26754. ],
  26755. [
  26756. 1,
  26757. twoDimVert0
  26758. ],
  26759. [
  26760. 1,
  26761. twoDimVert0
  26762. ]
  26763. ];
  26764. var whiteTable1 = [
  26765. [
  26766. -1,
  26767. -1
  26768. ],
  26769. [
  26770. 12,
  26771. ccittEOL
  26772. ],
  26773. [
  26774. -1,
  26775. -1
  26776. ],
  26777. [
  26778. -1,
  26779. -1
  26780. ],
  26781. [
  26782. -1,
  26783. -1
  26784. ],
  26785. [
  26786. -1,
  26787. -1
  26788. ],
  26789. [
  26790. -1,
  26791. -1
  26792. ],
  26793. [
  26794. -1,
  26795. -1
  26796. ],
  26797. [
  26798. -1,
  26799. -1
  26800. ],
  26801. [
  26802. -1,
  26803. -1
  26804. ],
  26805. [
  26806. -1,
  26807. -1
  26808. ],
  26809. [
  26810. -1,
  26811. -1
  26812. ],
  26813. [
  26814. -1,
  26815. -1
  26816. ],
  26817. [
  26818. -1,
  26819. -1
  26820. ],
  26821. [
  26822. -1,
  26823. -1
  26824. ],
  26825. [
  26826. -1,
  26827. -1
  26828. ],
  26829. [
  26830. 11,
  26831. 1792
  26832. ],
  26833. [
  26834. 11,
  26835. 1792
  26836. ],
  26837. [
  26838. 12,
  26839. 1984
  26840. ],
  26841. [
  26842. 12,
  26843. 2048
  26844. ],
  26845. [
  26846. 12,
  26847. 2112
  26848. ],
  26849. [
  26850. 12,
  26851. 2176
  26852. ],
  26853. [
  26854. 12,
  26855. 2240
  26856. ],
  26857. [
  26858. 12,
  26859. 2304
  26860. ],
  26861. [
  26862. 11,
  26863. 1856
  26864. ],
  26865. [
  26866. 11,
  26867. 1856
  26868. ],
  26869. [
  26870. 11,
  26871. 1920
  26872. ],
  26873. [
  26874. 11,
  26875. 1920
  26876. ],
  26877. [
  26878. 12,
  26879. 2368
  26880. ],
  26881. [
  26882. 12,
  26883. 2432
  26884. ],
  26885. [
  26886. 12,
  26887. 2496
  26888. ],
  26889. [
  26890. 12,
  26891. 2560
  26892. ]
  26893. ];
  26894. var whiteTable2 = [
  26895. [
  26896. -1,
  26897. -1
  26898. ],
  26899. [
  26900. -1,
  26901. -1
  26902. ],
  26903. [
  26904. -1,
  26905. -1
  26906. ],
  26907. [
  26908. -1,
  26909. -1
  26910. ],
  26911. [
  26912. 8,
  26913. 29
  26914. ],
  26915. [
  26916. 8,
  26917. 29
  26918. ],
  26919. [
  26920. 8,
  26921. 30
  26922. ],
  26923. [
  26924. 8,
  26925. 30
  26926. ],
  26927. [
  26928. 8,
  26929. 45
  26930. ],
  26931. [
  26932. 8,
  26933. 45
  26934. ],
  26935. [
  26936. 8,
  26937. 46
  26938. ],
  26939. [
  26940. 8,
  26941. 46
  26942. ],
  26943. [
  26944. 7,
  26945. 22
  26946. ],
  26947. [
  26948. 7,
  26949. 22
  26950. ],
  26951. [
  26952. 7,
  26953. 22
  26954. ],
  26955. [
  26956. 7,
  26957. 22
  26958. ],
  26959. [
  26960. 7,
  26961. 23
  26962. ],
  26963. [
  26964. 7,
  26965. 23
  26966. ],
  26967. [
  26968. 7,
  26969. 23
  26970. ],
  26971. [
  26972. 7,
  26973. 23
  26974. ],
  26975. [
  26976. 8,
  26977. 47
  26978. ],
  26979. [
  26980. 8,
  26981. 47
  26982. ],
  26983. [
  26984. 8,
  26985. 48
  26986. ],
  26987. [
  26988. 8,
  26989. 48
  26990. ],
  26991. [
  26992. 6,
  26993. 13
  26994. ],
  26995. [
  26996. 6,
  26997. 13
  26998. ],
  26999. [
  27000. 6,
  27001. 13
  27002. ],
  27003. [
  27004. 6,
  27005. 13
  27006. ],
  27007. [
  27008. 6,
  27009. 13
  27010. ],
  27011. [
  27012. 6,
  27013. 13
  27014. ],
  27015. [
  27016. 6,
  27017. 13
  27018. ],
  27019. [
  27020. 6,
  27021. 13
  27022. ],
  27023. [
  27024. 7,
  27025. 20
  27026. ],
  27027. [
  27028. 7,
  27029. 20
  27030. ],
  27031. [
  27032. 7,
  27033. 20
  27034. ],
  27035. [
  27036. 7,
  27037. 20
  27038. ],
  27039. [
  27040. 8,
  27041. 33
  27042. ],
  27043. [
  27044. 8,
  27045. 33
  27046. ],
  27047. [
  27048. 8,
  27049. 34
  27050. ],
  27051. [
  27052. 8,
  27053. 34
  27054. ],
  27055. [
  27056. 8,
  27057. 35
  27058. ],
  27059. [
  27060. 8,
  27061. 35
  27062. ],
  27063. [
  27064. 8,
  27065. 36
  27066. ],
  27067. [
  27068. 8,
  27069. 36
  27070. ],
  27071. [
  27072. 8,
  27073. 37
  27074. ],
  27075. [
  27076. 8,
  27077. 37
  27078. ],
  27079. [
  27080. 8,
  27081. 38
  27082. ],
  27083. [
  27084. 8,
  27085. 38
  27086. ],
  27087. [
  27088. 7,
  27089. 19
  27090. ],
  27091. [
  27092. 7,
  27093. 19
  27094. ],
  27095. [
  27096. 7,
  27097. 19
  27098. ],
  27099. [
  27100. 7,
  27101. 19
  27102. ],
  27103. [
  27104. 8,
  27105. 31
  27106. ],
  27107. [
  27108. 8,
  27109. 31
  27110. ],
  27111. [
  27112. 8,
  27113. 32
  27114. ],
  27115. [
  27116. 8,
  27117. 32
  27118. ],
  27119. [
  27120. 6,
  27121. 1
  27122. ],
  27123. [
  27124. 6,
  27125. 1
  27126. ],
  27127. [
  27128. 6,
  27129. 1
  27130. ],
  27131. [
  27132. 6,
  27133. 1
  27134. ],
  27135. [
  27136. 6,
  27137. 1
  27138. ],
  27139. [
  27140. 6,
  27141. 1
  27142. ],
  27143. [
  27144. 6,
  27145. 1
  27146. ],
  27147. [
  27148. 6,
  27149. 1
  27150. ],
  27151. [
  27152. 6,
  27153. 12
  27154. ],
  27155. [
  27156. 6,
  27157. 12
  27158. ],
  27159. [
  27160. 6,
  27161. 12
  27162. ],
  27163. [
  27164. 6,
  27165. 12
  27166. ],
  27167. [
  27168. 6,
  27169. 12
  27170. ],
  27171. [
  27172. 6,
  27173. 12
  27174. ],
  27175. [
  27176. 6,
  27177. 12
  27178. ],
  27179. [
  27180. 6,
  27181. 12
  27182. ],
  27183. [
  27184. 8,
  27185. 53
  27186. ],
  27187. [
  27188. 8,
  27189. 53
  27190. ],
  27191. [
  27192. 8,
  27193. 54
  27194. ],
  27195. [
  27196. 8,
  27197. 54
  27198. ],
  27199. [
  27200. 7,
  27201. 26
  27202. ],
  27203. [
  27204. 7,
  27205. 26
  27206. ],
  27207. [
  27208. 7,
  27209. 26
  27210. ],
  27211. [
  27212. 7,
  27213. 26
  27214. ],
  27215. [
  27216. 8,
  27217. 39
  27218. ],
  27219. [
  27220. 8,
  27221. 39
  27222. ],
  27223. [
  27224. 8,
  27225. 40
  27226. ],
  27227. [
  27228. 8,
  27229. 40
  27230. ],
  27231. [
  27232. 8,
  27233. 41
  27234. ],
  27235. [
  27236. 8,
  27237. 41
  27238. ],
  27239. [
  27240. 8,
  27241. 42
  27242. ],
  27243. [
  27244. 8,
  27245. 42
  27246. ],
  27247. [
  27248. 8,
  27249. 43
  27250. ],
  27251. [
  27252. 8,
  27253. 43
  27254. ],
  27255. [
  27256. 8,
  27257. 44
  27258. ],
  27259. [
  27260. 8,
  27261. 44
  27262. ],
  27263. [
  27264. 7,
  27265. 21
  27266. ],
  27267. [
  27268. 7,
  27269. 21
  27270. ],
  27271. [
  27272. 7,
  27273. 21
  27274. ],
  27275. [
  27276. 7,
  27277. 21
  27278. ],
  27279. [
  27280. 7,
  27281. 28
  27282. ],
  27283. [
  27284. 7,
  27285. 28
  27286. ],
  27287. [
  27288. 7,
  27289. 28
  27290. ],
  27291. [
  27292. 7,
  27293. 28
  27294. ],
  27295. [
  27296. 8,
  27297. 61
  27298. ],
  27299. [
  27300. 8,
  27301. 61
  27302. ],
  27303. [
  27304. 8,
  27305. 62
  27306. ],
  27307. [
  27308. 8,
  27309. 62
  27310. ],
  27311. [
  27312. 8,
  27313. 63
  27314. ],
  27315. [
  27316. 8,
  27317. 63
  27318. ],
  27319. [
  27320. 8,
  27321. 0
  27322. ],
  27323. [
  27324. 8,
  27325. 0
  27326. ],
  27327. [
  27328. 8,
  27329. 320
  27330. ],
  27331. [
  27332. 8,
  27333. 320
  27334. ],
  27335. [
  27336. 8,
  27337. 384
  27338. ],
  27339. [
  27340. 8,
  27341. 384
  27342. ],
  27343. [
  27344. 5,
  27345. 10
  27346. ],
  27347. [
  27348. 5,
  27349. 10
  27350. ],
  27351. [
  27352. 5,
  27353. 10
  27354. ],
  27355. [
  27356. 5,
  27357. 10
  27358. ],
  27359. [
  27360. 5,
  27361. 10
  27362. ],
  27363. [
  27364. 5,
  27365. 10
  27366. ],
  27367. [
  27368. 5,
  27369. 10
  27370. ],
  27371. [
  27372. 5,
  27373. 10
  27374. ],
  27375. [
  27376. 5,
  27377. 10
  27378. ],
  27379. [
  27380. 5,
  27381. 10
  27382. ],
  27383. [
  27384. 5,
  27385. 10
  27386. ],
  27387. [
  27388. 5,
  27389. 10
  27390. ],
  27391. [
  27392. 5,
  27393. 10
  27394. ],
  27395. [
  27396. 5,
  27397. 10
  27398. ],
  27399. [
  27400. 5,
  27401. 10
  27402. ],
  27403. [
  27404. 5,
  27405. 10
  27406. ],
  27407. [
  27408. 5,
  27409. 11
  27410. ],
  27411. [
  27412. 5,
  27413. 11
  27414. ],
  27415. [
  27416. 5,
  27417. 11
  27418. ],
  27419. [
  27420. 5,
  27421. 11
  27422. ],
  27423. [
  27424. 5,
  27425. 11
  27426. ],
  27427. [
  27428. 5,
  27429. 11
  27430. ],
  27431. [
  27432. 5,
  27433. 11
  27434. ],
  27435. [
  27436. 5,
  27437. 11
  27438. ],
  27439. [
  27440. 5,
  27441. 11
  27442. ],
  27443. [
  27444. 5,
  27445. 11
  27446. ],
  27447. [
  27448. 5,
  27449. 11
  27450. ],
  27451. [
  27452. 5,
  27453. 11
  27454. ],
  27455. [
  27456. 5,
  27457. 11
  27458. ],
  27459. [
  27460. 5,
  27461. 11
  27462. ],
  27463. [
  27464. 5,
  27465. 11
  27466. ],
  27467. [
  27468. 5,
  27469. 11
  27470. ],
  27471. [
  27472. 7,
  27473. 27
  27474. ],
  27475. [
  27476. 7,
  27477. 27
  27478. ],
  27479. [
  27480. 7,
  27481. 27
  27482. ],
  27483. [
  27484. 7,
  27485. 27
  27486. ],
  27487. [
  27488. 8,
  27489. 59
  27490. ],
  27491. [
  27492. 8,
  27493. 59
  27494. ],
  27495. [
  27496. 8,
  27497. 60
  27498. ],
  27499. [
  27500. 8,
  27501. 60
  27502. ],
  27503. [
  27504. 9,
  27505. 1472
  27506. ],
  27507. [
  27508. 9,
  27509. 1536
  27510. ],
  27511. [
  27512. 9,
  27513. 1600
  27514. ],
  27515. [
  27516. 9,
  27517. 1728
  27518. ],
  27519. [
  27520. 7,
  27521. 18
  27522. ],
  27523. [
  27524. 7,
  27525. 18
  27526. ],
  27527. [
  27528. 7,
  27529. 18
  27530. ],
  27531. [
  27532. 7,
  27533. 18
  27534. ],
  27535. [
  27536. 7,
  27537. 24
  27538. ],
  27539. [
  27540. 7,
  27541. 24
  27542. ],
  27543. [
  27544. 7,
  27545. 24
  27546. ],
  27547. [
  27548. 7,
  27549. 24
  27550. ],
  27551. [
  27552. 8,
  27553. 49
  27554. ],
  27555. [
  27556. 8,
  27557. 49
  27558. ],
  27559. [
  27560. 8,
  27561. 50
  27562. ],
  27563. [
  27564. 8,
  27565. 50
  27566. ],
  27567. [
  27568. 8,
  27569. 51
  27570. ],
  27571. [
  27572. 8,
  27573. 51
  27574. ],
  27575. [
  27576. 8,
  27577. 52
  27578. ],
  27579. [
  27580. 8,
  27581. 52
  27582. ],
  27583. [
  27584. 7,
  27585. 25
  27586. ],
  27587. [
  27588. 7,
  27589. 25
  27590. ],
  27591. [
  27592. 7,
  27593. 25
  27594. ],
  27595. [
  27596. 7,
  27597. 25
  27598. ],
  27599. [
  27600. 8,
  27601. 55
  27602. ],
  27603. [
  27604. 8,
  27605. 55
  27606. ],
  27607. [
  27608. 8,
  27609. 56
  27610. ],
  27611. [
  27612. 8,
  27613. 56
  27614. ],
  27615. [
  27616. 8,
  27617. 57
  27618. ],
  27619. [
  27620. 8,
  27621. 57
  27622. ],
  27623. [
  27624. 8,
  27625. 58
  27626. ],
  27627. [
  27628. 8,
  27629. 58
  27630. ],
  27631. [
  27632. 6,
  27633. 192
  27634. ],
  27635. [
  27636. 6,
  27637. 192
  27638. ],
  27639. [
  27640. 6,
  27641. 192
  27642. ],
  27643. [
  27644. 6,
  27645. 192
  27646. ],
  27647. [
  27648. 6,
  27649. 192
  27650. ],
  27651. [
  27652. 6,
  27653. 192
  27654. ],
  27655. [
  27656. 6,
  27657. 192
  27658. ],
  27659. [
  27660. 6,
  27661. 192
  27662. ],
  27663. [
  27664. 6,
  27665. 1664
  27666. ],
  27667. [
  27668. 6,
  27669. 1664
  27670. ],
  27671. [
  27672. 6,
  27673. 1664
  27674. ],
  27675. [
  27676. 6,
  27677. 1664
  27678. ],
  27679. [
  27680. 6,
  27681. 1664
  27682. ],
  27683. [
  27684. 6,
  27685. 1664
  27686. ],
  27687. [
  27688. 6,
  27689. 1664
  27690. ],
  27691. [
  27692. 6,
  27693. 1664
  27694. ],
  27695. [
  27696. 8,
  27697. 448
  27698. ],
  27699. [
  27700. 8,
  27701. 448
  27702. ],
  27703. [
  27704. 8,
  27705. 512
  27706. ],
  27707. [
  27708. 8,
  27709. 512
  27710. ],
  27711. [
  27712. 9,
  27713. 704
  27714. ],
  27715. [
  27716. 9,
  27717. 768
  27718. ],
  27719. [
  27720. 8,
  27721. 640
  27722. ],
  27723. [
  27724. 8,
  27725. 640
  27726. ],
  27727. [
  27728. 8,
  27729. 576
  27730. ],
  27731. [
  27732. 8,
  27733. 576
  27734. ],
  27735. [
  27736. 9,
  27737. 832
  27738. ],
  27739. [
  27740. 9,
  27741. 896
  27742. ],
  27743. [
  27744. 9,
  27745. 960
  27746. ],
  27747. [
  27748. 9,
  27749. 1024
  27750. ],
  27751. [
  27752. 9,
  27753. 1088
  27754. ],
  27755. [
  27756. 9,
  27757. 1152
  27758. ],
  27759. [
  27760. 9,
  27761. 1216
  27762. ],
  27763. [
  27764. 9,
  27765. 1280
  27766. ],
  27767. [
  27768. 9,
  27769. 1344
  27770. ],
  27771. [
  27772. 9,
  27773. 1408
  27774. ],
  27775. [
  27776. 7,
  27777. 256
  27778. ],
  27779. [
  27780. 7,
  27781. 256
  27782. ],
  27783. [
  27784. 7,
  27785. 256
  27786. ],
  27787. [
  27788. 7,
  27789. 256
  27790. ],
  27791. [
  27792. 4,
  27793. 2
  27794. ],
  27795. [
  27796. 4,
  27797. 2
  27798. ],
  27799. [
  27800. 4,
  27801. 2
  27802. ],
  27803. [
  27804. 4,
  27805. 2
  27806. ],
  27807. [
  27808. 4,
  27809. 2
  27810. ],
  27811. [
  27812. 4,
  27813. 2
  27814. ],
  27815. [
  27816. 4,
  27817. 2
  27818. ],
  27819. [
  27820. 4,
  27821. 2
  27822. ],
  27823. [
  27824. 4,
  27825. 2
  27826. ],
  27827. [
  27828. 4,
  27829. 2
  27830. ],
  27831. [
  27832. 4,
  27833. 2
  27834. ],
  27835. [
  27836. 4,
  27837. 2
  27838. ],
  27839. [
  27840. 4,
  27841. 2
  27842. ],
  27843. [
  27844. 4,
  27845. 2
  27846. ],
  27847. [
  27848. 4,
  27849. 2
  27850. ],
  27851. [
  27852. 4,
  27853. 2
  27854. ],
  27855. [
  27856. 4,
  27857. 2
  27858. ],
  27859. [
  27860. 4,
  27861. 2
  27862. ],
  27863. [
  27864. 4,
  27865. 2
  27866. ],
  27867. [
  27868. 4,
  27869. 2
  27870. ],
  27871. [
  27872. 4,
  27873. 2
  27874. ],
  27875. [
  27876. 4,
  27877. 2
  27878. ],
  27879. [
  27880. 4,
  27881. 2
  27882. ],
  27883. [
  27884. 4,
  27885. 2
  27886. ],
  27887. [
  27888. 4,
  27889. 2
  27890. ],
  27891. [
  27892. 4,
  27893. 2
  27894. ],
  27895. [
  27896. 4,
  27897. 2
  27898. ],
  27899. [
  27900. 4,
  27901. 2
  27902. ],
  27903. [
  27904. 4,
  27905. 2
  27906. ],
  27907. [
  27908. 4,
  27909. 2
  27910. ],
  27911. [
  27912. 4,
  27913. 2
  27914. ],
  27915. [
  27916. 4,
  27917. 2
  27918. ],
  27919. [
  27920. 4,
  27921. 3
  27922. ],
  27923. [
  27924. 4,
  27925. 3
  27926. ],
  27927. [
  27928. 4,
  27929. 3
  27930. ],
  27931. [
  27932. 4,
  27933. 3
  27934. ],
  27935. [
  27936. 4,
  27937. 3
  27938. ],
  27939. [
  27940. 4,
  27941. 3
  27942. ],
  27943. [
  27944. 4,
  27945. 3
  27946. ],
  27947. [
  27948. 4,
  27949. 3
  27950. ],
  27951. [
  27952. 4,
  27953. 3
  27954. ],
  27955. [
  27956. 4,
  27957. 3
  27958. ],
  27959. [
  27960. 4,
  27961. 3
  27962. ],
  27963. [
  27964. 4,
  27965. 3
  27966. ],
  27967. [
  27968. 4,
  27969. 3
  27970. ],
  27971. [
  27972. 4,
  27973. 3
  27974. ],
  27975. [
  27976. 4,
  27977. 3
  27978. ],
  27979. [
  27980. 4,
  27981. 3
  27982. ],
  27983. [
  27984. 4,
  27985. 3
  27986. ],
  27987. [
  27988. 4,
  27989. 3
  27990. ],
  27991. [
  27992. 4,
  27993. 3
  27994. ],
  27995. [
  27996. 4,
  27997. 3
  27998. ],
  27999. [
  28000. 4,
  28001. 3
  28002. ],
  28003. [
  28004. 4,
  28005. 3
  28006. ],
  28007. [
  28008. 4,
  28009. 3
  28010. ],
  28011. [
  28012. 4,
  28013. 3
  28014. ],
  28015. [
  28016. 4,
  28017. 3
  28018. ],
  28019. [
  28020. 4,
  28021. 3
  28022. ],
  28023. [
  28024. 4,
  28025. 3
  28026. ],
  28027. [
  28028. 4,
  28029. 3
  28030. ],
  28031. [
  28032. 4,
  28033. 3
  28034. ],
  28035. [
  28036. 4,
  28037. 3
  28038. ],
  28039. [
  28040. 4,
  28041. 3
  28042. ],
  28043. [
  28044. 4,
  28045. 3
  28046. ],
  28047. [
  28048. 5,
  28049. 128
  28050. ],
  28051. [
  28052. 5,
  28053. 128
  28054. ],
  28055. [
  28056. 5,
  28057. 128
  28058. ],
  28059. [
  28060. 5,
  28061. 128
  28062. ],
  28063. [
  28064. 5,
  28065. 128
  28066. ],
  28067. [
  28068. 5,
  28069. 128
  28070. ],
  28071. [
  28072. 5,
  28073. 128
  28074. ],
  28075. [
  28076. 5,
  28077. 128
  28078. ],
  28079. [
  28080. 5,
  28081. 128
  28082. ],
  28083. [
  28084. 5,
  28085. 128
  28086. ],
  28087. [
  28088. 5,
  28089. 128
  28090. ],
  28091. [
  28092. 5,
  28093. 128
  28094. ],
  28095. [
  28096. 5,
  28097. 128
  28098. ],
  28099. [
  28100. 5,
  28101. 128
  28102. ],
  28103. [
  28104. 5,
  28105. 128
  28106. ],
  28107. [
  28108. 5,
  28109. 128
  28110. ],
  28111. [
  28112. 5,
  28113. 8
  28114. ],
  28115. [
  28116. 5,
  28117. 8
  28118. ],
  28119. [
  28120. 5,
  28121. 8
  28122. ],
  28123. [
  28124. 5,
  28125. 8
  28126. ],
  28127. [
  28128. 5,
  28129. 8
  28130. ],
  28131. [
  28132. 5,
  28133. 8
  28134. ],
  28135. [
  28136. 5,
  28137. 8
  28138. ],
  28139. [
  28140. 5,
  28141. 8
  28142. ],
  28143. [
  28144. 5,
  28145. 8
  28146. ],
  28147. [
  28148. 5,
  28149. 8
  28150. ],
  28151. [
  28152. 5,
  28153. 8
  28154. ],
  28155. [
  28156. 5,
  28157. 8
  28158. ],
  28159. [
  28160. 5,
  28161. 8
  28162. ],
  28163. [
  28164. 5,
  28165. 8
  28166. ],
  28167. [
  28168. 5,
  28169. 8
  28170. ],
  28171. [
  28172. 5,
  28173. 8
  28174. ],
  28175. [
  28176. 5,
  28177. 9
  28178. ],
  28179. [
  28180. 5,
  28181. 9
  28182. ],
  28183. [
  28184. 5,
  28185. 9
  28186. ],
  28187. [
  28188. 5,
  28189. 9
  28190. ],
  28191. [
  28192. 5,
  28193. 9
  28194. ],
  28195. [
  28196. 5,
  28197. 9
  28198. ],
  28199. [
  28200. 5,
  28201. 9
  28202. ],
  28203. [
  28204. 5,
  28205. 9
  28206. ],
  28207. [
  28208. 5,
  28209. 9
  28210. ],
  28211. [
  28212. 5,
  28213. 9
  28214. ],
  28215. [
  28216. 5,
  28217. 9
  28218. ],
  28219. [
  28220. 5,
  28221. 9
  28222. ],
  28223. [
  28224. 5,
  28225. 9
  28226. ],
  28227. [
  28228. 5,
  28229. 9
  28230. ],
  28231. [
  28232. 5,
  28233. 9
  28234. ],
  28235. [
  28236. 5,
  28237. 9
  28238. ],
  28239. [
  28240. 6,
  28241. 16
  28242. ],
  28243. [
  28244. 6,
  28245. 16
  28246. ],
  28247. [
  28248. 6,
  28249. 16
  28250. ],
  28251. [
  28252. 6,
  28253. 16
  28254. ],
  28255. [
  28256. 6,
  28257. 16
  28258. ],
  28259. [
  28260. 6,
  28261. 16
  28262. ],
  28263. [
  28264. 6,
  28265. 16
  28266. ],
  28267. [
  28268. 6,
  28269. 16
  28270. ],
  28271. [
  28272. 6,
  28273. 17
  28274. ],
  28275. [
  28276. 6,
  28277. 17
  28278. ],
  28279. [
  28280. 6,
  28281. 17
  28282. ],
  28283. [
  28284. 6,
  28285. 17
  28286. ],
  28287. [
  28288. 6,
  28289. 17
  28290. ],
  28291. [
  28292. 6,
  28293. 17
  28294. ],
  28295. [
  28296. 6,
  28297. 17
  28298. ],
  28299. [
  28300. 6,
  28301. 17
  28302. ],
  28303. [
  28304. 4,
  28305. 4
  28306. ],
  28307. [
  28308. 4,
  28309. 4
  28310. ],
  28311. [
  28312. 4,
  28313. 4
  28314. ],
  28315. [
  28316. 4,
  28317. 4
  28318. ],
  28319. [
  28320. 4,
  28321. 4
  28322. ],
  28323. [
  28324. 4,
  28325. 4
  28326. ],
  28327. [
  28328. 4,
  28329. 4
  28330. ],
  28331. [
  28332. 4,
  28333. 4
  28334. ],
  28335. [
  28336. 4,
  28337. 4
  28338. ],
  28339. [
  28340. 4,
  28341. 4
  28342. ],
  28343. [
  28344. 4,
  28345. 4
  28346. ],
  28347. [
  28348. 4,
  28349. 4
  28350. ],
  28351. [
  28352. 4,
  28353. 4
  28354. ],
  28355. [
  28356. 4,
  28357. 4
  28358. ],
  28359. [
  28360. 4,
  28361. 4
  28362. ],
  28363. [
  28364. 4,
  28365. 4
  28366. ],
  28367. [
  28368. 4,
  28369. 4
  28370. ],
  28371. [
  28372. 4,
  28373. 4
  28374. ],
  28375. [
  28376. 4,
  28377. 4
  28378. ],
  28379. [
  28380. 4,
  28381. 4
  28382. ],
  28383. [
  28384. 4,
  28385. 4
  28386. ],
  28387. [
  28388. 4,
  28389. 4
  28390. ],
  28391. [
  28392. 4,
  28393. 4
  28394. ],
  28395. [
  28396. 4,
  28397. 4
  28398. ],
  28399. [
  28400. 4,
  28401. 4
  28402. ],
  28403. [
  28404. 4,
  28405. 4
  28406. ],
  28407. [
  28408. 4,
  28409. 4
  28410. ],
  28411. [
  28412. 4,
  28413. 4
  28414. ],
  28415. [
  28416. 4,
  28417. 4
  28418. ],
  28419. [
  28420. 4,
  28421. 4
  28422. ],
  28423. [
  28424. 4,
  28425. 4
  28426. ],
  28427. [
  28428. 4,
  28429. 4
  28430. ],
  28431. [
  28432. 4,
  28433. 5
  28434. ],
  28435. [
  28436. 4,
  28437. 5
  28438. ],
  28439. [
  28440. 4,
  28441. 5
  28442. ],
  28443. [
  28444. 4,
  28445. 5
  28446. ],
  28447. [
  28448. 4,
  28449. 5
  28450. ],
  28451. [
  28452. 4,
  28453. 5
  28454. ],
  28455. [
  28456. 4,
  28457. 5
  28458. ],
  28459. [
  28460. 4,
  28461. 5
  28462. ],
  28463. [
  28464. 4,
  28465. 5
  28466. ],
  28467. [
  28468. 4,
  28469. 5
  28470. ],
  28471. [
  28472. 4,
  28473. 5
  28474. ],
  28475. [
  28476. 4,
  28477. 5
  28478. ],
  28479. [
  28480. 4,
  28481. 5
  28482. ],
  28483. [
  28484. 4,
  28485. 5
  28486. ],
  28487. [
  28488. 4,
  28489. 5
  28490. ],
  28491. [
  28492. 4,
  28493. 5
  28494. ],
  28495. [
  28496. 4,
  28497. 5
  28498. ],
  28499. [
  28500. 4,
  28501. 5
  28502. ],
  28503. [
  28504. 4,
  28505. 5
  28506. ],
  28507. [
  28508. 4,
  28509. 5
  28510. ],
  28511. [
  28512. 4,
  28513. 5
  28514. ],
  28515. [
  28516. 4,
  28517. 5
  28518. ],
  28519. [
  28520. 4,
  28521. 5
  28522. ],
  28523. [
  28524. 4,
  28525. 5
  28526. ],
  28527. [
  28528. 4,
  28529. 5
  28530. ],
  28531. [
  28532. 4,
  28533. 5
  28534. ],
  28535. [
  28536. 4,
  28537. 5
  28538. ],
  28539. [
  28540. 4,
  28541. 5
  28542. ],
  28543. [
  28544. 4,
  28545. 5
  28546. ],
  28547. [
  28548. 4,
  28549. 5
  28550. ],
  28551. [
  28552. 4,
  28553. 5
  28554. ],
  28555. [
  28556. 4,
  28557. 5
  28558. ],
  28559. [
  28560. 6,
  28561. 14
  28562. ],
  28563. [
  28564. 6,
  28565. 14
  28566. ],
  28567. [
  28568. 6,
  28569. 14
  28570. ],
  28571. [
  28572. 6,
  28573. 14
  28574. ],
  28575. [
  28576. 6,
  28577. 14
  28578. ],
  28579. [
  28580. 6,
  28581. 14
  28582. ],
  28583. [
  28584. 6,
  28585. 14
  28586. ],
  28587. [
  28588. 6,
  28589. 14
  28590. ],
  28591. [
  28592. 6,
  28593. 15
  28594. ],
  28595. [
  28596. 6,
  28597. 15
  28598. ],
  28599. [
  28600. 6,
  28601. 15
  28602. ],
  28603. [
  28604. 6,
  28605. 15
  28606. ],
  28607. [
  28608. 6,
  28609. 15
  28610. ],
  28611. [
  28612. 6,
  28613. 15
  28614. ],
  28615. [
  28616. 6,
  28617. 15
  28618. ],
  28619. [
  28620. 6,
  28621. 15
  28622. ],
  28623. [
  28624. 5,
  28625. 64
  28626. ],
  28627. [
  28628. 5,
  28629. 64
  28630. ],
  28631. [
  28632. 5,
  28633. 64
  28634. ],
  28635. [
  28636. 5,
  28637. 64
  28638. ],
  28639. [
  28640. 5,
  28641. 64
  28642. ],
  28643. [
  28644. 5,
  28645. 64
  28646. ],
  28647. [
  28648. 5,
  28649. 64
  28650. ],
  28651. [
  28652. 5,
  28653. 64
  28654. ],
  28655. [
  28656. 5,
  28657. 64
  28658. ],
  28659. [
  28660. 5,
  28661. 64
  28662. ],
  28663. [
  28664. 5,
  28665. 64
  28666. ],
  28667. [
  28668. 5,
  28669. 64
  28670. ],
  28671. [
  28672. 5,
  28673. 64
  28674. ],
  28675. [
  28676. 5,
  28677. 64
  28678. ],
  28679. [
  28680. 5,
  28681. 64
  28682. ],
  28683. [
  28684. 5,
  28685. 64
  28686. ],
  28687. [
  28688. 4,
  28689. 6
  28690. ],
  28691. [
  28692. 4,
  28693. 6
  28694. ],
  28695. [
  28696. 4,
  28697. 6
  28698. ],
  28699. [
  28700. 4,
  28701. 6
  28702. ],
  28703. [
  28704. 4,
  28705. 6
  28706. ],
  28707. [
  28708. 4,
  28709. 6
  28710. ],
  28711. [
  28712. 4,
  28713. 6
  28714. ],
  28715. [
  28716. 4,
  28717. 6
  28718. ],
  28719. [
  28720. 4,
  28721. 6
  28722. ],
  28723. [
  28724. 4,
  28725. 6
  28726. ],
  28727. [
  28728. 4,
  28729. 6
  28730. ],
  28731. [
  28732. 4,
  28733. 6
  28734. ],
  28735. [
  28736. 4,
  28737. 6
  28738. ],
  28739. [
  28740. 4,
  28741. 6
  28742. ],
  28743. [
  28744. 4,
  28745. 6
  28746. ],
  28747. [
  28748. 4,
  28749. 6
  28750. ],
  28751. [
  28752. 4,
  28753. 6
  28754. ],
  28755. [
  28756. 4,
  28757. 6
  28758. ],
  28759. [
  28760. 4,
  28761. 6
  28762. ],
  28763. [
  28764. 4,
  28765. 6
  28766. ],
  28767. [
  28768. 4,
  28769. 6
  28770. ],
  28771. [
  28772. 4,
  28773. 6
  28774. ],
  28775. [
  28776. 4,
  28777. 6
  28778. ],
  28779. [
  28780. 4,
  28781. 6
  28782. ],
  28783. [
  28784. 4,
  28785. 6
  28786. ],
  28787. [
  28788. 4,
  28789. 6
  28790. ],
  28791. [
  28792. 4,
  28793. 6
  28794. ],
  28795. [
  28796. 4,
  28797. 6
  28798. ],
  28799. [
  28800. 4,
  28801. 6
  28802. ],
  28803. [
  28804. 4,
  28805. 6
  28806. ],
  28807. [
  28808. 4,
  28809. 6
  28810. ],
  28811. [
  28812. 4,
  28813. 6
  28814. ],
  28815. [
  28816. 4,
  28817. 7
  28818. ],
  28819. [
  28820. 4,
  28821. 7
  28822. ],
  28823. [
  28824. 4,
  28825. 7
  28826. ],
  28827. [
  28828. 4,
  28829. 7
  28830. ],
  28831. [
  28832. 4,
  28833. 7
  28834. ],
  28835. [
  28836. 4,
  28837. 7
  28838. ],
  28839. [
  28840. 4,
  28841. 7
  28842. ],
  28843. [
  28844. 4,
  28845. 7
  28846. ],
  28847. [
  28848. 4,
  28849. 7
  28850. ],
  28851. [
  28852. 4,
  28853. 7
  28854. ],
  28855. [
  28856. 4,
  28857. 7
  28858. ],
  28859. [
  28860. 4,
  28861. 7
  28862. ],
  28863. [
  28864. 4,
  28865. 7
  28866. ],
  28867. [
  28868. 4,
  28869. 7
  28870. ],
  28871. [
  28872. 4,
  28873. 7
  28874. ],
  28875. [
  28876. 4,
  28877. 7
  28878. ],
  28879. [
  28880. 4,
  28881. 7
  28882. ],
  28883. [
  28884. 4,
  28885. 7
  28886. ],
  28887. [
  28888. 4,
  28889. 7
  28890. ],
  28891. [
  28892. 4,
  28893. 7
  28894. ],
  28895. [
  28896. 4,
  28897. 7
  28898. ],
  28899. [
  28900. 4,
  28901. 7
  28902. ],
  28903. [
  28904. 4,
  28905. 7
  28906. ],
  28907. [
  28908. 4,
  28909. 7
  28910. ],
  28911. [
  28912. 4,
  28913. 7
  28914. ],
  28915. [
  28916. 4,
  28917. 7
  28918. ],
  28919. [
  28920. 4,
  28921. 7
  28922. ],
  28923. [
  28924. 4,
  28925. 7
  28926. ],
  28927. [
  28928. 4,
  28929. 7
  28930. ],
  28931. [
  28932. 4,
  28933. 7
  28934. ],
  28935. [
  28936. 4,
  28937. 7
  28938. ],
  28939. [
  28940. 4,
  28941. 7
  28942. ]
  28943. ];
  28944. var blackTable1 = [
  28945. [
  28946. -1,
  28947. -1
  28948. ],
  28949. [
  28950. -1,
  28951. -1
  28952. ],
  28953. [
  28954. 12,
  28955. ccittEOL
  28956. ],
  28957. [
  28958. 12,
  28959. ccittEOL
  28960. ],
  28961. [
  28962. -1,
  28963. -1
  28964. ],
  28965. [
  28966. -1,
  28967. -1
  28968. ],
  28969. [
  28970. -1,
  28971. -1
  28972. ],
  28973. [
  28974. -1,
  28975. -1
  28976. ],
  28977. [
  28978. -1,
  28979. -1
  28980. ],
  28981. [
  28982. -1,
  28983. -1
  28984. ],
  28985. [
  28986. -1,
  28987. -1
  28988. ],
  28989. [
  28990. -1,
  28991. -1
  28992. ],
  28993. [
  28994. -1,
  28995. -1
  28996. ],
  28997. [
  28998. -1,
  28999. -1
  29000. ],
  29001. [
  29002. -1,
  29003. -1
  29004. ],
  29005. [
  29006. -1,
  29007. -1
  29008. ],
  29009. [
  29010. -1,
  29011. -1
  29012. ],
  29013. [
  29014. -1,
  29015. -1
  29016. ],
  29017. [
  29018. -1,
  29019. -1
  29020. ],
  29021. [
  29022. -1,
  29023. -1
  29024. ],
  29025. [
  29026. -1,
  29027. -1
  29028. ],
  29029. [
  29030. -1,
  29031. -1
  29032. ],
  29033. [
  29034. -1,
  29035. -1
  29036. ],
  29037. [
  29038. -1,
  29039. -1
  29040. ],
  29041. [
  29042. -1,
  29043. -1
  29044. ],
  29045. [
  29046. -1,
  29047. -1
  29048. ],
  29049. [
  29050. -1,
  29051. -1
  29052. ],
  29053. [
  29054. -1,
  29055. -1
  29056. ],
  29057. [
  29058. -1,
  29059. -1
  29060. ],
  29061. [
  29062. -1,
  29063. -1
  29064. ],
  29065. [
  29066. -1,
  29067. -1
  29068. ],
  29069. [
  29070. -1,
  29071. -1
  29072. ],
  29073. [
  29074. 11,
  29075. 1792
  29076. ],
  29077. [
  29078. 11,
  29079. 1792
  29080. ],
  29081. [
  29082. 11,
  29083. 1792
  29084. ],
  29085. [
  29086. 11,
  29087. 1792
  29088. ],
  29089. [
  29090. 12,
  29091. 1984
  29092. ],
  29093. [
  29094. 12,
  29095. 1984
  29096. ],
  29097. [
  29098. 12,
  29099. 2048
  29100. ],
  29101. [
  29102. 12,
  29103. 2048
  29104. ],
  29105. [
  29106. 12,
  29107. 2112
  29108. ],
  29109. [
  29110. 12,
  29111. 2112
  29112. ],
  29113. [
  29114. 12,
  29115. 2176
  29116. ],
  29117. [
  29118. 12,
  29119. 2176
  29120. ],
  29121. [
  29122. 12,
  29123. 2240
  29124. ],
  29125. [
  29126. 12,
  29127. 2240
  29128. ],
  29129. [
  29130. 12,
  29131. 2304
  29132. ],
  29133. [
  29134. 12,
  29135. 2304
  29136. ],
  29137. [
  29138. 11,
  29139. 1856
  29140. ],
  29141. [
  29142. 11,
  29143. 1856
  29144. ],
  29145. [
  29146. 11,
  29147. 1856
  29148. ],
  29149. [
  29150. 11,
  29151. 1856
  29152. ],
  29153. [
  29154. 11,
  29155. 1920
  29156. ],
  29157. [
  29158. 11,
  29159. 1920
  29160. ],
  29161. [
  29162. 11,
  29163. 1920
  29164. ],
  29165. [
  29166. 11,
  29167. 1920
  29168. ],
  29169. [
  29170. 12,
  29171. 2368
  29172. ],
  29173. [
  29174. 12,
  29175. 2368
  29176. ],
  29177. [
  29178. 12,
  29179. 2432
  29180. ],
  29181. [
  29182. 12,
  29183. 2432
  29184. ],
  29185. [
  29186. 12,
  29187. 2496
  29188. ],
  29189. [
  29190. 12,
  29191. 2496
  29192. ],
  29193. [
  29194. 12,
  29195. 2560
  29196. ],
  29197. [
  29198. 12,
  29199. 2560
  29200. ],
  29201. [
  29202. 10,
  29203. 18
  29204. ],
  29205. [
  29206. 10,
  29207. 18
  29208. ],
  29209. [
  29210. 10,
  29211. 18
  29212. ],
  29213. [
  29214. 10,
  29215. 18
  29216. ],
  29217. [
  29218. 10,
  29219. 18
  29220. ],
  29221. [
  29222. 10,
  29223. 18
  29224. ],
  29225. [
  29226. 10,
  29227. 18
  29228. ],
  29229. [
  29230. 10,
  29231. 18
  29232. ],
  29233. [
  29234. 12,
  29235. 52
  29236. ],
  29237. [
  29238. 12,
  29239. 52
  29240. ],
  29241. [
  29242. 13,
  29243. 640
  29244. ],
  29245. [
  29246. 13,
  29247. 704
  29248. ],
  29249. [
  29250. 13,
  29251. 768
  29252. ],
  29253. [
  29254. 13,
  29255. 832
  29256. ],
  29257. [
  29258. 12,
  29259. 55
  29260. ],
  29261. [
  29262. 12,
  29263. 55
  29264. ],
  29265. [
  29266. 12,
  29267. 56
  29268. ],
  29269. [
  29270. 12,
  29271. 56
  29272. ],
  29273. [
  29274. 13,
  29275. 1280
  29276. ],
  29277. [
  29278. 13,
  29279. 1344
  29280. ],
  29281. [
  29282. 13,
  29283. 1408
  29284. ],
  29285. [
  29286. 13,
  29287. 1472
  29288. ],
  29289. [
  29290. 12,
  29291. 59
  29292. ],
  29293. [
  29294. 12,
  29295. 59
  29296. ],
  29297. [
  29298. 12,
  29299. 60
  29300. ],
  29301. [
  29302. 12,
  29303. 60
  29304. ],
  29305. [
  29306. 13,
  29307. 1536
  29308. ],
  29309. [
  29310. 13,
  29311. 1600
  29312. ],
  29313. [
  29314. 11,
  29315. 24
  29316. ],
  29317. [
  29318. 11,
  29319. 24
  29320. ],
  29321. [
  29322. 11,
  29323. 24
  29324. ],
  29325. [
  29326. 11,
  29327. 24
  29328. ],
  29329. [
  29330. 11,
  29331. 25
  29332. ],
  29333. [
  29334. 11,
  29335. 25
  29336. ],
  29337. [
  29338. 11,
  29339. 25
  29340. ],
  29341. [
  29342. 11,
  29343. 25
  29344. ],
  29345. [
  29346. 13,
  29347. 1664
  29348. ],
  29349. [
  29350. 13,
  29351. 1728
  29352. ],
  29353. [
  29354. 12,
  29355. 320
  29356. ],
  29357. [
  29358. 12,
  29359. 320
  29360. ],
  29361. [
  29362. 12,
  29363. 384
  29364. ],
  29365. [
  29366. 12,
  29367. 384
  29368. ],
  29369. [
  29370. 12,
  29371. 448
  29372. ],
  29373. [
  29374. 12,
  29375. 448
  29376. ],
  29377. [
  29378. 13,
  29379. 512
  29380. ],
  29381. [
  29382. 13,
  29383. 576
  29384. ],
  29385. [
  29386. 12,
  29387. 53
  29388. ],
  29389. [
  29390. 12,
  29391. 53
  29392. ],
  29393. [
  29394. 12,
  29395. 54
  29396. ],
  29397. [
  29398. 12,
  29399. 54
  29400. ],
  29401. [
  29402. 13,
  29403. 896
  29404. ],
  29405. [
  29406. 13,
  29407. 960
  29408. ],
  29409. [
  29410. 13,
  29411. 1024
  29412. ],
  29413. [
  29414. 13,
  29415. 1088
  29416. ],
  29417. [
  29418. 13,
  29419. 1152
  29420. ],
  29421. [
  29422. 13,
  29423. 1216
  29424. ],
  29425. [
  29426. 10,
  29427. 64
  29428. ],
  29429. [
  29430. 10,
  29431. 64
  29432. ],
  29433. [
  29434. 10,
  29435. 64
  29436. ],
  29437. [
  29438. 10,
  29439. 64
  29440. ],
  29441. [
  29442. 10,
  29443. 64
  29444. ],
  29445. [
  29446. 10,
  29447. 64
  29448. ],
  29449. [
  29450. 10,
  29451. 64
  29452. ],
  29453. [
  29454. 10,
  29455. 64
  29456. ]
  29457. ];
  29458. var blackTable2 = [
  29459. [
  29460. 8,
  29461. 13
  29462. ],
  29463. [
  29464. 8,
  29465. 13
  29466. ],
  29467. [
  29468. 8,
  29469. 13
  29470. ],
  29471. [
  29472. 8,
  29473. 13
  29474. ],
  29475. [
  29476. 8,
  29477. 13
  29478. ],
  29479. [
  29480. 8,
  29481. 13
  29482. ],
  29483. [
  29484. 8,
  29485. 13
  29486. ],
  29487. [
  29488. 8,
  29489. 13
  29490. ],
  29491. [
  29492. 8,
  29493. 13
  29494. ],
  29495. [
  29496. 8,
  29497. 13
  29498. ],
  29499. [
  29500. 8,
  29501. 13
  29502. ],
  29503. [
  29504. 8,
  29505. 13
  29506. ],
  29507. [
  29508. 8,
  29509. 13
  29510. ],
  29511. [
  29512. 8,
  29513. 13
  29514. ],
  29515. [
  29516. 8,
  29517. 13
  29518. ],
  29519. [
  29520. 8,
  29521. 13
  29522. ],
  29523. [
  29524. 11,
  29525. 23
  29526. ],
  29527. [
  29528. 11,
  29529. 23
  29530. ],
  29531. [
  29532. 12,
  29533. 50
  29534. ],
  29535. [
  29536. 12,
  29537. 51
  29538. ],
  29539. [
  29540. 12,
  29541. 44
  29542. ],
  29543. [
  29544. 12,
  29545. 45
  29546. ],
  29547. [
  29548. 12,
  29549. 46
  29550. ],
  29551. [
  29552. 12,
  29553. 47
  29554. ],
  29555. [
  29556. 12,
  29557. 57
  29558. ],
  29559. [
  29560. 12,
  29561. 58
  29562. ],
  29563. [
  29564. 12,
  29565. 61
  29566. ],
  29567. [
  29568. 12,
  29569. 256
  29570. ],
  29571. [
  29572. 10,
  29573. 16
  29574. ],
  29575. [
  29576. 10,
  29577. 16
  29578. ],
  29579. [
  29580. 10,
  29581. 16
  29582. ],
  29583. [
  29584. 10,
  29585. 16
  29586. ],
  29587. [
  29588. 10,
  29589. 17
  29590. ],
  29591. [
  29592. 10,
  29593. 17
  29594. ],
  29595. [
  29596. 10,
  29597. 17
  29598. ],
  29599. [
  29600. 10,
  29601. 17
  29602. ],
  29603. [
  29604. 12,
  29605. 48
  29606. ],
  29607. [
  29608. 12,
  29609. 49
  29610. ],
  29611. [
  29612. 12,
  29613. 62
  29614. ],
  29615. [
  29616. 12,
  29617. 63
  29618. ],
  29619. [
  29620. 12,
  29621. 30
  29622. ],
  29623. [
  29624. 12,
  29625. 31
  29626. ],
  29627. [
  29628. 12,
  29629. 32
  29630. ],
  29631. [
  29632. 12,
  29633. 33
  29634. ],
  29635. [
  29636. 12,
  29637. 40
  29638. ],
  29639. [
  29640. 12,
  29641. 41
  29642. ],
  29643. [
  29644. 11,
  29645. 22
  29646. ],
  29647. [
  29648. 11,
  29649. 22
  29650. ],
  29651. [
  29652. 8,
  29653. 14
  29654. ],
  29655. [
  29656. 8,
  29657. 14
  29658. ],
  29659. [
  29660. 8,
  29661. 14
  29662. ],
  29663. [
  29664. 8,
  29665. 14
  29666. ],
  29667. [
  29668. 8,
  29669. 14
  29670. ],
  29671. [
  29672. 8,
  29673. 14
  29674. ],
  29675. [
  29676. 8,
  29677. 14
  29678. ],
  29679. [
  29680. 8,
  29681. 14
  29682. ],
  29683. [
  29684. 8,
  29685. 14
  29686. ],
  29687. [
  29688. 8,
  29689. 14
  29690. ],
  29691. [
  29692. 8,
  29693. 14
  29694. ],
  29695. [
  29696. 8,
  29697. 14
  29698. ],
  29699. [
  29700. 8,
  29701. 14
  29702. ],
  29703. [
  29704. 8,
  29705. 14
  29706. ],
  29707. [
  29708. 8,
  29709. 14
  29710. ],
  29711. [
  29712. 8,
  29713. 14
  29714. ],
  29715. [
  29716. 7,
  29717. 10
  29718. ],
  29719. [
  29720. 7,
  29721. 10
  29722. ],
  29723. [
  29724. 7,
  29725. 10
  29726. ],
  29727. [
  29728. 7,
  29729. 10
  29730. ],
  29731. [
  29732. 7,
  29733. 10
  29734. ],
  29735. [
  29736. 7,
  29737. 10
  29738. ],
  29739. [
  29740. 7,
  29741. 10
  29742. ],
  29743. [
  29744. 7,
  29745. 10
  29746. ],
  29747. [
  29748. 7,
  29749. 10
  29750. ],
  29751. [
  29752. 7,
  29753. 10
  29754. ],
  29755. [
  29756. 7,
  29757. 10
  29758. ],
  29759. [
  29760. 7,
  29761. 10
  29762. ],
  29763. [
  29764. 7,
  29765. 10
  29766. ],
  29767. [
  29768. 7,
  29769. 10
  29770. ],
  29771. [
  29772. 7,
  29773. 10
  29774. ],
  29775. [
  29776. 7,
  29777. 10
  29778. ],
  29779. [
  29780. 7,
  29781. 10
  29782. ],
  29783. [
  29784. 7,
  29785. 10
  29786. ],
  29787. [
  29788. 7,
  29789. 10
  29790. ],
  29791. [
  29792. 7,
  29793. 10
  29794. ],
  29795. [
  29796. 7,
  29797. 10
  29798. ],
  29799. [
  29800. 7,
  29801. 10
  29802. ],
  29803. [
  29804. 7,
  29805. 10
  29806. ],
  29807. [
  29808. 7,
  29809. 10
  29810. ],
  29811. [
  29812. 7,
  29813. 10
  29814. ],
  29815. [
  29816. 7,
  29817. 10
  29818. ],
  29819. [
  29820. 7,
  29821. 10
  29822. ],
  29823. [
  29824. 7,
  29825. 10
  29826. ],
  29827. [
  29828. 7,
  29829. 10
  29830. ],
  29831. [
  29832. 7,
  29833. 10
  29834. ],
  29835. [
  29836. 7,
  29837. 10
  29838. ],
  29839. [
  29840. 7,
  29841. 10
  29842. ],
  29843. [
  29844. 7,
  29845. 11
  29846. ],
  29847. [
  29848. 7,
  29849. 11
  29850. ],
  29851. [
  29852. 7,
  29853. 11
  29854. ],
  29855. [
  29856. 7,
  29857. 11
  29858. ],
  29859. [
  29860. 7,
  29861. 11
  29862. ],
  29863. [
  29864. 7,
  29865. 11
  29866. ],
  29867. [
  29868. 7,
  29869. 11
  29870. ],
  29871. [
  29872. 7,
  29873. 11
  29874. ],
  29875. [
  29876. 7,
  29877. 11
  29878. ],
  29879. [
  29880. 7,
  29881. 11
  29882. ],
  29883. [
  29884. 7,
  29885. 11
  29886. ],
  29887. [
  29888. 7,
  29889. 11
  29890. ],
  29891. [
  29892. 7,
  29893. 11
  29894. ],
  29895. [
  29896. 7,
  29897. 11
  29898. ],
  29899. [
  29900. 7,
  29901. 11
  29902. ],
  29903. [
  29904. 7,
  29905. 11
  29906. ],
  29907. [
  29908. 7,
  29909. 11
  29910. ],
  29911. [
  29912. 7,
  29913. 11
  29914. ],
  29915. [
  29916. 7,
  29917. 11
  29918. ],
  29919. [
  29920. 7,
  29921. 11
  29922. ],
  29923. [
  29924. 7,
  29925. 11
  29926. ],
  29927. [
  29928. 7,
  29929. 11
  29930. ],
  29931. [
  29932. 7,
  29933. 11
  29934. ],
  29935. [
  29936. 7,
  29937. 11
  29938. ],
  29939. [
  29940. 7,
  29941. 11
  29942. ],
  29943. [
  29944. 7,
  29945. 11
  29946. ],
  29947. [
  29948. 7,
  29949. 11
  29950. ],
  29951. [
  29952. 7,
  29953. 11
  29954. ],
  29955. [
  29956. 7,
  29957. 11
  29958. ],
  29959. [
  29960. 7,
  29961. 11
  29962. ],
  29963. [
  29964. 7,
  29965. 11
  29966. ],
  29967. [
  29968. 7,
  29969. 11
  29970. ],
  29971. [
  29972. 9,
  29973. 15
  29974. ],
  29975. [
  29976. 9,
  29977. 15
  29978. ],
  29979. [
  29980. 9,
  29981. 15
  29982. ],
  29983. [
  29984. 9,
  29985. 15
  29986. ],
  29987. [
  29988. 9,
  29989. 15
  29990. ],
  29991. [
  29992. 9,
  29993. 15
  29994. ],
  29995. [
  29996. 9,
  29997. 15
  29998. ],
  29999. [
  30000. 9,
  30001. 15
  30002. ],
  30003. [
  30004. 12,
  30005. 128
  30006. ],
  30007. [
  30008. 12,
  30009. 192
  30010. ],
  30011. [
  30012. 12,
  30013. 26
  30014. ],
  30015. [
  30016. 12,
  30017. 27
  30018. ],
  30019. [
  30020. 12,
  30021. 28
  30022. ],
  30023. [
  30024. 12,
  30025. 29
  30026. ],
  30027. [
  30028. 11,
  30029. 19
  30030. ],
  30031. [
  30032. 11,
  30033. 19
  30034. ],
  30035. [
  30036. 11,
  30037. 20
  30038. ],
  30039. [
  30040. 11,
  30041. 20
  30042. ],
  30043. [
  30044. 12,
  30045. 34
  30046. ],
  30047. [
  30048. 12,
  30049. 35
  30050. ],
  30051. [
  30052. 12,
  30053. 36
  30054. ],
  30055. [
  30056. 12,
  30057. 37
  30058. ],
  30059. [
  30060. 12,
  30061. 38
  30062. ],
  30063. [
  30064. 12,
  30065. 39
  30066. ],
  30067. [
  30068. 11,
  30069. 21
  30070. ],
  30071. [
  30072. 11,
  30073. 21
  30074. ],
  30075. [
  30076. 12,
  30077. 42
  30078. ],
  30079. [
  30080. 12,
  30081. 43
  30082. ],
  30083. [
  30084. 10,
  30085. 0
  30086. ],
  30087. [
  30088. 10,
  30089. 0
  30090. ],
  30091. [
  30092. 10,
  30093. 0
  30094. ],
  30095. [
  30096. 10,
  30097. 0
  30098. ],
  30099. [
  30100. 7,
  30101. 12
  30102. ],
  30103. [
  30104. 7,
  30105. 12
  30106. ],
  30107. [
  30108. 7,
  30109. 12
  30110. ],
  30111. [
  30112. 7,
  30113. 12
  30114. ],
  30115. [
  30116. 7,
  30117. 12
  30118. ],
  30119. [
  30120. 7,
  30121. 12
  30122. ],
  30123. [
  30124. 7,
  30125. 12
  30126. ],
  30127. [
  30128. 7,
  30129. 12
  30130. ],
  30131. [
  30132. 7,
  30133. 12
  30134. ],
  30135. [
  30136. 7,
  30137. 12
  30138. ],
  30139. [
  30140. 7,
  30141. 12
  30142. ],
  30143. [
  30144. 7,
  30145. 12
  30146. ],
  30147. [
  30148. 7,
  30149. 12
  30150. ],
  30151. [
  30152. 7,
  30153. 12
  30154. ],
  30155. [
  30156. 7,
  30157. 12
  30158. ],
  30159. [
  30160. 7,
  30161. 12
  30162. ],
  30163. [
  30164. 7,
  30165. 12
  30166. ],
  30167. [
  30168. 7,
  30169. 12
  30170. ],
  30171. [
  30172. 7,
  30173. 12
  30174. ],
  30175. [
  30176. 7,
  30177. 12
  30178. ],
  30179. [
  30180. 7,
  30181. 12
  30182. ],
  30183. [
  30184. 7,
  30185. 12
  30186. ],
  30187. [
  30188. 7,
  30189. 12
  30190. ],
  30191. [
  30192. 7,
  30193. 12
  30194. ],
  30195. [
  30196. 7,
  30197. 12
  30198. ],
  30199. [
  30200. 7,
  30201. 12
  30202. ],
  30203. [
  30204. 7,
  30205. 12
  30206. ],
  30207. [
  30208. 7,
  30209. 12
  30210. ],
  30211. [
  30212. 7,
  30213. 12
  30214. ],
  30215. [
  30216. 7,
  30217. 12
  30218. ],
  30219. [
  30220. 7,
  30221. 12
  30222. ],
  30223. [
  30224. 7,
  30225. 12
  30226. ]
  30227. ];
  30228. var blackTable3 = [
  30229. [
  30230. -1,
  30231. -1
  30232. ],
  30233. [
  30234. -1,
  30235. -1
  30236. ],
  30237. [
  30238. -1,
  30239. -1
  30240. ],
  30241. [
  30242. -1,
  30243. -1
  30244. ],
  30245. [
  30246. 6,
  30247. 9
  30248. ],
  30249. [
  30250. 6,
  30251. 8
  30252. ],
  30253. [
  30254. 5,
  30255. 7
  30256. ],
  30257. [
  30258. 5,
  30259. 7
  30260. ],
  30261. [
  30262. 4,
  30263. 6
  30264. ],
  30265. [
  30266. 4,
  30267. 6
  30268. ],
  30269. [
  30270. 4,
  30271. 6
  30272. ],
  30273. [
  30274. 4,
  30275. 6
  30276. ],
  30277. [
  30278. 4,
  30279. 5
  30280. ],
  30281. [
  30282. 4,
  30283. 5
  30284. ],
  30285. [
  30286. 4,
  30287. 5
  30288. ],
  30289. [
  30290. 4,
  30291. 5
  30292. ],
  30293. [
  30294. 3,
  30295. 1
  30296. ],
  30297. [
  30298. 3,
  30299. 1
  30300. ],
  30301. [
  30302. 3,
  30303. 1
  30304. ],
  30305. [
  30306. 3,
  30307. 1
  30308. ],
  30309. [
  30310. 3,
  30311. 1
  30312. ],
  30313. [
  30314. 3,
  30315. 1
  30316. ],
  30317. [
  30318. 3,
  30319. 1
  30320. ],
  30321. [
  30322. 3,
  30323. 1
  30324. ],
  30325. [
  30326. 3,
  30327. 4
  30328. ],
  30329. [
  30330. 3,
  30331. 4
  30332. ],
  30333. [
  30334. 3,
  30335. 4
  30336. ],
  30337. [
  30338. 3,
  30339. 4
  30340. ],
  30341. [
  30342. 3,
  30343. 4
  30344. ],
  30345. [
  30346. 3,
  30347. 4
  30348. ],
  30349. [
  30350. 3,
  30351. 4
  30352. ],
  30353. [
  30354. 3,
  30355. 4
  30356. ],
  30357. [
  30358. 2,
  30359. 3
  30360. ],
  30361. [
  30362. 2,
  30363. 3
  30364. ],
  30365. [
  30366. 2,
  30367. 3
  30368. ],
  30369. [
  30370. 2,
  30371. 3
  30372. ],
  30373. [
  30374. 2,
  30375. 3
  30376. ],
  30377. [
  30378. 2,
  30379. 3
  30380. ],
  30381. [
  30382. 2,
  30383. 3
  30384. ],
  30385. [
  30386. 2,
  30387. 3
  30388. ],
  30389. [
  30390. 2,
  30391. 3
  30392. ],
  30393. [
  30394. 2,
  30395. 3
  30396. ],
  30397. [
  30398. 2,
  30399. 3
  30400. ],
  30401. [
  30402. 2,
  30403. 3
  30404. ],
  30405. [
  30406. 2,
  30407. 3
  30408. ],
  30409. [
  30410. 2,
  30411. 3
  30412. ],
  30413. [
  30414. 2,
  30415. 3
  30416. ],
  30417. [
  30418. 2,
  30419. 3
  30420. ],
  30421. [
  30422. 2,
  30423. 2
  30424. ],
  30425. [
  30426. 2,
  30427. 2
  30428. ],
  30429. [
  30430. 2,
  30431. 2
  30432. ],
  30433. [
  30434. 2,
  30435. 2
  30436. ],
  30437. [
  30438. 2,
  30439. 2
  30440. ],
  30441. [
  30442. 2,
  30443. 2
  30444. ],
  30445. [
  30446. 2,
  30447. 2
  30448. ],
  30449. [
  30450. 2,
  30451. 2
  30452. ],
  30453. [
  30454. 2,
  30455. 2
  30456. ],
  30457. [
  30458. 2,
  30459. 2
  30460. ],
  30461. [
  30462. 2,
  30463. 2
  30464. ],
  30465. [
  30466. 2,
  30467. 2
  30468. ],
  30469. [
  30470. 2,
  30471. 2
  30472. ],
  30473. [
  30474. 2,
  30475. 2
  30476. ],
  30477. [
  30478. 2,
  30479. 2
  30480. ],
  30481. [
  30482. 2,
  30483. 2
  30484. ]
  30485. ];
  30486. function CCITTFaxStream(str, maybeLength, params) {
  30487. this.str = str;
  30488. this.dict = str.dict;
  30489. params = params || Dict.empty;
  30490. this.encoding = params.get('K') || 0;
  30491. this.eoline = params.get('EndOfLine') || false;
  30492. this.byteAlign = params.get('EncodedByteAlign') || false;
  30493. this.columns = params.get('Columns') || 1728;
  30494. this.rows = params.get('Rows') || 0;
  30495. var eoblock = params.get('EndOfBlock');
  30496. if (eoblock === null || eoblock === undefined) {
  30497. eoblock = true;
  30498. }
  30499. this.eoblock = eoblock;
  30500. this.black = params.get('BlackIs1') || false;
  30501. this.codingLine = new Uint32Array(this.columns + 1);
  30502. this.refLine = new Uint32Array(this.columns + 2);
  30503. this.codingLine[0] = this.columns;
  30504. this.codingPos = 0;
  30505. this.row = 0;
  30506. this.nextLine2D = this.encoding < 0;
  30507. this.inputBits = 0;
  30508. this.inputBuf = 0;
  30509. this.outputBits = 0;
  30510. var code1;
  30511. while ((code1 = this.lookBits(12)) === 0) {
  30512. this.eatBits(1);
  30513. }
  30514. if (code1 === 1) {
  30515. this.eatBits(12);
  30516. }
  30517. if (this.encoding > 0) {
  30518. this.nextLine2D = !this.lookBits(1);
  30519. this.eatBits(1);
  30520. }
  30521. DecodeStream.call(this, maybeLength);
  30522. }
  30523. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30524. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30525. while (!this.eof) {
  30526. var c = this.lookChar();
  30527. this.ensureBuffer(this.bufferLength + 1);
  30528. this.buffer[this.bufferLength++] = c;
  30529. }
  30530. };
  30531. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30532. var codingLine = this.codingLine;
  30533. var codingPos = this.codingPos;
  30534. if (a1 > codingLine[codingPos]) {
  30535. if (a1 > this.columns) {
  30536. info('row is wrong length');
  30537. this.err = true;
  30538. a1 = this.columns;
  30539. }
  30540. if (codingPos & 1 ^ blackPixels) {
  30541. ++codingPos;
  30542. }
  30543. codingLine[codingPos] = a1;
  30544. }
  30545. this.codingPos = codingPos;
  30546. };
  30547. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30548. var codingLine = this.codingLine;
  30549. var codingPos = this.codingPos;
  30550. if (a1 > codingLine[codingPos]) {
  30551. if (a1 > this.columns) {
  30552. info('row is wrong length');
  30553. this.err = true;
  30554. a1 = this.columns;
  30555. }
  30556. if (codingPos & 1 ^ blackPixels) {
  30557. ++codingPos;
  30558. }
  30559. codingLine[codingPos] = a1;
  30560. } else if (a1 < codingLine[codingPos]) {
  30561. if (a1 < 0) {
  30562. info('invalid code');
  30563. this.err = true;
  30564. a1 = 0;
  30565. }
  30566. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30567. --codingPos;
  30568. }
  30569. codingLine[codingPos] = a1;
  30570. }
  30571. this.codingPos = codingPos;
  30572. };
  30573. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30574. var refLine = this.refLine;
  30575. var codingLine = this.codingLine;
  30576. var columns = this.columns;
  30577. var refPos, blackPixels, bits, i;
  30578. if (this.outputBits === 0) {
  30579. if (this.eof) {
  30580. return null;
  30581. }
  30582. this.err = false;
  30583. var code1, code2, code3;
  30584. if (this.nextLine2D) {
  30585. for (i = 0; codingLine[i] < columns; ++i) {
  30586. refLine[i] = codingLine[i];
  30587. }
  30588. refLine[i++] = columns;
  30589. refLine[i] = columns;
  30590. codingLine[0] = 0;
  30591. this.codingPos = 0;
  30592. refPos = 0;
  30593. blackPixels = 0;
  30594. while (codingLine[this.codingPos] < columns) {
  30595. code1 = this.getTwoDimCode();
  30596. switch (code1) {
  30597. case twoDimPass:
  30598. this.addPixels(refLine[refPos + 1], blackPixels);
  30599. if (refLine[refPos + 1] < columns) {
  30600. refPos += 2;
  30601. }
  30602. break;
  30603. case twoDimHoriz:
  30604. code1 = code2 = 0;
  30605. if (blackPixels) {
  30606. do {
  30607. code1 += code3 = this.getBlackCode();
  30608. } while (code3 >= 64);
  30609. do {
  30610. code2 += code3 = this.getWhiteCode();
  30611. } while (code3 >= 64);
  30612. } else {
  30613. do {
  30614. code1 += code3 = this.getWhiteCode();
  30615. } while (code3 >= 64);
  30616. do {
  30617. code2 += code3 = this.getBlackCode();
  30618. } while (code3 >= 64);
  30619. }
  30620. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30621. if (codingLine[this.codingPos] < columns) {
  30622. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30623. }
  30624. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30625. refPos += 2;
  30626. }
  30627. break;
  30628. case twoDimVertR3:
  30629. this.addPixels(refLine[refPos] + 3, blackPixels);
  30630. blackPixels ^= 1;
  30631. if (codingLine[this.codingPos] < columns) {
  30632. ++refPos;
  30633. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30634. refPos += 2;
  30635. }
  30636. }
  30637. break;
  30638. case twoDimVertR2:
  30639. this.addPixels(refLine[refPos] + 2, blackPixels);
  30640. blackPixels ^= 1;
  30641. if (codingLine[this.codingPos] < columns) {
  30642. ++refPos;
  30643. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30644. refPos += 2;
  30645. }
  30646. }
  30647. break;
  30648. case twoDimVertR1:
  30649. this.addPixels(refLine[refPos] + 1, blackPixels);
  30650. blackPixels ^= 1;
  30651. if (codingLine[this.codingPos] < columns) {
  30652. ++refPos;
  30653. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30654. refPos += 2;
  30655. }
  30656. }
  30657. break;
  30658. case twoDimVert0:
  30659. this.addPixels(refLine[refPos], blackPixels);
  30660. blackPixels ^= 1;
  30661. if (codingLine[this.codingPos] < columns) {
  30662. ++refPos;
  30663. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30664. refPos += 2;
  30665. }
  30666. }
  30667. break;
  30668. case twoDimVertL3:
  30669. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  30670. blackPixels ^= 1;
  30671. if (codingLine[this.codingPos] < columns) {
  30672. if (refPos > 0) {
  30673. --refPos;
  30674. } else {
  30675. ++refPos;
  30676. }
  30677. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30678. refPos += 2;
  30679. }
  30680. }
  30681. break;
  30682. case twoDimVertL2:
  30683. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  30684. blackPixels ^= 1;
  30685. if (codingLine[this.codingPos] < columns) {
  30686. if (refPos > 0) {
  30687. --refPos;
  30688. } else {
  30689. ++refPos;
  30690. }
  30691. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30692. refPos += 2;
  30693. }
  30694. }
  30695. break;
  30696. case twoDimVertL1:
  30697. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  30698. blackPixels ^= 1;
  30699. if (codingLine[this.codingPos] < columns) {
  30700. if (refPos > 0) {
  30701. --refPos;
  30702. } else {
  30703. ++refPos;
  30704. }
  30705. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30706. refPos += 2;
  30707. }
  30708. }
  30709. break;
  30710. case ccittEOF:
  30711. this.addPixels(columns, 0);
  30712. this.eof = true;
  30713. break;
  30714. default:
  30715. info('bad 2d code');
  30716. this.addPixels(columns, 0);
  30717. this.err = true;
  30718. }
  30719. }
  30720. } else {
  30721. codingLine[0] = 0;
  30722. this.codingPos = 0;
  30723. blackPixels = 0;
  30724. while (codingLine[this.codingPos] < columns) {
  30725. code1 = 0;
  30726. if (blackPixels) {
  30727. do {
  30728. code1 += code3 = this.getBlackCode();
  30729. } while (code3 >= 64);
  30730. } else {
  30731. do {
  30732. code1 += code3 = this.getWhiteCode();
  30733. } while (code3 >= 64);
  30734. }
  30735. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30736. blackPixels ^= 1;
  30737. }
  30738. }
  30739. var gotEOL = false;
  30740. if (this.byteAlign) {
  30741. this.inputBits &= ~7;
  30742. }
  30743. if (!this.eoblock && this.row === this.rows - 1) {
  30744. this.eof = true;
  30745. } else {
  30746. code1 = this.lookBits(12);
  30747. if (this.eoline) {
  30748. while (code1 !== ccittEOF && code1 !== 1) {
  30749. this.eatBits(1);
  30750. code1 = this.lookBits(12);
  30751. }
  30752. } else {
  30753. while (code1 === 0) {
  30754. this.eatBits(1);
  30755. code1 = this.lookBits(12);
  30756. }
  30757. }
  30758. if (code1 === 1) {
  30759. this.eatBits(12);
  30760. gotEOL = true;
  30761. } else if (code1 === ccittEOF) {
  30762. this.eof = true;
  30763. }
  30764. }
  30765. if (!this.eof && this.encoding > 0) {
  30766. this.nextLine2D = !this.lookBits(1);
  30767. this.eatBits(1);
  30768. }
  30769. if (this.eoblock && gotEOL && this.byteAlign) {
  30770. code1 = this.lookBits(12);
  30771. if (code1 === 1) {
  30772. this.eatBits(12);
  30773. if (this.encoding > 0) {
  30774. this.lookBits(1);
  30775. this.eatBits(1);
  30776. }
  30777. if (this.encoding >= 0) {
  30778. for (i = 0; i < 4; ++i) {
  30779. code1 = this.lookBits(12);
  30780. if (code1 !== 1) {
  30781. info('bad rtc code: ' + code1);
  30782. }
  30783. this.eatBits(12);
  30784. if (this.encoding > 0) {
  30785. this.lookBits(1);
  30786. this.eatBits(1);
  30787. }
  30788. }
  30789. }
  30790. this.eof = true;
  30791. }
  30792. } else if (this.err && this.eoline) {
  30793. while (true) {
  30794. code1 = this.lookBits(13);
  30795. if (code1 === ccittEOF) {
  30796. this.eof = true;
  30797. return null;
  30798. }
  30799. if (code1 >> 1 === 1) {
  30800. break;
  30801. }
  30802. this.eatBits(1);
  30803. }
  30804. this.eatBits(12);
  30805. if (this.encoding > 0) {
  30806. this.eatBits(1);
  30807. this.nextLine2D = !(code1 & 1);
  30808. }
  30809. }
  30810. if (codingLine[0] > 0) {
  30811. this.outputBits = codingLine[this.codingPos = 0];
  30812. } else {
  30813. this.outputBits = codingLine[this.codingPos = 1];
  30814. }
  30815. this.row++;
  30816. }
  30817. var c;
  30818. if (this.outputBits >= 8) {
  30819. c = this.codingPos & 1 ? 0 : 0xFF;
  30820. this.outputBits -= 8;
  30821. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  30822. this.codingPos++;
  30823. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30824. }
  30825. } else {
  30826. bits = 8;
  30827. c = 0;
  30828. do {
  30829. if (this.outputBits > bits) {
  30830. c <<= bits;
  30831. if (!(this.codingPos & 1)) {
  30832. c |= 0xFF >> 8 - bits;
  30833. }
  30834. this.outputBits -= bits;
  30835. bits = 0;
  30836. } else {
  30837. c <<= this.outputBits;
  30838. if (!(this.codingPos & 1)) {
  30839. c |= 0xFF >> 8 - this.outputBits;
  30840. }
  30841. bits -= this.outputBits;
  30842. this.outputBits = 0;
  30843. if (codingLine[this.codingPos] < columns) {
  30844. this.codingPos++;
  30845. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30846. } else if (bits > 0) {
  30847. c <<= bits;
  30848. bits = 0;
  30849. }
  30850. }
  30851. } while (bits);
  30852. }
  30853. if (this.black) {
  30854. c ^= 0xFF;
  30855. }
  30856. return c;
  30857. };
  30858. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  30859. var limitValue = limit || 0;
  30860. for (var i = start; i <= end; ++i) {
  30861. var code = this.lookBits(i);
  30862. if (code === ccittEOF) {
  30863. return [
  30864. true,
  30865. 1,
  30866. false
  30867. ];
  30868. }
  30869. if (i < end) {
  30870. code <<= end - i;
  30871. }
  30872. if (!limitValue || code >= limitValue) {
  30873. var p = table[code - limitValue];
  30874. if (p[0] === i) {
  30875. this.eatBits(i);
  30876. return [
  30877. true,
  30878. p[1],
  30879. true
  30880. ];
  30881. }
  30882. }
  30883. }
  30884. return [
  30885. false,
  30886. 0,
  30887. false
  30888. ];
  30889. };
  30890. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  30891. var code = 0;
  30892. var p;
  30893. if (this.eoblock) {
  30894. code = this.lookBits(7);
  30895. p = twoDimTable[code];
  30896. if (p && p[0] > 0) {
  30897. this.eatBits(p[0]);
  30898. return p[1];
  30899. }
  30900. } else {
  30901. var result = this.findTableCode(1, 7, twoDimTable);
  30902. if (result[0] && result[2]) {
  30903. return result[1];
  30904. }
  30905. }
  30906. info('Bad two dim code');
  30907. return ccittEOF;
  30908. };
  30909. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  30910. var code = 0;
  30911. var p;
  30912. if (this.eoblock) {
  30913. code = this.lookBits(12);
  30914. if (code === ccittEOF) {
  30915. return 1;
  30916. }
  30917. if (code >> 5 === 0) {
  30918. p = whiteTable1[code];
  30919. } else {
  30920. p = whiteTable2[code >> 3];
  30921. }
  30922. if (p[0] > 0) {
  30923. this.eatBits(p[0]);
  30924. return p[1];
  30925. }
  30926. } else {
  30927. var result = this.findTableCode(1, 9, whiteTable2);
  30928. if (result[0]) {
  30929. return result[1];
  30930. }
  30931. result = this.findTableCode(11, 12, whiteTable1);
  30932. if (result[0]) {
  30933. return result[1];
  30934. }
  30935. }
  30936. info('bad white code');
  30937. this.eatBits(1);
  30938. return 1;
  30939. };
  30940. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  30941. var code, p;
  30942. if (this.eoblock) {
  30943. code = this.lookBits(13);
  30944. if (code === ccittEOF) {
  30945. return 1;
  30946. }
  30947. if (code >> 7 === 0) {
  30948. p = blackTable1[code];
  30949. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  30950. p = blackTable2[(code >> 1) - 64];
  30951. } else {
  30952. p = blackTable3[code >> 7];
  30953. }
  30954. if (p[0] > 0) {
  30955. this.eatBits(p[0]);
  30956. return p[1];
  30957. }
  30958. } else {
  30959. var result = this.findTableCode(2, 6, blackTable3);
  30960. if (result[0]) {
  30961. return result[1];
  30962. }
  30963. result = this.findTableCode(7, 12, blackTable2, 64);
  30964. if (result[0]) {
  30965. return result[1];
  30966. }
  30967. result = this.findTableCode(10, 13, blackTable1);
  30968. if (result[0]) {
  30969. return result[1];
  30970. }
  30971. }
  30972. info('bad black code');
  30973. this.eatBits(1);
  30974. return 1;
  30975. };
  30976. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  30977. var c;
  30978. while (this.inputBits < n) {
  30979. if ((c = this.str.getByte()) === -1) {
  30980. if (this.inputBits === 0) {
  30981. return ccittEOF;
  30982. }
  30983. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  30984. }
  30985. this.inputBuf = this.inputBuf << 8 | c;
  30986. this.inputBits += 8;
  30987. }
  30988. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  30989. };
  30990. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  30991. if ((this.inputBits -= n) < 0) {
  30992. this.inputBits = 0;
  30993. }
  30994. };
  30995. return CCITTFaxStream;
  30996. }();
  30997. var LZWStream = function LZWStreamClosure() {
  30998. function LZWStream(str, maybeLength, earlyChange) {
  30999. this.str = str;
  31000. this.dict = str.dict;
  31001. this.cachedData = 0;
  31002. this.bitsCached = 0;
  31003. var maxLzwDictionarySize = 4096;
  31004. var lzwState = {
  31005. earlyChange: earlyChange,
  31006. codeLength: 9,
  31007. nextCode: 258,
  31008. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31009. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31010. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31011. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31012. currentSequenceLength: 0
  31013. };
  31014. for (var i = 0; i < 256; ++i) {
  31015. lzwState.dictionaryValues[i] = i;
  31016. lzwState.dictionaryLengths[i] = 1;
  31017. }
  31018. this.lzwState = lzwState;
  31019. DecodeStream.call(this, maybeLength);
  31020. }
  31021. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31022. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31023. var bitsCached = this.bitsCached;
  31024. var cachedData = this.cachedData;
  31025. while (bitsCached < n) {
  31026. var c = this.str.getByte();
  31027. if (c === -1) {
  31028. this.eof = true;
  31029. return null;
  31030. }
  31031. cachedData = cachedData << 8 | c;
  31032. bitsCached += 8;
  31033. }
  31034. this.bitsCached = bitsCached -= n;
  31035. this.cachedData = cachedData;
  31036. this.lastCode = null;
  31037. return cachedData >>> bitsCached & (1 << n) - 1;
  31038. };
  31039. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31040. var blockSize = 512;
  31041. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31042. var i, j, q;
  31043. var lzwState = this.lzwState;
  31044. if (!lzwState) {
  31045. return;
  31046. }
  31047. var earlyChange = lzwState.earlyChange;
  31048. var nextCode = lzwState.nextCode;
  31049. var dictionaryValues = lzwState.dictionaryValues;
  31050. var dictionaryLengths = lzwState.dictionaryLengths;
  31051. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31052. var codeLength = lzwState.codeLength;
  31053. var prevCode = lzwState.prevCode;
  31054. var currentSequence = lzwState.currentSequence;
  31055. var currentSequenceLength = lzwState.currentSequenceLength;
  31056. var decodedLength = 0;
  31057. var currentBufferLength = this.bufferLength;
  31058. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31059. for (i = 0; i < blockSize; i++) {
  31060. var code = this.readBits(codeLength);
  31061. var hasPrev = currentSequenceLength > 0;
  31062. if (code < 256) {
  31063. currentSequence[0] = code;
  31064. currentSequenceLength = 1;
  31065. } else if (code >= 258) {
  31066. if (code < nextCode) {
  31067. currentSequenceLength = dictionaryLengths[code];
  31068. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31069. currentSequence[j] = dictionaryValues[q];
  31070. q = dictionaryPrevCodes[q];
  31071. }
  31072. } else {
  31073. currentSequence[currentSequenceLength++] = currentSequence[0];
  31074. }
  31075. } else if (code === 256) {
  31076. codeLength = 9;
  31077. nextCode = 258;
  31078. currentSequenceLength = 0;
  31079. continue;
  31080. } else {
  31081. this.eof = true;
  31082. delete this.lzwState;
  31083. break;
  31084. }
  31085. if (hasPrev) {
  31086. dictionaryPrevCodes[nextCode] = prevCode;
  31087. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31088. dictionaryValues[nextCode] = currentSequence[0];
  31089. nextCode++;
  31090. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31091. }
  31092. prevCode = code;
  31093. decodedLength += currentSequenceLength;
  31094. if (estimatedDecodedSize < decodedLength) {
  31095. do {
  31096. estimatedDecodedSize += decodedSizeDelta;
  31097. } while (estimatedDecodedSize < decodedLength);
  31098. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31099. }
  31100. for (j = 0; j < currentSequenceLength; j++) {
  31101. buffer[currentBufferLength++] = currentSequence[j];
  31102. }
  31103. }
  31104. lzwState.nextCode = nextCode;
  31105. lzwState.codeLength = codeLength;
  31106. lzwState.prevCode = prevCode;
  31107. lzwState.currentSequenceLength = currentSequenceLength;
  31108. this.bufferLength = currentBufferLength;
  31109. };
  31110. return LZWStream;
  31111. }();
  31112. var NullStream = function NullStreamClosure() {
  31113. function NullStream() {
  31114. Stream.call(this, new Uint8Array(0));
  31115. }
  31116. NullStream.prototype = Stream.prototype;
  31117. return NullStream;
  31118. }();
  31119. exports.Ascii85Stream = Ascii85Stream;
  31120. exports.AsciiHexStream = AsciiHexStream;
  31121. exports.CCITTFaxStream = CCITTFaxStream;
  31122. exports.DecryptStream = DecryptStream;
  31123. exports.DecodeStream = DecodeStream;
  31124. exports.FlateStream = FlateStream;
  31125. exports.Jbig2Stream = Jbig2Stream;
  31126. exports.JpegStream = JpegStream;
  31127. exports.JpxStream = JpxStream;
  31128. exports.NullStream = NullStream;
  31129. exports.PredictorStream = PredictorStream;
  31130. exports.RunLengthStream = RunLengthStream;
  31131. exports.Stream = Stream;
  31132. exports.StreamsSequenceStream = StreamsSequenceStream;
  31133. exports.StringStream = StringStream;
  31134. exports.LZWStream = LZWStream;
  31135. }));
  31136. (function (root, factory) {
  31137. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31138. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31139. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31140. var AnnotationType = sharedUtil.AnnotationType;
  31141. var Util = sharedUtil.Util;
  31142. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31143. var LinkTarget = displayDOMUtils.LinkTarget;
  31144. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31145. var warn = sharedUtil.warn;
  31146. var CustomStyle = displayDOMUtils.CustomStyle;
  31147. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31148. function AnnotationElementFactory() {
  31149. }
  31150. AnnotationElementFactory.prototype = {
  31151. create: function AnnotationElementFactory_create(parameters) {
  31152. var subtype = parameters.data.annotationType;
  31153. switch (subtype) {
  31154. case AnnotationType.LINK:
  31155. return new LinkAnnotationElement(parameters);
  31156. case AnnotationType.TEXT:
  31157. return new TextAnnotationElement(parameters);
  31158. case AnnotationType.WIDGET:
  31159. var fieldType = parameters.data.fieldType;
  31160. switch (fieldType) {
  31161. case 'Tx':
  31162. return new TextWidgetAnnotationElement(parameters);
  31163. case 'Ch':
  31164. return new ChoiceWidgetAnnotationElement(parameters);
  31165. }
  31166. return new WidgetAnnotationElement(parameters);
  31167. case AnnotationType.POPUP:
  31168. return new PopupAnnotationElement(parameters);
  31169. case AnnotationType.HIGHLIGHT:
  31170. return new HighlightAnnotationElement(parameters);
  31171. case AnnotationType.UNDERLINE:
  31172. return new UnderlineAnnotationElement(parameters);
  31173. case AnnotationType.SQUIGGLY:
  31174. return new SquigglyAnnotationElement(parameters);
  31175. case AnnotationType.STRIKEOUT:
  31176. return new StrikeOutAnnotationElement(parameters);
  31177. case AnnotationType.FILEATTACHMENT:
  31178. return new FileAttachmentAnnotationElement(parameters);
  31179. default:
  31180. return new AnnotationElement(parameters);
  31181. }
  31182. }
  31183. };
  31184. var AnnotationElement = function AnnotationElementClosure() {
  31185. function AnnotationElement(parameters, isRenderable) {
  31186. this.isRenderable = isRenderable || false;
  31187. this.data = parameters.data;
  31188. this.layer = parameters.layer;
  31189. this.page = parameters.page;
  31190. this.viewport = parameters.viewport;
  31191. this.linkService = parameters.linkService;
  31192. this.downloadManager = parameters.downloadManager;
  31193. this.imageResourcesPath = parameters.imageResourcesPath;
  31194. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31195. if (isRenderable) {
  31196. this.container = this._createContainer();
  31197. }
  31198. }
  31199. AnnotationElement.prototype = {
  31200. _createContainer: function AnnotationElement_createContainer() {
  31201. var data = this.data, page = this.page, viewport = this.viewport;
  31202. var container = document.createElement('section');
  31203. var width = data.rect[2] - data.rect[0];
  31204. var height = data.rect[3] - data.rect[1];
  31205. container.setAttribute('data-annotation-id', data.id);
  31206. var rect = Util.normalizeRect([
  31207. data.rect[0],
  31208. page.view[3] - data.rect[1] + page.view[1],
  31209. data.rect[2],
  31210. page.view[3] - data.rect[3] + page.view[1]
  31211. ]);
  31212. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31213. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31214. if (data.borderStyle.width > 0) {
  31215. container.style.borderWidth = data.borderStyle.width + 'px';
  31216. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31217. width = width - 2 * data.borderStyle.width;
  31218. height = height - 2 * data.borderStyle.width;
  31219. }
  31220. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31221. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31222. if (horizontalRadius > 0 || verticalRadius > 0) {
  31223. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31224. CustomStyle.setProp('borderRadius', container, radius);
  31225. }
  31226. switch (data.borderStyle.style) {
  31227. case AnnotationBorderStyleType.SOLID:
  31228. container.style.borderStyle = 'solid';
  31229. break;
  31230. case AnnotationBorderStyleType.DASHED:
  31231. container.style.borderStyle = 'dashed';
  31232. break;
  31233. case AnnotationBorderStyleType.BEVELED:
  31234. warn('Unimplemented border style: beveled');
  31235. break;
  31236. case AnnotationBorderStyleType.INSET:
  31237. warn('Unimplemented border style: inset');
  31238. break;
  31239. case AnnotationBorderStyleType.UNDERLINE:
  31240. container.style.borderBottomStyle = 'solid';
  31241. break;
  31242. default:
  31243. break;
  31244. }
  31245. if (data.color) {
  31246. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31247. } else {
  31248. container.style.borderWidth = 0;
  31249. }
  31250. }
  31251. container.style.left = rect[0] + 'px';
  31252. container.style.top = rect[1] + 'px';
  31253. container.style.width = width + 'px';
  31254. container.style.height = height + 'px';
  31255. return container;
  31256. },
  31257. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31258. if (!trigger) {
  31259. trigger = document.createElement('div');
  31260. trigger.style.height = container.style.height;
  31261. trigger.style.width = container.style.width;
  31262. container.appendChild(trigger);
  31263. }
  31264. var popupElement = new PopupElement({
  31265. container: container,
  31266. trigger: trigger,
  31267. color: data.color,
  31268. title: data.title,
  31269. contents: data.contents,
  31270. hideWrapper: true
  31271. });
  31272. var popup = popupElement.render();
  31273. popup.style.left = container.style.width;
  31274. container.appendChild(popup);
  31275. },
  31276. render: function AnnotationElement_render() {
  31277. throw new Error('Abstract method AnnotationElement.render called');
  31278. }
  31279. };
  31280. return AnnotationElement;
  31281. }();
  31282. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31283. function LinkAnnotationElement(parameters) {
  31284. AnnotationElement.call(this, parameters, true);
  31285. }
  31286. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31287. render: function LinkAnnotationElement_render() {
  31288. this.container.className = 'linkAnnotation';
  31289. var link = document.createElement('a');
  31290. addLinkAttributes(link, {
  31291. url: this.data.url,
  31292. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31293. });
  31294. if (!this.data.url) {
  31295. if (this.data.action) {
  31296. this._bindNamedAction(link, this.data.action);
  31297. } else {
  31298. this._bindLink(link, this.data.dest);
  31299. }
  31300. }
  31301. this.container.appendChild(link);
  31302. return this.container;
  31303. },
  31304. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31305. var self = this;
  31306. link.href = this.linkService.getDestinationHash(destination);
  31307. link.onclick = function () {
  31308. if (destination) {
  31309. self.linkService.navigateTo(destination);
  31310. }
  31311. return false;
  31312. };
  31313. if (destination) {
  31314. link.className = 'internalLink';
  31315. }
  31316. },
  31317. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31318. var self = this;
  31319. link.href = this.linkService.getAnchorUrl('');
  31320. link.onclick = function () {
  31321. self.linkService.executeNamedAction(action);
  31322. return false;
  31323. };
  31324. link.className = 'internalLink';
  31325. }
  31326. });
  31327. return LinkAnnotationElement;
  31328. }();
  31329. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31330. function TextAnnotationElement(parameters) {
  31331. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31332. AnnotationElement.call(this, parameters, isRenderable);
  31333. }
  31334. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31335. render: function TextAnnotationElement_render() {
  31336. this.container.className = 'textAnnotation';
  31337. var image = document.createElement('img');
  31338. image.style.height = this.container.style.height;
  31339. image.style.width = this.container.style.width;
  31340. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31341. image.alt = '[{{type}} Annotation]';
  31342. image.dataset.l10nId = 'text_annotation_type';
  31343. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31344. if (!this.data.hasPopup) {
  31345. this._createPopup(this.container, image, this.data);
  31346. }
  31347. this.container.appendChild(image);
  31348. return this.container;
  31349. }
  31350. });
  31351. return TextAnnotationElement;
  31352. }();
  31353. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31354. function WidgetAnnotationElement(parameters, isRenderable) {
  31355. AnnotationElement.call(this, parameters, isRenderable);
  31356. }
  31357. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31358. render: function WidgetAnnotationElement_render() {
  31359. return this.container;
  31360. }
  31361. });
  31362. return WidgetAnnotationElement;
  31363. }();
  31364. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31365. var TEXT_ALIGNMENT = [
  31366. 'left',
  31367. 'center',
  31368. 'right'
  31369. ];
  31370. function TextWidgetAnnotationElement(parameters) {
  31371. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31372. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31373. }
  31374. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31375. render: function TextWidgetAnnotationElement_render() {
  31376. this.container.className = 'textWidgetAnnotation';
  31377. var element = null;
  31378. if (this.renderInteractiveForms) {
  31379. if (this.data.multiLine) {
  31380. element = document.createElement('textarea');
  31381. element.textContent = this.data.fieldValue;
  31382. } else {
  31383. element = document.createElement('input');
  31384. element.type = 'text';
  31385. element.setAttribute('value', this.data.fieldValue);
  31386. }
  31387. element.disabled = this.data.readOnly;
  31388. if (this.data.maxLen !== null) {
  31389. element.maxLength = this.data.maxLen;
  31390. }
  31391. if (this.data.comb) {
  31392. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31393. var combWidth = fieldWidth / this.data.maxLen;
  31394. element.classList.add('comb');
  31395. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31396. }
  31397. } else {
  31398. element = document.createElement('div');
  31399. element.textContent = this.data.fieldValue;
  31400. element.style.verticalAlign = 'middle';
  31401. element.style.display = 'table-cell';
  31402. var font = null;
  31403. if (this.data.fontRefName) {
  31404. font = this.page.commonObjs.getData(this.data.fontRefName);
  31405. }
  31406. this._setTextStyle(element, font);
  31407. }
  31408. if (this.data.textAlignment !== null) {
  31409. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31410. }
  31411. this.container.appendChild(element);
  31412. return this.container;
  31413. },
  31414. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31415. var style = element.style;
  31416. style.fontSize = this.data.fontSize + 'px';
  31417. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31418. if (!font) {
  31419. return;
  31420. }
  31421. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31422. style.fontStyle = font.italic ? 'italic' : 'normal';
  31423. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31424. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31425. style.fontFamily = fontFamily + fallbackName;
  31426. }
  31427. });
  31428. return TextWidgetAnnotationElement;
  31429. }();
  31430. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31431. function ChoiceWidgetAnnotationElement(parameters) {
  31432. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31433. }
  31434. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31435. render: function ChoiceWidgetAnnotationElement_render() {
  31436. this.container.className = 'choiceWidgetAnnotation';
  31437. var selectElement = document.createElement('select');
  31438. selectElement.disabled = this.data.readOnly;
  31439. if (!this.data.combo) {
  31440. selectElement.size = this.data.options.length;
  31441. if (this.data.multiSelect) {
  31442. selectElement.multiple = true;
  31443. }
  31444. }
  31445. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31446. var option = this.data.options[i];
  31447. var optionElement = document.createElement('option');
  31448. optionElement.textContent = option.displayValue;
  31449. optionElement.value = option.exportValue;
  31450. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31451. optionElement.setAttribute('selected', true);
  31452. }
  31453. selectElement.appendChild(optionElement);
  31454. }
  31455. this.container.appendChild(selectElement);
  31456. return this.container;
  31457. }
  31458. });
  31459. return ChoiceWidgetAnnotationElement;
  31460. }();
  31461. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31462. function PopupAnnotationElement(parameters) {
  31463. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31464. AnnotationElement.call(this, parameters, isRenderable);
  31465. }
  31466. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31467. render: function PopupAnnotationElement_render() {
  31468. this.container.className = 'popupAnnotation';
  31469. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31470. var parentElement = this.layer.querySelector(selector);
  31471. if (!parentElement) {
  31472. return this.container;
  31473. }
  31474. var popup = new PopupElement({
  31475. container: this.container,
  31476. trigger: parentElement,
  31477. color: this.data.color,
  31478. title: this.data.title,
  31479. contents: this.data.contents
  31480. });
  31481. var parentLeft = parseFloat(parentElement.style.left);
  31482. var parentWidth = parseFloat(parentElement.style.width);
  31483. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31484. this.container.style.left = parentLeft + parentWidth + 'px';
  31485. this.container.appendChild(popup.render());
  31486. return this.container;
  31487. }
  31488. });
  31489. return PopupAnnotationElement;
  31490. }();
  31491. var PopupElement = function PopupElementClosure() {
  31492. var BACKGROUND_ENLIGHT = 0.7;
  31493. function PopupElement(parameters) {
  31494. this.container = parameters.container;
  31495. this.trigger = parameters.trigger;
  31496. this.color = parameters.color;
  31497. this.title = parameters.title;
  31498. this.contents = parameters.contents;
  31499. this.hideWrapper = parameters.hideWrapper || false;
  31500. this.pinned = false;
  31501. }
  31502. PopupElement.prototype = {
  31503. render: function PopupElement_render() {
  31504. var wrapper = document.createElement('div');
  31505. wrapper.className = 'popupWrapper';
  31506. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31507. this.hideElement.setAttribute('hidden', true);
  31508. var popup = document.createElement('div');
  31509. popup.className = 'popup';
  31510. var color = this.color;
  31511. if (color) {
  31512. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31513. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31514. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31515. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31516. }
  31517. var contents = this._formatContents(this.contents);
  31518. var title = document.createElement('h1');
  31519. title.textContent = this.title;
  31520. this.trigger.addEventListener('click', this._toggle.bind(this));
  31521. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31522. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31523. popup.addEventListener('click', this._hide.bind(this, true));
  31524. popup.appendChild(title);
  31525. popup.appendChild(contents);
  31526. wrapper.appendChild(popup);
  31527. return wrapper;
  31528. },
  31529. _formatContents: function PopupElement_formatContents(contents) {
  31530. var p = document.createElement('p');
  31531. var lines = contents.split(/(?:\r\n?|\n)/);
  31532. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31533. var line = lines[i];
  31534. p.appendChild(document.createTextNode(line));
  31535. if (i < ii - 1) {
  31536. p.appendChild(document.createElement('br'));
  31537. }
  31538. }
  31539. return p;
  31540. },
  31541. _toggle: function PopupElement_toggle() {
  31542. if (this.pinned) {
  31543. this._hide(true);
  31544. } else {
  31545. this._show(true);
  31546. }
  31547. },
  31548. _show: function PopupElement_show(pin) {
  31549. if (pin) {
  31550. this.pinned = true;
  31551. }
  31552. if (this.hideElement.hasAttribute('hidden')) {
  31553. this.hideElement.removeAttribute('hidden');
  31554. this.container.style.zIndex += 1;
  31555. }
  31556. },
  31557. _hide: function PopupElement_hide(unpin) {
  31558. if (unpin) {
  31559. this.pinned = false;
  31560. }
  31561. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31562. this.hideElement.setAttribute('hidden', true);
  31563. this.container.style.zIndex -= 1;
  31564. }
  31565. }
  31566. };
  31567. return PopupElement;
  31568. }();
  31569. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31570. function HighlightAnnotationElement(parameters) {
  31571. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31572. AnnotationElement.call(this, parameters, isRenderable);
  31573. }
  31574. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31575. render: function HighlightAnnotationElement_render() {
  31576. this.container.className = 'highlightAnnotation';
  31577. if (!this.data.hasPopup) {
  31578. this._createPopup(this.container, null, this.data);
  31579. }
  31580. return this.container;
  31581. }
  31582. });
  31583. return HighlightAnnotationElement;
  31584. }();
  31585. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31586. function UnderlineAnnotationElement(parameters) {
  31587. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31588. AnnotationElement.call(this, parameters, isRenderable);
  31589. }
  31590. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31591. render: function UnderlineAnnotationElement_render() {
  31592. this.container.className = 'underlineAnnotation';
  31593. if (!this.data.hasPopup) {
  31594. this._createPopup(this.container, null, this.data);
  31595. }
  31596. return this.container;
  31597. }
  31598. });
  31599. return UnderlineAnnotationElement;
  31600. }();
  31601. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31602. function SquigglyAnnotationElement(parameters) {
  31603. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31604. AnnotationElement.call(this, parameters, isRenderable);
  31605. }
  31606. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31607. render: function SquigglyAnnotationElement_render() {
  31608. this.container.className = 'squigglyAnnotation';
  31609. if (!this.data.hasPopup) {
  31610. this._createPopup(this.container, null, this.data);
  31611. }
  31612. return this.container;
  31613. }
  31614. });
  31615. return SquigglyAnnotationElement;
  31616. }();
  31617. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31618. function StrikeOutAnnotationElement(parameters) {
  31619. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31620. AnnotationElement.call(this, parameters, isRenderable);
  31621. }
  31622. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31623. render: function StrikeOutAnnotationElement_render() {
  31624. this.container.className = 'strikeoutAnnotation';
  31625. if (!this.data.hasPopup) {
  31626. this._createPopup(this.container, null, this.data);
  31627. }
  31628. return this.container;
  31629. }
  31630. });
  31631. return StrikeOutAnnotationElement;
  31632. }();
  31633. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31634. function FileAttachmentAnnotationElement(parameters) {
  31635. AnnotationElement.call(this, parameters, true);
  31636. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31637. this.content = parameters.data.file.content;
  31638. }
  31639. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31640. render: function FileAttachmentAnnotationElement_render() {
  31641. this.container.className = 'fileAttachmentAnnotation';
  31642. var trigger = document.createElement('div');
  31643. trigger.style.height = this.container.style.height;
  31644. trigger.style.width = this.container.style.width;
  31645. trigger.addEventListener('dblclick', this._download.bind(this));
  31646. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31647. this._createPopup(this.container, trigger, this.data);
  31648. }
  31649. this.container.appendChild(trigger);
  31650. return this.container;
  31651. },
  31652. _download: function FileAttachmentAnnotationElement_download() {
  31653. if (!this.downloadManager) {
  31654. warn('Download cannot be started due to unavailable download manager');
  31655. return;
  31656. }
  31657. this.downloadManager.downloadData(this.content, this.filename, '');
  31658. }
  31659. });
  31660. return FileAttachmentAnnotationElement;
  31661. }();
  31662. var AnnotationLayer = function AnnotationLayerClosure() {
  31663. return {
  31664. render: function AnnotationLayer_render(parameters) {
  31665. var annotationElementFactory = new AnnotationElementFactory();
  31666. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31667. var data = parameters.annotations[i];
  31668. if (!data) {
  31669. continue;
  31670. }
  31671. var properties = {
  31672. data: data,
  31673. layer: parameters.div,
  31674. page: parameters.page,
  31675. viewport: parameters.viewport,
  31676. linkService: parameters.linkService,
  31677. downloadManager: parameters.downloadManager,
  31678. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31679. renderInteractiveForms: parameters.renderInteractiveForms || false
  31680. };
  31681. var element = annotationElementFactory.create(properties);
  31682. if (element.isRenderable) {
  31683. parameters.div.appendChild(element.render());
  31684. }
  31685. }
  31686. },
  31687. update: function AnnotationLayer_update(parameters) {
  31688. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31689. var data = parameters.annotations[i];
  31690. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31691. if (element) {
  31692. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31693. }
  31694. }
  31695. parameters.div.removeAttribute('hidden');
  31696. }
  31697. };
  31698. }();
  31699. exports.AnnotationLayer = AnnotationLayer;
  31700. }));
  31701. (function (root, factory) {
  31702. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31703. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31704. var Util = sharedUtil.Util;
  31705. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31706. var CustomStyle = displayDOMUtils.CustomStyle;
  31707. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31708. var renderTextLayer = function renderTextLayerClosure() {
  31709. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31710. var NonWhitespaceRegexp = /\S/;
  31711. function isAllWhitespace(str) {
  31712. return !NonWhitespaceRegexp.test(str);
  31713. }
  31714. var styleBuf = [
  31715. 'left: ',
  31716. 0,
  31717. 'px; top: ',
  31718. 0,
  31719. 'px; font-size: ',
  31720. 0,
  31721. 'px; font-family: ',
  31722. '',
  31723. ';'
  31724. ];
  31725. function appendText(task, geom, styles) {
  31726. var textDiv = document.createElement('div');
  31727. var textDivProperties = {
  31728. style: null,
  31729. angle: 0,
  31730. canvasWidth: 0,
  31731. isWhitespace: false,
  31732. originalTransform: null,
  31733. paddingBottom: 0,
  31734. paddingLeft: 0,
  31735. paddingRight: 0,
  31736. paddingTop: 0,
  31737. scale: 1
  31738. };
  31739. task._textDivs.push(textDiv);
  31740. if (isAllWhitespace(geom.str)) {
  31741. textDivProperties.isWhitespace = true;
  31742. task._textDivProperties.set(textDiv, textDivProperties);
  31743. return;
  31744. }
  31745. var tx = Util.transform(task._viewport.transform, geom.transform);
  31746. var angle = Math.atan2(tx[1], tx[0]);
  31747. var style = styles[geom.fontName];
  31748. if (style.vertical) {
  31749. angle += Math.PI / 2;
  31750. }
  31751. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31752. var fontAscent = fontHeight;
  31753. if (style.ascent) {
  31754. fontAscent = style.ascent * fontAscent;
  31755. } else if (style.descent) {
  31756. fontAscent = (1 + style.descent) * fontAscent;
  31757. }
  31758. var left;
  31759. var top;
  31760. if (angle === 0) {
  31761. left = tx[4];
  31762. top = tx[5] - fontAscent;
  31763. } else {
  31764. left = tx[4] + fontAscent * Math.sin(angle);
  31765. top = tx[5] - fontAscent * Math.cos(angle);
  31766. }
  31767. styleBuf[1] = left;
  31768. styleBuf[3] = top;
  31769. styleBuf[5] = fontHeight;
  31770. styleBuf[7] = style.fontFamily;
  31771. textDivProperties.style = styleBuf.join('');
  31772. textDiv.setAttribute('style', textDivProperties.style);
  31773. textDiv.textContent = geom.str;
  31774. if (getDefaultSetting('pdfBug')) {
  31775. textDiv.dataset.fontName = geom.fontName;
  31776. }
  31777. if (angle !== 0) {
  31778. textDivProperties.angle = angle * (180 / Math.PI);
  31779. }
  31780. if (geom.str.length > 1) {
  31781. if (style.vertical) {
  31782. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31783. } else {
  31784. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31785. }
  31786. }
  31787. task._textDivProperties.set(textDiv, textDivProperties);
  31788. if (task._enhanceTextSelection) {
  31789. var angleCos = 1, angleSin = 0;
  31790. if (angle !== 0) {
  31791. angleCos = Math.cos(angle);
  31792. angleSin = Math.sin(angle);
  31793. }
  31794. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31795. var divHeight = fontHeight;
  31796. var m, b;
  31797. if (angle !== 0) {
  31798. m = [
  31799. angleCos,
  31800. angleSin,
  31801. -angleSin,
  31802. angleCos,
  31803. left,
  31804. top
  31805. ];
  31806. b = Util.getAxialAlignedBoundingBox([
  31807. 0,
  31808. 0,
  31809. divWidth,
  31810. divHeight
  31811. ], m);
  31812. } else {
  31813. b = [
  31814. left,
  31815. top,
  31816. left + divWidth,
  31817. top + divHeight
  31818. ];
  31819. }
  31820. task._bounds.push({
  31821. left: b[0],
  31822. top: b[1],
  31823. right: b[2],
  31824. bottom: b[3],
  31825. div: textDiv,
  31826. size: [
  31827. divWidth,
  31828. divHeight
  31829. ],
  31830. m: m
  31831. });
  31832. }
  31833. }
  31834. function render(task) {
  31835. if (task._canceled) {
  31836. return;
  31837. }
  31838. var textLayerFrag = task._container;
  31839. var textDivs = task._textDivs;
  31840. var capability = task._capability;
  31841. var textDivsLength = textDivs.length;
  31842. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  31843. task._renderingDone = true;
  31844. capability.resolve();
  31845. return;
  31846. }
  31847. var canvas = document.createElement('canvas');
  31848. var ctx = canvas.getContext('2d', { alpha: false });
  31849. var lastFontSize;
  31850. var lastFontFamily;
  31851. for (var i = 0; i < textDivsLength; i++) {
  31852. var textDiv = textDivs[i];
  31853. var textDivProperties = task._textDivProperties.get(textDiv);
  31854. if (textDivProperties.isWhitespace) {
  31855. continue;
  31856. }
  31857. var fontSize = textDiv.style.fontSize;
  31858. var fontFamily = textDiv.style.fontFamily;
  31859. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  31860. ctx.font = fontSize + ' ' + fontFamily;
  31861. lastFontSize = fontSize;
  31862. lastFontFamily = fontFamily;
  31863. }
  31864. var width = ctx.measureText(textDiv.textContent).width;
  31865. textLayerFrag.appendChild(textDiv);
  31866. var transform = '';
  31867. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  31868. textDivProperties.scale = textDivProperties.canvasWidth / width;
  31869. transform = 'scaleX(' + textDivProperties.scale + ')';
  31870. }
  31871. if (textDivProperties.angle !== 0) {
  31872. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  31873. }
  31874. if (transform !== '') {
  31875. textDivProperties.originalTransform = transform;
  31876. CustomStyle.setProp('transform', textDiv, transform);
  31877. }
  31878. task._textDivProperties.set(textDiv, textDivProperties);
  31879. }
  31880. task._renderingDone = true;
  31881. capability.resolve();
  31882. }
  31883. function expand(task) {
  31884. var bounds = task._bounds;
  31885. var viewport = task._viewport;
  31886. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  31887. for (var i = 0; i < expanded.length; i++) {
  31888. var div = bounds[i].div;
  31889. var divProperties = task._textDivProperties.get(div);
  31890. if (divProperties.angle === 0) {
  31891. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  31892. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  31893. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  31894. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  31895. task._textDivProperties.set(div, divProperties);
  31896. continue;
  31897. }
  31898. var e = expanded[i], b = bounds[i];
  31899. var m = b.m, c = m[0], s = m[1];
  31900. var points = [
  31901. [
  31902. 0,
  31903. 0
  31904. ],
  31905. [
  31906. 0,
  31907. b.size[1]
  31908. ],
  31909. [
  31910. b.size[0],
  31911. 0
  31912. ],
  31913. b.size
  31914. ];
  31915. var ts = new Float64Array(64);
  31916. points.forEach(function (p, i) {
  31917. var t = Util.applyTransform(p, m);
  31918. ts[i + 0] = c && (e.left - t[0]) / c;
  31919. ts[i + 4] = s && (e.top - t[1]) / s;
  31920. ts[i + 8] = c && (e.right - t[0]) / c;
  31921. ts[i + 12] = s && (e.bottom - t[1]) / s;
  31922. ts[i + 16] = s && (e.left - t[0]) / -s;
  31923. ts[i + 20] = c && (e.top - t[1]) / c;
  31924. ts[i + 24] = s && (e.right - t[0]) / -s;
  31925. ts[i + 28] = c && (e.bottom - t[1]) / c;
  31926. ts[i + 32] = c && (e.left - t[0]) / -c;
  31927. ts[i + 36] = s && (e.top - t[1]) / -s;
  31928. ts[i + 40] = c && (e.right - t[0]) / -c;
  31929. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  31930. ts[i + 48] = s && (e.left - t[0]) / s;
  31931. ts[i + 52] = c && (e.top - t[1]) / -c;
  31932. ts[i + 56] = s && (e.right - t[0]) / s;
  31933. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  31934. });
  31935. var findPositiveMin = function (ts, offset, count) {
  31936. var result = 0;
  31937. for (var i = 0; i < count; i++) {
  31938. var t = ts[offset++];
  31939. if (t > 0) {
  31940. result = result ? Math.min(t, result) : t;
  31941. }
  31942. }
  31943. return result;
  31944. };
  31945. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  31946. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  31947. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  31948. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  31949. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  31950. task._textDivProperties.set(div, divProperties);
  31951. }
  31952. }
  31953. function expandBounds(width, height, boxes) {
  31954. var bounds = boxes.map(function (box, i) {
  31955. return {
  31956. x1: box.left,
  31957. y1: box.top,
  31958. x2: box.right,
  31959. y2: box.bottom,
  31960. index: i,
  31961. x1New: undefined,
  31962. x2New: undefined
  31963. };
  31964. });
  31965. expandBoundsLTR(width, bounds);
  31966. var expanded = new Array(boxes.length);
  31967. bounds.forEach(function (b) {
  31968. var i = b.index;
  31969. expanded[i] = {
  31970. left: b.x1New,
  31971. top: 0,
  31972. right: b.x2New,
  31973. bottom: 0
  31974. };
  31975. });
  31976. boxes.map(function (box, i) {
  31977. var e = expanded[i], b = bounds[i];
  31978. b.x1 = box.top;
  31979. b.y1 = width - e.right;
  31980. b.x2 = box.bottom;
  31981. b.y2 = width - e.left;
  31982. b.index = i;
  31983. b.x1New = undefined;
  31984. b.x2New = undefined;
  31985. });
  31986. expandBoundsLTR(height, bounds);
  31987. bounds.forEach(function (b) {
  31988. var i = b.index;
  31989. expanded[i].top = b.x1New;
  31990. expanded[i].bottom = b.x2New;
  31991. });
  31992. return expanded;
  31993. }
  31994. function expandBoundsLTR(width, bounds) {
  31995. bounds.sort(function (a, b) {
  31996. return a.x1 - b.x1 || a.index - b.index;
  31997. });
  31998. var fakeBoundary = {
  31999. x1: -Infinity,
  32000. y1: -Infinity,
  32001. x2: 0,
  32002. y2: Infinity,
  32003. index: -1,
  32004. x1New: 0,
  32005. x2New: 0
  32006. };
  32007. var horizon = [{
  32008. start: -Infinity,
  32009. end: Infinity,
  32010. boundary: fakeBoundary
  32011. }];
  32012. bounds.forEach(function (boundary) {
  32013. var i = 0;
  32014. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32015. i++;
  32016. }
  32017. var j = horizon.length - 1;
  32018. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32019. j--;
  32020. }
  32021. var horizonPart, affectedBoundary;
  32022. var q, k, maxXNew = -Infinity;
  32023. for (q = i; q <= j; q++) {
  32024. horizonPart = horizon[q];
  32025. affectedBoundary = horizonPart.boundary;
  32026. var xNew;
  32027. if (affectedBoundary.x2 > boundary.x1) {
  32028. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32029. } else if (affectedBoundary.x2New === undefined) {
  32030. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32031. } else {
  32032. xNew = affectedBoundary.x2New;
  32033. }
  32034. if (xNew > maxXNew) {
  32035. maxXNew = xNew;
  32036. }
  32037. }
  32038. boundary.x1New = maxXNew;
  32039. for (q = i; q <= j; q++) {
  32040. horizonPart = horizon[q];
  32041. affectedBoundary = horizonPart.boundary;
  32042. if (affectedBoundary.x2New === undefined) {
  32043. if (affectedBoundary.x2 > boundary.x1) {
  32044. if (affectedBoundary.index > boundary.index) {
  32045. affectedBoundary.x2New = affectedBoundary.x2;
  32046. }
  32047. } else {
  32048. affectedBoundary.x2New = maxXNew;
  32049. }
  32050. } else if (affectedBoundary.x2New > maxXNew) {
  32051. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32052. }
  32053. }
  32054. var changedHorizon = [], lastBoundary = null;
  32055. for (q = i; q <= j; q++) {
  32056. horizonPart = horizon[q];
  32057. affectedBoundary = horizonPart.boundary;
  32058. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32059. if (lastBoundary === useBoundary) {
  32060. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32061. } else {
  32062. changedHorizon.push({
  32063. start: horizonPart.start,
  32064. end: horizonPart.end,
  32065. boundary: useBoundary
  32066. });
  32067. lastBoundary = useBoundary;
  32068. }
  32069. }
  32070. if (horizon[i].start < boundary.y1) {
  32071. changedHorizon[0].start = boundary.y1;
  32072. changedHorizon.unshift({
  32073. start: horizon[i].start,
  32074. end: boundary.y1,
  32075. boundary: horizon[i].boundary
  32076. });
  32077. }
  32078. if (boundary.y2 < horizon[j].end) {
  32079. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32080. changedHorizon.push({
  32081. start: boundary.y2,
  32082. end: horizon[j].end,
  32083. boundary: horizon[j].boundary
  32084. });
  32085. }
  32086. for (q = i; q <= j; q++) {
  32087. horizonPart = horizon[q];
  32088. affectedBoundary = horizonPart.boundary;
  32089. if (affectedBoundary.x2New !== undefined) {
  32090. continue;
  32091. }
  32092. var used = false;
  32093. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32094. used = horizon[k].boundary === affectedBoundary;
  32095. }
  32096. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32097. used = horizon[k].boundary === affectedBoundary;
  32098. }
  32099. for (k = 0; !used && k < changedHorizon.length; k++) {
  32100. used = changedHorizon[k].boundary === affectedBoundary;
  32101. }
  32102. if (!used) {
  32103. affectedBoundary.x2New = maxXNew;
  32104. }
  32105. }
  32106. Array.prototype.splice.apply(horizon, [
  32107. i,
  32108. j - i + 1
  32109. ].concat(changedHorizon));
  32110. });
  32111. horizon.forEach(function (horizonPart) {
  32112. var affectedBoundary = horizonPart.boundary;
  32113. if (affectedBoundary.x2New === undefined) {
  32114. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32115. }
  32116. });
  32117. }
  32118. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32119. this._textContent = textContent;
  32120. this._container = container;
  32121. this._viewport = viewport;
  32122. this._textDivs = textDivs || [];
  32123. this._textDivProperties = new WeakMap();
  32124. this._renderingDone = false;
  32125. this._canceled = false;
  32126. this._capability = createPromiseCapability();
  32127. this._renderTimer = null;
  32128. this._bounds = [];
  32129. this._enhanceTextSelection = !!enhanceTextSelection;
  32130. }
  32131. TextLayerRenderTask.prototype = {
  32132. get promise() {
  32133. return this._capability.promise;
  32134. },
  32135. cancel: function TextLayer_cancel() {
  32136. this._canceled = true;
  32137. if (this._renderTimer !== null) {
  32138. clearTimeout(this._renderTimer);
  32139. this._renderTimer = null;
  32140. }
  32141. this._capability.reject('canceled');
  32142. },
  32143. _render: function TextLayer_render(timeout) {
  32144. var textItems = this._textContent.items;
  32145. var textStyles = this._textContent.styles;
  32146. for (var i = 0, len = textItems.length; i < len; i++) {
  32147. appendText(this, textItems[i], textStyles);
  32148. }
  32149. if (!timeout) {
  32150. render(this);
  32151. } else {
  32152. var self = this;
  32153. this._renderTimer = setTimeout(function () {
  32154. render(self);
  32155. self._renderTimer = null;
  32156. }, timeout);
  32157. }
  32158. },
  32159. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32160. if (!this._enhanceTextSelection || !this._renderingDone) {
  32161. return;
  32162. }
  32163. if (this._bounds !== null) {
  32164. expand(this);
  32165. this._bounds = null;
  32166. }
  32167. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32168. var div = this._textDivs[i];
  32169. var divProperties = this._textDivProperties.get(div);
  32170. if (divProperties.isWhitespace) {
  32171. continue;
  32172. }
  32173. if (expandDivs) {
  32174. var transform = '', padding = '';
  32175. if (divProperties.scale !== 1) {
  32176. transform = 'scaleX(' + divProperties.scale + ')';
  32177. }
  32178. if (divProperties.angle !== 0) {
  32179. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32180. }
  32181. if (divProperties.paddingLeft !== 0) {
  32182. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32183. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32184. }
  32185. if (divProperties.paddingTop !== 0) {
  32186. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32187. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32188. }
  32189. if (divProperties.paddingRight !== 0) {
  32190. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32191. }
  32192. if (divProperties.paddingBottom !== 0) {
  32193. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32194. }
  32195. if (padding !== '') {
  32196. div.setAttribute('style', divProperties.style + padding);
  32197. }
  32198. if (transform !== '') {
  32199. CustomStyle.setProp('transform', div, transform);
  32200. }
  32201. } else {
  32202. div.style.padding = 0;
  32203. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32204. }
  32205. }
  32206. }
  32207. };
  32208. function renderTextLayer(renderParameters) {
  32209. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32210. task._render(renderParameters.timeout);
  32211. return task;
  32212. }
  32213. return renderTextLayer;
  32214. }();
  32215. exports.renderTextLayer = renderTextLayer;
  32216. }));
  32217. (function (root, factory) {
  32218. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32219. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32220. var shadow = sharedUtil.shadow;
  32221. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32222. var WebGLUtils = function WebGLUtilsClosure() {
  32223. function loadShader(gl, code, shaderType) {
  32224. var shader = gl.createShader(shaderType);
  32225. gl.shaderSource(shader, code);
  32226. gl.compileShader(shader);
  32227. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32228. if (!compiled) {
  32229. var errorMsg = gl.getShaderInfoLog(shader);
  32230. throw new Error('Error during shader compilation: ' + errorMsg);
  32231. }
  32232. return shader;
  32233. }
  32234. function createVertexShader(gl, code) {
  32235. return loadShader(gl, code, gl.VERTEX_SHADER);
  32236. }
  32237. function createFragmentShader(gl, code) {
  32238. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32239. }
  32240. function createProgram(gl, shaders) {
  32241. var program = gl.createProgram();
  32242. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32243. gl.attachShader(program, shaders[i]);
  32244. }
  32245. gl.linkProgram(program);
  32246. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32247. if (!linked) {
  32248. var errorMsg = gl.getProgramInfoLog(program);
  32249. throw new Error('Error during program linking: ' + errorMsg);
  32250. }
  32251. return program;
  32252. }
  32253. function createTexture(gl, image, textureId) {
  32254. gl.activeTexture(textureId);
  32255. var texture = gl.createTexture();
  32256. gl.bindTexture(gl.TEXTURE_2D, texture);
  32257. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32258. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32259. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32260. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32261. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32262. return texture;
  32263. }
  32264. var currentGL, currentCanvas;
  32265. function generateGL() {
  32266. if (currentGL) {
  32267. return;
  32268. }
  32269. currentCanvas = document.createElement('canvas');
  32270. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32271. }
  32272. var smaskVertexShaderCode = '\
  32273. attribute vec2 a_position; \
  32274. attribute vec2 a_texCoord; \
  32275. \
  32276. uniform vec2 u_resolution; \
  32277. \
  32278. varying vec2 v_texCoord; \
  32279. \
  32280. void main() { \
  32281. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32282. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32283. \
  32284. v_texCoord = a_texCoord; \
  32285. } ';
  32286. var smaskFragmentShaderCode = '\
  32287. precision mediump float; \
  32288. \
  32289. uniform vec4 u_backdrop; \
  32290. uniform int u_subtype; \
  32291. uniform sampler2D u_image; \
  32292. uniform sampler2D u_mask; \
  32293. \
  32294. varying vec2 v_texCoord; \
  32295. \
  32296. void main() { \
  32297. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32298. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32299. if (u_backdrop.a > 0.0) { \
  32300. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32301. u_backdrop.rgb * (1.0 - maskColor.a); \
  32302. } \
  32303. float lum; \
  32304. if (u_subtype == 0) { \
  32305. lum = maskColor.a; \
  32306. } else { \
  32307. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32308. maskColor.b * 0.11; \
  32309. } \
  32310. imageColor.a *= lum; \
  32311. imageColor.rgb *= imageColor.a; \
  32312. gl_FragColor = imageColor; \
  32313. } ';
  32314. var smaskCache = null;
  32315. function initSmaskGL() {
  32316. var canvas, gl;
  32317. generateGL();
  32318. canvas = currentCanvas;
  32319. currentCanvas = null;
  32320. gl = currentGL;
  32321. currentGL = null;
  32322. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32323. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32324. var program = createProgram(gl, [
  32325. vertexShader,
  32326. fragmentShader
  32327. ]);
  32328. gl.useProgram(program);
  32329. var cache = {};
  32330. cache.gl = gl;
  32331. cache.canvas = canvas;
  32332. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32333. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32334. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32335. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32336. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32337. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32338. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32339. var texCoordBuffer = gl.createBuffer();
  32340. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32341. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32342. 0.0,
  32343. 0.0,
  32344. 1.0,
  32345. 0.0,
  32346. 0.0,
  32347. 1.0,
  32348. 0.0,
  32349. 1.0,
  32350. 1.0,
  32351. 0.0,
  32352. 1.0,
  32353. 1.0
  32354. ]), gl.STATIC_DRAW);
  32355. gl.enableVertexAttribArray(texCoordLocation);
  32356. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32357. gl.uniform1i(texLayerLocation, 0);
  32358. gl.uniform1i(texMaskLocation, 1);
  32359. smaskCache = cache;
  32360. }
  32361. function composeSMask(layer, mask, properties) {
  32362. var width = layer.width, height = layer.height;
  32363. if (!smaskCache) {
  32364. initSmaskGL();
  32365. }
  32366. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32367. canvas.width = width;
  32368. canvas.height = height;
  32369. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32370. gl.uniform2f(cache.resolutionLocation, width, height);
  32371. if (properties.backdrop) {
  32372. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32373. } else {
  32374. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32375. }
  32376. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32377. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32378. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32379. var buffer = gl.createBuffer();
  32380. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32381. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32382. 0,
  32383. 0,
  32384. width,
  32385. 0,
  32386. 0,
  32387. height,
  32388. 0,
  32389. height,
  32390. width,
  32391. 0,
  32392. width,
  32393. height
  32394. ]), gl.STATIC_DRAW);
  32395. gl.enableVertexAttribArray(cache.positionLocation);
  32396. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32397. gl.clearColor(0, 0, 0, 0);
  32398. gl.enable(gl.BLEND);
  32399. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32400. gl.clear(gl.COLOR_BUFFER_BIT);
  32401. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32402. gl.flush();
  32403. gl.deleteTexture(texture);
  32404. gl.deleteTexture(maskTexture);
  32405. gl.deleteBuffer(buffer);
  32406. return canvas;
  32407. }
  32408. var figuresVertexShaderCode = '\
  32409. attribute vec2 a_position; \
  32410. attribute vec3 a_color; \
  32411. \
  32412. uniform vec2 u_resolution; \
  32413. uniform vec2 u_scale; \
  32414. uniform vec2 u_offset; \
  32415. \
  32416. varying vec4 v_color; \
  32417. \
  32418. void main() { \
  32419. vec2 position = (a_position + u_offset) * u_scale; \
  32420. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32421. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32422. \
  32423. v_color = vec4(a_color / 255.0, 1.0); \
  32424. } ';
  32425. var figuresFragmentShaderCode = '\
  32426. precision mediump float; \
  32427. \
  32428. varying vec4 v_color; \
  32429. \
  32430. void main() { \
  32431. gl_FragColor = v_color; \
  32432. } ';
  32433. var figuresCache = null;
  32434. function initFiguresGL() {
  32435. var canvas, gl;
  32436. generateGL();
  32437. canvas = currentCanvas;
  32438. currentCanvas = null;
  32439. gl = currentGL;
  32440. currentGL = null;
  32441. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32442. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32443. var program = createProgram(gl, [
  32444. vertexShader,
  32445. fragmentShader
  32446. ]);
  32447. gl.useProgram(program);
  32448. var cache = {};
  32449. cache.gl = gl;
  32450. cache.canvas = canvas;
  32451. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32452. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32453. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32454. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32455. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32456. figuresCache = cache;
  32457. }
  32458. function drawFigures(width, height, backgroundColor, figures, context) {
  32459. if (!figuresCache) {
  32460. initFiguresGL();
  32461. }
  32462. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32463. canvas.width = width;
  32464. canvas.height = height;
  32465. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32466. gl.uniform2f(cache.resolutionLocation, width, height);
  32467. var count = 0;
  32468. var i, ii, rows;
  32469. for (i = 0, ii = figures.length; i < ii; i++) {
  32470. switch (figures[i].type) {
  32471. case 'lattice':
  32472. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32473. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32474. break;
  32475. case 'triangles':
  32476. count += figures[i].coords.length;
  32477. break;
  32478. }
  32479. }
  32480. var coords = new Float32Array(count * 2);
  32481. var colors = new Uint8Array(count * 3);
  32482. var coordsMap = context.coords, colorsMap = context.colors;
  32483. var pIndex = 0, cIndex = 0;
  32484. for (i = 0, ii = figures.length; i < ii; i++) {
  32485. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32486. switch (figure.type) {
  32487. case 'lattice':
  32488. var cols = figure.verticesPerRow;
  32489. rows = ps.length / cols | 0;
  32490. for (var row = 1; row < rows; row++) {
  32491. var offset = row * cols + 1;
  32492. for (var col = 1; col < cols; col++, offset++) {
  32493. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32494. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32495. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32496. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32497. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32498. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32499. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32500. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32501. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32502. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32503. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32504. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32505. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32506. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32507. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32508. coords[pIndex + 6] = coords[pIndex + 2];
  32509. coords[pIndex + 7] = coords[pIndex + 3];
  32510. coords[pIndex + 8] = coords[pIndex + 4];
  32511. coords[pIndex + 9] = coords[pIndex + 5];
  32512. coords[pIndex + 10] = coordsMap[ps[offset]];
  32513. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32514. colors[cIndex + 9] = colors[cIndex + 3];
  32515. colors[cIndex + 10] = colors[cIndex + 4];
  32516. colors[cIndex + 11] = colors[cIndex + 5];
  32517. colors[cIndex + 12] = colors[cIndex + 6];
  32518. colors[cIndex + 13] = colors[cIndex + 7];
  32519. colors[cIndex + 14] = colors[cIndex + 8];
  32520. colors[cIndex + 15] = colorsMap[cs[offset]];
  32521. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32522. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32523. pIndex += 12;
  32524. cIndex += 18;
  32525. }
  32526. }
  32527. break;
  32528. case 'triangles':
  32529. for (var j = 0, jj = ps.length; j < jj; j++) {
  32530. coords[pIndex] = coordsMap[ps[j]];
  32531. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32532. colors[cIndex] = colorsMap[cs[j]];
  32533. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32534. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32535. pIndex += 2;
  32536. cIndex += 3;
  32537. }
  32538. break;
  32539. }
  32540. }
  32541. if (backgroundColor) {
  32542. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32543. } else {
  32544. gl.clearColor(0, 0, 0, 0);
  32545. }
  32546. gl.clear(gl.COLOR_BUFFER_BIT);
  32547. var coordsBuffer = gl.createBuffer();
  32548. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32549. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32550. gl.enableVertexAttribArray(cache.positionLocation);
  32551. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32552. var colorsBuffer = gl.createBuffer();
  32553. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32554. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32555. gl.enableVertexAttribArray(cache.colorLocation);
  32556. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32557. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32558. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32559. gl.drawArrays(gl.TRIANGLES, 0, count);
  32560. gl.flush();
  32561. gl.deleteBuffer(coordsBuffer);
  32562. gl.deleteBuffer(colorsBuffer);
  32563. return canvas;
  32564. }
  32565. function cleanup() {
  32566. if (smaskCache && smaskCache.canvas) {
  32567. smaskCache.canvas.width = 0;
  32568. smaskCache.canvas.height = 0;
  32569. }
  32570. if (figuresCache && figuresCache.canvas) {
  32571. figuresCache.canvas.width = 0;
  32572. figuresCache.canvas.height = 0;
  32573. }
  32574. smaskCache = null;
  32575. figuresCache = null;
  32576. }
  32577. return {
  32578. get isEnabled() {
  32579. if (getDefaultSetting('disableWebGL')) {
  32580. return false;
  32581. }
  32582. var enabled = false;
  32583. try {
  32584. generateGL();
  32585. enabled = !!currentGL;
  32586. } catch (e) {
  32587. }
  32588. return shadow(this, 'isEnabled', enabled);
  32589. },
  32590. composeSMask: composeSMask,
  32591. drawFigures: drawFigures,
  32592. clear: cleanup
  32593. };
  32594. }();
  32595. exports.WebGLUtils = WebGLUtils;
  32596. }));
  32597. (function (root, factory) {
  32598. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32599. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32600. var PasswordException = sharedUtil.PasswordException;
  32601. var PasswordResponses = sharedUtil.PasswordResponses;
  32602. var bytesToString = sharedUtil.bytesToString;
  32603. var warn = sharedUtil.warn;
  32604. var error = sharedUtil.error;
  32605. var assert = sharedUtil.assert;
  32606. var isInt = sharedUtil.isInt;
  32607. var stringToBytes = sharedUtil.stringToBytes;
  32608. var utf8StringToString = sharedUtil.utf8StringToString;
  32609. var Name = corePrimitives.Name;
  32610. var isName = corePrimitives.isName;
  32611. var isDict = corePrimitives.isDict;
  32612. var DecryptStream = coreStream.DecryptStream;
  32613. var ARCFourCipher = function ARCFourCipherClosure() {
  32614. function ARCFourCipher(key) {
  32615. this.a = 0;
  32616. this.b = 0;
  32617. var s = new Uint8Array(256);
  32618. var i, j = 0, tmp, keyLength = key.length;
  32619. for (i = 0; i < 256; ++i) {
  32620. s[i] = i;
  32621. }
  32622. for (i = 0; i < 256; ++i) {
  32623. tmp = s[i];
  32624. j = j + tmp + key[i % keyLength] & 0xFF;
  32625. s[i] = s[j];
  32626. s[j] = tmp;
  32627. }
  32628. this.s = s;
  32629. }
  32630. ARCFourCipher.prototype = {
  32631. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32632. var i, n = data.length, tmp, tmp2;
  32633. var a = this.a, b = this.b, s = this.s;
  32634. var output = new Uint8Array(n);
  32635. for (i = 0; i < n; ++i) {
  32636. a = a + 1 & 0xFF;
  32637. tmp = s[a];
  32638. b = b + tmp & 0xFF;
  32639. tmp2 = s[b];
  32640. s[a] = tmp2;
  32641. s[b] = tmp;
  32642. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32643. }
  32644. this.a = a;
  32645. this.b = b;
  32646. return output;
  32647. }
  32648. };
  32649. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32650. return ARCFourCipher;
  32651. }();
  32652. var calculateMD5 = function calculateMD5Closure() {
  32653. var r = new Uint8Array([
  32654. 7,
  32655. 12,
  32656. 17,
  32657. 22,
  32658. 7,
  32659. 12,
  32660. 17,
  32661. 22,
  32662. 7,
  32663. 12,
  32664. 17,
  32665. 22,
  32666. 7,
  32667. 12,
  32668. 17,
  32669. 22,
  32670. 5,
  32671. 9,
  32672. 14,
  32673. 20,
  32674. 5,
  32675. 9,
  32676. 14,
  32677. 20,
  32678. 5,
  32679. 9,
  32680. 14,
  32681. 20,
  32682. 5,
  32683. 9,
  32684. 14,
  32685. 20,
  32686. 4,
  32687. 11,
  32688. 16,
  32689. 23,
  32690. 4,
  32691. 11,
  32692. 16,
  32693. 23,
  32694. 4,
  32695. 11,
  32696. 16,
  32697. 23,
  32698. 4,
  32699. 11,
  32700. 16,
  32701. 23,
  32702. 6,
  32703. 10,
  32704. 15,
  32705. 21,
  32706. 6,
  32707. 10,
  32708. 15,
  32709. 21,
  32710. 6,
  32711. 10,
  32712. 15,
  32713. 21,
  32714. 6,
  32715. 10,
  32716. 15,
  32717. 21
  32718. ]);
  32719. var k = new Int32Array([
  32720. -680876936,
  32721. -389564586,
  32722. 606105819,
  32723. -1044525330,
  32724. -176418897,
  32725. 1200080426,
  32726. -1473231341,
  32727. -45705983,
  32728. 1770035416,
  32729. -1958414417,
  32730. -42063,
  32731. -1990404162,
  32732. 1804603682,
  32733. -40341101,
  32734. -1502002290,
  32735. 1236535329,
  32736. -165796510,
  32737. -1069501632,
  32738. 643717713,
  32739. -373897302,
  32740. -701558691,
  32741. 38016083,
  32742. -660478335,
  32743. -405537848,
  32744. 568446438,
  32745. -1019803690,
  32746. -187363961,
  32747. 1163531501,
  32748. -1444681467,
  32749. -51403784,
  32750. 1735328473,
  32751. -1926607734,
  32752. -378558,
  32753. -2022574463,
  32754. 1839030562,
  32755. -35309556,
  32756. -1530992060,
  32757. 1272893353,
  32758. -155497632,
  32759. -1094730640,
  32760. 681279174,
  32761. -358537222,
  32762. -722521979,
  32763. 76029189,
  32764. -640364487,
  32765. -421815835,
  32766. 530742520,
  32767. -995338651,
  32768. -198630844,
  32769. 1126891415,
  32770. -1416354905,
  32771. -57434055,
  32772. 1700485571,
  32773. -1894986606,
  32774. -1051523,
  32775. -2054922799,
  32776. 1873313359,
  32777. -30611744,
  32778. -1560198380,
  32779. 1309151649,
  32780. -145523070,
  32781. -1120210379,
  32782. 718787259,
  32783. -343485551
  32784. ]);
  32785. function hash(data, offset, length) {
  32786. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32787. var paddedLength = length + 72 & ~63;
  32788. var padded = new Uint8Array(paddedLength);
  32789. var i, j, n;
  32790. for (i = 0; i < length; ++i) {
  32791. padded[i] = data[offset++];
  32792. }
  32793. padded[i++] = 0x80;
  32794. n = paddedLength - 8;
  32795. while (i < n) {
  32796. padded[i++] = 0;
  32797. }
  32798. padded[i++] = length << 3 & 0xFF;
  32799. padded[i++] = length >> 5 & 0xFF;
  32800. padded[i++] = length >> 13 & 0xFF;
  32801. padded[i++] = length >> 21 & 0xFF;
  32802. padded[i++] = length >>> 29 & 0xFF;
  32803. padded[i++] = 0;
  32804. padded[i++] = 0;
  32805. padded[i++] = 0;
  32806. var w = new Int32Array(16);
  32807. for (i = 0; i < paddedLength;) {
  32808. for (j = 0; j < 16; ++j, i += 4) {
  32809. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32810. }
  32811. var a = h0, b = h1, c = h2, d = h3, f, g;
  32812. for (j = 0; j < 64; ++j) {
  32813. if (j < 16) {
  32814. f = b & c | ~b & d;
  32815. g = j;
  32816. } else if (j < 32) {
  32817. f = d & b | ~d & c;
  32818. g = 5 * j + 1 & 15;
  32819. } else if (j < 48) {
  32820. f = b ^ c ^ d;
  32821. g = 3 * j + 5 & 15;
  32822. } else {
  32823. f = c ^ (b | ~d);
  32824. g = 7 * j & 15;
  32825. }
  32826. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  32827. d = c;
  32828. c = b;
  32829. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  32830. a = tmp;
  32831. }
  32832. h0 = h0 + a | 0;
  32833. h1 = h1 + b | 0;
  32834. h2 = h2 + c | 0;
  32835. h3 = h3 + d | 0;
  32836. }
  32837. return new Uint8Array([
  32838. h0 & 0xFF,
  32839. h0 >> 8 & 0xFF,
  32840. h0 >> 16 & 0xFF,
  32841. h0 >>> 24 & 0xFF,
  32842. h1 & 0xFF,
  32843. h1 >> 8 & 0xFF,
  32844. h1 >> 16 & 0xFF,
  32845. h1 >>> 24 & 0xFF,
  32846. h2 & 0xFF,
  32847. h2 >> 8 & 0xFF,
  32848. h2 >> 16 & 0xFF,
  32849. h2 >>> 24 & 0xFF,
  32850. h3 & 0xFF,
  32851. h3 >> 8 & 0xFF,
  32852. h3 >> 16 & 0xFF,
  32853. h3 >>> 24 & 0xFF
  32854. ]);
  32855. }
  32856. return hash;
  32857. }();
  32858. var Word64 = function Word64Closure() {
  32859. function Word64(highInteger, lowInteger) {
  32860. this.high = highInteger | 0;
  32861. this.low = lowInteger | 0;
  32862. }
  32863. Word64.prototype = {
  32864. and: function Word64_and(word) {
  32865. this.high &= word.high;
  32866. this.low &= word.low;
  32867. },
  32868. xor: function Word64_xor(word) {
  32869. this.high ^= word.high;
  32870. this.low ^= word.low;
  32871. },
  32872. or: function Word64_or(word) {
  32873. this.high |= word.high;
  32874. this.low |= word.low;
  32875. },
  32876. shiftRight: function Word64_shiftRight(places) {
  32877. if (places >= 32) {
  32878. this.low = this.high >>> places - 32 | 0;
  32879. this.high = 0;
  32880. } else {
  32881. this.low = this.low >>> places | this.high << 32 - places;
  32882. this.high = this.high >>> places | 0;
  32883. }
  32884. },
  32885. shiftLeft: function Word64_shiftLeft(places) {
  32886. if (places >= 32) {
  32887. this.high = this.low << places - 32;
  32888. this.low = 0;
  32889. } else {
  32890. this.high = this.high << places | this.low >>> 32 - places;
  32891. this.low = this.low << places;
  32892. }
  32893. },
  32894. rotateRight: function Word64_rotateRight(places) {
  32895. var low, high;
  32896. if (places & 32) {
  32897. high = this.low;
  32898. low = this.high;
  32899. } else {
  32900. low = this.low;
  32901. high = this.high;
  32902. }
  32903. places &= 31;
  32904. this.low = low >>> places | high << 32 - places;
  32905. this.high = high >>> places | low << 32 - places;
  32906. },
  32907. not: function Word64_not() {
  32908. this.high = ~this.high;
  32909. this.low = ~this.low;
  32910. },
  32911. add: function Word64_add(word) {
  32912. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  32913. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  32914. if (lowAdd > 0xFFFFFFFF) {
  32915. highAdd += 1;
  32916. }
  32917. this.low = lowAdd | 0;
  32918. this.high = highAdd | 0;
  32919. },
  32920. copyTo: function Word64_copyTo(bytes, offset) {
  32921. bytes[offset] = this.high >>> 24 & 0xFF;
  32922. bytes[offset + 1] = this.high >> 16 & 0xFF;
  32923. bytes[offset + 2] = this.high >> 8 & 0xFF;
  32924. bytes[offset + 3] = this.high & 0xFF;
  32925. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  32926. bytes[offset + 5] = this.low >> 16 & 0xFF;
  32927. bytes[offset + 6] = this.low >> 8 & 0xFF;
  32928. bytes[offset + 7] = this.low & 0xFF;
  32929. },
  32930. assign: function Word64_assign(word) {
  32931. this.high = word.high;
  32932. this.low = word.low;
  32933. }
  32934. };
  32935. return Word64;
  32936. }();
  32937. var calculateSHA256 = function calculateSHA256Closure() {
  32938. function rotr(x, n) {
  32939. return x >>> n | x << 32 - n;
  32940. }
  32941. function ch(x, y, z) {
  32942. return x & y ^ ~x & z;
  32943. }
  32944. function maj(x, y, z) {
  32945. return x & y ^ x & z ^ y & z;
  32946. }
  32947. function sigma(x) {
  32948. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  32949. }
  32950. function sigmaPrime(x) {
  32951. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  32952. }
  32953. function littleSigma(x) {
  32954. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  32955. }
  32956. function littleSigmaPrime(x) {
  32957. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  32958. }
  32959. var k = [
  32960. 0x428a2f98,
  32961. 0x71374491,
  32962. 0xb5c0fbcf,
  32963. 0xe9b5dba5,
  32964. 0x3956c25b,
  32965. 0x59f111f1,
  32966. 0x923f82a4,
  32967. 0xab1c5ed5,
  32968. 0xd807aa98,
  32969. 0x12835b01,
  32970. 0x243185be,
  32971. 0x550c7dc3,
  32972. 0x72be5d74,
  32973. 0x80deb1fe,
  32974. 0x9bdc06a7,
  32975. 0xc19bf174,
  32976. 0xe49b69c1,
  32977. 0xefbe4786,
  32978. 0x0fc19dc6,
  32979. 0x240ca1cc,
  32980. 0x2de92c6f,
  32981. 0x4a7484aa,
  32982. 0x5cb0a9dc,
  32983. 0x76f988da,
  32984. 0x983e5152,
  32985. 0xa831c66d,
  32986. 0xb00327c8,
  32987. 0xbf597fc7,
  32988. 0xc6e00bf3,
  32989. 0xd5a79147,
  32990. 0x06ca6351,
  32991. 0x14292967,
  32992. 0x27b70a85,
  32993. 0x2e1b2138,
  32994. 0x4d2c6dfc,
  32995. 0x53380d13,
  32996. 0x650a7354,
  32997. 0x766a0abb,
  32998. 0x81c2c92e,
  32999. 0x92722c85,
  33000. 0xa2bfe8a1,
  33001. 0xa81a664b,
  33002. 0xc24b8b70,
  33003. 0xc76c51a3,
  33004. 0xd192e819,
  33005. 0xd6990624,
  33006. 0xf40e3585,
  33007. 0x106aa070,
  33008. 0x19a4c116,
  33009. 0x1e376c08,
  33010. 0x2748774c,
  33011. 0x34b0bcb5,
  33012. 0x391c0cb3,
  33013. 0x4ed8aa4a,
  33014. 0x5b9cca4f,
  33015. 0x682e6ff3,
  33016. 0x748f82ee,
  33017. 0x78a5636f,
  33018. 0x84c87814,
  33019. 0x8cc70208,
  33020. 0x90befffa,
  33021. 0xa4506ceb,
  33022. 0xbef9a3f7,
  33023. 0xc67178f2
  33024. ];
  33025. function hash(data, offset, length) {
  33026. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33027. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33028. var padded = new Uint8Array(paddedLength);
  33029. var i, j, n;
  33030. for (i = 0; i < length; ++i) {
  33031. padded[i] = data[offset++];
  33032. }
  33033. padded[i++] = 0x80;
  33034. n = paddedLength - 8;
  33035. while (i < n) {
  33036. padded[i++] = 0;
  33037. }
  33038. padded[i++] = 0;
  33039. padded[i++] = 0;
  33040. padded[i++] = 0;
  33041. padded[i++] = length >>> 29 & 0xFF;
  33042. padded[i++] = length >> 21 & 0xFF;
  33043. padded[i++] = length >> 13 & 0xFF;
  33044. padded[i++] = length >> 5 & 0xFF;
  33045. padded[i++] = length << 3 & 0xFF;
  33046. var w = new Uint32Array(64);
  33047. for (i = 0; i < paddedLength;) {
  33048. for (j = 0; j < 16; ++j) {
  33049. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33050. i += 4;
  33051. }
  33052. for (j = 16; j < 64; ++j) {
  33053. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33054. }
  33055. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33056. for (j = 0; j < 64; ++j) {
  33057. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33058. t2 = sigma(a) + maj(a, b, c);
  33059. h = g;
  33060. g = f;
  33061. f = e;
  33062. e = d + t1 | 0;
  33063. d = c;
  33064. c = b;
  33065. b = a;
  33066. a = t1 + t2 | 0;
  33067. }
  33068. h0 = h0 + a | 0;
  33069. h1 = h1 + b | 0;
  33070. h2 = h2 + c | 0;
  33071. h3 = h3 + d | 0;
  33072. h4 = h4 + e | 0;
  33073. h5 = h5 + f | 0;
  33074. h6 = h6 + g | 0;
  33075. h7 = h7 + h | 0;
  33076. }
  33077. return new Uint8Array([
  33078. h0 >> 24 & 0xFF,
  33079. h0 >> 16 & 0xFF,
  33080. h0 >> 8 & 0xFF,
  33081. h0 & 0xFF,
  33082. h1 >> 24 & 0xFF,
  33083. h1 >> 16 & 0xFF,
  33084. h1 >> 8 & 0xFF,
  33085. h1 & 0xFF,
  33086. h2 >> 24 & 0xFF,
  33087. h2 >> 16 & 0xFF,
  33088. h2 >> 8 & 0xFF,
  33089. h2 & 0xFF,
  33090. h3 >> 24 & 0xFF,
  33091. h3 >> 16 & 0xFF,
  33092. h3 >> 8 & 0xFF,
  33093. h3 & 0xFF,
  33094. h4 >> 24 & 0xFF,
  33095. h4 >> 16 & 0xFF,
  33096. h4 >> 8 & 0xFF,
  33097. h4 & 0xFF,
  33098. h5 >> 24 & 0xFF,
  33099. h5 >> 16 & 0xFF,
  33100. h5 >> 8 & 0xFF,
  33101. h5 & 0xFF,
  33102. h6 >> 24 & 0xFF,
  33103. h6 >> 16 & 0xFF,
  33104. h6 >> 8 & 0xFF,
  33105. h6 & 0xFF,
  33106. h7 >> 24 & 0xFF,
  33107. h7 >> 16 & 0xFF,
  33108. h7 >> 8 & 0xFF,
  33109. h7 & 0xFF
  33110. ]);
  33111. }
  33112. return hash;
  33113. }();
  33114. var calculateSHA512 = function calculateSHA512Closure() {
  33115. function ch(result, x, y, z, tmp) {
  33116. result.assign(x);
  33117. result.and(y);
  33118. tmp.assign(x);
  33119. tmp.not();
  33120. tmp.and(z);
  33121. result.xor(tmp);
  33122. }
  33123. function maj(result, x, y, z, tmp) {
  33124. result.assign(x);
  33125. result.and(y);
  33126. tmp.assign(x);
  33127. tmp.and(z);
  33128. result.xor(tmp);
  33129. tmp.assign(y);
  33130. tmp.and(z);
  33131. result.xor(tmp);
  33132. }
  33133. function sigma(result, x, tmp) {
  33134. result.assign(x);
  33135. result.rotateRight(28);
  33136. tmp.assign(x);
  33137. tmp.rotateRight(34);
  33138. result.xor(tmp);
  33139. tmp.assign(x);
  33140. tmp.rotateRight(39);
  33141. result.xor(tmp);
  33142. }
  33143. function sigmaPrime(result, x, tmp) {
  33144. result.assign(x);
  33145. result.rotateRight(14);
  33146. tmp.assign(x);
  33147. tmp.rotateRight(18);
  33148. result.xor(tmp);
  33149. tmp.assign(x);
  33150. tmp.rotateRight(41);
  33151. result.xor(tmp);
  33152. }
  33153. function littleSigma(result, x, tmp) {
  33154. result.assign(x);
  33155. result.rotateRight(1);
  33156. tmp.assign(x);
  33157. tmp.rotateRight(8);
  33158. result.xor(tmp);
  33159. tmp.assign(x);
  33160. tmp.shiftRight(7);
  33161. result.xor(tmp);
  33162. }
  33163. function littleSigmaPrime(result, x, tmp) {
  33164. result.assign(x);
  33165. result.rotateRight(19);
  33166. tmp.assign(x);
  33167. tmp.rotateRight(61);
  33168. result.xor(tmp);
  33169. tmp.assign(x);
  33170. tmp.shiftRight(6);
  33171. result.xor(tmp);
  33172. }
  33173. var k = [
  33174. new Word64(0x428a2f98, 0xd728ae22),
  33175. new Word64(0x71374491, 0x23ef65cd),
  33176. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33177. new Word64(0xe9b5dba5, 0x8189dbbc),
  33178. new Word64(0x3956c25b, 0xf348b538),
  33179. new Word64(0x59f111f1, 0xb605d019),
  33180. new Word64(0x923f82a4, 0xaf194f9b),
  33181. new Word64(0xab1c5ed5, 0xda6d8118),
  33182. new Word64(0xd807aa98, 0xa3030242),
  33183. new Word64(0x12835b01, 0x45706fbe),
  33184. new Word64(0x243185be, 0x4ee4b28c),
  33185. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33186. new Word64(0x72be5d74, 0xf27b896f),
  33187. new Word64(0x80deb1fe, 0x3b1696b1),
  33188. new Word64(0x9bdc06a7, 0x25c71235),
  33189. new Word64(0xc19bf174, 0xcf692694),
  33190. new Word64(0xe49b69c1, 0x9ef14ad2),
  33191. new Word64(0xefbe4786, 0x384f25e3),
  33192. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33193. new Word64(0x240ca1cc, 0x77ac9c65),
  33194. new Word64(0x2de92c6f, 0x592b0275),
  33195. new Word64(0x4a7484aa, 0x6ea6e483),
  33196. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33197. new Word64(0x76f988da, 0x831153b5),
  33198. new Word64(0x983e5152, 0xee66dfab),
  33199. new Word64(0xa831c66d, 0x2db43210),
  33200. new Word64(0xb00327c8, 0x98fb213f),
  33201. new Word64(0xbf597fc7, 0xbeef0ee4),
  33202. new Word64(0xc6e00bf3, 0x3da88fc2),
  33203. new Word64(0xd5a79147, 0x930aa725),
  33204. new Word64(0x06ca6351, 0xe003826f),
  33205. new Word64(0x14292967, 0x0a0e6e70),
  33206. new Word64(0x27b70a85, 0x46d22ffc),
  33207. new Word64(0x2e1b2138, 0x5c26c926),
  33208. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33209. new Word64(0x53380d13, 0x9d95b3df),
  33210. new Word64(0x650a7354, 0x8baf63de),
  33211. new Word64(0x766a0abb, 0x3c77b2a8),
  33212. new Word64(0x81c2c92e, 0x47edaee6),
  33213. new Word64(0x92722c85, 0x1482353b),
  33214. new Word64(0xa2bfe8a1, 0x4cf10364),
  33215. new Word64(0xa81a664b, 0xbc423001),
  33216. new Word64(0xc24b8b70, 0xd0f89791),
  33217. new Word64(0xc76c51a3, 0x0654be30),
  33218. new Word64(0xd192e819, 0xd6ef5218),
  33219. new Word64(0xd6990624, 0x5565a910),
  33220. new Word64(0xf40e3585, 0x5771202a),
  33221. new Word64(0x106aa070, 0x32bbd1b8),
  33222. new Word64(0x19a4c116, 0xb8d2d0c8),
  33223. new Word64(0x1e376c08, 0x5141ab53),
  33224. new Word64(0x2748774c, 0xdf8eeb99),
  33225. new Word64(0x34b0bcb5, 0xe19b48a8),
  33226. new Word64(0x391c0cb3, 0xc5c95a63),
  33227. new Word64(0x4ed8aa4a, 0xe3418acb),
  33228. new Word64(0x5b9cca4f, 0x7763e373),
  33229. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33230. new Word64(0x748f82ee, 0x5defb2fc),
  33231. new Word64(0x78a5636f, 0x43172f60),
  33232. new Word64(0x84c87814, 0xa1f0ab72),
  33233. new Word64(0x8cc70208, 0x1a6439ec),
  33234. new Word64(0x90befffa, 0x23631e28),
  33235. new Word64(0xa4506ceb, 0xde82bde9),
  33236. new Word64(0xbef9a3f7, 0xb2c67915),
  33237. new Word64(0xc67178f2, 0xe372532b),
  33238. new Word64(0xca273ece, 0xea26619c),
  33239. new Word64(0xd186b8c7, 0x21c0c207),
  33240. new Word64(0xeada7dd6, 0xcde0eb1e),
  33241. new Word64(0xf57d4f7f, 0xee6ed178),
  33242. new Word64(0x06f067aa, 0x72176fba),
  33243. new Word64(0x0a637dc5, 0xa2c898a6),
  33244. new Word64(0x113f9804, 0xbef90dae),
  33245. new Word64(0x1b710b35, 0x131c471b),
  33246. new Word64(0x28db77f5, 0x23047d84),
  33247. new Word64(0x32caab7b, 0x40c72493),
  33248. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33249. new Word64(0x431d67c4, 0x9c100d4c),
  33250. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33251. new Word64(0x597f299c, 0xfc657e2a),
  33252. new Word64(0x5fcb6fab, 0x3ad6faec),
  33253. new Word64(0x6c44198c, 0x4a475817)
  33254. ];
  33255. function hash(data, offset, length, mode384) {
  33256. mode384 = !!mode384;
  33257. var h0, h1, h2, h3, h4, h5, h6, h7;
  33258. if (!mode384) {
  33259. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33260. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33261. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33262. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33263. h4 = new Word64(0x510e527f, 0xade682d1);
  33264. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33265. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33266. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33267. } else {
  33268. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33269. h1 = new Word64(0x629a292a, 0x367cd507);
  33270. h2 = new Word64(0x9159015a, 0x3070dd17);
  33271. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33272. h4 = new Word64(0x67332667, 0xffc00b31);
  33273. h5 = new Word64(0x8eb44a87, 0x68581511);
  33274. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33275. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33276. }
  33277. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33278. var padded = new Uint8Array(paddedLength);
  33279. var i, j, n;
  33280. for (i = 0; i < length; ++i) {
  33281. padded[i] = data[offset++];
  33282. }
  33283. padded[i++] = 0x80;
  33284. n = paddedLength - 16;
  33285. while (i < n) {
  33286. padded[i++] = 0;
  33287. }
  33288. padded[i++] = 0;
  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++] = length >>> 29 & 0xFF;
  33300. padded[i++] = length >> 21 & 0xFF;
  33301. padded[i++] = length >> 13 & 0xFF;
  33302. padded[i++] = length >> 5 & 0xFF;
  33303. padded[i++] = length << 3 & 0xFF;
  33304. var w = new Array(80);
  33305. for (i = 0; i < 80; i++) {
  33306. w[i] = new Word64(0, 0);
  33307. }
  33308. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33309. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33310. var g = new Word64(0, 0), h = new Word64(0, 0);
  33311. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33312. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33313. for (i = 0; i < paddedLength;) {
  33314. for (j = 0; j < 16; ++j) {
  33315. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33316. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33317. i += 8;
  33318. }
  33319. for (j = 16; j < 80; ++j) {
  33320. tmp3 = w[j];
  33321. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33322. tmp3.add(w[j - 7]);
  33323. littleSigma(tmp1, w[j - 15], tmp2);
  33324. tmp3.add(tmp1);
  33325. tmp3.add(w[j - 16]);
  33326. }
  33327. a.assign(h0);
  33328. b.assign(h1);
  33329. c.assign(h2);
  33330. d.assign(h3);
  33331. e.assign(h4);
  33332. f.assign(h5);
  33333. g.assign(h6);
  33334. h.assign(h7);
  33335. for (j = 0; j < 80; ++j) {
  33336. t1.assign(h);
  33337. sigmaPrime(tmp1, e, tmp2);
  33338. t1.add(tmp1);
  33339. ch(tmp1, e, f, g, tmp2);
  33340. t1.add(tmp1);
  33341. t1.add(k[j]);
  33342. t1.add(w[j]);
  33343. sigma(t2, a, tmp2);
  33344. maj(tmp1, a, b, c, tmp2);
  33345. t2.add(tmp1);
  33346. tmp3 = h;
  33347. h = g;
  33348. g = f;
  33349. f = e;
  33350. d.add(t1);
  33351. e = d;
  33352. d = c;
  33353. c = b;
  33354. b = a;
  33355. tmp3.assign(t1);
  33356. tmp3.add(t2);
  33357. a = tmp3;
  33358. }
  33359. h0.add(a);
  33360. h1.add(b);
  33361. h2.add(c);
  33362. h3.add(d);
  33363. h4.add(e);
  33364. h5.add(f);
  33365. h6.add(g);
  33366. h7.add(h);
  33367. }
  33368. var result;
  33369. if (!mode384) {
  33370. result = new Uint8Array(64);
  33371. h0.copyTo(result, 0);
  33372. h1.copyTo(result, 8);
  33373. h2.copyTo(result, 16);
  33374. h3.copyTo(result, 24);
  33375. h4.copyTo(result, 32);
  33376. h5.copyTo(result, 40);
  33377. h6.copyTo(result, 48);
  33378. h7.copyTo(result, 56);
  33379. } else {
  33380. result = new Uint8Array(48);
  33381. h0.copyTo(result, 0);
  33382. h1.copyTo(result, 8);
  33383. h2.copyTo(result, 16);
  33384. h3.copyTo(result, 24);
  33385. h4.copyTo(result, 32);
  33386. h5.copyTo(result, 40);
  33387. }
  33388. return result;
  33389. }
  33390. return hash;
  33391. }();
  33392. var calculateSHA384 = function calculateSHA384Closure() {
  33393. function hash(data, offset, length) {
  33394. return calculateSHA512(data, offset, length, true);
  33395. }
  33396. return hash;
  33397. }();
  33398. var NullCipher = function NullCipherClosure() {
  33399. function NullCipher() {
  33400. }
  33401. NullCipher.prototype = {
  33402. decryptBlock: function NullCipher_decryptBlock(data) {
  33403. return data;
  33404. }
  33405. };
  33406. return NullCipher;
  33407. }();
  33408. var AES128Cipher = function AES128CipherClosure() {
  33409. var rcon = new Uint8Array([
  33410. 0x8d,
  33411. 0x01,
  33412. 0x02,
  33413. 0x04,
  33414. 0x08,
  33415. 0x10,
  33416. 0x20,
  33417. 0x40,
  33418. 0x80,
  33419. 0x1b,
  33420. 0x36,
  33421. 0x6c,
  33422. 0xd8,
  33423. 0xab,
  33424. 0x4d,
  33425. 0x9a,
  33426. 0x2f,
  33427. 0x5e,
  33428. 0xbc,
  33429. 0x63,
  33430. 0xc6,
  33431. 0x97,
  33432. 0x35,
  33433. 0x6a,
  33434. 0xd4,
  33435. 0xb3,
  33436. 0x7d,
  33437. 0xfa,
  33438. 0xef,
  33439. 0xc5,
  33440. 0x91,
  33441. 0x39,
  33442. 0x72,
  33443. 0xe4,
  33444. 0xd3,
  33445. 0xbd,
  33446. 0x61,
  33447. 0xc2,
  33448. 0x9f,
  33449. 0x25,
  33450. 0x4a,
  33451. 0x94,
  33452. 0x33,
  33453. 0x66,
  33454. 0xcc,
  33455. 0x83,
  33456. 0x1d,
  33457. 0x3a,
  33458. 0x74,
  33459. 0xe8,
  33460. 0xcb,
  33461. 0x8d,
  33462. 0x01,
  33463. 0x02,
  33464. 0x04,
  33465. 0x08,
  33466. 0x10,
  33467. 0x20,
  33468. 0x40,
  33469. 0x80,
  33470. 0x1b,
  33471. 0x36,
  33472. 0x6c,
  33473. 0xd8,
  33474. 0xab,
  33475. 0x4d,
  33476. 0x9a,
  33477. 0x2f,
  33478. 0x5e,
  33479. 0xbc,
  33480. 0x63,
  33481. 0xc6,
  33482. 0x97,
  33483. 0x35,
  33484. 0x6a,
  33485. 0xd4,
  33486. 0xb3,
  33487. 0x7d,
  33488. 0xfa,
  33489. 0xef,
  33490. 0xc5,
  33491. 0x91,
  33492. 0x39,
  33493. 0x72,
  33494. 0xe4,
  33495. 0xd3,
  33496. 0xbd,
  33497. 0x61,
  33498. 0xc2,
  33499. 0x9f,
  33500. 0x25,
  33501. 0x4a,
  33502. 0x94,
  33503. 0x33,
  33504. 0x66,
  33505. 0xcc,
  33506. 0x83,
  33507. 0x1d,
  33508. 0x3a,
  33509. 0x74,
  33510. 0xe8,
  33511. 0xcb,
  33512. 0x8d,
  33513. 0x01,
  33514. 0x02,
  33515. 0x04,
  33516. 0x08,
  33517. 0x10,
  33518. 0x20,
  33519. 0x40,
  33520. 0x80,
  33521. 0x1b,
  33522. 0x36,
  33523. 0x6c,
  33524. 0xd8,
  33525. 0xab,
  33526. 0x4d,
  33527. 0x9a,
  33528. 0x2f,
  33529. 0x5e,
  33530. 0xbc,
  33531. 0x63,
  33532. 0xc6,
  33533. 0x97,
  33534. 0x35,
  33535. 0x6a,
  33536. 0xd4,
  33537. 0xb3,
  33538. 0x7d,
  33539. 0xfa,
  33540. 0xef,
  33541. 0xc5,
  33542. 0x91,
  33543. 0x39,
  33544. 0x72,
  33545. 0xe4,
  33546. 0xd3,
  33547. 0xbd,
  33548. 0x61,
  33549. 0xc2,
  33550. 0x9f,
  33551. 0x25,
  33552. 0x4a,
  33553. 0x94,
  33554. 0x33,
  33555. 0x66,
  33556. 0xcc,
  33557. 0x83,
  33558. 0x1d,
  33559. 0x3a,
  33560. 0x74,
  33561. 0xe8,
  33562. 0xcb,
  33563. 0x8d,
  33564. 0x01,
  33565. 0x02,
  33566. 0x04,
  33567. 0x08,
  33568. 0x10,
  33569. 0x20,
  33570. 0x40,
  33571. 0x80,
  33572. 0x1b,
  33573. 0x36,
  33574. 0x6c,
  33575. 0xd8,
  33576. 0xab,
  33577. 0x4d,
  33578. 0x9a,
  33579. 0x2f,
  33580. 0x5e,
  33581. 0xbc,
  33582. 0x63,
  33583. 0xc6,
  33584. 0x97,
  33585. 0x35,
  33586. 0x6a,
  33587. 0xd4,
  33588. 0xb3,
  33589. 0x7d,
  33590. 0xfa,
  33591. 0xef,
  33592. 0xc5,
  33593. 0x91,
  33594. 0x39,
  33595. 0x72,
  33596. 0xe4,
  33597. 0xd3,
  33598. 0xbd,
  33599. 0x61,
  33600. 0xc2,
  33601. 0x9f,
  33602. 0x25,
  33603. 0x4a,
  33604. 0x94,
  33605. 0x33,
  33606. 0x66,
  33607. 0xcc,
  33608. 0x83,
  33609. 0x1d,
  33610. 0x3a,
  33611. 0x74,
  33612. 0xe8,
  33613. 0xcb,
  33614. 0x8d,
  33615. 0x01,
  33616. 0x02,
  33617. 0x04,
  33618. 0x08,
  33619. 0x10,
  33620. 0x20,
  33621. 0x40,
  33622. 0x80,
  33623. 0x1b,
  33624. 0x36,
  33625. 0x6c,
  33626. 0xd8,
  33627. 0xab,
  33628. 0x4d,
  33629. 0x9a,
  33630. 0x2f,
  33631. 0x5e,
  33632. 0xbc,
  33633. 0x63,
  33634. 0xc6,
  33635. 0x97,
  33636. 0x35,
  33637. 0x6a,
  33638. 0xd4,
  33639. 0xb3,
  33640. 0x7d,
  33641. 0xfa,
  33642. 0xef,
  33643. 0xc5,
  33644. 0x91,
  33645. 0x39,
  33646. 0x72,
  33647. 0xe4,
  33648. 0xd3,
  33649. 0xbd,
  33650. 0x61,
  33651. 0xc2,
  33652. 0x9f,
  33653. 0x25,
  33654. 0x4a,
  33655. 0x94,
  33656. 0x33,
  33657. 0x66,
  33658. 0xcc,
  33659. 0x83,
  33660. 0x1d,
  33661. 0x3a,
  33662. 0x74,
  33663. 0xe8,
  33664. 0xcb,
  33665. 0x8d
  33666. ]);
  33667. var s = new Uint8Array([
  33668. 0x63,
  33669. 0x7c,
  33670. 0x77,
  33671. 0x7b,
  33672. 0xf2,
  33673. 0x6b,
  33674. 0x6f,
  33675. 0xc5,
  33676. 0x30,
  33677. 0x01,
  33678. 0x67,
  33679. 0x2b,
  33680. 0xfe,
  33681. 0xd7,
  33682. 0xab,
  33683. 0x76,
  33684. 0xca,
  33685. 0x82,
  33686. 0xc9,
  33687. 0x7d,
  33688. 0xfa,
  33689. 0x59,
  33690. 0x47,
  33691. 0xf0,
  33692. 0xad,
  33693. 0xd4,
  33694. 0xa2,
  33695. 0xaf,
  33696. 0x9c,
  33697. 0xa4,
  33698. 0x72,
  33699. 0xc0,
  33700. 0xb7,
  33701. 0xfd,
  33702. 0x93,
  33703. 0x26,
  33704. 0x36,
  33705. 0x3f,
  33706. 0xf7,
  33707. 0xcc,
  33708. 0x34,
  33709. 0xa5,
  33710. 0xe5,
  33711. 0xf1,
  33712. 0x71,
  33713. 0xd8,
  33714. 0x31,
  33715. 0x15,
  33716. 0x04,
  33717. 0xc7,
  33718. 0x23,
  33719. 0xc3,
  33720. 0x18,
  33721. 0x96,
  33722. 0x05,
  33723. 0x9a,
  33724. 0x07,
  33725. 0x12,
  33726. 0x80,
  33727. 0xe2,
  33728. 0xeb,
  33729. 0x27,
  33730. 0xb2,
  33731. 0x75,
  33732. 0x09,
  33733. 0x83,
  33734. 0x2c,
  33735. 0x1a,
  33736. 0x1b,
  33737. 0x6e,
  33738. 0x5a,
  33739. 0xa0,
  33740. 0x52,
  33741. 0x3b,
  33742. 0xd6,
  33743. 0xb3,
  33744. 0x29,
  33745. 0xe3,
  33746. 0x2f,
  33747. 0x84,
  33748. 0x53,
  33749. 0xd1,
  33750. 0x00,
  33751. 0xed,
  33752. 0x20,
  33753. 0xfc,
  33754. 0xb1,
  33755. 0x5b,
  33756. 0x6a,
  33757. 0xcb,
  33758. 0xbe,
  33759. 0x39,
  33760. 0x4a,
  33761. 0x4c,
  33762. 0x58,
  33763. 0xcf,
  33764. 0xd0,
  33765. 0xef,
  33766. 0xaa,
  33767. 0xfb,
  33768. 0x43,
  33769. 0x4d,
  33770. 0x33,
  33771. 0x85,
  33772. 0x45,
  33773. 0xf9,
  33774. 0x02,
  33775. 0x7f,
  33776. 0x50,
  33777. 0x3c,
  33778. 0x9f,
  33779. 0xa8,
  33780. 0x51,
  33781. 0xa3,
  33782. 0x40,
  33783. 0x8f,
  33784. 0x92,
  33785. 0x9d,
  33786. 0x38,
  33787. 0xf5,
  33788. 0xbc,
  33789. 0xb6,
  33790. 0xda,
  33791. 0x21,
  33792. 0x10,
  33793. 0xff,
  33794. 0xf3,
  33795. 0xd2,
  33796. 0xcd,
  33797. 0x0c,
  33798. 0x13,
  33799. 0xec,
  33800. 0x5f,
  33801. 0x97,
  33802. 0x44,
  33803. 0x17,
  33804. 0xc4,
  33805. 0xa7,
  33806. 0x7e,
  33807. 0x3d,
  33808. 0x64,
  33809. 0x5d,
  33810. 0x19,
  33811. 0x73,
  33812. 0x60,
  33813. 0x81,
  33814. 0x4f,
  33815. 0xdc,
  33816. 0x22,
  33817. 0x2a,
  33818. 0x90,
  33819. 0x88,
  33820. 0x46,
  33821. 0xee,
  33822. 0xb8,
  33823. 0x14,
  33824. 0xde,
  33825. 0x5e,
  33826. 0x0b,
  33827. 0xdb,
  33828. 0xe0,
  33829. 0x32,
  33830. 0x3a,
  33831. 0x0a,
  33832. 0x49,
  33833. 0x06,
  33834. 0x24,
  33835. 0x5c,
  33836. 0xc2,
  33837. 0xd3,
  33838. 0xac,
  33839. 0x62,
  33840. 0x91,
  33841. 0x95,
  33842. 0xe4,
  33843. 0x79,
  33844. 0xe7,
  33845. 0xc8,
  33846. 0x37,
  33847. 0x6d,
  33848. 0x8d,
  33849. 0xd5,
  33850. 0x4e,
  33851. 0xa9,
  33852. 0x6c,
  33853. 0x56,
  33854. 0xf4,
  33855. 0xea,
  33856. 0x65,
  33857. 0x7a,
  33858. 0xae,
  33859. 0x08,
  33860. 0xba,
  33861. 0x78,
  33862. 0x25,
  33863. 0x2e,
  33864. 0x1c,
  33865. 0xa6,
  33866. 0xb4,
  33867. 0xc6,
  33868. 0xe8,
  33869. 0xdd,
  33870. 0x74,
  33871. 0x1f,
  33872. 0x4b,
  33873. 0xbd,
  33874. 0x8b,
  33875. 0x8a,
  33876. 0x70,
  33877. 0x3e,
  33878. 0xb5,
  33879. 0x66,
  33880. 0x48,
  33881. 0x03,
  33882. 0xf6,
  33883. 0x0e,
  33884. 0x61,
  33885. 0x35,
  33886. 0x57,
  33887. 0xb9,
  33888. 0x86,
  33889. 0xc1,
  33890. 0x1d,
  33891. 0x9e,
  33892. 0xe1,
  33893. 0xf8,
  33894. 0x98,
  33895. 0x11,
  33896. 0x69,
  33897. 0xd9,
  33898. 0x8e,
  33899. 0x94,
  33900. 0x9b,
  33901. 0x1e,
  33902. 0x87,
  33903. 0xe9,
  33904. 0xce,
  33905. 0x55,
  33906. 0x28,
  33907. 0xdf,
  33908. 0x8c,
  33909. 0xa1,
  33910. 0x89,
  33911. 0x0d,
  33912. 0xbf,
  33913. 0xe6,
  33914. 0x42,
  33915. 0x68,
  33916. 0x41,
  33917. 0x99,
  33918. 0x2d,
  33919. 0x0f,
  33920. 0xb0,
  33921. 0x54,
  33922. 0xbb,
  33923. 0x16
  33924. ]);
  33925. var inv_s = new Uint8Array([
  33926. 0x52,
  33927. 0x09,
  33928. 0x6a,
  33929. 0xd5,
  33930. 0x30,
  33931. 0x36,
  33932. 0xa5,
  33933. 0x38,
  33934. 0xbf,
  33935. 0x40,
  33936. 0xa3,
  33937. 0x9e,
  33938. 0x81,
  33939. 0xf3,
  33940. 0xd7,
  33941. 0xfb,
  33942. 0x7c,
  33943. 0xe3,
  33944. 0x39,
  33945. 0x82,
  33946. 0x9b,
  33947. 0x2f,
  33948. 0xff,
  33949. 0x87,
  33950. 0x34,
  33951. 0x8e,
  33952. 0x43,
  33953. 0x44,
  33954. 0xc4,
  33955. 0xde,
  33956. 0xe9,
  33957. 0xcb,
  33958. 0x54,
  33959. 0x7b,
  33960. 0x94,
  33961. 0x32,
  33962. 0xa6,
  33963. 0xc2,
  33964. 0x23,
  33965. 0x3d,
  33966. 0xee,
  33967. 0x4c,
  33968. 0x95,
  33969. 0x0b,
  33970. 0x42,
  33971. 0xfa,
  33972. 0xc3,
  33973. 0x4e,
  33974. 0x08,
  33975. 0x2e,
  33976. 0xa1,
  33977. 0x66,
  33978. 0x28,
  33979. 0xd9,
  33980. 0x24,
  33981. 0xb2,
  33982. 0x76,
  33983. 0x5b,
  33984. 0xa2,
  33985. 0x49,
  33986. 0x6d,
  33987. 0x8b,
  33988. 0xd1,
  33989. 0x25,
  33990. 0x72,
  33991. 0xf8,
  33992. 0xf6,
  33993. 0x64,
  33994. 0x86,
  33995. 0x68,
  33996. 0x98,
  33997. 0x16,
  33998. 0xd4,
  33999. 0xa4,
  34000. 0x5c,
  34001. 0xcc,
  34002. 0x5d,
  34003. 0x65,
  34004. 0xb6,
  34005. 0x92,
  34006. 0x6c,
  34007. 0x70,
  34008. 0x48,
  34009. 0x50,
  34010. 0xfd,
  34011. 0xed,
  34012. 0xb9,
  34013. 0xda,
  34014. 0x5e,
  34015. 0x15,
  34016. 0x46,
  34017. 0x57,
  34018. 0xa7,
  34019. 0x8d,
  34020. 0x9d,
  34021. 0x84,
  34022. 0x90,
  34023. 0xd8,
  34024. 0xab,
  34025. 0x00,
  34026. 0x8c,
  34027. 0xbc,
  34028. 0xd3,
  34029. 0x0a,
  34030. 0xf7,
  34031. 0xe4,
  34032. 0x58,
  34033. 0x05,
  34034. 0xb8,
  34035. 0xb3,
  34036. 0x45,
  34037. 0x06,
  34038. 0xd0,
  34039. 0x2c,
  34040. 0x1e,
  34041. 0x8f,
  34042. 0xca,
  34043. 0x3f,
  34044. 0x0f,
  34045. 0x02,
  34046. 0xc1,
  34047. 0xaf,
  34048. 0xbd,
  34049. 0x03,
  34050. 0x01,
  34051. 0x13,
  34052. 0x8a,
  34053. 0x6b,
  34054. 0x3a,
  34055. 0x91,
  34056. 0x11,
  34057. 0x41,
  34058. 0x4f,
  34059. 0x67,
  34060. 0xdc,
  34061. 0xea,
  34062. 0x97,
  34063. 0xf2,
  34064. 0xcf,
  34065. 0xce,
  34066. 0xf0,
  34067. 0xb4,
  34068. 0xe6,
  34069. 0x73,
  34070. 0x96,
  34071. 0xac,
  34072. 0x74,
  34073. 0x22,
  34074. 0xe7,
  34075. 0xad,
  34076. 0x35,
  34077. 0x85,
  34078. 0xe2,
  34079. 0xf9,
  34080. 0x37,
  34081. 0xe8,
  34082. 0x1c,
  34083. 0x75,
  34084. 0xdf,
  34085. 0x6e,
  34086. 0x47,
  34087. 0xf1,
  34088. 0x1a,
  34089. 0x71,
  34090. 0x1d,
  34091. 0x29,
  34092. 0xc5,
  34093. 0x89,
  34094. 0x6f,
  34095. 0xb7,
  34096. 0x62,
  34097. 0x0e,
  34098. 0xaa,
  34099. 0x18,
  34100. 0xbe,
  34101. 0x1b,
  34102. 0xfc,
  34103. 0x56,
  34104. 0x3e,
  34105. 0x4b,
  34106. 0xc6,
  34107. 0xd2,
  34108. 0x79,
  34109. 0x20,
  34110. 0x9a,
  34111. 0xdb,
  34112. 0xc0,
  34113. 0xfe,
  34114. 0x78,
  34115. 0xcd,
  34116. 0x5a,
  34117. 0xf4,
  34118. 0x1f,
  34119. 0xdd,
  34120. 0xa8,
  34121. 0x33,
  34122. 0x88,
  34123. 0x07,
  34124. 0xc7,
  34125. 0x31,
  34126. 0xb1,
  34127. 0x12,
  34128. 0x10,
  34129. 0x59,
  34130. 0x27,
  34131. 0x80,
  34132. 0xec,
  34133. 0x5f,
  34134. 0x60,
  34135. 0x51,
  34136. 0x7f,
  34137. 0xa9,
  34138. 0x19,
  34139. 0xb5,
  34140. 0x4a,
  34141. 0x0d,
  34142. 0x2d,
  34143. 0xe5,
  34144. 0x7a,
  34145. 0x9f,
  34146. 0x93,
  34147. 0xc9,
  34148. 0x9c,
  34149. 0xef,
  34150. 0xa0,
  34151. 0xe0,
  34152. 0x3b,
  34153. 0x4d,
  34154. 0xae,
  34155. 0x2a,
  34156. 0xf5,
  34157. 0xb0,
  34158. 0xc8,
  34159. 0xeb,
  34160. 0xbb,
  34161. 0x3c,
  34162. 0x83,
  34163. 0x53,
  34164. 0x99,
  34165. 0x61,
  34166. 0x17,
  34167. 0x2b,
  34168. 0x04,
  34169. 0x7e,
  34170. 0xba,
  34171. 0x77,
  34172. 0xd6,
  34173. 0x26,
  34174. 0xe1,
  34175. 0x69,
  34176. 0x14,
  34177. 0x63,
  34178. 0x55,
  34179. 0x21,
  34180. 0x0c,
  34181. 0x7d
  34182. ]);
  34183. var mixCol = new Uint8Array(256);
  34184. for (var i = 0; i < 256; i++) {
  34185. if (i < 128) {
  34186. mixCol[i] = i << 1;
  34187. } else {
  34188. mixCol[i] = i << 1 ^ 0x1b;
  34189. }
  34190. }
  34191. var mix = new Uint32Array([
  34192. 0x00000000,
  34193. 0x0e090d0b,
  34194. 0x1c121a16,
  34195. 0x121b171d,
  34196. 0x3824342c,
  34197. 0x362d3927,
  34198. 0x24362e3a,
  34199. 0x2a3f2331,
  34200. 0x70486858,
  34201. 0x7e416553,
  34202. 0x6c5a724e,
  34203. 0x62537f45,
  34204. 0x486c5c74,
  34205. 0x4665517f,
  34206. 0x547e4662,
  34207. 0x5a774b69,
  34208. 0xe090d0b0,
  34209. 0xee99ddbb,
  34210. 0xfc82caa6,
  34211. 0xf28bc7ad,
  34212. 0xd8b4e49c,
  34213. 0xd6bde997,
  34214. 0xc4a6fe8a,
  34215. 0xcaaff381,
  34216. 0x90d8b8e8,
  34217. 0x9ed1b5e3,
  34218. 0x8ccaa2fe,
  34219. 0x82c3aff5,
  34220. 0xa8fc8cc4,
  34221. 0xa6f581cf,
  34222. 0xb4ee96d2,
  34223. 0xbae79bd9,
  34224. 0xdb3bbb7b,
  34225. 0xd532b670,
  34226. 0xc729a16d,
  34227. 0xc920ac66,
  34228. 0xe31f8f57,
  34229. 0xed16825c,
  34230. 0xff0d9541,
  34231. 0xf104984a,
  34232. 0xab73d323,
  34233. 0xa57ade28,
  34234. 0xb761c935,
  34235. 0xb968c43e,
  34236. 0x9357e70f,
  34237. 0x9d5eea04,
  34238. 0x8f45fd19,
  34239. 0x814cf012,
  34240. 0x3bab6bcb,
  34241. 0x35a266c0,
  34242. 0x27b971dd,
  34243. 0x29b07cd6,
  34244. 0x038f5fe7,
  34245. 0x0d8652ec,
  34246. 0x1f9d45f1,
  34247. 0x119448fa,
  34248. 0x4be30393,
  34249. 0x45ea0e98,
  34250. 0x57f11985,
  34251. 0x59f8148e,
  34252. 0x73c737bf,
  34253. 0x7dce3ab4,
  34254. 0x6fd52da9,
  34255. 0x61dc20a2,
  34256. 0xad766df6,
  34257. 0xa37f60fd,
  34258. 0xb16477e0,
  34259. 0xbf6d7aeb,
  34260. 0x955259da,
  34261. 0x9b5b54d1,
  34262. 0x894043cc,
  34263. 0x87494ec7,
  34264. 0xdd3e05ae,
  34265. 0xd33708a5,
  34266. 0xc12c1fb8,
  34267. 0xcf2512b3,
  34268. 0xe51a3182,
  34269. 0xeb133c89,
  34270. 0xf9082b94,
  34271. 0xf701269f,
  34272. 0x4de6bd46,
  34273. 0x43efb04d,
  34274. 0x51f4a750,
  34275. 0x5ffdaa5b,
  34276. 0x75c2896a,
  34277. 0x7bcb8461,
  34278. 0x69d0937c,
  34279. 0x67d99e77,
  34280. 0x3daed51e,
  34281. 0x33a7d815,
  34282. 0x21bccf08,
  34283. 0x2fb5c203,
  34284. 0x058ae132,
  34285. 0x0b83ec39,
  34286. 0x1998fb24,
  34287. 0x1791f62f,
  34288. 0x764dd68d,
  34289. 0x7844db86,
  34290. 0x6a5fcc9b,
  34291. 0x6456c190,
  34292. 0x4e69e2a1,
  34293. 0x4060efaa,
  34294. 0x527bf8b7,
  34295. 0x5c72f5bc,
  34296. 0x0605bed5,
  34297. 0x080cb3de,
  34298. 0x1a17a4c3,
  34299. 0x141ea9c8,
  34300. 0x3e218af9,
  34301. 0x302887f2,
  34302. 0x223390ef,
  34303. 0x2c3a9de4,
  34304. 0x96dd063d,
  34305. 0x98d40b36,
  34306. 0x8acf1c2b,
  34307. 0x84c61120,
  34308. 0xaef93211,
  34309. 0xa0f03f1a,
  34310. 0xb2eb2807,
  34311. 0xbce2250c,
  34312. 0xe6956e65,
  34313. 0xe89c636e,
  34314. 0xfa877473,
  34315. 0xf48e7978,
  34316. 0xdeb15a49,
  34317. 0xd0b85742,
  34318. 0xc2a3405f,
  34319. 0xccaa4d54,
  34320. 0x41ecdaf7,
  34321. 0x4fe5d7fc,
  34322. 0x5dfec0e1,
  34323. 0x53f7cdea,
  34324. 0x79c8eedb,
  34325. 0x77c1e3d0,
  34326. 0x65daf4cd,
  34327. 0x6bd3f9c6,
  34328. 0x31a4b2af,
  34329. 0x3fadbfa4,
  34330. 0x2db6a8b9,
  34331. 0x23bfa5b2,
  34332. 0x09808683,
  34333. 0x07898b88,
  34334. 0x15929c95,
  34335. 0x1b9b919e,
  34336. 0xa17c0a47,
  34337. 0xaf75074c,
  34338. 0xbd6e1051,
  34339. 0xb3671d5a,
  34340. 0x99583e6b,
  34341. 0x97513360,
  34342. 0x854a247d,
  34343. 0x8b432976,
  34344. 0xd134621f,
  34345. 0xdf3d6f14,
  34346. 0xcd267809,
  34347. 0xc32f7502,
  34348. 0xe9105633,
  34349. 0xe7195b38,
  34350. 0xf5024c25,
  34351. 0xfb0b412e,
  34352. 0x9ad7618c,
  34353. 0x94de6c87,
  34354. 0x86c57b9a,
  34355. 0x88cc7691,
  34356. 0xa2f355a0,
  34357. 0xacfa58ab,
  34358. 0xbee14fb6,
  34359. 0xb0e842bd,
  34360. 0xea9f09d4,
  34361. 0xe49604df,
  34362. 0xf68d13c2,
  34363. 0xf8841ec9,
  34364. 0xd2bb3df8,
  34365. 0xdcb230f3,
  34366. 0xcea927ee,
  34367. 0xc0a02ae5,
  34368. 0x7a47b13c,
  34369. 0x744ebc37,
  34370. 0x6655ab2a,
  34371. 0x685ca621,
  34372. 0x42638510,
  34373. 0x4c6a881b,
  34374. 0x5e719f06,
  34375. 0x5078920d,
  34376. 0x0a0fd964,
  34377. 0x0406d46f,
  34378. 0x161dc372,
  34379. 0x1814ce79,
  34380. 0x322bed48,
  34381. 0x3c22e043,
  34382. 0x2e39f75e,
  34383. 0x2030fa55,
  34384. 0xec9ab701,
  34385. 0xe293ba0a,
  34386. 0xf088ad17,
  34387. 0xfe81a01c,
  34388. 0xd4be832d,
  34389. 0xdab78e26,
  34390. 0xc8ac993b,
  34391. 0xc6a59430,
  34392. 0x9cd2df59,
  34393. 0x92dbd252,
  34394. 0x80c0c54f,
  34395. 0x8ec9c844,
  34396. 0xa4f6eb75,
  34397. 0xaaffe67e,
  34398. 0xb8e4f163,
  34399. 0xb6edfc68,
  34400. 0x0c0a67b1,
  34401. 0x02036aba,
  34402. 0x10187da7,
  34403. 0x1e1170ac,
  34404. 0x342e539d,
  34405. 0x3a275e96,
  34406. 0x283c498b,
  34407. 0x26354480,
  34408. 0x7c420fe9,
  34409. 0x724b02e2,
  34410. 0x605015ff,
  34411. 0x6e5918f4,
  34412. 0x44663bc5,
  34413. 0x4a6f36ce,
  34414. 0x587421d3,
  34415. 0x567d2cd8,
  34416. 0x37a10c7a,
  34417. 0x39a80171,
  34418. 0x2bb3166c,
  34419. 0x25ba1b67,
  34420. 0x0f853856,
  34421. 0x018c355d,
  34422. 0x13972240,
  34423. 0x1d9e2f4b,
  34424. 0x47e96422,
  34425. 0x49e06929,
  34426. 0x5bfb7e34,
  34427. 0x55f2733f,
  34428. 0x7fcd500e,
  34429. 0x71c45d05,
  34430. 0x63df4a18,
  34431. 0x6dd64713,
  34432. 0xd731dcca,
  34433. 0xd938d1c1,
  34434. 0xcb23c6dc,
  34435. 0xc52acbd7,
  34436. 0xef15e8e6,
  34437. 0xe11ce5ed,
  34438. 0xf307f2f0,
  34439. 0xfd0efffb,
  34440. 0xa779b492,
  34441. 0xa970b999,
  34442. 0xbb6bae84,
  34443. 0xb562a38f,
  34444. 0x9f5d80be,
  34445. 0x91548db5,
  34446. 0x834f9aa8,
  34447. 0x8d4697a3
  34448. ]);
  34449. function expandKey128(cipherKey) {
  34450. var b = 176, result = new Uint8Array(b);
  34451. result.set(cipherKey);
  34452. for (var j = 16, i = 1; j < b; ++i) {
  34453. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34454. t1 = s[t1];
  34455. t2 = s[t2];
  34456. t3 = s[t3];
  34457. t4 = s[t4];
  34458. t1 = t1 ^ rcon[i];
  34459. for (var n = 0; n < 4; ++n) {
  34460. result[j] = t1 ^= result[j - 16];
  34461. j++;
  34462. result[j] = t2 ^= result[j - 16];
  34463. j++;
  34464. result[j] = t3 ^= result[j - 16];
  34465. j++;
  34466. result[j] = t4 ^= result[j - 16];
  34467. j++;
  34468. }
  34469. }
  34470. return result;
  34471. }
  34472. function decrypt128(input, key) {
  34473. var state = new Uint8Array(16);
  34474. state.set(input);
  34475. var i, j, k;
  34476. var t, u, v;
  34477. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34478. state[j] ^= key[k];
  34479. }
  34480. for (i = 9; i >= 1; --i) {
  34481. t = state[13];
  34482. state[13] = state[9];
  34483. state[9] = state[5];
  34484. state[5] = state[1];
  34485. state[1] = t;
  34486. t = state[14];
  34487. u = state[10];
  34488. state[14] = state[6];
  34489. state[10] = state[2];
  34490. state[6] = t;
  34491. state[2] = u;
  34492. t = state[15];
  34493. u = state[11];
  34494. v = state[7];
  34495. state[15] = state[3];
  34496. state[11] = t;
  34497. state[7] = u;
  34498. state[3] = v;
  34499. for (j = 0; j < 16; ++j) {
  34500. state[j] = inv_s[state[j]];
  34501. }
  34502. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34503. state[j] ^= key[k];
  34504. }
  34505. for (j = 0; j < 16; j += 4) {
  34506. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34507. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34508. state[j] = t >>> 24 & 0xFF;
  34509. state[j + 1] = t >> 16 & 0xFF;
  34510. state[j + 2] = t >> 8 & 0xFF;
  34511. state[j + 3] = t & 0xFF;
  34512. }
  34513. }
  34514. t = state[13];
  34515. state[13] = state[9];
  34516. state[9] = state[5];
  34517. state[5] = state[1];
  34518. state[1] = t;
  34519. t = state[14];
  34520. u = state[10];
  34521. state[14] = state[6];
  34522. state[10] = state[2];
  34523. state[6] = t;
  34524. state[2] = u;
  34525. t = state[15];
  34526. u = state[11];
  34527. v = state[7];
  34528. state[15] = state[3];
  34529. state[11] = t;
  34530. state[7] = u;
  34531. state[3] = v;
  34532. for (j = 0; j < 16; ++j) {
  34533. state[j] = inv_s[state[j]];
  34534. state[j] ^= key[j];
  34535. }
  34536. return state;
  34537. }
  34538. function encrypt128(input, key) {
  34539. var t, u, v, k;
  34540. var state = new Uint8Array(16);
  34541. state.set(input);
  34542. for (j = 0; j < 16; ++j) {
  34543. state[j] ^= key[j];
  34544. }
  34545. for (i = 1; i < 10; i++) {
  34546. for (j = 0; j < 16; ++j) {
  34547. state[j] = s[state[j]];
  34548. }
  34549. v = state[1];
  34550. state[1] = state[5];
  34551. state[5] = state[9];
  34552. state[9] = state[13];
  34553. state[13] = v;
  34554. v = state[2];
  34555. u = state[6];
  34556. state[2] = state[10];
  34557. state[6] = state[14];
  34558. state[10] = v;
  34559. state[14] = u;
  34560. v = state[3];
  34561. u = state[7];
  34562. t = state[11];
  34563. state[3] = state[15];
  34564. state[7] = v;
  34565. state[11] = u;
  34566. state[15] = t;
  34567. for (var j = 0; j < 16; j += 4) {
  34568. var s0 = state[j + 0], s1 = state[j + 1];
  34569. var s2 = state[j + 2], s3 = state[j + 3];
  34570. t = s0 ^ s1 ^ s2 ^ s3;
  34571. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34572. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34573. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34574. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34575. }
  34576. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34577. state[j] ^= key[k];
  34578. }
  34579. }
  34580. for (j = 0; j < 16; ++j) {
  34581. state[j] = s[state[j]];
  34582. }
  34583. v = state[1];
  34584. state[1] = state[5];
  34585. state[5] = state[9];
  34586. state[9] = state[13];
  34587. state[13] = v;
  34588. v = state[2];
  34589. u = state[6];
  34590. state[2] = state[10];
  34591. state[6] = state[14];
  34592. state[10] = v;
  34593. state[14] = u;
  34594. v = state[3];
  34595. u = state[7];
  34596. t = state[11];
  34597. state[3] = state[15];
  34598. state[7] = v;
  34599. state[11] = u;
  34600. state[15] = t;
  34601. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34602. state[j] ^= key[k];
  34603. }
  34604. return state;
  34605. }
  34606. function AES128Cipher(key) {
  34607. this.key = expandKey128(key);
  34608. this.buffer = new Uint8Array(16);
  34609. this.bufferPosition = 0;
  34610. }
  34611. function decryptBlock2(data, finalize) {
  34612. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34613. for (i = 0; i < sourceLength; ++i) {
  34614. buffer[bufferLength] = data[i];
  34615. ++bufferLength;
  34616. if (bufferLength < 16) {
  34617. continue;
  34618. }
  34619. var plain = decrypt128(buffer, this.key);
  34620. for (j = 0; j < 16; ++j) {
  34621. plain[j] ^= iv[j];
  34622. }
  34623. iv = buffer;
  34624. result.push(plain);
  34625. buffer = new Uint8Array(16);
  34626. bufferLength = 0;
  34627. }
  34628. this.buffer = buffer;
  34629. this.bufferLength = bufferLength;
  34630. this.iv = iv;
  34631. if (result.length === 0) {
  34632. return new Uint8Array([]);
  34633. }
  34634. var outputLength = 16 * result.length;
  34635. if (finalize) {
  34636. var lastBlock = result[result.length - 1];
  34637. var psLen = lastBlock[15];
  34638. if (psLen <= 16) {
  34639. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34640. if (lastBlock[i] !== psLen) {
  34641. psLen = 0;
  34642. break;
  34643. }
  34644. }
  34645. outputLength -= psLen;
  34646. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34647. }
  34648. }
  34649. var output = new Uint8Array(outputLength);
  34650. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34651. output.set(result[i], j);
  34652. }
  34653. return output;
  34654. }
  34655. AES128Cipher.prototype = {
  34656. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34657. var i, sourceLength = data.length;
  34658. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34659. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34660. buffer[bufferLength] = data[i];
  34661. }
  34662. if (bufferLength < 16) {
  34663. this.bufferLength = bufferLength;
  34664. return new Uint8Array([]);
  34665. }
  34666. this.iv = buffer;
  34667. this.buffer = new Uint8Array(16);
  34668. this.bufferLength = 0;
  34669. this.decryptBlock = decryptBlock2;
  34670. return this.decryptBlock(data.subarray(16), finalize);
  34671. },
  34672. encrypt: function AES128Cipher_encrypt(data, iv) {
  34673. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34674. if (!iv) {
  34675. iv = new Uint8Array(16);
  34676. }
  34677. for (i = 0; i < sourceLength; ++i) {
  34678. buffer[bufferLength] = data[i];
  34679. ++bufferLength;
  34680. if (bufferLength < 16) {
  34681. continue;
  34682. }
  34683. for (j = 0; j < 16; ++j) {
  34684. buffer[j] ^= iv[j];
  34685. }
  34686. var cipher = encrypt128(buffer, this.key);
  34687. iv = cipher;
  34688. result.push(cipher);
  34689. buffer = new Uint8Array(16);
  34690. bufferLength = 0;
  34691. }
  34692. this.buffer = buffer;
  34693. this.bufferLength = bufferLength;
  34694. this.iv = iv;
  34695. if (result.length === 0) {
  34696. return new Uint8Array([]);
  34697. }
  34698. var outputLength = 16 * result.length;
  34699. var output = new Uint8Array(outputLength);
  34700. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34701. output.set(result[i], j);
  34702. }
  34703. return output;
  34704. }
  34705. };
  34706. return AES128Cipher;
  34707. }();
  34708. var AES256Cipher = function AES256CipherClosure() {
  34709. var rcon = new Uint8Array([
  34710. 0x8d,
  34711. 0x01,
  34712. 0x02,
  34713. 0x04,
  34714. 0x08,
  34715. 0x10,
  34716. 0x20,
  34717. 0x40,
  34718. 0x80,
  34719. 0x1b,
  34720. 0x36,
  34721. 0x6c,
  34722. 0xd8,
  34723. 0xab,
  34724. 0x4d,
  34725. 0x9a,
  34726. 0x2f,
  34727. 0x5e,
  34728. 0xbc,
  34729. 0x63,
  34730. 0xc6,
  34731. 0x97,
  34732. 0x35,
  34733. 0x6a,
  34734. 0xd4,
  34735. 0xb3,
  34736. 0x7d,
  34737. 0xfa,
  34738. 0xef,
  34739. 0xc5,
  34740. 0x91,
  34741. 0x39,
  34742. 0x72,
  34743. 0xe4,
  34744. 0xd3,
  34745. 0xbd,
  34746. 0x61,
  34747. 0xc2,
  34748. 0x9f,
  34749. 0x25,
  34750. 0x4a,
  34751. 0x94,
  34752. 0x33,
  34753. 0x66,
  34754. 0xcc,
  34755. 0x83,
  34756. 0x1d,
  34757. 0x3a,
  34758. 0x74,
  34759. 0xe8,
  34760. 0xcb,
  34761. 0x8d,
  34762. 0x01,
  34763. 0x02,
  34764. 0x04,
  34765. 0x08,
  34766. 0x10,
  34767. 0x20,
  34768. 0x40,
  34769. 0x80,
  34770. 0x1b,
  34771. 0x36,
  34772. 0x6c,
  34773. 0xd8,
  34774. 0xab,
  34775. 0x4d,
  34776. 0x9a,
  34777. 0x2f,
  34778. 0x5e,
  34779. 0xbc,
  34780. 0x63,
  34781. 0xc6,
  34782. 0x97,
  34783. 0x35,
  34784. 0x6a,
  34785. 0xd4,
  34786. 0xb3,
  34787. 0x7d,
  34788. 0xfa,
  34789. 0xef,
  34790. 0xc5,
  34791. 0x91,
  34792. 0x39,
  34793. 0x72,
  34794. 0xe4,
  34795. 0xd3,
  34796. 0xbd,
  34797. 0x61,
  34798. 0xc2,
  34799. 0x9f,
  34800. 0x25,
  34801. 0x4a,
  34802. 0x94,
  34803. 0x33,
  34804. 0x66,
  34805. 0xcc,
  34806. 0x83,
  34807. 0x1d,
  34808. 0x3a,
  34809. 0x74,
  34810. 0xe8,
  34811. 0xcb,
  34812. 0x8d,
  34813. 0x01,
  34814. 0x02,
  34815. 0x04,
  34816. 0x08,
  34817. 0x10,
  34818. 0x20,
  34819. 0x40,
  34820. 0x80,
  34821. 0x1b,
  34822. 0x36,
  34823. 0x6c,
  34824. 0xd8,
  34825. 0xab,
  34826. 0x4d,
  34827. 0x9a,
  34828. 0x2f,
  34829. 0x5e,
  34830. 0xbc,
  34831. 0x63,
  34832. 0xc6,
  34833. 0x97,
  34834. 0x35,
  34835. 0x6a,
  34836. 0xd4,
  34837. 0xb3,
  34838. 0x7d,
  34839. 0xfa,
  34840. 0xef,
  34841. 0xc5,
  34842. 0x91,
  34843. 0x39,
  34844. 0x72,
  34845. 0xe4,
  34846. 0xd3,
  34847. 0xbd,
  34848. 0x61,
  34849. 0xc2,
  34850. 0x9f,
  34851. 0x25,
  34852. 0x4a,
  34853. 0x94,
  34854. 0x33,
  34855. 0x66,
  34856. 0xcc,
  34857. 0x83,
  34858. 0x1d,
  34859. 0x3a,
  34860. 0x74,
  34861. 0xe8,
  34862. 0xcb,
  34863. 0x8d,
  34864. 0x01,
  34865. 0x02,
  34866. 0x04,
  34867. 0x08,
  34868. 0x10,
  34869. 0x20,
  34870. 0x40,
  34871. 0x80,
  34872. 0x1b,
  34873. 0x36,
  34874. 0x6c,
  34875. 0xd8,
  34876. 0xab,
  34877. 0x4d,
  34878. 0x9a,
  34879. 0x2f,
  34880. 0x5e,
  34881. 0xbc,
  34882. 0x63,
  34883. 0xc6,
  34884. 0x97,
  34885. 0x35,
  34886. 0x6a,
  34887. 0xd4,
  34888. 0xb3,
  34889. 0x7d,
  34890. 0xfa,
  34891. 0xef,
  34892. 0xc5,
  34893. 0x91,
  34894. 0x39,
  34895. 0x72,
  34896. 0xe4,
  34897. 0xd3,
  34898. 0xbd,
  34899. 0x61,
  34900. 0xc2,
  34901. 0x9f,
  34902. 0x25,
  34903. 0x4a,
  34904. 0x94,
  34905. 0x33,
  34906. 0x66,
  34907. 0xcc,
  34908. 0x83,
  34909. 0x1d,
  34910. 0x3a,
  34911. 0x74,
  34912. 0xe8,
  34913. 0xcb,
  34914. 0x8d,
  34915. 0x01,
  34916. 0x02,
  34917. 0x04,
  34918. 0x08,
  34919. 0x10,
  34920. 0x20,
  34921. 0x40,
  34922. 0x80,
  34923. 0x1b,
  34924. 0x36,
  34925. 0x6c,
  34926. 0xd8,
  34927. 0xab,
  34928. 0x4d,
  34929. 0x9a,
  34930. 0x2f,
  34931. 0x5e,
  34932. 0xbc,
  34933. 0x63,
  34934. 0xc6,
  34935. 0x97,
  34936. 0x35,
  34937. 0x6a,
  34938. 0xd4,
  34939. 0xb3,
  34940. 0x7d,
  34941. 0xfa,
  34942. 0xef,
  34943. 0xc5,
  34944. 0x91,
  34945. 0x39,
  34946. 0x72,
  34947. 0xe4,
  34948. 0xd3,
  34949. 0xbd,
  34950. 0x61,
  34951. 0xc2,
  34952. 0x9f,
  34953. 0x25,
  34954. 0x4a,
  34955. 0x94,
  34956. 0x33,
  34957. 0x66,
  34958. 0xcc,
  34959. 0x83,
  34960. 0x1d,
  34961. 0x3a,
  34962. 0x74,
  34963. 0xe8,
  34964. 0xcb,
  34965. 0x8d
  34966. ]);
  34967. var s = new Uint8Array([
  34968. 0x63,
  34969. 0x7c,
  34970. 0x77,
  34971. 0x7b,
  34972. 0xf2,
  34973. 0x6b,
  34974. 0x6f,
  34975. 0xc5,
  34976. 0x30,
  34977. 0x01,
  34978. 0x67,
  34979. 0x2b,
  34980. 0xfe,
  34981. 0xd7,
  34982. 0xab,
  34983. 0x76,
  34984. 0xca,
  34985. 0x82,
  34986. 0xc9,
  34987. 0x7d,
  34988. 0xfa,
  34989. 0x59,
  34990. 0x47,
  34991. 0xf0,
  34992. 0xad,
  34993. 0xd4,
  34994. 0xa2,
  34995. 0xaf,
  34996. 0x9c,
  34997. 0xa4,
  34998. 0x72,
  34999. 0xc0,
  35000. 0xb7,
  35001. 0xfd,
  35002. 0x93,
  35003. 0x26,
  35004. 0x36,
  35005. 0x3f,
  35006. 0xf7,
  35007. 0xcc,
  35008. 0x34,
  35009. 0xa5,
  35010. 0xe5,
  35011. 0xf1,
  35012. 0x71,
  35013. 0xd8,
  35014. 0x31,
  35015. 0x15,
  35016. 0x04,
  35017. 0xc7,
  35018. 0x23,
  35019. 0xc3,
  35020. 0x18,
  35021. 0x96,
  35022. 0x05,
  35023. 0x9a,
  35024. 0x07,
  35025. 0x12,
  35026. 0x80,
  35027. 0xe2,
  35028. 0xeb,
  35029. 0x27,
  35030. 0xb2,
  35031. 0x75,
  35032. 0x09,
  35033. 0x83,
  35034. 0x2c,
  35035. 0x1a,
  35036. 0x1b,
  35037. 0x6e,
  35038. 0x5a,
  35039. 0xa0,
  35040. 0x52,
  35041. 0x3b,
  35042. 0xd6,
  35043. 0xb3,
  35044. 0x29,
  35045. 0xe3,
  35046. 0x2f,
  35047. 0x84,
  35048. 0x53,
  35049. 0xd1,
  35050. 0x00,
  35051. 0xed,
  35052. 0x20,
  35053. 0xfc,
  35054. 0xb1,
  35055. 0x5b,
  35056. 0x6a,
  35057. 0xcb,
  35058. 0xbe,
  35059. 0x39,
  35060. 0x4a,
  35061. 0x4c,
  35062. 0x58,
  35063. 0xcf,
  35064. 0xd0,
  35065. 0xef,
  35066. 0xaa,
  35067. 0xfb,
  35068. 0x43,
  35069. 0x4d,
  35070. 0x33,
  35071. 0x85,
  35072. 0x45,
  35073. 0xf9,
  35074. 0x02,
  35075. 0x7f,
  35076. 0x50,
  35077. 0x3c,
  35078. 0x9f,
  35079. 0xa8,
  35080. 0x51,
  35081. 0xa3,
  35082. 0x40,
  35083. 0x8f,
  35084. 0x92,
  35085. 0x9d,
  35086. 0x38,
  35087. 0xf5,
  35088. 0xbc,
  35089. 0xb6,
  35090. 0xda,
  35091. 0x21,
  35092. 0x10,
  35093. 0xff,
  35094. 0xf3,
  35095. 0xd2,
  35096. 0xcd,
  35097. 0x0c,
  35098. 0x13,
  35099. 0xec,
  35100. 0x5f,
  35101. 0x97,
  35102. 0x44,
  35103. 0x17,
  35104. 0xc4,
  35105. 0xa7,
  35106. 0x7e,
  35107. 0x3d,
  35108. 0x64,
  35109. 0x5d,
  35110. 0x19,
  35111. 0x73,
  35112. 0x60,
  35113. 0x81,
  35114. 0x4f,
  35115. 0xdc,
  35116. 0x22,
  35117. 0x2a,
  35118. 0x90,
  35119. 0x88,
  35120. 0x46,
  35121. 0xee,
  35122. 0xb8,
  35123. 0x14,
  35124. 0xde,
  35125. 0x5e,
  35126. 0x0b,
  35127. 0xdb,
  35128. 0xe0,
  35129. 0x32,
  35130. 0x3a,
  35131. 0x0a,
  35132. 0x49,
  35133. 0x06,
  35134. 0x24,
  35135. 0x5c,
  35136. 0xc2,
  35137. 0xd3,
  35138. 0xac,
  35139. 0x62,
  35140. 0x91,
  35141. 0x95,
  35142. 0xe4,
  35143. 0x79,
  35144. 0xe7,
  35145. 0xc8,
  35146. 0x37,
  35147. 0x6d,
  35148. 0x8d,
  35149. 0xd5,
  35150. 0x4e,
  35151. 0xa9,
  35152. 0x6c,
  35153. 0x56,
  35154. 0xf4,
  35155. 0xea,
  35156. 0x65,
  35157. 0x7a,
  35158. 0xae,
  35159. 0x08,
  35160. 0xba,
  35161. 0x78,
  35162. 0x25,
  35163. 0x2e,
  35164. 0x1c,
  35165. 0xa6,
  35166. 0xb4,
  35167. 0xc6,
  35168. 0xe8,
  35169. 0xdd,
  35170. 0x74,
  35171. 0x1f,
  35172. 0x4b,
  35173. 0xbd,
  35174. 0x8b,
  35175. 0x8a,
  35176. 0x70,
  35177. 0x3e,
  35178. 0xb5,
  35179. 0x66,
  35180. 0x48,
  35181. 0x03,
  35182. 0xf6,
  35183. 0x0e,
  35184. 0x61,
  35185. 0x35,
  35186. 0x57,
  35187. 0xb9,
  35188. 0x86,
  35189. 0xc1,
  35190. 0x1d,
  35191. 0x9e,
  35192. 0xe1,
  35193. 0xf8,
  35194. 0x98,
  35195. 0x11,
  35196. 0x69,
  35197. 0xd9,
  35198. 0x8e,
  35199. 0x94,
  35200. 0x9b,
  35201. 0x1e,
  35202. 0x87,
  35203. 0xe9,
  35204. 0xce,
  35205. 0x55,
  35206. 0x28,
  35207. 0xdf,
  35208. 0x8c,
  35209. 0xa1,
  35210. 0x89,
  35211. 0x0d,
  35212. 0xbf,
  35213. 0xe6,
  35214. 0x42,
  35215. 0x68,
  35216. 0x41,
  35217. 0x99,
  35218. 0x2d,
  35219. 0x0f,
  35220. 0xb0,
  35221. 0x54,
  35222. 0xbb,
  35223. 0x16
  35224. ]);
  35225. var inv_s = new Uint8Array([
  35226. 0x52,
  35227. 0x09,
  35228. 0x6a,
  35229. 0xd5,
  35230. 0x30,
  35231. 0x36,
  35232. 0xa5,
  35233. 0x38,
  35234. 0xbf,
  35235. 0x40,
  35236. 0xa3,
  35237. 0x9e,
  35238. 0x81,
  35239. 0xf3,
  35240. 0xd7,
  35241. 0xfb,
  35242. 0x7c,
  35243. 0xe3,
  35244. 0x39,
  35245. 0x82,
  35246. 0x9b,
  35247. 0x2f,
  35248. 0xff,
  35249. 0x87,
  35250. 0x34,
  35251. 0x8e,
  35252. 0x43,
  35253. 0x44,
  35254. 0xc4,
  35255. 0xde,
  35256. 0xe9,
  35257. 0xcb,
  35258. 0x54,
  35259. 0x7b,
  35260. 0x94,
  35261. 0x32,
  35262. 0xa6,
  35263. 0xc2,
  35264. 0x23,
  35265. 0x3d,
  35266. 0xee,
  35267. 0x4c,
  35268. 0x95,
  35269. 0x0b,
  35270. 0x42,
  35271. 0xfa,
  35272. 0xc3,
  35273. 0x4e,
  35274. 0x08,
  35275. 0x2e,
  35276. 0xa1,
  35277. 0x66,
  35278. 0x28,
  35279. 0xd9,
  35280. 0x24,
  35281. 0xb2,
  35282. 0x76,
  35283. 0x5b,
  35284. 0xa2,
  35285. 0x49,
  35286. 0x6d,
  35287. 0x8b,
  35288. 0xd1,
  35289. 0x25,
  35290. 0x72,
  35291. 0xf8,
  35292. 0xf6,
  35293. 0x64,
  35294. 0x86,
  35295. 0x68,
  35296. 0x98,
  35297. 0x16,
  35298. 0xd4,
  35299. 0xa4,
  35300. 0x5c,
  35301. 0xcc,
  35302. 0x5d,
  35303. 0x65,
  35304. 0xb6,
  35305. 0x92,
  35306. 0x6c,
  35307. 0x70,
  35308. 0x48,
  35309. 0x50,
  35310. 0xfd,
  35311. 0xed,
  35312. 0xb9,
  35313. 0xda,
  35314. 0x5e,
  35315. 0x15,
  35316. 0x46,
  35317. 0x57,
  35318. 0xa7,
  35319. 0x8d,
  35320. 0x9d,
  35321. 0x84,
  35322. 0x90,
  35323. 0xd8,
  35324. 0xab,
  35325. 0x00,
  35326. 0x8c,
  35327. 0xbc,
  35328. 0xd3,
  35329. 0x0a,
  35330. 0xf7,
  35331. 0xe4,
  35332. 0x58,
  35333. 0x05,
  35334. 0xb8,
  35335. 0xb3,
  35336. 0x45,
  35337. 0x06,
  35338. 0xd0,
  35339. 0x2c,
  35340. 0x1e,
  35341. 0x8f,
  35342. 0xca,
  35343. 0x3f,
  35344. 0x0f,
  35345. 0x02,
  35346. 0xc1,
  35347. 0xaf,
  35348. 0xbd,
  35349. 0x03,
  35350. 0x01,
  35351. 0x13,
  35352. 0x8a,
  35353. 0x6b,
  35354. 0x3a,
  35355. 0x91,
  35356. 0x11,
  35357. 0x41,
  35358. 0x4f,
  35359. 0x67,
  35360. 0xdc,
  35361. 0xea,
  35362. 0x97,
  35363. 0xf2,
  35364. 0xcf,
  35365. 0xce,
  35366. 0xf0,
  35367. 0xb4,
  35368. 0xe6,
  35369. 0x73,
  35370. 0x96,
  35371. 0xac,
  35372. 0x74,
  35373. 0x22,
  35374. 0xe7,
  35375. 0xad,
  35376. 0x35,
  35377. 0x85,
  35378. 0xe2,
  35379. 0xf9,
  35380. 0x37,
  35381. 0xe8,
  35382. 0x1c,
  35383. 0x75,
  35384. 0xdf,
  35385. 0x6e,
  35386. 0x47,
  35387. 0xf1,
  35388. 0x1a,
  35389. 0x71,
  35390. 0x1d,
  35391. 0x29,
  35392. 0xc5,
  35393. 0x89,
  35394. 0x6f,
  35395. 0xb7,
  35396. 0x62,
  35397. 0x0e,
  35398. 0xaa,
  35399. 0x18,
  35400. 0xbe,
  35401. 0x1b,
  35402. 0xfc,
  35403. 0x56,
  35404. 0x3e,
  35405. 0x4b,
  35406. 0xc6,
  35407. 0xd2,
  35408. 0x79,
  35409. 0x20,
  35410. 0x9a,
  35411. 0xdb,
  35412. 0xc0,
  35413. 0xfe,
  35414. 0x78,
  35415. 0xcd,
  35416. 0x5a,
  35417. 0xf4,
  35418. 0x1f,
  35419. 0xdd,
  35420. 0xa8,
  35421. 0x33,
  35422. 0x88,
  35423. 0x07,
  35424. 0xc7,
  35425. 0x31,
  35426. 0xb1,
  35427. 0x12,
  35428. 0x10,
  35429. 0x59,
  35430. 0x27,
  35431. 0x80,
  35432. 0xec,
  35433. 0x5f,
  35434. 0x60,
  35435. 0x51,
  35436. 0x7f,
  35437. 0xa9,
  35438. 0x19,
  35439. 0xb5,
  35440. 0x4a,
  35441. 0x0d,
  35442. 0x2d,
  35443. 0xe5,
  35444. 0x7a,
  35445. 0x9f,
  35446. 0x93,
  35447. 0xc9,
  35448. 0x9c,
  35449. 0xef,
  35450. 0xa0,
  35451. 0xe0,
  35452. 0x3b,
  35453. 0x4d,
  35454. 0xae,
  35455. 0x2a,
  35456. 0xf5,
  35457. 0xb0,
  35458. 0xc8,
  35459. 0xeb,
  35460. 0xbb,
  35461. 0x3c,
  35462. 0x83,
  35463. 0x53,
  35464. 0x99,
  35465. 0x61,
  35466. 0x17,
  35467. 0x2b,
  35468. 0x04,
  35469. 0x7e,
  35470. 0xba,
  35471. 0x77,
  35472. 0xd6,
  35473. 0x26,
  35474. 0xe1,
  35475. 0x69,
  35476. 0x14,
  35477. 0x63,
  35478. 0x55,
  35479. 0x21,
  35480. 0x0c,
  35481. 0x7d
  35482. ]);
  35483. var mixCol = new Uint8Array(256);
  35484. for (var i = 0; i < 256; i++) {
  35485. if (i < 128) {
  35486. mixCol[i] = i << 1;
  35487. } else {
  35488. mixCol[i] = i << 1 ^ 0x1b;
  35489. }
  35490. }
  35491. var mix = new Uint32Array([
  35492. 0x00000000,
  35493. 0x0e090d0b,
  35494. 0x1c121a16,
  35495. 0x121b171d,
  35496. 0x3824342c,
  35497. 0x362d3927,
  35498. 0x24362e3a,
  35499. 0x2a3f2331,
  35500. 0x70486858,
  35501. 0x7e416553,
  35502. 0x6c5a724e,
  35503. 0x62537f45,
  35504. 0x486c5c74,
  35505. 0x4665517f,
  35506. 0x547e4662,
  35507. 0x5a774b69,
  35508. 0xe090d0b0,
  35509. 0xee99ddbb,
  35510. 0xfc82caa6,
  35511. 0xf28bc7ad,
  35512. 0xd8b4e49c,
  35513. 0xd6bde997,
  35514. 0xc4a6fe8a,
  35515. 0xcaaff381,
  35516. 0x90d8b8e8,
  35517. 0x9ed1b5e3,
  35518. 0x8ccaa2fe,
  35519. 0x82c3aff5,
  35520. 0xa8fc8cc4,
  35521. 0xa6f581cf,
  35522. 0xb4ee96d2,
  35523. 0xbae79bd9,
  35524. 0xdb3bbb7b,
  35525. 0xd532b670,
  35526. 0xc729a16d,
  35527. 0xc920ac66,
  35528. 0xe31f8f57,
  35529. 0xed16825c,
  35530. 0xff0d9541,
  35531. 0xf104984a,
  35532. 0xab73d323,
  35533. 0xa57ade28,
  35534. 0xb761c935,
  35535. 0xb968c43e,
  35536. 0x9357e70f,
  35537. 0x9d5eea04,
  35538. 0x8f45fd19,
  35539. 0x814cf012,
  35540. 0x3bab6bcb,
  35541. 0x35a266c0,
  35542. 0x27b971dd,
  35543. 0x29b07cd6,
  35544. 0x038f5fe7,
  35545. 0x0d8652ec,
  35546. 0x1f9d45f1,
  35547. 0x119448fa,
  35548. 0x4be30393,
  35549. 0x45ea0e98,
  35550. 0x57f11985,
  35551. 0x59f8148e,
  35552. 0x73c737bf,
  35553. 0x7dce3ab4,
  35554. 0x6fd52da9,
  35555. 0x61dc20a2,
  35556. 0xad766df6,
  35557. 0xa37f60fd,
  35558. 0xb16477e0,
  35559. 0xbf6d7aeb,
  35560. 0x955259da,
  35561. 0x9b5b54d1,
  35562. 0x894043cc,
  35563. 0x87494ec7,
  35564. 0xdd3e05ae,
  35565. 0xd33708a5,
  35566. 0xc12c1fb8,
  35567. 0xcf2512b3,
  35568. 0xe51a3182,
  35569. 0xeb133c89,
  35570. 0xf9082b94,
  35571. 0xf701269f,
  35572. 0x4de6bd46,
  35573. 0x43efb04d,
  35574. 0x51f4a750,
  35575. 0x5ffdaa5b,
  35576. 0x75c2896a,
  35577. 0x7bcb8461,
  35578. 0x69d0937c,
  35579. 0x67d99e77,
  35580. 0x3daed51e,
  35581. 0x33a7d815,
  35582. 0x21bccf08,
  35583. 0x2fb5c203,
  35584. 0x058ae132,
  35585. 0x0b83ec39,
  35586. 0x1998fb24,
  35587. 0x1791f62f,
  35588. 0x764dd68d,
  35589. 0x7844db86,
  35590. 0x6a5fcc9b,
  35591. 0x6456c190,
  35592. 0x4e69e2a1,
  35593. 0x4060efaa,
  35594. 0x527bf8b7,
  35595. 0x5c72f5bc,
  35596. 0x0605bed5,
  35597. 0x080cb3de,
  35598. 0x1a17a4c3,
  35599. 0x141ea9c8,
  35600. 0x3e218af9,
  35601. 0x302887f2,
  35602. 0x223390ef,
  35603. 0x2c3a9de4,
  35604. 0x96dd063d,
  35605. 0x98d40b36,
  35606. 0x8acf1c2b,
  35607. 0x84c61120,
  35608. 0xaef93211,
  35609. 0xa0f03f1a,
  35610. 0xb2eb2807,
  35611. 0xbce2250c,
  35612. 0xe6956e65,
  35613. 0xe89c636e,
  35614. 0xfa877473,
  35615. 0xf48e7978,
  35616. 0xdeb15a49,
  35617. 0xd0b85742,
  35618. 0xc2a3405f,
  35619. 0xccaa4d54,
  35620. 0x41ecdaf7,
  35621. 0x4fe5d7fc,
  35622. 0x5dfec0e1,
  35623. 0x53f7cdea,
  35624. 0x79c8eedb,
  35625. 0x77c1e3d0,
  35626. 0x65daf4cd,
  35627. 0x6bd3f9c6,
  35628. 0x31a4b2af,
  35629. 0x3fadbfa4,
  35630. 0x2db6a8b9,
  35631. 0x23bfa5b2,
  35632. 0x09808683,
  35633. 0x07898b88,
  35634. 0x15929c95,
  35635. 0x1b9b919e,
  35636. 0xa17c0a47,
  35637. 0xaf75074c,
  35638. 0xbd6e1051,
  35639. 0xb3671d5a,
  35640. 0x99583e6b,
  35641. 0x97513360,
  35642. 0x854a247d,
  35643. 0x8b432976,
  35644. 0xd134621f,
  35645. 0xdf3d6f14,
  35646. 0xcd267809,
  35647. 0xc32f7502,
  35648. 0xe9105633,
  35649. 0xe7195b38,
  35650. 0xf5024c25,
  35651. 0xfb0b412e,
  35652. 0x9ad7618c,
  35653. 0x94de6c87,
  35654. 0x86c57b9a,
  35655. 0x88cc7691,
  35656. 0xa2f355a0,
  35657. 0xacfa58ab,
  35658. 0xbee14fb6,
  35659. 0xb0e842bd,
  35660. 0xea9f09d4,
  35661. 0xe49604df,
  35662. 0xf68d13c2,
  35663. 0xf8841ec9,
  35664. 0xd2bb3df8,
  35665. 0xdcb230f3,
  35666. 0xcea927ee,
  35667. 0xc0a02ae5,
  35668. 0x7a47b13c,
  35669. 0x744ebc37,
  35670. 0x6655ab2a,
  35671. 0x685ca621,
  35672. 0x42638510,
  35673. 0x4c6a881b,
  35674. 0x5e719f06,
  35675. 0x5078920d,
  35676. 0x0a0fd964,
  35677. 0x0406d46f,
  35678. 0x161dc372,
  35679. 0x1814ce79,
  35680. 0x322bed48,
  35681. 0x3c22e043,
  35682. 0x2e39f75e,
  35683. 0x2030fa55,
  35684. 0xec9ab701,
  35685. 0xe293ba0a,
  35686. 0xf088ad17,
  35687. 0xfe81a01c,
  35688. 0xd4be832d,
  35689. 0xdab78e26,
  35690. 0xc8ac993b,
  35691. 0xc6a59430,
  35692. 0x9cd2df59,
  35693. 0x92dbd252,
  35694. 0x80c0c54f,
  35695. 0x8ec9c844,
  35696. 0xa4f6eb75,
  35697. 0xaaffe67e,
  35698. 0xb8e4f163,
  35699. 0xb6edfc68,
  35700. 0x0c0a67b1,
  35701. 0x02036aba,
  35702. 0x10187da7,
  35703. 0x1e1170ac,
  35704. 0x342e539d,
  35705. 0x3a275e96,
  35706. 0x283c498b,
  35707. 0x26354480,
  35708. 0x7c420fe9,
  35709. 0x724b02e2,
  35710. 0x605015ff,
  35711. 0x6e5918f4,
  35712. 0x44663bc5,
  35713. 0x4a6f36ce,
  35714. 0x587421d3,
  35715. 0x567d2cd8,
  35716. 0x37a10c7a,
  35717. 0x39a80171,
  35718. 0x2bb3166c,
  35719. 0x25ba1b67,
  35720. 0x0f853856,
  35721. 0x018c355d,
  35722. 0x13972240,
  35723. 0x1d9e2f4b,
  35724. 0x47e96422,
  35725. 0x49e06929,
  35726. 0x5bfb7e34,
  35727. 0x55f2733f,
  35728. 0x7fcd500e,
  35729. 0x71c45d05,
  35730. 0x63df4a18,
  35731. 0x6dd64713,
  35732. 0xd731dcca,
  35733. 0xd938d1c1,
  35734. 0xcb23c6dc,
  35735. 0xc52acbd7,
  35736. 0xef15e8e6,
  35737. 0xe11ce5ed,
  35738. 0xf307f2f0,
  35739. 0xfd0efffb,
  35740. 0xa779b492,
  35741. 0xa970b999,
  35742. 0xbb6bae84,
  35743. 0xb562a38f,
  35744. 0x9f5d80be,
  35745. 0x91548db5,
  35746. 0x834f9aa8,
  35747. 0x8d4697a3
  35748. ]);
  35749. function expandKey256(cipherKey) {
  35750. var b = 240, result = new Uint8Array(b);
  35751. var r = 1;
  35752. result.set(cipherKey);
  35753. for (var j = 32, i = 1; j < b; ++i) {
  35754. if (j % 32 === 16) {
  35755. t1 = s[t1];
  35756. t2 = s[t2];
  35757. t3 = s[t3];
  35758. t4 = s[t4];
  35759. } else if (j % 32 === 0) {
  35760. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35761. t1 = s[t1];
  35762. t2 = s[t2];
  35763. t3 = s[t3];
  35764. t4 = s[t4];
  35765. t1 = t1 ^ r;
  35766. if ((r <<= 1) >= 256) {
  35767. r = (r ^ 0x1b) & 0xFF;
  35768. }
  35769. }
  35770. for (var n = 0; n < 4; ++n) {
  35771. result[j] = t1 ^= result[j - 32];
  35772. j++;
  35773. result[j] = t2 ^= result[j - 32];
  35774. j++;
  35775. result[j] = t3 ^= result[j - 32];
  35776. j++;
  35777. result[j] = t4 ^= result[j - 32];
  35778. j++;
  35779. }
  35780. }
  35781. return result;
  35782. }
  35783. function decrypt256(input, key) {
  35784. var state = new Uint8Array(16);
  35785. state.set(input);
  35786. var i, j, k;
  35787. var t, u, v;
  35788. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35789. state[j] ^= key[k];
  35790. }
  35791. for (i = 13; i >= 1; --i) {
  35792. t = state[13];
  35793. state[13] = state[9];
  35794. state[9] = state[5];
  35795. state[5] = state[1];
  35796. state[1] = t;
  35797. t = state[14];
  35798. u = state[10];
  35799. state[14] = state[6];
  35800. state[10] = state[2];
  35801. state[6] = t;
  35802. state[2] = u;
  35803. t = state[15];
  35804. u = state[11];
  35805. v = state[7];
  35806. state[15] = state[3];
  35807. state[11] = t;
  35808. state[7] = u;
  35809. state[3] = v;
  35810. for (j = 0; j < 16; ++j) {
  35811. state[j] = inv_s[state[j]];
  35812. }
  35813. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35814. state[j] ^= key[k];
  35815. }
  35816. for (j = 0; j < 16; j += 4) {
  35817. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35818. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35819. state[j] = t >>> 24 & 0xFF;
  35820. state[j + 1] = t >> 16 & 0xFF;
  35821. state[j + 2] = t >> 8 & 0xFF;
  35822. state[j + 3] = t & 0xFF;
  35823. }
  35824. }
  35825. t = state[13];
  35826. state[13] = state[9];
  35827. state[9] = state[5];
  35828. state[5] = state[1];
  35829. state[1] = t;
  35830. t = state[14];
  35831. u = state[10];
  35832. state[14] = state[6];
  35833. state[10] = state[2];
  35834. state[6] = t;
  35835. state[2] = u;
  35836. t = state[15];
  35837. u = state[11];
  35838. v = state[7];
  35839. state[15] = state[3];
  35840. state[11] = t;
  35841. state[7] = u;
  35842. state[3] = v;
  35843. for (j = 0; j < 16; ++j) {
  35844. state[j] = inv_s[state[j]];
  35845. state[j] ^= key[j];
  35846. }
  35847. return state;
  35848. }
  35849. function encrypt256(input, key) {
  35850. var t, u, v, k;
  35851. var state = new Uint8Array(16);
  35852. state.set(input);
  35853. for (j = 0; j < 16; ++j) {
  35854. state[j] ^= key[j];
  35855. }
  35856. for (i = 1; i < 14; i++) {
  35857. for (j = 0; j < 16; ++j) {
  35858. state[j] = s[state[j]];
  35859. }
  35860. v = state[1];
  35861. state[1] = state[5];
  35862. state[5] = state[9];
  35863. state[9] = state[13];
  35864. state[13] = v;
  35865. v = state[2];
  35866. u = state[6];
  35867. state[2] = state[10];
  35868. state[6] = state[14];
  35869. state[10] = v;
  35870. state[14] = u;
  35871. v = state[3];
  35872. u = state[7];
  35873. t = state[11];
  35874. state[3] = state[15];
  35875. state[7] = v;
  35876. state[11] = u;
  35877. state[15] = t;
  35878. for (var j = 0; j < 16; j += 4) {
  35879. var s0 = state[j + 0], s1 = state[j + 1];
  35880. var s2 = state[j + 2], s3 = state[j + 3];
  35881. t = s0 ^ s1 ^ s2 ^ s3;
  35882. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  35883. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  35884. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  35885. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  35886. }
  35887. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35888. state[j] ^= key[k];
  35889. }
  35890. }
  35891. for (j = 0; j < 16; ++j) {
  35892. state[j] = s[state[j]];
  35893. }
  35894. v = state[1];
  35895. state[1] = state[5];
  35896. state[5] = state[9];
  35897. state[9] = state[13];
  35898. state[13] = v;
  35899. v = state[2];
  35900. u = state[6];
  35901. state[2] = state[10];
  35902. state[6] = state[14];
  35903. state[10] = v;
  35904. state[14] = u;
  35905. v = state[3];
  35906. u = state[7];
  35907. t = state[11];
  35908. state[3] = state[15];
  35909. state[7] = v;
  35910. state[11] = u;
  35911. state[15] = t;
  35912. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35913. state[j] ^= key[k];
  35914. }
  35915. return state;
  35916. }
  35917. function AES256Cipher(key) {
  35918. this.key = expandKey256(key);
  35919. this.buffer = new Uint8Array(16);
  35920. this.bufferPosition = 0;
  35921. }
  35922. function decryptBlock2(data, finalize) {
  35923. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  35924. for (i = 0; i < sourceLength; ++i) {
  35925. buffer[bufferLength] = data[i];
  35926. ++bufferLength;
  35927. if (bufferLength < 16) {
  35928. continue;
  35929. }
  35930. var plain = decrypt256(buffer, this.key);
  35931. for (j = 0; j < 16; ++j) {
  35932. plain[j] ^= iv[j];
  35933. }
  35934. iv = buffer;
  35935. result.push(plain);
  35936. buffer = new Uint8Array(16);
  35937. bufferLength = 0;
  35938. }
  35939. this.buffer = buffer;
  35940. this.bufferLength = bufferLength;
  35941. this.iv = iv;
  35942. if (result.length === 0) {
  35943. return new Uint8Array([]);
  35944. }
  35945. var outputLength = 16 * result.length;
  35946. if (finalize) {
  35947. var lastBlock = result[result.length - 1];
  35948. var psLen = lastBlock[15];
  35949. if (psLen <= 16) {
  35950. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  35951. if (lastBlock[i] !== psLen) {
  35952. psLen = 0;
  35953. break;
  35954. }
  35955. }
  35956. outputLength -= psLen;
  35957. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  35958. }
  35959. }
  35960. var output = new Uint8Array(outputLength);
  35961. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35962. output.set(result[i], j);
  35963. }
  35964. return output;
  35965. }
  35966. AES256Cipher.prototype = {
  35967. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  35968. var i, sourceLength = data.length;
  35969. var buffer = this.buffer, bufferLength = this.bufferPosition;
  35970. if (iv) {
  35971. this.iv = iv;
  35972. } else {
  35973. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  35974. buffer[bufferLength] = data[i];
  35975. }
  35976. if (bufferLength < 16) {
  35977. this.bufferLength = bufferLength;
  35978. return new Uint8Array([]);
  35979. }
  35980. this.iv = buffer;
  35981. data = data.subarray(16);
  35982. }
  35983. this.buffer = new Uint8Array(16);
  35984. this.bufferLength = 0;
  35985. this.decryptBlock = decryptBlock2;
  35986. return this.decryptBlock(data, finalize);
  35987. },
  35988. encrypt: function AES256Cipher_encrypt(data, iv) {
  35989. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  35990. if (!iv) {
  35991. iv = new Uint8Array(16);
  35992. }
  35993. for (i = 0; i < sourceLength; ++i) {
  35994. buffer[bufferLength] = data[i];
  35995. ++bufferLength;
  35996. if (bufferLength < 16) {
  35997. continue;
  35998. }
  35999. for (j = 0; j < 16; ++j) {
  36000. buffer[j] ^= iv[j];
  36001. }
  36002. var cipher = encrypt256(buffer, this.key);
  36003. this.iv = cipher;
  36004. result.push(cipher);
  36005. buffer = new Uint8Array(16);
  36006. bufferLength = 0;
  36007. }
  36008. this.buffer = buffer;
  36009. this.bufferLength = bufferLength;
  36010. this.iv = iv;
  36011. if (result.length === 0) {
  36012. return new Uint8Array([]);
  36013. }
  36014. var outputLength = 16 * result.length;
  36015. var output = new Uint8Array(outputLength);
  36016. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36017. output.set(result[i], j);
  36018. }
  36019. return output;
  36020. }
  36021. };
  36022. return AES256Cipher;
  36023. }();
  36024. var PDF17 = function PDF17Closure() {
  36025. function compareByteArrays(array1, array2) {
  36026. if (array1.length !== array2.length) {
  36027. return false;
  36028. }
  36029. for (var i = 0; i < array1.length; i++) {
  36030. if (array1[i] !== array2[i]) {
  36031. return false;
  36032. }
  36033. }
  36034. return true;
  36035. }
  36036. function PDF17() {
  36037. }
  36038. PDF17.prototype = {
  36039. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36040. var hashData = new Uint8Array(password.length + 56);
  36041. hashData.set(password, 0);
  36042. hashData.set(ownerValidationSalt, password.length);
  36043. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36044. var result = calculateSHA256(hashData, 0, hashData.length);
  36045. return compareByteArrays(result, ownerPassword);
  36046. },
  36047. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36048. var hashData = new Uint8Array(password.length + 8);
  36049. hashData.set(password, 0);
  36050. hashData.set(userValidationSalt, password.length);
  36051. var result = calculateSHA256(hashData, 0, hashData.length);
  36052. return compareByteArrays(result, userPassword);
  36053. },
  36054. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36055. var hashData = new Uint8Array(password.length + 56);
  36056. hashData.set(password, 0);
  36057. hashData.set(ownerKeySalt, password.length);
  36058. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36059. var key = calculateSHA256(hashData, 0, hashData.length);
  36060. var cipher = new AES256Cipher(key);
  36061. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36062. },
  36063. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36064. var hashData = new Uint8Array(password.length + 8);
  36065. hashData.set(password, 0);
  36066. hashData.set(userKeySalt, password.length);
  36067. var key = calculateSHA256(hashData, 0, hashData.length);
  36068. var cipher = new AES256Cipher(key);
  36069. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36070. }
  36071. };
  36072. return PDF17;
  36073. }();
  36074. var PDF20 = function PDF20Closure() {
  36075. function concatArrays(array1, array2) {
  36076. var t = new Uint8Array(array1.length + array2.length);
  36077. t.set(array1, 0);
  36078. t.set(array2, array1.length);
  36079. return t;
  36080. }
  36081. function calculatePDF20Hash(password, input, userBytes) {
  36082. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36083. var e = [0];
  36084. var i = 0;
  36085. while (i < 64 || e[e.length - 1] > i - 32) {
  36086. var arrayLength = password.length + k.length + userBytes.length;
  36087. var k1 = new Uint8Array(arrayLength * 64);
  36088. var array = concatArrays(password, k);
  36089. array = concatArrays(array, userBytes);
  36090. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36091. k1.set(array, pos);
  36092. }
  36093. var cipher = new AES128Cipher(k.subarray(0, 16));
  36094. e = cipher.encrypt(k1, k.subarray(16, 32));
  36095. var remainder = 0;
  36096. for (var z = 0; z < 16; z++) {
  36097. remainder *= 256 % 3;
  36098. remainder %= 3;
  36099. remainder += (e[z] >>> 0) % 3;
  36100. remainder %= 3;
  36101. }
  36102. if (remainder === 0) {
  36103. k = calculateSHA256(e, 0, e.length);
  36104. } else if (remainder === 1) {
  36105. k = calculateSHA384(e, 0, e.length);
  36106. } else if (remainder === 2) {
  36107. k = calculateSHA512(e, 0, e.length);
  36108. }
  36109. i++;
  36110. }
  36111. return k.subarray(0, 32);
  36112. }
  36113. function PDF20() {
  36114. }
  36115. function compareByteArrays(array1, array2) {
  36116. if (array1.length !== array2.length) {
  36117. return false;
  36118. }
  36119. for (var i = 0; i < array1.length; i++) {
  36120. if (array1[i] !== array2[i]) {
  36121. return false;
  36122. }
  36123. }
  36124. return true;
  36125. }
  36126. PDF20.prototype = {
  36127. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36128. return calculatePDF20Hash(password, concatBytes, userBytes);
  36129. },
  36130. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36131. var hashData = new Uint8Array(password.length + 56);
  36132. hashData.set(password, 0);
  36133. hashData.set(ownerValidationSalt, password.length);
  36134. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36135. var result = calculatePDF20Hash(password, hashData, userBytes);
  36136. return compareByteArrays(result, ownerPassword);
  36137. },
  36138. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36139. var hashData = new Uint8Array(password.length + 8);
  36140. hashData.set(password, 0);
  36141. hashData.set(userValidationSalt, password.length);
  36142. var result = calculatePDF20Hash(password, hashData, []);
  36143. return compareByteArrays(result, userPassword);
  36144. },
  36145. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36146. var hashData = new Uint8Array(password.length + 56);
  36147. hashData.set(password, 0);
  36148. hashData.set(ownerKeySalt, password.length);
  36149. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36150. var key = calculatePDF20Hash(password, hashData, userBytes);
  36151. var cipher = new AES256Cipher(key);
  36152. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36153. },
  36154. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36155. var hashData = new Uint8Array(password.length + 8);
  36156. hashData.set(password, 0);
  36157. hashData.set(userKeySalt, password.length);
  36158. var key = calculatePDF20Hash(password, hashData, []);
  36159. var cipher = new AES256Cipher(key);
  36160. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36161. }
  36162. };
  36163. return PDF20;
  36164. }();
  36165. var CipherTransform = function CipherTransformClosure() {
  36166. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36167. this.stringCipherConstructor = stringCipherConstructor;
  36168. this.streamCipherConstructor = streamCipherConstructor;
  36169. }
  36170. CipherTransform.prototype = {
  36171. createStream: function CipherTransform_createStream(stream, length) {
  36172. var cipher = new this.streamCipherConstructor();
  36173. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36174. return cipher.decryptBlock(data, finalize);
  36175. });
  36176. },
  36177. decryptString: function CipherTransform_decryptString(s) {
  36178. var cipher = new this.stringCipherConstructor();
  36179. var data = stringToBytes(s);
  36180. data = cipher.decryptBlock(data, true);
  36181. return bytesToString(data);
  36182. }
  36183. };
  36184. return CipherTransform;
  36185. }();
  36186. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36187. var defaultPasswordBytes = new Uint8Array([
  36188. 0x28,
  36189. 0xBF,
  36190. 0x4E,
  36191. 0x5E,
  36192. 0x4E,
  36193. 0x75,
  36194. 0x8A,
  36195. 0x41,
  36196. 0x64,
  36197. 0x00,
  36198. 0x4E,
  36199. 0x56,
  36200. 0xFF,
  36201. 0xFA,
  36202. 0x01,
  36203. 0x08,
  36204. 0x2E,
  36205. 0x2E,
  36206. 0x00,
  36207. 0xB6,
  36208. 0xD0,
  36209. 0x68,
  36210. 0x3E,
  36211. 0x80,
  36212. 0x2F,
  36213. 0x0C,
  36214. 0xA9,
  36215. 0xFE,
  36216. 0x64,
  36217. 0x53,
  36218. 0x69,
  36219. 0x7A
  36220. ]);
  36221. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36222. if (password) {
  36223. var passwordLength = Math.min(127, password.length);
  36224. password = password.subarray(0, passwordLength);
  36225. } else {
  36226. password = [];
  36227. }
  36228. var pdfAlgorithm;
  36229. if (revision === 6) {
  36230. pdfAlgorithm = new PDF20();
  36231. } else {
  36232. pdfAlgorithm = new PDF17();
  36233. }
  36234. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36235. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36236. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36237. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36238. }
  36239. return null;
  36240. }
  36241. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36242. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36243. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36244. if (password) {
  36245. n = Math.min(32, password.length);
  36246. for (; i < n; ++i) {
  36247. hashData[i] = password[i];
  36248. }
  36249. }
  36250. j = 0;
  36251. while (i < 32) {
  36252. hashData[i++] = defaultPasswordBytes[j++];
  36253. }
  36254. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36255. hashData[i++] = ownerPassword[j];
  36256. }
  36257. hashData[i++] = flags & 0xFF;
  36258. hashData[i++] = flags >> 8 & 0xFF;
  36259. hashData[i++] = flags >> 16 & 0xFF;
  36260. hashData[i++] = flags >>> 24 & 0xFF;
  36261. for (j = 0, n = fileId.length; j < n; ++j) {
  36262. hashData[i++] = fileId[j];
  36263. }
  36264. if (revision >= 4 && !encryptMetadata) {
  36265. hashData[i++] = 0xFF;
  36266. hashData[i++] = 0xFF;
  36267. hashData[i++] = 0xFF;
  36268. hashData[i++] = 0xFF;
  36269. }
  36270. var hash = calculateMD5(hashData, 0, i);
  36271. var keyLengthInBytes = keyLength >> 3;
  36272. if (revision >= 3) {
  36273. for (j = 0; j < 50; ++j) {
  36274. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36275. }
  36276. }
  36277. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36278. var cipher, checkData;
  36279. if (revision >= 3) {
  36280. for (i = 0; i < 32; ++i) {
  36281. hashData[i] = defaultPasswordBytes[i];
  36282. }
  36283. for (j = 0, n = fileId.length; j < n; ++j) {
  36284. hashData[i++] = fileId[j];
  36285. }
  36286. cipher = new ARCFourCipher(encryptionKey);
  36287. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36288. n = encryptionKey.length;
  36289. var derivedKey = new Uint8Array(n), k;
  36290. for (j = 1; j <= 19; ++j) {
  36291. for (k = 0; k < n; ++k) {
  36292. derivedKey[k] = encryptionKey[k] ^ j;
  36293. }
  36294. cipher = new ARCFourCipher(derivedKey);
  36295. checkData = cipher.encryptBlock(checkData);
  36296. }
  36297. for (j = 0, n = checkData.length; j < n; ++j) {
  36298. if (userPassword[j] !== checkData[j]) {
  36299. return null;
  36300. }
  36301. }
  36302. } else {
  36303. cipher = new ARCFourCipher(encryptionKey);
  36304. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36305. for (j = 0, n = checkData.length; j < n; ++j) {
  36306. if (userPassword[j] !== checkData[j]) {
  36307. return null;
  36308. }
  36309. }
  36310. }
  36311. return encryptionKey;
  36312. }
  36313. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36314. var hashData = new Uint8Array(32), i = 0, j, n;
  36315. n = Math.min(32, password.length);
  36316. for (; i < n; ++i) {
  36317. hashData[i] = password[i];
  36318. }
  36319. j = 0;
  36320. while (i < 32) {
  36321. hashData[i++] = defaultPasswordBytes[j++];
  36322. }
  36323. var hash = calculateMD5(hashData, 0, i);
  36324. var keyLengthInBytes = keyLength >> 3;
  36325. if (revision >= 3) {
  36326. for (j = 0; j < 50; ++j) {
  36327. hash = calculateMD5(hash, 0, hash.length);
  36328. }
  36329. }
  36330. var cipher, userPassword;
  36331. if (revision >= 3) {
  36332. userPassword = ownerPassword;
  36333. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36334. for (j = 19; j >= 0; j--) {
  36335. for (k = 0; k < keyLengthInBytes; ++k) {
  36336. derivedKey[k] = hash[k] ^ j;
  36337. }
  36338. cipher = new ARCFourCipher(derivedKey);
  36339. userPassword = cipher.encryptBlock(userPassword);
  36340. }
  36341. } else {
  36342. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36343. userPassword = cipher.encryptBlock(ownerPassword);
  36344. }
  36345. return userPassword;
  36346. }
  36347. var identityName = Name.get('Identity');
  36348. function CipherTransformFactory(dict, fileId, password) {
  36349. var filter = dict.get('Filter');
  36350. if (!isName(filter, 'Standard')) {
  36351. error('unknown encryption method');
  36352. }
  36353. this.dict = dict;
  36354. var algorithm = dict.get('V');
  36355. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36356. error('unsupported encryption algorithm');
  36357. }
  36358. this.algorithm = algorithm;
  36359. var keyLength = dict.get('Length');
  36360. if (!keyLength) {
  36361. if (algorithm <= 3) {
  36362. keyLength = 40;
  36363. } else {
  36364. var cfDict = dict.get('CF');
  36365. var streamCryptoName = dict.get('StmF');
  36366. if (isDict(cfDict) && isName(streamCryptoName)) {
  36367. cfDict.suppressEncryption = true;
  36368. var handlerDict = cfDict.get(streamCryptoName.name);
  36369. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36370. if (keyLength < 40) {
  36371. keyLength <<= 3;
  36372. }
  36373. }
  36374. }
  36375. }
  36376. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36377. error('invalid key length');
  36378. }
  36379. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36380. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36381. var flags = dict.get('P');
  36382. var revision = dict.get('R');
  36383. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36384. this.encryptMetadata = encryptMetadata;
  36385. var fileIdBytes = stringToBytes(fileId);
  36386. var passwordBytes;
  36387. if (password) {
  36388. if (revision === 6) {
  36389. try {
  36390. password = utf8StringToString(password);
  36391. } catch (ex) {
  36392. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36393. }
  36394. }
  36395. passwordBytes = stringToBytes(password);
  36396. }
  36397. var encryptionKey;
  36398. if (algorithm !== 5) {
  36399. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36400. } else {
  36401. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36402. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36403. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36404. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36405. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36406. var ownerEncryption = stringToBytes(dict.get('OE'));
  36407. var userEncryption = stringToBytes(dict.get('UE'));
  36408. var perms = stringToBytes(dict.get('Perms'));
  36409. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36410. }
  36411. if (!encryptionKey && !password) {
  36412. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36413. } else if (!encryptionKey && password) {
  36414. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36415. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36416. }
  36417. if (!encryptionKey) {
  36418. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36419. }
  36420. this.encryptionKey = encryptionKey;
  36421. if (algorithm >= 4) {
  36422. var cf = dict.get('CF');
  36423. if (isDict(cf)) {
  36424. cf.suppressEncryption = true;
  36425. }
  36426. this.cf = cf;
  36427. this.stmf = dict.get('StmF') || identityName;
  36428. this.strf = dict.get('StrF') || identityName;
  36429. this.eff = dict.get('EFF') || this.stmf;
  36430. }
  36431. }
  36432. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36433. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36434. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36435. key[i] = encryptionKey[i];
  36436. }
  36437. key[i++] = num & 0xFF;
  36438. key[i++] = num >> 8 & 0xFF;
  36439. key[i++] = num >> 16 & 0xFF;
  36440. key[i++] = gen & 0xFF;
  36441. key[i++] = gen >> 8 & 0xFF;
  36442. if (isAes) {
  36443. key[i++] = 0x73;
  36444. key[i++] = 0x41;
  36445. key[i++] = 0x6C;
  36446. key[i++] = 0x54;
  36447. }
  36448. var hash = calculateMD5(key, 0, i);
  36449. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36450. }
  36451. function buildCipherConstructor(cf, name, num, gen, key) {
  36452. assert(isName(name), 'Invalid crypt filter name.');
  36453. var cryptFilter = cf.get(name.name);
  36454. var cfm;
  36455. if (cryptFilter !== null && cryptFilter !== undefined) {
  36456. cfm = cryptFilter.get('CFM');
  36457. }
  36458. if (!cfm || cfm.name === 'None') {
  36459. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36460. return new NullCipher();
  36461. };
  36462. }
  36463. if ('V2' === cfm.name) {
  36464. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36465. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36466. };
  36467. }
  36468. if ('AESV2' === cfm.name) {
  36469. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36470. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36471. };
  36472. }
  36473. if ('AESV3' === cfm.name) {
  36474. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36475. return new AES256Cipher(key);
  36476. };
  36477. }
  36478. error('Unknown crypto method');
  36479. }
  36480. CipherTransformFactory.prototype = {
  36481. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36482. if (this.algorithm === 4 || this.algorithm === 5) {
  36483. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36484. }
  36485. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36486. var cipherConstructor = function buildCipherCipherConstructor() {
  36487. return new ARCFourCipher(key);
  36488. };
  36489. return new CipherTransform(cipherConstructor, cipherConstructor);
  36490. }
  36491. };
  36492. return CipherTransformFactory;
  36493. }();
  36494. exports.AES128Cipher = AES128Cipher;
  36495. exports.AES256Cipher = AES256Cipher;
  36496. exports.ARCFourCipher = ARCFourCipher;
  36497. exports.CipherTransformFactory = CipherTransformFactory;
  36498. exports.PDF17 = PDF17;
  36499. exports.PDF20 = PDF20;
  36500. exports.calculateMD5 = calculateMD5;
  36501. exports.calculateSHA256 = calculateSHA256;
  36502. exports.calculateSHA384 = calculateSHA384;
  36503. exports.calculateSHA512 = calculateSHA512;
  36504. }));
  36505. (function (root, factory) {
  36506. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36507. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36508. var Util = sharedUtil.Util;
  36509. var bytesToString = sharedUtil.bytesToString;
  36510. var error = sharedUtil.error;
  36511. var Stream = coreStream.Stream;
  36512. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36513. var StandardEncoding = coreEncodings.StandardEncoding;
  36514. var CFFParser = coreCFFParser.CFFParser;
  36515. var FontRendererFactory = function FontRendererFactoryClosure() {
  36516. function getLong(data, offset) {
  36517. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36518. }
  36519. function getUshort(data, offset) {
  36520. return data[offset] << 8 | data[offset + 1];
  36521. }
  36522. function parseCmap(data, start, end) {
  36523. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36524. var format = getUshort(data, start + offset);
  36525. var length, ranges, p, i;
  36526. if (format === 4) {
  36527. length = getUshort(data, start + offset + 2);
  36528. var segCount = getUshort(data, start + offset + 6) >> 1;
  36529. p = start + offset + 14;
  36530. ranges = [];
  36531. for (i = 0; i < segCount; i++, p += 2) {
  36532. ranges[i] = { end: getUshort(data, p) };
  36533. }
  36534. p += 2;
  36535. for (i = 0; i < segCount; i++, p += 2) {
  36536. ranges[i].start = getUshort(data, p);
  36537. }
  36538. for (i = 0; i < segCount; i++, p += 2) {
  36539. ranges[i].idDelta = getUshort(data, p);
  36540. }
  36541. for (i = 0; i < segCount; i++, p += 2) {
  36542. var idOffset = getUshort(data, p);
  36543. if (idOffset === 0) {
  36544. continue;
  36545. }
  36546. ranges[i].ids = [];
  36547. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36548. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36549. idOffset += 2;
  36550. }
  36551. }
  36552. return ranges;
  36553. } else if (format === 12) {
  36554. length = getLong(data, start + offset + 4);
  36555. var groups = getLong(data, start + offset + 12);
  36556. p = start + offset + 16;
  36557. ranges = [];
  36558. for (i = 0; i < groups; i++) {
  36559. ranges.push({
  36560. start: getLong(data, p),
  36561. end: getLong(data, p + 4),
  36562. idDelta: getLong(data, p + 8) - getLong(data, p)
  36563. });
  36564. p += 12;
  36565. }
  36566. return ranges;
  36567. }
  36568. error('not supported cmap: ' + format);
  36569. }
  36570. function parseCff(data, start, end, seacAnalysisEnabled) {
  36571. var properties = {};
  36572. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36573. var cff = parser.parse();
  36574. return {
  36575. glyphs: cff.charStrings.objects,
  36576. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36577. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36578. };
  36579. }
  36580. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36581. var itemSize, itemDecode;
  36582. if (isGlyphLocationsLong) {
  36583. itemSize = 4;
  36584. itemDecode = function fontItemDecodeLong(data, offset) {
  36585. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36586. };
  36587. } else {
  36588. itemSize = 2;
  36589. itemDecode = function fontItemDecode(data, offset) {
  36590. return data[offset] << 9 | data[offset + 1] << 1;
  36591. };
  36592. }
  36593. var glyphs = [];
  36594. var startOffset = itemDecode(loca, 0);
  36595. for (var j = itemSize; j < loca.length; j += itemSize) {
  36596. var endOffset = itemDecode(loca, j);
  36597. glyphs.push(glyf.subarray(startOffset, endOffset));
  36598. startOffset = endOffset;
  36599. }
  36600. return glyphs;
  36601. }
  36602. function lookupCmap(ranges, unicode) {
  36603. var code = unicode.charCodeAt(0), gid = 0;
  36604. var l = 0, r = ranges.length - 1;
  36605. while (l < r) {
  36606. var c = l + r + 1 >> 1;
  36607. if (code < ranges[c].start) {
  36608. r = c - 1;
  36609. } else {
  36610. l = c;
  36611. }
  36612. }
  36613. if (ranges[l].start <= code && code <= ranges[l].end) {
  36614. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36615. }
  36616. return {
  36617. charCode: code,
  36618. glyphId: gid
  36619. };
  36620. }
  36621. function compileGlyf(code, cmds, font) {
  36622. function moveTo(x, y) {
  36623. cmds.push({
  36624. cmd: 'moveTo',
  36625. args: [
  36626. x,
  36627. y
  36628. ]
  36629. });
  36630. }
  36631. function lineTo(x, y) {
  36632. cmds.push({
  36633. cmd: 'lineTo',
  36634. args: [
  36635. x,
  36636. y
  36637. ]
  36638. });
  36639. }
  36640. function quadraticCurveTo(xa, ya, x, y) {
  36641. cmds.push({
  36642. cmd: 'quadraticCurveTo',
  36643. args: [
  36644. xa,
  36645. ya,
  36646. x,
  36647. y
  36648. ]
  36649. });
  36650. }
  36651. var i = 0;
  36652. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36653. var flags;
  36654. var x = 0, y = 0;
  36655. i += 10;
  36656. if (numberOfContours < 0) {
  36657. do {
  36658. flags = code[i] << 8 | code[i + 1];
  36659. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36660. i += 4;
  36661. var arg1, arg2;
  36662. if (flags & 0x01) {
  36663. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36664. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36665. i += 4;
  36666. } else {
  36667. arg1 = code[i++];
  36668. arg2 = code[i++];
  36669. }
  36670. if (flags & 0x02) {
  36671. x = arg1;
  36672. y = arg2;
  36673. } else {
  36674. x = 0;
  36675. y = 0;
  36676. }
  36677. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36678. if (flags & 0x08) {
  36679. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36680. i += 2;
  36681. } else if (flags & 0x40) {
  36682. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36683. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36684. i += 4;
  36685. } else if (flags & 0x80) {
  36686. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36687. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36688. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36689. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36690. i += 8;
  36691. }
  36692. var subglyph = font.glyphs[glyphIndex];
  36693. if (subglyph) {
  36694. cmds.push({ cmd: 'save' });
  36695. cmds.push({
  36696. cmd: 'transform',
  36697. args: [
  36698. scaleX,
  36699. scale01,
  36700. scale10,
  36701. scaleY,
  36702. x,
  36703. y
  36704. ]
  36705. });
  36706. compileGlyf(subglyph, cmds, font);
  36707. cmds.push({ cmd: 'restore' });
  36708. }
  36709. } while (flags & 0x20);
  36710. } else {
  36711. var endPtsOfContours = [];
  36712. var j, jj;
  36713. for (j = 0; j < numberOfContours; j++) {
  36714. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36715. i += 2;
  36716. }
  36717. var instructionLength = code[i] << 8 | code[i + 1];
  36718. i += 2 + instructionLength;
  36719. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36720. var points = [];
  36721. while (points.length < numberOfPoints) {
  36722. flags = code[i++];
  36723. var repeat = 1;
  36724. if (flags & 0x08) {
  36725. repeat += code[i++];
  36726. }
  36727. while (repeat-- > 0) {
  36728. points.push({ flags: flags });
  36729. }
  36730. }
  36731. for (j = 0; j < numberOfPoints; j++) {
  36732. switch (points[j].flags & 0x12) {
  36733. case 0x00:
  36734. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36735. i += 2;
  36736. break;
  36737. case 0x02:
  36738. x -= code[i++];
  36739. break;
  36740. case 0x12:
  36741. x += code[i++];
  36742. break;
  36743. }
  36744. points[j].x = x;
  36745. }
  36746. for (j = 0; j < numberOfPoints; j++) {
  36747. switch (points[j].flags & 0x24) {
  36748. case 0x00:
  36749. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36750. i += 2;
  36751. break;
  36752. case 0x04:
  36753. y -= code[i++];
  36754. break;
  36755. case 0x24:
  36756. y += code[i++];
  36757. break;
  36758. }
  36759. points[j].y = y;
  36760. }
  36761. var startPoint = 0;
  36762. for (i = 0; i < numberOfContours; i++) {
  36763. var endPoint = endPtsOfContours[i];
  36764. var contour = points.slice(startPoint, endPoint + 1);
  36765. if (contour[0].flags & 1) {
  36766. contour.push(contour[0]);
  36767. } else if (contour[contour.length - 1].flags & 1) {
  36768. contour.unshift(contour[contour.length - 1]);
  36769. } else {
  36770. var p = {
  36771. flags: 1,
  36772. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36773. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36774. };
  36775. contour.unshift(p);
  36776. contour.push(p);
  36777. }
  36778. moveTo(contour[0].x, contour[0].y);
  36779. for (j = 1, jj = contour.length; j < jj; j++) {
  36780. if (contour[j].flags & 1) {
  36781. lineTo(contour[j].x, contour[j].y);
  36782. } else if (contour[j + 1].flags & 1) {
  36783. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36784. j++;
  36785. } else {
  36786. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36787. }
  36788. }
  36789. startPoint = endPoint + 1;
  36790. }
  36791. }
  36792. }
  36793. function compileCharString(code, cmds, font) {
  36794. var stack = [];
  36795. var x = 0, y = 0;
  36796. var stems = 0;
  36797. function moveTo(x, y) {
  36798. cmds.push({
  36799. cmd: 'moveTo',
  36800. args: [
  36801. x,
  36802. y
  36803. ]
  36804. });
  36805. }
  36806. function lineTo(x, y) {
  36807. cmds.push({
  36808. cmd: 'lineTo',
  36809. args: [
  36810. x,
  36811. y
  36812. ]
  36813. });
  36814. }
  36815. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36816. cmds.push({
  36817. cmd: 'bezierCurveTo',
  36818. args: [
  36819. x1,
  36820. y1,
  36821. x2,
  36822. y2,
  36823. x,
  36824. y
  36825. ]
  36826. });
  36827. }
  36828. function parse(code) {
  36829. var i = 0;
  36830. while (i < code.length) {
  36831. var stackClean = false;
  36832. var v = code[i++];
  36833. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  36834. switch (v) {
  36835. case 1:
  36836. stems += stack.length >> 1;
  36837. stackClean = true;
  36838. break;
  36839. case 3:
  36840. stems += stack.length >> 1;
  36841. stackClean = true;
  36842. break;
  36843. case 4:
  36844. y += stack.pop();
  36845. moveTo(x, y);
  36846. stackClean = true;
  36847. break;
  36848. case 5:
  36849. while (stack.length > 0) {
  36850. x += stack.shift();
  36851. y += stack.shift();
  36852. lineTo(x, y);
  36853. }
  36854. break;
  36855. case 6:
  36856. while (stack.length > 0) {
  36857. x += stack.shift();
  36858. lineTo(x, y);
  36859. if (stack.length === 0) {
  36860. break;
  36861. }
  36862. y += stack.shift();
  36863. lineTo(x, y);
  36864. }
  36865. break;
  36866. case 7:
  36867. while (stack.length > 0) {
  36868. y += stack.shift();
  36869. lineTo(x, y);
  36870. if (stack.length === 0) {
  36871. break;
  36872. }
  36873. x += stack.shift();
  36874. lineTo(x, y);
  36875. }
  36876. break;
  36877. case 8:
  36878. while (stack.length > 0) {
  36879. xa = x + stack.shift();
  36880. ya = y + stack.shift();
  36881. xb = xa + stack.shift();
  36882. yb = ya + stack.shift();
  36883. x = xb + stack.shift();
  36884. y = yb + stack.shift();
  36885. bezierCurveTo(xa, ya, xb, yb, x, y);
  36886. }
  36887. break;
  36888. case 10:
  36889. n = stack.pop() + font.subrsBias;
  36890. subrCode = font.subrs[n];
  36891. if (subrCode) {
  36892. parse(subrCode);
  36893. }
  36894. break;
  36895. case 11:
  36896. return;
  36897. case 12:
  36898. v = code[i++];
  36899. switch (v) {
  36900. case 34:
  36901. xa = x + stack.shift();
  36902. xb = xa + stack.shift();
  36903. y1 = y + stack.shift();
  36904. x = xb + stack.shift();
  36905. bezierCurveTo(xa, y, xb, y1, x, y1);
  36906. xa = x + stack.shift();
  36907. xb = xa + stack.shift();
  36908. x = xb + stack.shift();
  36909. bezierCurveTo(xa, y1, xb, y, x, y);
  36910. break;
  36911. case 35:
  36912. xa = x + stack.shift();
  36913. ya = y + stack.shift();
  36914. xb = xa + stack.shift();
  36915. yb = ya + stack.shift();
  36916. x = xb + stack.shift();
  36917. y = yb + stack.shift();
  36918. bezierCurveTo(xa, ya, xb, yb, x, y);
  36919. xa = x + stack.shift();
  36920. ya = y + stack.shift();
  36921. xb = xa + stack.shift();
  36922. yb = ya + stack.shift();
  36923. x = xb + stack.shift();
  36924. y = yb + stack.shift();
  36925. bezierCurveTo(xa, ya, xb, yb, x, y);
  36926. stack.pop();
  36927. break;
  36928. case 36:
  36929. xa = x + stack.shift();
  36930. y1 = y + stack.shift();
  36931. xb = xa + stack.shift();
  36932. y2 = y1 + stack.shift();
  36933. x = xb + stack.shift();
  36934. bezierCurveTo(xa, y1, xb, y2, x, y2);
  36935. xa = x + stack.shift();
  36936. xb = xa + stack.shift();
  36937. y3 = y2 + stack.shift();
  36938. x = xb + stack.shift();
  36939. bezierCurveTo(xa, y2, xb, y3, x, y);
  36940. break;
  36941. case 37:
  36942. var x0 = x, y0 = y;
  36943. xa = x + stack.shift();
  36944. ya = y + stack.shift();
  36945. xb = xa + stack.shift();
  36946. yb = ya + stack.shift();
  36947. x = xb + stack.shift();
  36948. y = yb + stack.shift();
  36949. bezierCurveTo(xa, ya, xb, yb, x, y);
  36950. xa = x + stack.shift();
  36951. ya = y + stack.shift();
  36952. xb = xa + stack.shift();
  36953. yb = ya + stack.shift();
  36954. x = xb;
  36955. y = yb;
  36956. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  36957. x += stack.shift();
  36958. } else {
  36959. y += stack.shift();
  36960. }
  36961. bezierCurveTo(xa, ya, xb, yb, x, y);
  36962. break;
  36963. default:
  36964. error('unknown operator: 12 ' + v);
  36965. }
  36966. break;
  36967. case 14:
  36968. if (stack.length >= 4) {
  36969. var achar = stack.pop();
  36970. var bchar = stack.pop();
  36971. y = stack.pop();
  36972. x = stack.pop();
  36973. cmds.push({ cmd: 'save' });
  36974. cmds.push({
  36975. cmd: 'translate',
  36976. args: [
  36977. x,
  36978. y
  36979. ]
  36980. });
  36981. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  36982. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36983. cmds.push({ cmd: 'restore' });
  36984. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  36985. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36986. }
  36987. return;
  36988. case 18:
  36989. stems += stack.length >> 1;
  36990. stackClean = true;
  36991. break;
  36992. case 19:
  36993. stems += stack.length >> 1;
  36994. i += stems + 7 >> 3;
  36995. stackClean = true;
  36996. break;
  36997. case 20:
  36998. stems += stack.length >> 1;
  36999. i += stems + 7 >> 3;
  37000. stackClean = true;
  37001. break;
  37002. case 21:
  37003. y += stack.pop();
  37004. x += stack.pop();
  37005. moveTo(x, y);
  37006. stackClean = true;
  37007. break;
  37008. case 22:
  37009. x += stack.pop();
  37010. moveTo(x, y);
  37011. stackClean = true;
  37012. break;
  37013. case 23:
  37014. stems += stack.length >> 1;
  37015. stackClean = true;
  37016. break;
  37017. case 24:
  37018. while (stack.length > 2) {
  37019. xa = x + stack.shift();
  37020. ya = y + stack.shift();
  37021. xb = xa + stack.shift();
  37022. yb = ya + stack.shift();
  37023. x = xb + stack.shift();
  37024. y = yb + stack.shift();
  37025. bezierCurveTo(xa, ya, xb, yb, x, y);
  37026. }
  37027. x += stack.shift();
  37028. y += stack.shift();
  37029. lineTo(x, y);
  37030. break;
  37031. case 25:
  37032. while (stack.length > 6) {
  37033. x += stack.shift();
  37034. y += stack.shift();
  37035. lineTo(x, y);
  37036. }
  37037. xa = x + stack.shift();
  37038. ya = y + stack.shift();
  37039. xb = xa + stack.shift();
  37040. yb = ya + stack.shift();
  37041. x = xb + stack.shift();
  37042. y = yb + stack.shift();
  37043. bezierCurveTo(xa, ya, xb, yb, x, y);
  37044. break;
  37045. case 26:
  37046. if (stack.length % 2) {
  37047. x += stack.shift();
  37048. }
  37049. while (stack.length > 0) {
  37050. xa = x;
  37051. ya = y + stack.shift();
  37052. xb = xa + stack.shift();
  37053. yb = ya + stack.shift();
  37054. x = xb;
  37055. y = yb + stack.shift();
  37056. bezierCurveTo(xa, ya, xb, yb, x, y);
  37057. }
  37058. break;
  37059. case 27:
  37060. if (stack.length % 2) {
  37061. y += stack.shift();
  37062. }
  37063. while (stack.length > 0) {
  37064. xa = x + stack.shift();
  37065. ya = y;
  37066. xb = xa + stack.shift();
  37067. yb = ya + stack.shift();
  37068. x = xb + stack.shift();
  37069. y = yb;
  37070. bezierCurveTo(xa, ya, xb, yb, x, y);
  37071. }
  37072. break;
  37073. case 28:
  37074. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37075. i += 2;
  37076. break;
  37077. case 29:
  37078. n = stack.pop() + font.gsubrsBias;
  37079. subrCode = font.gsubrs[n];
  37080. if (subrCode) {
  37081. parse(subrCode);
  37082. }
  37083. break;
  37084. case 30:
  37085. while (stack.length > 0) {
  37086. xa = x;
  37087. ya = y + stack.shift();
  37088. xb = xa + stack.shift();
  37089. yb = ya + stack.shift();
  37090. x = xb + stack.shift();
  37091. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37092. bezierCurveTo(xa, ya, xb, yb, x, y);
  37093. if (stack.length === 0) {
  37094. break;
  37095. }
  37096. xa = x + stack.shift();
  37097. ya = y;
  37098. xb = xa + stack.shift();
  37099. yb = ya + stack.shift();
  37100. y = yb + stack.shift();
  37101. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37102. bezierCurveTo(xa, ya, xb, yb, x, y);
  37103. }
  37104. break;
  37105. case 31:
  37106. while (stack.length > 0) {
  37107. xa = x + stack.shift();
  37108. ya = y;
  37109. xb = xa + stack.shift();
  37110. yb = ya + stack.shift();
  37111. y = yb + stack.shift();
  37112. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37113. bezierCurveTo(xa, ya, xb, yb, x, y);
  37114. if (stack.length === 0) {
  37115. break;
  37116. }
  37117. xa = x;
  37118. ya = y + stack.shift();
  37119. xb = xa + stack.shift();
  37120. yb = ya + stack.shift();
  37121. x = xb + stack.shift();
  37122. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37123. bezierCurveTo(xa, ya, xb, yb, x, y);
  37124. }
  37125. break;
  37126. default:
  37127. if (v < 32) {
  37128. error('unknown operator: ' + v);
  37129. }
  37130. if (v < 247) {
  37131. stack.push(v - 139);
  37132. } else if (v < 251) {
  37133. stack.push((v - 247) * 256 + code[i++] + 108);
  37134. } else if (v < 255) {
  37135. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37136. } else {
  37137. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37138. i += 4;
  37139. }
  37140. break;
  37141. }
  37142. if (stackClean) {
  37143. stack.length = 0;
  37144. }
  37145. }
  37146. }
  37147. parse(code);
  37148. }
  37149. var noop = '';
  37150. function CompiledFont(fontMatrix) {
  37151. this.compiledGlyphs = Object.create(null);
  37152. this.compiledCharCodeToGlyphId = Object.create(null);
  37153. this.fontMatrix = fontMatrix;
  37154. }
  37155. CompiledFont.prototype = {
  37156. getPathJs: function (unicode) {
  37157. var cmap = lookupCmap(this.cmap, unicode);
  37158. var fn = this.compiledGlyphs[cmap.glyphId];
  37159. if (!fn) {
  37160. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37161. this.compiledGlyphs[cmap.glyphId] = fn;
  37162. }
  37163. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37164. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37165. }
  37166. return fn;
  37167. },
  37168. compileGlyph: function (code) {
  37169. if (!code || code.length === 0 || code[0] === 14) {
  37170. return noop;
  37171. }
  37172. var cmds = [];
  37173. cmds.push({ cmd: 'save' });
  37174. cmds.push({
  37175. cmd: 'transform',
  37176. args: this.fontMatrix.slice()
  37177. });
  37178. cmds.push({
  37179. cmd: 'scale',
  37180. args: [
  37181. 'size',
  37182. '-size'
  37183. ]
  37184. });
  37185. this.compileGlyphImpl(code, cmds);
  37186. cmds.push({ cmd: 'restore' });
  37187. return cmds;
  37188. },
  37189. compileGlyphImpl: function () {
  37190. error('Children classes should implement this.');
  37191. },
  37192. hasBuiltPath: function (unicode) {
  37193. var cmap = lookupCmap(this.cmap, unicode);
  37194. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37195. }
  37196. };
  37197. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37198. fontMatrix = fontMatrix || [
  37199. 0.000488,
  37200. 0,
  37201. 0,
  37202. 0.000488,
  37203. 0,
  37204. 0
  37205. ];
  37206. CompiledFont.call(this, fontMatrix);
  37207. this.glyphs = glyphs;
  37208. this.cmap = cmap;
  37209. }
  37210. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37211. compileGlyphImpl: function (code, cmds) {
  37212. compileGlyf(code, cmds, this);
  37213. }
  37214. });
  37215. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37216. fontMatrix = fontMatrix || [
  37217. 0.001,
  37218. 0,
  37219. 0,
  37220. 0.001,
  37221. 0,
  37222. 0
  37223. ];
  37224. CompiledFont.call(this, fontMatrix);
  37225. this.glyphs = cffInfo.glyphs;
  37226. this.gsubrs = cffInfo.gsubrs || [];
  37227. this.subrs = cffInfo.subrs || [];
  37228. this.cmap = cmap;
  37229. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37230. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37231. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37232. }
  37233. Util.inherit(Type2Compiled, CompiledFont, {
  37234. compileGlyphImpl: function (code, cmds) {
  37235. compileCharString(code, cmds, this);
  37236. }
  37237. });
  37238. return {
  37239. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37240. var data = new Uint8Array(font.data);
  37241. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37242. var numTables = getUshort(data, 4);
  37243. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37244. var tag = bytesToString(data.subarray(p, p + 4));
  37245. var offset = getLong(data, p + 8);
  37246. var length = getLong(data, p + 12);
  37247. switch (tag) {
  37248. case 'cmap':
  37249. cmap = parseCmap(data, offset, offset + length);
  37250. break;
  37251. case 'glyf':
  37252. glyf = data.subarray(offset, offset + length);
  37253. break;
  37254. case 'loca':
  37255. loca = data.subarray(offset, offset + length);
  37256. break;
  37257. case 'head':
  37258. unitsPerEm = getUshort(data, offset + 18);
  37259. indexToLocFormat = getUshort(data, offset + 50);
  37260. break;
  37261. case 'CFF ':
  37262. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37263. break;
  37264. }
  37265. }
  37266. if (glyf) {
  37267. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37268. 1 / unitsPerEm,
  37269. 0,
  37270. 0,
  37271. 1 / unitsPerEm,
  37272. 0,
  37273. 0
  37274. ];
  37275. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37276. } else {
  37277. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37278. }
  37279. }
  37280. };
  37281. }();
  37282. exports.FontRendererFactory = FontRendererFactory;
  37283. }));
  37284. (function (root, factory) {
  37285. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37286. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37287. var MissingDataException = sharedUtil.MissingDataException;
  37288. var StreamType = sharedUtil.StreamType;
  37289. var assert = sharedUtil.assert;
  37290. var error = sharedUtil.error;
  37291. var info = sharedUtil.info;
  37292. var isArray = sharedUtil.isArray;
  37293. var isInt = sharedUtil.isInt;
  37294. var isNum = sharedUtil.isNum;
  37295. var isString = sharedUtil.isString;
  37296. var warn = sharedUtil.warn;
  37297. var Cmd = corePrimitives.Cmd;
  37298. var Dict = corePrimitives.Dict;
  37299. var Name = corePrimitives.Name;
  37300. var Ref = corePrimitives.Ref;
  37301. var isCmd = corePrimitives.isCmd;
  37302. var isDict = corePrimitives.isDict;
  37303. var isName = corePrimitives.isName;
  37304. var Ascii85Stream = coreStream.Ascii85Stream;
  37305. var AsciiHexStream = coreStream.AsciiHexStream;
  37306. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37307. var FlateStream = coreStream.FlateStream;
  37308. var Jbig2Stream = coreStream.Jbig2Stream;
  37309. var JpegStream = coreStream.JpegStream;
  37310. var JpxStream = coreStream.JpxStream;
  37311. var LZWStream = coreStream.LZWStream;
  37312. var NullStream = coreStream.NullStream;
  37313. var PredictorStream = coreStream.PredictorStream;
  37314. var RunLengthStream = coreStream.RunLengthStream;
  37315. var EOF = {};
  37316. function isEOF(v) {
  37317. return v === EOF;
  37318. }
  37319. var MAX_LENGTH_TO_CACHE = 1000;
  37320. var Parser = function ParserClosure() {
  37321. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37322. this.lexer = lexer;
  37323. this.allowStreams = allowStreams;
  37324. this.xref = xref;
  37325. this.recoveryMode = recoveryMode || false;
  37326. this.imageCache = Object.create(null);
  37327. this.refill();
  37328. }
  37329. Parser.prototype = {
  37330. refill: function Parser_refill() {
  37331. this.buf1 = this.lexer.getObj();
  37332. this.buf2 = this.lexer.getObj();
  37333. },
  37334. shift: function Parser_shift() {
  37335. if (isCmd(this.buf2, 'ID')) {
  37336. this.buf1 = this.buf2;
  37337. this.buf2 = null;
  37338. } else {
  37339. this.buf1 = this.buf2;
  37340. this.buf2 = this.lexer.getObj();
  37341. }
  37342. },
  37343. tryShift: function Parser_tryShift() {
  37344. try {
  37345. this.shift();
  37346. return true;
  37347. } catch (e) {
  37348. if (e instanceof MissingDataException) {
  37349. throw e;
  37350. }
  37351. return false;
  37352. }
  37353. },
  37354. getObj: function Parser_getObj(cipherTransform) {
  37355. var buf1 = this.buf1;
  37356. this.shift();
  37357. if (buf1 instanceof Cmd) {
  37358. switch (buf1.cmd) {
  37359. case 'BI':
  37360. return this.makeInlineImage(cipherTransform);
  37361. case '[':
  37362. var array = [];
  37363. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37364. array.push(this.getObj(cipherTransform));
  37365. }
  37366. if (isEOF(this.buf1)) {
  37367. if (!this.recoveryMode) {
  37368. error('End of file inside array');
  37369. }
  37370. return array;
  37371. }
  37372. this.shift();
  37373. return array;
  37374. case '<<':
  37375. var dict = new Dict(this.xref);
  37376. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37377. if (!isName(this.buf1)) {
  37378. info('Malformed dictionary: key must be a name object');
  37379. this.shift();
  37380. continue;
  37381. }
  37382. var key = this.buf1.name;
  37383. this.shift();
  37384. if (isEOF(this.buf1)) {
  37385. break;
  37386. }
  37387. dict.set(key, this.getObj(cipherTransform));
  37388. }
  37389. if (isEOF(this.buf1)) {
  37390. if (!this.recoveryMode) {
  37391. error('End of file inside dictionary');
  37392. }
  37393. return dict;
  37394. }
  37395. if (isCmd(this.buf2, 'stream')) {
  37396. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37397. }
  37398. this.shift();
  37399. return dict;
  37400. default:
  37401. return buf1;
  37402. }
  37403. }
  37404. if (isInt(buf1)) {
  37405. var num = buf1;
  37406. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37407. var ref = new Ref(num, this.buf1);
  37408. this.shift();
  37409. this.shift();
  37410. return ref;
  37411. }
  37412. return num;
  37413. }
  37414. if (isString(buf1)) {
  37415. var str = buf1;
  37416. if (cipherTransform) {
  37417. str = cipherTransform.decryptString(str);
  37418. }
  37419. return str;
  37420. }
  37421. return buf1;
  37422. },
  37423. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37424. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37425. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37426. while ((ch = stream.getByte()) !== -1) {
  37427. if (state === 0) {
  37428. state = ch === E ? 1 : 0;
  37429. } else if (state === 1) {
  37430. state = ch === I ? 2 : 0;
  37431. } else {
  37432. assert(state === 2);
  37433. if (ch === SPACE || ch === LF || ch === CR) {
  37434. n = 5;
  37435. followingBytes = stream.peekBytes(n);
  37436. for (i = 0; i < n; i++) {
  37437. ch = followingBytes[i];
  37438. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37439. state = 0;
  37440. break;
  37441. }
  37442. }
  37443. if (state === 2) {
  37444. break;
  37445. }
  37446. } else
  37447. {
  37448. state = 0;
  37449. }
  37450. }
  37451. }
  37452. return stream.pos - 4 - startPos;
  37453. },
  37454. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37455. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37456. while ((b = stream.getByte()) !== -1) {
  37457. if (b !== 0xFF) {
  37458. continue;
  37459. }
  37460. switch (stream.getByte()) {
  37461. case 0x00:
  37462. break;
  37463. case 0xFF:
  37464. stream.skip(-1);
  37465. break;
  37466. case 0xD9:
  37467. foundEOI = true;
  37468. break;
  37469. case 0xC0:
  37470. case 0xC1:
  37471. case 0xC2:
  37472. case 0xC3:
  37473. case 0xC5:
  37474. case 0xC6:
  37475. case 0xC7:
  37476. case 0xC9:
  37477. case 0xCA:
  37478. case 0xCB:
  37479. case 0xCD:
  37480. case 0xCE:
  37481. case 0xCF:
  37482. case 0xC4:
  37483. case 0xCC:
  37484. case 0xDA:
  37485. case 0xDB:
  37486. case 0xDC:
  37487. case 0xDD:
  37488. case 0xDE:
  37489. case 0xDF:
  37490. case 0xE0:
  37491. case 0xE1:
  37492. case 0xE2:
  37493. case 0xE3:
  37494. case 0xE4:
  37495. case 0xE5:
  37496. case 0xE6:
  37497. case 0xE7:
  37498. case 0xE8:
  37499. case 0xE9:
  37500. case 0xEA:
  37501. case 0xEB:
  37502. case 0xEC:
  37503. case 0xED:
  37504. case 0xEE:
  37505. case 0xEF:
  37506. case 0xFE:
  37507. markerLength = stream.getUint16();
  37508. if (markerLength > 2) {
  37509. stream.skip(markerLength - 2);
  37510. } else
  37511. {
  37512. stream.skip(-2);
  37513. }
  37514. break;
  37515. }
  37516. if (foundEOI) {
  37517. break;
  37518. }
  37519. }
  37520. length = stream.pos - startPos;
  37521. if (b === -1) {
  37522. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37523. stream.skip(-length);
  37524. return this.findDefaultInlineStreamEnd(stream);
  37525. }
  37526. this.inlineStreamSkipEI(stream);
  37527. return length;
  37528. },
  37529. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37530. var TILDE = 0x7E, GT = 0x3E;
  37531. var startPos = stream.pos, ch, length;
  37532. while ((ch = stream.getByte()) !== -1) {
  37533. if (ch === TILDE && stream.peekByte() === GT) {
  37534. stream.skip();
  37535. break;
  37536. }
  37537. }
  37538. length = stream.pos - startPos;
  37539. if (ch === -1) {
  37540. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37541. stream.skip(-length);
  37542. return this.findDefaultInlineStreamEnd(stream);
  37543. }
  37544. this.inlineStreamSkipEI(stream);
  37545. return length;
  37546. },
  37547. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37548. var GT = 0x3E;
  37549. var startPos = stream.pos, ch, length;
  37550. while ((ch = stream.getByte()) !== -1) {
  37551. if (ch === GT) {
  37552. break;
  37553. }
  37554. }
  37555. length = stream.pos - startPos;
  37556. if (ch === -1) {
  37557. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37558. stream.skip(-length);
  37559. return this.findDefaultInlineStreamEnd(stream);
  37560. }
  37561. this.inlineStreamSkipEI(stream);
  37562. return length;
  37563. },
  37564. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37565. var E = 0x45, I = 0x49;
  37566. var state = 0, ch;
  37567. while ((ch = stream.getByte()) !== -1) {
  37568. if (state === 0) {
  37569. state = ch === E ? 1 : 0;
  37570. } else if (state === 1) {
  37571. state = ch === I ? 2 : 0;
  37572. } else if (state === 2) {
  37573. break;
  37574. }
  37575. }
  37576. },
  37577. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37578. var lexer = this.lexer;
  37579. var stream = lexer.stream;
  37580. var dict = new Dict(this.xref);
  37581. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37582. if (!isName(this.buf1)) {
  37583. error('Dictionary key must be a name object');
  37584. }
  37585. var key = this.buf1.name;
  37586. this.shift();
  37587. if (isEOF(this.buf1)) {
  37588. break;
  37589. }
  37590. dict.set(key, this.getObj(cipherTransform));
  37591. }
  37592. var filter = dict.get('Filter', 'F'), filterName;
  37593. if (isName(filter)) {
  37594. filterName = filter.name;
  37595. } else if (isArray(filter) && isName(filter[0])) {
  37596. filterName = filter[0].name;
  37597. }
  37598. var startPos = stream.pos, length, i, ii;
  37599. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37600. length = this.findDCTDecodeInlineStreamEnd(stream);
  37601. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37602. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37603. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37604. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37605. } else {
  37606. length = this.findDefaultInlineStreamEnd(stream);
  37607. }
  37608. var imageStream = stream.makeSubStream(startPos, length, dict);
  37609. var adler32;
  37610. if (length < MAX_LENGTH_TO_CACHE) {
  37611. var imageBytes = imageStream.getBytes();
  37612. imageStream.reset();
  37613. var a = 1;
  37614. var b = 0;
  37615. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37616. a += imageBytes[i] & 0xff;
  37617. b += a;
  37618. }
  37619. adler32 = b % 65521 << 16 | a % 65521;
  37620. if (this.imageCache.adler32 === adler32) {
  37621. this.buf2 = Cmd.get('EI');
  37622. this.shift();
  37623. this.imageCache[adler32].reset();
  37624. return this.imageCache[adler32];
  37625. }
  37626. }
  37627. if (cipherTransform) {
  37628. imageStream = cipherTransform.createStream(imageStream, length);
  37629. }
  37630. imageStream = this.filter(imageStream, dict, length);
  37631. imageStream.dict = dict;
  37632. if (adler32 !== undefined) {
  37633. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37634. this.imageCache[adler32] = imageStream;
  37635. }
  37636. this.buf2 = Cmd.get('EI');
  37637. this.shift();
  37638. return imageStream;
  37639. },
  37640. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37641. var lexer = this.lexer;
  37642. var stream = lexer.stream;
  37643. lexer.skipToNextLine();
  37644. var pos = stream.pos - 1;
  37645. var length = dict.get('Length');
  37646. if (!isInt(length)) {
  37647. info('Bad ' + length + ' attribute in stream');
  37648. length = 0;
  37649. }
  37650. stream.pos = pos + length;
  37651. lexer.nextChar();
  37652. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37653. this.shift();
  37654. } else
  37655. {
  37656. stream.pos = pos;
  37657. var SCAN_BLOCK_SIZE = 2048;
  37658. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37659. var ENDSTREAM_SIGNATURE = [
  37660. 0x65,
  37661. 0x6E,
  37662. 0x64,
  37663. 0x73,
  37664. 0x74,
  37665. 0x72,
  37666. 0x65,
  37667. 0x61,
  37668. 0x6D
  37669. ];
  37670. var skipped = 0, found = false, i, j;
  37671. while (stream.pos < stream.end) {
  37672. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37673. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37674. if (scanLength <= 0) {
  37675. break;
  37676. }
  37677. found = false;
  37678. i = 0;
  37679. while (i < scanLength) {
  37680. j = 0;
  37681. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37682. j++;
  37683. }
  37684. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37685. found = true;
  37686. break;
  37687. }
  37688. i++;
  37689. }
  37690. if (found) {
  37691. skipped += i;
  37692. stream.pos += i;
  37693. break;
  37694. }
  37695. skipped += scanLength;
  37696. stream.pos += scanLength;
  37697. }
  37698. if (!found) {
  37699. error('Missing endstream');
  37700. }
  37701. length = skipped;
  37702. lexer.nextChar();
  37703. this.shift();
  37704. this.shift();
  37705. }
  37706. this.shift();
  37707. stream = stream.makeSubStream(pos, length, dict);
  37708. if (cipherTransform) {
  37709. stream = cipherTransform.createStream(stream, length);
  37710. }
  37711. stream = this.filter(stream, dict, length);
  37712. stream.dict = dict;
  37713. return stream;
  37714. },
  37715. filter: function Parser_filter(stream, dict, length) {
  37716. var filter = dict.get('Filter', 'F');
  37717. var params = dict.get('DecodeParms', 'DP');
  37718. if (isName(filter)) {
  37719. if (isArray(params)) {
  37720. params = params[0];
  37721. }
  37722. return this.makeFilter(stream, filter.name, length, params);
  37723. }
  37724. var maybeLength = length;
  37725. if (isArray(filter)) {
  37726. var filterArray = filter;
  37727. var paramsArray = params;
  37728. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37729. filter = filterArray[i];
  37730. if (!isName(filter)) {
  37731. error('Bad filter name: ' + filter);
  37732. }
  37733. params = null;
  37734. if (isArray(paramsArray) && i in paramsArray) {
  37735. params = paramsArray[i];
  37736. }
  37737. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37738. maybeLength = null;
  37739. }
  37740. }
  37741. return stream;
  37742. },
  37743. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37744. if (maybeLength === 0) {
  37745. warn('Empty "' + name + '" stream.');
  37746. return new NullStream(stream);
  37747. }
  37748. try {
  37749. if (params && this.xref) {
  37750. params = this.xref.fetchIfRef(params);
  37751. }
  37752. var xrefStreamStats = this.xref.stats.streamTypes;
  37753. if (name === 'FlateDecode' || name === 'Fl') {
  37754. xrefStreamStats[StreamType.FLATE] = true;
  37755. if (params) {
  37756. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37757. }
  37758. return new FlateStream(stream, maybeLength);
  37759. }
  37760. if (name === 'LZWDecode' || name === 'LZW') {
  37761. xrefStreamStats[StreamType.LZW] = true;
  37762. var earlyChange = 1;
  37763. if (params) {
  37764. if (params.has('EarlyChange')) {
  37765. earlyChange = params.get('EarlyChange');
  37766. }
  37767. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37768. }
  37769. return new LZWStream(stream, maybeLength, earlyChange);
  37770. }
  37771. if (name === 'DCTDecode' || name === 'DCT') {
  37772. xrefStreamStats[StreamType.DCT] = true;
  37773. return new JpegStream(stream, maybeLength, stream.dict, params);
  37774. }
  37775. if (name === 'JPXDecode' || name === 'JPX') {
  37776. xrefStreamStats[StreamType.JPX] = true;
  37777. return new JpxStream(stream, maybeLength, stream.dict, params);
  37778. }
  37779. if (name === 'ASCII85Decode' || name === 'A85') {
  37780. xrefStreamStats[StreamType.A85] = true;
  37781. return new Ascii85Stream(stream, maybeLength);
  37782. }
  37783. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37784. xrefStreamStats[StreamType.AHX] = true;
  37785. return new AsciiHexStream(stream, maybeLength);
  37786. }
  37787. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37788. xrefStreamStats[StreamType.CCF] = true;
  37789. return new CCITTFaxStream(stream, maybeLength, params);
  37790. }
  37791. if (name === 'RunLengthDecode' || name === 'RL') {
  37792. xrefStreamStats[StreamType.RL] = true;
  37793. return new RunLengthStream(stream, maybeLength);
  37794. }
  37795. if (name === 'JBIG2Decode') {
  37796. xrefStreamStats[StreamType.JBIG] = true;
  37797. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37798. }
  37799. warn('filter "' + name + '" not supported yet');
  37800. return stream;
  37801. } catch (ex) {
  37802. if (ex instanceof MissingDataException) {
  37803. throw ex;
  37804. }
  37805. warn('Invalid stream: \"' + ex + '\"');
  37806. return new NullStream(stream);
  37807. }
  37808. }
  37809. };
  37810. return Parser;
  37811. }();
  37812. var Lexer = function LexerClosure() {
  37813. function Lexer(stream, knownCommands) {
  37814. this.stream = stream;
  37815. this.nextChar();
  37816. this.strBuf = [];
  37817. this.knownCommands = knownCommands;
  37818. }
  37819. var specialChars = [
  37820. 1,
  37821. 0,
  37822. 0,
  37823. 0,
  37824. 0,
  37825. 0,
  37826. 0,
  37827. 0,
  37828. 0,
  37829. 1,
  37830. 1,
  37831. 0,
  37832. 1,
  37833. 1,
  37834. 0,
  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. 1,
  37853. 0,
  37854. 0,
  37855. 0,
  37856. 0,
  37857. 2,
  37858. 0,
  37859. 0,
  37860. 2,
  37861. 2,
  37862. 0,
  37863. 0,
  37864. 0,
  37865. 0,
  37866. 0,
  37867. 2,
  37868. 0,
  37869. 0,
  37870. 0,
  37871. 0,
  37872. 0,
  37873. 0,
  37874. 0,
  37875. 0,
  37876. 0,
  37877. 0,
  37878. 0,
  37879. 0,
  37880. 2,
  37881. 0,
  37882. 2,
  37883. 0,
  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. 2,
  37912. 0,
  37913. 2,
  37914. 0,
  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. 2,
  37944. 0,
  37945. 2,
  37946. 0,
  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. ];
  38077. function toHexDigit(ch) {
  38078. if (ch >= 0x30 && ch <= 0x39) {
  38079. return ch & 0x0F;
  38080. }
  38081. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38082. return (ch & 0x0F) + 9;
  38083. }
  38084. return -1;
  38085. }
  38086. Lexer.prototype = {
  38087. nextChar: function Lexer_nextChar() {
  38088. return this.currentChar = this.stream.getByte();
  38089. },
  38090. peekChar: function Lexer_peekChar() {
  38091. return this.stream.peekByte();
  38092. },
  38093. getNumber: function Lexer_getNumber() {
  38094. var ch = this.currentChar;
  38095. var eNotation = false;
  38096. var divideBy = 0;
  38097. var sign = 1;
  38098. if (ch === 0x2D) {
  38099. sign = -1;
  38100. ch = this.nextChar();
  38101. if (ch === 0x2D) {
  38102. ch = this.nextChar();
  38103. }
  38104. } else if (ch === 0x2B) {
  38105. ch = this.nextChar();
  38106. }
  38107. if (ch === 0x2E) {
  38108. divideBy = 10;
  38109. ch = this.nextChar();
  38110. }
  38111. if (ch < 0x30 || ch > 0x39) {
  38112. error('Invalid number: ' + String.fromCharCode(ch));
  38113. return 0;
  38114. }
  38115. var baseValue = ch - 0x30;
  38116. var powerValue = 0;
  38117. var powerValueSign = 1;
  38118. while ((ch = this.nextChar()) >= 0) {
  38119. if (0x30 <= ch && ch <= 0x39) {
  38120. var currentDigit = ch - 0x30;
  38121. if (eNotation) {
  38122. powerValue = powerValue * 10 + currentDigit;
  38123. } else {
  38124. if (divideBy !== 0) {
  38125. divideBy *= 10;
  38126. }
  38127. baseValue = baseValue * 10 + currentDigit;
  38128. }
  38129. } else if (ch === 0x2E) {
  38130. if (divideBy === 0) {
  38131. divideBy = 1;
  38132. } else {
  38133. break;
  38134. }
  38135. } else if (ch === 0x2D) {
  38136. warn('Badly formatted number');
  38137. } else if (ch === 0x45 || ch === 0x65) {
  38138. ch = this.peekChar();
  38139. if (ch === 0x2B || ch === 0x2D) {
  38140. powerValueSign = ch === 0x2D ? -1 : 1;
  38141. this.nextChar();
  38142. } else if (ch < 0x30 || ch > 0x39) {
  38143. break;
  38144. }
  38145. eNotation = true;
  38146. } else {
  38147. break;
  38148. }
  38149. }
  38150. if (divideBy !== 0) {
  38151. baseValue /= divideBy;
  38152. }
  38153. if (eNotation) {
  38154. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38155. }
  38156. return sign * baseValue;
  38157. },
  38158. getString: function Lexer_getString() {
  38159. var numParen = 1;
  38160. var done = false;
  38161. var strBuf = this.strBuf;
  38162. strBuf.length = 0;
  38163. var ch = this.nextChar();
  38164. while (true) {
  38165. var charBuffered = false;
  38166. switch (ch | 0) {
  38167. case -1:
  38168. warn('Unterminated string');
  38169. done = true;
  38170. break;
  38171. case 0x28:
  38172. ++numParen;
  38173. strBuf.push('(');
  38174. break;
  38175. case 0x29:
  38176. if (--numParen === 0) {
  38177. this.nextChar();
  38178. done = true;
  38179. } else {
  38180. strBuf.push(')');
  38181. }
  38182. break;
  38183. case 0x5C:
  38184. ch = this.nextChar();
  38185. switch (ch) {
  38186. case -1:
  38187. warn('Unterminated string');
  38188. done = true;
  38189. break;
  38190. case 0x6E:
  38191. strBuf.push('\n');
  38192. break;
  38193. case 0x72:
  38194. strBuf.push('\r');
  38195. break;
  38196. case 0x74:
  38197. strBuf.push('\t');
  38198. break;
  38199. case 0x62:
  38200. strBuf.push('\b');
  38201. break;
  38202. case 0x66:
  38203. strBuf.push('\f');
  38204. break;
  38205. case 0x5C:
  38206. case 0x28:
  38207. case 0x29:
  38208. strBuf.push(String.fromCharCode(ch));
  38209. break;
  38210. case 0x30:
  38211. case 0x31:
  38212. case 0x32:
  38213. case 0x33:
  38214. case 0x34:
  38215. case 0x35:
  38216. case 0x36:
  38217. case 0x37:
  38218. var x = ch & 0x0F;
  38219. ch = this.nextChar();
  38220. charBuffered = true;
  38221. if (ch >= 0x30 && ch <= 0x37) {
  38222. x = (x << 3) + (ch & 0x0F);
  38223. ch = this.nextChar();
  38224. if (ch >= 0x30 && ch <= 0x37) {
  38225. charBuffered = false;
  38226. x = (x << 3) + (ch & 0x0F);
  38227. }
  38228. }
  38229. strBuf.push(String.fromCharCode(x));
  38230. break;
  38231. case 0x0D:
  38232. if (this.peekChar() === 0x0A) {
  38233. this.nextChar();
  38234. }
  38235. break;
  38236. case 0x0A:
  38237. break;
  38238. default:
  38239. strBuf.push(String.fromCharCode(ch));
  38240. break;
  38241. }
  38242. break;
  38243. default:
  38244. strBuf.push(String.fromCharCode(ch));
  38245. break;
  38246. }
  38247. if (done) {
  38248. break;
  38249. }
  38250. if (!charBuffered) {
  38251. ch = this.nextChar();
  38252. }
  38253. }
  38254. return strBuf.join('');
  38255. },
  38256. getName: function Lexer_getName() {
  38257. var ch, previousCh;
  38258. var strBuf = this.strBuf;
  38259. strBuf.length = 0;
  38260. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38261. if (ch === 0x23) {
  38262. ch = this.nextChar();
  38263. if (specialChars[ch]) {
  38264. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38265. strBuf.push('#');
  38266. break;
  38267. }
  38268. var x = toHexDigit(ch);
  38269. if (x !== -1) {
  38270. previousCh = ch;
  38271. ch = this.nextChar();
  38272. var x2 = toHexDigit(ch);
  38273. if (x2 === -1) {
  38274. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38275. strBuf.push('#', String.fromCharCode(previousCh));
  38276. if (specialChars[ch]) {
  38277. break;
  38278. }
  38279. strBuf.push(String.fromCharCode(ch));
  38280. continue;
  38281. }
  38282. strBuf.push(String.fromCharCode(x << 4 | x2));
  38283. } else {
  38284. strBuf.push('#', String.fromCharCode(ch));
  38285. }
  38286. } else {
  38287. strBuf.push(String.fromCharCode(ch));
  38288. }
  38289. }
  38290. if (strBuf.length > 127) {
  38291. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38292. }
  38293. return Name.get(strBuf.join(''));
  38294. },
  38295. getHexString: function Lexer_getHexString() {
  38296. var strBuf = this.strBuf;
  38297. strBuf.length = 0;
  38298. var ch = this.currentChar;
  38299. var isFirstHex = true;
  38300. var firstDigit;
  38301. var secondDigit;
  38302. while (true) {
  38303. if (ch < 0) {
  38304. warn('Unterminated hex string');
  38305. break;
  38306. } else if (ch === 0x3E) {
  38307. this.nextChar();
  38308. break;
  38309. } else if (specialChars[ch] === 1) {
  38310. ch = this.nextChar();
  38311. continue;
  38312. } else {
  38313. if (isFirstHex) {
  38314. firstDigit = toHexDigit(ch);
  38315. if (firstDigit === -1) {
  38316. warn('Ignoring invalid character "' + ch + '" in hex string');
  38317. ch = this.nextChar();
  38318. continue;
  38319. }
  38320. } else {
  38321. secondDigit = toHexDigit(ch);
  38322. if (secondDigit === -1) {
  38323. warn('Ignoring invalid character "' + ch + '" in hex string');
  38324. ch = this.nextChar();
  38325. continue;
  38326. }
  38327. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38328. }
  38329. isFirstHex = !isFirstHex;
  38330. ch = this.nextChar();
  38331. }
  38332. }
  38333. return strBuf.join('');
  38334. },
  38335. getObj: function Lexer_getObj() {
  38336. var comment = false;
  38337. var ch = this.currentChar;
  38338. while (true) {
  38339. if (ch < 0) {
  38340. return EOF;
  38341. }
  38342. if (comment) {
  38343. if (ch === 0x0A || ch === 0x0D) {
  38344. comment = false;
  38345. }
  38346. } else if (ch === 0x25) {
  38347. comment = true;
  38348. } else if (specialChars[ch] !== 1) {
  38349. break;
  38350. }
  38351. ch = this.nextChar();
  38352. }
  38353. switch (ch | 0) {
  38354. case 0x30:
  38355. case 0x31:
  38356. case 0x32:
  38357. case 0x33:
  38358. case 0x34:
  38359. case 0x35:
  38360. case 0x36:
  38361. case 0x37:
  38362. case 0x38:
  38363. case 0x39:
  38364. case 0x2B:
  38365. case 0x2D:
  38366. case 0x2E:
  38367. return this.getNumber();
  38368. case 0x28:
  38369. return this.getString();
  38370. case 0x2F:
  38371. return this.getName();
  38372. case 0x5B:
  38373. this.nextChar();
  38374. return Cmd.get('[');
  38375. case 0x5D:
  38376. this.nextChar();
  38377. return Cmd.get(']');
  38378. case 0x3C:
  38379. ch = this.nextChar();
  38380. if (ch === 0x3C) {
  38381. this.nextChar();
  38382. return Cmd.get('<<');
  38383. }
  38384. return this.getHexString();
  38385. case 0x3E:
  38386. ch = this.nextChar();
  38387. if (ch === 0x3E) {
  38388. this.nextChar();
  38389. return Cmd.get('>>');
  38390. }
  38391. return Cmd.get('>');
  38392. case 0x7B:
  38393. this.nextChar();
  38394. return Cmd.get('{');
  38395. case 0x7D:
  38396. this.nextChar();
  38397. return Cmd.get('}');
  38398. case 0x29:
  38399. error('Illegal character: ' + ch);
  38400. break;
  38401. }
  38402. var str = String.fromCharCode(ch);
  38403. var knownCommands = this.knownCommands;
  38404. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38405. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38406. var possibleCommand = str + String.fromCharCode(ch);
  38407. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38408. break;
  38409. }
  38410. if (str.length === 128) {
  38411. error('Command token too long: ' + str.length);
  38412. }
  38413. str = possibleCommand;
  38414. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38415. }
  38416. if (str === 'true') {
  38417. return true;
  38418. }
  38419. if (str === 'false') {
  38420. return false;
  38421. }
  38422. if (str === 'null') {
  38423. return null;
  38424. }
  38425. return Cmd.get(str);
  38426. },
  38427. skipToNextLine: function Lexer_skipToNextLine() {
  38428. var ch = this.currentChar;
  38429. while (ch >= 0) {
  38430. if (ch === 0x0D) {
  38431. ch = this.nextChar();
  38432. if (ch === 0x0A) {
  38433. this.nextChar();
  38434. }
  38435. break;
  38436. } else if (ch === 0x0A) {
  38437. this.nextChar();
  38438. break;
  38439. }
  38440. ch = this.nextChar();
  38441. }
  38442. }
  38443. };
  38444. return Lexer;
  38445. }();
  38446. var Linearization = {
  38447. create: function LinearizationCreate(stream) {
  38448. function getInt(name, allowZeroValue) {
  38449. var obj = linDict.get(name);
  38450. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38451. return obj;
  38452. }
  38453. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38454. }
  38455. function getHints() {
  38456. var hints = linDict.get('H'), hintsLength, item;
  38457. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38458. for (var index = 0; index < hintsLength; index++) {
  38459. if (!(isInt(item = hints[index]) && item > 0)) {
  38460. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38461. }
  38462. }
  38463. return hints;
  38464. }
  38465. throw new Error('Hint array in the linearization dictionary is invalid.');
  38466. }
  38467. var parser = new Parser(new Lexer(stream), false, null);
  38468. var obj1 = parser.getObj();
  38469. var obj2 = parser.getObj();
  38470. var obj3 = parser.getObj();
  38471. var linDict = parser.getObj();
  38472. var obj, length;
  38473. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38474. return null;
  38475. } else if ((length = getInt('L')) !== stream.length) {
  38476. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38477. }
  38478. return {
  38479. length: length,
  38480. hints: getHints(),
  38481. objectNumberFirst: getInt('O'),
  38482. endFirst: getInt('E'),
  38483. numPages: getInt('N'),
  38484. mainXRefEntriesOffset: getInt('T'),
  38485. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38486. };
  38487. }
  38488. };
  38489. exports.EOF = EOF;
  38490. exports.Lexer = Lexer;
  38491. exports.Linearization = Linearization;
  38492. exports.Parser = Parser;
  38493. exports.isEOF = isEOF;
  38494. }));
  38495. (function (root, factory) {
  38496. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38497. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38498. var warn = sharedUtil.warn;
  38499. var isSpace = sharedUtil.isSpace;
  38500. var Stream = coreStream.Stream;
  38501. var getEncoding = coreEncodings.getEncoding;
  38502. var HINTING_ENABLED = false;
  38503. var Type1CharString = function Type1CharStringClosure() {
  38504. var COMMAND_MAP = {
  38505. 'hstem': [1],
  38506. 'vstem': [3],
  38507. 'vmoveto': [4],
  38508. 'rlineto': [5],
  38509. 'hlineto': [6],
  38510. 'vlineto': [7],
  38511. 'rrcurveto': [8],
  38512. 'callsubr': [10],
  38513. 'flex': [
  38514. 12,
  38515. 35
  38516. ],
  38517. 'drop': [
  38518. 12,
  38519. 18
  38520. ],
  38521. 'endchar': [14],
  38522. 'rmoveto': [21],
  38523. 'hmoveto': [22],
  38524. 'vhcurveto': [30],
  38525. 'hvcurveto': [31]
  38526. };
  38527. function Type1CharString() {
  38528. this.width = 0;
  38529. this.lsb = 0;
  38530. this.flexing = false;
  38531. this.output = [];
  38532. this.stack = [];
  38533. }
  38534. Type1CharString.prototype = {
  38535. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38536. var count = encoded.length;
  38537. var error = false;
  38538. var wx, sbx, subrNumber;
  38539. for (var i = 0; i < count; i++) {
  38540. var value = encoded[i];
  38541. if (value < 32) {
  38542. if (value === 12) {
  38543. value = (value << 8) + encoded[++i];
  38544. }
  38545. switch (value) {
  38546. case 1:
  38547. if (!HINTING_ENABLED) {
  38548. this.stack = [];
  38549. break;
  38550. }
  38551. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38552. break;
  38553. case 3:
  38554. if (!HINTING_ENABLED) {
  38555. this.stack = [];
  38556. break;
  38557. }
  38558. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38559. break;
  38560. case 4:
  38561. if (this.flexing) {
  38562. if (this.stack.length < 1) {
  38563. error = true;
  38564. break;
  38565. }
  38566. var dy = this.stack.pop();
  38567. this.stack.push(0, dy);
  38568. break;
  38569. }
  38570. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38571. break;
  38572. case 5:
  38573. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38574. break;
  38575. case 6:
  38576. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38577. break;
  38578. case 7:
  38579. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38580. break;
  38581. case 8:
  38582. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38583. break;
  38584. case 9:
  38585. this.stack = [];
  38586. break;
  38587. case 10:
  38588. if (this.stack.length < 1) {
  38589. error = true;
  38590. break;
  38591. }
  38592. subrNumber = this.stack.pop();
  38593. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38594. break;
  38595. case 11:
  38596. return error;
  38597. case 13:
  38598. if (this.stack.length < 2) {
  38599. error = true;
  38600. break;
  38601. }
  38602. wx = this.stack.pop();
  38603. sbx = this.stack.pop();
  38604. this.lsb = sbx;
  38605. this.width = wx;
  38606. this.stack.push(wx, sbx);
  38607. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38608. break;
  38609. case 14:
  38610. this.output.push(COMMAND_MAP.endchar[0]);
  38611. break;
  38612. case 21:
  38613. if (this.flexing) {
  38614. break;
  38615. }
  38616. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38617. break;
  38618. case 22:
  38619. if (this.flexing) {
  38620. this.stack.push(0);
  38621. break;
  38622. }
  38623. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38624. break;
  38625. case 30:
  38626. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38627. break;
  38628. case 31:
  38629. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38630. break;
  38631. case (12 << 8) + 0:
  38632. this.stack = [];
  38633. break;
  38634. case (12 << 8) + 1:
  38635. if (!HINTING_ENABLED) {
  38636. this.stack = [];
  38637. break;
  38638. }
  38639. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38640. break;
  38641. case (12 << 8) + 2:
  38642. if (!HINTING_ENABLED) {
  38643. this.stack = [];
  38644. break;
  38645. }
  38646. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38647. break;
  38648. case (12 << 8) + 6:
  38649. if (seacAnalysisEnabled) {
  38650. this.seac = this.stack.splice(-4, 4);
  38651. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38652. } else {
  38653. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38654. }
  38655. break;
  38656. case (12 << 8) + 7:
  38657. if (this.stack.length < 4) {
  38658. error = true;
  38659. break;
  38660. }
  38661. var wy = this.stack.pop();
  38662. wx = this.stack.pop();
  38663. var sby = this.stack.pop();
  38664. sbx = this.stack.pop();
  38665. this.lsb = sbx;
  38666. this.width = wx;
  38667. this.stack.push(wx, sbx, sby);
  38668. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38669. break;
  38670. case (12 << 8) + 12:
  38671. if (this.stack.length < 2) {
  38672. error = true;
  38673. break;
  38674. }
  38675. var num2 = this.stack.pop();
  38676. var num1 = this.stack.pop();
  38677. this.stack.push(num1 / num2);
  38678. break;
  38679. case (12 << 8) + 16:
  38680. if (this.stack.length < 2) {
  38681. error = true;
  38682. break;
  38683. }
  38684. subrNumber = this.stack.pop();
  38685. var numArgs = this.stack.pop();
  38686. if (subrNumber === 0 && numArgs === 3) {
  38687. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38688. 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]);
  38689. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38690. this.flexing = false;
  38691. this.stack.push(flexArgs[15], flexArgs[16]);
  38692. } else if (subrNumber === 1 && numArgs === 0) {
  38693. this.flexing = true;
  38694. }
  38695. break;
  38696. case (12 << 8) + 17:
  38697. break;
  38698. case (12 << 8) + 33:
  38699. this.stack = [];
  38700. break;
  38701. default:
  38702. warn('Unknown type 1 charstring command of "' + value + '"');
  38703. break;
  38704. }
  38705. if (error) {
  38706. break;
  38707. }
  38708. continue;
  38709. } else if (value <= 246) {
  38710. value = value - 139;
  38711. } else if (value <= 250) {
  38712. value = (value - 247) * 256 + encoded[++i] + 108;
  38713. } else if (value <= 254) {
  38714. value = -((value - 251) * 256) - encoded[++i] - 108;
  38715. } else {
  38716. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38717. }
  38718. this.stack.push(value);
  38719. }
  38720. return error;
  38721. },
  38722. executeCommand: function (howManyArgs, command, keepStack) {
  38723. var stackLength = this.stack.length;
  38724. if (howManyArgs > stackLength) {
  38725. return true;
  38726. }
  38727. var start = stackLength - howManyArgs;
  38728. for (var i = start; i < stackLength; i++) {
  38729. var value = this.stack[i];
  38730. if (value === (value | 0)) {
  38731. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38732. } else {
  38733. value = 65536 * value | 0;
  38734. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38735. }
  38736. }
  38737. this.output.push.apply(this.output, command);
  38738. if (keepStack) {
  38739. this.stack.splice(start, howManyArgs);
  38740. } else {
  38741. this.stack.length = 0;
  38742. }
  38743. return false;
  38744. }
  38745. };
  38746. return Type1CharString;
  38747. }();
  38748. var Type1Parser = function Type1ParserClosure() {
  38749. var EEXEC_ENCRYPT_KEY = 55665;
  38750. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38751. function isHexDigit(code) {
  38752. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38753. }
  38754. function decrypt(data, key, discardNumber) {
  38755. if (discardNumber >= data.length) {
  38756. return new Uint8Array(0);
  38757. }
  38758. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38759. for (i = 0; i < discardNumber; i++) {
  38760. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38761. }
  38762. var count = data.length - discardNumber;
  38763. var decrypted = new Uint8Array(count);
  38764. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38765. var value = data[i];
  38766. decrypted[j] = value ^ r >> 8;
  38767. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38768. }
  38769. return decrypted;
  38770. }
  38771. function decryptAscii(data, key, discardNumber) {
  38772. var r = key | 0, c1 = 52845, c2 = 22719;
  38773. var count = data.length, maybeLength = count >>> 1;
  38774. var decrypted = new Uint8Array(maybeLength);
  38775. var i, j;
  38776. for (i = 0, j = 0; i < count; i++) {
  38777. var digit1 = data[i];
  38778. if (!isHexDigit(digit1)) {
  38779. continue;
  38780. }
  38781. i++;
  38782. var digit2;
  38783. while (i < count && !isHexDigit(digit2 = data[i])) {
  38784. i++;
  38785. }
  38786. if (i < count) {
  38787. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38788. decrypted[j++] = value ^ r >> 8;
  38789. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38790. }
  38791. }
  38792. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38793. }
  38794. function isSpecial(c) {
  38795. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38796. }
  38797. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38798. if (encrypted) {
  38799. var data = stream.getBytes();
  38800. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38801. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38802. }
  38803. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38804. this.stream = stream;
  38805. this.nextChar();
  38806. }
  38807. Type1Parser.prototype = {
  38808. readNumberArray: function Type1Parser_readNumberArray() {
  38809. this.getToken();
  38810. var array = [];
  38811. while (true) {
  38812. var token = this.getToken();
  38813. if (token === null || token === ']' || token === '}') {
  38814. break;
  38815. }
  38816. array.push(parseFloat(token || 0));
  38817. }
  38818. return array;
  38819. },
  38820. readNumber: function Type1Parser_readNumber() {
  38821. var token = this.getToken();
  38822. return parseFloat(token || 0);
  38823. },
  38824. readInt: function Type1Parser_readInt() {
  38825. var token = this.getToken();
  38826. return parseInt(token || 0, 10) | 0;
  38827. },
  38828. readBoolean: function Type1Parser_readBoolean() {
  38829. var token = this.getToken();
  38830. return token === 'true' ? 1 : 0;
  38831. },
  38832. nextChar: function Type1_nextChar() {
  38833. return this.currentChar = this.stream.getByte();
  38834. },
  38835. getToken: function Type1Parser_getToken() {
  38836. var comment = false;
  38837. var ch = this.currentChar;
  38838. while (true) {
  38839. if (ch === -1) {
  38840. return null;
  38841. }
  38842. if (comment) {
  38843. if (ch === 0x0A || ch === 0x0D) {
  38844. comment = false;
  38845. }
  38846. } else if (ch === 0x25) {
  38847. comment = true;
  38848. } else if (!isSpace(ch)) {
  38849. break;
  38850. }
  38851. ch = this.nextChar();
  38852. }
  38853. if (isSpecial(ch)) {
  38854. this.nextChar();
  38855. return String.fromCharCode(ch);
  38856. }
  38857. var token = '';
  38858. do {
  38859. token += String.fromCharCode(ch);
  38860. ch = this.nextChar();
  38861. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  38862. return token;
  38863. },
  38864. extractFontProgram: function Type1Parser_extractFontProgram() {
  38865. var stream = this.stream;
  38866. var subrs = [], charstrings = [];
  38867. var privateData = Object.create(null);
  38868. privateData['lenIV'] = 4;
  38869. var program = {
  38870. subrs: [],
  38871. charstrings: [],
  38872. properties: { 'privateData': privateData }
  38873. };
  38874. var token, length, data, lenIV, encoded;
  38875. while ((token = this.getToken()) !== null) {
  38876. if (token !== '/') {
  38877. continue;
  38878. }
  38879. token = this.getToken();
  38880. switch (token) {
  38881. case 'CharStrings':
  38882. this.getToken();
  38883. this.getToken();
  38884. this.getToken();
  38885. this.getToken();
  38886. while (true) {
  38887. token = this.getToken();
  38888. if (token === null || token === 'end') {
  38889. break;
  38890. }
  38891. if (token !== '/') {
  38892. continue;
  38893. }
  38894. var glyph = this.getToken();
  38895. length = this.readInt();
  38896. this.getToken();
  38897. data = stream.makeSubStream(stream.pos, length);
  38898. lenIV = program.properties.privateData['lenIV'];
  38899. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38900. stream.skip(length);
  38901. this.nextChar();
  38902. token = this.getToken();
  38903. if (token === 'noaccess') {
  38904. this.getToken();
  38905. }
  38906. charstrings.push({
  38907. glyph: glyph,
  38908. encoded: encoded
  38909. });
  38910. }
  38911. break;
  38912. case 'Subrs':
  38913. var num = this.readInt();
  38914. this.getToken();
  38915. while ((token = this.getToken()) === 'dup') {
  38916. var index = this.readInt();
  38917. length = this.readInt();
  38918. this.getToken();
  38919. data = stream.makeSubStream(stream.pos, length);
  38920. lenIV = program.properties.privateData['lenIV'];
  38921. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38922. stream.skip(length);
  38923. this.nextChar();
  38924. token = this.getToken();
  38925. if (token === 'noaccess') {
  38926. this.getToken();
  38927. }
  38928. subrs[index] = encoded;
  38929. }
  38930. break;
  38931. case 'BlueValues':
  38932. case 'OtherBlues':
  38933. case 'FamilyBlues':
  38934. case 'FamilyOtherBlues':
  38935. var blueArray = this.readNumberArray();
  38936. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  38937. program.properties.privateData[token] = blueArray;
  38938. }
  38939. break;
  38940. case 'StemSnapH':
  38941. case 'StemSnapV':
  38942. program.properties.privateData[token] = this.readNumberArray();
  38943. break;
  38944. case 'StdHW':
  38945. case 'StdVW':
  38946. program.properties.privateData[token] = this.readNumberArray()[0];
  38947. break;
  38948. case 'BlueShift':
  38949. case 'lenIV':
  38950. case 'BlueFuzz':
  38951. case 'BlueScale':
  38952. case 'LanguageGroup':
  38953. case 'ExpansionFactor':
  38954. program.properties.privateData[token] = this.readNumber();
  38955. break;
  38956. case 'ForceBold':
  38957. program.properties.privateData[token] = this.readBoolean();
  38958. break;
  38959. }
  38960. }
  38961. for (var i = 0; i < charstrings.length; i++) {
  38962. glyph = charstrings[i].glyph;
  38963. encoded = charstrings[i].encoded;
  38964. var charString = new Type1CharString();
  38965. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  38966. var output = charString.output;
  38967. if (error) {
  38968. output = [14];
  38969. }
  38970. program.charstrings.push({
  38971. glyphName: glyph,
  38972. charstring: output,
  38973. width: charString.width,
  38974. lsb: charString.lsb,
  38975. seac: charString.seac
  38976. });
  38977. }
  38978. return program;
  38979. },
  38980. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  38981. var token;
  38982. while ((token = this.getToken()) !== null) {
  38983. if (token !== '/') {
  38984. continue;
  38985. }
  38986. token = this.getToken();
  38987. switch (token) {
  38988. case 'FontMatrix':
  38989. var matrix = this.readNumberArray();
  38990. properties.fontMatrix = matrix;
  38991. break;
  38992. case 'Encoding':
  38993. var encodingArg = this.getToken();
  38994. var encoding;
  38995. if (!/^\d+$/.test(encodingArg)) {
  38996. encoding = getEncoding(encodingArg);
  38997. } else {
  38998. encoding = [];
  38999. var size = parseInt(encodingArg, 10) | 0;
  39000. this.getToken();
  39001. for (var j = 0; j < size; j++) {
  39002. token = this.getToken();
  39003. while (token !== 'dup' && token !== 'def') {
  39004. token = this.getToken();
  39005. if (token === null) {
  39006. return;
  39007. }
  39008. }
  39009. if (token === 'def') {
  39010. break;
  39011. }
  39012. var index = this.readInt();
  39013. this.getToken();
  39014. var glyph = this.getToken();
  39015. encoding[index] = glyph;
  39016. this.getToken();
  39017. }
  39018. }
  39019. properties.builtInEncoding = encoding;
  39020. break;
  39021. case 'FontBBox':
  39022. var fontBBox = this.readNumberArray();
  39023. properties.ascent = fontBBox[3];
  39024. properties.descent = fontBBox[1];
  39025. properties.ascentScaled = true;
  39026. break;
  39027. }
  39028. }
  39029. }
  39030. };
  39031. return Type1Parser;
  39032. }();
  39033. exports.Type1Parser = Type1Parser;
  39034. }));
  39035. (function (root, factory) {
  39036. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39037. }(this, function (exports, sharedUtil, displayWebGL) {
  39038. var Util = sharedUtil.Util;
  39039. var info = sharedUtil.info;
  39040. var isArray = sharedUtil.isArray;
  39041. var error = sharedUtil.error;
  39042. var WebGLUtils = displayWebGL.WebGLUtils;
  39043. var ShadingIRs = {};
  39044. ShadingIRs.RadialAxial = {
  39045. fromIR: function RadialAxial_fromIR(raw) {
  39046. var type = raw[1];
  39047. var colorStops = raw[2];
  39048. var p0 = raw[3];
  39049. var p1 = raw[4];
  39050. var r0 = raw[5];
  39051. var r1 = raw[6];
  39052. return {
  39053. type: 'Pattern',
  39054. getPattern: function RadialAxial_getPattern(ctx) {
  39055. var grad;
  39056. if (type === 'axial') {
  39057. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39058. } else if (type === 'radial') {
  39059. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39060. }
  39061. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39062. var c = colorStops[i];
  39063. grad.addColorStop(c[0], c[1]);
  39064. }
  39065. return grad;
  39066. }
  39067. };
  39068. }
  39069. };
  39070. var createMeshCanvas = function createMeshCanvasClosure() {
  39071. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39072. var coords = context.coords, colors = context.colors;
  39073. var bytes = data.data, rowSize = data.width * 4;
  39074. var tmp;
  39075. if (coords[p1 + 1] > coords[p2 + 1]) {
  39076. tmp = p1;
  39077. p1 = p2;
  39078. p2 = tmp;
  39079. tmp = c1;
  39080. c1 = c2;
  39081. c2 = tmp;
  39082. }
  39083. if (coords[p2 + 1] > coords[p3 + 1]) {
  39084. tmp = p2;
  39085. p2 = p3;
  39086. p3 = tmp;
  39087. tmp = c2;
  39088. c2 = c3;
  39089. c3 = tmp;
  39090. }
  39091. if (coords[p1 + 1] > coords[p2 + 1]) {
  39092. tmp = p1;
  39093. p1 = p2;
  39094. p2 = tmp;
  39095. tmp = c1;
  39096. c1 = c2;
  39097. c2 = tmp;
  39098. }
  39099. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39100. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39101. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39102. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39103. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39104. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39105. if (y1 >= y3) {
  39106. return;
  39107. }
  39108. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39109. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39110. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39111. var minY = Math.round(y1), maxY = Math.round(y3);
  39112. var xa, car, cag, cab;
  39113. var xb, cbr, cbg, cbb;
  39114. var k;
  39115. for (var y = minY; y <= maxY; y++) {
  39116. if (y < y2) {
  39117. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39118. xa = x1 - (x1 - x2) * k;
  39119. car = c1r - (c1r - c2r) * k;
  39120. cag = c1g - (c1g - c2g) * k;
  39121. cab = c1b - (c1b - c2b) * k;
  39122. } else {
  39123. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39124. xa = x2 - (x2 - x3) * k;
  39125. car = c2r - (c2r - c3r) * k;
  39126. cag = c2g - (c2g - c3g) * k;
  39127. cab = c2b - (c2b - c3b) * k;
  39128. }
  39129. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39130. xb = x1 - (x1 - x3) * k;
  39131. cbr = c1r - (c1r - c3r) * k;
  39132. cbg = c1g - (c1g - c3g) * k;
  39133. cbb = c1b - (c1b - c3b) * k;
  39134. var x1_ = Math.round(Math.min(xa, xb));
  39135. var x2_ = Math.round(Math.max(xa, xb));
  39136. var j = rowSize * y + x1_ * 4;
  39137. for (var x = x1_; x <= x2_; x++) {
  39138. k = (xa - x) / (xa - xb);
  39139. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39140. bytes[j++] = car - (car - cbr) * k | 0;
  39141. bytes[j++] = cag - (cag - cbg) * k | 0;
  39142. bytes[j++] = cab - (cab - cbb) * k | 0;
  39143. bytes[j++] = 255;
  39144. }
  39145. }
  39146. }
  39147. function drawFigure(data, figure, context) {
  39148. var ps = figure.coords;
  39149. var cs = figure.colors;
  39150. var i, ii;
  39151. switch (figure.type) {
  39152. case 'lattice':
  39153. var verticesPerRow = figure.verticesPerRow;
  39154. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39155. var cols = verticesPerRow - 1;
  39156. for (i = 0; i < rows; i++) {
  39157. var q = i * verticesPerRow;
  39158. for (var j = 0; j < cols; j++, q++) {
  39159. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39160. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39161. }
  39162. }
  39163. break;
  39164. case 'triangles':
  39165. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39166. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39167. }
  39168. break;
  39169. default:
  39170. error('illigal figure');
  39171. break;
  39172. }
  39173. }
  39174. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39175. var EXPECTED_SCALE = 1.1;
  39176. var MAX_PATTERN_SIZE = 3000;
  39177. var BORDER_SIZE = 2;
  39178. var offsetX = Math.floor(bounds[0]);
  39179. var offsetY = Math.floor(bounds[1]);
  39180. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39181. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39182. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39183. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39184. var scaleX = boundsWidth / width;
  39185. var scaleY = boundsHeight / height;
  39186. var context = {
  39187. coords: coords,
  39188. colors: colors,
  39189. offsetX: -offsetX,
  39190. offsetY: -offsetY,
  39191. scaleX: 1 / scaleX,
  39192. scaleY: 1 / scaleY
  39193. };
  39194. var paddedWidth = width + BORDER_SIZE * 2;
  39195. var paddedHeight = height + BORDER_SIZE * 2;
  39196. var canvas, tmpCanvas, i, ii;
  39197. if (WebGLUtils.isEnabled) {
  39198. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39199. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39200. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39201. canvas = tmpCanvas.canvas;
  39202. } else {
  39203. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39204. var tmpCtx = tmpCanvas.context;
  39205. var data = tmpCtx.createImageData(width, height);
  39206. if (backgroundColor) {
  39207. var bytes = data.data;
  39208. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39209. bytes[i] = backgroundColor[0];
  39210. bytes[i + 1] = backgroundColor[1];
  39211. bytes[i + 2] = backgroundColor[2];
  39212. bytes[i + 3] = 255;
  39213. }
  39214. }
  39215. for (i = 0; i < figures.length; i++) {
  39216. drawFigure(data, figures[i], context);
  39217. }
  39218. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39219. canvas = tmpCanvas.canvas;
  39220. }
  39221. return {
  39222. canvas: canvas,
  39223. offsetX: offsetX - BORDER_SIZE * scaleX,
  39224. offsetY: offsetY - BORDER_SIZE * scaleY,
  39225. scaleX: scaleX,
  39226. scaleY: scaleY
  39227. };
  39228. }
  39229. return createMeshCanvas;
  39230. }();
  39231. ShadingIRs.Mesh = {
  39232. fromIR: function Mesh_fromIR(raw) {
  39233. var coords = raw[2];
  39234. var colors = raw[3];
  39235. var figures = raw[4];
  39236. var bounds = raw[5];
  39237. var matrix = raw[6];
  39238. var background = raw[8];
  39239. return {
  39240. type: 'Pattern',
  39241. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39242. var scale;
  39243. if (shadingFill) {
  39244. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39245. } else {
  39246. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39247. if (matrix) {
  39248. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39249. scale = [
  39250. scale[0] * matrixScale[0],
  39251. scale[1] * matrixScale[1]
  39252. ];
  39253. }
  39254. }
  39255. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39256. if (!shadingFill) {
  39257. ctx.setTransform.apply(ctx, owner.baseTransform);
  39258. if (matrix) {
  39259. ctx.transform.apply(ctx, matrix);
  39260. }
  39261. }
  39262. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39263. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39264. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39265. }
  39266. };
  39267. }
  39268. };
  39269. ShadingIRs.Dummy = {
  39270. fromIR: function Dummy_fromIR() {
  39271. return {
  39272. type: 'Pattern',
  39273. getPattern: function Dummy_fromIR_getPattern() {
  39274. return 'hotpink';
  39275. }
  39276. };
  39277. }
  39278. };
  39279. function getShadingPatternFromIR(raw) {
  39280. var shadingIR = ShadingIRs[raw[0]];
  39281. if (!shadingIR) {
  39282. error('Unknown IR type: ' + raw[0]);
  39283. }
  39284. return shadingIR.fromIR(raw);
  39285. }
  39286. var TilingPattern = function TilingPatternClosure() {
  39287. var PaintType = {
  39288. COLORED: 1,
  39289. UNCOLORED: 2
  39290. };
  39291. var MAX_PATTERN_SIZE = 3000;
  39292. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39293. this.operatorList = IR[2];
  39294. this.matrix = IR[3] || [
  39295. 1,
  39296. 0,
  39297. 0,
  39298. 1,
  39299. 0,
  39300. 0
  39301. ];
  39302. this.bbox = IR[4];
  39303. this.xstep = IR[5];
  39304. this.ystep = IR[6];
  39305. this.paintType = IR[7];
  39306. this.tilingType = IR[8];
  39307. this.color = color;
  39308. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39309. this.baseTransform = baseTransform;
  39310. this.type = 'Pattern';
  39311. this.ctx = ctx;
  39312. }
  39313. TilingPattern.prototype = {
  39314. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39315. var operatorList = this.operatorList;
  39316. var bbox = this.bbox;
  39317. var xstep = this.xstep;
  39318. var ystep = this.ystep;
  39319. var paintType = this.paintType;
  39320. var tilingType = this.tilingType;
  39321. var color = this.color;
  39322. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39323. info('TilingType: ' + tilingType);
  39324. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39325. var topLeft = [
  39326. x0,
  39327. y0
  39328. ];
  39329. var botRight = [
  39330. x0 + xstep,
  39331. y0 + ystep
  39332. ];
  39333. var width = botRight[0] - topLeft[0];
  39334. var height = botRight[1] - topLeft[1];
  39335. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39336. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39337. var combinedScale = [
  39338. matrixScale[0] * curMatrixScale[0],
  39339. matrixScale[1] * curMatrixScale[1]
  39340. ];
  39341. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39342. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39343. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39344. var tmpCtx = tmpCanvas.context;
  39345. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39346. graphics.groupLevel = owner.groupLevel;
  39347. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39348. this.setScale(width, height, xstep, ystep);
  39349. this.transformToScale(graphics);
  39350. var tmpTranslate = [
  39351. 1,
  39352. 0,
  39353. 0,
  39354. 1,
  39355. -topLeft[0],
  39356. -topLeft[1]
  39357. ];
  39358. graphics.transform.apply(graphics, tmpTranslate);
  39359. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39360. graphics.executeOperatorList(operatorList);
  39361. return tmpCanvas.canvas;
  39362. },
  39363. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39364. this.scale = [
  39365. width / xstep,
  39366. height / ystep
  39367. ];
  39368. },
  39369. transformToScale: function TilingPattern_transformToScale(graphics) {
  39370. var scale = this.scale;
  39371. var tmpScale = [
  39372. scale[0],
  39373. 0,
  39374. 0,
  39375. scale[1],
  39376. 0,
  39377. 0
  39378. ];
  39379. graphics.transform.apply(graphics, tmpScale);
  39380. },
  39381. scaleToContext: function TilingPattern_scaleToContext() {
  39382. var scale = this.scale;
  39383. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39384. },
  39385. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39386. if (bbox && isArray(bbox) && bbox.length === 4) {
  39387. var bboxWidth = x1 - x0;
  39388. var bboxHeight = y1 - y0;
  39389. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39390. graphics.clip();
  39391. graphics.endPath();
  39392. }
  39393. },
  39394. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39395. switch (paintType) {
  39396. case PaintType.COLORED:
  39397. var ctx = this.ctx;
  39398. context.fillStyle = ctx.fillStyle;
  39399. context.strokeStyle = ctx.strokeStyle;
  39400. break;
  39401. case PaintType.UNCOLORED:
  39402. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39403. context.fillStyle = cssColor;
  39404. context.strokeStyle = cssColor;
  39405. break;
  39406. default:
  39407. error('Unsupported paint type: ' + paintType);
  39408. }
  39409. },
  39410. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39411. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39412. ctx = this.ctx;
  39413. ctx.setTransform.apply(ctx, this.baseTransform);
  39414. ctx.transform.apply(ctx, this.matrix);
  39415. this.scaleToContext();
  39416. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39417. }
  39418. };
  39419. return TilingPattern;
  39420. }();
  39421. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39422. exports.TilingPattern = TilingPattern;
  39423. }));
  39424. (function (root, factory) {
  39425. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39426. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39427. var Util = sharedUtil.Util;
  39428. var assert = sharedUtil.assert;
  39429. var warn = sharedUtil.warn;
  39430. var error = sharedUtil.error;
  39431. var isInt = sharedUtil.isInt;
  39432. var isString = sharedUtil.isString;
  39433. var MissingDataException = sharedUtil.MissingDataException;
  39434. var isName = corePrimitives.isName;
  39435. var isCmd = corePrimitives.isCmd;
  39436. var isStream = corePrimitives.isStream;
  39437. var StringStream = coreStream.StringStream;
  39438. var Lexer = coreParser.Lexer;
  39439. var isEOF = coreParser.isEOF;
  39440. var BUILT_IN_CMAPS = [
  39441. 'Adobe-GB1-UCS2',
  39442. 'Adobe-CNS1-UCS2',
  39443. 'Adobe-Japan1-UCS2',
  39444. 'Adobe-Korea1-UCS2',
  39445. '78-EUC-H',
  39446. '78-EUC-V',
  39447. '78-H',
  39448. '78-RKSJ-H',
  39449. '78-RKSJ-V',
  39450. '78-V',
  39451. '78ms-RKSJ-H',
  39452. '78ms-RKSJ-V',
  39453. '83pv-RKSJ-H',
  39454. '90ms-RKSJ-H',
  39455. '90ms-RKSJ-V',
  39456. '90msp-RKSJ-H',
  39457. '90msp-RKSJ-V',
  39458. '90pv-RKSJ-H',
  39459. '90pv-RKSJ-V',
  39460. 'Add-H',
  39461. 'Add-RKSJ-H',
  39462. 'Add-RKSJ-V',
  39463. 'Add-V',
  39464. 'Adobe-CNS1-0',
  39465. 'Adobe-CNS1-1',
  39466. 'Adobe-CNS1-2',
  39467. 'Adobe-CNS1-3',
  39468. 'Adobe-CNS1-4',
  39469. 'Adobe-CNS1-5',
  39470. 'Adobe-CNS1-6',
  39471. 'Adobe-GB1-0',
  39472. 'Adobe-GB1-1',
  39473. 'Adobe-GB1-2',
  39474. 'Adobe-GB1-3',
  39475. 'Adobe-GB1-4',
  39476. 'Adobe-GB1-5',
  39477. 'Adobe-Japan1-0',
  39478. 'Adobe-Japan1-1',
  39479. 'Adobe-Japan1-2',
  39480. 'Adobe-Japan1-3',
  39481. 'Adobe-Japan1-4',
  39482. 'Adobe-Japan1-5',
  39483. 'Adobe-Japan1-6',
  39484. 'Adobe-Korea1-0',
  39485. 'Adobe-Korea1-1',
  39486. 'Adobe-Korea1-2',
  39487. 'B5-H',
  39488. 'B5-V',
  39489. 'B5pc-H',
  39490. 'B5pc-V',
  39491. 'CNS-EUC-H',
  39492. 'CNS-EUC-V',
  39493. 'CNS1-H',
  39494. 'CNS1-V',
  39495. 'CNS2-H',
  39496. 'CNS2-V',
  39497. 'ETHK-B5-H',
  39498. 'ETHK-B5-V',
  39499. 'ETen-B5-H',
  39500. 'ETen-B5-V',
  39501. 'ETenms-B5-H',
  39502. 'ETenms-B5-V',
  39503. 'EUC-H',
  39504. 'EUC-V',
  39505. 'Ext-H',
  39506. 'Ext-RKSJ-H',
  39507. 'Ext-RKSJ-V',
  39508. 'Ext-V',
  39509. 'GB-EUC-H',
  39510. 'GB-EUC-V',
  39511. 'GB-H',
  39512. 'GB-V',
  39513. 'GBK-EUC-H',
  39514. 'GBK-EUC-V',
  39515. 'GBK2K-H',
  39516. 'GBK2K-V',
  39517. 'GBKp-EUC-H',
  39518. 'GBKp-EUC-V',
  39519. 'GBT-EUC-H',
  39520. 'GBT-EUC-V',
  39521. 'GBT-H',
  39522. 'GBT-V',
  39523. 'GBTpc-EUC-H',
  39524. 'GBTpc-EUC-V',
  39525. 'GBpc-EUC-H',
  39526. 'GBpc-EUC-V',
  39527. 'H',
  39528. 'HKdla-B5-H',
  39529. 'HKdla-B5-V',
  39530. 'HKdlb-B5-H',
  39531. 'HKdlb-B5-V',
  39532. 'HKgccs-B5-H',
  39533. 'HKgccs-B5-V',
  39534. 'HKm314-B5-H',
  39535. 'HKm314-B5-V',
  39536. 'HKm471-B5-H',
  39537. 'HKm471-B5-V',
  39538. 'HKscs-B5-H',
  39539. 'HKscs-B5-V',
  39540. 'Hankaku',
  39541. 'Hiragana',
  39542. 'KSC-EUC-H',
  39543. 'KSC-EUC-V',
  39544. 'KSC-H',
  39545. 'KSC-Johab-H',
  39546. 'KSC-Johab-V',
  39547. 'KSC-V',
  39548. 'KSCms-UHC-H',
  39549. 'KSCms-UHC-HW-H',
  39550. 'KSCms-UHC-HW-V',
  39551. 'KSCms-UHC-V',
  39552. 'KSCpc-EUC-H',
  39553. 'KSCpc-EUC-V',
  39554. 'Katakana',
  39555. 'NWP-H',
  39556. 'NWP-V',
  39557. 'RKSJ-H',
  39558. 'RKSJ-V',
  39559. 'Roman',
  39560. 'UniCNS-UCS2-H',
  39561. 'UniCNS-UCS2-V',
  39562. 'UniCNS-UTF16-H',
  39563. 'UniCNS-UTF16-V',
  39564. 'UniCNS-UTF32-H',
  39565. 'UniCNS-UTF32-V',
  39566. 'UniCNS-UTF8-H',
  39567. 'UniCNS-UTF8-V',
  39568. 'UniGB-UCS2-H',
  39569. 'UniGB-UCS2-V',
  39570. 'UniGB-UTF16-H',
  39571. 'UniGB-UTF16-V',
  39572. 'UniGB-UTF32-H',
  39573. 'UniGB-UTF32-V',
  39574. 'UniGB-UTF8-H',
  39575. 'UniGB-UTF8-V',
  39576. 'UniJIS-UCS2-H',
  39577. 'UniJIS-UCS2-HW-H',
  39578. 'UniJIS-UCS2-HW-V',
  39579. 'UniJIS-UCS2-V',
  39580. 'UniJIS-UTF16-H',
  39581. 'UniJIS-UTF16-V',
  39582. 'UniJIS-UTF32-H',
  39583. 'UniJIS-UTF32-V',
  39584. 'UniJIS-UTF8-H',
  39585. 'UniJIS-UTF8-V',
  39586. 'UniJIS2004-UTF16-H',
  39587. 'UniJIS2004-UTF16-V',
  39588. 'UniJIS2004-UTF32-H',
  39589. 'UniJIS2004-UTF32-V',
  39590. 'UniJIS2004-UTF8-H',
  39591. 'UniJIS2004-UTF8-V',
  39592. 'UniJISPro-UCS2-HW-V',
  39593. 'UniJISPro-UCS2-V',
  39594. 'UniJISPro-UTF8-V',
  39595. 'UniJISX0213-UTF32-H',
  39596. 'UniJISX0213-UTF32-V',
  39597. 'UniJISX02132004-UTF32-H',
  39598. 'UniJISX02132004-UTF32-V',
  39599. 'UniKS-UCS2-H',
  39600. 'UniKS-UCS2-V',
  39601. 'UniKS-UTF16-H',
  39602. 'UniKS-UTF16-V',
  39603. 'UniKS-UTF32-H',
  39604. 'UniKS-UTF32-V',
  39605. 'UniKS-UTF8-H',
  39606. 'UniKS-UTF8-V',
  39607. 'V',
  39608. 'WP-Symbol'
  39609. ];
  39610. var CMap = function CMapClosure() {
  39611. function CMap(builtInCMap) {
  39612. this.codespaceRanges = [
  39613. [],
  39614. [],
  39615. [],
  39616. []
  39617. ];
  39618. this.numCodespaceRanges = 0;
  39619. this._map = [];
  39620. this.name = '';
  39621. this.vertical = false;
  39622. this.useCMap = null;
  39623. this.builtInCMap = builtInCMap;
  39624. }
  39625. CMap.prototype = {
  39626. addCodespaceRange: function (n, low, high) {
  39627. this.codespaceRanges[n - 1].push(low, high);
  39628. this.numCodespaceRanges++;
  39629. },
  39630. mapCidRange: function (low, high, dstLow) {
  39631. while (low <= high) {
  39632. this._map[low++] = dstLow++;
  39633. }
  39634. },
  39635. mapBfRange: function (low, high, dstLow) {
  39636. var lastByte = dstLow.length - 1;
  39637. while (low <= high) {
  39638. this._map[low++] = dstLow;
  39639. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39640. }
  39641. },
  39642. mapBfRangeToArray: function (low, high, array) {
  39643. var i = 0, ii = array.length;
  39644. while (low <= high && i < ii) {
  39645. this._map[low] = array[i++];
  39646. ++low;
  39647. }
  39648. },
  39649. mapOne: function (src, dst) {
  39650. this._map[src] = dst;
  39651. },
  39652. lookup: function (code) {
  39653. return this._map[code];
  39654. },
  39655. contains: function (code) {
  39656. return this._map[code] !== undefined;
  39657. },
  39658. forEach: function (callback) {
  39659. var map = this._map;
  39660. var length = map.length;
  39661. var i;
  39662. if (length <= 0x10000) {
  39663. for (i = 0; i < length; i++) {
  39664. if (map[i] !== undefined) {
  39665. callback(i, map[i]);
  39666. }
  39667. }
  39668. } else {
  39669. for (i in this._map) {
  39670. callback(i, map[i]);
  39671. }
  39672. }
  39673. },
  39674. charCodeOf: function (value) {
  39675. return this._map.indexOf(value);
  39676. },
  39677. getMap: function () {
  39678. return this._map;
  39679. },
  39680. readCharCode: function (str, offset, out) {
  39681. var c = 0;
  39682. var codespaceRanges = this.codespaceRanges;
  39683. var codespaceRangesLen = this.codespaceRanges.length;
  39684. for (var n = 0; n < codespaceRangesLen; n++) {
  39685. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39686. var codespaceRange = codespaceRanges[n];
  39687. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39688. var low = codespaceRange[k++];
  39689. var high = codespaceRange[k++];
  39690. if (c >= low && c <= high) {
  39691. out.charcode = c;
  39692. out.length = n + 1;
  39693. return;
  39694. }
  39695. }
  39696. }
  39697. out.charcode = 0;
  39698. out.length = 1;
  39699. },
  39700. get length() {
  39701. return this._map.length;
  39702. },
  39703. get isIdentityCMap() {
  39704. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39705. return false;
  39706. }
  39707. if (this._map.length !== 0x10000) {
  39708. return false;
  39709. }
  39710. for (var i = 0; i < 0x10000; i++) {
  39711. if (this._map[i] !== i) {
  39712. return false;
  39713. }
  39714. }
  39715. return true;
  39716. }
  39717. };
  39718. return CMap;
  39719. }();
  39720. var IdentityCMap = function IdentityCMapClosure() {
  39721. function IdentityCMap(vertical, n) {
  39722. CMap.call(this);
  39723. this.vertical = vertical;
  39724. this.addCodespaceRange(n, 0, 0xffff);
  39725. }
  39726. Util.inherit(IdentityCMap, CMap, {});
  39727. IdentityCMap.prototype = {
  39728. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39729. mapCidRange: function (low, high, dstLow) {
  39730. error('should not call mapCidRange');
  39731. },
  39732. mapBfRange: function (low, high, dstLow) {
  39733. error('should not call mapBfRange');
  39734. },
  39735. mapBfRangeToArray: function (low, high, array) {
  39736. error('should not call mapBfRangeToArray');
  39737. },
  39738. mapOne: function (src, dst) {
  39739. error('should not call mapCidOne');
  39740. },
  39741. lookup: function (code) {
  39742. return isInt(code) && code <= 0xffff ? code : undefined;
  39743. },
  39744. contains: function (code) {
  39745. return isInt(code) && code <= 0xffff;
  39746. },
  39747. forEach: function (callback) {
  39748. for (var i = 0; i <= 0xffff; i++) {
  39749. callback(i, i);
  39750. }
  39751. },
  39752. charCodeOf: function (value) {
  39753. return isInt(value) && value <= 0xffff ? value : -1;
  39754. },
  39755. getMap: function () {
  39756. var map = new Array(0x10000);
  39757. for (var i = 0; i <= 0xffff; i++) {
  39758. map[i] = i;
  39759. }
  39760. return map;
  39761. },
  39762. readCharCode: CMap.prototype.readCharCode,
  39763. get length() {
  39764. return 0x10000;
  39765. },
  39766. get isIdentityCMap() {
  39767. error('should not access .isIdentityCMap');
  39768. }
  39769. };
  39770. return IdentityCMap;
  39771. }();
  39772. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39773. function fetchBinaryData(url) {
  39774. return new Promise(function (resolve, reject) {
  39775. var request = new XMLHttpRequest();
  39776. request.open('GET', url, true);
  39777. request.responseType = 'arraybuffer';
  39778. request.onreadystatechange = function () {
  39779. if (request.readyState === XMLHttpRequest.DONE) {
  39780. if (!request.response || request.status !== 200 && request.status !== 0) {
  39781. reject(new Error('Unable to get binary cMap at: ' + url));
  39782. } else {
  39783. resolve(new Uint8Array(request.response));
  39784. }
  39785. }
  39786. };
  39787. request.send(null);
  39788. });
  39789. }
  39790. function hexToInt(a, size) {
  39791. var n = 0;
  39792. for (var i = 0; i <= size; i++) {
  39793. n = n << 8 | a[i];
  39794. }
  39795. return n >>> 0;
  39796. }
  39797. function hexToStr(a, size) {
  39798. if (size === 1) {
  39799. return String.fromCharCode(a[0], a[1]);
  39800. }
  39801. if (size === 3) {
  39802. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39803. }
  39804. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39805. }
  39806. function addHex(a, b, size) {
  39807. var c = 0;
  39808. for (var i = size; i >= 0; i--) {
  39809. c += a[i] + b[i];
  39810. a[i] = c & 255;
  39811. c >>= 8;
  39812. }
  39813. }
  39814. function incHex(a, size) {
  39815. var c = 1;
  39816. for (var i = size; i >= 0 && c > 0; i--) {
  39817. c += a[i];
  39818. a[i] = c & 255;
  39819. c >>= 8;
  39820. }
  39821. }
  39822. var MAX_NUM_SIZE = 16;
  39823. var MAX_ENCODED_NUM_SIZE = 19;
  39824. function BinaryCMapStream(data) {
  39825. this.buffer = data;
  39826. this.pos = 0;
  39827. this.end = data.length;
  39828. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  39829. }
  39830. BinaryCMapStream.prototype = {
  39831. readByte: function () {
  39832. if (this.pos >= this.end) {
  39833. return -1;
  39834. }
  39835. return this.buffer[this.pos++];
  39836. },
  39837. readNumber: function () {
  39838. var n = 0;
  39839. var last;
  39840. do {
  39841. var b = this.readByte();
  39842. if (b < 0) {
  39843. error('unexpected EOF in bcmap');
  39844. }
  39845. last = !(b & 0x80);
  39846. n = n << 7 | b & 0x7F;
  39847. } while (!last);
  39848. return n;
  39849. },
  39850. readSigned: function () {
  39851. var n = this.readNumber();
  39852. return n & 1 ? ~(n >>> 1) : n >>> 1;
  39853. },
  39854. readHex: function (num, size) {
  39855. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  39856. this.pos += size + 1;
  39857. },
  39858. readHexNumber: function (num, size) {
  39859. var last;
  39860. var stack = this.tmpBuf, sp = 0;
  39861. do {
  39862. var b = this.readByte();
  39863. if (b < 0) {
  39864. error('unexpected EOF in bcmap');
  39865. }
  39866. last = !(b & 0x80);
  39867. stack[sp++] = b & 0x7F;
  39868. } while (!last);
  39869. var i = size, buffer = 0, bufferSize = 0;
  39870. while (i >= 0) {
  39871. while (bufferSize < 8 && stack.length > 0) {
  39872. buffer = stack[--sp] << bufferSize | buffer;
  39873. bufferSize += 7;
  39874. }
  39875. num[i] = buffer & 255;
  39876. i--;
  39877. buffer >>= 8;
  39878. bufferSize -= 8;
  39879. }
  39880. },
  39881. readHexSigned: function (num, size) {
  39882. this.readHexNumber(num, size);
  39883. var sign = num[size] & 1 ? 255 : 0;
  39884. var c = 0;
  39885. for (var i = 0; i <= size; i++) {
  39886. c = (c & 1) << 8 | num[i];
  39887. num[i] = c >> 1 ^ sign;
  39888. }
  39889. },
  39890. readString: function () {
  39891. var len = this.readNumber();
  39892. var s = '';
  39893. for (var i = 0; i < len; i++) {
  39894. s += String.fromCharCode(this.readNumber());
  39895. }
  39896. return s;
  39897. }
  39898. };
  39899. function processBinaryCMap(url, cMap, extend) {
  39900. return fetchBinaryData(url).then(function (data) {
  39901. var stream = new BinaryCMapStream(data);
  39902. var header = stream.readByte();
  39903. cMap.vertical = !!(header & 1);
  39904. var useCMap = null;
  39905. var start = new Uint8Array(MAX_NUM_SIZE);
  39906. var end = new Uint8Array(MAX_NUM_SIZE);
  39907. var char = new Uint8Array(MAX_NUM_SIZE);
  39908. var charCode = new Uint8Array(MAX_NUM_SIZE);
  39909. var tmp = new Uint8Array(MAX_NUM_SIZE);
  39910. var code;
  39911. var b;
  39912. while ((b = stream.readByte()) >= 0) {
  39913. var type = b >> 5;
  39914. if (type === 7) {
  39915. switch (b & 0x1F) {
  39916. case 0:
  39917. stream.readString();
  39918. break;
  39919. case 1:
  39920. useCMap = stream.readString();
  39921. break;
  39922. }
  39923. continue;
  39924. }
  39925. var sequence = !!(b & 0x10);
  39926. var dataSize = b & 15;
  39927. assert(dataSize + 1 <= MAX_NUM_SIZE);
  39928. var ucs2DataSize = 1;
  39929. var subitemsCount = stream.readNumber();
  39930. var i;
  39931. switch (type) {
  39932. case 0:
  39933. stream.readHex(start, dataSize);
  39934. stream.readHexNumber(end, dataSize);
  39935. addHex(end, start, dataSize);
  39936. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39937. for (i = 1; i < subitemsCount; i++) {
  39938. incHex(end, dataSize);
  39939. stream.readHexNumber(start, dataSize);
  39940. addHex(start, end, dataSize);
  39941. stream.readHexNumber(end, dataSize);
  39942. addHex(end, start, dataSize);
  39943. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39944. }
  39945. break;
  39946. case 1:
  39947. stream.readHex(start, dataSize);
  39948. stream.readHexNumber(end, dataSize);
  39949. addHex(end, start, dataSize);
  39950. code = stream.readNumber();
  39951. for (i = 1; i < subitemsCount; i++) {
  39952. incHex(end, dataSize);
  39953. stream.readHexNumber(start, dataSize);
  39954. addHex(start, end, dataSize);
  39955. stream.readHexNumber(end, dataSize);
  39956. addHex(end, start, dataSize);
  39957. code = stream.readNumber();
  39958. }
  39959. break;
  39960. case 2:
  39961. stream.readHex(char, dataSize);
  39962. code = stream.readNumber();
  39963. cMap.mapOne(hexToInt(char, dataSize), code);
  39964. for (i = 1; i < subitemsCount; i++) {
  39965. incHex(char, dataSize);
  39966. if (!sequence) {
  39967. stream.readHexNumber(tmp, dataSize);
  39968. addHex(char, tmp, dataSize);
  39969. }
  39970. code = stream.readSigned() + (code + 1);
  39971. cMap.mapOne(hexToInt(char, dataSize), code);
  39972. }
  39973. break;
  39974. case 3:
  39975. stream.readHex(start, dataSize);
  39976. stream.readHexNumber(end, dataSize);
  39977. addHex(end, start, dataSize);
  39978. code = stream.readNumber();
  39979. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39980. for (i = 1; i < subitemsCount; i++) {
  39981. incHex(end, dataSize);
  39982. if (!sequence) {
  39983. stream.readHexNumber(start, dataSize);
  39984. addHex(start, end, dataSize);
  39985. } else {
  39986. start.set(end);
  39987. }
  39988. stream.readHexNumber(end, dataSize);
  39989. addHex(end, start, dataSize);
  39990. code = stream.readNumber();
  39991. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39992. }
  39993. break;
  39994. case 4:
  39995. stream.readHex(char, ucs2DataSize);
  39996. stream.readHex(charCode, dataSize);
  39997. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  39998. for (i = 1; i < subitemsCount; i++) {
  39999. incHex(char, ucs2DataSize);
  40000. if (!sequence) {
  40001. stream.readHexNumber(tmp, ucs2DataSize);
  40002. addHex(char, tmp, ucs2DataSize);
  40003. }
  40004. incHex(charCode, dataSize);
  40005. stream.readHexSigned(tmp, dataSize);
  40006. addHex(charCode, tmp, dataSize);
  40007. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40008. }
  40009. break;
  40010. case 5:
  40011. stream.readHex(start, ucs2DataSize);
  40012. stream.readHexNumber(end, ucs2DataSize);
  40013. addHex(end, start, ucs2DataSize);
  40014. stream.readHex(charCode, dataSize);
  40015. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40016. for (i = 1; i < subitemsCount; i++) {
  40017. incHex(end, ucs2DataSize);
  40018. if (!sequence) {
  40019. stream.readHexNumber(start, ucs2DataSize);
  40020. addHex(start, end, ucs2DataSize);
  40021. } else {
  40022. start.set(end);
  40023. }
  40024. stream.readHexNumber(end, ucs2DataSize);
  40025. addHex(end, start, ucs2DataSize);
  40026. stream.readHex(charCode, dataSize);
  40027. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40028. }
  40029. break;
  40030. default:
  40031. error('Unknown type: ' + type);
  40032. break;
  40033. }
  40034. }
  40035. if (useCMap) {
  40036. return extend(useCMap);
  40037. }
  40038. return cMap;
  40039. });
  40040. }
  40041. function BinaryCMapReader() {
  40042. }
  40043. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40044. return BinaryCMapReader;
  40045. }();
  40046. var CMapFactory = function CMapFactoryClosure() {
  40047. function strToInt(str) {
  40048. var a = 0;
  40049. for (var i = 0; i < str.length; i++) {
  40050. a = a << 8 | str.charCodeAt(i);
  40051. }
  40052. return a >>> 0;
  40053. }
  40054. function expectString(obj) {
  40055. if (!isString(obj)) {
  40056. error('Malformed CMap: expected string.');
  40057. }
  40058. }
  40059. function expectInt(obj) {
  40060. if (!isInt(obj)) {
  40061. error('Malformed CMap: expected int.');
  40062. }
  40063. }
  40064. function parseBfChar(cMap, lexer) {
  40065. while (true) {
  40066. var obj = lexer.getObj();
  40067. if (isEOF(obj)) {
  40068. break;
  40069. }
  40070. if (isCmd(obj, 'endbfchar')) {
  40071. return;
  40072. }
  40073. expectString(obj);
  40074. var src = strToInt(obj);
  40075. obj = lexer.getObj();
  40076. expectString(obj);
  40077. var dst = obj;
  40078. cMap.mapOne(src, dst);
  40079. }
  40080. }
  40081. function parseBfRange(cMap, lexer) {
  40082. while (true) {
  40083. var obj = lexer.getObj();
  40084. if (isEOF(obj)) {
  40085. break;
  40086. }
  40087. if (isCmd(obj, 'endbfrange')) {
  40088. return;
  40089. }
  40090. expectString(obj);
  40091. var low = strToInt(obj);
  40092. obj = lexer.getObj();
  40093. expectString(obj);
  40094. var high = strToInt(obj);
  40095. obj = lexer.getObj();
  40096. if (isInt(obj) || isString(obj)) {
  40097. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40098. cMap.mapBfRange(low, high, dstLow);
  40099. } else if (isCmd(obj, '[')) {
  40100. obj = lexer.getObj();
  40101. var array = [];
  40102. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40103. array.push(obj);
  40104. obj = lexer.getObj();
  40105. }
  40106. cMap.mapBfRangeToArray(low, high, array);
  40107. } else {
  40108. break;
  40109. }
  40110. }
  40111. error('Invalid bf range.');
  40112. }
  40113. function parseCidChar(cMap, lexer) {
  40114. while (true) {
  40115. var obj = lexer.getObj();
  40116. if (isEOF(obj)) {
  40117. break;
  40118. }
  40119. if (isCmd(obj, 'endcidchar')) {
  40120. return;
  40121. }
  40122. expectString(obj);
  40123. var src = strToInt(obj);
  40124. obj = lexer.getObj();
  40125. expectInt(obj);
  40126. var dst = obj;
  40127. cMap.mapOne(src, dst);
  40128. }
  40129. }
  40130. function parseCidRange(cMap, lexer) {
  40131. while (true) {
  40132. var obj = lexer.getObj();
  40133. if (isEOF(obj)) {
  40134. break;
  40135. }
  40136. if (isCmd(obj, 'endcidrange')) {
  40137. return;
  40138. }
  40139. expectString(obj);
  40140. var low = strToInt(obj);
  40141. obj = lexer.getObj();
  40142. expectString(obj);
  40143. var high = strToInt(obj);
  40144. obj = lexer.getObj();
  40145. expectInt(obj);
  40146. var dstLow = obj;
  40147. cMap.mapCidRange(low, high, dstLow);
  40148. }
  40149. }
  40150. function parseCodespaceRange(cMap, lexer) {
  40151. while (true) {
  40152. var obj = lexer.getObj();
  40153. if (isEOF(obj)) {
  40154. break;
  40155. }
  40156. if (isCmd(obj, 'endcodespacerange')) {
  40157. return;
  40158. }
  40159. if (!isString(obj)) {
  40160. break;
  40161. }
  40162. var low = strToInt(obj);
  40163. obj = lexer.getObj();
  40164. if (!isString(obj)) {
  40165. break;
  40166. }
  40167. var high = strToInt(obj);
  40168. cMap.addCodespaceRange(obj.length, low, high);
  40169. }
  40170. error('Invalid codespace range.');
  40171. }
  40172. function parseWMode(cMap, lexer) {
  40173. var obj = lexer.getObj();
  40174. if (isInt(obj)) {
  40175. cMap.vertical = !!obj;
  40176. }
  40177. }
  40178. function parseCMapName(cMap, lexer) {
  40179. var obj = lexer.getObj();
  40180. if (isName(obj) && isString(obj.name)) {
  40181. cMap.name = obj.name;
  40182. }
  40183. }
  40184. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40185. var previous;
  40186. var embededUseCMap;
  40187. objLoop:
  40188. while (true) {
  40189. try {
  40190. var obj = lexer.getObj();
  40191. if (isEOF(obj)) {
  40192. break;
  40193. } else if (isName(obj)) {
  40194. if (obj.name === 'WMode') {
  40195. parseWMode(cMap, lexer);
  40196. } else if (obj.name === 'CMapName') {
  40197. parseCMapName(cMap, lexer);
  40198. }
  40199. previous = obj;
  40200. } else if (isCmd(obj)) {
  40201. switch (obj.cmd) {
  40202. case 'endcmap':
  40203. break objLoop;
  40204. case 'usecmap':
  40205. if (isName(previous)) {
  40206. embededUseCMap = previous.name;
  40207. }
  40208. break;
  40209. case 'begincodespacerange':
  40210. parseCodespaceRange(cMap, lexer);
  40211. break;
  40212. case 'beginbfchar':
  40213. parseBfChar(cMap, lexer);
  40214. break;
  40215. case 'begincidchar':
  40216. parseCidChar(cMap, lexer);
  40217. break;
  40218. case 'beginbfrange':
  40219. parseBfRange(cMap, lexer);
  40220. break;
  40221. case 'begincidrange':
  40222. parseCidRange(cMap, lexer);
  40223. break;
  40224. }
  40225. }
  40226. } catch (ex) {
  40227. if (ex instanceof MissingDataException) {
  40228. throw ex;
  40229. }
  40230. warn('Invalid cMap data: ' + ex);
  40231. continue;
  40232. }
  40233. }
  40234. if (!useCMap && embededUseCMap) {
  40235. useCMap = embededUseCMap;
  40236. }
  40237. if (useCMap) {
  40238. return extendCMap(cMap, builtInCMapParams, useCMap);
  40239. }
  40240. return Promise.resolve(cMap);
  40241. }
  40242. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40243. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40244. cMap.useCMap = newCMap;
  40245. if (cMap.numCodespaceRanges === 0) {
  40246. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40247. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40248. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40249. }
  40250. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40251. }
  40252. cMap.useCMap.forEach(function (key, value) {
  40253. if (!cMap.contains(key)) {
  40254. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40255. }
  40256. });
  40257. return cMap;
  40258. });
  40259. }
  40260. function parseBinaryCMap(name, builtInCMapParams) {
  40261. var url = builtInCMapParams.url + name + '.bcmap';
  40262. var cMap = new CMap(true);
  40263. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40264. return extendCMap(cMap, builtInCMapParams, useCMap);
  40265. });
  40266. }
  40267. function createBuiltInCMap(name, builtInCMapParams) {
  40268. if (name === 'Identity-H') {
  40269. return Promise.resolve(new IdentityCMap(false, 2));
  40270. } else if (name === 'Identity-V') {
  40271. return Promise.resolve(new IdentityCMap(true, 2));
  40272. }
  40273. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40274. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40275. }
  40276. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40277. if (builtInCMapParams.packed) {
  40278. return parseBinaryCMap(name, builtInCMapParams);
  40279. }
  40280. return new Promise(function (resolve, reject) {
  40281. var url = builtInCMapParams.url + name;
  40282. var request = new XMLHttpRequest();
  40283. request.onreadystatechange = function () {
  40284. if (request.readyState === XMLHttpRequest.DONE) {
  40285. if (request.status === 200 || request.status === 0) {
  40286. var cMap = new CMap(true);
  40287. var lexer = new Lexer(new StringStream(request.responseText));
  40288. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40289. resolve(parsedCMap);
  40290. });
  40291. } else {
  40292. reject(new Error('Unable to get cMap at: ' + url));
  40293. }
  40294. }
  40295. };
  40296. request.open('GET', url, true);
  40297. request.send(null);
  40298. });
  40299. }
  40300. return {
  40301. create: function (encoding, builtInCMapParams, useCMap) {
  40302. if (isName(encoding)) {
  40303. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40304. } else if (isStream(encoding)) {
  40305. var cMap = new CMap();
  40306. var lexer = new Lexer(encoding);
  40307. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40308. if (parsedCMap.isIdentityCMap) {
  40309. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40310. }
  40311. return parsedCMap;
  40312. });
  40313. }
  40314. return Promise.reject(new Error('Encoding required.'));
  40315. }
  40316. };
  40317. }();
  40318. exports.CMap = CMap;
  40319. exports.CMapFactory = CMapFactory;
  40320. exports.IdentityCMap = IdentityCMap;
  40321. }));
  40322. (function (root, factory) {
  40323. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40324. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40325. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40326. var FontType = sharedUtil.FontType;
  40327. var assert = sharedUtil.assert;
  40328. var bytesToString = sharedUtil.bytesToString;
  40329. var error = sharedUtil.error;
  40330. var info = sharedUtil.info;
  40331. var isArray = sharedUtil.isArray;
  40332. var isInt = sharedUtil.isInt;
  40333. var isNum = sharedUtil.isNum;
  40334. var readUint32 = sharedUtil.readUint32;
  40335. var shadow = sharedUtil.shadow;
  40336. var string32 = sharedUtil.string32;
  40337. var warn = sharedUtil.warn;
  40338. var MissingDataException = sharedUtil.MissingDataException;
  40339. var isSpace = sharedUtil.isSpace;
  40340. var Stream = coreStream.Stream;
  40341. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40342. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40343. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40344. var StandardEncoding = coreEncodings.StandardEncoding;
  40345. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40346. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40347. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40348. var getEncoding = coreEncodings.getEncoding;
  40349. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40350. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40351. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40352. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40353. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40354. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40355. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40356. var Type1Parser = coreType1Parser.Type1Parser;
  40357. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40358. var CFFParser = coreCFFParser.CFFParser;
  40359. var CFFCompiler = coreCFFParser.CFFCompiler;
  40360. var CFF = coreCFFParser.CFF;
  40361. var CFFHeader = coreCFFParser.CFFHeader;
  40362. var CFFTopDict = coreCFFParser.CFFTopDict;
  40363. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40364. var CFFStrings = coreCFFParser.CFFStrings;
  40365. var CFFIndex = coreCFFParser.CFFIndex;
  40366. var CFFCharset = coreCFFParser.CFFCharset;
  40367. var PRIVATE_USE_OFFSET_START = 0xE000;
  40368. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40369. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40370. var PDF_GLYPH_SPACE_UNITS = 1000;
  40371. var SEAC_ANALYSIS_ENABLED = false;
  40372. var FontFlags = {
  40373. FixedPitch: 1,
  40374. Serif: 2,
  40375. Symbolic: 4,
  40376. Script: 8,
  40377. Nonsymbolic: 32,
  40378. Italic: 64,
  40379. AllCap: 65536,
  40380. SmallCap: 131072,
  40381. ForceBold: 262144
  40382. };
  40383. var MacStandardGlyphOrdering = [
  40384. '.notdef',
  40385. '.null',
  40386. 'nonmarkingreturn',
  40387. 'space',
  40388. 'exclam',
  40389. 'quotedbl',
  40390. 'numbersign',
  40391. 'dollar',
  40392. 'percent',
  40393. 'ampersand',
  40394. 'quotesingle',
  40395. 'parenleft',
  40396. 'parenright',
  40397. 'asterisk',
  40398. 'plus',
  40399. 'comma',
  40400. 'hyphen',
  40401. 'period',
  40402. 'slash',
  40403. 'zero',
  40404. 'one',
  40405. 'two',
  40406. 'three',
  40407. 'four',
  40408. 'five',
  40409. 'six',
  40410. 'seven',
  40411. 'eight',
  40412. 'nine',
  40413. 'colon',
  40414. 'semicolon',
  40415. 'less',
  40416. 'equal',
  40417. 'greater',
  40418. 'question',
  40419. 'at',
  40420. 'A',
  40421. 'B',
  40422. 'C',
  40423. 'D',
  40424. 'E',
  40425. 'F',
  40426. 'G',
  40427. 'H',
  40428. 'I',
  40429. 'J',
  40430. 'K',
  40431. 'L',
  40432. 'M',
  40433. 'N',
  40434. 'O',
  40435. 'P',
  40436. 'Q',
  40437. 'R',
  40438. 'S',
  40439. 'T',
  40440. 'U',
  40441. 'V',
  40442. 'W',
  40443. 'X',
  40444. 'Y',
  40445. 'Z',
  40446. 'bracketleft',
  40447. 'backslash',
  40448. 'bracketright',
  40449. 'asciicircum',
  40450. 'underscore',
  40451. 'grave',
  40452. 'a',
  40453. 'b',
  40454. 'c',
  40455. 'd',
  40456. 'e',
  40457. 'f',
  40458. 'g',
  40459. 'h',
  40460. 'i',
  40461. 'j',
  40462. 'k',
  40463. 'l',
  40464. 'm',
  40465. 'n',
  40466. 'o',
  40467. 'p',
  40468. 'q',
  40469. 'r',
  40470. 's',
  40471. 't',
  40472. 'u',
  40473. 'v',
  40474. 'w',
  40475. 'x',
  40476. 'y',
  40477. 'z',
  40478. 'braceleft',
  40479. 'bar',
  40480. 'braceright',
  40481. 'asciitilde',
  40482. 'Adieresis',
  40483. 'Aring',
  40484. 'Ccedilla',
  40485. 'Eacute',
  40486. 'Ntilde',
  40487. 'Odieresis',
  40488. 'Udieresis',
  40489. 'aacute',
  40490. 'agrave',
  40491. 'acircumflex',
  40492. 'adieresis',
  40493. 'atilde',
  40494. 'aring',
  40495. 'ccedilla',
  40496. 'eacute',
  40497. 'egrave',
  40498. 'ecircumflex',
  40499. 'edieresis',
  40500. 'iacute',
  40501. 'igrave',
  40502. 'icircumflex',
  40503. 'idieresis',
  40504. 'ntilde',
  40505. 'oacute',
  40506. 'ograve',
  40507. 'ocircumflex',
  40508. 'odieresis',
  40509. 'otilde',
  40510. 'uacute',
  40511. 'ugrave',
  40512. 'ucircumflex',
  40513. 'udieresis',
  40514. 'dagger',
  40515. 'degree',
  40516. 'cent',
  40517. 'sterling',
  40518. 'section',
  40519. 'bullet',
  40520. 'paragraph',
  40521. 'germandbls',
  40522. 'registered',
  40523. 'copyright',
  40524. 'trademark',
  40525. 'acute',
  40526. 'dieresis',
  40527. 'notequal',
  40528. 'AE',
  40529. 'Oslash',
  40530. 'infinity',
  40531. 'plusminus',
  40532. 'lessequal',
  40533. 'greaterequal',
  40534. 'yen',
  40535. 'mu',
  40536. 'partialdiff',
  40537. 'summation',
  40538. 'product',
  40539. 'pi',
  40540. 'integral',
  40541. 'ordfeminine',
  40542. 'ordmasculine',
  40543. 'Omega',
  40544. 'ae',
  40545. 'oslash',
  40546. 'questiondown',
  40547. 'exclamdown',
  40548. 'logicalnot',
  40549. 'radical',
  40550. 'florin',
  40551. 'approxequal',
  40552. 'Delta',
  40553. 'guillemotleft',
  40554. 'guillemotright',
  40555. 'ellipsis',
  40556. 'nonbreakingspace',
  40557. 'Agrave',
  40558. 'Atilde',
  40559. 'Otilde',
  40560. 'OE',
  40561. 'oe',
  40562. 'endash',
  40563. 'emdash',
  40564. 'quotedblleft',
  40565. 'quotedblright',
  40566. 'quoteleft',
  40567. 'quoteright',
  40568. 'divide',
  40569. 'lozenge',
  40570. 'ydieresis',
  40571. 'Ydieresis',
  40572. 'fraction',
  40573. 'currency',
  40574. 'guilsinglleft',
  40575. 'guilsinglright',
  40576. 'fi',
  40577. 'fl',
  40578. 'daggerdbl',
  40579. 'periodcentered',
  40580. 'quotesinglbase',
  40581. 'quotedblbase',
  40582. 'perthousand',
  40583. 'Acircumflex',
  40584. 'Ecircumflex',
  40585. 'Aacute',
  40586. 'Edieresis',
  40587. 'Egrave',
  40588. 'Iacute',
  40589. 'Icircumflex',
  40590. 'Idieresis',
  40591. 'Igrave',
  40592. 'Oacute',
  40593. 'Ocircumflex',
  40594. 'apple',
  40595. 'Ograve',
  40596. 'Uacute',
  40597. 'Ucircumflex',
  40598. 'Ugrave',
  40599. 'dotlessi',
  40600. 'circumflex',
  40601. 'tilde',
  40602. 'macron',
  40603. 'breve',
  40604. 'dotaccent',
  40605. 'ring',
  40606. 'cedilla',
  40607. 'hungarumlaut',
  40608. 'ogonek',
  40609. 'caron',
  40610. 'Lslash',
  40611. 'lslash',
  40612. 'Scaron',
  40613. 'scaron',
  40614. 'Zcaron',
  40615. 'zcaron',
  40616. 'brokenbar',
  40617. 'Eth',
  40618. 'eth',
  40619. 'Yacute',
  40620. 'yacute',
  40621. 'Thorn',
  40622. 'thorn',
  40623. 'minus',
  40624. 'multiply',
  40625. 'onesuperior',
  40626. 'twosuperior',
  40627. 'threesuperior',
  40628. 'onehalf',
  40629. 'onequarter',
  40630. 'threequarters',
  40631. 'franc',
  40632. 'Gbreve',
  40633. 'gbreve',
  40634. 'Idotaccent',
  40635. 'Scedilla',
  40636. 'scedilla',
  40637. 'Cacute',
  40638. 'cacute',
  40639. 'Ccaron',
  40640. 'ccaron',
  40641. 'dcroat'
  40642. ];
  40643. function adjustWidths(properties) {
  40644. if (!properties.fontMatrix) {
  40645. return;
  40646. }
  40647. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40648. return;
  40649. }
  40650. var scale = 0.001 / properties.fontMatrix[0];
  40651. var glyphsWidths = properties.widths;
  40652. for (var glyph in glyphsWidths) {
  40653. glyphsWidths[glyph] *= scale;
  40654. }
  40655. properties.defaultWidth *= scale;
  40656. }
  40657. function adjustToUnicode(properties, builtInEncoding) {
  40658. if (properties.hasIncludedToUnicodeMap) {
  40659. return;
  40660. }
  40661. if (properties.hasEncoding) {
  40662. return;
  40663. }
  40664. if (builtInEncoding === properties.defaultEncoding) {
  40665. return;
  40666. }
  40667. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40668. return;
  40669. }
  40670. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40671. for (var charCode in builtInEncoding) {
  40672. var glyphName = builtInEncoding[charCode];
  40673. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40674. if (unicode !== -1) {
  40675. toUnicode[charCode] = String.fromCharCode(unicode);
  40676. }
  40677. }
  40678. properties.toUnicode.amend(toUnicode);
  40679. }
  40680. function getFontType(type, subtype) {
  40681. switch (type) {
  40682. case 'Type1':
  40683. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40684. case 'CIDFontType0':
  40685. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40686. case 'OpenType':
  40687. return FontType.OPENTYPE;
  40688. case 'TrueType':
  40689. return FontType.TRUETYPE;
  40690. case 'CIDFontType2':
  40691. return FontType.CIDFONTTYPE2;
  40692. case 'MMType1':
  40693. return FontType.MMTYPE1;
  40694. case 'Type0':
  40695. return FontType.TYPE0;
  40696. default:
  40697. return FontType.UNKNOWN;
  40698. }
  40699. }
  40700. function recoverGlyphName(name, glyphsUnicodeMap) {
  40701. if (glyphsUnicodeMap[name] !== undefined) {
  40702. return name;
  40703. }
  40704. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40705. if (unicode !== -1) {
  40706. for (var key in glyphsUnicodeMap) {
  40707. if (glyphsUnicodeMap[key] === unicode) {
  40708. return key;
  40709. }
  40710. }
  40711. }
  40712. info('Unable to recover a standard glyph name for: ' + name);
  40713. return name;
  40714. }
  40715. var Glyph = function GlyphClosure() {
  40716. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40717. this.fontChar = fontChar;
  40718. this.unicode = unicode;
  40719. this.accent = accent;
  40720. this.width = width;
  40721. this.vmetric = vmetric;
  40722. this.operatorListId = operatorListId;
  40723. this.isSpace = isSpace;
  40724. this.isInFont = isInFont;
  40725. }
  40726. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40727. 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;
  40728. };
  40729. return Glyph;
  40730. }();
  40731. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40732. function ToUnicodeMap(cmap) {
  40733. this._map = cmap;
  40734. }
  40735. ToUnicodeMap.prototype = {
  40736. get length() {
  40737. return this._map.length;
  40738. },
  40739. forEach: function (callback) {
  40740. for (var charCode in this._map) {
  40741. callback(charCode, this._map[charCode].charCodeAt(0));
  40742. }
  40743. },
  40744. has: function (i) {
  40745. return this._map[i] !== undefined;
  40746. },
  40747. get: function (i) {
  40748. return this._map[i];
  40749. },
  40750. charCodeOf: function (v) {
  40751. return this._map.indexOf(v);
  40752. },
  40753. amend: function (map) {
  40754. for (var charCode in map) {
  40755. this._map[charCode] = map[charCode];
  40756. }
  40757. }
  40758. };
  40759. return ToUnicodeMap;
  40760. }();
  40761. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40762. function IdentityToUnicodeMap(firstChar, lastChar) {
  40763. this.firstChar = firstChar;
  40764. this.lastChar = lastChar;
  40765. }
  40766. IdentityToUnicodeMap.prototype = {
  40767. get length() {
  40768. return this.lastChar + 1 - this.firstChar;
  40769. },
  40770. forEach: function (callback) {
  40771. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40772. callback(i, i);
  40773. }
  40774. },
  40775. has: function (i) {
  40776. return this.firstChar <= i && i <= this.lastChar;
  40777. },
  40778. get: function (i) {
  40779. if (this.firstChar <= i && i <= this.lastChar) {
  40780. return String.fromCharCode(i);
  40781. }
  40782. return undefined;
  40783. },
  40784. charCodeOf: function (v) {
  40785. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40786. },
  40787. amend: function (map) {
  40788. error('Should not call amend()');
  40789. }
  40790. };
  40791. return IdentityToUnicodeMap;
  40792. }();
  40793. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40794. function writeInt16(dest, offset, num) {
  40795. dest[offset] = num >> 8 & 0xFF;
  40796. dest[offset + 1] = num & 0xFF;
  40797. }
  40798. function writeInt32(dest, offset, num) {
  40799. dest[offset] = num >> 24 & 0xFF;
  40800. dest[offset + 1] = num >> 16 & 0xFF;
  40801. dest[offset + 2] = num >> 8 & 0xFF;
  40802. dest[offset + 3] = num & 0xFF;
  40803. }
  40804. function writeData(dest, offset, data) {
  40805. var i, ii;
  40806. if (data instanceof Uint8Array) {
  40807. dest.set(data, offset);
  40808. } else if (typeof data === 'string') {
  40809. for (i = 0, ii = data.length; i < ii; i++) {
  40810. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40811. }
  40812. } else {
  40813. for (i = 0, ii = data.length; i < ii; i++) {
  40814. dest[offset++] = data[i] & 0xFF;
  40815. }
  40816. }
  40817. }
  40818. function OpenTypeFileBuilder(sfnt) {
  40819. this.sfnt = sfnt;
  40820. this.tables = Object.create(null);
  40821. }
  40822. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40823. var maxPower2 = 1, log2 = 0;
  40824. while ((maxPower2 ^ entriesCount) > maxPower2) {
  40825. maxPower2 <<= 1;
  40826. log2++;
  40827. }
  40828. var searchRange = maxPower2 * entrySize;
  40829. return {
  40830. range: searchRange,
  40831. entry: log2,
  40832. rangeShift: entrySize * entriesCount - searchRange
  40833. };
  40834. };
  40835. var OTF_HEADER_SIZE = 12;
  40836. var OTF_TABLE_ENTRY_SIZE = 16;
  40837. OpenTypeFileBuilder.prototype = {
  40838. toArray: function OpenTypeFileBuilder_toArray() {
  40839. var sfnt = this.sfnt;
  40840. var tables = this.tables;
  40841. var tablesNames = Object.keys(tables);
  40842. tablesNames.sort();
  40843. var numTables = tablesNames.length;
  40844. var i, j, jj, table, tableName;
  40845. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  40846. var tableOffsets = [offset];
  40847. for (i = 0; i < numTables; i++) {
  40848. table = tables[tablesNames[i]];
  40849. var paddedLength = (table.length + 3 & ~3) >>> 0;
  40850. offset += paddedLength;
  40851. tableOffsets.push(offset);
  40852. }
  40853. var file = new Uint8Array(offset);
  40854. for (i = 0; i < numTables; i++) {
  40855. table = tables[tablesNames[i]];
  40856. writeData(file, tableOffsets[i], table);
  40857. }
  40858. if (sfnt === 'true') {
  40859. sfnt = string32(0x00010000);
  40860. }
  40861. file[0] = sfnt.charCodeAt(0) & 0xFF;
  40862. file[1] = sfnt.charCodeAt(1) & 0xFF;
  40863. file[2] = sfnt.charCodeAt(2) & 0xFF;
  40864. file[3] = sfnt.charCodeAt(3) & 0xFF;
  40865. writeInt16(file, 4, numTables);
  40866. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  40867. writeInt16(file, 6, searchParams.range);
  40868. writeInt16(file, 8, searchParams.entry);
  40869. writeInt16(file, 10, searchParams.rangeShift);
  40870. offset = OTF_HEADER_SIZE;
  40871. for (i = 0; i < numTables; i++) {
  40872. tableName = tablesNames[i];
  40873. file[offset] = tableName.charCodeAt(0) & 0xFF;
  40874. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  40875. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  40876. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  40877. var checksum = 0;
  40878. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  40879. var quad = readUint32(file, j);
  40880. checksum = checksum + quad >>> 0;
  40881. }
  40882. writeInt32(file, offset + 4, checksum);
  40883. writeInt32(file, offset + 8, tableOffsets[i]);
  40884. writeInt32(file, offset + 12, tables[tableName].length);
  40885. offset += OTF_TABLE_ENTRY_SIZE;
  40886. }
  40887. return file;
  40888. },
  40889. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  40890. if (tag in this.tables) {
  40891. throw new Error('Table ' + tag + ' already exists');
  40892. }
  40893. this.tables[tag] = data;
  40894. }
  40895. };
  40896. return OpenTypeFileBuilder;
  40897. }();
  40898. var ProblematicCharRanges = new Int32Array([
  40899. 0x0000,
  40900. 0x0020,
  40901. 0x007F,
  40902. 0x00A1,
  40903. 0x00AD,
  40904. 0x00AE,
  40905. 0x0600,
  40906. 0x0780,
  40907. 0x08A0,
  40908. 0x10A0,
  40909. 0x1780,
  40910. 0x1800,
  40911. 0x1C00,
  40912. 0x1C50,
  40913. 0x2000,
  40914. 0x2010,
  40915. 0x2011,
  40916. 0x2012,
  40917. 0x2028,
  40918. 0x2030,
  40919. 0x205F,
  40920. 0x2070,
  40921. 0x25CC,
  40922. 0x25CD,
  40923. 0x3000,
  40924. 0x3001,
  40925. 0xAA60,
  40926. 0xAA80,
  40927. 0xFFF0,
  40928. 0x10000
  40929. ]);
  40930. var Font = function FontClosure() {
  40931. function Font(name, file, properties) {
  40932. var charCode, glyphName, unicode;
  40933. this.name = name;
  40934. this.loadedName = properties.loadedName;
  40935. this.isType3Font = properties.isType3Font;
  40936. this.sizes = [];
  40937. this.missingFile = false;
  40938. this.glyphCache = Object.create(null);
  40939. var names = name.split('+');
  40940. names = names.length > 1 ? names[1] : names[0];
  40941. names = names.split(/[-,_]/g)[0];
  40942. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  40943. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  40944. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  40945. var type = properties.type;
  40946. var subtype = properties.subtype;
  40947. this.type = type;
  40948. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  40949. this.differences = properties.differences;
  40950. this.widths = properties.widths;
  40951. this.defaultWidth = properties.defaultWidth;
  40952. this.composite = properties.composite;
  40953. this.wideChars = properties.wideChars;
  40954. this.cMap = properties.cMap;
  40955. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  40956. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  40957. this.fontMatrix = properties.fontMatrix;
  40958. this.bbox = properties.bbox;
  40959. this.toUnicode = properties.toUnicode;
  40960. this.toFontChar = [];
  40961. if (properties.type === 'Type3') {
  40962. for (charCode = 0; charCode < 256; charCode++) {
  40963. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  40964. }
  40965. this.fontType = FontType.TYPE3;
  40966. return;
  40967. }
  40968. this.cidEncoding = properties.cidEncoding;
  40969. this.vertical = properties.vertical;
  40970. if (this.vertical) {
  40971. this.vmetrics = properties.vmetrics;
  40972. this.defaultVMetrics = properties.defaultVMetrics;
  40973. }
  40974. var glyphsUnicodeMap;
  40975. if (!file || file.isEmpty) {
  40976. if (file) {
  40977. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  40978. }
  40979. this.missingFile = true;
  40980. var fontName = name.replace(/[,_]/g, '-');
  40981. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  40982. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  40983. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  40984. this.bold = fontName.search(/bold/gi) !== -1;
  40985. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  40986. this.black = name.search(/Black/g) !== -1;
  40987. this.remeasure = Object.keys(this.widths).length > 0;
  40988. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  40989. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  40990. var map = [];
  40991. for (charCode in GlyphMapForStandardFonts) {
  40992. map[+charCode] = GlyphMapForStandardFonts[charCode];
  40993. }
  40994. if (/ArialBlack/i.test(name)) {
  40995. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  40996. for (charCode in SupplementalGlyphMapForArialBlack) {
  40997. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  40998. }
  40999. }
  41000. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41001. if (!isIdentityUnicode) {
  41002. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41003. map[+charCode] = unicodeCharCode;
  41004. });
  41005. }
  41006. this.toFontChar = map;
  41007. this.toUnicode = new ToUnicodeMap(map);
  41008. } else if (/Symbol/i.test(fontName)) {
  41009. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41010. } else if (/Dingbats/i.test(fontName)) {
  41011. if (/Wingdings/i.test(name)) {
  41012. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41013. }
  41014. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41015. } else if (isStandardFont) {
  41016. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41017. } else {
  41018. glyphsUnicodeMap = getGlyphsUnicode();
  41019. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41020. if (!this.composite) {
  41021. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41022. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41023. if (unicode !== -1) {
  41024. unicodeCharCode = unicode;
  41025. }
  41026. }
  41027. this.toFontChar[charCode] = unicodeCharCode;
  41028. }.bind(this));
  41029. }
  41030. this.loadedName = fontName.split('-')[0];
  41031. this.loading = false;
  41032. this.fontType = getFontType(type, subtype);
  41033. return;
  41034. }
  41035. if (subtype === 'Type1C') {
  41036. if (type !== 'Type1' && type !== 'MMType1') {
  41037. if (isTrueTypeFile(file)) {
  41038. subtype = 'TrueType';
  41039. } else {
  41040. type = 'Type1';
  41041. }
  41042. } else if (isOpenTypeFile(file)) {
  41043. type = subtype = 'OpenType';
  41044. }
  41045. }
  41046. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41047. type = 'CIDFontType0';
  41048. }
  41049. if (subtype === 'OpenType') {
  41050. type = 'OpenType';
  41051. }
  41052. if (type === 'CIDFontType0') {
  41053. if (isType1File(file)) {
  41054. subtype = 'CIDFontType0';
  41055. } else if (isOpenTypeFile(file)) {
  41056. type = subtype = 'OpenType';
  41057. } else {
  41058. subtype = 'CIDFontType0C';
  41059. }
  41060. }
  41061. var data;
  41062. switch (type) {
  41063. case 'MMType1':
  41064. info('MMType1 font (' + name + '), falling back to Type1.');
  41065. case 'Type1':
  41066. case 'CIDFontType0':
  41067. this.mimetype = 'font/opentype';
  41068. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41069. adjustWidths(properties);
  41070. data = this.convert(name, cff, properties);
  41071. break;
  41072. case 'OpenType':
  41073. case 'TrueType':
  41074. case 'CIDFontType2':
  41075. this.mimetype = 'font/opentype';
  41076. data = this.checkAndRepair(name, file, properties);
  41077. if (this.isOpenType) {
  41078. adjustWidths(properties);
  41079. type = 'OpenType';
  41080. }
  41081. break;
  41082. default:
  41083. error('Font ' + type + ' is not supported');
  41084. break;
  41085. }
  41086. this.data = data;
  41087. this.fontType = getFontType(type, subtype);
  41088. this.fontMatrix = properties.fontMatrix;
  41089. this.widths = properties.widths;
  41090. this.defaultWidth = properties.defaultWidth;
  41091. this.toUnicode = properties.toUnicode;
  41092. this.encoding = properties.baseEncoding;
  41093. this.seacMap = properties.seacMap;
  41094. this.loading = true;
  41095. }
  41096. Font.getFontID = function () {
  41097. var ID = 1;
  41098. return function Font_getFontID() {
  41099. return String(ID++);
  41100. };
  41101. }();
  41102. function int16(b0, b1) {
  41103. return (b0 << 8) + b1;
  41104. }
  41105. function signedInt16(b0, b1) {
  41106. var value = (b0 << 8) + b1;
  41107. return value & 1 << 15 ? value - 0x10000 : value;
  41108. }
  41109. function int32(b0, b1, b2, b3) {
  41110. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41111. }
  41112. function string16(value) {
  41113. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41114. }
  41115. function safeString16(value) {
  41116. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41117. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41118. }
  41119. function isTrueTypeFile(file) {
  41120. var header = file.peekBytes(4);
  41121. return readUint32(header, 0) === 0x00010000;
  41122. }
  41123. function isOpenTypeFile(file) {
  41124. var header = file.peekBytes(4);
  41125. return bytesToString(header) === 'OTTO';
  41126. }
  41127. function isType1File(file) {
  41128. var header = file.peekBytes(2);
  41129. if (header[0] === 0x25 && header[1] === 0x21) {
  41130. return true;
  41131. }
  41132. if (header[0] === 0x80 && header[1] === 0x01) {
  41133. return true;
  41134. }
  41135. return false;
  41136. }
  41137. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41138. var toFontChar = [], unicode;
  41139. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41140. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41141. if (unicode !== -1) {
  41142. toFontChar[i] = unicode;
  41143. }
  41144. }
  41145. for (var charCode in differences) {
  41146. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41147. if (unicode !== -1) {
  41148. toFontChar[+charCode] = unicode;
  41149. }
  41150. }
  41151. return toFontChar;
  41152. }
  41153. function isProblematicUnicodeLocation(code) {
  41154. var i = 0, j = ProblematicCharRanges.length - 1;
  41155. while (i < j) {
  41156. var c = i + j + 1 >> 1;
  41157. if (code < ProblematicCharRanges[c]) {
  41158. j = c - 1;
  41159. } else {
  41160. i = c;
  41161. }
  41162. }
  41163. return !(i & 1);
  41164. }
  41165. function adjustMapping(charCodeToGlyphId, properties) {
  41166. var toUnicode = properties.toUnicode;
  41167. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41168. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41169. var newMap = Object.create(null);
  41170. var toFontChar = [];
  41171. var usedFontCharCodes = [];
  41172. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41173. for (var originalCharCode in charCodeToGlyphId) {
  41174. originalCharCode |= 0;
  41175. var glyphId = charCodeToGlyphId[originalCharCode];
  41176. var fontCharCode = originalCharCode;
  41177. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41178. var unicode = toUnicode.get(fontCharCode);
  41179. if (unicode.length === 1) {
  41180. fontCharCode = unicode.charCodeAt(0);
  41181. }
  41182. }
  41183. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && isIdentityUnicode) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41184. do {
  41185. fontCharCode = nextAvailableFontCharCode++;
  41186. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41187. fontCharCode = 0xF020;
  41188. nextAvailableFontCharCode = fontCharCode + 1;
  41189. }
  41190. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41191. }
  41192. newMap[fontCharCode] = glyphId;
  41193. toFontChar[originalCharCode] = fontCharCode;
  41194. usedFontCharCodes[fontCharCode] = true;
  41195. }
  41196. return {
  41197. toFontChar: toFontChar,
  41198. charCodeToGlyphId: newMap,
  41199. nextAvailableFontCharCode: nextAvailableFontCharCode
  41200. };
  41201. }
  41202. function getRanges(glyphs, numGlyphs) {
  41203. var codes = [];
  41204. for (var charCode in glyphs) {
  41205. if (glyphs[charCode] >= numGlyphs) {
  41206. continue;
  41207. }
  41208. codes.push({
  41209. fontCharCode: charCode | 0,
  41210. glyphId: glyphs[charCode]
  41211. });
  41212. }
  41213. codes.sort(function fontGetRangesSort(a, b) {
  41214. return a.fontCharCode - b.fontCharCode;
  41215. });
  41216. var ranges = [];
  41217. var length = codes.length;
  41218. for (var n = 0; n < length;) {
  41219. var start = codes[n].fontCharCode;
  41220. var codeIndices = [codes[n].glyphId];
  41221. ++n;
  41222. var end = start;
  41223. while (n < length && end + 1 === codes[n].fontCharCode) {
  41224. codeIndices.push(codes[n].glyphId);
  41225. ++end;
  41226. ++n;
  41227. if (end === 0xFFFF) {
  41228. break;
  41229. }
  41230. }
  41231. ranges.push([
  41232. start,
  41233. end,
  41234. codeIndices
  41235. ]);
  41236. }
  41237. return ranges;
  41238. }
  41239. function createCmapTable(glyphs, numGlyphs) {
  41240. var ranges = getRanges(glyphs, numGlyphs);
  41241. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41242. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41243. var i, ii, j, jj;
  41244. for (i = ranges.length - 1; i >= 0; --i) {
  41245. if (ranges[i][0] <= 0xFFFF) {
  41246. break;
  41247. }
  41248. }
  41249. var bmpLength = i + 1;
  41250. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41251. ranges[i][1] = 0xFFFE;
  41252. }
  41253. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41254. var segCount = bmpLength + trailingRangesCount;
  41255. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41256. var startCount = '';
  41257. var endCount = '';
  41258. var idDeltas = '';
  41259. var idRangeOffsets = '';
  41260. var glyphsIds = '';
  41261. var bias = 0;
  41262. var range, start, end, codes;
  41263. for (i = 0, ii = bmpLength; i < ii; i++) {
  41264. range = ranges[i];
  41265. start = range[0];
  41266. end = range[1];
  41267. startCount += string16(start);
  41268. endCount += string16(end);
  41269. codes = range[2];
  41270. var contiguous = true;
  41271. for (j = 1, jj = codes.length; j < jj; ++j) {
  41272. if (codes[j] !== codes[j - 1] + 1) {
  41273. contiguous = false;
  41274. break;
  41275. }
  41276. }
  41277. if (!contiguous) {
  41278. var offset = (segCount - i) * 2 + bias * 2;
  41279. bias += end - start + 1;
  41280. idDeltas += string16(0);
  41281. idRangeOffsets += string16(offset);
  41282. for (j = 0, jj = codes.length; j < jj; ++j) {
  41283. glyphsIds += string16(codes[j]);
  41284. }
  41285. } else {
  41286. var startCode = codes[0];
  41287. idDeltas += string16(startCode - start & 0xFFFF);
  41288. idRangeOffsets += string16(0);
  41289. }
  41290. }
  41291. if (trailingRangesCount > 0) {
  41292. endCount += '\xFF\xFF';
  41293. startCount += '\xFF\xFF';
  41294. idDeltas += '\x00\x01';
  41295. idRangeOffsets += '\x00\x00';
  41296. }
  41297. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41298. var format31012 = '';
  41299. var header31012 = '';
  41300. if (numTables > 1) {
  41301. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41302. format31012 = '';
  41303. for (i = 0, ii = ranges.length; i < ii; i++) {
  41304. range = ranges[i];
  41305. start = range[0];
  41306. codes = range[2];
  41307. var code = codes[0];
  41308. for (j = 1, jj = codes.length; j < jj; ++j) {
  41309. if (codes[j] !== codes[j - 1] + 1) {
  41310. end = range[0] + j - 1;
  41311. format31012 += string32(start) + string32(end) + string32(code);
  41312. start = end + 1;
  41313. code = codes[j];
  41314. }
  41315. }
  41316. format31012 += string32(start) + string32(range[1]) + string32(code);
  41317. }
  41318. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41319. }
  41320. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41321. }
  41322. function validateOS2Table(os2) {
  41323. var stream = new Stream(os2.data);
  41324. var version = stream.getUint16();
  41325. stream.getBytes(60);
  41326. var selection = stream.getUint16();
  41327. if (version < 4 && selection & 0x0300) {
  41328. return false;
  41329. }
  41330. var firstChar = stream.getUint16();
  41331. var lastChar = stream.getUint16();
  41332. if (firstChar > lastChar) {
  41333. return false;
  41334. }
  41335. stream.getBytes(6);
  41336. var usWinAscent = stream.getUint16();
  41337. if (usWinAscent === 0) {
  41338. return false;
  41339. }
  41340. os2.data[8] = os2.data[9] = 0;
  41341. return true;
  41342. }
  41343. function createOS2Table(properties, charstrings, override) {
  41344. override = override || {
  41345. unitsPerEm: 0,
  41346. yMax: 0,
  41347. yMin: 0,
  41348. ascent: 0,
  41349. descent: 0
  41350. };
  41351. var ulUnicodeRange1 = 0;
  41352. var ulUnicodeRange2 = 0;
  41353. var ulUnicodeRange3 = 0;
  41354. var ulUnicodeRange4 = 0;
  41355. var firstCharIndex = null;
  41356. var lastCharIndex = 0;
  41357. if (charstrings) {
  41358. for (var code in charstrings) {
  41359. code |= 0;
  41360. if (firstCharIndex > code || !firstCharIndex) {
  41361. firstCharIndex = code;
  41362. }
  41363. if (lastCharIndex < code) {
  41364. lastCharIndex = code;
  41365. }
  41366. var position = getUnicodeRangeFor(code);
  41367. if (position < 32) {
  41368. ulUnicodeRange1 |= 1 << position;
  41369. } else if (position < 64) {
  41370. ulUnicodeRange2 |= 1 << position - 32;
  41371. } else if (position < 96) {
  41372. ulUnicodeRange3 |= 1 << position - 64;
  41373. } else if (position < 123) {
  41374. ulUnicodeRange4 |= 1 << position - 96;
  41375. } else {
  41376. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41377. }
  41378. }
  41379. } else {
  41380. firstCharIndex = 0;
  41381. lastCharIndex = 255;
  41382. }
  41383. var bbox = properties.bbox || [
  41384. 0,
  41385. 0,
  41386. 0,
  41387. 0
  41388. ];
  41389. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41390. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41391. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41392. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41393. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41394. typoDescent = -typoDescent;
  41395. }
  41396. var winAscent = override.yMax || typoAscent;
  41397. var winDescent = -override.yMin || -typoDescent;
  41398. 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';
  41399. }
  41400. function createPostTable(properties) {
  41401. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41402. 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';
  41403. }
  41404. function createNameTable(name, proto) {
  41405. if (!proto) {
  41406. proto = [
  41407. [],
  41408. []
  41409. ];
  41410. }
  41411. var strings = [
  41412. proto[0][0] || 'Original licence',
  41413. proto[0][1] || name,
  41414. proto[0][2] || 'Unknown',
  41415. proto[0][3] || 'uniqueID',
  41416. proto[0][4] || name,
  41417. proto[0][5] || 'Version 0.11',
  41418. proto[0][6] || '',
  41419. proto[0][7] || 'Unknown',
  41420. proto[0][8] || 'Unknown',
  41421. proto[0][9] || 'Unknown'
  41422. ];
  41423. var stringsUnicode = [];
  41424. var i, ii, j, jj, str;
  41425. for (i = 0, ii = strings.length; i < ii; i++) {
  41426. str = proto[1][i] || strings[i];
  41427. var strBufUnicode = [];
  41428. for (j = 0, jj = str.length; j < jj; j++) {
  41429. strBufUnicode.push(string16(str.charCodeAt(j)));
  41430. }
  41431. stringsUnicode.push(strBufUnicode.join(''));
  41432. }
  41433. var names = [
  41434. strings,
  41435. stringsUnicode
  41436. ];
  41437. var platforms = [
  41438. '\x00\x01',
  41439. '\x00\x03'
  41440. ];
  41441. var encodings = [
  41442. '\x00\x00',
  41443. '\x00\x01'
  41444. ];
  41445. var languages = [
  41446. '\x00\x00',
  41447. '\x04\x09'
  41448. ];
  41449. var namesRecordCount = strings.length * platforms.length;
  41450. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41451. var strOffset = 0;
  41452. for (i = 0, ii = platforms.length; i < ii; i++) {
  41453. var strs = names[i];
  41454. for (j = 0, jj = strs.length; j < jj; j++) {
  41455. str = strs[j];
  41456. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41457. nameTable += nameRecord;
  41458. strOffset += str.length;
  41459. }
  41460. }
  41461. nameTable += strings.join('') + stringsUnicode.join('');
  41462. return nameTable;
  41463. }
  41464. Font.prototype = {
  41465. name: null,
  41466. font: null,
  41467. mimetype: null,
  41468. encoding: null,
  41469. get renderer() {
  41470. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41471. return shadow(this, 'renderer', renderer);
  41472. },
  41473. exportData: function Font_exportData() {
  41474. var data = {};
  41475. for (var i in this) {
  41476. if (this.hasOwnProperty(i)) {
  41477. data[i] = this[i];
  41478. }
  41479. }
  41480. return data;
  41481. },
  41482. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41483. function readTableEntry(file) {
  41484. var tag = bytesToString(file.getBytes(4));
  41485. var checksum = file.getInt32() >>> 0;
  41486. var offset = file.getInt32() >>> 0;
  41487. var length = file.getInt32() >>> 0;
  41488. var previousPosition = file.pos;
  41489. file.pos = file.start ? file.start : 0;
  41490. file.skip(offset);
  41491. var data = file.getBytes(length);
  41492. file.pos = previousPosition;
  41493. if (tag === 'head') {
  41494. data[8] = data[9] = data[10] = data[11] = 0;
  41495. data[17] |= 0x20;
  41496. }
  41497. return {
  41498. tag: tag,
  41499. checksum: checksum,
  41500. length: length,
  41501. offset: offset,
  41502. data: data
  41503. };
  41504. }
  41505. function readOpenTypeHeader(ttf) {
  41506. return {
  41507. version: bytesToString(ttf.getBytes(4)),
  41508. numTables: ttf.getUint16(),
  41509. searchRange: ttf.getUint16(),
  41510. entrySelector: ttf.getUint16(),
  41511. rangeShift: ttf.getUint16()
  41512. };
  41513. }
  41514. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41515. if (!cmap) {
  41516. warn('No cmap table available.');
  41517. return {
  41518. platformId: -1,
  41519. encodingId: -1,
  41520. mappings: [],
  41521. hasShortCmap: false
  41522. };
  41523. }
  41524. var segment;
  41525. var start = (font.start ? font.start : 0) + cmap.offset;
  41526. font.pos = start;
  41527. var version = font.getUint16();
  41528. var numTables = font.getUint16();
  41529. var potentialTable;
  41530. var canBreak = false;
  41531. for (var i = 0; i < numTables; i++) {
  41532. var platformId = font.getUint16();
  41533. var encodingId = font.getUint16();
  41534. var offset = font.getInt32() >>> 0;
  41535. var useTable = false;
  41536. if (platformId === 0 && encodingId === 0) {
  41537. useTable = true;
  41538. } else if (platformId === 1 && encodingId === 0) {
  41539. useTable = true;
  41540. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41541. useTable = true;
  41542. if (!isSymbolicFont) {
  41543. canBreak = true;
  41544. }
  41545. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41546. useTable = true;
  41547. canBreak = true;
  41548. }
  41549. if (useTable) {
  41550. potentialTable = {
  41551. platformId: platformId,
  41552. encodingId: encodingId,
  41553. offset: offset
  41554. };
  41555. }
  41556. if (canBreak) {
  41557. break;
  41558. }
  41559. }
  41560. if (potentialTable) {
  41561. font.pos = start + potentialTable.offset;
  41562. }
  41563. if (!potentialTable || font.peekByte() === -1) {
  41564. warn('Could not find a preferred cmap table.');
  41565. return {
  41566. platformId: -1,
  41567. encodingId: -1,
  41568. mappings: [],
  41569. hasShortCmap: false
  41570. };
  41571. }
  41572. var format = font.getUint16();
  41573. var length = font.getUint16();
  41574. var language = font.getUint16();
  41575. var hasShortCmap = false;
  41576. var mappings = [];
  41577. var j, glyphId;
  41578. if (format === 0) {
  41579. for (j = 0; j < 256; j++) {
  41580. var index = font.getByte();
  41581. if (!index) {
  41582. continue;
  41583. }
  41584. mappings.push({
  41585. charCode: j,
  41586. glyphId: index
  41587. });
  41588. }
  41589. hasShortCmap = true;
  41590. } else if (format === 4) {
  41591. var segCount = font.getUint16() >> 1;
  41592. font.getBytes(6);
  41593. var segIndex, segments = [];
  41594. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41595. segments.push({ end: font.getUint16() });
  41596. }
  41597. font.getUint16();
  41598. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41599. segments[segIndex].start = font.getUint16();
  41600. }
  41601. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41602. segments[segIndex].delta = font.getUint16();
  41603. }
  41604. var offsetsCount = 0;
  41605. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41606. segment = segments[segIndex];
  41607. var rangeOffset = font.getUint16();
  41608. if (!rangeOffset) {
  41609. segment.offsetIndex = -1;
  41610. continue;
  41611. }
  41612. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41613. segment.offsetIndex = offsetIndex;
  41614. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41615. }
  41616. var offsets = [];
  41617. for (j = 0; j < offsetsCount; j++) {
  41618. offsets.push(font.getUint16());
  41619. }
  41620. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41621. segment = segments[segIndex];
  41622. start = segment.start;
  41623. var end = segment.end;
  41624. var delta = segment.delta;
  41625. offsetIndex = segment.offsetIndex;
  41626. for (j = start; j <= end; j++) {
  41627. if (j === 0xFFFF) {
  41628. continue;
  41629. }
  41630. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41631. glyphId = glyphId + delta & 0xFFFF;
  41632. if (glyphId === 0) {
  41633. continue;
  41634. }
  41635. mappings.push({
  41636. charCode: j,
  41637. glyphId: glyphId
  41638. });
  41639. }
  41640. }
  41641. } else if (format === 6) {
  41642. var firstCode = font.getUint16();
  41643. var entryCount = font.getUint16();
  41644. for (j = 0; j < entryCount; j++) {
  41645. glyphId = font.getUint16();
  41646. var charCode = firstCode + j;
  41647. mappings.push({
  41648. charCode: charCode,
  41649. glyphId: glyphId
  41650. });
  41651. }
  41652. } else {
  41653. warn('cmap table has unsupported format: ' + format);
  41654. return {
  41655. platformId: -1,
  41656. encodingId: -1,
  41657. mappings: [],
  41658. hasShortCmap: false
  41659. };
  41660. }
  41661. mappings.sort(function (a, b) {
  41662. return a.charCode - b.charCode;
  41663. });
  41664. for (i = 1; i < mappings.length; i++) {
  41665. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41666. mappings.splice(i, 1);
  41667. i--;
  41668. }
  41669. }
  41670. return {
  41671. platformId: potentialTable.platformId,
  41672. encodingId: potentialTable.encodingId,
  41673. mappings: mappings,
  41674. hasShortCmap: hasShortCmap
  41675. };
  41676. }
  41677. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41678. if (!header) {
  41679. if (metrics) {
  41680. metrics.data = null;
  41681. }
  41682. return;
  41683. }
  41684. font.pos = (font.start ? font.start : 0) + header.offset;
  41685. font.pos += header.length - 2;
  41686. var numOfMetrics = font.getUint16();
  41687. if (numOfMetrics > numGlyphs) {
  41688. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41689. numOfMetrics = numGlyphs;
  41690. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41691. header.data[35] = numOfMetrics & 0x00ff;
  41692. }
  41693. var numOfSidebearings = numGlyphs - numOfMetrics;
  41694. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41695. if (numMissing > 0) {
  41696. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41697. entries.set(metrics.data);
  41698. metrics.data = entries;
  41699. }
  41700. }
  41701. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41702. if (sourceEnd - sourceStart <= 12) {
  41703. return 0;
  41704. }
  41705. var glyf = source.subarray(sourceStart, sourceEnd);
  41706. var contoursCount = glyf[0] << 8 | glyf[1];
  41707. if (contoursCount & 0x8000) {
  41708. dest.set(glyf, destStart);
  41709. return glyf.length;
  41710. }
  41711. var i, j = 10, flagsCount = 0;
  41712. for (i = 0; i < contoursCount; i++) {
  41713. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41714. flagsCount = endPoint + 1;
  41715. j += 2;
  41716. }
  41717. var instructionsStart = j;
  41718. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41719. j += 2 + instructionsLength;
  41720. var instructionsEnd = j;
  41721. var coordinatesLength = 0;
  41722. for (i = 0; i < flagsCount; i++) {
  41723. var flag = glyf[j++];
  41724. if (flag & 0xC0) {
  41725. glyf[j - 1] = flag & 0x3F;
  41726. }
  41727. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41728. coordinatesLength += xyLength;
  41729. if (flag & 8) {
  41730. var repeat = glyf[j++];
  41731. i += repeat;
  41732. coordinatesLength += repeat * xyLength;
  41733. }
  41734. }
  41735. if (coordinatesLength === 0) {
  41736. return 0;
  41737. }
  41738. var glyphDataLength = j + coordinatesLength;
  41739. if (glyphDataLength > glyf.length) {
  41740. return 0;
  41741. }
  41742. if (!hintsValid && instructionsLength > 0) {
  41743. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41744. dest.set([
  41745. 0,
  41746. 0
  41747. ], destStart + instructionsStart);
  41748. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41749. glyphDataLength -= instructionsLength;
  41750. if (glyf.length - glyphDataLength > 3) {
  41751. glyphDataLength = glyphDataLength + 3 & ~3;
  41752. }
  41753. return glyphDataLength;
  41754. }
  41755. if (glyf.length - glyphDataLength > 3) {
  41756. glyphDataLength = glyphDataLength + 3 & ~3;
  41757. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41758. return glyphDataLength;
  41759. }
  41760. dest.set(glyf, destStart);
  41761. return glyf.length;
  41762. }
  41763. function sanitizeHead(head, numGlyphs, locaLength) {
  41764. var data = head.data;
  41765. var version = int32(data[0], data[1], data[2], data[3]);
  41766. if (version >> 16 !== 1) {
  41767. info('Attempting to fix invalid version in head table: ' + version);
  41768. data[0] = 0;
  41769. data[1] = 1;
  41770. data[2] = 0;
  41771. data[3] = 0;
  41772. }
  41773. var indexToLocFormat = int16(data[50], data[51]);
  41774. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41775. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41776. var numGlyphsPlusOne = numGlyphs + 1;
  41777. if (locaLength === numGlyphsPlusOne << 1) {
  41778. data[50] = 0;
  41779. data[51] = 0;
  41780. } else if (locaLength === numGlyphsPlusOne << 2) {
  41781. data[50] = 0;
  41782. data[51] = 1;
  41783. } else {
  41784. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41785. }
  41786. }
  41787. }
  41788. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41789. var itemSize, itemDecode, itemEncode;
  41790. if (isGlyphLocationsLong) {
  41791. itemSize = 4;
  41792. itemDecode = function fontItemDecodeLong(data, offset) {
  41793. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41794. };
  41795. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41796. data[offset] = value >>> 24 & 0xFF;
  41797. data[offset + 1] = value >> 16 & 0xFF;
  41798. data[offset + 2] = value >> 8 & 0xFF;
  41799. data[offset + 3] = value & 0xFF;
  41800. };
  41801. } else {
  41802. itemSize = 2;
  41803. itemDecode = function fontItemDecode(data, offset) {
  41804. return data[offset] << 9 | data[offset + 1] << 1;
  41805. };
  41806. itemEncode = function fontItemEncode(data, offset, value) {
  41807. data[offset] = value >> 9 & 0xFF;
  41808. data[offset + 1] = value >> 1 & 0xFF;
  41809. };
  41810. }
  41811. var locaData = loca.data;
  41812. var locaDataSize = itemSize * (1 + numGlyphs);
  41813. if (locaData.length !== locaDataSize) {
  41814. locaData = new Uint8Array(locaDataSize);
  41815. locaData.set(loca.data.subarray(0, locaDataSize));
  41816. loca.data = locaData;
  41817. }
  41818. var oldGlyfData = glyf.data;
  41819. var oldGlyfDataLength = oldGlyfData.length;
  41820. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41821. var startOffset = itemDecode(locaData, 0);
  41822. var writeOffset = 0;
  41823. var missingGlyphData = Object.create(null);
  41824. itemEncode(locaData, 0, writeOffset);
  41825. var i, j;
  41826. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41827. var endOffset = itemDecode(locaData, j);
  41828. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  41829. endOffset = oldGlyfDataLength;
  41830. }
  41831. if (endOffset > oldGlyfDataLength) {
  41832. itemEncode(locaData, j, writeOffset);
  41833. startOffset = endOffset;
  41834. continue;
  41835. }
  41836. if (startOffset === endOffset) {
  41837. missingGlyphData[i] = true;
  41838. }
  41839. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  41840. writeOffset += newLength;
  41841. itemEncode(locaData, j, writeOffset);
  41842. startOffset = endOffset;
  41843. }
  41844. if (writeOffset === 0) {
  41845. var simpleGlyph = new Uint8Array([
  41846. 0,
  41847. 1,
  41848. 0,
  41849. 0,
  41850. 0,
  41851. 0,
  41852. 0,
  41853. 0,
  41854. 0,
  41855. 0,
  41856. 0,
  41857. 0,
  41858. 0,
  41859. 0,
  41860. 49,
  41861. 0
  41862. ]);
  41863. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41864. itemEncode(locaData, j, simpleGlyph.length);
  41865. }
  41866. glyf.data = simpleGlyph;
  41867. return missingGlyphData;
  41868. }
  41869. if (dupFirstEntry) {
  41870. var firstEntryLength = itemDecode(locaData, itemSize);
  41871. if (newGlyfData.length > firstEntryLength + writeOffset) {
  41872. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  41873. } else {
  41874. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  41875. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  41876. }
  41877. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  41878. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  41879. } else {
  41880. glyf.data = newGlyfData.subarray(0, writeOffset);
  41881. }
  41882. return missingGlyphData;
  41883. }
  41884. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  41885. var start = (font.start ? font.start : 0) + post.offset;
  41886. font.pos = start;
  41887. var length = post.length, end = start + length;
  41888. var version = font.getInt32();
  41889. font.getBytes(28);
  41890. var glyphNames;
  41891. var valid = true;
  41892. var i;
  41893. switch (version) {
  41894. case 0x00010000:
  41895. glyphNames = MacStandardGlyphOrdering;
  41896. break;
  41897. case 0x00020000:
  41898. var numGlyphs = font.getUint16();
  41899. if (numGlyphs !== maxpNumGlyphs) {
  41900. valid = false;
  41901. break;
  41902. }
  41903. var glyphNameIndexes = [];
  41904. for (i = 0; i < numGlyphs; ++i) {
  41905. var index = font.getUint16();
  41906. if (index >= 32768) {
  41907. valid = false;
  41908. break;
  41909. }
  41910. glyphNameIndexes.push(index);
  41911. }
  41912. if (!valid) {
  41913. break;
  41914. }
  41915. var customNames = [];
  41916. var strBuf = [];
  41917. while (font.pos < end) {
  41918. var stringLength = font.getByte();
  41919. strBuf.length = stringLength;
  41920. for (i = 0; i < stringLength; ++i) {
  41921. strBuf[i] = String.fromCharCode(font.getByte());
  41922. }
  41923. customNames.push(strBuf.join(''));
  41924. }
  41925. glyphNames = [];
  41926. for (i = 0; i < numGlyphs; ++i) {
  41927. var j = glyphNameIndexes[i];
  41928. if (j < 258) {
  41929. glyphNames.push(MacStandardGlyphOrdering[j]);
  41930. continue;
  41931. }
  41932. glyphNames.push(customNames[j - 258]);
  41933. }
  41934. break;
  41935. case 0x00030000:
  41936. break;
  41937. default:
  41938. warn('Unknown/unsupported post table version ' + version);
  41939. valid = false;
  41940. if (properties.defaultEncoding) {
  41941. glyphNames = properties.defaultEncoding;
  41942. }
  41943. break;
  41944. }
  41945. properties.glyphNames = glyphNames;
  41946. return valid;
  41947. }
  41948. function readNameTable(nameTable) {
  41949. var start = (font.start ? font.start : 0) + nameTable.offset;
  41950. font.pos = start;
  41951. var names = [
  41952. [],
  41953. []
  41954. ];
  41955. var length = nameTable.length, end = start + length;
  41956. var format = font.getUint16();
  41957. var FORMAT_0_HEADER_LENGTH = 6;
  41958. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  41959. return names;
  41960. }
  41961. var numRecords = font.getUint16();
  41962. var stringsStart = font.getUint16();
  41963. var records = [];
  41964. var NAME_RECORD_LENGTH = 12;
  41965. var i, ii;
  41966. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  41967. var r = {
  41968. platform: font.getUint16(),
  41969. encoding: font.getUint16(),
  41970. language: font.getUint16(),
  41971. name: font.getUint16(),
  41972. length: font.getUint16(),
  41973. offset: font.getUint16()
  41974. };
  41975. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  41976. records.push(r);
  41977. }
  41978. }
  41979. for (i = 0, ii = records.length; i < ii; i++) {
  41980. var record = records[i];
  41981. if (record.length <= 0) {
  41982. continue;
  41983. }
  41984. var pos = start + stringsStart + record.offset;
  41985. if (pos + record.length > end) {
  41986. continue;
  41987. }
  41988. font.pos = pos;
  41989. var nameIndex = record.name;
  41990. if (record.encoding) {
  41991. var str = '';
  41992. for (var j = 0, jj = record.length; j < jj; j += 2) {
  41993. str += String.fromCharCode(font.getUint16());
  41994. }
  41995. names[1][nameIndex] = str;
  41996. } else {
  41997. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  41998. }
  41999. }
  42000. return names;
  42001. }
  42002. var TTOpsStackDeltas = [
  42003. 0,
  42004. 0,
  42005. 0,
  42006. 0,
  42007. 0,
  42008. 0,
  42009. 0,
  42010. 0,
  42011. -2,
  42012. -2,
  42013. -2,
  42014. -2,
  42015. 0,
  42016. 0,
  42017. -2,
  42018. -5,
  42019. -1,
  42020. -1,
  42021. -1,
  42022. -1,
  42023. -1,
  42024. -1,
  42025. -1,
  42026. -1,
  42027. 0,
  42028. 0,
  42029. -1,
  42030. 0,
  42031. -1,
  42032. -1,
  42033. -1,
  42034. -1,
  42035. 1,
  42036. -1,
  42037. -999,
  42038. 0,
  42039. 1,
  42040. 0,
  42041. -1,
  42042. -2,
  42043. 0,
  42044. -1,
  42045. -2,
  42046. -1,
  42047. -1,
  42048. 0,
  42049. -1,
  42050. -1,
  42051. 0,
  42052. 0,
  42053. -999,
  42054. -999,
  42055. -1,
  42056. -1,
  42057. -1,
  42058. -1,
  42059. -2,
  42060. -999,
  42061. -2,
  42062. -2,
  42063. -999,
  42064. 0,
  42065. -2,
  42066. -2,
  42067. 0,
  42068. 0,
  42069. -2,
  42070. 0,
  42071. -2,
  42072. 0,
  42073. 0,
  42074. 0,
  42075. -2,
  42076. -1,
  42077. -1,
  42078. 1,
  42079. 1,
  42080. 0,
  42081. 0,
  42082. -1,
  42083. -1,
  42084. -1,
  42085. -1,
  42086. -1,
  42087. -1,
  42088. -1,
  42089. 0,
  42090. 0,
  42091. -1,
  42092. 0,
  42093. -1,
  42094. -1,
  42095. 0,
  42096. -999,
  42097. -1,
  42098. -1,
  42099. -1,
  42100. -1,
  42101. -1,
  42102. -1,
  42103. 0,
  42104. 0,
  42105. 0,
  42106. 0,
  42107. 0,
  42108. 0,
  42109. 0,
  42110. 0,
  42111. 0,
  42112. 0,
  42113. 0,
  42114. 0,
  42115. -2,
  42116. -999,
  42117. -999,
  42118. -999,
  42119. -999,
  42120. -999,
  42121. -1,
  42122. -1,
  42123. -2,
  42124. -2,
  42125. 0,
  42126. 0,
  42127. 0,
  42128. 0,
  42129. -1,
  42130. -1,
  42131. -999,
  42132. -2,
  42133. -2,
  42134. 0,
  42135. 0,
  42136. -1,
  42137. -2,
  42138. -2,
  42139. 0,
  42140. 0,
  42141. 0,
  42142. -1,
  42143. -1,
  42144. -1,
  42145. -2
  42146. ];
  42147. function sanitizeTTProgram(table, ttContext) {
  42148. var data = table.data;
  42149. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42150. var stack = [];
  42151. var callstack = [];
  42152. var functionsCalled = [];
  42153. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42154. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42155. for (var ii = data.length; i < ii;) {
  42156. var op = data[i++];
  42157. if (op === 0x40) {
  42158. n = data[i++];
  42159. if (inFDEF || inELSE) {
  42160. i += n;
  42161. } else {
  42162. for (j = 0; j < n; j++) {
  42163. stack.push(data[i++]);
  42164. }
  42165. }
  42166. } else if (op === 0x41) {
  42167. n = data[i++];
  42168. if (inFDEF || inELSE) {
  42169. i += n * 2;
  42170. } else {
  42171. for (j = 0; j < n; j++) {
  42172. b = data[i++];
  42173. stack.push(b << 8 | data[i++]);
  42174. }
  42175. }
  42176. } else if ((op & 0xF8) === 0xB0) {
  42177. n = op - 0xB0 + 1;
  42178. if (inFDEF || inELSE) {
  42179. i += n;
  42180. } else {
  42181. for (j = 0; j < n; j++) {
  42182. stack.push(data[i++]);
  42183. }
  42184. }
  42185. } else if ((op & 0xF8) === 0xB8) {
  42186. n = op - 0xB8 + 1;
  42187. if (inFDEF || inELSE) {
  42188. i += n * 2;
  42189. } else {
  42190. for (j = 0; j < n; j++) {
  42191. b = data[i++];
  42192. stack.push(b << 8 | data[i++]);
  42193. }
  42194. }
  42195. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42196. if (!inFDEF && !inELSE) {
  42197. funcId = stack[stack.length - 1];
  42198. ttContext.functionsUsed[funcId] = true;
  42199. if (funcId in ttContext.functionsStackDeltas) {
  42200. stack.length += ttContext.functionsStackDeltas[funcId];
  42201. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42202. callstack.push({
  42203. data: data,
  42204. i: i,
  42205. stackTop: stack.length - 1
  42206. });
  42207. functionsCalled.push(funcId);
  42208. pc = ttContext.functionsDefined[funcId];
  42209. if (!pc) {
  42210. warn('TT: CALL non-existent function');
  42211. ttContext.hintsValid = false;
  42212. return;
  42213. }
  42214. data = pc.data;
  42215. i = pc.i;
  42216. }
  42217. }
  42218. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42219. if (inFDEF || inELSE) {
  42220. warn('TT: nested FDEFs not allowed');
  42221. tooComplexToFollowFunctions = true;
  42222. }
  42223. inFDEF = true;
  42224. lastDeff = i;
  42225. funcId = stack.pop();
  42226. ttContext.functionsDefined[funcId] = {
  42227. data: data,
  42228. i: i
  42229. };
  42230. } else if (op === 0x2D) {
  42231. if (inFDEF) {
  42232. inFDEF = false;
  42233. lastEndf = i;
  42234. } else {
  42235. pc = callstack.pop();
  42236. if (!pc) {
  42237. warn('TT: ENDF bad stack');
  42238. ttContext.hintsValid = false;
  42239. return;
  42240. }
  42241. funcId = functionsCalled.pop();
  42242. data = pc.data;
  42243. i = pc.i;
  42244. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42245. }
  42246. } else if (op === 0x89) {
  42247. if (inFDEF || inELSE) {
  42248. warn('TT: nested IDEFs not allowed');
  42249. tooComplexToFollowFunctions = true;
  42250. }
  42251. inFDEF = true;
  42252. lastDeff = i;
  42253. } else if (op === 0x58) {
  42254. ++ifLevel;
  42255. } else if (op === 0x1B) {
  42256. inELSE = ifLevel;
  42257. } else if (op === 0x59) {
  42258. if (inELSE === ifLevel) {
  42259. inELSE = 0;
  42260. }
  42261. --ifLevel;
  42262. } else if (op === 0x1C) {
  42263. if (!inFDEF && !inELSE) {
  42264. var offset = stack[stack.length - 1];
  42265. if (offset > 0) {
  42266. i += offset - 1;
  42267. }
  42268. }
  42269. }
  42270. if (!inFDEF && !inELSE) {
  42271. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42272. if (op >= 0x71 && op <= 0x75) {
  42273. n = stack.pop();
  42274. if (n === n) {
  42275. stackDelta = -n * 2;
  42276. }
  42277. }
  42278. while (stackDelta < 0 && stack.length > 0) {
  42279. stack.pop();
  42280. stackDelta++;
  42281. }
  42282. while (stackDelta > 0) {
  42283. stack.push(NaN);
  42284. stackDelta--;
  42285. }
  42286. }
  42287. }
  42288. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42289. var content = [data];
  42290. if (i > data.length) {
  42291. content.push(new Uint8Array(i - data.length));
  42292. }
  42293. if (lastDeff > lastEndf) {
  42294. warn('TT: complementing a missing function tail');
  42295. content.push(new Uint8Array([
  42296. 0x22,
  42297. 0x2D
  42298. ]));
  42299. }
  42300. foldTTTable(table, content);
  42301. }
  42302. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42303. if (ttContext.tooComplexToFollowFunctions) {
  42304. return;
  42305. }
  42306. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42307. warn('TT: more functions defined than expected');
  42308. ttContext.hintsValid = false;
  42309. return;
  42310. }
  42311. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42312. if (j > maxFunctionDefs) {
  42313. warn('TT: invalid function id: ' + j);
  42314. ttContext.hintsValid = false;
  42315. return;
  42316. }
  42317. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42318. warn('TT: undefined function: ' + j);
  42319. ttContext.hintsValid = false;
  42320. return;
  42321. }
  42322. }
  42323. }
  42324. function foldTTTable(table, content) {
  42325. if (content.length > 1) {
  42326. var newLength = 0;
  42327. var j, jj;
  42328. for (j = 0, jj = content.length; j < jj; j++) {
  42329. newLength += content[j].length;
  42330. }
  42331. newLength = newLength + 3 & ~3;
  42332. var result = new Uint8Array(newLength);
  42333. var pos = 0;
  42334. for (j = 0, jj = content.length; j < jj; j++) {
  42335. result.set(content[j], pos);
  42336. pos += content[j].length;
  42337. }
  42338. table.data = result;
  42339. table.length = newLength;
  42340. }
  42341. }
  42342. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42343. var ttContext = {
  42344. functionsDefined: [],
  42345. functionsUsed: [],
  42346. functionsStackDeltas: [],
  42347. tooComplexToFollowFunctions: false,
  42348. hintsValid: true
  42349. };
  42350. if (fpgm) {
  42351. sanitizeTTProgram(fpgm, ttContext);
  42352. }
  42353. if (prep) {
  42354. sanitizeTTProgram(prep, ttContext);
  42355. }
  42356. if (fpgm) {
  42357. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42358. }
  42359. if (cvt && cvt.length & 1) {
  42360. var cvtData = new Uint8Array(cvt.length + 1);
  42361. cvtData.set(cvt.data);
  42362. cvt.data = cvtData;
  42363. }
  42364. return ttContext.hintsValid;
  42365. }
  42366. font = new Stream(new Uint8Array(font.getBytes()));
  42367. var VALID_TABLES = [
  42368. 'OS/2',
  42369. 'cmap',
  42370. 'head',
  42371. 'hhea',
  42372. 'hmtx',
  42373. 'maxp',
  42374. 'name',
  42375. 'post',
  42376. 'loca',
  42377. 'glyf',
  42378. 'fpgm',
  42379. 'prep',
  42380. 'cvt ',
  42381. 'CFF '
  42382. ];
  42383. var header = readOpenTypeHeader(font);
  42384. var numTables = header.numTables;
  42385. var cff, cffFile;
  42386. var tables = Object.create(null);
  42387. tables['OS/2'] = null;
  42388. tables['cmap'] = null;
  42389. tables['head'] = null;
  42390. tables['hhea'] = null;
  42391. tables['hmtx'] = null;
  42392. tables['maxp'] = null;
  42393. tables['name'] = null;
  42394. tables['post'] = null;
  42395. var table;
  42396. for (var i = 0; i < numTables; i++) {
  42397. table = readTableEntry(font);
  42398. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42399. continue;
  42400. }
  42401. if (table.length === 0) {
  42402. continue;
  42403. }
  42404. tables[table.tag] = table;
  42405. }
  42406. var isTrueType = !tables['CFF '];
  42407. if (!isTrueType) {
  42408. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42409. cffFile = new Stream(tables['CFF '].data);
  42410. cff = new CFFFont(cffFile, properties);
  42411. adjustWidths(properties);
  42412. return this.convert(name, cff, properties);
  42413. }
  42414. delete tables['glyf'];
  42415. delete tables['loca'];
  42416. delete tables['fpgm'];
  42417. delete tables['prep'];
  42418. delete tables['cvt '];
  42419. this.isOpenType = true;
  42420. } else {
  42421. if (!tables['loca']) {
  42422. error('Required "loca" table is not found');
  42423. }
  42424. if (!tables['glyf']) {
  42425. warn('Required "glyf" table is not found -- trying to recover.');
  42426. tables['glyf'] = {
  42427. tag: 'glyf',
  42428. data: new Uint8Array(0)
  42429. };
  42430. }
  42431. this.isOpenType = false;
  42432. }
  42433. if (!tables['maxp']) {
  42434. error('Required "maxp" table is not found');
  42435. }
  42436. font.pos = (font.start || 0) + tables['maxp'].offset;
  42437. var version = font.getInt32();
  42438. var numGlyphs = font.getUint16();
  42439. var maxFunctionDefs = 0;
  42440. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42441. font.pos += 8;
  42442. var maxZones = font.getUint16();
  42443. if (maxZones > 2) {
  42444. tables['maxp'].data[14] = 0;
  42445. tables['maxp'].data[15] = 2;
  42446. }
  42447. font.pos += 4;
  42448. maxFunctionDefs = font.getUint16();
  42449. }
  42450. var dupFirstEntry = false;
  42451. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42452. dupFirstEntry = true;
  42453. numGlyphs++;
  42454. tables['maxp'].data[4] = numGlyphs >> 8;
  42455. tables['maxp'].data[5] = numGlyphs & 255;
  42456. }
  42457. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42458. if (!hintsValid) {
  42459. delete tables['fpgm'];
  42460. delete tables['prep'];
  42461. delete tables['cvt '];
  42462. }
  42463. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42464. if (!tables['head']) {
  42465. error('Required "head" table is not found');
  42466. }
  42467. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42468. var missingGlyphs = Object.create(null);
  42469. if (isTrueType) {
  42470. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42471. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42472. }
  42473. if (!tables['hhea']) {
  42474. error('Required "hhea" table is not found');
  42475. }
  42476. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42477. tables['hhea'].data[10] = 0xFF;
  42478. tables['hhea'].data[11] = 0xFF;
  42479. }
  42480. var metricsOverride = {
  42481. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42482. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42483. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42484. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42485. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42486. };
  42487. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42488. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42489. if (tables['post']) {
  42490. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42491. if (!valid) {
  42492. tables['post'] = null;
  42493. }
  42494. }
  42495. var charCodeToGlyphId = [], charCode;
  42496. var toUnicode = properties.toUnicode, widths = properties.widths;
  42497. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42498. function hasGlyph(glyphId, charCode, widthCode) {
  42499. if (!missingGlyphs[glyphId]) {
  42500. return true;
  42501. }
  42502. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42503. return true;
  42504. }
  42505. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42506. return true;
  42507. }
  42508. return false;
  42509. }
  42510. if (properties.type === 'CIDFontType2') {
  42511. var cidToGidMap = properties.cidToGidMap || [];
  42512. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42513. properties.cMap.forEach(function (charCode, cid) {
  42514. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42515. var glyphId = -1;
  42516. if (isCidToGidMapEmpty) {
  42517. glyphId = cid;
  42518. } else if (cidToGidMap[cid] !== undefined) {
  42519. glyphId = cidToGidMap[cid];
  42520. }
  42521. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42522. charCodeToGlyphId[charCode] = glyphId;
  42523. }
  42524. });
  42525. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42526. charCodeToGlyphId[0] = numGlyphs - 1;
  42527. }
  42528. } else {
  42529. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42530. var cmapPlatformId = cmapTable.platformId;
  42531. var cmapEncodingId = cmapTable.encodingId;
  42532. var cmapMappings = cmapTable.mappings;
  42533. var cmapMappingsLength = cmapMappings.length;
  42534. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42535. var baseEncoding = [];
  42536. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42537. baseEncoding = getEncoding(properties.baseEncodingName);
  42538. }
  42539. var glyphsUnicodeMap = getGlyphsUnicode();
  42540. for (charCode = 0; charCode < 256; charCode++) {
  42541. var glyphName, standardGlyphName;
  42542. if (this.differences && charCode in this.differences) {
  42543. glyphName = this.differences[charCode];
  42544. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42545. glyphName = baseEncoding[charCode];
  42546. } else {
  42547. glyphName = StandardEncoding[charCode];
  42548. }
  42549. if (!glyphName) {
  42550. continue;
  42551. }
  42552. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42553. var unicodeOrCharCode, isUnicode = false;
  42554. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42555. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42556. isUnicode = true;
  42557. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42558. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42559. }
  42560. var found = false;
  42561. for (i = 0; i < cmapMappingsLength; ++i) {
  42562. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42563. continue;
  42564. }
  42565. var code = isUnicode ? charCode : unicodeOrCharCode;
  42566. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42567. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42568. found = true;
  42569. break;
  42570. }
  42571. }
  42572. if (!found && properties.glyphNames) {
  42573. var glyphId = properties.glyphNames.indexOf(glyphName);
  42574. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42575. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42576. }
  42577. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42578. charCodeToGlyphId[charCode] = glyphId;
  42579. found = true;
  42580. }
  42581. }
  42582. if (!found) {
  42583. charCodeToGlyphId[charCode] = 0;
  42584. }
  42585. }
  42586. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42587. for (i = 0; i < cmapMappingsLength; ++i) {
  42588. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42589. }
  42590. } else {
  42591. for (i = 0; i < cmapMappingsLength; ++i) {
  42592. charCode = cmapMappings[i].charCode & 0xFF;
  42593. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42594. }
  42595. }
  42596. }
  42597. if (charCodeToGlyphId.length === 0) {
  42598. charCodeToGlyphId[0] = 0;
  42599. }
  42600. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42601. this.toFontChar = newMapping.toFontChar;
  42602. tables['cmap'] = {
  42603. tag: 'cmap',
  42604. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42605. };
  42606. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42607. tables['OS/2'] = {
  42608. tag: 'OS/2',
  42609. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42610. };
  42611. }
  42612. if (!tables['post']) {
  42613. tables['post'] = {
  42614. tag: 'post',
  42615. data: createPostTable(properties)
  42616. };
  42617. }
  42618. if (!isTrueType) {
  42619. try {
  42620. cffFile = new Stream(tables['CFF '].data);
  42621. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42622. cff = parser.parse();
  42623. var compiler = new CFFCompiler(cff);
  42624. tables['CFF '].data = compiler.compile();
  42625. } catch (e) {
  42626. warn('Failed to compile font ' + properties.loadedName);
  42627. }
  42628. }
  42629. if (!tables['name']) {
  42630. tables['name'] = {
  42631. tag: 'name',
  42632. data: createNameTable(this.name)
  42633. };
  42634. } else {
  42635. var namePrototype = readNameTable(tables['name']);
  42636. tables['name'].data = createNameTable(name, namePrototype);
  42637. }
  42638. var builder = new OpenTypeFileBuilder(header.version);
  42639. for (var tableTag in tables) {
  42640. builder.addTable(tableTag, tables[tableTag].data);
  42641. }
  42642. return builder.toArray();
  42643. },
  42644. convert: function Font_convert(fontName, font, properties) {
  42645. properties.fixedPitch = false;
  42646. if (properties.builtInEncoding) {
  42647. adjustToUnicode(properties, properties.builtInEncoding);
  42648. }
  42649. var mapping = font.getGlyphMapping(properties);
  42650. var newMapping = adjustMapping(mapping, properties);
  42651. this.toFontChar = newMapping.toFontChar;
  42652. var numGlyphs = font.numGlyphs;
  42653. function getCharCodes(charCodeToGlyphId, glyphId) {
  42654. var charCodes = null;
  42655. for (var charCode in charCodeToGlyphId) {
  42656. if (glyphId === charCodeToGlyphId[charCode]) {
  42657. if (!charCodes) {
  42658. charCodes = [];
  42659. }
  42660. charCodes.push(charCode | 0);
  42661. }
  42662. }
  42663. return charCodes;
  42664. }
  42665. function createCharCode(charCodeToGlyphId, glyphId) {
  42666. for (var charCode in charCodeToGlyphId) {
  42667. if (glyphId === charCodeToGlyphId[charCode]) {
  42668. return charCode | 0;
  42669. }
  42670. }
  42671. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42672. return newMapping.nextAvailableFontCharCode++;
  42673. }
  42674. var seacs = font.seacs;
  42675. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42676. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42677. var charset = font.getCharset();
  42678. var seacMap = Object.create(null);
  42679. for (var glyphId in seacs) {
  42680. glyphId |= 0;
  42681. var seac = seacs[glyphId];
  42682. var baseGlyphName = StandardEncoding[seac[2]];
  42683. var accentGlyphName = StandardEncoding[seac[3]];
  42684. var baseGlyphId = charset.indexOf(baseGlyphName);
  42685. var accentGlyphId = charset.indexOf(accentGlyphName);
  42686. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42687. continue;
  42688. }
  42689. var accentOffset = {
  42690. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42691. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42692. };
  42693. var charCodes = getCharCodes(mapping, glyphId);
  42694. if (!charCodes) {
  42695. continue;
  42696. }
  42697. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42698. var charCode = charCodes[i];
  42699. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42700. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42701. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42702. seacMap[charCode] = {
  42703. baseFontCharCode: baseFontCharCode,
  42704. accentFontCharCode: accentFontCharCode,
  42705. accentOffset: accentOffset
  42706. };
  42707. }
  42708. }
  42709. properties.seacMap = seacMap;
  42710. }
  42711. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42712. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42713. builder.addTable('CFF ', font.data);
  42714. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42715. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42716. 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');
  42717. 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));
  42718. builder.addTable('hmtx', function fontFieldsHmtx() {
  42719. var charstrings = font.charstrings;
  42720. var cffWidths = font.cff ? font.cff.widths : null;
  42721. var hmtx = '\x00\x00\x00\x00';
  42722. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42723. var width = 0;
  42724. if (charstrings) {
  42725. var charstring = charstrings[i - 1];
  42726. width = 'width' in charstring ? charstring.width : 0;
  42727. } else if (cffWidths) {
  42728. width = Math.ceil(cffWidths[i] || 0);
  42729. }
  42730. hmtx += string16(width) + string16(0);
  42731. }
  42732. return hmtx;
  42733. }());
  42734. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42735. builder.addTable('name', createNameTable(fontName));
  42736. builder.addTable('post', createPostTable(properties));
  42737. return builder.toArray();
  42738. },
  42739. get spaceWidth() {
  42740. if ('_shadowWidth' in this) {
  42741. return this._shadowWidth;
  42742. }
  42743. var possibleSpaceReplacements = [
  42744. 'space',
  42745. 'minus',
  42746. 'one',
  42747. 'i',
  42748. 'I'
  42749. ];
  42750. var width;
  42751. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42752. var glyphName = possibleSpaceReplacements[i];
  42753. if (glyphName in this.widths) {
  42754. width = this.widths[glyphName];
  42755. break;
  42756. }
  42757. var glyphsUnicodeMap = getGlyphsUnicode();
  42758. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42759. var charcode = 0;
  42760. if (this.composite) {
  42761. if (this.cMap.contains(glyphUnicode)) {
  42762. charcode = this.cMap.lookup(glyphUnicode);
  42763. }
  42764. }
  42765. if (!charcode && this.toUnicode) {
  42766. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42767. }
  42768. if (charcode <= 0) {
  42769. charcode = glyphUnicode;
  42770. }
  42771. width = this.widths[charcode];
  42772. if (width) {
  42773. break;
  42774. }
  42775. }
  42776. width = width || this.defaultWidth;
  42777. this._shadowWidth = width;
  42778. return width;
  42779. },
  42780. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42781. var fontCharCode, width, operatorListId;
  42782. var widthCode = charcode;
  42783. if (this.cMap && this.cMap.contains(charcode)) {
  42784. widthCode = this.cMap.lookup(charcode);
  42785. }
  42786. width = this.widths[widthCode];
  42787. width = isNum(width) ? width : this.defaultWidth;
  42788. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42789. var unicode = this.toUnicode.get(charcode) || charcode;
  42790. if (typeof unicode === 'number') {
  42791. unicode = String.fromCharCode(unicode);
  42792. }
  42793. var isInFont = charcode in this.toFontChar;
  42794. fontCharCode = this.toFontChar[charcode] || charcode;
  42795. if (this.missingFile) {
  42796. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42797. }
  42798. if (this.isType3Font) {
  42799. operatorListId = fontCharCode;
  42800. }
  42801. var accent = null;
  42802. if (this.seacMap && this.seacMap[charcode]) {
  42803. isInFont = true;
  42804. var seac = this.seacMap[charcode];
  42805. fontCharCode = seac.baseFontCharCode;
  42806. accent = {
  42807. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42808. offset: seac.accentOffset
  42809. };
  42810. }
  42811. var fontChar = String.fromCharCode(fontCharCode);
  42812. var glyph = this.glyphCache[charcode];
  42813. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42814. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42815. this.glyphCache[charcode] = glyph;
  42816. }
  42817. return glyph;
  42818. },
  42819. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42820. var charsCache = this.charsCache;
  42821. var glyphs, glyph, charcode;
  42822. if (charsCache) {
  42823. glyphs = charsCache[chars];
  42824. if (glyphs) {
  42825. return glyphs;
  42826. }
  42827. }
  42828. if (!charsCache) {
  42829. charsCache = this.charsCache = Object.create(null);
  42830. }
  42831. glyphs = [];
  42832. var charsCacheKey = chars;
  42833. var i = 0, ii;
  42834. if (this.cMap) {
  42835. var c = Object.create(null);
  42836. while (i < chars.length) {
  42837. this.cMap.readCharCode(chars, i, c);
  42838. charcode = c.charcode;
  42839. var length = c.length;
  42840. i += length;
  42841. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  42842. glyph = this.charToGlyph(charcode, isSpace);
  42843. glyphs.push(glyph);
  42844. }
  42845. } else {
  42846. for (i = 0, ii = chars.length; i < ii; ++i) {
  42847. charcode = chars.charCodeAt(i);
  42848. glyph = this.charToGlyph(charcode, charcode === 0x20);
  42849. glyphs.push(glyph);
  42850. }
  42851. }
  42852. return charsCache[charsCacheKey] = glyphs;
  42853. }
  42854. };
  42855. return Font;
  42856. }();
  42857. var ErrorFont = function ErrorFontClosure() {
  42858. function ErrorFont(error) {
  42859. this.error = error;
  42860. this.loadedName = 'g_font_error';
  42861. this.loading = false;
  42862. }
  42863. ErrorFont.prototype = {
  42864. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  42865. return [];
  42866. },
  42867. exportData: function ErrorFont_exportData() {
  42868. return { error: this.error };
  42869. }
  42870. };
  42871. return ErrorFont;
  42872. }();
  42873. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  42874. var charCodeToGlyphId = Object.create(null);
  42875. var glyphId, charCode, baseEncoding;
  42876. if (properties.baseEncodingName) {
  42877. baseEncoding = getEncoding(properties.baseEncodingName);
  42878. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42879. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42880. if (glyphId >= 0) {
  42881. charCodeToGlyphId[charCode] = glyphId;
  42882. } else {
  42883. charCodeToGlyphId[charCode] = 0;
  42884. }
  42885. }
  42886. } else if (!!(properties.flags & FontFlags.Symbolic)) {
  42887. for (charCode in builtInEncoding) {
  42888. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  42889. }
  42890. } else {
  42891. baseEncoding = StandardEncoding;
  42892. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42893. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42894. if (glyphId >= 0) {
  42895. charCodeToGlyphId[charCode] = glyphId;
  42896. } else {
  42897. charCodeToGlyphId[charCode] = 0;
  42898. }
  42899. }
  42900. }
  42901. var differences = properties.differences, glyphsUnicodeMap;
  42902. if (differences) {
  42903. for (charCode in differences) {
  42904. var glyphName = differences[charCode];
  42905. glyphId = glyphNames.indexOf(glyphName);
  42906. if (glyphId === -1) {
  42907. if (!glyphsUnicodeMap) {
  42908. glyphsUnicodeMap = getGlyphsUnicode();
  42909. }
  42910. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42911. if (standardGlyphName !== glyphName) {
  42912. glyphId = glyphNames.indexOf(standardGlyphName);
  42913. }
  42914. }
  42915. if (glyphId >= 0) {
  42916. charCodeToGlyphId[charCode] = glyphId;
  42917. } else {
  42918. charCodeToGlyphId[charCode] = 0;
  42919. }
  42920. }
  42921. }
  42922. return charCodeToGlyphId;
  42923. }
  42924. var Type1Font = function Type1FontClosure() {
  42925. function findBlock(streamBytes, signature, startIndex) {
  42926. var streamBytesLength = streamBytes.length;
  42927. var signatureLength = signature.length;
  42928. var scanLength = streamBytesLength - signatureLength;
  42929. var i = startIndex, j, found = false;
  42930. while (i < scanLength) {
  42931. j = 0;
  42932. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  42933. j++;
  42934. }
  42935. if (j >= signatureLength) {
  42936. i += j;
  42937. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  42938. i++;
  42939. }
  42940. found = true;
  42941. break;
  42942. }
  42943. i++;
  42944. }
  42945. return {
  42946. found: found,
  42947. length: i
  42948. };
  42949. }
  42950. function getHeaderBlock(stream, suggestedLength) {
  42951. var EEXEC_SIGNATURE = [
  42952. 0x65,
  42953. 0x65,
  42954. 0x78,
  42955. 0x65,
  42956. 0x63
  42957. ];
  42958. var streamStartPos = stream.pos;
  42959. var headerBytes, headerBytesLength, block;
  42960. try {
  42961. headerBytes = stream.getBytes(suggestedLength);
  42962. headerBytesLength = headerBytes.length;
  42963. } catch (ex) {
  42964. if (ex instanceof MissingDataException) {
  42965. throw ex;
  42966. }
  42967. }
  42968. if (headerBytesLength === suggestedLength) {
  42969. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  42970. if (block.found && block.length === suggestedLength) {
  42971. return {
  42972. stream: new Stream(headerBytes),
  42973. length: suggestedLength
  42974. };
  42975. }
  42976. }
  42977. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  42978. stream.pos = streamStartPos;
  42979. var SCAN_BLOCK_LENGTH = 2048;
  42980. var actualLength;
  42981. while (true) {
  42982. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  42983. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  42984. if (block.length === 0) {
  42985. break;
  42986. }
  42987. stream.pos += block.length;
  42988. if (block.found) {
  42989. actualLength = stream.pos - streamStartPos;
  42990. break;
  42991. }
  42992. }
  42993. stream.pos = streamStartPos;
  42994. if (actualLength) {
  42995. return {
  42996. stream: new Stream(stream.getBytes(actualLength)),
  42997. length: actualLength
  42998. };
  42999. }
  43000. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43001. return {
  43002. stream: new Stream(stream.getBytes(suggestedLength)),
  43003. length: suggestedLength
  43004. };
  43005. }
  43006. function getEexecBlock(stream, suggestedLength) {
  43007. var eexecBytes = stream.getBytes();
  43008. return {
  43009. stream: new Stream(eexecBytes),
  43010. length: eexecBytes.length
  43011. };
  43012. }
  43013. function Type1Font(name, file, properties) {
  43014. var PFB_HEADER_SIZE = 6;
  43015. var headerBlockLength = properties.length1;
  43016. var eexecBlockLength = properties.length2;
  43017. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43018. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43019. if (pfbHeaderPresent) {
  43020. file.skip(PFB_HEADER_SIZE);
  43021. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43022. }
  43023. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43024. headerBlockLength = headerBlock.length;
  43025. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43026. headerBlockParser.extractFontHeader(properties);
  43027. if (pfbHeaderPresent) {
  43028. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43029. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43030. }
  43031. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43032. eexecBlockLength = eexecBlock.length;
  43033. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43034. var data = eexecBlockParser.extractFontProgram();
  43035. for (var info in data.properties) {
  43036. properties[info] = data.properties[info];
  43037. }
  43038. var charstrings = data.charstrings;
  43039. var type2Charstrings = this.getType2Charstrings(charstrings);
  43040. var subrs = this.getType2Subrs(data.subrs);
  43041. this.charstrings = charstrings;
  43042. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43043. this.seacs = this.getSeacs(data.charstrings);
  43044. }
  43045. Type1Font.prototype = {
  43046. get numGlyphs() {
  43047. return this.charstrings.length + 1;
  43048. },
  43049. getCharset: function Type1Font_getCharset() {
  43050. var charset = ['.notdef'];
  43051. var charstrings = this.charstrings;
  43052. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43053. charset.push(charstrings[glyphId].glyphName);
  43054. }
  43055. return charset;
  43056. },
  43057. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43058. var charstrings = this.charstrings;
  43059. var glyphNames = ['.notdef'], glyphId;
  43060. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43061. glyphNames.push(charstrings[glyphId].glyphName);
  43062. }
  43063. var encoding = properties.builtInEncoding;
  43064. if (encoding) {
  43065. var builtInEncoding = Object.create(null);
  43066. for (var charCode in encoding) {
  43067. glyphId = glyphNames.indexOf(encoding[charCode]);
  43068. if (glyphId >= 0) {
  43069. builtInEncoding[charCode] = glyphId;
  43070. }
  43071. }
  43072. }
  43073. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43074. },
  43075. getSeacs: function Type1Font_getSeacs(charstrings) {
  43076. var i, ii;
  43077. var seacMap = [];
  43078. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43079. var charstring = charstrings[i];
  43080. if (charstring.seac) {
  43081. seacMap[i + 1] = charstring.seac;
  43082. }
  43083. }
  43084. return seacMap;
  43085. },
  43086. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43087. var type2Charstrings = [];
  43088. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43089. type2Charstrings.push(type1Charstrings[i].charstring);
  43090. }
  43091. return type2Charstrings;
  43092. },
  43093. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43094. var bias = 0;
  43095. var count = type1Subrs.length;
  43096. if (count < 1133) {
  43097. bias = 107;
  43098. } else if (count < 33769) {
  43099. bias = 1131;
  43100. } else {
  43101. bias = 32768;
  43102. }
  43103. var type2Subrs = [];
  43104. var i;
  43105. for (i = 0; i < bias; i++) {
  43106. type2Subrs.push([0x0B]);
  43107. }
  43108. for (i = 0; i < count; i++) {
  43109. type2Subrs.push(type1Subrs[i]);
  43110. }
  43111. return type2Subrs;
  43112. },
  43113. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43114. var cff = new CFF();
  43115. cff.header = new CFFHeader(1, 0, 4, 4);
  43116. cff.names = [name];
  43117. var topDict = new CFFTopDict();
  43118. topDict.setByName('version', 391);
  43119. topDict.setByName('Notice', 392);
  43120. topDict.setByName('FullName', 393);
  43121. topDict.setByName('FamilyName', 394);
  43122. topDict.setByName('Weight', 395);
  43123. topDict.setByName('Encoding', null);
  43124. topDict.setByName('FontMatrix', properties.fontMatrix);
  43125. topDict.setByName('FontBBox', properties.bbox);
  43126. topDict.setByName('charset', null);
  43127. topDict.setByName('CharStrings', null);
  43128. topDict.setByName('Private', null);
  43129. cff.topDict = topDict;
  43130. var strings = new CFFStrings();
  43131. strings.add('Version 0.11');
  43132. strings.add('See original notice');
  43133. strings.add(name);
  43134. strings.add(name);
  43135. strings.add('Medium');
  43136. cff.strings = strings;
  43137. cff.globalSubrIndex = new CFFIndex();
  43138. var count = glyphs.length;
  43139. var charsetArray = [0];
  43140. var i, ii;
  43141. for (i = 0; i < count; i++) {
  43142. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43143. if (index === -1) {
  43144. index = 0;
  43145. }
  43146. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43147. }
  43148. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43149. var charStringsIndex = new CFFIndex();
  43150. charStringsIndex.add([
  43151. 0x8B,
  43152. 0x0E
  43153. ]);
  43154. for (i = 0; i < count; i++) {
  43155. var glyph = glyphs[i];
  43156. if (glyph.length === 0) {
  43157. charStringsIndex.add([
  43158. 0x8B,
  43159. 0x0E
  43160. ]);
  43161. continue;
  43162. }
  43163. charStringsIndex.add(glyph);
  43164. }
  43165. cff.charStrings = charStringsIndex;
  43166. var privateDict = new CFFPrivateDict();
  43167. privateDict.setByName('Subrs', null);
  43168. var fields = [
  43169. 'BlueValues',
  43170. 'OtherBlues',
  43171. 'FamilyBlues',
  43172. 'FamilyOtherBlues',
  43173. 'StemSnapH',
  43174. 'StemSnapV',
  43175. 'BlueShift',
  43176. 'BlueFuzz',
  43177. 'BlueScale',
  43178. 'LanguageGroup',
  43179. 'ExpansionFactor',
  43180. 'ForceBold',
  43181. 'StdHW',
  43182. 'StdVW'
  43183. ];
  43184. for (i = 0, ii = fields.length; i < ii; i++) {
  43185. var field = fields[i];
  43186. if (!(field in properties.privateData)) {
  43187. continue;
  43188. }
  43189. var value = properties.privateData[field];
  43190. if (isArray(value)) {
  43191. for (var j = value.length - 1; j > 0; j--) {
  43192. value[j] -= value[j - 1];
  43193. }
  43194. }
  43195. privateDict.setByName(field, value);
  43196. }
  43197. cff.topDict.privateDict = privateDict;
  43198. var subrIndex = new CFFIndex();
  43199. for (i = 0, ii = subrs.length; i < ii; i++) {
  43200. subrIndex.add(subrs[i]);
  43201. }
  43202. privateDict.subrsIndex = subrIndex;
  43203. var compiler = new CFFCompiler(cff);
  43204. return compiler.compile();
  43205. }
  43206. };
  43207. return Type1Font;
  43208. }();
  43209. var CFFFont = function CFFFontClosure() {
  43210. function CFFFont(file, properties) {
  43211. this.properties = properties;
  43212. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43213. this.cff = parser.parse();
  43214. var compiler = new CFFCompiler(this.cff);
  43215. this.seacs = this.cff.seacs;
  43216. try {
  43217. this.data = compiler.compile();
  43218. } catch (e) {
  43219. warn('Failed to compile font ' + properties.loadedName);
  43220. this.data = file;
  43221. }
  43222. }
  43223. CFFFont.prototype = {
  43224. get numGlyphs() {
  43225. return this.cff.charStrings.count;
  43226. },
  43227. getCharset: function CFFFont_getCharset() {
  43228. return this.cff.charset.charset;
  43229. },
  43230. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43231. var cff = this.cff;
  43232. var properties = this.properties;
  43233. var charsets = cff.charset.charset;
  43234. var charCodeToGlyphId;
  43235. var glyphId;
  43236. if (properties.composite) {
  43237. charCodeToGlyphId = Object.create(null);
  43238. if (cff.isCIDFont) {
  43239. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43240. var cid = charsets[glyphId];
  43241. var charCode = properties.cMap.charCodeOf(cid);
  43242. charCodeToGlyphId[charCode] = glyphId;
  43243. }
  43244. } else {
  43245. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43246. charCodeToGlyphId[glyphId] = glyphId;
  43247. }
  43248. }
  43249. return charCodeToGlyphId;
  43250. }
  43251. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43252. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43253. return charCodeToGlyphId;
  43254. }
  43255. };
  43256. return CFFFont;
  43257. }();
  43258. (function checkSeacSupport() {
  43259. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43260. SEAC_ANALYSIS_ENABLED = true;
  43261. }
  43262. }());
  43263. (function checkChromeWindows() {
  43264. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43265. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43266. }
  43267. }());
  43268. exports.ErrorFont = ErrorFont;
  43269. exports.Font = Font;
  43270. exports.FontFlags = FontFlags;
  43271. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43272. exports.ToUnicodeMap = ToUnicodeMap;
  43273. exports.getFontType = getFontType;
  43274. }));
  43275. (function (root, factory) {
  43276. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43277. }(this, function (exports, sharedUtil, coreParser) {
  43278. var error = sharedUtil.error;
  43279. var isSpace = sharedUtil.isSpace;
  43280. var EOF = coreParser.EOF;
  43281. var PostScriptParser = function PostScriptParserClosure() {
  43282. function PostScriptParser(lexer) {
  43283. this.lexer = lexer;
  43284. this.operators = [];
  43285. this.token = null;
  43286. this.prev = null;
  43287. }
  43288. PostScriptParser.prototype = {
  43289. nextToken: function PostScriptParser_nextToken() {
  43290. this.prev = this.token;
  43291. this.token = this.lexer.getToken();
  43292. },
  43293. accept: function PostScriptParser_accept(type) {
  43294. if (this.token.type === type) {
  43295. this.nextToken();
  43296. return true;
  43297. }
  43298. return false;
  43299. },
  43300. expect: function PostScriptParser_expect(type) {
  43301. if (this.accept(type)) {
  43302. return true;
  43303. }
  43304. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43305. },
  43306. parse: function PostScriptParser_parse() {
  43307. this.nextToken();
  43308. this.expect(PostScriptTokenTypes.LBRACE);
  43309. this.parseBlock();
  43310. this.expect(PostScriptTokenTypes.RBRACE);
  43311. return this.operators;
  43312. },
  43313. parseBlock: function PostScriptParser_parseBlock() {
  43314. while (true) {
  43315. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43316. this.operators.push(this.prev.value);
  43317. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43318. this.operators.push(this.prev.value);
  43319. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43320. this.parseCondition();
  43321. } else {
  43322. return;
  43323. }
  43324. }
  43325. },
  43326. parseCondition: function PostScriptParser_parseCondition() {
  43327. var conditionLocation = this.operators.length;
  43328. this.operators.push(null, null);
  43329. this.parseBlock();
  43330. this.expect(PostScriptTokenTypes.RBRACE);
  43331. if (this.accept(PostScriptTokenTypes.IF)) {
  43332. this.operators[conditionLocation] = this.operators.length;
  43333. this.operators[conditionLocation + 1] = 'jz';
  43334. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43335. var jumpLocation = this.operators.length;
  43336. this.operators.push(null, null);
  43337. var endOfTrue = this.operators.length;
  43338. this.parseBlock();
  43339. this.expect(PostScriptTokenTypes.RBRACE);
  43340. this.expect(PostScriptTokenTypes.IFELSE);
  43341. this.operators[jumpLocation] = this.operators.length;
  43342. this.operators[jumpLocation + 1] = 'j';
  43343. this.operators[conditionLocation] = endOfTrue;
  43344. this.operators[conditionLocation + 1] = 'jz';
  43345. } else {
  43346. error('PS Function: error parsing conditional.');
  43347. }
  43348. }
  43349. };
  43350. return PostScriptParser;
  43351. }();
  43352. var PostScriptTokenTypes = {
  43353. LBRACE: 0,
  43354. RBRACE: 1,
  43355. NUMBER: 2,
  43356. OPERATOR: 3,
  43357. IF: 4,
  43358. IFELSE: 5
  43359. };
  43360. var PostScriptToken = function PostScriptTokenClosure() {
  43361. function PostScriptToken(type, value) {
  43362. this.type = type;
  43363. this.value = value;
  43364. }
  43365. var opCache = Object.create(null);
  43366. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43367. var opValue = opCache[op];
  43368. if (opValue) {
  43369. return opValue;
  43370. }
  43371. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43372. };
  43373. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43374. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43375. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43376. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43377. return PostScriptToken;
  43378. }();
  43379. var PostScriptLexer = function PostScriptLexerClosure() {
  43380. function PostScriptLexer(stream) {
  43381. this.stream = stream;
  43382. this.nextChar();
  43383. this.strBuf = [];
  43384. }
  43385. PostScriptLexer.prototype = {
  43386. nextChar: function PostScriptLexer_nextChar() {
  43387. return this.currentChar = this.stream.getByte();
  43388. },
  43389. getToken: function PostScriptLexer_getToken() {
  43390. var comment = false;
  43391. var ch = this.currentChar;
  43392. while (true) {
  43393. if (ch < 0) {
  43394. return EOF;
  43395. }
  43396. if (comment) {
  43397. if (ch === 0x0A || ch === 0x0D) {
  43398. comment = false;
  43399. }
  43400. } else if (ch === 0x25) {
  43401. comment = true;
  43402. } else if (!isSpace(ch)) {
  43403. break;
  43404. }
  43405. ch = this.nextChar();
  43406. }
  43407. switch (ch | 0) {
  43408. case 0x30:
  43409. case 0x31:
  43410. case 0x32:
  43411. case 0x33:
  43412. case 0x34:
  43413. case 0x35:
  43414. case 0x36:
  43415. case 0x37:
  43416. case 0x38:
  43417. case 0x39:
  43418. case 0x2B:
  43419. case 0x2D:
  43420. case 0x2E:
  43421. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43422. case 0x7B:
  43423. this.nextChar();
  43424. return PostScriptToken.LBRACE;
  43425. case 0x7D:
  43426. this.nextChar();
  43427. return PostScriptToken.RBRACE;
  43428. }
  43429. var strBuf = this.strBuf;
  43430. strBuf.length = 0;
  43431. strBuf[0] = String.fromCharCode(ch);
  43432. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43433. strBuf.push(String.fromCharCode(ch));
  43434. }
  43435. var str = strBuf.join('');
  43436. switch (str.toLowerCase()) {
  43437. case 'if':
  43438. return PostScriptToken.IF;
  43439. case 'ifelse':
  43440. return PostScriptToken.IFELSE;
  43441. default:
  43442. return PostScriptToken.getOperator(str);
  43443. }
  43444. },
  43445. getNumber: function PostScriptLexer_getNumber() {
  43446. var ch = this.currentChar;
  43447. var strBuf = this.strBuf;
  43448. strBuf.length = 0;
  43449. strBuf[0] = String.fromCharCode(ch);
  43450. while ((ch = this.nextChar()) >= 0) {
  43451. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43452. strBuf.push(String.fromCharCode(ch));
  43453. } else {
  43454. break;
  43455. }
  43456. }
  43457. var value = parseFloat(strBuf.join(''));
  43458. if (isNaN(value)) {
  43459. error('Invalid floating point number: ' + value);
  43460. }
  43461. return value;
  43462. }
  43463. };
  43464. return PostScriptLexer;
  43465. }();
  43466. exports.PostScriptLexer = PostScriptLexer;
  43467. exports.PostScriptParser = PostScriptParser;
  43468. }));
  43469. (function (root, factory) {
  43470. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43471. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43472. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43473. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43474. var ImageKind = sharedUtil.ImageKind;
  43475. var OPS = sharedUtil.OPS;
  43476. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43477. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43478. var Util = sharedUtil.Util;
  43479. var assert = sharedUtil.assert;
  43480. var info = sharedUtil.info;
  43481. var isNum = sharedUtil.isNum;
  43482. var isArray = sharedUtil.isArray;
  43483. var isLittleEndian = sharedUtil.isLittleEndian;
  43484. var error = sharedUtil.error;
  43485. var shadow = sharedUtil.shadow;
  43486. var warn = sharedUtil.warn;
  43487. var TilingPattern = displayPatternHelper.TilingPattern;
  43488. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43489. var WebGLUtils = displayWebGL.WebGLUtils;
  43490. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43491. var MIN_FONT_SIZE = 16;
  43492. var MAX_FONT_SIZE = 100;
  43493. var MAX_GROUP_SIZE = 4096;
  43494. var MIN_WIDTH_FACTOR = 0.65;
  43495. var COMPILE_TYPE3_GLYPHS = true;
  43496. var MAX_SIZE_TO_COMPILE = 1000;
  43497. var FULL_CHUNK_HEIGHT = 16;
  43498. var HasCanvasTypedArraysCached = {
  43499. get value() {
  43500. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43501. }
  43502. };
  43503. var IsLittleEndianCached = {
  43504. get value() {
  43505. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43506. }
  43507. };
  43508. function createScratchCanvas(width, height) {
  43509. var canvas = document.createElement('canvas');
  43510. canvas.width = width;
  43511. canvas.height = height;
  43512. return canvas;
  43513. }
  43514. function addContextCurrentTransform(ctx) {
  43515. if (!ctx.mozCurrentTransform) {
  43516. ctx._originalSave = ctx.save;
  43517. ctx._originalRestore = ctx.restore;
  43518. ctx._originalRotate = ctx.rotate;
  43519. ctx._originalScale = ctx.scale;
  43520. ctx._originalTranslate = ctx.translate;
  43521. ctx._originalTransform = ctx.transform;
  43522. ctx._originalSetTransform = ctx.setTransform;
  43523. ctx._transformMatrix = ctx._transformMatrix || [
  43524. 1,
  43525. 0,
  43526. 0,
  43527. 1,
  43528. 0,
  43529. 0
  43530. ];
  43531. ctx._transformStack = [];
  43532. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43533. get: function getCurrentTransform() {
  43534. return this._transformMatrix;
  43535. }
  43536. });
  43537. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43538. get: function getCurrentTransformInverse() {
  43539. var m = this._transformMatrix;
  43540. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43541. var ad_bc = a * d - b * c;
  43542. var bc_ad = b * c - a * d;
  43543. return [
  43544. d / ad_bc,
  43545. b / bc_ad,
  43546. c / bc_ad,
  43547. a / ad_bc,
  43548. (d * e - c * f) / bc_ad,
  43549. (b * e - a * f) / ad_bc
  43550. ];
  43551. }
  43552. });
  43553. ctx.save = function ctxSave() {
  43554. var old = this._transformMatrix;
  43555. this._transformStack.push(old);
  43556. this._transformMatrix = old.slice(0, 6);
  43557. this._originalSave();
  43558. };
  43559. ctx.restore = function ctxRestore() {
  43560. var prev = this._transformStack.pop();
  43561. if (prev) {
  43562. this._transformMatrix = prev;
  43563. this._originalRestore();
  43564. }
  43565. };
  43566. ctx.translate = function ctxTranslate(x, y) {
  43567. var m = this._transformMatrix;
  43568. m[4] = m[0] * x + m[2] * y + m[4];
  43569. m[5] = m[1] * x + m[3] * y + m[5];
  43570. this._originalTranslate(x, y);
  43571. };
  43572. ctx.scale = function ctxScale(x, y) {
  43573. var m = this._transformMatrix;
  43574. m[0] = m[0] * x;
  43575. m[1] = m[1] * x;
  43576. m[2] = m[2] * y;
  43577. m[3] = m[3] * y;
  43578. this._originalScale(x, y);
  43579. };
  43580. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43581. var m = this._transformMatrix;
  43582. this._transformMatrix = [
  43583. m[0] * a + m[2] * b,
  43584. m[1] * a + m[3] * b,
  43585. m[0] * c + m[2] * d,
  43586. m[1] * c + m[3] * d,
  43587. m[0] * e + m[2] * f + m[4],
  43588. m[1] * e + m[3] * f + m[5]
  43589. ];
  43590. ctx._originalTransform(a, b, c, d, e, f);
  43591. };
  43592. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43593. this._transformMatrix = [
  43594. a,
  43595. b,
  43596. c,
  43597. d,
  43598. e,
  43599. f
  43600. ];
  43601. ctx._originalSetTransform(a, b, c, d, e, f);
  43602. };
  43603. ctx.rotate = function ctxRotate(angle) {
  43604. var cosValue = Math.cos(angle);
  43605. var sinValue = Math.sin(angle);
  43606. var m = this._transformMatrix;
  43607. this._transformMatrix = [
  43608. m[0] * cosValue + m[2] * sinValue,
  43609. m[1] * cosValue + m[3] * sinValue,
  43610. m[0] * -sinValue + m[2] * cosValue,
  43611. m[1] * -sinValue + m[3] * cosValue,
  43612. m[4],
  43613. m[5]
  43614. ];
  43615. this._originalRotate(angle);
  43616. };
  43617. }
  43618. }
  43619. var CachedCanvases = function CachedCanvasesClosure() {
  43620. function CachedCanvases() {
  43621. this.cache = Object.create(null);
  43622. }
  43623. CachedCanvases.prototype = {
  43624. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43625. var canvasEntry;
  43626. if (this.cache[id] !== undefined) {
  43627. canvasEntry = this.cache[id];
  43628. canvasEntry.canvas.width = width;
  43629. canvasEntry.canvas.height = height;
  43630. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43631. } else {
  43632. var canvas = createScratchCanvas(width, height);
  43633. var ctx = canvas.getContext('2d');
  43634. if (trackTransform) {
  43635. addContextCurrentTransform(ctx);
  43636. }
  43637. this.cache[id] = canvasEntry = {
  43638. canvas: canvas,
  43639. context: ctx
  43640. };
  43641. }
  43642. return canvasEntry;
  43643. },
  43644. clear: function () {
  43645. for (var id in this.cache) {
  43646. var canvasEntry = this.cache[id];
  43647. canvasEntry.canvas.width = 0;
  43648. canvasEntry.canvas.height = 0;
  43649. delete this.cache[id];
  43650. }
  43651. }
  43652. };
  43653. return CachedCanvases;
  43654. }();
  43655. function compileType3Glyph(imgData) {
  43656. var POINT_TO_PROCESS_LIMIT = 1000;
  43657. var width = imgData.width, height = imgData.height;
  43658. var i, j, j0, width1 = width + 1;
  43659. var points = new Uint8Array(width1 * (height + 1));
  43660. var POINT_TYPES = new Uint8Array([
  43661. 0,
  43662. 2,
  43663. 4,
  43664. 0,
  43665. 1,
  43666. 0,
  43667. 5,
  43668. 4,
  43669. 8,
  43670. 10,
  43671. 0,
  43672. 8,
  43673. 0,
  43674. 2,
  43675. 1,
  43676. 0
  43677. ]);
  43678. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43679. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43680. for (i = 0, ii = data0.length; i < ii; i++) {
  43681. var mask = 128, elem = data0[i];
  43682. while (mask > 0) {
  43683. data[pos++] = elem & mask ? 0 : 255;
  43684. mask >>= 1;
  43685. }
  43686. }
  43687. var count = 0;
  43688. pos = 0;
  43689. if (data[pos] !== 0) {
  43690. points[0] = 1;
  43691. ++count;
  43692. }
  43693. for (j = 1; j < width; j++) {
  43694. if (data[pos] !== data[pos + 1]) {
  43695. points[j] = data[pos] ? 2 : 1;
  43696. ++count;
  43697. }
  43698. pos++;
  43699. }
  43700. if (data[pos] !== 0) {
  43701. points[j] = 2;
  43702. ++count;
  43703. }
  43704. for (i = 1; i < height; i++) {
  43705. pos = i * lineSize;
  43706. j0 = i * width1;
  43707. if (data[pos - lineSize] !== data[pos]) {
  43708. points[j0] = data[pos] ? 1 : 8;
  43709. ++count;
  43710. }
  43711. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43712. for (j = 1; j < width; j++) {
  43713. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43714. if (POINT_TYPES[sum]) {
  43715. points[j0 + j] = POINT_TYPES[sum];
  43716. ++count;
  43717. }
  43718. pos++;
  43719. }
  43720. if (data[pos - lineSize] !== data[pos]) {
  43721. points[j0 + j] = data[pos] ? 2 : 4;
  43722. ++count;
  43723. }
  43724. if (count > POINT_TO_PROCESS_LIMIT) {
  43725. return null;
  43726. }
  43727. }
  43728. pos = lineSize * (height - 1);
  43729. j0 = i * width1;
  43730. if (data[pos] !== 0) {
  43731. points[j0] = 8;
  43732. ++count;
  43733. }
  43734. for (j = 1; j < width; j++) {
  43735. if (data[pos] !== data[pos + 1]) {
  43736. points[j0 + j] = data[pos] ? 4 : 8;
  43737. ++count;
  43738. }
  43739. pos++;
  43740. }
  43741. if (data[pos] !== 0) {
  43742. points[j0 + j] = 4;
  43743. ++count;
  43744. }
  43745. if (count > POINT_TO_PROCESS_LIMIT) {
  43746. return null;
  43747. }
  43748. var steps = new Int32Array([
  43749. 0,
  43750. width1,
  43751. -1,
  43752. 0,
  43753. -width1,
  43754. 0,
  43755. 0,
  43756. 0,
  43757. 1
  43758. ]);
  43759. var outlines = [];
  43760. for (i = 0; count && i <= height; i++) {
  43761. var p = i * width1;
  43762. var end = p + width;
  43763. while (p < end && !points[p]) {
  43764. p++;
  43765. }
  43766. if (p === end) {
  43767. continue;
  43768. }
  43769. var coords = [
  43770. p % width1,
  43771. i
  43772. ];
  43773. var type = points[p], p0 = p, pp;
  43774. do {
  43775. var step = steps[type];
  43776. do {
  43777. p += step;
  43778. } while (!points[p]);
  43779. pp = points[p];
  43780. if (pp !== 5 && pp !== 10) {
  43781. type = pp;
  43782. points[p] = 0;
  43783. } else {
  43784. type = pp & 0x33 * type >> 4;
  43785. points[p] &= type >> 2 | type << 2;
  43786. }
  43787. coords.push(p % width1);
  43788. coords.push(p / width1 | 0);
  43789. --count;
  43790. } while (p0 !== p);
  43791. outlines.push(coords);
  43792. --i;
  43793. }
  43794. var drawOutline = function (c) {
  43795. c.save();
  43796. c.scale(1 / width, -1 / height);
  43797. c.translate(0, -height);
  43798. c.beginPath();
  43799. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43800. var o = outlines[i];
  43801. c.moveTo(o[0], o[1]);
  43802. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43803. c.lineTo(o[j], o[j + 1]);
  43804. }
  43805. }
  43806. c.fill();
  43807. c.beginPath();
  43808. c.restore();
  43809. };
  43810. return drawOutline;
  43811. }
  43812. var CanvasExtraState = function CanvasExtraStateClosure() {
  43813. function CanvasExtraState(old) {
  43814. this.alphaIsShape = false;
  43815. this.fontSize = 0;
  43816. this.fontSizeScale = 1;
  43817. this.textMatrix = IDENTITY_MATRIX;
  43818. this.textMatrixScale = 1;
  43819. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43820. this.leading = 0;
  43821. this.x = 0;
  43822. this.y = 0;
  43823. this.lineX = 0;
  43824. this.lineY = 0;
  43825. this.charSpacing = 0;
  43826. this.wordSpacing = 0;
  43827. this.textHScale = 1;
  43828. this.textRenderingMode = TextRenderingMode.FILL;
  43829. this.textRise = 0;
  43830. this.fillColor = '#000000';
  43831. this.strokeColor = '#000000';
  43832. this.patternFill = false;
  43833. this.fillAlpha = 1;
  43834. this.strokeAlpha = 1;
  43835. this.lineWidth = 1;
  43836. this.activeSMask = null;
  43837. this.resumeSMaskCtx = null;
  43838. this.old = old;
  43839. }
  43840. CanvasExtraState.prototype = {
  43841. clone: function CanvasExtraState_clone() {
  43842. return Object.create(this);
  43843. },
  43844. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  43845. this.x = x;
  43846. this.y = y;
  43847. }
  43848. };
  43849. return CanvasExtraState;
  43850. }();
  43851. var CanvasGraphics = function CanvasGraphicsClosure() {
  43852. var EXECUTION_TIME = 15;
  43853. var EXECUTION_STEPS = 10;
  43854. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  43855. this.ctx = canvasCtx;
  43856. this.current = new CanvasExtraState();
  43857. this.stateStack = [];
  43858. this.pendingClip = null;
  43859. this.pendingEOFill = false;
  43860. this.res = null;
  43861. this.xobjs = null;
  43862. this.commonObjs = commonObjs;
  43863. this.objs = objs;
  43864. this.imageLayer = imageLayer;
  43865. this.groupStack = [];
  43866. this.processingType3 = null;
  43867. this.baseTransform = null;
  43868. this.baseTransformStack = [];
  43869. this.groupLevel = 0;
  43870. this.smaskStack = [];
  43871. this.smaskCounter = 0;
  43872. this.tempSMask = null;
  43873. this.cachedCanvases = new CachedCanvases();
  43874. if (canvasCtx) {
  43875. addContextCurrentTransform(canvasCtx);
  43876. }
  43877. this.cachedGetSinglePixelWidth = null;
  43878. }
  43879. function putBinaryImageData(ctx, imgData) {
  43880. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  43881. ctx.putImageData(imgData, 0, 0);
  43882. return;
  43883. }
  43884. var height = imgData.height, width = imgData.width;
  43885. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43886. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43887. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43888. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43889. var srcPos = 0, destPos;
  43890. var src = imgData.data;
  43891. var dest = chunkImgData.data;
  43892. var i, j, thisChunkHeight, elemsInThisChunk;
  43893. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  43894. var srcLength = src.byteLength;
  43895. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  43896. var dest32DataLength = dest32.length;
  43897. var fullSrcDiff = width + 7 >> 3;
  43898. var white = 0xFFFFFFFF;
  43899. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  43900. for (i = 0; i < totalChunks; i++) {
  43901. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43902. destPos = 0;
  43903. for (j = 0; j < thisChunkHeight; j++) {
  43904. var srcDiff = srcLength - srcPos;
  43905. var k = 0;
  43906. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  43907. var kEndUnrolled = kEnd & ~7;
  43908. var mask = 0;
  43909. var srcByte = 0;
  43910. for (; k < kEndUnrolled; k += 8) {
  43911. srcByte = src[srcPos++];
  43912. dest32[destPos++] = srcByte & 128 ? white : black;
  43913. dest32[destPos++] = srcByte & 64 ? white : black;
  43914. dest32[destPos++] = srcByte & 32 ? white : black;
  43915. dest32[destPos++] = srcByte & 16 ? white : black;
  43916. dest32[destPos++] = srcByte & 8 ? white : black;
  43917. dest32[destPos++] = srcByte & 4 ? white : black;
  43918. dest32[destPos++] = srcByte & 2 ? white : black;
  43919. dest32[destPos++] = srcByte & 1 ? white : black;
  43920. }
  43921. for (; k < kEnd; k++) {
  43922. if (mask === 0) {
  43923. srcByte = src[srcPos++];
  43924. mask = 128;
  43925. }
  43926. dest32[destPos++] = srcByte & mask ? white : black;
  43927. mask >>= 1;
  43928. }
  43929. }
  43930. while (destPos < dest32DataLength) {
  43931. dest32[destPos++] = 0;
  43932. }
  43933. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43934. }
  43935. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  43936. j = 0;
  43937. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  43938. for (i = 0; i < fullChunks; i++) {
  43939. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43940. srcPos += elemsInThisChunk;
  43941. ctx.putImageData(chunkImgData, 0, j);
  43942. j += FULL_CHUNK_HEIGHT;
  43943. }
  43944. if (i < totalChunks) {
  43945. elemsInThisChunk = width * partialChunkHeight * 4;
  43946. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43947. ctx.putImageData(chunkImgData, 0, j);
  43948. }
  43949. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  43950. thisChunkHeight = FULL_CHUNK_HEIGHT;
  43951. elemsInThisChunk = width * thisChunkHeight;
  43952. for (i = 0; i < totalChunks; i++) {
  43953. if (i >= fullChunks) {
  43954. thisChunkHeight = partialChunkHeight;
  43955. elemsInThisChunk = width * thisChunkHeight;
  43956. }
  43957. destPos = 0;
  43958. for (j = elemsInThisChunk; j--;) {
  43959. dest[destPos++] = src[srcPos++];
  43960. dest[destPos++] = src[srcPos++];
  43961. dest[destPos++] = src[srcPos++];
  43962. dest[destPos++] = 255;
  43963. }
  43964. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43965. }
  43966. } else {
  43967. error('bad image kind: ' + imgData.kind);
  43968. }
  43969. }
  43970. function putBinaryImageMask(ctx, imgData) {
  43971. var height = imgData.height, width = imgData.width;
  43972. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43973. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43974. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43975. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43976. var srcPos = 0;
  43977. var src = imgData.data;
  43978. var dest = chunkImgData.data;
  43979. for (var i = 0; i < totalChunks; i++) {
  43980. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43981. var destPos = 3;
  43982. for (var j = 0; j < thisChunkHeight; j++) {
  43983. var mask = 0;
  43984. for (var k = 0; k < width; k++) {
  43985. if (!mask) {
  43986. var elem = src[srcPos++];
  43987. mask = 128;
  43988. }
  43989. dest[destPos] = elem & mask ? 0 : 255;
  43990. destPos += 4;
  43991. mask >>= 1;
  43992. }
  43993. }
  43994. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43995. }
  43996. }
  43997. function copyCtxState(sourceCtx, destCtx) {
  43998. var properties = [
  43999. 'strokeStyle',
  44000. 'fillStyle',
  44001. 'fillRule',
  44002. 'globalAlpha',
  44003. 'lineWidth',
  44004. 'lineCap',
  44005. 'lineJoin',
  44006. 'miterLimit',
  44007. 'globalCompositeOperation',
  44008. 'font'
  44009. ];
  44010. for (var i = 0, ii = properties.length; i < ii; i++) {
  44011. var property = properties[i];
  44012. if (sourceCtx[property] !== undefined) {
  44013. destCtx[property] = sourceCtx[property];
  44014. }
  44015. }
  44016. if (sourceCtx.setLineDash !== undefined) {
  44017. destCtx.setLineDash(sourceCtx.getLineDash());
  44018. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44019. }
  44020. }
  44021. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44022. var length = bytes.length;
  44023. for (var i = 3; i < length; i += 4) {
  44024. var alpha = bytes[i];
  44025. if (alpha === 0) {
  44026. bytes[i - 3] = r0;
  44027. bytes[i - 2] = g0;
  44028. bytes[i - 1] = b0;
  44029. } else if (alpha < 255) {
  44030. var alpha_ = 255 - alpha;
  44031. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44032. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44033. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44034. }
  44035. }
  44036. }
  44037. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44038. var length = maskData.length;
  44039. var scale = 1 / 255;
  44040. for (var i = 3; i < length; i += 4) {
  44041. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44042. layerData[i] = layerData[i] * alpha * scale | 0;
  44043. }
  44044. }
  44045. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44046. var length = maskData.length;
  44047. for (var i = 3; i < length; i += 4) {
  44048. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44049. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44050. }
  44051. }
  44052. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44053. var hasBackdrop = !!backdrop;
  44054. var r0 = hasBackdrop ? backdrop[0] : 0;
  44055. var g0 = hasBackdrop ? backdrop[1] : 0;
  44056. var b0 = hasBackdrop ? backdrop[2] : 0;
  44057. var composeFn;
  44058. if (subtype === 'Luminosity') {
  44059. composeFn = composeSMaskLuminosity;
  44060. } else {
  44061. composeFn = composeSMaskAlpha;
  44062. }
  44063. var PIXELS_TO_PROCESS = 1048576;
  44064. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44065. for (var row = 0; row < height; row += chunkSize) {
  44066. var chunkHeight = Math.min(chunkSize, height - row);
  44067. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44068. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44069. if (hasBackdrop) {
  44070. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44071. }
  44072. composeFn(maskData.data, layerData.data, transferMap);
  44073. maskCtx.putImageData(layerData, 0, row);
  44074. }
  44075. }
  44076. function composeSMask(ctx, smask, layerCtx) {
  44077. var mask = smask.canvas;
  44078. var maskCtx = smask.context;
  44079. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44080. var backdrop = smask.backdrop || null;
  44081. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44082. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44083. subtype: smask.subtype,
  44084. backdrop: backdrop
  44085. });
  44086. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44087. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44088. return;
  44089. }
  44090. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44091. ctx.drawImage(mask, 0, 0);
  44092. }
  44093. var LINE_CAP_STYLES = [
  44094. 'butt',
  44095. 'round',
  44096. 'square'
  44097. ];
  44098. var LINE_JOIN_STYLES = [
  44099. 'miter',
  44100. 'round',
  44101. 'bevel'
  44102. ];
  44103. var NORMAL_CLIP = {};
  44104. var EO_CLIP = {};
  44105. CanvasGraphics.prototype = {
  44106. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44107. var width = this.ctx.canvas.width;
  44108. var height = this.ctx.canvas.height;
  44109. this.ctx.save();
  44110. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44111. this.ctx.fillRect(0, 0, width, height);
  44112. this.ctx.restore();
  44113. if (transparency) {
  44114. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44115. this.compositeCtx = this.ctx;
  44116. this.transparentCanvas = transparentCanvas.canvas;
  44117. this.ctx = transparentCanvas.context;
  44118. this.ctx.save();
  44119. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44120. }
  44121. this.ctx.save();
  44122. if (transform) {
  44123. this.ctx.transform.apply(this.ctx, transform);
  44124. }
  44125. this.ctx.transform.apply(this.ctx, viewport.transform);
  44126. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44127. if (this.imageLayer) {
  44128. this.imageLayer.beginLayout();
  44129. }
  44130. },
  44131. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44132. var argsArray = operatorList.argsArray;
  44133. var fnArray = operatorList.fnArray;
  44134. var i = executionStartIdx || 0;
  44135. var argsArrayLen = argsArray.length;
  44136. if (argsArrayLen === i) {
  44137. return i;
  44138. }
  44139. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44140. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44141. var steps = 0;
  44142. var commonObjs = this.commonObjs;
  44143. var objs = this.objs;
  44144. var fnId;
  44145. while (true) {
  44146. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44147. stepper.breakIt(i, continueCallback);
  44148. return i;
  44149. }
  44150. fnId = fnArray[i];
  44151. if (fnId !== OPS.dependency) {
  44152. this[fnId].apply(this, argsArray[i]);
  44153. } else {
  44154. var deps = argsArray[i];
  44155. for (var n = 0, nn = deps.length; n < nn; n++) {
  44156. var depObjId = deps[n];
  44157. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44158. var objsPool = common ? commonObjs : objs;
  44159. if (!objsPool.isResolved(depObjId)) {
  44160. objsPool.get(depObjId, continueCallback);
  44161. return i;
  44162. }
  44163. }
  44164. }
  44165. i++;
  44166. if (i === argsArrayLen) {
  44167. return i;
  44168. }
  44169. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44170. if (Date.now() > endTime) {
  44171. continueCallback();
  44172. return i;
  44173. }
  44174. steps = 0;
  44175. }
  44176. }
  44177. },
  44178. endDrawing: function CanvasGraphics_endDrawing() {
  44179. if (this.current.activeSMask !== null) {
  44180. this.endSMaskGroup();
  44181. }
  44182. this.ctx.restore();
  44183. if (this.transparentCanvas) {
  44184. this.ctx = this.compositeCtx;
  44185. this.ctx.save();
  44186. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44187. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44188. this.ctx.restore();
  44189. this.transparentCanvas = null;
  44190. }
  44191. this.cachedCanvases.clear();
  44192. WebGLUtils.clear();
  44193. if (this.imageLayer) {
  44194. this.imageLayer.endLayout();
  44195. }
  44196. },
  44197. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44198. this.current.lineWidth = width;
  44199. this.ctx.lineWidth = width;
  44200. },
  44201. setLineCap: function CanvasGraphics_setLineCap(style) {
  44202. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44203. },
  44204. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44205. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44206. },
  44207. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44208. this.ctx.miterLimit = limit;
  44209. },
  44210. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44211. var ctx = this.ctx;
  44212. if (ctx.setLineDash !== undefined) {
  44213. ctx.setLineDash(dashArray);
  44214. ctx.lineDashOffset = dashPhase;
  44215. }
  44216. },
  44217. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44218. },
  44219. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44220. },
  44221. setGState: function CanvasGraphics_setGState(states) {
  44222. for (var i = 0, ii = states.length; i < ii; i++) {
  44223. var state = states[i];
  44224. var key = state[0];
  44225. var value = state[1];
  44226. switch (key) {
  44227. case 'LW':
  44228. this.setLineWidth(value);
  44229. break;
  44230. case 'LC':
  44231. this.setLineCap(value);
  44232. break;
  44233. case 'LJ':
  44234. this.setLineJoin(value);
  44235. break;
  44236. case 'ML':
  44237. this.setMiterLimit(value);
  44238. break;
  44239. case 'D':
  44240. this.setDash(value[0], value[1]);
  44241. break;
  44242. case 'RI':
  44243. this.setRenderingIntent(value);
  44244. break;
  44245. case 'FL':
  44246. this.setFlatness(value);
  44247. break;
  44248. case 'Font':
  44249. this.setFont(value[0], value[1]);
  44250. break;
  44251. case 'CA':
  44252. this.current.strokeAlpha = state[1];
  44253. break;
  44254. case 'ca':
  44255. this.current.fillAlpha = state[1];
  44256. this.ctx.globalAlpha = state[1];
  44257. break;
  44258. case 'BM':
  44259. if (value && value.name && value.name !== 'Normal') {
  44260. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44261. return '-' + c.toLowerCase();
  44262. }).substring(1);
  44263. this.ctx.globalCompositeOperation = mode;
  44264. if (this.ctx.globalCompositeOperation !== mode) {
  44265. warn('globalCompositeOperation "' + mode + '" is not supported');
  44266. }
  44267. } else {
  44268. this.ctx.globalCompositeOperation = 'source-over';
  44269. }
  44270. break;
  44271. case 'SMask':
  44272. if (this.current.activeSMask) {
  44273. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44274. this.suspendSMaskGroup();
  44275. } else {
  44276. this.endSMaskGroup();
  44277. }
  44278. }
  44279. this.current.activeSMask = value ? this.tempSMask : null;
  44280. if (this.current.activeSMask) {
  44281. this.beginSMaskGroup();
  44282. }
  44283. this.tempSMask = null;
  44284. break;
  44285. }
  44286. }
  44287. },
  44288. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44289. var activeSMask = this.current.activeSMask;
  44290. var drawnWidth = activeSMask.canvas.width;
  44291. var drawnHeight = activeSMask.canvas.height;
  44292. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44293. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44294. var currentCtx = this.ctx;
  44295. var currentTransform = currentCtx.mozCurrentTransform;
  44296. this.ctx.save();
  44297. var groupCtx = scratchCanvas.context;
  44298. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44299. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44300. groupCtx.transform.apply(groupCtx, currentTransform);
  44301. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44302. copyCtxState(currentCtx, groupCtx);
  44303. this.ctx = groupCtx;
  44304. this.setGState([
  44305. [
  44306. 'BM',
  44307. 'Normal'
  44308. ],
  44309. [
  44310. 'ca',
  44311. 1
  44312. ],
  44313. [
  44314. 'CA',
  44315. 1
  44316. ]
  44317. ]);
  44318. this.groupStack.push(currentCtx);
  44319. this.groupLevel++;
  44320. },
  44321. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44322. var groupCtx = this.ctx;
  44323. this.groupLevel--;
  44324. this.ctx = this.groupStack.pop();
  44325. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44326. this.ctx.restore();
  44327. this.ctx.save();
  44328. copyCtxState(groupCtx, this.ctx);
  44329. this.current.resumeSMaskCtx = groupCtx;
  44330. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44331. this.ctx.transform.apply(this.ctx, deltaTransform);
  44332. groupCtx.save();
  44333. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44334. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44335. groupCtx.restore();
  44336. },
  44337. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44338. var groupCtx = this.current.resumeSMaskCtx;
  44339. var currentCtx = this.ctx;
  44340. this.ctx = groupCtx;
  44341. this.groupStack.push(currentCtx);
  44342. this.groupLevel++;
  44343. },
  44344. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44345. var groupCtx = this.ctx;
  44346. this.groupLevel--;
  44347. this.ctx = this.groupStack.pop();
  44348. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44349. this.ctx.restore();
  44350. copyCtxState(groupCtx, this.ctx);
  44351. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44352. this.ctx.transform.apply(this.ctx, deltaTransform);
  44353. },
  44354. save: function CanvasGraphics_save() {
  44355. this.ctx.save();
  44356. var old = this.current;
  44357. this.stateStack.push(old);
  44358. this.current = old.clone();
  44359. this.current.resumeSMaskCtx = null;
  44360. },
  44361. restore: function CanvasGraphics_restore() {
  44362. if (this.current.resumeSMaskCtx) {
  44363. this.resumeSMaskGroup();
  44364. }
  44365. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44366. this.endSMaskGroup();
  44367. }
  44368. if (this.stateStack.length !== 0) {
  44369. this.current = this.stateStack.pop();
  44370. this.ctx.restore();
  44371. this.pendingClip = null;
  44372. this.cachedGetSinglePixelWidth = null;
  44373. }
  44374. },
  44375. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44376. this.ctx.transform(a, b, c, d, e, f);
  44377. this.cachedGetSinglePixelWidth = null;
  44378. },
  44379. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44380. var ctx = this.ctx;
  44381. var current = this.current;
  44382. var x = current.x, y = current.y;
  44383. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44384. switch (ops[i] | 0) {
  44385. case OPS.rectangle:
  44386. x = args[j++];
  44387. y = args[j++];
  44388. var width = args[j++];
  44389. var height = args[j++];
  44390. if (width === 0) {
  44391. width = this.getSinglePixelWidth();
  44392. }
  44393. if (height === 0) {
  44394. height = this.getSinglePixelWidth();
  44395. }
  44396. var xw = x + width;
  44397. var yh = y + height;
  44398. this.ctx.moveTo(x, y);
  44399. this.ctx.lineTo(xw, y);
  44400. this.ctx.lineTo(xw, yh);
  44401. this.ctx.lineTo(x, yh);
  44402. this.ctx.lineTo(x, y);
  44403. this.ctx.closePath();
  44404. break;
  44405. case OPS.moveTo:
  44406. x = args[j++];
  44407. y = args[j++];
  44408. ctx.moveTo(x, y);
  44409. break;
  44410. case OPS.lineTo:
  44411. x = args[j++];
  44412. y = args[j++];
  44413. ctx.lineTo(x, y);
  44414. break;
  44415. case OPS.curveTo:
  44416. x = args[j + 4];
  44417. y = args[j + 5];
  44418. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44419. j += 6;
  44420. break;
  44421. case OPS.curveTo2:
  44422. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44423. x = args[j + 2];
  44424. y = args[j + 3];
  44425. j += 4;
  44426. break;
  44427. case OPS.curveTo3:
  44428. x = args[j + 2];
  44429. y = args[j + 3];
  44430. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44431. j += 4;
  44432. break;
  44433. case OPS.closePath:
  44434. ctx.closePath();
  44435. break;
  44436. }
  44437. }
  44438. current.setCurrentPoint(x, y);
  44439. },
  44440. closePath: function CanvasGraphics_closePath() {
  44441. this.ctx.closePath();
  44442. },
  44443. stroke: function CanvasGraphics_stroke(consumePath) {
  44444. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44445. var ctx = this.ctx;
  44446. var strokeColor = this.current.strokeColor;
  44447. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44448. ctx.globalAlpha = this.current.strokeAlpha;
  44449. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44450. ctx.save();
  44451. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44452. ctx.stroke();
  44453. ctx.restore();
  44454. } else {
  44455. ctx.stroke();
  44456. }
  44457. if (consumePath) {
  44458. this.consumePath();
  44459. }
  44460. ctx.globalAlpha = this.current.fillAlpha;
  44461. },
  44462. closeStroke: function CanvasGraphics_closeStroke() {
  44463. this.closePath();
  44464. this.stroke();
  44465. },
  44466. fill: function CanvasGraphics_fill(consumePath) {
  44467. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44468. var ctx = this.ctx;
  44469. var fillColor = this.current.fillColor;
  44470. var isPatternFill = this.current.patternFill;
  44471. var needRestore = false;
  44472. if (isPatternFill) {
  44473. ctx.save();
  44474. if (this.baseTransform) {
  44475. ctx.setTransform.apply(ctx, this.baseTransform);
  44476. }
  44477. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44478. needRestore = true;
  44479. }
  44480. if (this.pendingEOFill) {
  44481. if (ctx.mozFillRule !== undefined) {
  44482. ctx.mozFillRule = 'evenodd';
  44483. ctx.fill();
  44484. ctx.mozFillRule = 'nonzero';
  44485. } else {
  44486. ctx.fill('evenodd');
  44487. }
  44488. this.pendingEOFill = false;
  44489. } else {
  44490. ctx.fill();
  44491. }
  44492. if (needRestore) {
  44493. ctx.restore();
  44494. }
  44495. if (consumePath) {
  44496. this.consumePath();
  44497. }
  44498. },
  44499. eoFill: function CanvasGraphics_eoFill() {
  44500. this.pendingEOFill = true;
  44501. this.fill();
  44502. },
  44503. fillStroke: function CanvasGraphics_fillStroke() {
  44504. this.fill(false);
  44505. this.stroke(false);
  44506. this.consumePath();
  44507. },
  44508. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44509. this.pendingEOFill = true;
  44510. this.fillStroke();
  44511. },
  44512. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44513. this.closePath();
  44514. this.fillStroke();
  44515. },
  44516. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44517. this.pendingEOFill = true;
  44518. this.closePath();
  44519. this.fillStroke();
  44520. },
  44521. endPath: function CanvasGraphics_endPath() {
  44522. this.consumePath();
  44523. },
  44524. clip: function CanvasGraphics_clip() {
  44525. this.pendingClip = NORMAL_CLIP;
  44526. },
  44527. eoClip: function CanvasGraphics_eoClip() {
  44528. this.pendingClip = EO_CLIP;
  44529. },
  44530. beginText: function CanvasGraphics_beginText() {
  44531. this.current.textMatrix = IDENTITY_MATRIX;
  44532. this.current.textMatrixScale = 1;
  44533. this.current.x = this.current.lineX = 0;
  44534. this.current.y = this.current.lineY = 0;
  44535. },
  44536. endText: function CanvasGraphics_endText() {
  44537. var paths = this.pendingTextPaths;
  44538. var ctx = this.ctx;
  44539. if (paths === undefined) {
  44540. ctx.beginPath();
  44541. return;
  44542. }
  44543. ctx.save();
  44544. ctx.beginPath();
  44545. for (var i = 0; i < paths.length; i++) {
  44546. var path = paths[i];
  44547. ctx.setTransform.apply(ctx, path.transform);
  44548. ctx.translate(path.x, path.y);
  44549. path.addToPath(ctx, path.fontSize);
  44550. }
  44551. ctx.restore();
  44552. ctx.clip();
  44553. ctx.beginPath();
  44554. delete this.pendingTextPaths;
  44555. },
  44556. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44557. this.current.charSpacing = spacing;
  44558. },
  44559. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44560. this.current.wordSpacing = spacing;
  44561. },
  44562. setHScale: function CanvasGraphics_setHScale(scale) {
  44563. this.current.textHScale = scale / 100;
  44564. },
  44565. setLeading: function CanvasGraphics_setLeading(leading) {
  44566. this.current.leading = -leading;
  44567. },
  44568. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44569. var fontObj = this.commonObjs.get(fontRefName);
  44570. var current = this.current;
  44571. if (!fontObj) {
  44572. error('Can\'t find font for ' + fontRefName);
  44573. }
  44574. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44575. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44576. warn('Invalid font matrix for font ' + fontRefName);
  44577. }
  44578. if (size < 0) {
  44579. size = -size;
  44580. current.fontDirection = -1;
  44581. } else {
  44582. current.fontDirection = 1;
  44583. }
  44584. this.current.font = fontObj;
  44585. this.current.fontSize = size;
  44586. if (fontObj.isType3Font) {
  44587. return;
  44588. }
  44589. var name = fontObj.loadedName || 'sans-serif';
  44590. var bold = fontObj.black ? fontObj.bold ? '900' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  44591. var italic = fontObj.italic ? 'italic' : 'normal';
  44592. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44593. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44594. this.current.fontSizeScale = size / browserFontSize;
  44595. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44596. this.ctx.font = rule;
  44597. },
  44598. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44599. this.current.textRenderingMode = mode;
  44600. },
  44601. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44602. this.current.textRise = rise;
  44603. },
  44604. moveText: function CanvasGraphics_moveText(x, y) {
  44605. this.current.x = this.current.lineX += x;
  44606. this.current.y = this.current.lineY += y;
  44607. },
  44608. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44609. this.setLeading(-y);
  44610. this.moveText(x, y);
  44611. },
  44612. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44613. this.current.textMatrix = [
  44614. a,
  44615. b,
  44616. c,
  44617. d,
  44618. e,
  44619. f
  44620. ];
  44621. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44622. this.current.x = this.current.lineX = 0;
  44623. this.current.y = this.current.lineY = 0;
  44624. },
  44625. nextLine: function CanvasGraphics_nextLine() {
  44626. this.moveText(0, this.current.leading);
  44627. },
  44628. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44629. var ctx = this.ctx;
  44630. var current = this.current;
  44631. var font = current.font;
  44632. var textRenderingMode = current.textRenderingMode;
  44633. var fontSize = current.fontSize / current.fontSizeScale;
  44634. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44635. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44636. var addToPath;
  44637. if (font.disableFontFace || isAddToPathSet) {
  44638. addToPath = font.getPathGenerator(this.commonObjs, character);
  44639. }
  44640. if (font.disableFontFace) {
  44641. ctx.save();
  44642. ctx.translate(x, y);
  44643. ctx.beginPath();
  44644. addToPath(ctx, fontSize);
  44645. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44646. ctx.fill();
  44647. }
  44648. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44649. ctx.stroke();
  44650. }
  44651. ctx.restore();
  44652. } else {
  44653. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44654. ctx.fillText(character, x, y);
  44655. }
  44656. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44657. ctx.strokeText(character, x, y);
  44658. }
  44659. }
  44660. if (isAddToPathSet) {
  44661. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44662. paths.push({
  44663. transform: ctx.mozCurrentTransform,
  44664. x: x,
  44665. y: y,
  44666. fontSize: fontSize,
  44667. addToPath: addToPath
  44668. });
  44669. }
  44670. },
  44671. get isFontSubpixelAAEnabled() {
  44672. var ctx = document.createElement('canvas').getContext('2d');
  44673. ctx.scale(1.5, 1);
  44674. ctx.fillText('I', 0, 10);
  44675. var data = ctx.getImageData(0, 0, 10, 10).data;
  44676. var enabled = false;
  44677. for (var i = 3; i < data.length; i += 4) {
  44678. if (data[i] > 0 && data[i] < 255) {
  44679. enabled = true;
  44680. break;
  44681. }
  44682. }
  44683. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44684. },
  44685. showText: function CanvasGraphics_showText(glyphs) {
  44686. var current = this.current;
  44687. var font = current.font;
  44688. if (font.isType3Font) {
  44689. return this.showType3Text(glyphs);
  44690. }
  44691. var fontSize = current.fontSize;
  44692. if (fontSize === 0) {
  44693. return;
  44694. }
  44695. var ctx = this.ctx;
  44696. var fontSizeScale = current.fontSizeScale;
  44697. var charSpacing = current.charSpacing;
  44698. var wordSpacing = current.wordSpacing;
  44699. var fontDirection = current.fontDirection;
  44700. var textHScale = current.textHScale * fontDirection;
  44701. var glyphsLength = glyphs.length;
  44702. var vertical = font.vertical;
  44703. var spacingDir = vertical ? 1 : -1;
  44704. var defaultVMetrics = font.defaultVMetrics;
  44705. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44706. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44707. ctx.save();
  44708. ctx.transform.apply(ctx, current.textMatrix);
  44709. ctx.translate(current.x, current.y + current.textRise);
  44710. if (current.patternFill) {
  44711. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44712. }
  44713. if (fontDirection > 0) {
  44714. ctx.scale(textHScale, -1);
  44715. } else {
  44716. ctx.scale(textHScale, 1);
  44717. }
  44718. var lineWidth = current.lineWidth;
  44719. var scale = current.textMatrixScale;
  44720. if (scale === 0 || lineWidth === 0) {
  44721. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44722. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44723. this.cachedGetSinglePixelWidth = null;
  44724. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44725. }
  44726. } else {
  44727. lineWidth /= scale;
  44728. }
  44729. if (fontSizeScale !== 1.0) {
  44730. ctx.scale(fontSizeScale, fontSizeScale);
  44731. lineWidth /= fontSizeScale;
  44732. }
  44733. ctx.lineWidth = lineWidth;
  44734. var x = 0, i;
  44735. for (i = 0; i < glyphsLength; ++i) {
  44736. var glyph = glyphs[i];
  44737. if (isNum(glyph)) {
  44738. x += spacingDir * glyph * fontSize / 1000;
  44739. continue;
  44740. }
  44741. var restoreNeeded = false;
  44742. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44743. var character = glyph.fontChar;
  44744. var accent = glyph.accent;
  44745. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44746. var width = glyph.width;
  44747. if (vertical) {
  44748. var vmetric, vx, vy;
  44749. vmetric = glyph.vmetric || defaultVMetrics;
  44750. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44751. vx = -vx * widthAdvanceScale;
  44752. vy = vmetric[2] * widthAdvanceScale;
  44753. width = vmetric ? -vmetric[0] : width;
  44754. scaledX = vx / fontSizeScale;
  44755. scaledY = (x + vy) / fontSizeScale;
  44756. } else {
  44757. scaledX = x / fontSizeScale;
  44758. scaledY = 0;
  44759. }
  44760. if (font.remeasure && width > 0) {
  44761. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44762. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44763. var characterScaleX = width / measuredWidth;
  44764. restoreNeeded = true;
  44765. ctx.save();
  44766. ctx.scale(characterScaleX, 1);
  44767. scaledX /= characterScaleX;
  44768. } else if (width !== measuredWidth) {
  44769. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44770. }
  44771. }
  44772. if (glyph.isInFont || font.missingFile) {
  44773. if (simpleFillText && !accent) {
  44774. ctx.fillText(character, scaledX, scaledY);
  44775. } else {
  44776. this.paintChar(character, scaledX, scaledY);
  44777. if (accent) {
  44778. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44779. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44780. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44781. }
  44782. }
  44783. }
  44784. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44785. x += charWidth;
  44786. if (restoreNeeded) {
  44787. ctx.restore();
  44788. }
  44789. }
  44790. if (vertical) {
  44791. current.y -= x * textHScale;
  44792. } else {
  44793. current.x += x * textHScale;
  44794. }
  44795. ctx.restore();
  44796. },
  44797. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44798. var ctx = this.ctx;
  44799. var current = this.current;
  44800. var font = current.font;
  44801. var fontSize = current.fontSize;
  44802. var fontDirection = current.fontDirection;
  44803. var spacingDir = font.vertical ? 1 : -1;
  44804. var charSpacing = current.charSpacing;
  44805. var wordSpacing = current.wordSpacing;
  44806. var textHScale = current.textHScale * fontDirection;
  44807. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44808. var glyphsLength = glyphs.length;
  44809. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44810. var i, glyph, width, spacingLength;
  44811. if (isTextInvisible || fontSize === 0) {
  44812. return;
  44813. }
  44814. this.cachedGetSinglePixelWidth = null;
  44815. ctx.save();
  44816. ctx.transform.apply(ctx, current.textMatrix);
  44817. ctx.translate(current.x, current.y);
  44818. ctx.scale(textHScale, fontDirection);
  44819. for (i = 0; i < glyphsLength; ++i) {
  44820. glyph = glyphs[i];
  44821. if (isNum(glyph)) {
  44822. spacingLength = spacingDir * glyph * fontSize / 1000;
  44823. this.ctx.translate(spacingLength, 0);
  44824. current.x += spacingLength * textHScale;
  44825. continue;
  44826. }
  44827. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44828. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  44829. if (!operatorList) {
  44830. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  44831. continue;
  44832. }
  44833. this.processingType3 = glyph;
  44834. this.save();
  44835. ctx.scale(fontSize, fontSize);
  44836. ctx.transform.apply(ctx, fontMatrix);
  44837. this.executeOperatorList(operatorList);
  44838. this.restore();
  44839. var transformed = Util.applyTransform([
  44840. glyph.width,
  44841. 0
  44842. ], fontMatrix);
  44843. width = transformed[0] * fontSize + spacing;
  44844. ctx.translate(width, 0);
  44845. current.x += width * textHScale;
  44846. }
  44847. ctx.restore();
  44848. this.processingType3 = null;
  44849. },
  44850. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  44851. },
  44852. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  44853. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  44854. this.clip();
  44855. this.endPath();
  44856. },
  44857. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  44858. var pattern;
  44859. if (IR[0] === 'TilingPattern') {
  44860. var color = IR[1];
  44861. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  44862. var self = this;
  44863. var canvasGraphicsFactory = {
  44864. createCanvasGraphics: function (ctx) {
  44865. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  44866. }
  44867. };
  44868. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  44869. } else {
  44870. pattern = getShadingPatternFromIR(IR);
  44871. }
  44872. return pattern;
  44873. },
  44874. setStrokeColorN: function CanvasGraphics_setStrokeColorN()
  44875. {
  44876. this.current.strokeColor = this.getColorN_Pattern(arguments);
  44877. },
  44878. setFillColorN: function CanvasGraphics_setFillColorN()
  44879. {
  44880. this.current.fillColor = this.getColorN_Pattern(arguments);
  44881. this.current.patternFill = true;
  44882. },
  44883. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  44884. var color = Util.makeCssRgb(r, g, b);
  44885. this.ctx.strokeStyle = color;
  44886. this.current.strokeColor = color;
  44887. },
  44888. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  44889. var color = Util.makeCssRgb(r, g, b);
  44890. this.ctx.fillStyle = color;
  44891. this.current.fillColor = color;
  44892. this.current.patternFill = false;
  44893. },
  44894. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  44895. var ctx = this.ctx;
  44896. this.save();
  44897. var pattern = getShadingPatternFromIR(patternIR);
  44898. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  44899. var inv = ctx.mozCurrentTransformInverse;
  44900. if (inv) {
  44901. var canvas = ctx.canvas;
  44902. var width = canvas.width;
  44903. var height = canvas.height;
  44904. var bl = Util.applyTransform([
  44905. 0,
  44906. 0
  44907. ], inv);
  44908. var br = Util.applyTransform([
  44909. 0,
  44910. height
  44911. ], inv);
  44912. var ul = Util.applyTransform([
  44913. width,
  44914. 0
  44915. ], inv);
  44916. var ur = Util.applyTransform([
  44917. width,
  44918. height
  44919. ], inv);
  44920. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  44921. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  44922. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  44923. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  44924. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  44925. } else {
  44926. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  44927. }
  44928. this.restore();
  44929. },
  44930. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  44931. error('Should not call beginInlineImage');
  44932. },
  44933. beginImageData: function CanvasGraphics_beginImageData() {
  44934. error('Should not call beginImageData');
  44935. },
  44936. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  44937. this.save();
  44938. this.baseTransformStack.push(this.baseTransform);
  44939. if (isArray(matrix) && 6 === matrix.length) {
  44940. this.transform.apply(this, matrix);
  44941. }
  44942. this.baseTransform = this.ctx.mozCurrentTransform;
  44943. if (isArray(bbox) && 4 === bbox.length) {
  44944. var width = bbox[2] - bbox[0];
  44945. var height = bbox[3] - bbox[1];
  44946. this.ctx.rect(bbox[0], bbox[1], width, height);
  44947. this.clip();
  44948. this.endPath();
  44949. }
  44950. },
  44951. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  44952. this.restore();
  44953. this.baseTransform = this.baseTransformStack.pop();
  44954. },
  44955. beginGroup: function CanvasGraphics_beginGroup(group) {
  44956. this.save();
  44957. var currentCtx = this.ctx;
  44958. if (!group.isolated) {
  44959. info('TODO: Support non-isolated groups.');
  44960. }
  44961. if (group.knockout) {
  44962. warn('Knockout groups not supported.');
  44963. }
  44964. var currentTransform = currentCtx.mozCurrentTransform;
  44965. if (group.matrix) {
  44966. currentCtx.transform.apply(currentCtx, group.matrix);
  44967. }
  44968. assert(group.bbox, 'Bounding box is required.');
  44969. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  44970. var canvasBounds = [
  44971. 0,
  44972. 0,
  44973. currentCtx.canvas.width,
  44974. currentCtx.canvas.height
  44975. ];
  44976. bounds = Util.intersect(bounds, canvasBounds) || [
  44977. 0,
  44978. 0,
  44979. 0,
  44980. 0
  44981. ];
  44982. var offsetX = Math.floor(bounds[0]);
  44983. var offsetY = Math.floor(bounds[1]);
  44984. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  44985. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  44986. var scaleX = 1, scaleY = 1;
  44987. if (drawnWidth > MAX_GROUP_SIZE) {
  44988. scaleX = drawnWidth / MAX_GROUP_SIZE;
  44989. drawnWidth = MAX_GROUP_SIZE;
  44990. }
  44991. if (drawnHeight > MAX_GROUP_SIZE) {
  44992. scaleY = drawnHeight / MAX_GROUP_SIZE;
  44993. drawnHeight = MAX_GROUP_SIZE;
  44994. }
  44995. var cacheId = 'groupAt' + this.groupLevel;
  44996. if (group.smask) {
  44997. cacheId += '_smask_' + this.smaskCounter++ % 2;
  44998. }
  44999. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45000. var groupCtx = scratchCanvas.context;
  45001. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45002. groupCtx.translate(-offsetX, -offsetY);
  45003. groupCtx.transform.apply(groupCtx, currentTransform);
  45004. if (group.smask) {
  45005. this.smaskStack.push({
  45006. canvas: scratchCanvas.canvas,
  45007. context: groupCtx,
  45008. offsetX: offsetX,
  45009. offsetY: offsetY,
  45010. scaleX: scaleX,
  45011. scaleY: scaleY,
  45012. subtype: group.smask.subtype,
  45013. backdrop: group.smask.backdrop,
  45014. transferMap: group.smask.transferMap || null,
  45015. startTransformInverse: null
  45016. });
  45017. } else
  45018. {
  45019. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45020. currentCtx.translate(offsetX, offsetY);
  45021. currentCtx.scale(scaleX, scaleY);
  45022. }
  45023. copyCtxState(currentCtx, groupCtx);
  45024. this.ctx = groupCtx;
  45025. this.setGState([
  45026. [
  45027. 'BM',
  45028. 'Normal'
  45029. ],
  45030. [
  45031. 'ca',
  45032. 1
  45033. ],
  45034. [
  45035. 'CA',
  45036. 1
  45037. ]
  45038. ]);
  45039. this.groupStack.push(currentCtx);
  45040. this.groupLevel++;
  45041. this.current.activeSMask = null;
  45042. },
  45043. endGroup: function CanvasGraphics_endGroup(group) {
  45044. this.groupLevel--;
  45045. var groupCtx = this.ctx;
  45046. this.ctx = this.groupStack.pop();
  45047. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45048. this.ctx.imageSmoothingEnabled = false;
  45049. } else {
  45050. this.ctx.mozImageSmoothingEnabled = false;
  45051. }
  45052. if (group.smask) {
  45053. this.tempSMask = this.smaskStack.pop();
  45054. } else {
  45055. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45056. }
  45057. this.restore();
  45058. },
  45059. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45060. this.save();
  45061. this.current = new CanvasExtraState();
  45062. if (this.baseTransform) {
  45063. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45064. }
  45065. },
  45066. endAnnotations: function CanvasGraphics_endAnnotations() {
  45067. this.restore();
  45068. },
  45069. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45070. this.save();
  45071. if (isArray(rect) && 4 === rect.length) {
  45072. var width = rect[2] - rect[0];
  45073. var height = rect[3] - rect[1];
  45074. this.ctx.rect(rect[0], rect[1], width, height);
  45075. this.clip();
  45076. this.endPath();
  45077. }
  45078. this.transform.apply(this, transform);
  45079. this.transform.apply(this, matrix);
  45080. },
  45081. endAnnotation: function CanvasGraphics_endAnnotation() {
  45082. this.restore();
  45083. },
  45084. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45085. var domImage = this.objs.get(objId);
  45086. if (!domImage) {
  45087. warn('Dependent image isn\'t ready yet');
  45088. return;
  45089. }
  45090. this.save();
  45091. var ctx = this.ctx;
  45092. ctx.scale(1 / w, -1 / h);
  45093. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45094. if (this.imageLayer) {
  45095. var currentTransform = ctx.mozCurrentTransformInverse;
  45096. var position = this.getCanvasPosition(0, 0);
  45097. this.imageLayer.appendImage({
  45098. objId: objId,
  45099. left: position[0],
  45100. top: position[1],
  45101. width: w / currentTransform[0],
  45102. height: h / currentTransform[3]
  45103. });
  45104. }
  45105. this.restore();
  45106. },
  45107. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45108. var ctx = this.ctx;
  45109. var width = img.width, height = img.height;
  45110. var fillColor = this.current.fillColor;
  45111. var isPatternFill = this.current.patternFill;
  45112. var glyph = this.processingType3;
  45113. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45114. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45115. glyph.compiled = compileType3Glyph({
  45116. data: img.data,
  45117. width: width,
  45118. height: height
  45119. });
  45120. } else {
  45121. glyph.compiled = null;
  45122. }
  45123. }
  45124. if (glyph && glyph.compiled) {
  45125. glyph.compiled(ctx);
  45126. return;
  45127. }
  45128. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45129. var maskCtx = maskCanvas.context;
  45130. maskCtx.save();
  45131. putBinaryImageMask(maskCtx, img);
  45132. maskCtx.globalCompositeOperation = 'source-in';
  45133. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45134. maskCtx.fillRect(0, 0, width, height);
  45135. maskCtx.restore();
  45136. this.paintInlineImageXObject(maskCanvas.canvas);
  45137. },
  45138. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45139. var width = imgData.width;
  45140. var height = imgData.height;
  45141. var fillColor = this.current.fillColor;
  45142. var isPatternFill = this.current.patternFill;
  45143. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45144. var maskCtx = maskCanvas.context;
  45145. maskCtx.save();
  45146. putBinaryImageMask(maskCtx, imgData);
  45147. maskCtx.globalCompositeOperation = 'source-in';
  45148. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45149. maskCtx.fillRect(0, 0, width, height);
  45150. maskCtx.restore();
  45151. var ctx = this.ctx;
  45152. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45153. ctx.save();
  45154. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45155. ctx.scale(1, -1);
  45156. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45157. ctx.restore();
  45158. }
  45159. },
  45160. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45161. var ctx = this.ctx;
  45162. var fillColor = this.current.fillColor;
  45163. var isPatternFill = this.current.patternFill;
  45164. for (var i = 0, ii = images.length; i < ii; i++) {
  45165. var image = images[i];
  45166. var width = image.width, height = image.height;
  45167. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45168. var maskCtx = maskCanvas.context;
  45169. maskCtx.save();
  45170. putBinaryImageMask(maskCtx, image);
  45171. maskCtx.globalCompositeOperation = 'source-in';
  45172. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45173. maskCtx.fillRect(0, 0, width, height);
  45174. maskCtx.restore();
  45175. ctx.save();
  45176. ctx.transform.apply(ctx, image.transform);
  45177. ctx.scale(1, -1);
  45178. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45179. ctx.restore();
  45180. }
  45181. },
  45182. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45183. var imgData = this.objs.get(objId);
  45184. if (!imgData) {
  45185. warn('Dependent image isn\'t ready yet');
  45186. return;
  45187. }
  45188. this.paintInlineImageXObject(imgData);
  45189. },
  45190. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45191. var imgData = this.objs.get(objId);
  45192. if (!imgData) {
  45193. warn('Dependent image isn\'t ready yet');
  45194. return;
  45195. }
  45196. var width = imgData.width;
  45197. var height = imgData.height;
  45198. var map = [];
  45199. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45200. map.push({
  45201. transform: [
  45202. scaleX,
  45203. 0,
  45204. 0,
  45205. scaleY,
  45206. positions[i],
  45207. positions[i + 1]
  45208. ],
  45209. x: 0,
  45210. y: 0,
  45211. w: width,
  45212. h: height
  45213. });
  45214. }
  45215. this.paintInlineImageXObjectGroup(imgData, map);
  45216. },
  45217. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45218. var width = imgData.width;
  45219. var height = imgData.height;
  45220. var ctx = this.ctx;
  45221. this.save();
  45222. ctx.scale(1 / width, -1 / height);
  45223. var currentTransform = ctx.mozCurrentTransformInverse;
  45224. var a = currentTransform[0], b = currentTransform[1];
  45225. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45226. var c = currentTransform[2], d = currentTransform[3];
  45227. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45228. var imgToPaint, tmpCanvas;
  45229. if (imgData instanceof HTMLElement || !imgData.data) {
  45230. imgToPaint = imgData;
  45231. } else {
  45232. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45233. var tmpCtx = tmpCanvas.context;
  45234. putBinaryImageData(tmpCtx, imgData);
  45235. imgToPaint = tmpCanvas.canvas;
  45236. }
  45237. var paintWidth = width, paintHeight = height;
  45238. var tmpCanvasId = 'prescale1';
  45239. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45240. var newWidth = paintWidth, newHeight = paintHeight;
  45241. if (widthScale > 2 && paintWidth > 1) {
  45242. newWidth = Math.ceil(paintWidth / 2);
  45243. widthScale /= paintWidth / newWidth;
  45244. }
  45245. if (heightScale > 2 && paintHeight > 1) {
  45246. newHeight = Math.ceil(paintHeight / 2);
  45247. heightScale /= paintHeight / newHeight;
  45248. }
  45249. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45250. tmpCtx = tmpCanvas.context;
  45251. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45252. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45253. imgToPaint = tmpCanvas.canvas;
  45254. paintWidth = newWidth;
  45255. paintHeight = newHeight;
  45256. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45257. }
  45258. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45259. if (this.imageLayer) {
  45260. var position = this.getCanvasPosition(0, -height);
  45261. this.imageLayer.appendImage({
  45262. imgData: imgData,
  45263. left: position[0],
  45264. top: position[1],
  45265. width: width / currentTransform[0],
  45266. height: height / currentTransform[3]
  45267. });
  45268. }
  45269. this.restore();
  45270. },
  45271. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45272. var ctx = this.ctx;
  45273. var w = imgData.width;
  45274. var h = imgData.height;
  45275. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45276. var tmpCtx = tmpCanvas.context;
  45277. putBinaryImageData(tmpCtx, imgData);
  45278. for (var i = 0, ii = map.length; i < ii; i++) {
  45279. var entry = map[i];
  45280. ctx.save();
  45281. ctx.transform.apply(ctx, entry.transform);
  45282. ctx.scale(1, -1);
  45283. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45284. if (this.imageLayer) {
  45285. var position = this.getCanvasPosition(entry.x, entry.y);
  45286. this.imageLayer.appendImage({
  45287. imgData: imgData,
  45288. left: position[0],
  45289. top: position[1],
  45290. width: w,
  45291. height: h
  45292. });
  45293. }
  45294. ctx.restore();
  45295. }
  45296. },
  45297. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45298. this.ctx.fillRect(0, 0, 1, 1);
  45299. },
  45300. paintXObject: function CanvasGraphics_paintXObject() {
  45301. warn('Unsupported \'paintXObject\' command.');
  45302. },
  45303. markPoint: function CanvasGraphics_markPoint(tag) {
  45304. },
  45305. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45306. },
  45307. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45308. },
  45309. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45310. },
  45311. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45312. },
  45313. beginCompat: function CanvasGraphics_beginCompat() {
  45314. },
  45315. endCompat: function CanvasGraphics_endCompat() {
  45316. },
  45317. consumePath: function CanvasGraphics_consumePath() {
  45318. var ctx = this.ctx;
  45319. if (this.pendingClip) {
  45320. if (this.pendingClip === EO_CLIP) {
  45321. if (ctx.mozFillRule !== undefined) {
  45322. ctx.mozFillRule = 'evenodd';
  45323. ctx.clip();
  45324. ctx.mozFillRule = 'nonzero';
  45325. } else {
  45326. ctx.clip('evenodd');
  45327. }
  45328. } else {
  45329. ctx.clip();
  45330. }
  45331. this.pendingClip = null;
  45332. }
  45333. ctx.beginPath();
  45334. },
  45335. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45336. if (this.cachedGetSinglePixelWidth === null) {
  45337. this.ctx.save();
  45338. var inverse = this.ctx.mozCurrentTransformInverse;
  45339. this.ctx.restore();
  45340. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45341. }
  45342. return this.cachedGetSinglePixelWidth;
  45343. },
  45344. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45345. var transform = this.ctx.mozCurrentTransform;
  45346. return [
  45347. transform[0] * x + transform[2] * y + transform[4],
  45348. transform[1] * x + transform[3] * y + transform[5]
  45349. ];
  45350. }
  45351. };
  45352. for (var op in OPS) {
  45353. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45354. }
  45355. return CanvasGraphics;
  45356. }();
  45357. exports.CanvasGraphics = CanvasGraphics;
  45358. exports.createScratchCanvas = createScratchCanvas;
  45359. }));
  45360. (function (root, factory) {
  45361. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45362. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45363. var error = sharedUtil.error;
  45364. var info = sharedUtil.info;
  45365. var isArray = sharedUtil.isArray;
  45366. var isBool = sharedUtil.isBool;
  45367. var isDict = corePrimitives.isDict;
  45368. var isStream = corePrimitives.isStream;
  45369. var PostScriptLexer = corePsParser.PostScriptLexer;
  45370. var PostScriptParser = corePsParser.PostScriptParser;
  45371. var PDFFunction = function PDFFunctionClosure() {
  45372. var CONSTRUCT_SAMPLED = 0;
  45373. var CONSTRUCT_INTERPOLATED = 2;
  45374. var CONSTRUCT_STICHED = 3;
  45375. var CONSTRUCT_POSTSCRIPT = 4;
  45376. return {
  45377. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45378. var i, ii;
  45379. var length = 1;
  45380. for (i = 0, ii = size.length; i < ii; i++) {
  45381. length *= size[i];
  45382. }
  45383. length *= outputSize;
  45384. var array = new Array(length);
  45385. var codeSize = 0;
  45386. var codeBuf = 0;
  45387. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45388. var strBytes = str.getBytes((length * bps + 7) / 8);
  45389. var strIdx = 0;
  45390. for (i = 0; i < length; i++) {
  45391. while (codeSize < bps) {
  45392. codeBuf <<= 8;
  45393. codeBuf |= strBytes[strIdx++];
  45394. codeSize += 8;
  45395. }
  45396. codeSize -= bps;
  45397. array[i] = (codeBuf >> codeSize) * sampleMul;
  45398. codeBuf &= (1 << codeSize) - 1;
  45399. }
  45400. return array;
  45401. },
  45402. getIR: function PDFFunction_getIR(xref, fn) {
  45403. var dict = fn.dict;
  45404. if (!dict) {
  45405. dict = fn;
  45406. }
  45407. var types = [
  45408. this.constructSampled,
  45409. null,
  45410. this.constructInterpolated,
  45411. this.constructStiched,
  45412. this.constructPostScript
  45413. ];
  45414. var typeNum = dict.get('FunctionType');
  45415. var typeFn = types[typeNum];
  45416. if (!typeFn) {
  45417. error('Unknown type of function');
  45418. }
  45419. return typeFn.call(this, fn, dict, xref);
  45420. },
  45421. fromIR: function PDFFunction_fromIR(IR) {
  45422. var type = IR[0];
  45423. switch (type) {
  45424. case CONSTRUCT_SAMPLED:
  45425. return this.constructSampledFromIR(IR);
  45426. case CONSTRUCT_INTERPOLATED:
  45427. return this.constructInterpolatedFromIR(IR);
  45428. case CONSTRUCT_STICHED:
  45429. return this.constructStichedFromIR(IR);
  45430. default:
  45431. return this.constructPostScriptFromIR(IR);
  45432. }
  45433. },
  45434. parse: function PDFFunction_parse(xref, fn) {
  45435. var IR = this.getIR(xref, fn);
  45436. return this.fromIR(IR);
  45437. },
  45438. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45439. if (!isArray(fnObj)) {
  45440. return this.parse(xref, fnObj);
  45441. }
  45442. var fnArray = [];
  45443. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45444. var obj = xref.fetchIfRef(fnObj[j]);
  45445. fnArray.push(PDFFunction.parse(xref, obj));
  45446. }
  45447. return function (src, srcOffset, dest, destOffset) {
  45448. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45449. fnArray[i](src, srcOffset, dest, destOffset + i);
  45450. }
  45451. };
  45452. },
  45453. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45454. function toMultiArray(arr) {
  45455. var inputLength = arr.length;
  45456. var out = [];
  45457. var index = 0;
  45458. for (var i = 0; i < inputLength; i += 2) {
  45459. out[index] = [
  45460. arr[i],
  45461. arr[i + 1]
  45462. ];
  45463. ++index;
  45464. }
  45465. return out;
  45466. }
  45467. var domain = dict.getArray('Domain');
  45468. var range = dict.getArray('Range');
  45469. if (!domain || !range) {
  45470. error('No domain or range');
  45471. }
  45472. var inputSize = domain.length / 2;
  45473. var outputSize = range.length / 2;
  45474. domain = toMultiArray(domain);
  45475. range = toMultiArray(range);
  45476. var size = dict.get('Size');
  45477. var bps = dict.get('BitsPerSample');
  45478. var order = dict.get('Order') || 1;
  45479. if (order !== 1) {
  45480. info('No support for cubic spline interpolation: ' + order);
  45481. }
  45482. var encode = dict.getArray('Encode');
  45483. if (!encode) {
  45484. encode = [];
  45485. for (var i = 0; i < inputSize; ++i) {
  45486. encode.push(0);
  45487. encode.push(size[i] - 1);
  45488. }
  45489. }
  45490. encode = toMultiArray(encode);
  45491. var decode = dict.getArray('Decode');
  45492. if (!decode) {
  45493. decode = range;
  45494. } else {
  45495. decode = toMultiArray(decode);
  45496. }
  45497. var samples = this.getSampleArray(size, outputSize, bps, str);
  45498. return [
  45499. CONSTRUCT_SAMPLED,
  45500. inputSize,
  45501. domain,
  45502. encode,
  45503. decode,
  45504. samples,
  45505. size,
  45506. outputSize,
  45507. Math.pow(2, bps) - 1,
  45508. range
  45509. ];
  45510. },
  45511. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45512. function interpolate(x, xmin, xmax, ymin, ymax) {
  45513. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45514. }
  45515. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45516. var m = IR[1];
  45517. var domain = IR[2];
  45518. var encode = IR[3];
  45519. var decode = IR[4];
  45520. var samples = IR[5];
  45521. var size = IR[6];
  45522. var n = IR[7];
  45523. var range = IR[9];
  45524. var cubeVertices = 1 << m;
  45525. var cubeN = new Float64Array(cubeVertices);
  45526. var cubeVertex = new Uint32Array(cubeVertices);
  45527. var i, j;
  45528. for (j = 0; j < cubeVertices; j++) {
  45529. cubeN[j] = 1;
  45530. }
  45531. var k = n, pos = 1;
  45532. for (i = 0; i < m; ++i) {
  45533. var domain_2i = domain[i][0];
  45534. var domain_2i_1 = domain[i][1];
  45535. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45536. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45537. var size_i = size[i];
  45538. e = Math.min(Math.max(e, 0), size_i - 1);
  45539. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45540. var n0 = e0 + 1 - e;
  45541. var n1 = e - e0;
  45542. var offset0 = e0 * k;
  45543. var offset1 = offset0 + k;
  45544. for (j = 0; j < cubeVertices; j++) {
  45545. if (j & pos) {
  45546. cubeN[j] *= n1;
  45547. cubeVertex[j] += offset1;
  45548. } else {
  45549. cubeN[j] *= n0;
  45550. cubeVertex[j] += offset0;
  45551. }
  45552. }
  45553. k *= size_i;
  45554. pos <<= 1;
  45555. }
  45556. for (j = 0; j < n; ++j) {
  45557. var rj = 0;
  45558. for (i = 0; i < cubeVertices; i++) {
  45559. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45560. }
  45561. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45562. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45563. }
  45564. };
  45565. },
  45566. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45567. var c0 = dict.getArray('C0') || [0];
  45568. var c1 = dict.getArray('C1') || [1];
  45569. var n = dict.get('N');
  45570. if (!isArray(c0) || !isArray(c1)) {
  45571. error('Illegal dictionary for interpolated function');
  45572. }
  45573. var length = c0.length;
  45574. var diff = [];
  45575. for (var i = 0; i < length; ++i) {
  45576. diff.push(c1[i] - c0[i]);
  45577. }
  45578. return [
  45579. CONSTRUCT_INTERPOLATED,
  45580. c0,
  45581. diff,
  45582. n
  45583. ];
  45584. },
  45585. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45586. var c0 = IR[1];
  45587. var diff = IR[2];
  45588. var n = IR[3];
  45589. var length = diff.length;
  45590. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45591. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45592. for (var j = 0; j < length; ++j) {
  45593. dest[destOffset + j] = c0[j] + x * diff[j];
  45594. }
  45595. };
  45596. },
  45597. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45598. var domain = dict.getArray('Domain');
  45599. if (!domain) {
  45600. error('No domain');
  45601. }
  45602. var inputSize = domain.length / 2;
  45603. if (inputSize !== 1) {
  45604. error('Bad domain for stiched function');
  45605. }
  45606. var fnRefs = dict.get('Functions');
  45607. var fns = [];
  45608. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45609. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45610. }
  45611. var bounds = dict.getArray('Bounds');
  45612. var encode = dict.getArray('Encode');
  45613. return [
  45614. CONSTRUCT_STICHED,
  45615. domain,
  45616. bounds,
  45617. encode,
  45618. fns
  45619. ];
  45620. },
  45621. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45622. var domain = IR[1];
  45623. var bounds = IR[2];
  45624. var encode = IR[3];
  45625. var fnsIR = IR[4];
  45626. var fns = [];
  45627. var tmpBuf = new Float32Array(1);
  45628. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45629. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45630. }
  45631. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45632. var clip = function constructStichedFromIRClip(v, min, max) {
  45633. if (v > max) {
  45634. v = max;
  45635. } else if (v < min) {
  45636. v = min;
  45637. }
  45638. return v;
  45639. };
  45640. var v = clip(src[srcOffset], domain[0], domain[1]);
  45641. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45642. if (v < bounds[i]) {
  45643. break;
  45644. }
  45645. }
  45646. var dmin = domain[0];
  45647. if (i > 0) {
  45648. dmin = bounds[i - 1];
  45649. }
  45650. var dmax = domain[1];
  45651. if (i < bounds.length) {
  45652. dmax = bounds[i];
  45653. }
  45654. var rmin = encode[2 * i];
  45655. var rmax = encode[2 * i + 1];
  45656. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45657. fns[i](tmpBuf, 0, dest, destOffset);
  45658. };
  45659. },
  45660. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45661. var domain = dict.getArray('Domain');
  45662. var range = dict.getArray('Range');
  45663. if (!domain) {
  45664. error('No domain.');
  45665. }
  45666. if (!range) {
  45667. error('No range.');
  45668. }
  45669. var lexer = new PostScriptLexer(fn);
  45670. var parser = new PostScriptParser(lexer);
  45671. var code = parser.parse();
  45672. return [
  45673. CONSTRUCT_POSTSCRIPT,
  45674. domain,
  45675. range,
  45676. code
  45677. ];
  45678. },
  45679. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45680. var domain = IR[1];
  45681. var range = IR[2];
  45682. var code = IR[3];
  45683. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45684. if (compiled) {
  45685. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45686. }
  45687. info('Unable to compile PS function');
  45688. var numOutputs = range.length >> 1;
  45689. var numInputs = domain.length >> 1;
  45690. var evaluator = new PostScriptEvaluator(code);
  45691. var cache = Object.create(null);
  45692. var MAX_CACHE_SIZE = 2048 * 4;
  45693. var cache_available = MAX_CACHE_SIZE;
  45694. var tmpBuf = new Float32Array(numInputs);
  45695. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45696. var i, value;
  45697. var key = '';
  45698. var input = tmpBuf;
  45699. for (i = 0; i < numInputs; i++) {
  45700. value = src[srcOffset + i];
  45701. input[i] = value;
  45702. key += value + '_';
  45703. }
  45704. var cachedValue = cache[key];
  45705. if (cachedValue !== undefined) {
  45706. dest.set(cachedValue, destOffset);
  45707. return;
  45708. }
  45709. var output = new Float32Array(numOutputs);
  45710. var stack = evaluator.execute(input);
  45711. var stackIndex = stack.length - numOutputs;
  45712. for (i = 0; i < numOutputs; i++) {
  45713. value = stack[stackIndex + i];
  45714. var bound = range[i * 2];
  45715. if (value < bound) {
  45716. value = bound;
  45717. } else {
  45718. bound = range[i * 2 + 1];
  45719. if (value > bound) {
  45720. value = bound;
  45721. }
  45722. }
  45723. output[i] = value;
  45724. }
  45725. if (cache_available > 0) {
  45726. cache_available--;
  45727. cache[key] = output;
  45728. }
  45729. dest.set(output, destOffset);
  45730. };
  45731. }
  45732. };
  45733. }();
  45734. function isPDFFunction(v) {
  45735. var fnDict;
  45736. if (typeof v !== 'object') {
  45737. return false;
  45738. } else if (isDict(v)) {
  45739. fnDict = v;
  45740. } else if (isStream(v)) {
  45741. fnDict = v.dict;
  45742. } else {
  45743. return false;
  45744. }
  45745. return fnDict.has('FunctionType');
  45746. }
  45747. var PostScriptStack = function PostScriptStackClosure() {
  45748. var MAX_STACK_SIZE = 100;
  45749. function PostScriptStack(initialStack) {
  45750. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45751. }
  45752. PostScriptStack.prototype = {
  45753. push: function PostScriptStack_push(value) {
  45754. if (this.stack.length >= MAX_STACK_SIZE) {
  45755. error('PostScript function stack overflow.');
  45756. }
  45757. this.stack.push(value);
  45758. },
  45759. pop: function PostScriptStack_pop() {
  45760. if (this.stack.length <= 0) {
  45761. error('PostScript function stack underflow.');
  45762. }
  45763. return this.stack.pop();
  45764. },
  45765. copy: function PostScriptStack_copy(n) {
  45766. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45767. error('PostScript function stack overflow.');
  45768. }
  45769. var stack = this.stack;
  45770. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45771. stack.push(stack[i]);
  45772. }
  45773. },
  45774. index: function PostScriptStack_index(n) {
  45775. this.push(this.stack[this.stack.length - n - 1]);
  45776. },
  45777. roll: function PostScriptStack_roll(n, p) {
  45778. var stack = this.stack;
  45779. var l = stack.length - n;
  45780. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45781. for (i = l, j = r; i < j; i++, j--) {
  45782. t = stack[i];
  45783. stack[i] = stack[j];
  45784. stack[j] = t;
  45785. }
  45786. for (i = l, j = c - 1; i < j; i++, j--) {
  45787. t = stack[i];
  45788. stack[i] = stack[j];
  45789. stack[j] = t;
  45790. }
  45791. for (i = c, j = r; i < j; i++, j--) {
  45792. t = stack[i];
  45793. stack[i] = stack[j];
  45794. stack[j] = t;
  45795. }
  45796. }
  45797. };
  45798. return PostScriptStack;
  45799. }();
  45800. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45801. function PostScriptEvaluator(operators) {
  45802. this.operators = operators;
  45803. }
  45804. PostScriptEvaluator.prototype = {
  45805. execute: function PostScriptEvaluator_execute(initialStack) {
  45806. var stack = new PostScriptStack(initialStack);
  45807. var counter = 0;
  45808. var operators = this.operators;
  45809. var length = operators.length;
  45810. var operator, a, b;
  45811. while (counter < length) {
  45812. operator = operators[counter++];
  45813. if (typeof operator === 'number') {
  45814. stack.push(operator);
  45815. continue;
  45816. }
  45817. switch (operator) {
  45818. case 'jz':
  45819. b = stack.pop();
  45820. a = stack.pop();
  45821. if (!a) {
  45822. counter = b;
  45823. }
  45824. break;
  45825. case 'j':
  45826. a = stack.pop();
  45827. counter = a;
  45828. break;
  45829. case 'abs':
  45830. a = stack.pop();
  45831. stack.push(Math.abs(a));
  45832. break;
  45833. case 'add':
  45834. b = stack.pop();
  45835. a = stack.pop();
  45836. stack.push(a + b);
  45837. break;
  45838. case 'and':
  45839. b = stack.pop();
  45840. a = stack.pop();
  45841. if (isBool(a) && isBool(b)) {
  45842. stack.push(a && b);
  45843. } else {
  45844. stack.push(a & b);
  45845. }
  45846. break;
  45847. case 'atan':
  45848. a = stack.pop();
  45849. stack.push(Math.atan(a));
  45850. break;
  45851. case 'bitshift':
  45852. b = stack.pop();
  45853. a = stack.pop();
  45854. if (a > 0) {
  45855. stack.push(a << b);
  45856. } else {
  45857. stack.push(a >> b);
  45858. }
  45859. break;
  45860. case 'ceiling':
  45861. a = stack.pop();
  45862. stack.push(Math.ceil(a));
  45863. break;
  45864. case 'copy':
  45865. a = stack.pop();
  45866. stack.copy(a);
  45867. break;
  45868. case 'cos':
  45869. a = stack.pop();
  45870. stack.push(Math.cos(a));
  45871. break;
  45872. case 'cvi':
  45873. a = stack.pop() | 0;
  45874. stack.push(a);
  45875. break;
  45876. case 'cvr':
  45877. break;
  45878. case 'div':
  45879. b = stack.pop();
  45880. a = stack.pop();
  45881. stack.push(a / b);
  45882. break;
  45883. case 'dup':
  45884. stack.copy(1);
  45885. break;
  45886. case 'eq':
  45887. b = stack.pop();
  45888. a = stack.pop();
  45889. stack.push(a === b);
  45890. break;
  45891. case 'exch':
  45892. stack.roll(2, 1);
  45893. break;
  45894. case 'exp':
  45895. b = stack.pop();
  45896. a = stack.pop();
  45897. stack.push(Math.pow(a, b));
  45898. break;
  45899. case 'false':
  45900. stack.push(false);
  45901. break;
  45902. case 'floor':
  45903. a = stack.pop();
  45904. stack.push(Math.floor(a));
  45905. break;
  45906. case 'ge':
  45907. b = stack.pop();
  45908. a = stack.pop();
  45909. stack.push(a >= b);
  45910. break;
  45911. case 'gt':
  45912. b = stack.pop();
  45913. a = stack.pop();
  45914. stack.push(a > b);
  45915. break;
  45916. case 'idiv':
  45917. b = stack.pop();
  45918. a = stack.pop();
  45919. stack.push(a / b | 0);
  45920. break;
  45921. case 'index':
  45922. a = stack.pop();
  45923. stack.index(a);
  45924. break;
  45925. case 'le':
  45926. b = stack.pop();
  45927. a = stack.pop();
  45928. stack.push(a <= b);
  45929. break;
  45930. case 'ln':
  45931. a = stack.pop();
  45932. stack.push(Math.log(a));
  45933. break;
  45934. case 'log':
  45935. a = stack.pop();
  45936. stack.push(Math.log(a) / Math.LN10);
  45937. break;
  45938. case 'lt':
  45939. b = stack.pop();
  45940. a = stack.pop();
  45941. stack.push(a < b);
  45942. break;
  45943. case 'mod':
  45944. b = stack.pop();
  45945. a = stack.pop();
  45946. stack.push(a % b);
  45947. break;
  45948. case 'mul':
  45949. b = stack.pop();
  45950. a = stack.pop();
  45951. stack.push(a * b);
  45952. break;
  45953. case 'ne':
  45954. b = stack.pop();
  45955. a = stack.pop();
  45956. stack.push(a !== b);
  45957. break;
  45958. case 'neg':
  45959. a = stack.pop();
  45960. stack.push(-a);
  45961. break;
  45962. case 'not':
  45963. a = stack.pop();
  45964. if (isBool(a)) {
  45965. stack.push(!a);
  45966. } else {
  45967. stack.push(~a);
  45968. }
  45969. break;
  45970. case 'or':
  45971. b = stack.pop();
  45972. a = stack.pop();
  45973. if (isBool(a) && isBool(b)) {
  45974. stack.push(a || b);
  45975. } else {
  45976. stack.push(a | b);
  45977. }
  45978. break;
  45979. case 'pop':
  45980. stack.pop();
  45981. break;
  45982. case 'roll':
  45983. b = stack.pop();
  45984. a = stack.pop();
  45985. stack.roll(a, b);
  45986. break;
  45987. case 'round':
  45988. a = stack.pop();
  45989. stack.push(Math.round(a));
  45990. break;
  45991. case 'sin':
  45992. a = stack.pop();
  45993. stack.push(Math.sin(a));
  45994. break;
  45995. case 'sqrt':
  45996. a = stack.pop();
  45997. stack.push(Math.sqrt(a));
  45998. break;
  45999. case 'sub':
  46000. b = stack.pop();
  46001. a = stack.pop();
  46002. stack.push(a - b);
  46003. break;
  46004. case 'true':
  46005. stack.push(true);
  46006. break;
  46007. case 'truncate':
  46008. a = stack.pop();
  46009. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46010. stack.push(a);
  46011. break;
  46012. case 'xor':
  46013. b = stack.pop();
  46014. a = stack.pop();
  46015. if (isBool(a) && isBool(b)) {
  46016. stack.push(a !== b);
  46017. } else {
  46018. stack.push(a ^ b);
  46019. }
  46020. break;
  46021. default:
  46022. error('Unknown operator ' + operator);
  46023. break;
  46024. }
  46025. }
  46026. return stack.stack;
  46027. }
  46028. };
  46029. return PostScriptEvaluator;
  46030. }();
  46031. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46032. function AstNode(type) {
  46033. this.type = type;
  46034. }
  46035. AstNode.prototype.visit = function (visitor) {
  46036. throw new Error('abstract method');
  46037. };
  46038. function AstArgument(index, min, max) {
  46039. AstNode.call(this, 'args');
  46040. this.index = index;
  46041. this.min = min;
  46042. this.max = max;
  46043. }
  46044. AstArgument.prototype = Object.create(AstNode.prototype);
  46045. AstArgument.prototype.visit = function (visitor) {
  46046. visitor.visitArgument(this);
  46047. };
  46048. function AstLiteral(number) {
  46049. AstNode.call(this, 'literal');
  46050. this.number = number;
  46051. this.min = number;
  46052. this.max = number;
  46053. }
  46054. AstLiteral.prototype = Object.create(AstNode.prototype);
  46055. AstLiteral.prototype.visit = function (visitor) {
  46056. visitor.visitLiteral(this);
  46057. };
  46058. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46059. AstNode.call(this, 'binary');
  46060. this.op = op;
  46061. this.arg1 = arg1;
  46062. this.arg2 = arg2;
  46063. this.min = min;
  46064. this.max = max;
  46065. }
  46066. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46067. AstBinaryOperation.prototype.visit = function (visitor) {
  46068. visitor.visitBinaryOperation(this);
  46069. };
  46070. function AstMin(arg, max) {
  46071. AstNode.call(this, 'max');
  46072. this.arg = arg;
  46073. this.min = arg.min;
  46074. this.max = max;
  46075. }
  46076. AstMin.prototype = Object.create(AstNode.prototype);
  46077. AstMin.prototype.visit = function (visitor) {
  46078. visitor.visitMin(this);
  46079. };
  46080. function AstVariable(index, min, max) {
  46081. AstNode.call(this, 'var');
  46082. this.index = index;
  46083. this.min = min;
  46084. this.max = max;
  46085. }
  46086. AstVariable.prototype = Object.create(AstNode.prototype);
  46087. AstVariable.prototype.visit = function (visitor) {
  46088. visitor.visitVariable(this);
  46089. };
  46090. function AstVariableDefinition(variable, arg) {
  46091. AstNode.call(this, 'definition');
  46092. this.variable = variable;
  46093. this.arg = arg;
  46094. }
  46095. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46096. AstVariableDefinition.prototype.visit = function (visitor) {
  46097. visitor.visitVariableDefinition(this);
  46098. };
  46099. function ExpressionBuilderVisitor() {
  46100. this.parts = [];
  46101. }
  46102. ExpressionBuilderVisitor.prototype = {
  46103. visitArgument: function (arg) {
  46104. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46105. },
  46106. visitVariable: function (variable) {
  46107. this.parts.push('v', variable.index);
  46108. },
  46109. visitLiteral: function (literal) {
  46110. this.parts.push(literal.number);
  46111. },
  46112. visitBinaryOperation: function (operation) {
  46113. this.parts.push('(');
  46114. operation.arg1.visit(this);
  46115. this.parts.push(' ', operation.op, ' ');
  46116. operation.arg2.visit(this);
  46117. this.parts.push(')');
  46118. },
  46119. visitVariableDefinition: function (definition) {
  46120. this.parts.push('var ');
  46121. definition.variable.visit(this);
  46122. this.parts.push(' = ');
  46123. definition.arg.visit(this);
  46124. this.parts.push(';');
  46125. },
  46126. visitMin: function (max) {
  46127. this.parts.push('Math.min(');
  46128. max.arg.visit(this);
  46129. this.parts.push(', ', max.max, ')');
  46130. },
  46131. toString: function () {
  46132. return this.parts.join('');
  46133. }
  46134. };
  46135. function buildAddOperation(num1, num2) {
  46136. if (num2.type === 'literal' && num2.number === 0) {
  46137. return num1;
  46138. }
  46139. if (num1.type === 'literal' && num1.number === 0) {
  46140. return num2;
  46141. }
  46142. if (num2.type === 'literal' && num1.type === 'literal') {
  46143. return new AstLiteral(num1.number + num2.number);
  46144. }
  46145. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46146. }
  46147. function buildMulOperation(num1, num2) {
  46148. if (num2.type === 'literal') {
  46149. if (num2.number === 0) {
  46150. return new AstLiteral(0);
  46151. } else if (num2.number === 1) {
  46152. return num1;
  46153. } else if (num1.type === 'literal') {
  46154. return new AstLiteral(num1.number * num2.number);
  46155. }
  46156. }
  46157. if (num1.type === 'literal') {
  46158. if (num1.number === 0) {
  46159. return new AstLiteral(0);
  46160. } else if (num1.number === 1) {
  46161. return num2;
  46162. }
  46163. }
  46164. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46165. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46166. return new AstBinaryOperation('*', num1, num2, min, max);
  46167. }
  46168. function buildSubOperation(num1, num2) {
  46169. if (num2.type === 'literal') {
  46170. if (num2.number === 0) {
  46171. return num1;
  46172. } else if (num1.type === 'literal') {
  46173. return new AstLiteral(num1.number - num2.number);
  46174. }
  46175. }
  46176. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46177. return num2.arg2;
  46178. }
  46179. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46180. }
  46181. function buildMinOperation(num1, max) {
  46182. if (num1.min >= max) {
  46183. return new AstLiteral(max);
  46184. } else if (num1.max <= max) {
  46185. return num1;
  46186. }
  46187. return new AstMin(num1, max);
  46188. }
  46189. function PostScriptCompiler() {
  46190. }
  46191. PostScriptCompiler.prototype = {
  46192. compile: function PostScriptCompiler_compile(code, domain, range) {
  46193. var stack = [];
  46194. var i, ii;
  46195. var instructions = [];
  46196. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46197. var lastRegister = 0;
  46198. var n, j;
  46199. var num1, num2, ast1, ast2, tmpVar, item;
  46200. for (i = 0; i < inputSize; i++) {
  46201. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46202. }
  46203. for (i = 0, ii = code.length; i < ii; i++) {
  46204. item = code[i];
  46205. if (typeof item === 'number') {
  46206. stack.push(new AstLiteral(item));
  46207. continue;
  46208. }
  46209. switch (item) {
  46210. case 'add':
  46211. if (stack.length < 2) {
  46212. return null;
  46213. }
  46214. num2 = stack.pop();
  46215. num1 = stack.pop();
  46216. stack.push(buildAddOperation(num1, num2));
  46217. break;
  46218. case 'cvr':
  46219. if (stack.length < 1) {
  46220. return null;
  46221. }
  46222. break;
  46223. case 'mul':
  46224. if (stack.length < 2) {
  46225. return null;
  46226. }
  46227. num2 = stack.pop();
  46228. num1 = stack.pop();
  46229. stack.push(buildMulOperation(num1, num2));
  46230. break;
  46231. case 'sub':
  46232. if (stack.length < 2) {
  46233. return null;
  46234. }
  46235. num2 = stack.pop();
  46236. num1 = stack.pop();
  46237. stack.push(buildSubOperation(num1, num2));
  46238. break;
  46239. case 'exch':
  46240. if (stack.length < 2) {
  46241. return null;
  46242. }
  46243. ast1 = stack.pop();
  46244. ast2 = stack.pop();
  46245. stack.push(ast1, ast2);
  46246. break;
  46247. case 'pop':
  46248. if (stack.length < 1) {
  46249. return null;
  46250. }
  46251. stack.pop();
  46252. break;
  46253. case 'index':
  46254. if (stack.length < 1) {
  46255. return null;
  46256. }
  46257. num1 = stack.pop();
  46258. if (num1.type !== 'literal') {
  46259. return null;
  46260. }
  46261. n = num1.number;
  46262. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46263. return null;
  46264. }
  46265. ast1 = stack[stack.length - n - 1];
  46266. if (ast1.type === 'literal' || ast1.type === 'var') {
  46267. stack.push(ast1);
  46268. break;
  46269. }
  46270. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46271. stack[stack.length - n - 1] = tmpVar;
  46272. stack.push(tmpVar);
  46273. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46274. break;
  46275. case 'dup':
  46276. if (stack.length < 1) {
  46277. return null;
  46278. }
  46279. 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]) {
  46280. num1 = stack.pop();
  46281. stack.push(buildMinOperation(num1, code[i + 1]));
  46282. i += 6;
  46283. break;
  46284. }
  46285. ast1 = stack[stack.length - 1];
  46286. if (ast1.type === 'literal' || ast1.type === 'var') {
  46287. stack.push(ast1);
  46288. break;
  46289. }
  46290. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46291. stack[stack.length - 1] = tmpVar;
  46292. stack.push(tmpVar);
  46293. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46294. break;
  46295. case 'roll':
  46296. if (stack.length < 2) {
  46297. return null;
  46298. }
  46299. num2 = stack.pop();
  46300. num1 = stack.pop();
  46301. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46302. return null;
  46303. }
  46304. j = num2.number;
  46305. n = num1.number;
  46306. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46307. return null;
  46308. }
  46309. j = (j % n + n) % n;
  46310. if (j === 0) {
  46311. break;
  46312. }
  46313. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46314. break;
  46315. default:
  46316. return null;
  46317. }
  46318. }
  46319. if (stack.length !== outputSize) {
  46320. return null;
  46321. }
  46322. var result = [];
  46323. instructions.forEach(function (instruction) {
  46324. var statementBuilder = new ExpressionBuilderVisitor();
  46325. instruction.visit(statementBuilder);
  46326. result.push(statementBuilder.toString());
  46327. });
  46328. stack.forEach(function (expr, i) {
  46329. var statementBuilder = new ExpressionBuilderVisitor();
  46330. expr.visit(statementBuilder);
  46331. var min = range[i * 2], max = range[i * 2 + 1];
  46332. var out = [statementBuilder.toString()];
  46333. if (min > expr.min) {
  46334. out.unshift('Math.max(', min, ', ');
  46335. out.push(')');
  46336. }
  46337. if (max < expr.max) {
  46338. out.unshift('Math.min(', max, ', ');
  46339. out.push(')');
  46340. }
  46341. out.unshift('dest[destOffset + ', i, '] = ');
  46342. out.push(';');
  46343. result.push(out.join(''));
  46344. });
  46345. return result.join('\n');
  46346. }
  46347. };
  46348. return PostScriptCompiler;
  46349. }();
  46350. exports.isPDFFunction = isPDFFunction;
  46351. exports.PDFFunction = PDFFunction;
  46352. exports.PostScriptEvaluator = PostScriptEvaluator;
  46353. exports.PostScriptCompiler = PostScriptCompiler;
  46354. }));
  46355. (function (root, factory) {
  46356. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46357. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46358. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46359. var MessageHandler = sharedUtil.MessageHandler;
  46360. var MissingPDFException = sharedUtil.MissingPDFException;
  46361. var PageViewport = sharedUtil.PageViewport;
  46362. var PasswordResponses = sharedUtil.PasswordResponses;
  46363. var PasswordException = sharedUtil.PasswordException;
  46364. var StatTimer = sharedUtil.StatTimer;
  46365. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46366. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46367. var Util = sharedUtil.Util;
  46368. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46369. var error = sharedUtil.error;
  46370. var deprecated = sharedUtil.deprecated;
  46371. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46372. var info = sharedUtil.info;
  46373. var isInt = sharedUtil.isInt;
  46374. var isArray = sharedUtil.isArray;
  46375. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46376. var isSameOrigin = sharedUtil.isSameOrigin;
  46377. var loadJpegStream = sharedUtil.loadJpegStream;
  46378. var stringToBytes = sharedUtil.stringToBytes;
  46379. var globalScope = sharedUtil.globalScope;
  46380. var warn = sharedUtil.warn;
  46381. var FontFaceObject = displayFontLoader.FontFaceObject;
  46382. var FontLoader = displayFontLoader.FontLoader;
  46383. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46384. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46385. var Metadata = displayMetadata.Metadata;
  46386. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46387. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46388. var isWorkerDisabled = false;
  46389. var workerSrc;
  46390. var isPostMessageTransfersDisabled = false;
  46391. var fakeWorkerFilesLoader = null;
  46392. var useRequireEnsure = false;
  46393. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46394. var task = new PDFDocumentLoadingTask();
  46395. if (arguments.length > 1) {
  46396. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46397. }
  46398. if (pdfDataRangeTransport) {
  46399. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46400. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46401. pdfDataRangeTransport.length = src.length;
  46402. pdfDataRangeTransport.initialData = src.initialData;
  46403. if (!pdfDataRangeTransport.abort) {
  46404. pdfDataRangeTransport.abort = function () {
  46405. };
  46406. }
  46407. }
  46408. src = Object.create(src);
  46409. src.range = pdfDataRangeTransport;
  46410. }
  46411. task.onPassword = passwordCallback || null;
  46412. task.onProgress = progressCallback || null;
  46413. var source;
  46414. if (typeof src === 'string') {
  46415. source = { url: src };
  46416. } else if (isArrayBuffer(src)) {
  46417. source = { data: src };
  46418. } else if (src instanceof PDFDataRangeTransport) {
  46419. source = { range: src };
  46420. } else {
  46421. if (typeof src !== 'object') {
  46422. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46423. }
  46424. if (!src.url && !src.data && !src.range) {
  46425. error('Invalid parameter object: need either .data, .range or .url');
  46426. }
  46427. source = src;
  46428. }
  46429. var params = {};
  46430. var rangeTransport = null;
  46431. var worker = null;
  46432. for (var key in source) {
  46433. if (key === 'url' && typeof window !== 'undefined') {
  46434. params[key] = new URL(source[key], window.location).href;
  46435. continue;
  46436. } else if (key === 'range') {
  46437. rangeTransport = source[key];
  46438. continue;
  46439. } else if (key === 'worker') {
  46440. worker = source[key];
  46441. continue;
  46442. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46443. var pdfBytes = source[key];
  46444. if (typeof pdfBytes === 'string') {
  46445. params[key] = stringToBytes(pdfBytes);
  46446. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46447. params[key] = new Uint8Array(pdfBytes);
  46448. } else if (isArrayBuffer(pdfBytes)) {
  46449. params[key] = new Uint8Array(pdfBytes);
  46450. } else {
  46451. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46452. }
  46453. continue;
  46454. }
  46455. params[key] = source[key];
  46456. }
  46457. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46458. if (!worker) {
  46459. worker = new PDFWorker();
  46460. task._worker = worker;
  46461. }
  46462. var docId = task.docId;
  46463. worker.promise.then(function () {
  46464. if (task.destroyed) {
  46465. throw new Error('Loading aborted');
  46466. }
  46467. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46468. if (task.destroyed) {
  46469. throw new Error('Loading aborted');
  46470. }
  46471. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46472. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46473. task._transport = transport;
  46474. messageHandler.send('Ready', null);
  46475. });
  46476. }).catch(task._capability.reject);
  46477. return task;
  46478. }
  46479. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46480. if (worker.destroyed) {
  46481. return Promise.reject(new Error('Worker was destroyed'));
  46482. }
  46483. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46484. source.disableStream = getDefaultSetting('disableStream');
  46485. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46486. if (pdfDataRangeTransport) {
  46487. source.length = pdfDataRangeTransport.length;
  46488. source.initialData = pdfDataRangeTransport.initialData;
  46489. }
  46490. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46491. docId: docId,
  46492. source: source,
  46493. disableRange: getDefaultSetting('disableRange'),
  46494. maxImageSize: getDefaultSetting('maxImageSize'),
  46495. cMapUrl: getDefaultSetting('cMapUrl'),
  46496. cMapPacked: getDefaultSetting('cMapPacked'),
  46497. disableFontFace: getDefaultSetting('disableFontFace'),
  46498. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46499. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46500. docBaseUrl: source.docBaseUrl
  46501. }).then(function (workerId) {
  46502. if (worker.destroyed) {
  46503. throw new Error('Worker was destroyed');
  46504. }
  46505. return workerId;
  46506. });
  46507. }
  46508. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46509. var nextDocumentId = 0;
  46510. function PDFDocumentLoadingTask() {
  46511. this._capability = createPromiseCapability();
  46512. this._transport = null;
  46513. this._worker = null;
  46514. this.docId = 'd' + nextDocumentId++;
  46515. this.destroyed = false;
  46516. this.onPassword = null;
  46517. this.onProgress = null;
  46518. this.onUnsupportedFeature = null;
  46519. }
  46520. PDFDocumentLoadingTask.prototype = {
  46521. get promise() {
  46522. return this._capability.promise;
  46523. },
  46524. destroy: function () {
  46525. this.destroyed = true;
  46526. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46527. return transportDestroyed.then(function () {
  46528. this._transport = null;
  46529. if (this._worker) {
  46530. this._worker.destroy();
  46531. this._worker = null;
  46532. }
  46533. }.bind(this));
  46534. },
  46535. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46536. return this.promise.then.apply(this.promise, arguments);
  46537. }
  46538. };
  46539. return PDFDocumentLoadingTask;
  46540. }();
  46541. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46542. function PDFDataRangeTransport(length, initialData) {
  46543. this.length = length;
  46544. this.initialData = initialData;
  46545. this._rangeListeners = [];
  46546. this._progressListeners = [];
  46547. this._progressiveReadListeners = [];
  46548. this._readyCapability = createPromiseCapability();
  46549. }
  46550. PDFDataRangeTransport.prototype = {
  46551. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46552. this._rangeListeners.push(listener);
  46553. },
  46554. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46555. this._progressListeners.push(listener);
  46556. },
  46557. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46558. this._progressiveReadListeners.push(listener);
  46559. },
  46560. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46561. var listeners = this._rangeListeners;
  46562. for (var i = 0, n = listeners.length; i < n; ++i) {
  46563. listeners[i](begin, chunk);
  46564. }
  46565. },
  46566. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46567. this._readyCapability.promise.then(function () {
  46568. var listeners = this._progressListeners;
  46569. for (var i = 0, n = listeners.length; i < n; ++i) {
  46570. listeners[i](loaded);
  46571. }
  46572. }.bind(this));
  46573. },
  46574. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46575. this._readyCapability.promise.then(function () {
  46576. var listeners = this._progressiveReadListeners;
  46577. for (var i = 0, n = listeners.length; i < n; ++i) {
  46578. listeners[i](chunk);
  46579. }
  46580. }.bind(this));
  46581. },
  46582. transportReady: function PDFDataRangeTransport_transportReady() {
  46583. this._readyCapability.resolve();
  46584. },
  46585. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46586. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46587. },
  46588. abort: function PDFDataRangeTransport_abort() {
  46589. }
  46590. };
  46591. return PDFDataRangeTransport;
  46592. }();
  46593. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46594. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46595. this.pdfInfo = pdfInfo;
  46596. this.transport = transport;
  46597. this.loadingTask = loadingTask;
  46598. }
  46599. PDFDocumentProxy.prototype = {
  46600. get numPages() {
  46601. return this.pdfInfo.numPages;
  46602. },
  46603. get fingerprint() {
  46604. return this.pdfInfo.fingerprint;
  46605. },
  46606. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46607. return this.transport.getPage(pageNumber);
  46608. },
  46609. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46610. return this.transport.getPageIndex(ref);
  46611. },
  46612. getDestinations: function PDFDocumentProxy_getDestinations() {
  46613. return this.transport.getDestinations();
  46614. },
  46615. getDestination: function PDFDocumentProxy_getDestination(id) {
  46616. return this.transport.getDestination(id);
  46617. },
  46618. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46619. return this.transport.getPageLabels();
  46620. },
  46621. getAttachments: function PDFDocumentProxy_getAttachments() {
  46622. return this.transport.getAttachments();
  46623. },
  46624. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46625. return this.transport.getJavaScript();
  46626. },
  46627. getOutline: function PDFDocumentProxy_getOutline() {
  46628. return this.transport.getOutline();
  46629. },
  46630. getMetadata: function PDFDocumentProxy_getMetadata() {
  46631. return this.transport.getMetadata();
  46632. },
  46633. getData: function PDFDocumentProxy_getData() {
  46634. return this.transport.getData();
  46635. },
  46636. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46637. return this.transport.downloadInfoCapability.promise;
  46638. },
  46639. getStats: function PDFDocumentProxy_getStats() {
  46640. return this.transport.getStats();
  46641. },
  46642. cleanup: function PDFDocumentProxy_cleanup() {
  46643. this.transport.startCleanup();
  46644. },
  46645. destroy: function PDFDocumentProxy_destroy() {
  46646. return this.loadingTask.destroy();
  46647. }
  46648. };
  46649. return PDFDocumentProxy;
  46650. }();
  46651. var PDFPageProxy = function PDFPageProxyClosure() {
  46652. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46653. this.pageIndex = pageIndex;
  46654. this.pageInfo = pageInfo;
  46655. this.transport = transport;
  46656. this.stats = new StatTimer();
  46657. this.stats.enabled = getDefaultSetting('enableStats');
  46658. this.commonObjs = transport.commonObjs;
  46659. this.objs = new PDFObjects();
  46660. this.cleanupAfterRender = false;
  46661. this.pendingCleanup = false;
  46662. this.intentStates = Object.create(null);
  46663. this.destroyed = false;
  46664. }
  46665. PDFPageProxy.prototype = {
  46666. get pageNumber() {
  46667. return this.pageIndex + 1;
  46668. },
  46669. get rotate() {
  46670. return this.pageInfo.rotate;
  46671. },
  46672. get ref() {
  46673. return this.pageInfo.ref;
  46674. },
  46675. get view() {
  46676. return this.pageInfo.view;
  46677. },
  46678. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46679. if (arguments.length < 2) {
  46680. rotate = this.rotate;
  46681. }
  46682. return new PageViewport(this.view, scale, rotate, 0, 0);
  46683. },
  46684. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46685. var intent = params && params.intent || null;
  46686. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46687. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46688. this.annotationsIntent = intent;
  46689. }
  46690. return this.annotationsPromise;
  46691. },
  46692. render: function PDFPageProxy_render(params) {
  46693. var stats = this.stats;
  46694. stats.time('Overall');
  46695. this.pendingCleanup = false;
  46696. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46697. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46698. if (!this.intentStates[renderingIntent]) {
  46699. this.intentStates[renderingIntent] = Object.create(null);
  46700. }
  46701. var intentState = this.intentStates[renderingIntent];
  46702. if (!intentState.displayReadyCapability) {
  46703. intentState.receivingOperatorList = true;
  46704. intentState.displayReadyCapability = createPromiseCapability();
  46705. intentState.operatorList = {
  46706. fnArray: [],
  46707. argsArray: [],
  46708. lastChunk: false
  46709. };
  46710. this.stats.time('Page Request');
  46711. this.transport.messageHandler.send('RenderPageRequest', {
  46712. pageIndex: this.pageNumber - 1,
  46713. intent: renderingIntent,
  46714. renderInteractiveForms: renderInteractiveForms
  46715. });
  46716. }
  46717. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46718. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46719. if (!intentState.renderTasks) {
  46720. intentState.renderTasks = [];
  46721. }
  46722. intentState.renderTasks.push(internalRenderTask);
  46723. var renderTask = internalRenderTask.task;
  46724. if (params.continueCallback) {
  46725. deprecated('render is used with continueCallback parameter');
  46726. renderTask.onContinue = params.continueCallback;
  46727. }
  46728. var self = this;
  46729. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46730. if (self.pendingCleanup) {
  46731. complete();
  46732. return;
  46733. }
  46734. stats.time('Rendering');
  46735. internalRenderTask.initializeGraphics(transparency);
  46736. internalRenderTask.operatorListChanged();
  46737. }, function pageDisplayReadPromiseError(reason) {
  46738. complete(reason);
  46739. });
  46740. function complete(error) {
  46741. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46742. if (i >= 0) {
  46743. intentState.renderTasks.splice(i, 1);
  46744. }
  46745. if (self.cleanupAfterRender) {
  46746. self.pendingCleanup = true;
  46747. }
  46748. self._tryCleanup();
  46749. if (error) {
  46750. internalRenderTask.capability.reject(error);
  46751. } else {
  46752. internalRenderTask.capability.resolve();
  46753. }
  46754. stats.timeEnd('Rendering');
  46755. stats.timeEnd('Overall');
  46756. }
  46757. return renderTask;
  46758. },
  46759. getOperatorList: function PDFPageProxy_getOperatorList() {
  46760. function operatorListChanged() {
  46761. if (intentState.operatorList.lastChunk) {
  46762. intentState.opListReadCapability.resolve(intentState.operatorList);
  46763. var i = intentState.renderTasks.indexOf(opListTask);
  46764. if (i >= 0) {
  46765. intentState.renderTasks.splice(i, 1);
  46766. }
  46767. }
  46768. }
  46769. var renderingIntent = 'oplist';
  46770. if (!this.intentStates[renderingIntent]) {
  46771. this.intentStates[renderingIntent] = Object.create(null);
  46772. }
  46773. var intentState = this.intentStates[renderingIntent];
  46774. var opListTask;
  46775. if (!intentState.opListReadCapability) {
  46776. opListTask = {};
  46777. opListTask.operatorListChanged = operatorListChanged;
  46778. intentState.receivingOperatorList = true;
  46779. intentState.opListReadCapability = createPromiseCapability();
  46780. intentState.renderTasks = [];
  46781. intentState.renderTasks.push(opListTask);
  46782. intentState.operatorList = {
  46783. fnArray: [],
  46784. argsArray: [],
  46785. lastChunk: false
  46786. };
  46787. this.transport.messageHandler.send('RenderPageRequest', {
  46788. pageIndex: this.pageIndex,
  46789. intent: renderingIntent
  46790. });
  46791. }
  46792. return intentState.opListReadCapability.promise;
  46793. },
  46794. getTextContent: function PDFPageProxy_getTextContent(params) {
  46795. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46796. pageIndex: this.pageNumber - 1,
  46797. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46798. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46799. });
  46800. },
  46801. _destroy: function PDFPageProxy_destroy() {
  46802. this.destroyed = true;
  46803. this.transport.pageCache[this.pageIndex] = null;
  46804. var waitOn = [];
  46805. Object.keys(this.intentStates).forEach(function (intent) {
  46806. if (intent === 'oplist') {
  46807. return;
  46808. }
  46809. var intentState = this.intentStates[intent];
  46810. intentState.renderTasks.forEach(function (renderTask) {
  46811. var renderCompleted = renderTask.capability.promise.catch(function () {
  46812. });
  46813. waitOn.push(renderCompleted);
  46814. renderTask.cancel();
  46815. });
  46816. }, this);
  46817. this.objs.clear();
  46818. this.annotationsPromise = null;
  46819. this.pendingCleanup = false;
  46820. return Promise.all(waitOn);
  46821. },
  46822. destroy: function () {
  46823. deprecated('page destroy method, use cleanup() instead');
  46824. this.cleanup();
  46825. },
  46826. cleanup: function PDFPageProxy_cleanup() {
  46827. this.pendingCleanup = true;
  46828. this._tryCleanup();
  46829. },
  46830. _tryCleanup: function PDFPageProxy_tryCleanup() {
  46831. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  46832. var intentState = this.intentStates[intent];
  46833. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  46834. }, this)) {
  46835. return;
  46836. }
  46837. Object.keys(this.intentStates).forEach(function (intent) {
  46838. delete this.intentStates[intent];
  46839. }, this);
  46840. this.objs.clear();
  46841. this.annotationsPromise = null;
  46842. this.pendingCleanup = false;
  46843. },
  46844. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  46845. var intentState = this.intentStates[intent];
  46846. if (intentState.displayReadyCapability) {
  46847. intentState.displayReadyCapability.resolve(transparency);
  46848. }
  46849. },
  46850. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  46851. var intentState = this.intentStates[intent];
  46852. var i, ii;
  46853. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  46854. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  46855. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  46856. }
  46857. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  46858. for (i = 0; i < intentState.renderTasks.length; i++) {
  46859. intentState.renderTasks[i].operatorListChanged();
  46860. }
  46861. if (operatorListChunk.lastChunk) {
  46862. intentState.receivingOperatorList = false;
  46863. this._tryCleanup();
  46864. }
  46865. }
  46866. };
  46867. return PDFPageProxy;
  46868. }();
  46869. var PDFWorker = function PDFWorkerClosure() {
  46870. var nextFakeWorkerId = 0;
  46871. function getWorkerSrc() {
  46872. if (typeof workerSrc !== 'undefined') {
  46873. return workerSrc;
  46874. }
  46875. if (getDefaultSetting('workerSrc')) {
  46876. return getDefaultSetting('workerSrc');
  46877. }
  46878. if (pdfjsFilePath) {
  46879. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  46880. }
  46881. error('No PDFJS.workerSrc specified');
  46882. }
  46883. var fakeWorkerFilesLoadedCapability;
  46884. function setupFakeWorkerGlobal() {
  46885. var WorkerMessageHandler;
  46886. if (fakeWorkerFilesLoadedCapability) {
  46887. return fakeWorkerFilesLoadedCapability.promise;
  46888. }
  46889. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  46890. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  46891. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  46892. return fakeWorkerFilesLoadedCapability.promise;
  46893. }
  46894. function FakeWorkerPort(defer) {
  46895. this._listeners = [];
  46896. this._defer = defer;
  46897. this._deferred = Promise.resolve(undefined);
  46898. }
  46899. FakeWorkerPort.prototype = {
  46900. postMessage: function (obj, transfers) {
  46901. function cloneValue(value) {
  46902. if (typeof value !== 'object' || value === null) {
  46903. return value;
  46904. }
  46905. if (cloned.has(value)) {
  46906. return cloned.get(value);
  46907. }
  46908. var result;
  46909. var buffer;
  46910. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  46911. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  46912. if (value === buffer) {
  46913. result = value;
  46914. } else if (transferable) {
  46915. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  46916. } else {
  46917. result = new value.constructor(value);
  46918. }
  46919. cloned.set(value, result);
  46920. return result;
  46921. }
  46922. result = isArray(value) ? [] : {};
  46923. cloned.set(value, result);
  46924. for (var i in value) {
  46925. var desc, p = value;
  46926. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  46927. p = Object.getPrototypeOf(p);
  46928. }
  46929. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  46930. continue;
  46931. }
  46932. result[i] = cloneValue(desc.value);
  46933. }
  46934. return result;
  46935. }
  46936. if (!this._defer) {
  46937. this._listeners.forEach(function (listener) {
  46938. listener.call(this, { data: obj });
  46939. }, this);
  46940. return;
  46941. }
  46942. var cloned = new WeakMap();
  46943. var e = { data: cloneValue(obj) };
  46944. this._deferred.then(function () {
  46945. this._listeners.forEach(function (listener) {
  46946. listener.call(this, e);
  46947. }, this);
  46948. }.bind(this));
  46949. },
  46950. addEventListener: function (name, listener) {
  46951. this._listeners.push(listener);
  46952. },
  46953. removeEventListener: function (name, listener) {
  46954. var i = this._listeners.indexOf(listener);
  46955. this._listeners.splice(i, 1);
  46956. },
  46957. terminate: function () {
  46958. this._listeners = [];
  46959. }
  46960. };
  46961. function createCDNWrapper(url) {
  46962. var wrapper = 'importScripts(\'' + url + '\');';
  46963. return URL.createObjectURL(new Blob([wrapper]));
  46964. }
  46965. function PDFWorker(name) {
  46966. this.name = name;
  46967. this.destroyed = false;
  46968. this._readyCapability = createPromiseCapability();
  46969. this._port = null;
  46970. this._webWorker = null;
  46971. this._messageHandler = null;
  46972. this._initialize();
  46973. }
  46974. PDFWorker.prototype = {
  46975. get promise() {
  46976. return this._readyCapability.promise;
  46977. },
  46978. get port() {
  46979. return this._port;
  46980. },
  46981. get messageHandler() {
  46982. return this._messageHandler;
  46983. },
  46984. _initialize: function PDFWorker_initialize() {
  46985. this._setupFakeWorker();
  46986. },
  46987. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  46988. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  46989. warn('Setting up fake worker.');
  46990. isWorkerDisabled = true;
  46991. }
  46992. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  46993. if (this.destroyed) {
  46994. this._readyCapability.reject(new Error('Worker was destroyed'));
  46995. return;
  46996. }
  46997. var isTypedArraysPresent = Uint8Array !== Float32Array;
  46998. var port = new FakeWorkerPort(isTypedArraysPresent);
  46999. this._port = port;
  47000. var id = 'fake' + nextFakeWorkerId++;
  47001. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47002. WorkerMessageHandler.setup(workerHandler, port);
  47003. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47004. this._messageHandler = messageHandler;
  47005. this._readyCapability.resolve();
  47006. }.bind(this));
  47007. },
  47008. destroy: function PDFWorker_destroy() {
  47009. this.destroyed = true;
  47010. if (this._webWorker) {
  47011. this._webWorker.terminate();
  47012. this._webWorker = null;
  47013. }
  47014. this._port = null;
  47015. if (this._messageHandler) {
  47016. this._messageHandler.destroy();
  47017. this._messageHandler = null;
  47018. }
  47019. }
  47020. };
  47021. return PDFWorker;
  47022. }();
  47023. var WorkerTransport = function WorkerTransportClosure() {
  47024. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47025. this.messageHandler = messageHandler;
  47026. this.loadingTask = loadingTask;
  47027. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47028. this.commonObjs = new PDFObjects();
  47029. this.fontLoader = new FontLoader(loadingTask.docId);
  47030. this.destroyed = false;
  47031. this.destroyCapability = null;
  47032. this.pageCache = [];
  47033. this.pagePromises = [];
  47034. this.downloadInfoCapability = createPromiseCapability();
  47035. this.setupMessageHandler();
  47036. }
  47037. WorkerTransport.prototype = {
  47038. destroy: function WorkerTransport_destroy() {
  47039. if (this.destroyCapability) {
  47040. return this.destroyCapability.promise;
  47041. }
  47042. this.destroyed = true;
  47043. this.destroyCapability = createPromiseCapability();
  47044. var waitOn = [];
  47045. this.pageCache.forEach(function (page) {
  47046. if (page) {
  47047. waitOn.push(page._destroy());
  47048. }
  47049. });
  47050. this.pageCache = [];
  47051. this.pagePromises = [];
  47052. var self = this;
  47053. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  47054. waitOn.push(terminated);
  47055. Promise.all(waitOn).then(function () {
  47056. self.fontLoader.clear();
  47057. if (self.pdfDataRangeTransport) {
  47058. self.pdfDataRangeTransport.abort();
  47059. self.pdfDataRangeTransport = null;
  47060. }
  47061. if (self.messageHandler) {
  47062. self.messageHandler.destroy();
  47063. self.messageHandler = null;
  47064. }
  47065. self.destroyCapability.resolve();
  47066. }, this.destroyCapability.reject);
  47067. return this.destroyCapability.promise;
  47068. },
  47069. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  47070. var messageHandler = this.messageHandler;
  47071. function updatePassword(password) {
  47072. messageHandler.send('UpdatePassword', password);
  47073. }
  47074. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47075. if (pdfDataRangeTransport) {
  47076. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47077. messageHandler.send('OnDataRange', {
  47078. begin: begin,
  47079. chunk: chunk
  47080. });
  47081. });
  47082. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47083. messageHandler.send('OnDataProgress', { loaded: loaded });
  47084. });
  47085. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47086. messageHandler.send('OnDataRange', { chunk: chunk });
  47087. });
  47088. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47089. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47090. }, this);
  47091. }
  47092. messageHandler.on('GetDoc', function transportDoc(data) {
  47093. var pdfInfo = data.pdfInfo;
  47094. this.numPages = data.pdfInfo.numPages;
  47095. var loadingTask = this.loadingTask;
  47096. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47097. this.pdfDocument = pdfDocument;
  47098. loadingTask._capability.resolve(pdfDocument);
  47099. }, this);
  47100. messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
  47101. var loadingTask = this.loadingTask;
  47102. if (loadingTask.onPassword) {
  47103. return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
  47104. }
  47105. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47106. }, this);
  47107. messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
  47108. var loadingTask = this.loadingTask;
  47109. if (loadingTask.onPassword) {
  47110. return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
  47111. }
  47112. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47113. }, this);
  47114. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47115. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47116. }, this);
  47117. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47118. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47119. }, this);
  47120. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47121. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47122. }, this);
  47123. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47124. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47125. }, this);
  47126. messageHandler.on('DataLoaded', function transportPage(data) {
  47127. this.downloadInfoCapability.resolve(data);
  47128. }, this);
  47129. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47130. if (this.pdfDataRangeTransport) {
  47131. this.pdfDataRangeTransport.transportReady();
  47132. }
  47133. }, this);
  47134. messageHandler.on('StartRenderPage', function transportRender(data) {
  47135. if (this.destroyed) {
  47136. return;
  47137. }
  47138. var page = this.pageCache[data.pageIndex];
  47139. page.stats.timeEnd('Page Request');
  47140. page._startRenderPage(data.transparency, data.intent);
  47141. }, this);
  47142. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47143. if (this.destroyed) {
  47144. return;
  47145. }
  47146. var page = this.pageCache[data.pageIndex];
  47147. page._renderPageChunk(data.operatorList, data.intent);
  47148. }, this);
  47149. messageHandler.on('commonobj', function transportObj(data) {
  47150. if (this.destroyed) {
  47151. return;
  47152. }
  47153. var id = data[0];
  47154. var type = data[1];
  47155. if (this.commonObjs.hasData(id)) {
  47156. return;
  47157. }
  47158. switch (type) {
  47159. case 'Font':
  47160. var exportedData = data[2];
  47161. if ('error' in exportedData) {
  47162. var exportedError = exportedData.error;
  47163. warn('Error during font loading: ' + exportedError);
  47164. this.commonObjs.resolve(id, exportedError);
  47165. break;
  47166. }
  47167. var fontRegistry = null;
  47168. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47169. fontRegistry = {
  47170. registerFont: function (font, url) {
  47171. globalScope['FontInspector'].fontAdded(font, url);
  47172. }
  47173. };
  47174. }
  47175. var font = new FontFaceObject(exportedData, {
  47176. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47177. disableFontFace: getDefaultSetting('disableFontFace'),
  47178. fontRegistry: fontRegistry
  47179. });
  47180. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47181. this.commonObjs.resolve(id, font);
  47182. }.bind(this));
  47183. break;
  47184. case 'FontPath':
  47185. this.commonObjs.resolve(id, data[2]);
  47186. break;
  47187. default:
  47188. error('Got unknown common object type ' + type);
  47189. }
  47190. }, this);
  47191. messageHandler.on('obj', function transportObj(data) {
  47192. if (this.destroyed) {
  47193. return;
  47194. }
  47195. var id = data[0];
  47196. var pageIndex = data[1];
  47197. var type = data[2];
  47198. var pageProxy = this.pageCache[pageIndex];
  47199. var imageData;
  47200. if (pageProxy.objs.hasData(id)) {
  47201. return;
  47202. }
  47203. switch (type) {
  47204. case 'JpegStream':
  47205. imageData = data[3];
  47206. loadJpegStream(id, imageData, pageProxy.objs);
  47207. break;
  47208. case 'Image':
  47209. imageData = data[3];
  47210. pageProxy.objs.resolve(id, imageData);
  47211. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47212. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47213. pageProxy.cleanupAfterRender = true;
  47214. }
  47215. break;
  47216. default:
  47217. error('Got unknown object type ' + type);
  47218. }
  47219. }, this);
  47220. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47221. if (this.destroyed) {
  47222. return;
  47223. }
  47224. var loadingTask = this.loadingTask;
  47225. if (loadingTask.onProgress) {
  47226. loadingTask.onProgress({
  47227. loaded: data.loaded,
  47228. total: data.total
  47229. });
  47230. }
  47231. }, this);
  47232. messageHandler.on('PageError', function transportError(data) {
  47233. if (this.destroyed) {
  47234. return;
  47235. }
  47236. var page = this.pageCache[data.pageNum - 1];
  47237. var intentState = page.intentStates[data.intent];
  47238. if (intentState.displayReadyCapability) {
  47239. intentState.displayReadyCapability.reject(data.error);
  47240. } else {
  47241. error(data.error);
  47242. }
  47243. if (intentState.operatorList) {
  47244. intentState.operatorList.lastChunk = true;
  47245. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47246. intentState.renderTasks[i].operatorListChanged();
  47247. }
  47248. }
  47249. }, this);
  47250. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47251. if (this.destroyed) {
  47252. return;
  47253. }
  47254. var featureId = data.featureId;
  47255. var loadingTask = this.loadingTask;
  47256. if (loadingTask.onUnsupportedFeature) {
  47257. loadingTask.onUnsupportedFeature(featureId);
  47258. }
  47259. _UnsupportedManager.notify(featureId);
  47260. }, this);
  47261. messageHandler.on('JpegDecode', function (data) {
  47262. if (this.destroyed) {
  47263. return Promise.reject(new Error('Worker was destroyed'));
  47264. }
  47265. var imageUrl = data[0];
  47266. var components = data[1];
  47267. if (components !== 3 && components !== 1) {
  47268. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47269. }
  47270. return new Promise(function (resolve, reject) {
  47271. var img = new Image();
  47272. img.onload = function () {
  47273. var width = img.width;
  47274. var height = img.height;
  47275. var size = width * height;
  47276. var rgbaLength = size * 4;
  47277. var buf = new Uint8Array(size * components);
  47278. var tmpCanvas = createScratchCanvas(width, height);
  47279. var tmpCtx = tmpCanvas.getContext('2d');
  47280. tmpCtx.drawImage(img, 0, 0);
  47281. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47282. var i, j;
  47283. if (components === 3) {
  47284. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47285. buf[j] = data[i];
  47286. buf[j + 1] = data[i + 1];
  47287. buf[j + 2] = data[i + 2];
  47288. }
  47289. } else if (components === 1) {
  47290. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47291. buf[j] = data[i];
  47292. }
  47293. }
  47294. resolve({
  47295. data: buf,
  47296. width: width,
  47297. height: height
  47298. });
  47299. };
  47300. img.onerror = function () {
  47301. reject(new Error('JpegDecode failed to load image'));
  47302. };
  47303. img.src = imageUrl;
  47304. });
  47305. }, this);
  47306. },
  47307. getData: function WorkerTransport_getData() {
  47308. return this.messageHandler.sendWithPromise('GetData', null);
  47309. },
  47310. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47311. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47312. return Promise.reject(new Error('Invalid page request'));
  47313. }
  47314. var pageIndex = pageNumber - 1;
  47315. if (pageIndex in this.pagePromises) {
  47316. return this.pagePromises[pageIndex];
  47317. }
  47318. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47319. if (this.destroyed) {
  47320. throw new Error('Transport destroyed');
  47321. }
  47322. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47323. this.pageCache[pageIndex] = page;
  47324. return page;
  47325. }.bind(this));
  47326. this.pagePromises[pageIndex] = promise;
  47327. return promise;
  47328. },
  47329. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47330. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47331. return Promise.reject(new Error(reason));
  47332. });
  47333. },
  47334. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47335. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47336. pageIndex: pageIndex,
  47337. intent: intent
  47338. });
  47339. },
  47340. getDestinations: function WorkerTransport_getDestinations() {
  47341. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47342. },
  47343. getDestination: function WorkerTransport_getDestination(id) {
  47344. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47345. },
  47346. getPageLabels: function WorkerTransport_getPageLabels() {
  47347. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47348. },
  47349. getAttachments: function WorkerTransport_getAttachments() {
  47350. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47351. },
  47352. getJavaScript: function WorkerTransport_getJavaScript() {
  47353. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47354. },
  47355. getOutline: function WorkerTransport_getOutline() {
  47356. return this.messageHandler.sendWithPromise('GetOutline', null);
  47357. },
  47358. getMetadata: function WorkerTransport_getMetadata() {
  47359. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47360. return {
  47361. info: results[0],
  47362. metadata: results[1] ? new Metadata(results[1]) : null
  47363. };
  47364. });
  47365. },
  47366. getStats: function WorkerTransport_getStats() {
  47367. return this.messageHandler.sendWithPromise('GetStats', null);
  47368. },
  47369. startCleanup: function WorkerTransport_startCleanup() {
  47370. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47371. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47372. var page = this.pageCache[i];
  47373. if (page) {
  47374. page.cleanup();
  47375. }
  47376. }
  47377. this.commonObjs.clear();
  47378. this.fontLoader.clear();
  47379. }.bind(this));
  47380. }
  47381. };
  47382. return WorkerTransport;
  47383. }();
  47384. var PDFObjects = function PDFObjectsClosure() {
  47385. function PDFObjects() {
  47386. this.objs = Object.create(null);
  47387. }
  47388. PDFObjects.prototype = {
  47389. ensureObj: function PDFObjects_ensureObj(objId) {
  47390. if (this.objs[objId]) {
  47391. return this.objs[objId];
  47392. }
  47393. var obj = {
  47394. capability: createPromiseCapability(),
  47395. data: null,
  47396. resolved: false
  47397. };
  47398. this.objs[objId] = obj;
  47399. return obj;
  47400. },
  47401. get: function PDFObjects_get(objId, callback) {
  47402. if (callback) {
  47403. this.ensureObj(objId).capability.promise.then(callback);
  47404. return null;
  47405. }
  47406. var obj = this.objs[objId];
  47407. if (!obj || !obj.resolved) {
  47408. error('Requesting object that isn\'t resolved yet ' + objId);
  47409. }
  47410. return obj.data;
  47411. },
  47412. resolve: function PDFObjects_resolve(objId, data) {
  47413. var obj = this.ensureObj(objId);
  47414. obj.resolved = true;
  47415. obj.data = data;
  47416. obj.capability.resolve(data);
  47417. },
  47418. isResolved: function PDFObjects_isResolved(objId) {
  47419. var objs = this.objs;
  47420. if (!objs[objId]) {
  47421. return false;
  47422. } else {
  47423. return objs[objId].resolved;
  47424. }
  47425. },
  47426. hasData: function PDFObjects_hasData(objId) {
  47427. return this.isResolved(objId);
  47428. },
  47429. getData: function PDFObjects_getData(objId) {
  47430. var objs = this.objs;
  47431. if (!objs[objId] || !objs[objId].resolved) {
  47432. return null;
  47433. } else {
  47434. return objs[objId].data;
  47435. }
  47436. },
  47437. clear: function PDFObjects_clear() {
  47438. this.objs = Object.create(null);
  47439. }
  47440. };
  47441. return PDFObjects;
  47442. }();
  47443. var RenderTask = function RenderTaskClosure() {
  47444. function RenderTask(internalRenderTask) {
  47445. this._internalRenderTask = internalRenderTask;
  47446. this.onContinue = null;
  47447. }
  47448. RenderTask.prototype = {
  47449. get promise() {
  47450. return this._internalRenderTask.capability.promise;
  47451. },
  47452. cancel: function RenderTask_cancel() {
  47453. this._internalRenderTask.cancel();
  47454. },
  47455. then: function RenderTask_then(onFulfilled, onRejected) {
  47456. return this.promise.then.apply(this.promise, arguments);
  47457. }
  47458. };
  47459. return RenderTask;
  47460. }();
  47461. var InternalRenderTask = function InternalRenderTaskClosure() {
  47462. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47463. this.callback = callback;
  47464. this.params = params;
  47465. this.objs = objs;
  47466. this.commonObjs = commonObjs;
  47467. this.operatorListIdx = null;
  47468. this.operatorList = operatorList;
  47469. this.pageNumber = pageNumber;
  47470. this.running = false;
  47471. this.graphicsReadyCallback = null;
  47472. this.graphicsReady = false;
  47473. this.useRequestAnimationFrame = false;
  47474. this.cancelled = false;
  47475. this.capability = createPromiseCapability();
  47476. this.task = new RenderTask(this);
  47477. this._continueBound = this._continue.bind(this);
  47478. this._scheduleNextBound = this._scheduleNext.bind(this);
  47479. this._nextBound = this._next.bind(this);
  47480. }
  47481. InternalRenderTask.prototype = {
  47482. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47483. if (this.cancelled) {
  47484. return;
  47485. }
  47486. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47487. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47488. this.stepper.init(this.operatorList);
  47489. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47490. }
  47491. var params = this.params;
  47492. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47493. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47494. this.operatorListIdx = 0;
  47495. this.graphicsReady = true;
  47496. if (this.graphicsReadyCallback) {
  47497. this.graphicsReadyCallback();
  47498. }
  47499. },
  47500. cancel: function InternalRenderTask_cancel() {
  47501. this.running = false;
  47502. this.cancelled = true;
  47503. this.callback('cancelled');
  47504. },
  47505. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47506. if (!this.graphicsReady) {
  47507. if (!this.graphicsReadyCallback) {
  47508. this.graphicsReadyCallback = this._continueBound;
  47509. }
  47510. return;
  47511. }
  47512. if (this.stepper) {
  47513. this.stepper.updateOperatorList(this.operatorList);
  47514. }
  47515. if (this.running) {
  47516. return;
  47517. }
  47518. this._continue();
  47519. },
  47520. _continue: function InternalRenderTask__continue() {
  47521. this.running = true;
  47522. if (this.cancelled) {
  47523. return;
  47524. }
  47525. if (this.task.onContinue) {
  47526. this.task.onContinue.call(this.task, this._scheduleNextBound);
  47527. } else {
  47528. this._scheduleNext();
  47529. }
  47530. },
  47531. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47532. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47533. window.requestAnimationFrame(this._nextBound);
  47534. } else {
  47535. Promise.resolve(undefined).then(this._nextBound);
  47536. }
  47537. },
  47538. _next: function InternalRenderTask__next() {
  47539. if (this.cancelled) {
  47540. return;
  47541. }
  47542. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47543. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47544. this.running = false;
  47545. if (this.operatorList.lastChunk) {
  47546. this.gfx.endDrawing();
  47547. this.callback();
  47548. }
  47549. }
  47550. }
  47551. };
  47552. return InternalRenderTask;
  47553. }();
  47554. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47555. var listeners = [];
  47556. return {
  47557. listen: function (cb) {
  47558. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47559. listeners.push(cb);
  47560. },
  47561. notify: function (featureId) {
  47562. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47563. listeners[i](featureId);
  47564. }
  47565. }
  47566. };
  47567. }();
  47568. if (typeof pdfjsVersion !== 'undefined') {
  47569. exports.version = pdfjsVersion;
  47570. }
  47571. if (typeof pdfjsBuild !== 'undefined') {
  47572. exports.build = pdfjsBuild;
  47573. }
  47574. exports.getDocument = getDocument;
  47575. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47576. exports.PDFWorker = PDFWorker;
  47577. exports.PDFDocumentProxy = PDFDocumentProxy;
  47578. exports.PDFPageProxy = PDFPageProxy;
  47579. exports._UnsupportedManager = _UnsupportedManager;
  47580. }));
  47581. (function (root, factory) {
  47582. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47583. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47584. var error = sharedUtil.error;
  47585. var info = sharedUtil.info;
  47586. var isArray = sharedUtil.isArray;
  47587. var isString = sharedUtil.isString;
  47588. var shadow = sharedUtil.shadow;
  47589. var warn = sharedUtil.warn;
  47590. var isDict = corePrimitives.isDict;
  47591. var isName = corePrimitives.isName;
  47592. var isStream = corePrimitives.isStream;
  47593. var PDFFunction = coreFunction.PDFFunction;
  47594. var ColorSpace = function ColorSpaceClosure() {
  47595. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47596. var COMPONENTS = 3;
  47597. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47598. var xRatio = w1 / w2;
  47599. var yRatio = h1 / h2;
  47600. var i, j, py, newIndex = 0, oldIndex;
  47601. var xScaled = new Uint16Array(w2);
  47602. var w1Scanline = w1 * COMPONENTS;
  47603. for (i = 0; i < w2; i++) {
  47604. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47605. }
  47606. for (i = 0; i < h2; i++) {
  47607. py = Math.floor(i * yRatio) * w1Scanline;
  47608. for (j = 0; j < w2; j++) {
  47609. oldIndex = py + xScaled[j];
  47610. dest[newIndex++] = src[oldIndex++];
  47611. dest[newIndex++] = src[oldIndex++];
  47612. dest[newIndex++] = src[oldIndex++];
  47613. newIndex += alpha01;
  47614. }
  47615. }
  47616. }
  47617. function ColorSpace() {
  47618. error('should not call ColorSpace constructor');
  47619. }
  47620. ColorSpace.prototype = {
  47621. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47622. var rgb = new Uint8Array(3);
  47623. this.getRgbItem(src, srcOffset, rgb, 0);
  47624. return rgb;
  47625. },
  47626. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47627. error('Should not call ColorSpace.getRgbItem');
  47628. },
  47629. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47630. error('Should not call ColorSpace.getRgbBuffer');
  47631. },
  47632. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47633. error('Should not call ColorSpace.getOutputLength');
  47634. },
  47635. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47636. return false;
  47637. },
  47638. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47639. var count = originalWidth * originalHeight;
  47640. var rgbBuf = null;
  47641. var numComponentColors = 1 << bpc;
  47642. var needsResizing = originalHeight !== height || originalWidth !== width;
  47643. var i, ii;
  47644. if (this.isPassthrough(bpc)) {
  47645. rgbBuf = comps;
  47646. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47647. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47648. var key;
  47649. for (i = 0; i < numComponentColors; i++) {
  47650. allColors[i] = i;
  47651. }
  47652. var colorMap = new Uint8Array(numComponentColors * 3);
  47653. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47654. var destPos, rgbPos;
  47655. if (!needsResizing) {
  47656. destPos = 0;
  47657. for (i = 0; i < count; ++i) {
  47658. key = comps[i] * 3;
  47659. dest[destPos++] = colorMap[key];
  47660. dest[destPos++] = colorMap[key + 1];
  47661. dest[destPos++] = colorMap[key + 2];
  47662. destPos += alpha01;
  47663. }
  47664. } else {
  47665. rgbBuf = new Uint8Array(count * 3);
  47666. rgbPos = 0;
  47667. for (i = 0; i < count; ++i) {
  47668. key = comps[i] * 3;
  47669. rgbBuf[rgbPos++] = colorMap[key];
  47670. rgbBuf[rgbPos++] = colorMap[key + 1];
  47671. rgbBuf[rgbPos++] = colorMap[key + 2];
  47672. }
  47673. }
  47674. } else {
  47675. if (!needsResizing) {
  47676. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47677. } else {
  47678. rgbBuf = new Uint8Array(count * 3);
  47679. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47680. }
  47681. }
  47682. if (rgbBuf) {
  47683. if (needsResizing) {
  47684. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47685. } else {
  47686. rgbPos = 0;
  47687. destPos = 0;
  47688. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47689. dest[destPos++] = rgbBuf[rgbPos++];
  47690. dest[destPos++] = rgbBuf[rgbPos++];
  47691. dest[destPos++] = rgbBuf[rgbPos++];
  47692. destPos += alpha01;
  47693. }
  47694. }
  47695. }
  47696. },
  47697. usesZeroToOneRange: true
  47698. };
  47699. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47700. var IR = ColorSpace.parseToIR(cs, xref, res);
  47701. if (IR instanceof AlternateCS) {
  47702. return IR;
  47703. }
  47704. return ColorSpace.fromIR(IR);
  47705. };
  47706. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47707. var name = isArray(IR) ? IR[0] : IR;
  47708. var whitePoint, blackPoint, gamma;
  47709. switch (name) {
  47710. case 'DeviceGrayCS':
  47711. return this.singletons.gray;
  47712. case 'DeviceRgbCS':
  47713. return this.singletons.rgb;
  47714. case 'DeviceCmykCS':
  47715. return this.singletons.cmyk;
  47716. case 'CalGrayCS':
  47717. whitePoint = IR[1];
  47718. blackPoint = IR[2];
  47719. gamma = IR[3];
  47720. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47721. case 'CalRGBCS':
  47722. whitePoint = IR[1];
  47723. blackPoint = IR[2];
  47724. gamma = IR[3];
  47725. var matrix = IR[4];
  47726. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47727. case 'PatternCS':
  47728. var basePatternCS = IR[1];
  47729. if (basePatternCS) {
  47730. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47731. }
  47732. return new PatternCS(basePatternCS);
  47733. case 'IndexedCS':
  47734. var baseIndexedCS = IR[1];
  47735. var hiVal = IR[2];
  47736. var lookup = IR[3];
  47737. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47738. case 'AlternateCS':
  47739. var numComps = IR[1];
  47740. var alt = IR[2];
  47741. var tintFnIR = IR[3];
  47742. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47743. case 'LabCS':
  47744. whitePoint = IR[1];
  47745. blackPoint = IR[2];
  47746. var range = IR[3];
  47747. return new LabCS(whitePoint, blackPoint, range);
  47748. default:
  47749. error('Unknown name ' + name);
  47750. }
  47751. return null;
  47752. };
  47753. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47754. if (isName(cs)) {
  47755. var colorSpaces = res.get('ColorSpace');
  47756. if (isDict(colorSpaces)) {
  47757. var refcs = colorSpaces.get(cs.name);
  47758. if (refcs) {
  47759. cs = refcs;
  47760. }
  47761. }
  47762. }
  47763. cs = xref.fetchIfRef(cs);
  47764. var mode;
  47765. if (isName(cs)) {
  47766. mode = cs.name;
  47767. this.mode = mode;
  47768. switch (mode) {
  47769. case 'DeviceGray':
  47770. case 'G':
  47771. return 'DeviceGrayCS';
  47772. case 'DeviceRGB':
  47773. case 'RGB':
  47774. return 'DeviceRgbCS';
  47775. case 'DeviceCMYK':
  47776. case 'CMYK':
  47777. return 'DeviceCmykCS';
  47778. case 'Pattern':
  47779. return [
  47780. 'PatternCS',
  47781. null
  47782. ];
  47783. default:
  47784. error('unrecognized colorspace ' + mode);
  47785. }
  47786. } else if (isArray(cs)) {
  47787. mode = xref.fetchIfRef(cs[0]).name;
  47788. this.mode = mode;
  47789. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47790. switch (mode) {
  47791. case 'DeviceGray':
  47792. case 'G':
  47793. return 'DeviceGrayCS';
  47794. case 'DeviceRGB':
  47795. case 'RGB':
  47796. return 'DeviceRgbCS';
  47797. case 'DeviceCMYK':
  47798. case 'CMYK':
  47799. return 'DeviceCmykCS';
  47800. case 'CalGray':
  47801. params = xref.fetchIfRef(cs[1]);
  47802. whitePoint = params.getArray('WhitePoint');
  47803. blackPoint = params.getArray('BlackPoint');
  47804. gamma = params.get('Gamma');
  47805. return [
  47806. 'CalGrayCS',
  47807. whitePoint,
  47808. blackPoint,
  47809. gamma
  47810. ];
  47811. case 'CalRGB':
  47812. params = xref.fetchIfRef(cs[1]);
  47813. whitePoint = params.getArray('WhitePoint');
  47814. blackPoint = params.getArray('BlackPoint');
  47815. gamma = params.getArray('Gamma');
  47816. var matrix = params.getArray('Matrix');
  47817. return [
  47818. 'CalRGBCS',
  47819. whitePoint,
  47820. blackPoint,
  47821. gamma,
  47822. matrix
  47823. ];
  47824. case 'ICCBased':
  47825. var stream = xref.fetchIfRef(cs[1]);
  47826. var dict = stream.dict;
  47827. numComps = dict.get('N');
  47828. alt = dict.get('Alternate');
  47829. if (alt) {
  47830. var altIR = ColorSpace.parseToIR(alt, xref, res);
  47831. var altCS = ColorSpace.fromIR(altIR);
  47832. if (altCS.numComps === numComps) {
  47833. return altIR;
  47834. }
  47835. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  47836. }
  47837. if (numComps === 1) {
  47838. return 'DeviceGrayCS';
  47839. } else if (numComps === 3) {
  47840. return 'DeviceRgbCS';
  47841. } else if (numComps === 4) {
  47842. return 'DeviceCmykCS';
  47843. }
  47844. break;
  47845. case 'Pattern':
  47846. var basePatternCS = cs[1] || null;
  47847. if (basePatternCS) {
  47848. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  47849. }
  47850. return [
  47851. 'PatternCS',
  47852. basePatternCS
  47853. ];
  47854. case 'Indexed':
  47855. case 'I':
  47856. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  47857. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  47858. var lookup = xref.fetchIfRef(cs[3]);
  47859. if (isStream(lookup)) {
  47860. lookup = lookup.getBytes();
  47861. }
  47862. return [
  47863. 'IndexedCS',
  47864. baseIndexedCS,
  47865. hiVal,
  47866. lookup
  47867. ];
  47868. case 'Separation':
  47869. case 'DeviceN':
  47870. var name = xref.fetchIfRef(cs[1]);
  47871. numComps = 1;
  47872. if (isName(name)) {
  47873. numComps = 1;
  47874. } else if (isArray(name)) {
  47875. numComps = name.length;
  47876. }
  47877. alt = ColorSpace.parseToIR(cs[2], xref, res);
  47878. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  47879. return [
  47880. 'AlternateCS',
  47881. numComps,
  47882. alt,
  47883. tintFnIR
  47884. ];
  47885. case 'Lab':
  47886. params = xref.fetchIfRef(cs[1]);
  47887. whitePoint = params.getArray('WhitePoint');
  47888. blackPoint = params.getArray('BlackPoint');
  47889. var range = params.getArray('Range');
  47890. return [
  47891. 'LabCS',
  47892. whitePoint,
  47893. blackPoint,
  47894. range
  47895. ];
  47896. default:
  47897. error('unimplemented color space object "' + mode + '"');
  47898. }
  47899. } else {
  47900. error('unrecognized color space object: "' + cs + '"');
  47901. }
  47902. return null;
  47903. };
  47904. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  47905. if (!isArray(decode)) {
  47906. return true;
  47907. }
  47908. if (n * 2 !== decode.length) {
  47909. warn('The decode map is not the correct length');
  47910. return true;
  47911. }
  47912. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  47913. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  47914. return false;
  47915. }
  47916. }
  47917. return true;
  47918. };
  47919. ColorSpace.singletons = {
  47920. get gray() {
  47921. return shadow(this, 'gray', new DeviceGrayCS());
  47922. },
  47923. get rgb() {
  47924. return shadow(this, 'rgb', new DeviceRgbCS());
  47925. },
  47926. get cmyk() {
  47927. return shadow(this, 'cmyk', new DeviceCmykCS());
  47928. }
  47929. };
  47930. return ColorSpace;
  47931. }();
  47932. var AlternateCS = function AlternateCSClosure() {
  47933. function AlternateCS(numComps, base, tintFn) {
  47934. this.name = 'Alternate';
  47935. this.numComps = numComps;
  47936. this.defaultColor = new Float32Array(numComps);
  47937. for (var i = 0; i < numComps; ++i) {
  47938. this.defaultColor[i] = 1;
  47939. }
  47940. this.base = base;
  47941. this.tintFn = tintFn;
  47942. this.tmpBuf = new Float32Array(base.numComps);
  47943. }
  47944. AlternateCS.prototype = {
  47945. getRgb: ColorSpace.prototype.getRgb,
  47946. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  47947. var tmpBuf = this.tmpBuf;
  47948. this.tintFn(src, srcOffset, tmpBuf, 0);
  47949. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  47950. },
  47951. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47952. var tintFn = this.tintFn;
  47953. var base = this.base;
  47954. var scale = 1 / ((1 << bits) - 1);
  47955. var baseNumComps = base.numComps;
  47956. var usesZeroToOneRange = base.usesZeroToOneRange;
  47957. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  47958. var pos = isPassthrough ? destOffset : 0;
  47959. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  47960. var numComps = this.numComps;
  47961. var scaled = new Float32Array(numComps);
  47962. var tinted = new Float32Array(baseNumComps);
  47963. var i, j;
  47964. if (usesZeroToOneRange) {
  47965. for (i = 0; i < count; i++) {
  47966. for (j = 0; j < numComps; j++) {
  47967. scaled[j] = src[srcOffset++] * scale;
  47968. }
  47969. tintFn(scaled, 0, tinted, 0);
  47970. for (j = 0; j < baseNumComps; j++) {
  47971. baseBuf[pos++] = tinted[j] * 255;
  47972. }
  47973. }
  47974. } else {
  47975. for (i = 0; i < count; i++) {
  47976. for (j = 0; j < numComps; j++) {
  47977. scaled[j] = src[srcOffset++] * scale;
  47978. }
  47979. tintFn(scaled, 0, tinted, 0);
  47980. base.getRgbItem(tinted, 0, baseBuf, pos);
  47981. pos += baseNumComps;
  47982. }
  47983. }
  47984. if (!isPassthrough) {
  47985. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  47986. }
  47987. },
  47988. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  47989. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  47990. },
  47991. isPassthrough: ColorSpace.prototype.isPassthrough,
  47992. fillRgb: ColorSpace.prototype.fillRgb,
  47993. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  47994. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  47995. },
  47996. usesZeroToOneRange: true
  47997. };
  47998. return AlternateCS;
  47999. }();
  48000. var PatternCS = function PatternCSClosure() {
  48001. function PatternCS(baseCS) {
  48002. this.name = 'Pattern';
  48003. this.base = baseCS;
  48004. }
  48005. PatternCS.prototype = {};
  48006. return PatternCS;
  48007. }();
  48008. var IndexedCS = function IndexedCSClosure() {
  48009. function IndexedCS(base, highVal, lookup) {
  48010. this.name = 'Indexed';
  48011. this.numComps = 1;
  48012. this.defaultColor = new Uint8Array([0]);
  48013. this.base = base;
  48014. this.highVal = highVal;
  48015. var baseNumComps = base.numComps;
  48016. var length = baseNumComps * highVal;
  48017. var lookupArray;
  48018. if (isStream(lookup)) {
  48019. lookupArray = new Uint8Array(length);
  48020. var bytes = lookup.getBytes(length);
  48021. lookupArray.set(bytes);
  48022. } else if (isString(lookup)) {
  48023. lookupArray = new Uint8Array(length);
  48024. for (var i = 0; i < length; ++i) {
  48025. lookupArray[i] = lookup.charCodeAt(i);
  48026. }
  48027. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48028. lookupArray = lookup;
  48029. } else {
  48030. error('Unrecognized lookup table: ' + lookup);
  48031. }
  48032. this.lookup = lookupArray;
  48033. }
  48034. IndexedCS.prototype = {
  48035. getRgb: ColorSpace.prototype.getRgb,
  48036. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48037. var numComps = this.base.numComps;
  48038. var start = src[srcOffset] * numComps;
  48039. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48040. },
  48041. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48042. var base = this.base;
  48043. var numComps = base.numComps;
  48044. var outputDelta = base.getOutputLength(numComps, alpha01);
  48045. var lookup = this.lookup;
  48046. for (var i = 0; i < count; ++i) {
  48047. var lookupPos = src[srcOffset++] * numComps;
  48048. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48049. destOffset += outputDelta;
  48050. }
  48051. },
  48052. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48053. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48054. },
  48055. isPassthrough: ColorSpace.prototype.isPassthrough,
  48056. fillRgb: ColorSpace.prototype.fillRgb,
  48057. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48058. return true;
  48059. },
  48060. usesZeroToOneRange: true
  48061. };
  48062. return IndexedCS;
  48063. }();
  48064. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48065. function DeviceGrayCS() {
  48066. this.name = 'DeviceGray';
  48067. this.numComps = 1;
  48068. this.defaultColor = new Float32Array([0]);
  48069. }
  48070. DeviceGrayCS.prototype = {
  48071. getRgb: ColorSpace.prototype.getRgb,
  48072. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48073. var c = src[srcOffset] * 255 | 0;
  48074. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48075. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48076. },
  48077. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48078. var scale = 255 / ((1 << bits) - 1);
  48079. var j = srcOffset, q = destOffset;
  48080. for (var i = 0; i < count; ++i) {
  48081. var c = scale * src[j++] | 0;
  48082. dest[q++] = c;
  48083. dest[q++] = c;
  48084. dest[q++] = c;
  48085. q += alpha01;
  48086. }
  48087. },
  48088. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48089. return inputLength * (3 + alpha01);
  48090. },
  48091. isPassthrough: ColorSpace.prototype.isPassthrough,
  48092. fillRgb: ColorSpace.prototype.fillRgb,
  48093. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48094. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48095. },
  48096. usesZeroToOneRange: true
  48097. };
  48098. return DeviceGrayCS;
  48099. }();
  48100. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48101. function DeviceRgbCS() {
  48102. this.name = 'DeviceRGB';
  48103. this.numComps = 3;
  48104. this.defaultColor = new Float32Array([
  48105. 0,
  48106. 0,
  48107. 0
  48108. ]);
  48109. }
  48110. DeviceRgbCS.prototype = {
  48111. getRgb: ColorSpace.prototype.getRgb,
  48112. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48113. var r = src[srcOffset] * 255 | 0;
  48114. var g = src[srcOffset + 1] * 255 | 0;
  48115. var b = src[srcOffset + 2] * 255 | 0;
  48116. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48117. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48118. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48119. },
  48120. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48121. if (bits === 8 && alpha01 === 0) {
  48122. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48123. return;
  48124. }
  48125. var scale = 255 / ((1 << bits) - 1);
  48126. var j = srcOffset, q = destOffset;
  48127. for (var i = 0; i < count; ++i) {
  48128. dest[q++] = scale * src[j++] | 0;
  48129. dest[q++] = scale * src[j++] | 0;
  48130. dest[q++] = scale * src[j++] | 0;
  48131. q += alpha01;
  48132. }
  48133. },
  48134. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48135. return inputLength * (3 + alpha01) / 3 | 0;
  48136. },
  48137. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48138. return bits === 8;
  48139. },
  48140. fillRgb: ColorSpace.prototype.fillRgb,
  48141. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48142. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48143. },
  48144. usesZeroToOneRange: true
  48145. };
  48146. return DeviceRgbCS;
  48147. }();
  48148. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48149. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48150. var c = src[srcOffset + 0] * srcScale;
  48151. var m = src[srcOffset + 1] * srcScale;
  48152. var y = src[srcOffset + 2] * srcScale;
  48153. var k = src[srcOffset + 3] * srcScale;
  48154. 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;
  48155. 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;
  48156. 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;
  48157. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48158. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48159. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48160. }
  48161. function DeviceCmykCS() {
  48162. this.name = 'DeviceCMYK';
  48163. this.numComps = 4;
  48164. this.defaultColor = new Float32Array([
  48165. 0,
  48166. 0,
  48167. 0,
  48168. 1
  48169. ]);
  48170. }
  48171. DeviceCmykCS.prototype = {
  48172. getRgb: ColorSpace.prototype.getRgb,
  48173. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48174. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48175. },
  48176. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48177. var scale = 1 / ((1 << bits) - 1);
  48178. for (var i = 0; i < count; i++) {
  48179. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48180. srcOffset += 4;
  48181. destOffset += 3 + alpha01;
  48182. }
  48183. },
  48184. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48185. return inputLength / 4 * (3 + alpha01) | 0;
  48186. },
  48187. isPassthrough: ColorSpace.prototype.isPassthrough,
  48188. fillRgb: ColorSpace.prototype.fillRgb,
  48189. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48190. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48191. },
  48192. usesZeroToOneRange: true
  48193. };
  48194. return DeviceCmykCS;
  48195. }();
  48196. var CalGrayCS = function CalGrayCSClosure() {
  48197. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48198. this.name = 'CalGray';
  48199. this.numComps = 1;
  48200. this.defaultColor = new Float32Array([0]);
  48201. if (!whitePoint) {
  48202. error('WhitePoint missing - required for color space CalGray');
  48203. }
  48204. blackPoint = blackPoint || [
  48205. 0,
  48206. 0,
  48207. 0
  48208. ];
  48209. gamma = gamma || 1;
  48210. this.XW = whitePoint[0];
  48211. this.YW = whitePoint[1];
  48212. this.ZW = whitePoint[2];
  48213. this.XB = blackPoint[0];
  48214. this.YB = blackPoint[1];
  48215. this.ZB = blackPoint[2];
  48216. this.G = gamma;
  48217. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48218. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48219. }
  48220. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48221. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48222. this.XB = this.YB = this.ZB = 0;
  48223. }
  48224. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48225. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48226. }
  48227. if (this.G < 1) {
  48228. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48229. this.G = 1;
  48230. }
  48231. }
  48232. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48233. var A = src[srcOffset] * scale;
  48234. var AG = Math.pow(A, cs.G);
  48235. var L = cs.YW * AG;
  48236. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48237. dest[destOffset] = val;
  48238. dest[destOffset + 1] = val;
  48239. dest[destOffset + 2] = val;
  48240. }
  48241. CalGrayCS.prototype = {
  48242. getRgb: ColorSpace.prototype.getRgb,
  48243. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48244. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48245. },
  48246. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48247. var scale = 1 / ((1 << bits) - 1);
  48248. for (var i = 0; i < count; ++i) {
  48249. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48250. srcOffset += 1;
  48251. destOffset += 3 + alpha01;
  48252. }
  48253. },
  48254. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48255. return inputLength * (3 + alpha01);
  48256. },
  48257. isPassthrough: ColorSpace.prototype.isPassthrough,
  48258. fillRgb: ColorSpace.prototype.fillRgb,
  48259. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48260. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48261. },
  48262. usesZeroToOneRange: true
  48263. };
  48264. return CalGrayCS;
  48265. }();
  48266. var CalRGBCS = function CalRGBCSClosure() {
  48267. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48268. 0.8951,
  48269. 0.2664,
  48270. -0.1614,
  48271. -0.7502,
  48272. 1.7135,
  48273. 0.0367,
  48274. 0.0389,
  48275. -0.0685,
  48276. 1.0296
  48277. ]);
  48278. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48279. 0.9869929,
  48280. -0.1470543,
  48281. 0.1599627,
  48282. 0.4323053,
  48283. 0.5183603,
  48284. 0.0492912,
  48285. -0.0085287,
  48286. 0.0400428,
  48287. 0.9684867
  48288. ]);
  48289. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48290. 3.2404542,
  48291. -1.5371385,
  48292. -0.4985314,
  48293. -0.9692660,
  48294. 1.8760108,
  48295. 0.0415560,
  48296. 0.0556434,
  48297. -0.2040259,
  48298. 1.0572252
  48299. ]);
  48300. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48301. 1,
  48302. 1,
  48303. 1
  48304. ]);
  48305. var tempNormalizeMatrix = new Float32Array(3);
  48306. var tempConvertMatrix1 = new Float32Array(3);
  48307. var tempConvertMatrix2 = new Float32Array(3);
  48308. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48309. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48310. this.name = 'CalRGB';
  48311. this.numComps = 3;
  48312. this.defaultColor = new Float32Array(3);
  48313. if (!whitePoint) {
  48314. error('WhitePoint missing - required for color space CalRGB');
  48315. }
  48316. blackPoint = blackPoint || new Float32Array(3);
  48317. gamma = gamma || new Float32Array([
  48318. 1,
  48319. 1,
  48320. 1
  48321. ]);
  48322. matrix = matrix || new Float32Array([
  48323. 1,
  48324. 0,
  48325. 0,
  48326. 0,
  48327. 1,
  48328. 0,
  48329. 0,
  48330. 0,
  48331. 1
  48332. ]);
  48333. var XW = whitePoint[0];
  48334. var YW = whitePoint[1];
  48335. var ZW = whitePoint[2];
  48336. this.whitePoint = whitePoint;
  48337. var XB = blackPoint[0];
  48338. var YB = blackPoint[1];
  48339. var ZB = blackPoint[2];
  48340. this.blackPoint = blackPoint;
  48341. this.GR = gamma[0];
  48342. this.GG = gamma[1];
  48343. this.GB = gamma[2];
  48344. this.MXA = matrix[0];
  48345. this.MYA = matrix[1];
  48346. this.MZA = matrix[2];
  48347. this.MXB = matrix[3];
  48348. this.MYB = matrix[4];
  48349. this.MZB = matrix[5];
  48350. this.MXC = matrix[6];
  48351. this.MYC = matrix[7];
  48352. this.MZC = matrix[8];
  48353. if (XW < 0 || ZW < 0 || YW !== 1) {
  48354. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48355. }
  48356. if (XB < 0 || YB < 0 || ZB < 0) {
  48357. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48358. this.blackPoint = new Float32Array(3);
  48359. }
  48360. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48361. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48362. this.GR = this.GG = this.GB = 1;
  48363. }
  48364. 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) {
  48365. 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');
  48366. this.MXA = this.MYB = this.MZC = 1;
  48367. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48368. }
  48369. }
  48370. function matrixProduct(a, b, result) {
  48371. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48372. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48373. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48374. }
  48375. function convertToFlat(sourceWhitePoint, LMS, result) {
  48376. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48377. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48378. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48379. }
  48380. function convertToD65(sourceWhitePoint, LMS, result) {
  48381. var D65X = 0.95047;
  48382. var D65Y = 1;
  48383. var D65Z = 1.08883;
  48384. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48385. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48386. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48387. }
  48388. function sRGBTransferFunction(color) {
  48389. if (color <= 0.0031308) {
  48390. return adjustToRange(0, 1, 12.92 * color);
  48391. }
  48392. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48393. }
  48394. function adjustToRange(min, max, value) {
  48395. return Math.max(min, Math.min(max, value));
  48396. }
  48397. function decodeL(L) {
  48398. if (L < 0) {
  48399. return -decodeL(-L);
  48400. }
  48401. if (L > 8.0) {
  48402. return Math.pow((L + 16) / 116, 3);
  48403. }
  48404. return L * DECODE_L_CONSTANT;
  48405. }
  48406. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48407. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48408. result[0] = XYZ_Flat[0];
  48409. result[1] = XYZ_Flat[1];
  48410. result[2] = XYZ_Flat[2];
  48411. return;
  48412. }
  48413. var zeroDecodeL = decodeL(0);
  48414. var X_DST = zeroDecodeL;
  48415. var X_SRC = decodeL(sourceBlackPoint[0]);
  48416. var Y_DST = zeroDecodeL;
  48417. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48418. var Z_DST = zeroDecodeL;
  48419. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48420. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48421. var X_Offset = 1 - X_Scale;
  48422. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48423. var Y_Offset = 1 - Y_Scale;
  48424. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48425. var Z_Offset = 1 - Z_Scale;
  48426. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48427. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48428. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48429. }
  48430. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48431. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48432. result[0] = XYZ_In[0];
  48433. result[1] = XYZ_In[1];
  48434. result[2] = XYZ_In[2];
  48435. return;
  48436. }
  48437. var LMS = result;
  48438. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48439. var LMS_Flat = tempNormalizeMatrix;
  48440. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48441. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48442. }
  48443. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48444. var LMS = result;
  48445. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48446. var LMS_D65 = tempNormalizeMatrix;
  48447. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48448. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48449. }
  48450. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48451. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48452. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48453. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48454. var AGR = Math.pow(A, cs.GR);
  48455. var BGG = Math.pow(B, cs.GG);
  48456. var CGB = Math.pow(C, cs.GB);
  48457. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48458. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48459. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48460. var XYZ = tempConvertMatrix1;
  48461. XYZ[0] = X;
  48462. XYZ[1] = Y;
  48463. XYZ[2] = Z;
  48464. var XYZ_Flat = tempConvertMatrix2;
  48465. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48466. var XYZ_Black = tempConvertMatrix1;
  48467. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48468. var XYZ_D65 = tempConvertMatrix2;
  48469. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48470. var SRGB = tempConvertMatrix1;
  48471. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48472. var sR = sRGBTransferFunction(SRGB[0]);
  48473. var sG = sRGBTransferFunction(SRGB[1]);
  48474. var sB = sRGBTransferFunction(SRGB[2]);
  48475. dest[destOffset] = Math.round(sR * 255);
  48476. dest[destOffset + 1] = Math.round(sG * 255);
  48477. dest[destOffset + 2] = Math.round(sB * 255);
  48478. }
  48479. CalRGBCS.prototype = {
  48480. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48481. var rgb = new Uint8Array(3);
  48482. this.getRgbItem(src, srcOffset, rgb, 0);
  48483. return rgb;
  48484. },
  48485. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48486. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48487. },
  48488. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48489. var scale = 1 / ((1 << bits) - 1);
  48490. for (var i = 0; i < count; ++i) {
  48491. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48492. srcOffset += 3;
  48493. destOffset += 3 + alpha01;
  48494. }
  48495. },
  48496. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48497. return inputLength * (3 + alpha01) / 3 | 0;
  48498. },
  48499. isPassthrough: ColorSpace.prototype.isPassthrough,
  48500. fillRgb: ColorSpace.prototype.fillRgb,
  48501. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48502. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48503. },
  48504. usesZeroToOneRange: true
  48505. };
  48506. return CalRGBCS;
  48507. }();
  48508. var LabCS = function LabCSClosure() {
  48509. function LabCS(whitePoint, blackPoint, range) {
  48510. this.name = 'Lab';
  48511. this.numComps = 3;
  48512. this.defaultColor = new Float32Array([
  48513. 0,
  48514. 0,
  48515. 0
  48516. ]);
  48517. if (!whitePoint) {
  48518. error('WhitePoint missing - required for color space Lab');
  48519. }
  48520. blackPoint = blackPoint || [
  48521. 0,
  48522. 0,
  48523. 0
  48524. ];
  48525. range = range || [
  48526. -100,
  48527. 100,
  48528. -100,
  48529. 100
  48530. ];
  48531. this.XW = whitePoint[0];
  48532. this.YW = whitePoint[1];
  48533. this.ZW = whitePoint[2];
  48534. this.amin = range[0];
  48535. this.amax = range[1];
  48536. this.bmin = range[2];
  48537. this.bmax = range[3];
  48538. this.XB = blackPoint[0];
  48539. this.YB = blackPoint[1];
  48540. this.ZB = blackPoint[2];
  48541. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48542. error('Invalid WhitePoint components, no fallback available');
  48543. }
  48544. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48545. info('Invalid BlackPoint, falling back to default');
  48546. this.XB = this.YB = this.ZB = 0;
  48547. }
  48548. if (this.amin > this.amax || this.bmin > this.bmax) {
  48549. info('Invalid Range, falling back to defaults');
  48550. this.amin = -100;
  48551. this.amax = 100;
  48552. this.bmin = -100;
  48553. this.bmax = 100;
  48554. }
  48555. }
  48556. function fn_g(x) {
  48557. if (x >= 6 / 29) {
  48558. return x * x * x;
  48559. } else {
  48560. return 108 / 841 * (x - 4 / 29);
  48561. }
  48562. }
  48563. function decode(value, high1, low2, high2) {
  48564. return low2 + value * (high2 - low2) / high1;
  48565. }
  48566. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48567. var Ls = src[srcOffset];
  48568. var as = src[srcOffset + 1];
  48569. var bs = src[srcOffset + 2];
  48570. if (maxVal !== false) {
  48571. Ls = decode(Ls, maxVal, 0, 100);
  48572. as = decode(as, maxVal, cs.amin, cs.amax);
  48573. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48574. }
  48575. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48576. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48577. var M = (Ls + 16) / 116;
  48578. var L = M + as / 500;
  48579. var N = M - bs / 200;
  48580. var X = cs.XW * fn_g(L);
  48581. var Y = cs.YW * fn_g(M);
  48582. var Z = cs.ZW * fn_g(N);
  48583. var r, g, b;
  48584. if (cs.ZW < 1) {
  48585. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48586. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48587. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48588. } else {
  48589. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48590. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48591. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48592. }
  48593. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48594. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48595. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48596. }
  48597. LabCS.prototype = {
  48598. getRgb: ColorSpace.prototype.getRgb,
  48599. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48600. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48601. },
  48602. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48603. var maxVal = (1 << bits) - 1;
  48604. for (var i = 0; i < count; i++) {
  48605. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48606. srcOffset += 3;
  48607. destOffset += 3 + alpha01;
  48608. }
  48609. },
  48610. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48611. return inputLength * (3 + alpha01) / 3 | 0;
  48612. },
  48613. isPassthrough: ColorSpace.prototype.isPassthrough,
  48614. fillRgb: ColorSpace.prototype.fillRgb,
  48615. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48616. return true;
  48617. },
  48618. usesZeroToOneRange: false
  48619. };
  48620. return LabCS;
  48621. }();
  48622. exports.ColorSpace = ColorSpace;
  48623. }));
  48624. (function (root, factory) {
  48625. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48626. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48627. var globalScope = sharedUtil.globalScope;
  48628. var deprecated = sharedUtil.deprecated;
  48629. var warn = sharedUtil.warn;
  48630. var LinkTarget = displayDOMUtils.LinkTarget;
  48631. var isWorker = typeof window === 'undefined';
  48632. if (!globalScope.PDFJS) {
  48633. globalScope.PDFJS = {};
  48634. }
  48635. var PDFJS = globalScope.PDFJS;
  48636. if (typeof pdfjsVersion !== 'undefined') {
  48637. PDFJS.version = pdfjsVersion;
  48638. }
  48639. if (typeof pdfjsBuild !== 'undefined') {
  48640. PDFJS.build = pdfjsBuild;
  48641. }
  48642. PDFJS.pdfBug = false;
  48643. if (PDFJS.verbosity !== undefined) {
  48644. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  48645. }
  48646. delete PDFJS.verbosity;
  48647. Object.defineProperty(PDFJS, 'verbosity', {
  48648. get: function () {
  48649. return sharedUtil.getVerbosityLevel();
  48650. },
  48651. set: function (level) {
  48652. sharedUtil.setVerbosityLevel(level);
  48653. },
  48654. enumerable: true,
  48655. configurable: true
  48656. });
  48657. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  48658. PDFJS.OPS = sharedUtil.OPS;
  48659. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  48660. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  48661. PDFJS.shadow = sharedUtil.shadow;
  48662. PDFJS.createBlob = sharedUtil.createBlob;
  48663. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  48664. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  48665. };
  48666. Object.defineProperty(PDFJS, 'isLittleEndian', {
  48667. configurable: true,
  48668. get: function PDFJS_isLittleEndian() {
  48669. var value = sharedUtil.isLittleEndian();
  48670. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  48671. }
  48672. });
  48673. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  48674. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  48675. PDFJS.PasswordException = sharedUtil.PasswordException;
  48676. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  48677. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  48678. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  48679. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  48680. PDFJS.Util = sharedUtil.Util;
  48681. PDFJS.PageViewport = sharedUtil.PageViewport;
  48682. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  48683. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  48684. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  48685. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  48686. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  48687. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  48688. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  48689. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  48690. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  48691. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  48692. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  48693. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  48694. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  48695. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  48696. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  48697. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  48698. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? 'noreferrer' : PDFJS.externalLinkRel;
  48699. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  48700. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  48701. delete PDFJS.openExternalLinksInNewWindow;
  48702. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  48703. get: function () {
  48704. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  48705. },
  48706. set: function (value) {
  48707. if (value) {
  48708. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  48709. }
  48710. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  48711. warn('PDFJS.externalLinkTarget is already initialized');
  48712. return;
  48713. }
  48714. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  48715. },
  48716. enumerable: true,
  48717. configurable: true
  48718. });
  48719. if (savedOpenExternalLinksInNewWindow) {
  48720. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  48721. }
  48722. PDFJS.getDocument = displayAPI.getDocument;
  48723. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  48724. PDFJS.PDFWorker = displayAPI.PDFWorker;
  48725. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  48726. configurable: true,
  48727. get: function PDFJS_hasCanvasTypedArrays() {
  48728. var value = displayDOMUtils.hasCanvasTypedArrays();
  48729. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  48730. }
  48731. });
  48732. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  48733. PDFJS.LinkTarget = LinkTarget;
  48734. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  48735. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  48736. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  48737. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  48738. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  48739. PDFJS.Metadata = displayMetadata.Metadata;
  48740. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  48741. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  48742. exports.globalScope = globalScope;
  48743. exports.isWorker = isWorker;
  48744. exports.PDFJS = globalScope.PDFJS;
  48745. }));
  48746. (function (root, factory) {
  48747. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  48748. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  48749. var ImageKind = sharedUtil.ImageKind;
  48750. var assert = sharedUtil.assert;
  48751. var error = sharedUtil.error;
  48752. var info = sharedUtil.info;
  48753. var isArray = sharedUtil.isArray;
  48754. var warn = sharedUtil.warn;
  48755. var Name = corePrimitives.Name;
  48756. var isStream = corePrimitives.isStream;
  48757. var ColorSpace = coreColorSpace.ColorSpace;
  48758. var DecodeStream = coreStream.DecodeStream;
  48759. var JpegStream = coreStream.JpegStream;
  48760. var JpxImage = coreJpx.JpxImage;
  48761. var PDFImage = function PDFImageClosure() {
  48762. function handleImageData(image, nativeDecoder) {
  48763. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  48764. return nativeDecoder.decode(image);
  48765. } else {
  48766. return Promise.resolve(image);
  48767. }
  48768. }
  48769. function decodeAndClamp(value, addend, coefficient, max) {
  48770. value = addend + value * coefficient;
  48771. return value < 0 ? 0 : value > max ? max : value;
  48772. }
  48773. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48774. var length = w2 * h2;
  48775. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48776. var xRatio = w1 / w2;
  48777. var yRatio = h1 / h2;
  48778. var i, j, py, newIndex = 0, oldIndex;
  48779. var xScaled = new Uint16Array(w2);
  48780. var w1Scanline = w1;
  48781. for (i = 0; i < w2; i++) {
  48782. xScaled[i] = Math.floor(i * xRatio);
  48783. }
  48784. for (i = 0; i < h2; i++) {
  48785. py = Math.floor(i * yRatio) * w1Scanline;
  48786. for (j = 0; j < w2; j++) {
  48787. oldIndex = py + xScaled[j];
  48788. dest[newIndex++] = src[oldIndex];
  48789. }
  48790. }
  48791. return dest;
  48792. }
  48793. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48794. this.image = image;
  48795. var dict = image.dict;
  48796. if (dict.has('Filter')) {
  48797. var filter = dict.get('Filter').name;
  48798. if (filter === 'JPXDecode') {
  48799. var jpxImage = new JpxImage();
  48800. jpxImage.parseImageProperties(image.stream);
  48801. image.stream.reset();
  48802. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48803. image.numComps = jpxImage.componentsCount;
  48804. } else if (filter === 'JBIG2Decode') {
  48805. image.bitsPerComponent = 1;
  48806. image.numComps = 1;
  48807. }
  48808. }
  48809. this.width = dict.get('Width', 'W');
  48810. this.height = dict.get('Height', 'H');
  48811. if (this.width < 1 || this.height < 1) {
  48812. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48813. }
  48814. this.interpolate = dict.get('Interpolate', 'I') || false;
  48815. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48816. this.matte = dict.get('Matte') || false;
  48817. var bitsPerComponent = image.bitsPerComponent;
  48818. if (!bitsPerComponent) {
  48819. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48820. if (!bitsPerComponent) {
  48821. if (this.imageMask) {
  48822. bitsPerComponent = 1;
  48823. } else {
  48824. error('Bits per component missing in image: ' + this.imageMask);
  48825. }
  48826. }
  48827. }
  48828. this.bpc = bitsPerComponent;
  48829. if (!this.imageMask) {
  48830. var colorSpace = dict.get('ColorSpace', 'CS');
  48831. if (!colorSpace) {
  48832. info('JPX images (which do not require color spaces)');
  48833. switch (image.numComps) {
  48834. case 1:
  48835. colorSpace = Name.get('DeviceGray');
  48836. break;
  48837. case 3:
  48838. colorSpace = Name.get('DeviceRGB');
  48839. break;
  48840. case 4:
  48841. colorSpace = Name.get('DeviceCMYK');
  48842. break;
  48843. default:
  48844. error('JPX images with ' + this.numComps + ' color components not supported.');
  48845. }
  48846. }
  48847. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  48848. this.numComps = this.colorSpace.numComps;
  48849. }
  48850. this.decode = dict.getArray('Decode', 'D');
  48851. this.needsDecode = false;
  48852. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  48853. this.needsDecode = true;
  48854. var max = (1 << bitsPerComponent) - 1;
  48855. this.decodeCoefficients = [];
  48856. this.decodeAddends = [];
  48857. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  48858. var dmin = this.decode[i];
  48859. var dmax = this.decode[i + 1];
  48860. this.decodeCoefficients[j] = dmax - dmin;
  48861. this.decodeAddends[j] = max * dmin;
  48862. }
  48863. }
  48864. if (smask) {
  48865. this.smask = new PDFImage(xref, res, smask, false);
  48866. } else if (mask) {
  48867. if (isStream(mask)) {
  48868. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  48869. if (!imageMask) {
  48870. warn('Ignoring /Mask in image without /ImageMask.');
  48871. } else {
  48872. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  48873. }
  48874. } else {
  48875. this.mask = mask;
  48876. }
  48877. }
  48878. }
  48879. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  48880. var imagePromise = handleImageData(image, nativeDecoder);
  48881. var smaskPromise;
  48882. var maskPromise;
  48883. var smask = image.dict.get('SMask');
  48884. var mask = image.dict.get('Mask');
  48885. if (smask) {
  48886. smaskPromise = handleImageData(smask, nativeDecoder);
  48887. maskPromise = Promise.resolve(null);
  48888. } else {
  48889. smaskPromise = Promise.resolve(null);
  48890. if (mask) {
  48891. if (isStream(mask)) {
  48892. maskPromise = handleImageData(mask, nativeDecoder);
  48893. } else if (isArray(mask)) {
  48894. maskPromise = Promise.resolve(mask);
  48895. } else {
  48896. warn('Unsupported mask format.');
  48897. maskPromise = Promise.resolve(null);
  48898. }
  48899. } else {
  48900. maskPromise = Promise.resolve(null);
  48901. }
  48902. }
  48903. return Promise.all([
  48904. imagePromise,
  48905. smaskPromise,
  48906. maskPromise
  48907. ]).then(function (results) {
  48908. var imageData = results[0];
  48909. var smaskData = results[1];
  48910. var maskData = results[2];
  48911. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  48912. });
  48913. };
  48914. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  48915. var computedLength = (width + 7 >> 3) * height;
  48916. var actualLength = imgArray.byteLength;
  48917. var haveFullData = computedLength === actualLength;
  48918. var data, i;
  48919. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  48920. data = imgArray;
  48921. } else if (!inverseDecode) {
  48922. data = new Uint8Array(actualLength);
  48923. data.set(imgArray);
  48924. } else {
  48925. data = new Uint8Array(computedLength);
  48926. data.set(imgArray);
  48927. for (i = actualLength; i < computedLength; i++) {
  48928. data[i] = 0xff;
  48929. }
  48930. }
  48931. if (inverseDecode) {
  48932. for (i = 0; i < actualLength; i++) {
  48933. data[i] = ~data[i];
  48934. }
  48935. }
  48936. return {
  48937. data: data,
  48938. width: width,
  48939. height: height
  48940. };
  48941. };
  48942. PDFImage.prototype = {
  48943. get drawWidth() {
  48944. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  48945. },
  48946. get drawHeight() {
  48947. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  48948. },
  48949. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  48950. var bpc = this.bpc;
  48951. var numComps = this.numComps;
  48952. var decodeAddends = this.decodeAddends;
  48953. var decodeCoefficients = this.decodeCoefficients;
  48954. var max = (1 << bpc) - 1;
  48955. var i, ii;
  48956. if (bpc === 1) {
  48957. for (i = 0, ii = buffer.length; i < ii; i++) {
  48958. buffer[i] = +!buffer[i];
  48959. }
  48960. return;
  48961. }
  48962. var index = 0;
  48963. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  48964. for (var j = 0; j < numComps; j++) {
  48965. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  48966. index++;
  48967. }
  48968. }
  48969. },
  48970. getComponents: function PDFImage_getComponents(buffer) {
  48971. var bpc = this.bpc;
  48972. if (bpc === 8) {
  48973. return buffer;
  48974. }
  48975. var width = this.width;
  48976. var height = this.height;
  48977. var numComps = this.numComps;
  48978. var length = width * height * numComps;
  48979. var bufferPos = 0;
  48980. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48981. var rowComps = width * numComps;
  48982. var max = (1 << bpc) - 1;
  48983. var i = 0, ii, buf;
  48984. if (bpc === 1) {
  48985. var mask, loop1End, loop2End;
  48986. for (var j = 0; j < height; j++) {
  48987. loop1End = i + (rowComps & ~7);
  48988. loop2End = i + rowComps;
  48989. while (i < loop1End) {
  48990. buf = buffer[bufferPos++];
  48991. output[i] = buf >> 7 & 1;
  48992. output[i + 1] = buf >> 6 & 1;
  48993. output[i + 2] = buf >> 5 & 1;
  48994. output[i + 3] = buf >> 4 & 1;
  48995. output[i + 4] = buf >> 3 & 1;
  48996. output[i + 5] = buf >> 2 & 1;
  48997. output[i + 6] = buf >> 1 & 1;
  48998. output[i + 7] = buf & 1;
  48999. i += 8;
  49000. }
  49001. if (i < loop2End) {
  49002. buf = buffer[bufferPos++];
  49003. mask = 128;
  49004. while (i < loop2End) {
  49005. output[i++] = +!!(buf & mask);
  49006. mask >>= 1;
  49007. }
  49008. }
  49009. }
  49010. } else {
  49011. var bits = 0;
  49012. buf = 0;
  49013. for (i = 0, ii = length; i < ii; ++i) {
  49014. if (i % rowComps === 0) {
  49015. buf = 0;
  49016. bits = 0;
  49017. }
  49018. while (bits < bpc) {
  49019. buf = buf << 8 | buffer[bufferPos++];
  49020. bits += 8;
  49021. }
  49022. var remainingBits = bits - bpc;
  49023. var value = buf >> remainingBits;
  49024. output[i] = value < 0 ? 0 : value > max ? max : value;
  49025. buf = buf & (1 << remainingBits) - 1;
  49026. bits = remainingBits;
  49027. }
  49028. }
  49029. return output;
  49030. },
  49031. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49032. var smask = this.smask;
  49033. var mask = this.mask;
  49034. var alphaBuf, sw, sh, i, ii, j;
  49035. if (smask) {
  49036. sw = smask.width;
  49037. sh = smask.height;
  49038. alphaBuf = new Uint8Array(sw * sh);
  49039. smask.fillGrayBuffer(alphaBuf);
  49040. if (sw !== width || sh !== height) {
  49041. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49042. }
  49043. } else if (mask) {
  49044. if (mask instanceof PDFImage) {
  49045. sw = mask.width;
  49046. sh = mask.height;
  49047. alphaBuf = new Uint8Array(sw * sh);
  49048. mask.numComps = 1;
  49049. mask.fillGrayBuffer(alphaBuf);
  49050. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49051. alphaBuf[i] = 255 - alphaBuf[i];
  49052. }
  49053. if (sw !== width || sh !== height) {
  49054. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49055. }
  49056. } else if (isArray(mask)) {
  49057. alphaBuf = new Uint8Array(width * height);
  49058. var numComps = this.numComps;
  49059. for (i = 0, ii = width * height; i < ii; ++i) {
  49060. var opacity = 0;
  49061. var imageOffset = i * numComps;
  49062. for (j = 0; j < numComps; ++j) {
  49063. var color = image[imageOffset + j];
  49064. var maskOffset = j * 2;
  49065. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49066. opacity = 255;
  49067. break;
  49068. }
  49069. }
  49070. alphaBuf[i] = opacity;
  49071. }
  49072. } else {
  49073. error('Unknown mask format.');
  49074. }
  49075. }
  49076. if (alphaBuf) {
  49077. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49078. rgbaBuf[j] = alphaBuf[i];
  49079. }
  49080. } else {
  49081. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49082. rgbaBuf[j] = 255;
  49083. }
  49084. }
  49085. },
  49086. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49087. var matte = this.smask && this.smask.matte;
  49088. if (!matte) {
  49089. return;
  49090. }
  49091. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49092. var matteR = matteRgb[0];
  49093. var matteG = matteRgb[1];
  49094. var matteB = matteRgb[2];
  49095. var length = width * height * 4;
  49096. var r, g, b;
  49097. for (var i = 0; i < length; i += 4) {
  49098. var alpha = buffer[i + 3];
  49099. if (alpha === 0) {
  49100. buffer[i] = 255;
  49101. buffer[i + 1] = 255;
  49102. buffer[i + 2] = 255;
  49103. continue;
  49104. }
  49105. var k = 255 / alpha;
  49106. r = (buffer[i] - matteR) * k + matteR;
  49107. g = (buffer[i + 1] - matteG) * k + matteG;
  49108. b = (buffer[i + 2] - matteB) * k + matteB;
  49109. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49110. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49111. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49112. }
  49113. },
  49114. createImageData: function PDFImage_createImageData(forceRGBA) {
  49115. var drawWidth = this.drawWidth;
  49116. var drawHeight = this.drawHeight;
  49117. var imgData = {
  49118. width: drawWidth,
  49119. height: drawHeight
  49120. };
  49121. var numComps = this.numComps;
  49122. var originalWidth = this.width;
  49123. var originalHeight = this.height;
  49124. var bpc = this.bpc;
  49125. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49126. var imgArray;
  49127. if (!forceRGBA) {
  49128. var kind;
  49129. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49130. kind = ImageKind.GRAYSCALE_1BPP;
  49131. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49132. kind = ImageKind.RGB_24BPP;
  49133. }
  49134. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49135. imgData.kind = kind;
  49136. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49137. if (this.image instanceof DecodeStream) {
  49138. imgData.data = imgArray;
  49139. } else {
  49140. var newArray = new Uint8Array(imgArray.length);
  49141. newArray.set(imgArray);
  49142. imgData.data = newArray;
  49143. }
  49144. if (this.needsDecode) {
  49145. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49146. var buffer = imgData.data;
  49147. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49148. buffer[i] ^= 0xff;
  49149. }
  49150. }
  49151. return imgData;
  49152. }
  49153. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49154. imgData.kind = ImageKind.RGB_24BPP;
  49155. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49156. return imgData;
  49157. }
  49158. }
  49159. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49160. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49161. var comps = this.getComponents(imgArray);
  49162. var alpha01, maybeUndoPreblend;
  49163. if (!forceRGBA && !this.smask && !this.mask) {
  49164. imgData.kind = ImageKind.RGB_24BPP;
  49165. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49166. alpha01 = 0;
  49167. maybeUndoPreblend = false;
  49168. } else {
  49169. imgData.kind = ImageKind.RGBA_32BPP;
  49170. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49171. alpha01 = 1;
  49172. maybeUndoPreblend = true;
  49173. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49174. }
  49175. if (this.needsDecode) {
  49176. this.decodeBuffer(comps);
  49177. }
  49178. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49179. if (maybeUndoPreblend) {
  49180. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49181. }
  49182. return imgData;
  49183. },
  49184. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49185. var numComps = this.numComps;
  49186. if (numComps !== 1) {
  49187. error('Reading gray scale from a color image: ' + numComps);
  49188. }
  49189. var width = this.width;
  49190. var height = this.height;
  49191. var bpc = this.bpc;
  49192. var rowBytes = width * numComps * bpc + 7 >> 3;
  49193. var imgArray = this.getImageBytes(height * rowBytes);
  49194. var comps = this.getComponents(imgArray);
  49195. var i, length;
  49196. if (bpc === 1) {
  49197. length = width * height;
  49198. if (this.needsDecode) {
  49199. for (i = 0; i < length; ++i) {
  49200. buffer[i] = comps[i] - 1 & 255;
  49201. }
  49202. } else {
  49203. for (i = 0; i < length; ++i) {
  49204. buffer[i] = -comps[i] & 255;
  49205. }
  49206. }
  49207. return;
  49208. }
  49209. if (this.needsDecode) {
  49210. this.decodeBuffer(comps);
  49211. }
  49212. length = width * height;
  49213. var scale = 255 / ((1 << bpc) - 1);
  49214. for (i = 0; i < length; ++i) {
  49215. buffer[i] = scale * comps[i] | 0;
  49216. }
  49217. },
  49218. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49219. this.image.reset();
  49220. this.image.drawWidth = drawWidth || this.width;
  49221. this.image.drawHeight = drawHeight || this.height;
  49222. this.image.forceRGB = !!forceRGB;
  49223. return this.image.getBytes(length);
  49224. }
  49225. };
  49226. return PDFImage;
  49227. }();
  49228. exports.PDFImage = PDFImage;
  49229. }));
  49230. (function (root, factory) {
  49231. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49232. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49233. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49234. var MissingDataException = sharedUtil.MissingDataException;
  49235. var XRefParseException = sharedUtil.XRefParseException;
  49236. var assert = sharedUtil.assert;
  49237. var bytesToString = sharedUtil.bytesToString;
  49238. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49239. var error = sharedUtil.error;
  49240. var info = sharedUtil.info;
  49241. var isArray = sharedUtil.isArray;
  49242. var isBool = sharedUtil.isBool;
  49243. var isInt = sharedUtil.isInt;
  49244. var isString = sharedUtil.isString;
  49245. var shadow = sharedUtil.shadow;
  49246. var stringToPDFString = sharedUtil.stringToPDFString;
  49247. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49248. var warn = sharedUtil.warn;
  49249. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49250. var Util = sharedUtil.Util;
  49251. var Ref = corePrimitives.Ref;
  49252. var RefSet = corePrimitives.RefSet;
  49253. var RefSetCache = corePrimitives.RefSetCache;
  49254. var isName = corePrimitives.isName;
  49255. var isCmd = corePrimitives.isCmd;
  49256. var isDict = corePrimitives.isDict;
  49257. var isRef = corePrimitives.isRef;
  49258. var isRefsEqual = corePrimitives.isRefsEqual;
  49259. var isStream = corePrimitives.isStream;
  49260. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49261. var Lexer = coreParser.Lexer;
  49262. var Parser = coreParser.Parser;
  49263. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49264. var ColorSpace = coreColorSpace.ColorSpace;
  49265. var Catalog = function CatalogClosure() {
  49266. function Catalog(pdfManager, xref, pageFactory) {
  49267. this.pdfManager = pdfManager;
  49268. this.xref = xref;
  49269. this.catDict = xref.getCatalogObj();
  49270. this.fontCache = new RefSetCache();
  49271. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49272. this.pageFactory = pageFactory;
  49273. this.pagePromises = [];
  49274. }
  49275. Catalog.prototype = {
  49276. get metadata() {
  49277. var streamRef = this.catDict.getRaw('Metadata');
  49278. if (!isRef(streamRef)) {
  49279. return shadow(this, 'metadata', null);
  49280. }
  49281. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49282. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49283. var metadata;
  49284. if (stream && isDict(stream.dict)) {
  49285. var type = stream.dict.get('Type');
  49286. var subtype = stream.dict.get('Subtype');
  49287. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49288. try {
  49289. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49290. } catch (e) {
  49291. info('Skipping invalid metadata.');
  49292. }
  49293. }
  49294. }
  49295. return shadow(this, 'metadata', metadata);
  49296. },
  49297. get toplevelPagesDict() {
  49298. var pagesObj = this.catDict.get('Pages');
  49299. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49300. return shadow(this, 'toplevelPagesDict', pagesObj);
  49301. },
  49302. get documentOutline() {
  49303. var obj = null;
  49304. try {
  49305. obj = this.readDocumentOutline();
  49306. } catch (ex) {
  49307. if (ex instanceof MissingDataException) {
  49308. throw ex;
  49309. }
  49310. warn('Unable to read document outline');
  49311. }
  49312. return shadow(this, 'documentOutline', obj);
  49313. },
  49314. readDocumentOutline: function Catalog_readDocumentOutline() {
  49315. var obj = this.catDict.get('Outlines');
  49316. if (!isDict(obj)) {
  49317. return null;
  49318. }
  49319. obj = obj.getRaw('First');
  49320. if (!isRef(obj)) {
  49321. return null;
  49322. }
  49323. var root = { items: [] };
  49324. var queue = [{
  49325. obj: obj,
  49326. parent: root
  49327. }];
  49328. var processed = new RefSet();
  49329. processed.put(obj);
  49330. var xref = this.xref, blackColor = new Uint8Array(3);
  49331. while (queue.length > 0) {
  49332. var i = queue.shift();
  49333. var outlineDict = xref.fetchIfRef(i.obj);
  49334. if (outlineDict === null) {
  49335. continue;
  49336. }
  49337. assert(outlineDict.has('Title'), 'Invalid outline item');
  49338. var data = {
  49339. url: null,
  49340. dest: null
  49341. };
  49342. Catalog.parseDestDictionary({
  49343. destDict: outlineDict,
  49344. resultObj: data,
  49345. docBaseUrl: this.pdfManager.docBaseUrl
  49346. });
  49347. var title = outlineDict.get('Title');
  49348. var flags = outlineDict.get('F') || 0;
  49349. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49350. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49351. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49352. }
  49353. var outlineItem = {
  49354. dest: data.dest,
  49355. url: data.url,
  49356. unsafeUrl: data.unsafeUrl,
  49357. newWindow: data.newWindow,
  49358. title: stringToPDFString(title),
  49359. color: rgbColor,
  49360. count: outlineDict.get('Count'),
  49361. bold: !!(flags & 2),
  49362. italic: !!(flags & 1),
  49363. items: []
  49364. };
  49365. i.parent.items.push(outlineItem);
  49366. obj = outlineDict.getRaw('First');
  49367. if (isRef(obj) && !processed.has(obj)) {
  49368. queue.push({
  49369. obj: obj,
  49370. parent: outlineItem
  49371. });
  49372. processed.put(obj);
  49373. }
  49374. obj = outlineDict.getRaw('Next');
  49375. if (isRef(obj) && !processed.has(obj)) {
  49376. queue.push({
  49377. obj: obj,
  49378. parent: i.parent
  49379. });
  49380. processed.put(obj);
  49381. }
  49382. }
  49383. return root.items.length > 0 ? root.items : null;
  49384. },
  49385. get numPages() {
  49386. var obj = this.toplevelPagesDict.get('Count');
  49387. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49388. return shadow(this, 'num', obj);
  49389. },
  49390. get destinations() {
  49391. function fetchDestination(dest) {
  49392. return isDict(dest) ? dest.get('D') : dest;
  49393. }
  49394. var xref = this.xref;
  49395. var dests = {}, nameTreeRef, nameDictionaryRef;
  49396. var obj = this.catDict.get('Names');
  49397. if (obj && obj.has('Dests')) {
  49398. nameTreeRef = obj.getRaw('Dests');
  49399. } else if (this.catDict.has('Dests')) {
  49400. nameDictionaryRef = this.catDict.get('Dests');
  49401. }
  49402. if (nameDictionaryRef) {
  49403. obj = nameDictionaryRef;
  49404. obj.forEach(function catalogForEach(key, value) {
  49405. if (!value) {
  49406. return;
  49407. }
  49408. dests[key] = fetchDestination(value);
  49409. });
  49410. }
  49411. if (nameTreeRef) {
  49412. var nameTree = new NameTree(nameTreeRef, xref);
  49413. var names = nameTree.getAll();
  49414. for (var name in names) {
  49415. dests[name] = fetchDestination(names[name]);
  49416. }
  49417. }
  49418. return shadow(this, 'destinations', dests);
  49419. },
  49420. getDestination: function Catalog_getDestination(destinationId) {
  49421. function fetchDestination(dest) {
  49422. return isDict(dest) ? dest.get('D') : dest;
  49423. }
  49424. var xref = this.xref;
  49425. var dest = null, nameTreeRef, nameDictionaryRef;
  49426. var obj = this.catDict.get('Names');
  49427. if (obj && obj.has('Dests')) {
  49428. nameTreeRef = obj.getRaw('Dests');
  49429. } else if (this.catDict.has('Dests')) {
  49430. nameDictionaryRef = this.catDict.get('Dests');
  49431. }
  49432. if (nameDictionaryRef) {
  49433. var value = nameDictionaryRef.get(destinationId);
  49434. if (value) {
  49435. dest = fetchDestination(value);
  49436. }
  49437. }
  49438. if (nameTreeRef) {
  49439. var nameTree = new NameTree(nameTreeRef, xref);
  49440. dest = fetchDestination(nameTree.get(destinationId));
  49441. }
  49442. return dest;
  49443. },
  49444. get pageLabels() {
  49445. var obj = null;
  49446. try {
  49447. obj = this.readPageLabels();
  49448. } catch (ex) {
  49449. if (ex instanceof MissingDataException) {
  49450. throw ex;
  49451. }
  49452. warn('Unable to read page labels.');
  49453. }
  49454. return shadow(this, 'pageLabels', obj);
  49455. },
  49456. readPageLabels: function Catalog_readPageLabels() {
  49457. var obj = this.catDict.getRaw('PageLabels');
  49458. if (!obj) {
  49459. return null;
  49460. }
  49461. var pageLabels = new Array(this.numPages);
  49462. var style = null;
  49463. var prefix = '';
  49464. var numberTree = new NumberTree(obj, this.xref);
  49465. var nums = numberTree.getAll();
  49466. var currentLabel = '', currentIndex = 1;
  49467. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49468. if (i in nums) {
  49469. var labelDict = nums[i];
  49470. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49471. var type = labelDict.get('Type');
  49472. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49473. var s = labelDict.get('S');
  49474. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49475. style = s ? s.name : null;
  49476. var p = labelDict.get('P');
  49477. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49478. prefix = p ? stringToPDFString(p) : '';
  49479. var st = labelDict.get('St');
  49480. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49481. currentIndex = st || 1;
  49482. }
  49483. switch (style) {
  49484. case 'D':
  49485. currentLabel = currentIndex;
  49486. break;
  49487. case 'R':
  49488. case 'r':
  49489. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49490. break;
  49491. case 'A':
  49492. case 'a':
  49493. var LIMIT = 26;
  49494. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49495. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49496. var letterIndex = currentIndex - 1;
  49497. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49498. var charBuf = [];
  49499. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49500. charBuf.push(character);
  49501. }
  49502. currentLabel = charBuf.join('');
  49503. break;
  49504. default:
  49505. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49506. }
  49507. pageLabels[i] = prefix + currentLabel;
  49508. currentLabel = '';
  49509. currentIndex++;
  49510. }
  49511. return pageLabels;
  49512. },
  49513. get attachments() {
  49514. var xref = this.xref;
  49515. var attachments = null, nameTreeRef;
  49516. var obj = this.catDict.get('Names');
  49517. if (obj) {
  49518. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49519. }
  49520. if (nameTreeRef) {
  49521. var nameTree = new NameTree(nameTreeRef, xref);
  49522. var names = nameTree.getAll();
  49523. for (var name in names) {
  49524. var fs = new FileSpec(names[name], xref);
  49525. if (!attachments) {
  49526. attachments = Object.create(null);
  49527. }
  49528. attachments[stringToPDFString(name)] = fs.serializable;
  49529. }
  49530. }
  49531. return shadow(this, 'attachments', attachments);
  49532. },
  49533. get javaScript() {
  49534. var xref = this.xref;
  49535. var obj = this.catDict.get('Names');
  49536. var javaScript = [];
  49537. function appendIfJavaScriptDict(jsDict) {
  49538. var type = jsDict.get('S');
  49539. if (!isName(type, 'JavaScript')) {
  49540. return;
  49541. }
  49542. var js = jsDict.get('JS');
  49543. if (isStream(js)) {
  49544. js = bytesToString(js.getBytes());
  49545. } else if (!isString(js)) {
  49546. return;
  49547. }
  49548. javaScript.push(stringToPDFString(js));
  49549. }
  49550. if (obj && obj.has('JavaScript')) {
  49551. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49552. var names = nameTree.getAll();
  49553. for (var name in names) {
  49554. var jsDict = names[name];
  49555. if (isDict(jsDict)) {
  49556. appendIfJavaScriptDict(jsDict);
  49557. }
  49558. }
  49559. }
  49560. var openactionDict = this.catDict.get('OpenAction');
  49561. if (isDict(openactionDict, 'Action')) {
  49562. var actionType = openactionDict.get('S');
  49563. if (isName(actionType, 'Named')) {
  49564. var action = openactionDict.get('N');
  49565. if (isName(action, 'Print')) {
  49566. javaScript.push('print({});');
  49567. }
  49568. } else {
  49569. appendIfJavaScriptDict(openactionDict);
  49570. }
  49571. }
  49572. return shadow(this, 'javaScript', javaScript);
  49573. },
  49574. cleanup: function Catalog_cleanup() {
  49575. var promises = [];
  49576. this.fontCache.forEach(function (promise) {
  49577. promises.push(promise);
  49578. });
  49579. return Promise.all(promises).then(function (translatedFonts) {
  49580. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49581. var font = translatedFonts[i].dict;
  49582. delete font.translated;
  49583. }
  49584. this.fontCache.clear();
  49585. }.bind(this));
  49586. },
  49587. getPage: function Catalog_getPage(pageIndex) {
  49588. if (!(pageIndex in this.pagePromises)) {
  49589. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49590. var dict = a[0];
  49591. var ref = a[1];
  49592. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49593. }.bind(this));
  49594. }
  49595. return this.pagePromises[pageIndex];
  49596. },
  49597. getPageDict: function Catalog_getPageDict(pageIndex) {
  49598. var capability = createPromiseCapability();
  49599. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49600. var currentPageIndex = 0;
  49601. var xref = this.xref;
  49602. var checkAllKids = false;
  49603. function next() {
  49604. while (nodesToVisit.length) {
  49605. var currentNode = nodesToVisit.pop();
  49606. if (isRef(currentNode)) {
  49607. xref.fetchAsync(currentNode).then(function (obj) {
  49608. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49609. if (pageIndex === currentPageIndex) {
  49610. capability.resolve([
  49611. obj,
  49612. currentNode
  49613. ]);
  49614. } else {
  49615. currentPageIndex++;
  49616. next();
  49617. }
  49618. return;
  49619. }
  49620. nodesToVisit.push(obj);
  49621. next();
  49622. }, capability.reject);
  49623. return;
  49624. }
  49625. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49626. var count = currentNode.get('Count');
  49627. if (count === 0) {
  49628. checkAllKids = true;
  49629. }
  49630. if (currentPageIndex + count <= pageIndex) {
  49631. currentPageIndex += count;
  49632. continue;
  49633. }
  49634. var kids = currentNode.get('Kids');
  49635. assert(isArray(kids), 'page dictionary kids object is not an array');
  49636. if (!checkAllKids && count === kids.length) {
  49637. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49638. currentPageIndex = pageIndex;
  49639. continue;
  49640. } else {
  49641. for (var last = kids.length - 1; last >= 0; last--) {
  49642. nodesToVisit.push(kids[last]);
  49643. }
  49644. }
  49645. }
  49646. capability.reject('Page index ' + pageIndex + ' not found.');
  49647. }
  49648. next();
  49649. return capability.promise;
  49650. },
  49651. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49652. var xref = this.xref;
  49653. function pagesBeforeRef(kidRef) {
  49654. var total = 0;
  49655. var parentRef;
  49656. return xref.fetchAsync(kidRef).then(function (node) {
  49657. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49658. throw new Error('The reference does not point to a /Page Dict.');
  49659. }
  49660. if (!node) {
  49661. return null;
  49662. }
  49663. assert(isDict(node), 'node must be a Dict.');
  49664. parentRef = node.getRaw('Parent');
  49665. return node.getAsync('Parent');
  49666. }).then(function (parent) {
  49667. if (!parent) {
  49668. return null;
  49669. }
  49670. assert(isDict(parent), 'parent must be a Dict.');
  49671. return parent.getAsync('Kids');
  49672. }).then(function (kids) {
  49673. if (!kids) {
  49674. return null;
  49675. }
  49676. var kidPromises = [];
  49677. var found = false;
  49678. for (var i = 0; i < kids.length; i++) {
  49679. var kid = kids[i];
  49680. assert(isRef(kid), 'kid must be a Ref.');
  49681. if (kid.num === kidRef.num) {
  49682. found = true;
  49683. break;
  49684. }
  49685. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49686. if (kid.has('Count')) {
  49687. var count = kid.get('Count');
  49688. total += count;
  49689. } else {
  49690. total++;
  49691. }
  49692. }));
  49693. }
  49694. if (!found) {
  49695. error('kid ref not found in parents kids');
  49696. }
  49697. return Promise.all(kidPromises).then(function () {
  49698. return [
  49699. total,
  49700. parentRef
  49701. ];
  49702. });
  49703. });
  49704. }
  49705. var total = 0;
  49706. function next(ref) {
  49707. return pagesBeforeRef(ref).then(function (args) {
  49708. if (!args) {
  49709. return total;
  49710. }
  49711. var count = args[0];
  49712. var parentRef = args[1];
  49713. total += count;
  49714. return next(parentRef);
  49715. });
  49716. }
  49717. return next(pageRef);
  49718. }
  49719. };
  49720. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49721. function addDefaultProtocolToUrl(url) {
  49722. if (url.indexOf('www.') === 0) {
  49723. return 'http://' + url;
  49724. }
  49725. return url;
  49726. }
  49727. function tryConvertUrlEncoding(url) {
  49728. try {
  49729. return stringToUTF8String(url);
  49730. } catch (e) {
  49731. return url;
  49732. }
  49733. }
  49734. var destDict = params.destDict;
  49735. if (!isDict(destDict)) {
  49736. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49737. return;
  49738. }
  49739. var resultObj = params.resultObj;
  49740. if (typeof resultObj !== 'object') {
  49741. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49742. return;
  49743. }
  49744. var docBaseUrl = params.docBaseUrl || null;
  49745. var action = destDict.get('A'), url, dest;
  49746. if (isDict(action)) {
  49747. var linkType = action.get('S').name;
  49748. switch (linkType) {
  49749. case 'URI':
  49750. url = action.get('URI');
  49751. if (isName(url)) {
  49752. url = '/' + url.name;
  49753. } else if (isString(url)) {
  49754. url = addDefaultProtocolToUrl(url);
  49755. }
  49756. break;
  49757. case 'GoTo':
  49758. dest = action.get('D');
  49759. break;
  49760. case 'Launch':
  49761. case 'GoToR':
  49762. var urlDict = action.get('F');
  49763. if (isDict(urlDict)) {
  49764. url = urlDict.get('F') || null;
  49765. } else if (isString(urlDict)) {
  49766. url = urlDict;
  49767. }
  49768. var remoteDest = action.get('D');
  49769. if (remoteDest) {
  49770. if (isName(remoteDest)) {
  49771. remoteDest = remoteDest.name;
  49772. }
  49773. if (isString(url)) {
  49774. var baseUrl = url.split('#')[0];
  49775. if (isString(remoteDest)) {
  49776. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49777. } else if (isArray(remoteDest)) {
  49778. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49779. }
  49780. }
  49781. }
  49782. var newWindow = action.get('NewWindow');
  49783. if (isBool(newWindow)) {
  49784. resultObj.newWindow = newWindow;
  49785. }
  49786. break;
  49787. case 'Named':
  49788. var namedAction = action.get('N');
  49789. if (isName(namedAction)) {
  49790. resultObj.action = namedAction.name;
  49791. }
  49792. break;
  49793. case 'JavaScript':
  49794. var jsAction = action.get('JS'), js;
  49795. if (isStream(jsAction)) {
  49796. js = bytesToString(jsAction.getBytes());
  49797. } else if (isString(jsAction)) {
  49798. js = jsAction;
  49799. }
  49800. if (js) {
  49801. var URL_OPEN_METHODS = [
  49802. 'app.launchURL',
  49803. 'window.open'
  49804. ];
  49805. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49806. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49807. if (jsUrl && jsUrl[1]) {
  49808. url = jsUrl[1];
  49809. break;
  49810. }
  49811. }
  49812. default:
  49813. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49814. break;
  49815. }
  49816. } else if (destDict.has('Dest')) {
  49817. dest = destDict.get('Dest');
  49818. }
  49819. if (isString(url)) {
  49820. url = tryConvertUrlEncoding(url);
  49821. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49822. if (absoluteUrl) {
  49823. resultObj.url = absoluteUrl.href;
  49824. }
  49825. resultObj.unsafeUrl = url;
  49826. }
  49827. if (dest) {
  49828. if (isName(dest)) {
  49829. dest = dest.name;
  49830. }
  49831. if (isString(dest) || isArray(dest)) {
  49832. resultObj.dest = dest;
  49833. }
  49834. }
  49835. };
  49836. return Catalog;
  49837. }();
  49838. var XRef = function XRefClosure() {
  49839. function XRef(stream, password) {
  49840. this.stream = stream;
  49841. this.entries = [];
  49842. this.xrefstms = Object.create(null);
  49843. this.cache = [];
  49844. this.password = password;
  49845. this.stats = {
  49846. streamTypes: [],
  49847. fontTypes: []
  49848. };
  49849. }
  49850. XRef.prototype = {
  49851. setStartXRef: function XRef_setStartXRef(startXRef) {
  49852. this.startXRefQueue = [startXRef];
  49853. },
  49854. parse: function XRef_parse(recoveryMode) {
  49855. var trailerDict;
  49856. if (!recoveryMode) {
  49857. trailerDict = this.readXRef();
  49858. } else {
  49859. warn('Indexing all PDF objects');
  49860. trailerDict = this.indexObjects();
  49861. }
  49862. trailerDict.assignXref(this);
  49863. this.trailer = trailerDict;
  49864. var encrypt = trailerDict.get('Encrypt');
  49865. if (encrypt) {
  49866. var ids = trailerDict.get('ID');
  49867. var fileId = ids && ids.length ? ids[0] : '';
  49868. encrypt.suppressEncryption = true;
  49869. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  49870. }
  49871. if (!(this.root = trailerDict.get('Root'))) {
  49872. error('Invalid root reference');
  49873. }
  49874. },
  49875. processXRefTable: function XRef_processXRefTable(parser) {
  49876. if (!('tableState' in this)) {
  49877. this.tableState = {
  49878. entryNum: 0,
  49879. streamPos: parser.lexer.stream.pos,
  49880. parserBuf1: parser.buf1,
  49881. parserBuf2: parser.buf2
  49882. };
  49883. }
  49884. var obj = this.readXRefTable(parser);
  49885. if (!isCmd(obj, 'trailer')) {
  49886. error('Invalid XRef table: could not find trailer dictionary');
  49887. }
  49888. var dict = parser.getObj();
  49889. if (!isDict(dict) && dict.dict) {
  49890. dict = dict.dict;
  49891. }
  49892. if (!isDict(dict)) {
  49893. error('Invalid XRef table: could not parse trailer dictionary');
  49894. }
  49895. delete this.tableState;
  49896. return dict;
  49897. },
  49898. readXRefTable: function XRef_readXRefTable(parser) {
  49899. var stream = parser.lexer.stream;
  49900. var tableState = this.tableState;
  49901. stream.pos = tableState.streamPos;
  49902. parser.buf1 = tableState.parserBuf1;
  49903. parser.buf2 = tableState.parserBuf2;
  49904. var obj;
  49905. while (true) {
  49906. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  49907. if (isCmd(obj = parser.getObj(), 'trailer')) {
  49908. break;
  49909. }
  49910. tableState.firstEntryNum = obj;
  49911. tableState.entryCount = parser.getObj();
  49912. }
  49913. var first = tableState.firstEntryNum;
  49914. var count = tableState.entryCount;
  49915. if (!isInt(first) || !isInt(count)) {
  49916. error('Invalid XRef table: wrong types in subsection header');
  49917. }
  49918. for (var i = tableState.entryNum; i < count; i++) {
  49919. tableState.streamPos = stream.pos;
  49920. tableState.entryNum = i;
  49921. tableState.parserBuf1 = parser.buf1;
  49922. tableState.parserBuf2 = parser.buf2;
  49923. var entry = {};
  49924. entry.offset = parser.getObj();
  49925. entry.gen = parser.getObj();
  49926. var type = parser.getObj();
  49927. if (isCmd(type, 'f')) {
  49928. entry.free = true;
  49929. } else if (isCmd(type, 'n')) {
  49930. entry.uncompressed = true;
  49931. }
  49932. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  49933. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  49934. }
  49935. if (i === 0 && entry.free && first === 1) {
  49936. first = 0;
  49937. }
  49938. if (!this.entries[i + first]) {
  49939. this.entries[i + first] = entry;
  49940. }
  49941. }
  49942. tableState.entryNum = 0;
  49943. tableState.streamPos = stream.pos;
  49944. tableState.parserBuf1 = parser.buf1;
  49945. tableState.parserBuf2 = parser.buf2;
  49946. delete tableState.firstEntryNum;
  49947. delete tableState.entryCount;
  49948. }
  49949. if (this.entries[0] && !this.entries[0].free) {
  49950. error('Invalid XRef table: unexpected first object');
  49951. }
  49952. return obj;
  49953. },
  49954. processXRefStream: function XRef_processXRefStream(stream) {
  49955. if (!('streamState' in this)) {
  49956. var streamParameters = stream.dict;
  49957. var byteWidths = streamParameters.get('W');
  49958. var range = streamParameters.get('Index');
  49959. if (!range) {
  49960. range = [
  49961. 0,
  49962. streamParameters.get('Size')
  49963. ];
  49964. }
  49965. this.streamState = {
  49966. entryRanges: range,
  49967. byteWidths: byteWidths,
  49968. entryNum: 0,
  49969. streamPos: stream.pos
  49970. };
  49971. }
  49972. this.readXRefStream(stream);
  49973. delete this.streamState;
  49974. return stream.dict;
  49975. },
  49976. readXRefStream: function XRef_readXRefStream(stream) {
  49977. var i, j;
  49978. var streamState = this.streamState;
  49979. stream.pos = streamState.streamPos;
  49980. var byteWidths = streamState.byteWidths;
  49981. var typeFieldWidth = byteWidths[0];
  49982. var offsetFieldWidth = byteWidths[1];
  49983. var generationFieldWidth = byteWidths[2];
  49984. var entryRanges = streamState.entryRanges;
  49985. while (entryRanges.length > 0) {
  49986. var first = entryRanges[0];
  49987. var n = entryRanges[1];
  49988. if (!isInt(first) || !isInt(n)) {
  49989. error('Invalid XRef range fields: ' + first + ', ' + n);
  49990. }
  49991. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  49992. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  49993. }
  49994. for (i = streamState.entryNum; i < n; ++i) {
  49995. streamState.entryNum = i;
  49996. streamState.streamPos = stream.pos;
  49997. var type = 0, offset = 0, generation = 0;
  49998. for (j = 0; j < typeFieldWidth; ++j) {
  49999. type = type << 8 | stream.getByte();
  50000. }
  50001. if (typeFieldWidth === 0) {
  50002. type = 1;
  50003. }
  50004. for (j = 0; j < offsetFieldWidth; ++j) {
  50005. offset = offset << 8 | stream.getByte();
  50006. }
  50007. for (j = 0; j < generationFieldWidth; ++j) {
  50008. generation = generation << 8 | stream.getByte();
  50009. }
  50010. var entry = {};
  50011. entry.offset = offset;
  50012. entry.gen = generation;
  50013. switch (type) {
  50014. case 0:
  50015. entry.free = true;
  50016. break;
  50017. case 1:
  50018. entry.uncompressed = true;
  50019. break;
  50020. case 2:
  50021. break;
  50022. default:
  50023. error('Invalid XRef entry type: ' + type);
  50024. }
  50025. if (!this.entries[first + i]) {
  50026. this.entries[first + i] = entry;
  50027. }
  50028. }
  50029. streamState.entryNum = 0;
  50030. streamState.streamPos = stream.pos;
  50031. entryRanges.splice(0, 2);
  50032. }
  50033. },
  50034. indexObjects: function XRef_indexObjects() {
  50035. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50036. var PERCENT = 0x25, LT = 0x3C;
  50037. function readToken(data, offset) {
  50038. var token = '', ch = data[offset];
  50039. while (ch !== LF && ch !== CR && ch !== LT) {
  50040. if (++offset >= data.length) {
  50041. break;
  50042. }
  50043. token += String.fromCharCode(ch);
  50044. ch = data[offset];
  50045. }
  50046. return token;
  50047. }
  50048. function skipUntil(data, offset, what) {
  50049. var length = what.length, dataLength = data.length;
  50050. var skipped = 0;
  50051. while (offset < dataLength) {
  50052. var i = 0;
  50053. while (i < length && data[offset + i] === what[i]) {
  50054. ++i;
  50055. }
  50056. if (i >= length) {
  50057. break;
  50058. }
  50059. offset++;
  50060. skipped++;
  50061. }
  50062. return skipped;
  50063. }
  50064. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50065. var trailerBytes = new Uint8Array([
  50066. 116,
  50067. 114,
  50068. 97,
  50069. 105,
  50070. 108,
  50071. 101,
  50072. 114
  50073. ]);
  50074. var startxrefBytes = new Uint8Array([
  50075. 115,
  50076. 116,
  50077. 97,
  50078. 114,
  50079. 116,
  50080. 120,
  50081. 114,
  50082. 101,
  50083. 102
  50084. ]);
  50085. var endobjBytes = new Uint8Array([
  50086. 101,
  50087. 110,
  50088. 100,
  50089. 111,
  50090. 98,
  50091. 106
  50092. ]);
  50093. var xrefBytes = new Uint8Array([
  50094. 47,
  50095. 88,
  50096. 82,
  50097. 101,
  50098. 102
  50099. ]);
  50100. this.entries.length = 0;
  50101. var stream = this.stream;
  50102. stream.pos = 0;
  50103. var buffer = stream.getBytes();
  50104. var position = stream.start, length = buffer.length;
  50105. var trailers = [], xrefStms = [];
  50106. while (position < length) {
  50107. var ch = buffer[position];
  50108. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50109. ++position;
  50110. continue;
  50111. }
  50112. if (ch === PERCENT) {
  50113. do {
  50114. ++position;
  50115. if (position >= length) {
  50116. break;
  50117. }
  50118. ch = buffer[position];
  50119. } while (ch !== LF && ch !== CR);
  50120. continue;
  50121. }
  50122. var token = readToken(buffer, position);
  50123. var m;
  50124. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50125. position += skipUntil(buffer, position, trailerBytes);
  50126. trailers.push(position);
  50127. position += skipUntil(buffer, position, startxrefBytes);
  50128. } else if (m = objRegExp.exec(token)) {
  50129. if (typeof this.entries[m[1]] === 'undefined') {
  50130. this.entries[m[1]] = {
  50131. offset: position - stream.start,
  50132. gen: m[2] | 0,
  50133. uncompressed: true
  50134. };
  50135. }
  50136. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50137. var content = buffer.subarray(position, position + contentLength);
  50138. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50139. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50140. xrefStms.push(position - stream.start);
  50141. this.xrefstms[position - stream.start] = 1;
  50142. }
  50143. position += contentLength;
  50144. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50145. trailers.push(position);
  50146. position += skipUntil(buffer, position, startxrefBytes);
  50147. } else {
  50148. position += token.length + 1;
  50149. }
  50150. }
  50151. var i, ii;
  50152. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50153. this.startXRefQueue.push(xrefStms[i]);
  50154. this.readXRef(true);
  50155. }
  50156. var dict;
  50157. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50158. stream.pos = trailers[i];
  50159. var parser = new Parser(new Lexer(stream), true, this, true);
  50160. var obj = parser.getObj();
  50161. if (!isCmd(obj, 'trailer')) {
  50162. continue;
  50163. }
  50164. dict = parser.getObj();
  50165. if (!isDict(dict)) {
  50166. continue;
  50167. }
  50168. if (dict.has('ID')) {
  50169. return dict;
  50170. }
  50171. }
  50172. if (dict) {
  50173. return dict;
  50174. }
  50175. throw new InvalidPDFException('Invalid PDF structure');
  50176. },
  50177. readXRef: function XRef_readXRef(recoveryMode) {
  50178. var stream = this.stream;
  50179. try {
  50180. while (this.startXRefQueue.length) {
  50181. var startXRef = this.startXRefQueue[0];
  50182. stream.pos = startXRef + stream.start;
  50183. var parser = new Parser(new Lexer(stream), true, this);
  50184. var obj = parser.getObj();
  50185. var dict;
  50186. if (isCmd(obj, 'xref')) {
  50187. dict = this.processXRefTable(parser);
  50188. if (!this.topDict) {
  50189. this.topDict = dict;
  50190. }
  50191. obj = dict.get('XRefStm');
  50192. if (isInt(obj)) {
  50193. var pos = obj;
  50194. if (!(pos in this.xrefstms)) {
  50195. this.xrefstms[pos] = 1;
  50196. this.startXRefQueue.push(pos);
  50197. }
  50198. }
  50199. } else if (isInt(obj)) {
  50200. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50201. error('Invalid XRef stream');
  50202. }
  50203. dict = this.processXRefStream(obj);
  50204. if (!this.topDict) {
  50205. this.topDict = dict;
  50206. }
  50207. if (!dict) {
  50208. error('Failed to read XRef stream');
  50209. }
  50210. } else {
  50211. error('Invalid XRef stream header');
  50212. }
  50213. obj = dict.get('Prev');
  50214. if (isInt(obj)) {
  50215. this.startXRefQueue.push(obj);
  50216. } else if (isRef(obj)) {
  50217. this.startXRefQueue.push(obj.num);
  50218. }
  50219. this.startXRefQueue.shift();
  50220. }
  50221. return this.topDict;
  50222. } catch (e) {
  50223. if (e instanceof MissingDataException) {
  50224. throw e;
  50225. }
  50226. info('(while reading XRef): ' + e);
  50227. }
  50228. if (recoveryMode) {
  50229. return;
  50230. }
  50231. throw new XRefParseException();
  50232. },
  50233. getEntry: function XRef_getEntry(i) {
  50234. var xrefEntry = this.entries[i];
  50235. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50236. return xrefEntry;
  50237. }
  50238. return null;
  50239. },
  50240. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50241. if (!isRef(obj)) {
  50242. return obj;
  50243. }
  50244. return this.fetch(obj, suppressEncryption);
  50245. },
  50246. fetch: function XRef_fetch(ref, suppressEncryption) {
  50247. assert(isRef(ref), 'ref object is not a reference');
  50248. var num = ref.num;
  50249. if (num in this.cache) {
  50250. var cacheEntry = this.cache[num];
  50251. return cacheEntry;
  50252. }
  50253. var xrefEntry = this.getEntry(num);
  50254. if (xrefEntry === null) {
  50255. return this.cache[num] = null;
  50256. }
  50257. if (xrefEntry.uncompressed) {
  50258. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50259. } else {
  50260. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50261. }
  50262. if (isDict(xrefEntry)) {
  50263. xrefEntry.objId = ref.toString();
  50264. } else if (isStream(xrefEntry)) {
  50265. xrefEntry.dict.objId = ref.toString();
  50266. }
  50267. return xrefEntry;
  50268. },
  50269. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50270. var gen = ref.gen;
  50271. var num = ref.num;
  50272. if (xrefEntry.gen !== gen) {
  50273. error('inconsistent generation in XRef');
  50274. }
  50275. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50276. var parser = new Parser(new Lexer(stream), true, this);
  50277. var obj1 = parser.getObj();
  50278. var obj2 = parser.getObj();
  50279. var obj3 = parser.getObj();
  50280. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50281. error('bad XRef entry');
  50282. }
  50283. if (!isCmd(obj3, 'obj')) {
  50284. if (obj3.cmd.indexOf('obj') === 0) {
  50285. num = parseInt(obj3.cmd.substring(3), 10);
  50286. if (!isNaN(num)) {
  50287. return num;
  50288. }
  50289. }
  50290. error('bad XRef entry');
  50291. }
  50292. if (this.encrypt && !suppressEncryption) {
  50293. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50294. } else {
  50295. xrefEntry = parser.getObj();
  50296. }
  50297. if (!isStream(xrefEntry)) {
  50298. this.cache[num] = xrefEntry;
  50299. }
  50300. return xrefEntry;
  50301. },
  50302. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50303. var tableOffset = xrefEntry.offset;
  50304. var stream = this.fetch(new Ref(tableOffset, 0));
  50305. if (!isStream(stream)) {
  50306. error('bad ObjStm stream');
  50307. }
  50308. var first = stream.dict.get('First');
  50309. var n = stream.dict.get('N');
  50310. if (!isInt(first) || !isInt(n)) {
  50311. error('invalid first and n parameters for ObjStm stream');
  50312. }
  50313. var parser = new Parser(new Lexer(stream), false, this);
  50314. parser.allowStreams = true;
  50315. var i, entries = [], num, nums = [];
  50316. for (i = 0; i < n; ++i) {
  50317. num = parser.getObj();
  50318. if (!isInt(num)) {
  50319. error('invalid object number in the ObjStm stream: ' + num);
  50320. }
  50321. nums.push(num);
  50322. var offset = parser.getObj();
  50323. if (!isInt(offset)) {
  50324. error('invalid object offset in the ObjStm stream: ' + offset);
  50325. }
  50326. }
  50327. for (i = 0; i < n; ++i) {
  50328. entries.push(parser.getObj());
  50329. if (isCmd(parser.buf1, 'endobj')) {
  50330. parser.shift();
  50331. }
  50332. num = nums[i];
  50333. var entry = this.entries[num];
  50334. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50335. this.cache[num] = entries[i];
  50336. }
  50337. }
  50338. xrefEntry = entries[xrefEntry.gen];
  50339. if (xrefEntry === undefined) {
  50340. error('bad XRef entry for compressed object');
  50341. }
  50342. return xrefEntry;
  50343. },
  50344. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50345. if (!isRef(obj)) {
  50346. return Promise.resolve(obj);
  50347. }
  50348. return this.fetchAsync(obj, suppressEncryption);
  50349. },
  50350. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50351. var streamManager = this.stream.manager;
  50352. var xref = this;
  50353. return new Promise(function tryFetch(resolve, reject) {
  50354. try {
  50355. resolve(xref.fetch(ref, suppressEncryption));
  50356. } catch (e) {
  50357. if (e instanceof MissingDataException) {
  50358. streamManager.requestRange(e.begin, e.end).then(function () {
  50359. tryFetch(resolve, reject);
  50360. }, reject);
  50361. return;
  50362. }
  50363. reject(e);
  50364. }
  50365. });
  50366. },
  50367. getCatalogObj: function XRef_getCatalogObj() {
  50368. return this.root;
  50369. }
  50370. };
  50371. return XRef;
  50372. }();
  50373. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50374. function NameOrNumberTree(root, xref) {
  50375. throw new Error('Cannot initialize NameOrNumberTree.');
  50376. }
  50377. NameOrNumberTree.prototype = {
  50378. getAll: function NameOrNumberTree_getAll() {
  50379. var dict = Object.create(null);
  50380. if (!this.root) {
  50381. return dict;
  50382. }
  50383. var xref = this.xref;
  50384. var processed = new RefSet();
  50385. processed.put(this.root);
  50386. var queue = [this.root];
  50387. while (queue.length > 0) {
  50388. var i, n;
  50389. var obj = xref.fetchIfRef(queue.shift());
  50390. if (!isDict(obj)) {
  50391. continue;
  50392. }
  50393. if (obj.has('Kids')) {
  50394. var kids = obj.get('Kids');
  50395. for (i = 0, n = kids.length; i < n; i++) {
  50396. var kid = kids[i];
  50397. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50398. queue.push(kid);
  50399. processed.put(kid);
  50400. }
  50401. continue;
  50402. }
  50403. var entries = obj.get(this._type);
  50404. if (isArray(entries)) {
  50405. for (i = 0, n = entries.length; i < n; i += 2) {
  50406. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50407. }
  50408. }
  50409. }
  50410. return dict;
  50411. },
  50412. get: function NameOrNumberTree_get(key) {
  50413. if (!this.root) {
  50414. return null;
  50415. }
  50416. var xref = this.xref;
  50417. var kidsOrEntries = xref.fetchIfRef(this.root);
  50418. var loopCount = 0;
  50419. var MAX_LEVELS = 10;
  50420. var l, r, m;
  50421. while (kidsOrEntries.has('Kids')) {
  50422. if (++loopCount > MAX_LEVELS) {
  50423. warn('Search depth limit reached for "' + this._type + '" tree.');
  50424. return null;
  50425. }
  50426. var kids = kidsOrEntries.get('Kids');
  50427. if (!isArray(kids)) {
  50428. return null;
  50429. }
  50430. l = 0;
  50431. r = kids.length - 1;
  50432. while (l <= r) {
  50433. m = l + r >> 1;
  50434. var kid = xref.fetchIfRef(kids[m]);
  50435. var limits = kid.get('Limits');
  50436. if (key < xref.fetchIfRef(limits[0])) {
  50437. r = m - 1;
  50438. } else if (key > xref.fetchIfRef(limits[1])) {
  50439. l = m + 1;
  50440. } else {
  50441. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50442. break;
  50443. }
  50444. }
  50445. if (l > r) {
  50446. return null;
  50447. }
  50448. }
  50449. var entries = kidsOrEntries.get(this._type);
  50450. if (isArray(entries)) {
  50451. l = 0;
  50452. r = entries.length - 2;
  50453. while (l <= r) {
  50454. m = l + r & ~1;
  50455. var currentKey = xref.fetchIfRef(entries[m]);
  50456. if (key < currentKey) {
  50457. r = m - 2;
  50458. } else if (key > currentKey) {
  50459. l = m + 2;
  50460. } else {
  50461. return xref.fetchIfRef(entries[m + 1]);
  50462. }
  50463. }
  50464. }
  50465. return null;
  50466. }
  50467. };
  50468. return NameOrNumberTree;
  50469. }();
  50470. var NameTree = function NameTreeClosure() {
  50471. function NameTree(root, xref) {
  50472. this.root = root;
  50473. this.xref = xref;
  50474. this._type = 'Names';
  50475. }
  50476. Util.inherit(NameTree, NameOrNumberTree, {});
  50477. return NameTree;
  50478. }();
  50479. var NumberTree = function NumberTreeClosure() {
  50480. function NumberTree(root, xref) {
  50481. this.root = root;
  50482. this.xref = xref;
  50483. this._type = 'Nums';
  50484. }
  50485. Util.inherit(NumberTree, NameOrNumberTree, {});
  50486. return NumberTree;
  50487. }();
  50488. var FileSpec = function FileSpecClosure() {
  50489. function FileSpec(root, xref) {
  50490. if (!root || !isDict(root)) {
  50491. return;
  50492. }
  50493. this.xref = xref;
  50494. this.root = root;
  50495. if (root.has('FS')) {
  50496. this.fs = root.get('FS');
  50497. }
  50498. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50499. if (root.has('RF')) {
  50500. warn('Related file specifications are not supported');
  50501. }
  50502. this.contentAvailable = true;
  50503. if (!root.has('EF')) {
  50504. this.contentAvailable = false;
  50505. warn('Non-embedded file specifications are not supported');
  50506. }
  50507. }
  50508. function pickPlatformItem(dict) {
  50509. if (dict.has('UF')) {
  50510. return dict.get('UF');
  50511. } else if (dict.has('F')) {
  50512. return dict.get('F');
  50513. } else if (dict.has('Unix')) {
  50514. return dict.get('Unix');
  50515. } else if (dict.has('Mac')) {
  50516. return dict.get('Mac');
  50517. } else if (dict.has('DOS')) {
  50518. return dict.get('DOS');
  50519. } else {
  50520. return null;
  50521. }
  50522. }
  50523. FileSpec.prototype = {
  50524. get filename() {
  50525. if (!this._filename && this.root) {
  50526. var filename = pickPlatformItem(this.root) || 'unnamed';
  50527. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50528. }
  50529. return this._filename;
  50530. },
  50531. get content() {
  50532. if (!this.contentAvailable) {
  50533. return null;
  50534. }
  50535. if (!this.contentRef && this.root) {
  50536. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50537. }
  50538. var content = null;
  50539. if (this.contentRef) {
  50540. var xref = this.xref;
  50541. var fileObj = xref.fetchIfRef(this.contentRef);
  50542. if (fileObj && isStream(fileObj)) {
  50543. content = fileObj.getBytes();
  50544. } else {
  50545. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50546. }
  50547. } else {
  50548. warn('Embedded file specification does not have a content');
  50549. }
  50550. return content;
  50551. },
  50552. get serializable() {
  50553. return {
  50554. filename: this.filename,
  50555. content: this.content
  50556. };
  50557. }
  50558. };
  50559. return FileSpec;
  50560. }();
  50561. var ObjectLoader = function () {
  50562. function mayHaveChildren(value) {
  50563. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50564. }
  50565. function addChildren(node, nodesToVisit) {
  50566. var value;
  50567. if (isDict(node) || isStream(node)) {
  50568. var map;
  50569. if (isDict(node)) {
  50570. map = node.map;
  50571. } else {
  50572. map = node.dict.map;
  50573. }
  50574. for (var key in map) {
  50575. value = map[key];
  50576. if (mayHaveChildren(value)) {
  50577. nodesToVisit.push(value);
  50578. }
  50579. }
  50580. } else if (isArray(node)) {
  50581. for (var i = 0, ii = node.length; i < ii; i++) {
  50582. value = node[i];
  50583. if (mayHaveChildren(value)) {
  50584. nodesToVisit.push(value);
  50585. }
  50586. }
  50587. }
  50588. }
  50589. function ObjectLoader(obj, keys, xref) {
  50590. this.obj = obj;
  50591. this.keys = keys;
  50592. this.xref = xref;
  50593. this.refSet = null;
  50594. this.capability = null;
  50595. }
  50596. ObjectLoader.prototype = {
  50597. load: function ObjectLoader_load() {
  50598. var keys = this.keys;
  50599. this.capability = createPromiseCapability();
  50600. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50601. this.capability.resolve();
  50602. return this.capability.promise;
  50603. }
  50604. this.refSet = new RefSet();
  50605. var nodesToVisit = [];
  50606. for (var i = 0; i < keys.length; i++) {
  50607. nodesToVisit.push(this.obj[keys[i]]);
  50608. }
  50609. this._walk(nodesToVisit);
  50610. return this.capability.promise;
  50611. },
  50612. _walk: function ObjectLoader_walk(nodesToVisit) {
  50613. var nodesToRevisit = [];
  50614. var pendingRequests = [];
  50615. while (nodesToVisit.length) {
  50616. var currentNode = nodesToVisit.pop();
  50617. if (isRef(currentNode)) {
  50618. if (this.refSet.has(currentNode)) {
  50619. continue;
  50620. }
  50621. try {
  50622. var ref = currentNode;
  50623. this.refSet.put(ref);
  50624. currentNode = this.xref.fetch(currentNode);
  50625. } catch (e) {
  50626. if (!(e instanceof MissingDataException)) {
  50627. throw e;
  50628. }
  50629. nodesToRevisit.push(currentNode);
  50630. pendingRequests.push({
  50631. begin: e.begin,
  50632. end: e.end
  50633. });
  50634. }
  50635. }
  50636. if (currentNode && currentNode.getBaseStreams) {
  50637. var baseStreams = currentNode.getBaseStreams();
  50638. var foundMissingData = false;
  50639. for (var i = 0; i < baseStreams.length; i++) {
  50640. var stream = baseStreams[i];
  50641. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50642. foundMissingData = true;
  50643. pendingRequests.push({
  50644. begin: stream.start,
  50645. end: stream.end
  50646. });
  50647. }
  50648. }
  50649. if (foundMissingData) {
  50650. nodesToRevisit.push(currentNode);
  50651. }
  50652. }
  50653. addChildren(currentNode, nodesToVisit);
  50654. }
  50655. if (pendingRequests.length) {
  50656. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50657. nodesToVisit = nodesToRevisit;
  50658. for (var i = 0; i < nodesToRevisit.length; i++) {
  50659. var node = nodesToRevisit[i];
  50660. if (isRef(node)) {
  50661. this.refSet.remove(node);
  50662. }
  50663. }
  50664. this._walk(nodesToVisit);
  50665. }.bind(this), this.capability.reject);
  50666. return;
  50667. }
  50668. this.refSet = null;
  50669. this.capability.resolve();
  50670. }
  50671. };
  50672. return ObjectLoader;
  50673. }();
  50674. exports.Catalog = Catalog;
  50675. exports.ObjectLoader = ObjectLoader;
  50676. exports.XRef = XRef;
  50677. exports.FileSpec = FileSpec;
  50678. }));
  50679. (function (root, factory) {
  50680. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50681. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50682. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50683. var MissingDataException = sharedUtil.MissingDataException;
  50684. var Util = sharedUtil.Util;
  50685. var assert = sharedUtil.assert;
  50686. var error = sharedUtil.error;
  50687. var info = sharedUtil.info;
  50688. var warn = sharedUtil.warn;
  50689. var isStream = corePrimitives.isStream;
  50690. var PDFFunction = coreFunction.PDFFunction;
  50691. var ColorSpace = coreColorSpace.ColorSpace;
  50692. var ShadingType = {
  50693. FUNCTION_BASED: 1,
  50694. AXIAL: 2,
  50695. RADIAL: 3,
  50696. FREE_FORM_MESH: 4,
  50697. LATTICE_FORM_MESH: 5,
  50698. COONS_PATCH_MESH: 6,
  50699. TENSOR_PATCH_MESH: 7
  50700. };
  50701. var Pattern = function PatternClosure() {
  50702. function Pattern() {
  50703. error('should not call Pattern constructor');
  50704. }
  50705. Pattern.prototype = {
  50706. getPattern: function Pattern_getPattern(ctx) {
  50707. error('Should not call Pattern.getStyle: ' + ctx);
  50708. }
  50709. };
  50710. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50711. var dict = isStream(shading) ? shading.dict : shading;
  50712. var type = dict.get('ShadingType');
  50713. try {
  50714. switch (type) {
  50715. case ShadingType.AXIAL:
  50716. case ShadingType.RADIAL:
  50717. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50718. case ShadingType.FREE_FORM_MESH:
  50719. case ShadingType.LATTICE_FORM_MESH:
  50720. case ShadingType.COONS_PATCH_MESH:
  50721. case ShadingType.TENSOR_PATCH_MESH:
  50722. return new Shadings.Mesh(shading, matrix, xref, res);
  50723. default:
  50724. throw new Error('Unsupported ShadingType: ' + type);
  50725. }
  50726. } catch (ex) {
  50727. if (ex instanceof MissingDataException) {
  50728. throw ex;
  50729. }
  50730. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50731. warn(ex);
  50732. return new Shadings.Dummy();
  50733. }
  50734. };
  50735. return Pattern;
  50736. }();
  50737. var Shadings = {};
  50738. Shadings.SMALL_NUMBER = 1e-6;
  50739. Shadings.RadialAxial = function RadialAxialClosure() {
  50740. function RadialAxial(dict, matrix, xref, res) {
  50741. this.matrix = matrix;
  50742. this.coordsArr = dict.getArray('Coords');
  50743. this.shadingType = dict.get('ShadingType');
  50744. this.type = 'Pattern';
  50745. var cs = dict.get('ColorSpace', 'CS');
  50746. cs = ColorSpace.parse(cs, xref, res);
  50747. this.cs = cs;
  50748. var t0 = 0.0, t1 = 1.0;
  50749. if (dict.has('Domain')) {
  50750. var domainArr = dict.getArray('Domain');
  50751. t0 = domainArr[0];
  50752. t1 = domainArr[1];
  50753. }
  50754. var extendStart = false, extendEnd = false;
  50755. if (dict.has('Extend')) {
  50756. var extendArr = dict.getArray('Extend');
  50757. extendStart = extendArr[0];
  50758. extendEnd = extendArr[1];
  50759. }
  50760. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50761. var x1 = this.coordsArr[0];
  50762. var y1 = this.coordsArr[1];
  50763. var r1 = this.coordsArr[2];
  50764. var x2 = this.coordsArr[3];
  50765. var y2 = this.coordsArr[4];
  50766. var r2 = this.coordsArr[5];
  50767. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50768. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50769. warn('Unsupported radial gradient.');
  50770. }
  50771. }
  50772. this.extendStart = extendStart;
  50773. this.extendEnd = extendEnd;
  50774. var fnObj = dict.get('Function');
  50775. var fn = PDFFunction.parseArray(xref, fnObj);
  50776. var diff = t1 - t0;
  50777. var step = diff / 10;
  50778. var colorStops = this.colorStops = [];
  50779. if (t0 >= t1 || step <= 0) {
  50780. info('Bad shading domain.');
  50781. return;
  50782. }
  50783. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50784. var rgbColor;
  50785. for (var i = t0; i <= t1; i += step) {
  50786. ratio[0] = i;
  50787. fn(ratio, 0, color, 0);
  50788. rgbColor = cs.getRgb(color, 0);
  50789. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50790. colorStops.push([
  50791. (i - t0) / diff,
  50792. cssColor
  50793. ]);
  50794. }
  50795. var background = 'transparent';
  50796. if (dict.has('Background')) {
  50797. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50798. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50799. }
  50800. if (!extendStart) {
  50801. colorStops.unshift([
  50802. 0,
  50803. background
  50804. ]);
  50805. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50806. }
  50807. if (!extendEnd) {
  50808. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50809. colorStops.push([
  50810. 1,
  50811. background
  50812. ]);
  50813. }
  50814. this.colorStops = colorStops;
  50815. }
  50816. RadialAxial.prototype = {
  50817. getIR: function RadialAxial_getIR() {
  50818. var coordsArr = this.coordsArr;
  50819. var shadingType = this.shadingType;
  50820. var type, p0, p1, r0, r1;
  50821. if (shadingType === ShadingType.AXIAL) {
  50822. p0 = [
  50823. coordsArr[0],
  50824. coordsArr[1]
  50825. ];
  50826. p1 = [
  50827. coordsArr[2],
  50828. coordsArr[3]
  50829. ];
  50830. r0 = null;
  50831. r1 = null;
  50832. type = 'axial';
  50833. } else if (shadingType === ShadingType.RADIAL) {
  50834. p0 = [
  50835. coordsArr[0],
  50836. coordsArr[1]
  50837. ];
  50838. p1 = [
  50839. coordsArr[3],
  50840. coordsArr[4]
  50841. ];
  50842. r0 = coordsArr[2];
  50843. r1 = coordsArr[5];
  50844. type = 'radial';
  50845. } else {
  50846. error('getPattern type unknown: ' + shadingType);
  50847. }
  50848. var matrix = this.matrix;
  50849. if (matrix) {
  50850. p0 = Util.applyTransform(p0, matrix);
  50851. p1 = Util.applyTransform(p1, matrix);
  50852. if (shadingType === ShadingType.RADIAL) {
  50853. var scale = Util.singularValueDecompose2dScale(matrix);
  50854. r0 *= scale[0];
  50855. r1 *= scale[1];
  50856. }
  50857. }
  50858. return [
  50859. 'RadialAxial',
  50860. type,
  50861. this.colorStops,
  50862. p0,
  50863. p1,
  50864. r0,
  50865. r1
  50866. ];
  50867. }
  50868. };
  50869. return RadialAxial;
  50870. }();
  50871. Shadings.Mesh = function MeshClosure() {
  50872. function MeshStreamReader(stream, context) {
  50873. this.stream = stream;
  50874. this.context = context;
  50875. this.buffer = 0;
  50876. this.bufferLength = 0;
  50877. var numComps = context.numComps;
  50878. this.tmpCompsBuf = new Float32Array(numComps);
  50879. var csNumComps = context.colorSpace.numComps;
  50880. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  50881. }
  50882. MeshStreamReader.prototype = {
  50883. get hasData() {
  50884. if (this.stream.end) {
  50885. return this.stream.pos < this.stream.end;
  50886. }
  50887. if (this.bufferLength > 0) {
  50888. return true;
  50889. }
  50890. var nextByte = this.stream.getByte();
  50891. if (nextByte < 0) {
  50892. return false;
  50893. }
  50894. this.buffer = nextByte;
  50895. this.bufferLength = 8;
  50896. return true;
  50897. },
  50898. readBits: function MeshStreamReader_readBits(n) {
  50899. var buffer = this.buffer;
  50900. var bufferLength = this.bufferLength;
  50901. if (n === 32) {
  50902. if (bufferLength === 0) {
  50903. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  50904. }
  50905. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  50906. var nextByte = this.stream.getByte();
  50907. this.buffer = nextByte & (1 << bufferLength) - 1;
  50908. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  50909. }
  50910. if (n === 8 && bufferLength === 0) {
  50911. return this.stream.getByte();
  50912. }
  50913. while (bufferLength < n) {
  50914. buffer = buffer << 8 | this.stream.getByte();
  50915. bufferLength += 8;
  50916. }
  50917. bufferLength -= n;
  50918. this.bufferLength = bufferLength;
  50919. this.buffer = buffer & (1 << bufferLength) - 1;
  50920. return buffer >> bufferLength;
  50921. },
  50922. align: function MeshStreamReader_align() {
  50923. this.buffer = 0;
  50924. this.bufferLength = 0;
  50925. },
  50926. readFlag: function MeshStreamReader_readFlag() {
  50927. return this.readBits(this.context.bitsPerFlag);
  50928. },
  50929. readCoordinate: function MeshStreamReader_readCoordinate() {
  50930. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  50931. var xi = this.readBits(bitsPerCoordinate);
  50932. var yi = this.readBits(bitsPerCoordinate);
  50933. var decode = this.context.decode;
  50934. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  50935. return [
  50936. xi * scale * (decode[1] - decode[0]) + decode[0],
  50937. yi * scale * (decode[3] - decode[2]) + decode[2]
  50938. ];
  50939. },
  50940. readComponents: function MeshStreamReader_readComponents() {
  50941. var numComps = this.context.numComps;
  50942. var bitsPerComponent = this.context.bitsPerComponent;
  50943. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  50944. var decode = this.context.decode;
  50945. var components = this.tmpCompsBuf;
  50946. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  50947. var ci = this.readBits(bitsPerComponent);
  50948. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  50949. }
  50950. var color = this.tmpCsCompsBuf;
  50951. if (this.context.colorFn) {
  50952. this.context.colorFn(components, 0, color, 0);
  50953. }
  50954. return this.context.colorSpace.getRgb(color, 0);
  50955. }
  50956. };
  50957. function decodeType4Shading(mesh, reader) {
  50958. var coords = mesh.coords;
  50959. var colors = mesh.colors;
  50960. var operators = [];
  50961. var ps = [];
  50962. var verticesLeft = 0;
  50963. while (reader.hasData) {
  50964. var f = reader.readFlag();
  50965. var coord = reader.readCoordinate();
  50966. var color = reader.readComponents();
  50967. if (verticesLeft === 0) {
  50968. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  50969. switch (f) {
  50970. case 0:
  50971. verticesLeft = 3;
  50972. break;
  50973. case 1:
  50974. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  50975. verticesLeft = 1;
  50976. break;
  50977. case 2:
  50978. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  50979. verticesLeft = 1;
  50980. break;
  50981. }
  50982. operators.push(f);
  50983. }
  50984. ps.push(coords.length);
  50985. coords.push(coord);
  50986. colors.push(color);
  50987. verticesLeft--;
  50988. reader.align();
  50989. }
  50990. mesh.figures.push({
  50991. type: 'triangles',
  50992. coords: new Int32Array(ps),
  50993. colors: new Int32Array(ps)
  50994. });
  50995. }
  50996. function decodeType5Shading(mesh, reader, verticesPerRow) {
  50997. var coords = mesh.coords;
  50998. var colors = mesh.colors;
  50999. var ps = [];
  51000. while (reader.hasData) {
  51001. var coord = reader.readCoordinate();
  51002. var color = reader.readComponents();
  51003. ps.push(coords.length);
  51004. coords.push(coord);
  51005. colors.push(color);
  51006. }
  51007. mesh.figures.push({
  51008. type: 'lattice',
  51009. coords: new Int32Array(ps),
  51010. colors: new Int32Array(ps),
  51011. verticesPerRow: verticesPerRow
  51012. });
  51013. }
  51014. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51015. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51016. var TRIANGLE_DENSITY = 20;
  51017. var getB = function getBClosure() {
  51018. function buildB(count) {
  51019. var lut = [];
  51020. for (var i = 0; i <= count; i++) {
  51021. var t = i / count, t_ = 1 - t;
  51022. lut.push(new Float32Array([
  51023. t_ * t_ * t_,
  51024. 3 * t * t_ * t_,
  51025. 3 * t * t * t_,
  51026. t * t * t
  51027. ]));
  51028. }
  51029. return lut;
  51030. }
  51031. var cache = [];
  51032. return function getB(count) {
  51033. if (!cache[count]) {
  51034. cache[count] = buildB(count);
  51035. }
  51036. return cache[count];
  51037. };
  51038. }();
  51039. function buildFigureFromPatch(mesh, index) {
  51040. var figure = mesh.figures[index];
  51041. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51042. var coords = mesh.coords, colors = mesh.colors;
  51043. var pi = figure.coords;
  51044. var ci = figure.colors;
  51045. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51046. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51047. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51048. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51049. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51050. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51051. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51052. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51053. var verticesPerRow = splitXBy + 1;
  51054. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51055. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51056. var k = 0;
  51057. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51058. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51059. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51060. for (var row = 0; row <= splitYBy; row++) {
  51061. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51062. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51063. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51064. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51065. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51066. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51067. for (var col = 0; col <= splitXBy; col++, k++) {
  51068. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51069. continue;
  51070. }
  51071. var x = 0, y = 0;
  51072. var q = 0;
  51073. for (var i = 0; i <= 3; i++) {
  51074. for (var j = 0; j <= 3; j++, q++) {
  51075. var m = bRow[row][i] * bCol[col][j];
  51076. x += coords[pi[q]][0] * m;
  51077. y += coords[pi[q]][1] * m;
  51078. }
  51079. }
  51080. figureCoords[k] = coords.length;
  51081. coords.push([
  51082. x,
  51083. y
  51084. ]);
  51085. figureColors[k] = colors.length;
  51086. var newColor = new Uint8Array(3);
  51087. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51088. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51089. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51090. colors.push(newColor);
  51091. }
  51092. }
  51093. figureCoords[0] = pi[0];
  51094. figureColors[0] = ci[0];
  51095. figureCoords[splitXBy] = pi[3];
  51096. figureColors[splitXBy] = ci[1];
  51097. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51098. figureColors[verticesPerRow * splitYBy] = ci[2];
  51099. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51100. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51101. mesh.figures[index] = {
  51102. type: 'lattice',
  51103. coords: figureCoords,
  51104. colors: figureColors,
  51105. verticesPerRow: verticesPerRow
  51106. };
  51107. }
  51108. function decodeType6Shading(mesh, reader) {
  51109. var coords = mesh.coords;
  51110. var colors = mesh.colors;
  51111. var ps = new Int32Array(16);
  51112. var cs = new Int32Array(4);
  51113. while (reader.hasData) {
  51114. var f = reader.readFlag();
  51115. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51116. var i, ii;
  51117. var pi = coords.length;
  51118. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51119. coords.push(reader.readCoordinate());
  51120. }
  51121. var ci = colors.length;
  51122. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51123. colors.push(reader.readComponents());
  51124. }
  51125. var tmp1, tmp2, tmp3, tmp4;
  51126. switch (f) {
  51127. case 0:
  51128. ps[12] = pi + 3;
  51129. ps[13] = pi + 4;
  51130. ps[14] = pi + 5;
  51131. ps[15] = pi + 6;
  51132. ps[8] = pi + 2;
  51133. ps[11] = pi + 7;
  51134. ps[4] = pi + 1;
  51135. ps[7] = pi + 8;
  51136. ps[0] = pi;
  51137. ps[1] = pi + 11;
  51138. ps[2] = pi + 10;
  51139. ps[3] = pi + 9;
  51140. cs[2] = ci + 1;
  51141. cs[3] = ci + 2;
  51142. cs[0] = ci;
  51143. cs[1] = ci + 3;
  51144. break;
  51145. case 1:
  51146. tmp1 = ps[12];
  51147. tmp2 = ps[13];
  51148. tmp3 = ps[14];
  51149. tmp4 = ps[15];
  51150. ps[12] = tmp4;
  51151. ps[13] = pi + 0;
  51152. ps[14] = pi + 1;
  51153. ps[15] = pi + 2;
  51154. ps[8] = tmp3;
  51155. ps[11] = pi + 3;
  51156. ps[4] = tmp2;
  51157. ps[7] = pi + 4;
  51158. ps[0] = tmp1;
  51159. ps[1] = pi + 7;
  51160. ps[2] = pi + 6;
  51161. ps[3] = pi + 5;
  51162. tmp1 = cs[2];
  51163. tmp2 = cs[3];
  51164. cs[2] = tmp2;
  51165. cs[3] = ci;
  51166. cs[0] = tmp1;
  51167. cs[1] = ci + 1;
  51168. break;
  51169. case 2:
  51170. tmp1 = ps[15];
  51171. tmp2 = ps[11];
  51172. ps[12] = ps[3];
  51173. ps[13] = pi + 0;
  51174. ps[14] = pi + 1;
  51175. ps[15] = pi + 2;
  51176. ps[8] = ps[7];
  51177. ps[11] = pi + 3;
  51178. ps[4] = tmp2;
  51179. ps[7] = pi + 4;
  51180. ps[0] = tmp1;
  51181. ps[1] = pi + 7;
  51182. ps[2] = pi + 6;
  51183. ps[3] = pi + 5;
  51184. tmp1 = cs[3];
  51185. cs[2] = cs[1];
  51186. cs[3] = ci;
  51187. cs[0] = tmp1;
  51188. cs[1] = ci + 1;
  51189. break;
  51190. case 3:
  51191. ps[12] = ps[0];
  51192. ps[13] = pi + 0;
  51193. ps[14] = pi + 1;
  51194. ps[15] = pi + 2;
  51195. ps[8] = ps[1];
  51196. ps[11] = pi + 3;
  51197. ps[4] = ps[2];
  51198. ps[7] = pi + 4;
  51199. ps[0] = ps[3];
  51200. ps[1] = pi + 7;
  51201. ps[2] = pi + 6;
  51202. ps[3] = pi + 5;
  51203. cs[2] = cs[0];
  51204. cs[3] = ci;
  51205. cs[0] = cs[1];
  51206. cs[1] = ci + 1;
  51207. break;
  51208. }
  51209. ps[5] = coords.length;
  51210. coords.push([
  51211. (-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,
  51212. (-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
  51213. ]);
  51214. ps[6] = coords.length;
  51215. coords.push([
  51216. (-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,
  51217. (-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
  51218. ]);
  51219. ps[9] = coords.length;
  51220. coords.push([
  51221. (-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,
  51222. (-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
  51223. ]);
  51224. ps[10] = coords.length;
  51225. coords.push([
  51226. (-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,
  51227. (-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
  51228. ]);
  51229. mesh.figures.push({
  51230. type: 'patch',
  51231. coords: new Int32Array(ps),
  51232. colors: new Int32Array(cs)
  51233. });
  51234. }
  51235. }
  51236. function decodeType7Shading(mesh, reader) {
  51237. var coords = mesh.coords;
  51238. var colors = mesh.colors;
  51239. var ps = new Int32Array(16);
  51240. var cs = new Int32Array(4);
  51241. while (reader.hasData) {
  51242. var f = reader.readFlag();
  51243. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51244. var i, ii;
  51245. var pi = coords.length;
  51246. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51247. coords.push(reader.readCoordinate());
  51248. }
  51249. var ci = colors.length;
  51250. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51251. colors.push(reader.readComponents());
  51252. }
  51253. var tmp1, tmp2, tmp3, tmp4;
  51254. switch (f) {
  51255. case 0:
  51256. ps[12] = pi + 3;
  51257. ps[13] = pi + 4;
  51258. ps[14] = pi + 5;
  51259. ps[15] = pi + 6;
  51260. ps[8] = pi + 2;
  51261. ps[9] = pi + 13;
  51262. ps[10] = pi + 14;
  51263. ps[11] = pi + 7;
  51264. ps[4] = pi + 1;
  51265. ps[5] = pi + 12;
  51266. ps[6] = pi + 15;
  51267. ps[7] = pi + 8;
  51268. ps[0] = pi;
  51269. ps[1] = pi + 11;
  51270. ps[2] = pi + 10;
  51271. ps[3] = pi + 9;
  51272. cs[2] = ci + 1;
  51273. cs[3] = ci + 2;
  51274. cs[0] = ci;
  51275. cs[1] = ci + 3;
  51276. break;
  51277. case 1:
  51278. tmp1 = ps[12];
  51279. tmp2 = ps[13];
  51280. tmp3 = ps[14];
  51281. tmp4 = ps[15];
  51282. ps[12] = tmp4;
  51283. ps[13] = pi + 0;
  51284. ps[14] = pi + 1;
  51285. ps[15] = pi + 2;
  51286. ps[8] = tmp3;
  51287. ps[9] = pi + 9;
  51288. ps[10] = pi + 10;
  51289. ps[11] = pi + 3;
  51290. ps[4] = tmp2;
  51291. ps[5] = pi + 8;
  51292. ps[6] = pi + 11;
  51293. ps[7] = pi + 4;
  51294. ps[0] = tmp1;
  51295. ps[1] = pi + 7;
  51296. ps[2] = pi + 6;
  51297. ps[3] = pi + 5;
  51298. tmp1 = cs[2];
  51299. tmp2 = cs[3];
  51300. cs[2] = tmp2;
  51301. cs[3] = ci;
  51302. cs[0] = tmp1;
  51303. cs[1] = ci + 1;
  51304. break;
  51305. case 2:
  51306. tmp1 = ps[15];
  51307. tmp2 = ps[11];
  51308. ps[12] = ps[3];
  51309. ps[13] = pi + 0;
  51310. ps[14] = pi + 1;
  51311. ps[15] = pi + 2;
  51312. ps[8] = ps[7];
  51313. ps[9] = pi + 9;
  51314. ps[10] = pi + 10;
  51315. ps[11] = pi + 3;
  51316. ps[4] = tmp2;
  51317. ps[5] = pi + 8;
  51318. ps[6] = pi + 11;
  51319. ps[7] = pi + 4;
  51320. ps[0] = tmp1;
  51321. ps[1] = pi + 7;
  51322. ps[2] = pi + 6;
  51323. ps[3] = pi + 5;
  51324. tmp1 = cs[3];
  51325. cs[2] = cs[1];
  51326. cs[3] = ci;
  51327. cs[0] = tmp1;
  51328. cs[1] = ci + 1;
  51329. break;
  51330. case 3:
  51331. ps[12] = ps[0];
  51332. ps[13] = pi + 0;
  51333. ps[14] = pi + 1;
  51334. ps[15] = pi + 2;
  51335. ps[8] = ps[1];
  51336. ps[9] = pi + 9;
  51337. ps[10] = pi + 10;
  51338. ps[11] = pi + 3;
  51339. ps[4] = ps[2];
  51340. ps[5] = pi + 8;
  51341. ps[6] = pi + 11;
  51342. ps[7] = pi + 4;
  51343. ps[0] = ps[3];
  51344. ps[1] = pi + 7;
  51345. ps[2] = pi + 6;
  51346. ps[3] = pi + 5;
  51347. cs[2] = cs[0];
  51348. cs[3] = ci;
  51349. cs[0] = cs[1];
  51350. cs[1] = ci + 1;
  51351. break;
  51352. }
  51353. mesh.figures.push({
  51354. type: 'patch',
  51355. coords: new Int32Array(ps),
  51356. colors: new Int32Array(cs)
  51357. });
  51358. }
  51359. }
  51360. function updateBounds(mesh) {
  51361. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51362. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51363. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51364. minX = minX > x ? x : minX;
  51365. minY = minY > y ? y : minY;
  51366. maxX = maxX < x ? x : maxX;
  51367. maxY = maxY < y ? y : maxY;
  51368. }
  51369. mesh.bounds = [
  51370. minX,
  51371. minY,
  51372. maxX,
  51373. maxY
  51374. ];
  51375. }
  51376. function packData(mesh) {
  51377. var i, ii, j, jj;
  51378. var coords = mesh.coords;
  51379. var coordsPacked = new Float32Array(coords.length * 2);
  51380. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51381. var xy = coords[i];
  51382. coordsPacked[j++] = xy[0];
  51383. coordsPacked[j++] = xy[1];
  51384. }
  51385. mesh.coords = coordsPacked;
  51386. var colors = mesh.colors;
  51387. var colorsPacked = new Uint8Array(colors.length * 3);
  51388. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51389. var c = colors[i];
  51390. colorsPacked[j++] = c[0];
  51391. colorsPacked[j++] = c[1];
  51392. colorsPacked[j++] = c[2];
  51393. }
  51394. mesh.colors = colorsPacked;
  51395. var figures = mesh.figures;
  51396. for (i = 0, ii = figures.length; i < ii; i++) {
  51397. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51398. for (j = 0, jj = ps.length; j < jj; j++) {
  51399. ps[j] *= 2;
  51400. cs[j] *= 3;
  51401. }
  51402. }
  51403. }
  51404. function Mesh(stream, matrix, xref, res) {
  51405. assert(isStream(stream), 'Mesh data is not a stream');
  51406. var dict = stream.dict;
  51407. this.matrix = matrix;
  51408. this.shadingType = dict.get('ShadingType');
  51409. this.type = 'Pattern';
  51410. this.bbox = dict.getArray('BBox');
  51411. var cs = dict.get('ColorSpace', 'CS');
  51412. cs = ColorSpace.parse(cs, xref, res);
  51413. this.cs = cs;
  51414. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51415. var fnObj = dict.get('Function');
  51416. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51417. this.coords = [];
  51418. this.colors = [];
  51419. this.figures = [];
  51420. var decodeContext = {
  51421. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51422. bitsPerComponent: dict.get('BitsPerComponent'),
  51423. bitsPerFlag: dict.get('BitsPerFlag'),
  51424. decode: dict.getArray('Decode'),
  51425. colorFn: fn,
  51426. colorSpace: cs,
  51427. numComps: fn ? 1 : cs.numComps
  51428. };
  51429. var reader = new MeshStreamReader(stream, decodeContext);
  51430. var patchMesh = false;
  51431. switch (this.shadingType) {
  51432. case ShadingType.FREE_FORM_MESH:
  51433. decodeType4Shading(this, reader);
  51434. break;
  51435. case ShadingType.LATTICE_FORM_MESH:
  51436. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51437. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51438. decodeType5Shading(this, reader, verticesPerRow);
  51439. break;
  51440. case ShadingType.COONS_PATCH_MESH:
  51441. decodeType6Shading(this, reader);
  51442. patchMesh = true;
  51443. break;
  51444. case ShadingType.TENSOR_PATCH_MESH:
  51445. decodeType7Shading(this, reader);
  51446. patchMesh = true;
  51447. break;
  51448. default:
  51449. error('Unsupported mesh type.');
  51450. break;
  51451. }
  51452. if (patchMesh) {
  51453. updateBounds(this);
  51454. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51455. buildFigureFromPatch(this, i);
  51456. }
  51457. }
  51458. updateBounds(this);
  51459. packData(this);
  51460. }
  51461. Mesh.prototype = {
  51462. getIR: function Mesh_getIR() {
  51463. return [
  51464. 'Mesh',
  51465. this.shadingType,
  51466. this.coords,
  51467. this.colors,
  51468. this.figures,
  51469. this.bounds,
  51470. this.matrix,
  51471. this.bbox,
  51472. this.background
  51473. ];
  51474. }
  51475. };
  51476. return Mesh;
  51477. }();
  51478. Shadings.Dummy = function DummyClosure() {
  51479. function Dummy() {
  51480. this.type = 'Pattern';
  51481. }
  51482. Dummy.prototype = {
  51483. getIR: function Dummy_getIR() {
  51484. return ['Dummy'];
  51485. }
  51486. };
  51487. return Dummy;
  51488. }();
  51489. function getTilingPatternIR(operatorList, dict, args) {
  51490. var matrix = dict.getArray('Matrix');
  51491. var bbox = dict.getArray('BBox');
  51492. var xstep = dict.get('XStep');
  51493. var ystep = dict.get('YStep');
  51494. var paintType = dict.get('PaintType');
  51495. var tilingType = dict.get('TilingType');
  51496. return [
  51497. 'TilingPattern',
  51498. args,
  51499. operatorList,
  51500. matrix,
  51501. bbox,
  51502. xstep,
  51503. ystep,
  51504. paintType,
  51505. tilingType
  51506. ];
  51507. }
  51508. exports.Pattern = Pattern;
  51509. exports.getTilingPatternIR = getTilingPatternIR;
  51510. }));
  51511. (function (root, factory) {
  51512. 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);
  51513. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51514. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51515. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51516. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51517. var ImageKind = sharedUtil.ImageKind;
  51518. var OPS = sharedUtil.OPS;
  51519. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51520. var Util = sharedUtil.Util;
  51521. var assert = sharedUtil.assert;
  51522. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51523. var error = sharedUtil.error;
  51524. var info = sharedUtil.info;
  51525. var isArray = sharedUtil.isArray;
  51526. var isNum = sharedUtil.isNum;
  51527. var isString = sharedUtil.isString;
  51528. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51529. var warn = sharedUtil.warn;
  51530. var Dict = corePrimitives.Dict;
  51531. var Name = corePrimitives.Name;
  51532. var isCmd = corePrimitives.isCmd;
  51533. var isDict = corePrimitives.isDict;
  51534. var isName = corePrimitives.isName;
  51535. var isRef = corePrimitives.isRef;
  51536. var isStream = corePrimitives.isStream;
  51537. var DecodeStream = coreStream.DecodeStream;
  51538. var JpegStream = coreStream.JpegStream;
  51539. var Stream = coreStream.Stream;
  51540. var Lexer = coreParser.Lexer;
  51541. var Parser = coreParser.Parser;
  51542. var isEOF = coreParser.isEOF;
  51543. var PDFImage = coreImage.PDFImage;
  51544. var ColorSpace = coreColorSpace.ColorSpace;
  51545. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51546. var ErrorFont = coreFonts.ErrorFont;
  51547. var FontFlags = coreFonts.FontFlags;
  51548. var Font = coreFonts.Font;
  51549. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51550. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51551. var getFontType = coreFonts.getFontType;
  51552. var isPDFFunction = coreFunction.isPDFFunction;
  51553. var PDFFunction = coreFunction.PDFFunction;
  51554. var Pattern = corePattern.Pattern;
  51555. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51556. var CMapFactory = coreCMap.CMapFactory;
  51557. var IdentityCMap = coreCMap.IdentityCMap;
  51558. var getMetrics = coreMetrics.getMetrics;
  51559. var bidi = coreBidi.bidi;
  51560. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51561. var StandardEncoding = coreEncodings.StandardEncoding;
  51562. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51563. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51564. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51565. var getEncoding = coreEncodings.getEncoding;
  51566. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51567. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51568. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51569. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51570. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51571. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51572. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51573. var PartialEvaluator = function PartialEvaluatorClosure() {
  51574. var DefaultPartialEvaluatorOptions = {
  51575. forceDataSchema: false,
  51576. maxImageSize: -1,
  51577. disableFontFace: false,
  51578. cMapOptions: {
  51579. url: null,
  51580. packed: false
  51581. }
  51582. };
  51583. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51584. this.xref = xref;
  51585. this.resources = resources;
  51586. this.handler = handler;
  51587. this.forceDataSchema = forceDataSchema;
  51588. }
  51589. NativeImageDecoder.prototype = {
  51590. canDecode: function (image) {
  51591. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51592. },
  51593. decode: function (image) {
  51594. var dict = image.dict;
  51595. var colorSpace = dict.get('ColorSpace', 'CS');
  51596. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51597. var numComps = colorSpace.numComps;
  51598. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51599. image.getIR(this.forceDataSchema),
  51600. numComps
  51601. ]);
  51602. return decodePromise.then(function (message) {
  51603. var data = message.data;
  51604. return new Stream(data, 0, data.length, image.dict);
  51605. });
  51606. }
  51607. };
  51608. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51609. var dict = image.dict;
  51610. if (dict.has('DecodeParms') || dict.has('DP')) {
  51611. return false;
  51612. }
  51613. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51614. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51615. };
  51616. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51617. var dict = image.dict;
  51618. if (dict.has('DecodeParms') || dict.has('DP')) {
  51619. return false;
  51620. }
  51621. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51622. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51623. };
  51624. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  51625. this.pdfManager = pdfManager;
  51626. this.xref = xref;
  51627. this.handler = handler;
  51628. this.pageIndex = pageIndex;
  51629. this.uniquePrefix = uniquePrefix;
  51630. this.idCounters = idCounters;
  51631. this.fontCache = fontCache;
  51632. this.options = options || DefaultPartialEvaluatorOptions;
  51633. }
  51634. var TIME_SLOT_DURATION_MS = 20;
  51635. var CHECK_TIME_EVERY = 100;
  51636. function TimeSlotManager() {
  51637. this.reset();
  51638. }
  51639. TimeSlotManager.prototype = {
  51640. check: function TimeSlotManager_check() {
  51641. if (++this.checked < CHECK_TIME_EVERY) {
  51642. return false;
  51643. }
  51644. this.checked = 0;
  51645. return this.endTime <= Date.now();
  51646. },
  51647. reset: function TimeSlotManager_reset() {
  51648. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51649. this.checked = 0;
  51650. }
  51651. };
  51652. var deferred = Promise.resolve();
  51653. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51654. PartialEvaluator.prototype = {
  51655. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51656. if (!isDict(resources)) {
  51657. return false;
  51658. }
  51659. var processed = Object.create(null);
  51660. if (resources.objId) {
  51661. processed[resources.objId] = true;
  51662. }
  51663. var nodes = [resources], xref = this.xref;
  51664. while (nodes.length) {
  51665. var key, i, ii;
  51666. var node = nodes.shift();
  51667. var graphicStates = node.get('ExtGState');
  51668. if (isDict(graphicStates)) {
  51669. var graphicStatesKeys = graphicStates.getKeys();
  51670. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51671. key = graphicStatesKeys[i];
  51672. var graphicState = graphicStates.get(key);
  51673. var bm = graphicState.get('BM');
  51674. if (isName(bm) && bm.name !== 'Normal') {
  51675. return true;
  51676. }
  51677. }
  51678. }
  51679. var xObjects = node.get('XObject');
  51680. if (!isDict(xObjects)) {
  51681. continue;
  51682. }
  51683. var xObjectsKeys = xObjects.getKeys();
  51684. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51685. key = xObjectsKeys[i];
  51686. var xObject = xObjects.getRaw(key);
  51687. if (isRef(xObject)) {
  51688. if (processed[xObject.toString()]) {
  51689. continue;
  51690. }
  51691. xObject = xref.fetch(xObject);
  51692. }
  51693. if (!isStream(xObject)) {
  51694. continue;
  51695. }
  51696. if (xObject.dict.objId) {
  51697. if (processed[xObject.dict.objId]) {
  51698. continue;
  51699. }
  51700. processed[xObject.dict.objId] = true;
  51701. }
  51702. var xResources = xObject.dict.get('Resources');
  51703. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51704. nodes.push(xResources);
  51705. if (xResources.objId) {
  51706. processed[xResources.objId] = true;
  51707. }
  51708. }
  51709. }
  51710. }
  51711. return false;
  51712. },
  51713. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51714. var matrix = xobj.dict.getArray('Matrix');
  51715. var bbox = xobj.dict.getArray('BBox');
  51716. var group = xobj.dict.get('Group');
  51717. if (group) {
  51718. var groupOptions = {
  51719. matrix: matrix,
  51720. bbox: bbox,
  51721. smask: smask,
  51722. isolated: false,
  51723. knockout: false
  51724. };
  51725. var groupSubtype = group.get('S');
  51726. var colorSpace;
  51727. if (isName(groupSubtype, 'Transparency')) {
  51728. groupOptions.isolated = group.get('I') || false;
  51729. groupOptions.knockout = group.get('K') || false;
  51730. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51731. }
  51732. if (smask && smask.backdrop) {
  51733. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51734. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51735. }
  51736. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51737. }
  51738. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51739. matrix,
  51740. bbox
  51741. ]);
  51742. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51743. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51744. if (group) {
  51745. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51746. }
  51747. });
  51748. },
  51749. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51750. var self = this;
  51751. var dict = image.dict;
  51752. var w = dict.get('Width', 'W');
  51753. var h = dict.get('Height', 'H');
  51754. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51755. warn('Image dimensions are missing, or not numbers.');
  51756. return;
  51757. }
  51758. var maxImageSize = this.options.maxImageSize;
  51759. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51760. warn('Image exceeded maximum allowed size and was removed.');
  51761. return;
  51762. }
  51763. var imageMask = dict.get('ImageMask', 'IM') || false;
  51764. var imgData, args;
  51765. if (imageMask) {
  51766. var width = dict.get('Width', 'W');
  51767. var height = dict.get('Height', 'H');
  51768. var bitStrideLength = width + 7 >> 3;
  51769. var imgArray = image.getBytes(bitStrideLength * height);
  51770. var decode = dict.getArray('Decode', 'D');
  51771. var inverseDecode = !!decode && decode[0] > 0;
  51772. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51773. imgData.cached = true;
  51774. args = [imgData];
  51775. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51776. if (cacheKey) {
  51777. imageCache[cacheKey] = {
  51778. fn: OPS.paintImageMaskXObject,
  51779. args: args
  51780. };
  51781. }
  51782. return;
  51783. }
  51784. var softMask = dict.get('SMask', 'SM') || false;
  51785. var mask = dict.get('Mask') || false;
  51786. var SMALL_IMAGE_DIMENSIONS = 200;
  51787. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51788. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51789. imgData = imageObj.createImageData(true);
  51790. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51791. return;
  51792. }
  51793. var uniquePrefix = this.uniquePrefix || '';
  51794. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  51795. operatorList.addDependency(objId);
  51796. args = [
  51797. objId,
  51798. w,
  51799. h
  51800. ];
  51801. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51802. operatorList.addOp(OPS.paintJpegXObject, args);
  51803. this.handler.send('obj', [
  51804. objId,
  51805. this.pageIndex,
  51806. 'JpegStream',
  51807. image.getIR(this.options.forceDataSchema)
  51808. ]);
  51809. return;
  51810. }
  51811. var nativeImageDecoder = null;
  51812. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51813. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51814. }
  51815. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51816. var imgData = imageObj.createImageData(false);
  51817. self.handler.send('obj', [
  51818. objId,
  51819. self.pageIndex,
  51820. 'Image',
  51821. imgData
  51822. ], [imgData.data.buffer]);
  51823. }).then(undefined, function (reason) {
  51824. warn('Unable to decode image: ' + reason);
  51825. self.handler.send('obj', [
  51826. objId,
  51827. self.pageIndex,
  51828. 'Image',
  51829. null
  51830. ]);
  51831. });
  51832. operatorList.addOp(OPS.paintImageXObject, args);
  51833. if (cacheKey) {
  51834. imageCache[cacheKey] = {
  51835. fn: OPS.paintImageXObject,
  51836. args: args
  51837. };
  51838. }
  51839. },
  51840. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51841. var smaskContent = smask.get('G');
  51842. var smaskOptions = {
  51843. subtype: smask.get('S').name,
  51844. backdrop: smask.get('BC')
  51845. };
  51846. var transferObj = smask.get('TR');
  51847. if (isPDFFunction(transferObj)) {
  51848. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51849. var transferMap = new Uint8Array(256);
  51850. var tmp = new Float32Array(1);
  51851. for (var i = 0; i < 256; i++) {
  51852. tmp[0] = i / 255;
  51853. transferFn(tmp, 0, tmp, 0);
  51854. transferMap[i] = tmp[0] * 255 | 0;
  51855. }
  51856. smaskOptions.transferMap = transferMap;
  51857. }
  51858. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  51859. },
  51860. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  51861. var tilingOpList = new OperatorList();
  51862. var resourcesArray = [
  51863. patternDict.get('Resources'),
  51864. resources
  51865. ];
  51866. var patternResources = Dict.merge(this.xref, resourcesArray);
  51867. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  51868. operatorList.addDependencies(tilingOpList.dependencies);
  51869. operatorList.addOp(fn, getTilingPatternIR({
  51870. fnArray: tilingOpList.fnArray,
  51871. argsArray: tilingOpList.argsArray
  51872. }, patternDict, args));
  51873. });
  51874. },
  51875. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  51876. var fontName;
  51877. if (fontArgs) {
  51878. fontArgs = fontArgs.slice();
  51879. fontName = fontArgs[0].name;
  51880. }
  51881. var self = this;
  51882. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  51883. if (!translated.font.isType3Font) {
  51884. return translated;
  51885. }
  51886. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  51887. return translated;
  51888. }, function (reason) {
  51889. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51890. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  51891. });
  51892. }).then(function (translated) {
  51893. state.font = translated.font;
  51894. translated.send(self.handler);
  51895. return translated.loadedName;
  51896. });
  51897. },
  51898. handleText: function PartialEvaluator_handleText(chars, state) {
  51899. var font = state.font;
  51900. var glyphs = font.charsToGlyphs(chars);
  51901. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  51902. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  51903. var buildPath = function (fontChar) {
  51904. if (!font.renderer.hasBuiltPath(fontChar)) {
  51905. var path = font.renderer.getPathJs(fontChar);
  51906. this.handler.send('commonobj', [
  51907. font.loadedName + '_path_' + fontChar,
  51908. 'FontPath',
  51909. path
  51910. ]);
  51911. }
  51912. }.bind(this);
  51913. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  51914. var glyph = glyphs[i];
  51915. buildPath(glyph.fontChar);
  51916. var accent = glyph.accent;
  51917. if (accent && accent.fontChar) {
  51918. buildPath(accent.fontChar);
  51919. }
  51920. }
  51921. }
  51922. return glyphs;
  51923. },
  51924. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  51925. var gStateObj = [];
  51926. var gStateKeys = gState.getKeys();
  51927. var self = this;
  51928. var promise = Promise.resolve();
  51929. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  51930. var key = gStateKeys[i];
  51931. var value = gState.get(key);
  51932. switch (key) {
  51933. case 'Type':
  51934. break;
  51935. case 'LW':
  51936. case 'LC':
  51937. case 'LJ':
  51938. case 'ML':
  51939. case 'D':
  51940. case 'RI':
  51941. case 'FL':
  51942. case 'CA':
  51943. case 'ca':
  51944. gStateObj.push([
  51945. key,
  51946. value
  51947. ]);
  51948. break;
  51949. case 'Font':
  51950. promise = promise.then(function () {
  51951. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  51952. operatorList.addDependency(loadedName);
  51953. gStateObj.push([
  51954. key,
  51955. [
  51956. loadedName,
  51957. value[1]
  51958. ]
  51959. ]);
  51960. });
  51961. });
  51962. break;
  51963. case 'BM':
  51964. gStateObj.push([
  51965. key,
  51966. value
  51967. ]);
  51968. break;
  51969. case 'SMask':
  51970. if (isName(value, 'None')) {
  51971. gStateObj.push([
  51972. key,
  51973. false
  51974. ]);
  51975. break;
  51976. }
  51977. if (isDict(value)) {
  51978. promise = promise.then(function (dict) {
  51979. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  51980. }.bind(this, value));
  51981. gStateObj.push([
  51982. key,
  51983. true
  51984. ]);
  51985. } else {
  51986. warn('Unsupported SMask type');
  51987. }
  51988. break;
  51989. case 'OP':
  51990. case 'op':
  51991. case 'OPM':
  51992. case 'BG':
  51993. case 'BG2':
  51994. case 'UCR':
  51995. case 'UCR2':
  51996. case 'TR':
  51997. case 'TR2':
  51998. case 'HT':
  51999. case 'SM':
  52000. case 'SA':
  52001. case 'AIS':
  52002. case 'TK':
  52003. info('graphic state operator ' + key);
  52004. break;
  52005. default:
  52006. info('Unknown graphic state operator ' + key);
  52007. break;
  52008. }
  52009. }
  52010. return promise.then(function () {
  52011. if (gStateObj.length > 0) {
  52012. operatorList.addOp(OPS.setGState, [gStateObj]);
  52013. }
  52014. });
  52015. },
  52016. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52017. function errorFont() {
  52018. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52019. }
  52020. var fontRef;
  52021. if (font) {
  52022. assert(isRef(font));
  52023. fontRef = font;
  52024. } else {
  52025. var fontRes = resources.get('Font');
  52026. if (fontRes) {
  52027. fontRef = fontRes.getRaw(fontName);
  52028. } else {
  52029. warn('fontRes not available');
  52030. return errorFont();
  52031. }
  52032. }
  52033. if (!fontRef) {
  52034. warn('fontRef not available');
  52035. return errorFont();
  52036. }
  52037. if (this.fontCache.has(fontRef)) {
  52038. return this.fontCache.get(fontRef);
  52039. }
  52040. font = xref.fetchIfRef(fontRef);
  52041. if (!isDict(font)) {
  52042. return errorFont();
  52043. }
  52044. if (font.translated) {
  52045. return font.translated;
  52046. }
  52047. var fontCapability = createPromiseCapability();
  52048. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52049. var descriptor = preEvaluatedFont.descriptor;
  52050. var fontRefIsRef = isRef(fontRef), fontID;
  52051. if (fontRefIsRef) {
  52052. fontID = fontRef.toString();
  52053. }
  52054. if (isDict(descriptor)) {
  52055. if (!descriptor.fontAliases) {
  52056. descriptor.fontAliases = Object.create(null);
  52057. }
  52058. var fontAliases = descriptor.fontAliases;
  52059. var hash = preEvaluatedFont.hash;
  52060. if (fontAliases[hash]) {
  52061. var aliasFontRef = fontAliases[hash].aliasRef;
  52062. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52063. this.fontCache.putAlias(fontRef, aliasFontRef);
  52064. return this.fontCache.get(fontRef);
  52065. }
  52066. } else {
  52067. fontAliases[hash] = { fontID: Font.getFontID() };
  52068. }
  52069. if (fontRefIsRef) {
  52070. fontAliases[hash].aliasRef = fontRef;
  52071. }
  52072. fontID = fontAliases[hash].fontID;
  52073. }
  52074. if (fontRefIsRef) {
  52075. this.fontCache.put(fontRef, fontCapability.promise);
  52076. } else {
  52077. if (!fontID) {
  52078. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  52079. }
  52080. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52081. }
  52082. assert(fontID, 'The "fontID" must be defined.');
  52083. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52084. font.translated = fontCapability.promise;
  52085. var translatedPromise;
  52086. try {
  52087. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52088. } catch (e) {
  52089. translatedPromise = Promise.reject(e);
  52090. }
  52091. var self = this;
  52092. translatedPromise.then(function (translatedFont) {
  52093. if (translatedFont.fontType !== undefined) {
  52094. var xrefFontStats = xref.stats.fontTypes;
  52095. xrefFontStats[translatedFont.fontType] = true;
  52096. }
  52097. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52098. }, function (reason) {
  52099. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52100. try {
  52101. var descriptor = preEvaluatedFont.descriptor;
  52102. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52103. var subtype = fontFile3 && fontFile3.get('Subtype');
  52104. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52105. var xrefFontStats = xref.stats.fontTypes;
  52106. xrefFontStats[fontType] = true;
  52107. } catch (ex) {
  52108. }
  52109. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52110. });
  52111. return fontCapability.promise;
  52112. },
  52113. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52114. var lastIndex = operatorList.length - 1;
  52115. if (!args) {
  52116. args = [];
  52117. }
  52118. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52119. operatorList.addOp(OPS.constructPath, [
  52120. [fn],
  52121. args
  52122. ]);
  52123. } else {
  52124. var opArgs = operatorList.argsArray[lastIndex];
  52125. opArgs[0].push(fn);
  52126. Array.prototype.push.apply(opArgs[1], args);
  52127. }
  52128. },
  52129. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52130. var patternName = args[args.length - 1];
  52131. var pattern;
  52132. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52133. var dict = isStream(pattern) ? pattern.dict : pattern;
  52134. var typeNum = dict.get('PatternType');
  52135. if (typeNum === TILING_PATTERN) {
  52136. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52137. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52138. } else if (typeNum === SHADING_PATTERN) {
  52139. var shading = dict.get('Shading');
  52140. var matrix = dict.getArray('Matrix');
  52141. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52142. operatorList.addOp(fn, pattern.getIR());
  52143. return Promise.resolve();
  52144. } else {
  52145. return Promise.reject('Unknown PatternType: ' + typeNum);
  52146. }
  52147. }
  52148. operatorList.addOp(fn, args);
  52149. return Promise.resolve();
  52150. },
  52151. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52152. var self = this;
  52153. var xref = this.xref;
  52154. var imageCache = Object.create(null);
  52155. assert(operatorList);
  52156. resources = resources || Dict.empty;
  52157. var xobjs = resources.get('XObject') || Dict.empty;
  52158. var patterns = resources.get('Pattern') || Dict.empty;
  52159. var stateManager = new StateManager(initialState || new EvalState());
  52160. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52161. var timeSlotManager = new TimeSlotManager();
  52162. return new Promise(function promiseBody(resolve, reject) {
  52163. var next = function (promise) {
  52164. promise.then(function () {
  52165. try {
  52166. promiseBody(resolve, reject);
  52167. } catch (ex) {
  52168. reject(ex);
  52169. }
  52170. }, reject);
  52171. };
  52172. task.ensureNotTerminated();
  52173. timeSlotManager.reset();
  52174. var stop, operation = {}, i, ii, cs;
  52175. while (!(stop = timeSlotManager.check())) {
  52176. operation.args = null;
  52177. if (!preprocessor.read(operation)) {
  52178. break;
  52179. }
  52180. var args = operation.args;
  52181. var fn = operation.fn;
  52182. switch (fn | 0) {
  52183. case OPS.paintXObject:
  52184. if (args[0].code) {
  52185. break;
  52186. }
  52187. var name = args[0].name;
  52188. if (!name) {
  52189. warn('XObject must be referred to by name.');
  52190. continue;
  52191. }
  52192. if (imageCache[name] !== undefined) {
  52193. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52194. args = null;
  52195. continue;
  52196. }
  52197. var xobj = xobjs.get(name);
  52198. if (xobj) {
  52199. assert(isStream(xobj), 'XObject should be a stream');
  52200. var type = xobj.dict.get('Subtype');
  52201. assert(isName(type), 'XObject should have a Name subtype');
  52202. if (type.name === 'Form') {
  52203. stateManager.save();
  52204. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52205. stateManager.restore();
  52206. }));
  52207. return;
  52208. } else if (type.name === 'Image') {
  52209. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52210. args = null;
  52211. continue;
  52212. } else if (type.name === 'PS') {
  52213. info('Ignored XObject subtype PS');
  52214. continue;
  52215. } else {
  52216. error('Unhandled XObject subtype ' + type.name);
  52217. }
  52218. }
  52219. break;
  52220. case OPS.setFont:
  52221. var fontSize = args[1];
  52222. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52223. operatorList.addDependency(loadedName);
  52224. operatorList.addOp(OPS.setFont, [
  52225. loadedName,
  52226. fontSize
  52227. ]);
  52228. }));
  52229. return;
  52230. case OPS.endInlineImage:
  52231. var cacheKey = args[0].cacheKey;
  52232. if (cacheKey) {
  52233. var cacheEntry = imageCache[cacheKey];
  52234. if (cacheEntry !== undefined) {
  52235. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52236. args = null;
  52237. continue;
  52238. }
  52239. }
  52240. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52241. args = null;
  52242. continue;
  52243. case OPS.showText:
  52244. args[0] = self.handleText(args[0], stateManager.state);
  52245. break;
  52246. case OPS.showSpacedText:
  52247. var arr = args[0];
  52248. var combinedGlyphs = [];
  52249. var arrLength = arr.length;
  52250. var state = stateManager.state;
  52251. for (i = 0; i < arrLength; ++i) {
  52252. var arrItem = arr[i];
  52253. if (isString(arrItem)) {
  52254. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52255. } else if (isNum(arrItem)) {
  52256. combinedGlyphs.push(arrItem);
  52257. }
  52258. }
  52259. args[0] = combinedGlyphs;
  52260. fn = OPS.showText;
  52261. break;
  52262. case OPS.nextLineShowText:
  52263. operatorList.addOp(OPS.nextLine);
  52264. args[0] = self.handleText(args[0], stateManager.state);
  52265. fn = OPS.showText;
  52266. break;
  52267. case OPS.nextLineSetSpacingShowText:
  52268. operatorList.addOp(OPS.nextLine);
  52269. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52270. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52271. args[0] = self.handleText(args[0], stateManager.state);
  52272. fn = OPS.showText;
  52273. break;
  52274. case OPS.setTextRenderingMode:
  52275. stateManager.state.textRenderingMode = args[0];
  52276. break;
  52277. case OPS.setFillColorSpace:
  52278. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52279. continue;
  52280. case OPS.setStrokeColorSpace:
  52281. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52282. continue;
  52283. case OPS.setFillColor:
  52284. cs = stateManager.state.fillColorSpace;
  52285. args = cs.getRgb(args, 0);
  52286. fn = OPS.setFillRGBColor;
  52287. break;
  52288. case OPS.setStrokeColor:
  52289. cs = stateManager.state.strokeColorSpace;
  52290. args = cs.getRgb(args, 0);
  52291. fn = OPS.setStrokeRGBColor;
  52292. break;
  52293. case OPS.setFillGray:
  52294. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52295. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52296. fn = OPS.setFillRGBColor;
  52297. break;
  52298. case OPS.setStrokeGray:
  52299. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52300. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52301. fn = OPS.setStrokeRGBColor;
  52302. break;
  52303. case OPS.setFillCMYKColor:
  52304. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52305. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52306. fn = OPS.setFillRGBColor;
  52307. break;
  52308. case OPS.setStrokeCMYKColor:
  52309. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52310. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52311. fn = OPS.setStrokeRGBColor;
  52312. break;
  52313. case OPS.setFillRGBColor:
  52314. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52315. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52316. break;
  52317. case OPS.setStrokeRGBColor:
  52318. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52319. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52320. break;
  52321. case OPS.setFillColorN:
  52322. cs = stateManager.state.fillColorSpace;
  52323. if (cs.name === 'Pattern') {
  52324. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52325. return;
  52326. }
  52327. args = cs.getRgb(args, 0);
  52328. fn = OPS.setFillRGBColor;
  52329. break;
  52330. case OPS.setStrokeColorN:
  52331. cs = stateManager.state.strokeColorSpace;
  52332. if (cs.name === 'Pattern') {
  52333. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52334. return;
  52335. }
  52336. args = cs.getRgb(args, 0);
  52337. fn = OPS.setStrokeRGBColor;
  52338. break;
  52339. case OPS.shadingFill:
  52340. var shadingRes = resources.get('Shading');
  52341. if (!shadingRes) {
  52342. error('No shading resource found');
  52343. }
  52344. var shading = shadingRes.get(args[0].name);
  52345. if (!shading) {
  52346. error('No shading object found');
  52347. }
  52348. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52349. var patternIR = shadingFill.getIR();
  52350. args = [patternIR];
  52351. fn = OPS.shadingFill;
  52352. break;
  52353. case OPS.setGState:
  52354. var dictName = args[0];
  52355. var extGState = resources.get('ExtGState');
  52356. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52357. break;
  52358. }
  52359. var gState = extGState.get(dictName.name);
  52360. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52361. return;
  52362. case OPS.moveTo:
  52363. case OPS.lineTo:
  52364. case OPS.curveTo:
  52365. case OPS.curveTo2:
  52366. case OPS.curveTo3:
  52367. case OPS.closePath:
  52368. self.buildPath(operatorList, fn, args);
  52369. continue;
  52370. case OPS.rectangle:
  52371. self.buildPath(operatorList, fn, args);
  52372. continue;
  52373. case OPS.markPoint:
  52374. case OPS.markPointProps:
  52375. case OPS.beginMarkedContent:
  52376. case OPS.beginMarkedContentProps:
  52377. case OPS.endMarkedContent:
  52378. case OPS.beginCompat:
  52379. case OPS.endCompat:
  52380. continue;
  52381. default:
  52382. if (args !== null) {
  52383. for (i = 0, ii = args.length; i < ii; i++) {
  52384. if (args[i] instanceof Dict) {
  52385. break;
  52386. }
  52387. }
  52388. if (i < ii) {
  52389. warn('getOperatorList - ignoring operator: ' + fn);
  52390. continue;
  52391. }
  52392. }
  52393. }
  52394. operatorList.addOp(fn, args);
  52395. }
  52396. if (stop) {
  52397. next(deferred);
  52398. return;
  52399. }
  52400. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52401. operatorList.addOp(OPS.restore, []);
  52402. }
  52403. resolve();
  52404. });
  52405. },
  52406. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52407. stateManager = stateManager || new StateManager(new TextState());
  52408. var WhitespaceRegexp = /\s/g;
  52409. var textContent = {
  52410. items: [],
  52411. styles: Object.create(null)
  52412. };
  52413. var textContentItem = {
  52414. initialized: false,
  52415. str: [],
  52416. width: 0,
  52417. height: 0,
  52418. vertical: false,
  52419. lastAdvanceWidth: 0,
  52420. lastAdvanceHeight: 0,
  52421. textAdvanceScale: 0,
  52422. spaceWidth: 0,
  52423. fakeSpaceMin: Infinity,
  52424. fakeMultiSpaceMin: Infinity,
  52425. fakeMultiSpaceMax: -0,
  52426. textRunBreakAllowed: false,
  52427. transform: null,
  52428. fontName: null
  52429. };
  52430. var SPACE_FACTOR = 0.3;
  52431. var MULTI_SPACE_FACTOR = 1.5;
  52432. var MULTI_SPACE_FACTOR_MAX = 4;
  52433. var self = this;
  52434. var xref = this.xref;
  52435. resources = xref.fetchIfRef(resources) || Dict.empty;
  52436. var xobjs = null;
  52437. var xobjsCache = Object.create(null);
  52438. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52439. var textState;
  52440. function ensureTextContentItem() {
  52441. if (textContentItem.initialized) {
  52442. return textContentItem;
  52443. }
  52444. var font = textState.font;
  52445. if (!(font.loadedName in textContent.styles)) {
  52446. textContent.styles[font.loadedName] = {
  52447. fontFamily: font.fallbackName,
  52448. ascent: font.ascent,
  52449. descent: font.descent,
  52450. vertical: font.vertical
  52451. };
  52452. }
  52453. textContentItem.fontName = font.loadedName;
  52454. var tsm = [
  52455. textState.fontSize * textState.textHScale,
  52456. 0,
  52457. 0,
  52458. textState.fontSize,
  52459. 0,
  52460. textState.textRise
  52461. ];
  52462. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52463. var glyphHeight = font.bbox[3] - font.bbox[1];
  52464. if (glyphHeight > 0) {
  52465. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52466. tsm[3] *= glyphHeight;
  52467. }
  52468. }
  52469. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52470. textContentItem.transform = trm;
  52471. if (!font.vertical) {
  52472. textContentItem.width = 0;
  52473. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52474. textContentItem.vertical = false;
  52475. } else {
  52476. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52477. textContentItem.height = 0;
  52478. textContentItem.vertical = true;
  52479. }
  52480. var a = textState.textLineMatrix[0];
  52481. var b = textState.textLineMatrix[1];
  52482. var scaleLineX = Math.sqrt(a * a + b * b);
  52483. a = textState.ctm[0];
  52484. b = textState.ctm[1];
  52485. var scaleCtmX = Math.sqrt(a * a + b * b);
  52486. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52487. textContentItem.lastAdvanceWidth = 0;
  52488. textContentItem.lastAdvanceHeight = 0;
  52489. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52490. if (spaceWidth) {
  52491. textContentItem.spaceWidth = spaceWidth;
  52492. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52493. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52494. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52495. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52496. } else {
  52497. textContentItem.spaceWidth = 0;
  52498. textContentItem.fakeSpaceMin = Infinity;
  52499. textContentItem.fakeMultiSpaceMin = Infinity;
  52500. textContentItem.fakeMultiSpaceMax = 0;
  52501. textContentItem.textRunBreakAllowed = false;
  52502. }
  52503. textContentItem.initialized = true;
  52504. return textContentItem;
  52505. }
  52506. function replaceWhitespace(str) {
  52507. var i = 0, ii = str.length, code;
  52508. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52509. i++;
  52510. }
  52511. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52512. }
  52513. function runBidiTransform(textChunk) {
  52514. var str = textChunk.str.join('');
  52515. var bidiResult = bidi(str, -1, textChunk.vertical);
  52516. return {
  52517. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52518. dir: bidiResult.dir,
  52519. width: textChunk.width,
  52520. height: textChunk.height,
  52521. transform: textChunk.transform,
  52522. fontName: textChunk.fontName
  52523. };
  52524. }
  52525. function handleSetFont(fontName, fontRef) {
  52526. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52527. textState.font = translated.font;
  52528. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52529. });
  52530. }
  52531. function buildTextContentItem(chars) {
  52532. var font = textState.font;
  52533. var textChunk = ensureTextContentItem();
  52534. var width = 0;
  52535. var height = 0;
  52536. var glyphs = font.charsToGlyphs(chars);
  52537. var defaultVMetrics = font.defaultVMetrics;
  52538. for (var i = 0; i < glyphs.length; i++) {
  52539. var glyph = glyphs[i];
  52540. var vMetricX = null;
  52541. var vMetricY = null;
  52542. var glyphWidth = null;
  52543. if (font.vertical) {
  52544. if (glyph.vmetric) {
  52545. glyphWidth = glyph.vmetric[0];
  52546. vMetricX = glyph.vmetric[1];
  52547. vMetricY = glyph.vmetric[2];
  52548. } else {
  52549. glyphWidth = glyph.width;
  52550. vMetricX = glyph.width * 0.5;
  52551. vMetricY = defaultVMetrics[2];
  52552. }
  52553. } else {
  52554. glyphWidth = glyph.width;
  52555. }
  52556. var glyphUnicode = glyph.unicode;
  52557. var NormalizedUnicodes = getNormalizedUnicodes();
  52558. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52559. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52560. }
  52561. glyphUnicode = reverseIfRtl(glyphUnicode);
  52562. var charSpacing = textState.charSpacing;
  52563. if (glyph.isSpace) {
  52564. var wordSpacing = textState.wordSpacing;
  52565. charSpacing += wordSpacing;
  52566. if (wordSpacing > 0) {
  52567. addFakeSpaces(wordSpacing, textChunk.str);
  52568. }
  52569. }
  52570. var tx = 0;
  52571. var ty = 0;
  52572. if (!font.vertical) {
  52573. var w0 = glyphWidth * textState.fontMatrix[0];
  52574. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52575. width += tx;
  52576. } else {
  52577. var w1 = glyphWidth * textState.fontMatrix[0];
  52578. ty = w1 * textState.fontSize + charSpacing;
  52579. height += ty;
  52580. }
  52581. textState.translateTextMatrix(tx, ty);
  52582. textChunk.str.push(glyphUnicode);
  52583. }
  52584. if (!font.vertical) {
  52585. textChunk.lastAdvanceWidth = width;
  52586. textChunk.width += width * textChunk.textAdvanceScale;
  52587. } else {
  52588. textChunk.lastAdvanceHeight = height;
  52589. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  52590. }
  52591. return textChunk;
  52592. }
  52593. function addFakeSpaces(width, strBuf) {
  52594. if (width < textContentItem.fakeSpaceMin) {
  52595. return;
  52596. }
  52597. if (width < textContentItem.fakeMultiSpaceMin) {
  52598. strBuf.push(' ');
  52599. return;
  52600. }
  52601. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52602. while (fakeSpaces-- > 0) {
  52603. strBuf.push(' ');
  52604. }
  52605. }
  52606. function flushTextContentItem() {
  52607. if (!textContentItem.initialized) {
  52608. return;
  52609. }
  52610. textContent.items.push(runBidiTransform(textContentItem));
  52611. textContentItem.initialized = false;
  52612. textContentItem.str.length = 0;
  52613. }
  52614. var timeSlotManager = new TimeSlotManager();
  52615. return new Promise(function promiseBody(resolve, reject) {
  52616. var next = function (promise) {
  52617. promise.then(function () {
  52618. try {
  52619. promiseBody(resolve, reject);
  52620. } catch (ex) {
  52621. reject(ex);
  52622. }
  52623. }, reject);
  52624. };
  52625. task.ensureNotTerminated();
  52626. timeSlotManager.reset();
  52627. var stop, operation = {}, args = [];
  52628. while (!(stop = timeSlotManager.check())) {
  52629. args.length = 0;
  52630. operation.args = args;
  52631. if (!preprocessor.read(operation)) {
  52632. break;
  52633. }
  52634. textState = stateManager.state;
  52635. var fn = operation.fn;
  52636. args = operation.args;
  52637. var advance, diff;
  52638. switch (fn | 0) {
  52639. case OPS.setFont:
  52640. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52641. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52642. break;
  52643. }
  52644. flushTextContentItem();
  52645. textState.fontName = fontNameArg;
  52646. textState.fontSize = fontSizeArg;
  52647. next(handleSetFont(fontNameArg, null));
  52648. return;
  52649. case OPS.setTextRise:
  52650. flushTextContentItem();
  52651. textState.textRise = args[0];
  52652. break;
  52653. case OPS.setHScale:
  52654. flushTextContentItem();
  52655. textState.textHScale = args[0] / 100;
  52656. break;
  52657. case OPS.setLeading:
  52658. flushTextContentItem();
  52659. textState.leading = args[0];
  52660. break;
  52661. case OPS.moveText:
  52662. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52663. advance = args[0] - args[1];
  52664. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52665. textState.translateTextLineMatrix(args[0], args[1]);
  52666. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52667. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52668. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52669. addFakeSpaces(diff, textContentItem.str);
  52670. break;
  52671. }
  52672. flushTextContentItem();
  52673. textState.translateTextLineMatrix(args[0], args[1]);
  52674. textState.textMatrix = textState.textLineMatrix.slice();
  52675. break;
  52676. case OPS.setLeadingMoveText:
  52677. flushTextContentItem();
  52678. textState.leading = -args[1];
  52679. textState.translateTextLineMatrix(args[0], args[1]);
  52680. textState.textMatrix = textState.textLineMatrix.slice();
  52681. break;
  52682. case OPS.nextLine:
  52683. flushTextContentItem();
  52684. textState.carriageReturn();
  52685. break;
  52686. case OPS.setTextMatrix:
  52687. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52688. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52689. textState.translateTextLineMatrix(advance.width, advance.height);
  52690. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52691. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52692. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52693. addFakeSpaces(diff, textContentItem.str);
  52694. break;
  52695. }
  52696. flushTextContentItem();
  52697. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52698. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52699. break;
  52700. case OPS.setCharSpacing:
  52701. textState.charSpacing = args[0];
  52702. break;
  52703. case OPS.setWordSpacing:
  52704. textState.wordSpacing = args[0];
  52705. break;
  52706. case OPS.beginText:
  52707. flushTextContentItem();
  52708. textState.textMatrix = IDENTITY_MATRIX.slice();
  52709. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52710. break;
  52711. case OPS.showSpacedText:
  52712. var items = args[0];
  52713. var offset;
  52714. for (var j = 0, jj = items.length; j < jj; j++) {
  52715. if (typeof items[j] === 'string') {
  52716. buildTextContentItem(items[j]);
  52717. } else if (isNum(items[j])) {
  52718. ensureTextContentItem();
  52719. advance = items[j] * textState.fontSize / 1000;
  52720. var breakTextRun = false;
  52721. if (textState.font.vertical) {
  52722. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  52723. textState.translateTextMatrix(0, advance);
  52724. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52725. if (!breakTextRun) {
  52726. textContentItem.height += offset;
  52727. }
  52728. } else {
  52729. advance = -advance;
  52730. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  52731. textState.translateTextMatrix(advance, 0);
  52732. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52733. if (!breakTextRun) {
  52734. textContentItem.width += offset;
  52735. }
  52736. }
  52737. if (breakTextRun) {
  52738. flushTextContentItem();
  52739. } else if (advance > 0) {
  52740. addFakeSpaces(advance, textContentItem.str);
  52741. }
  52742. }
  52743. }
  52744. break;
  52745. case OPS.showText:
  52746. buildTextContentItem(args[0]);
  52747. break;
  52748. case OPS.nextLineShowText:
  52749. flushTextContentItem();
  52750. textState.carriageReturn();
  52751. buildTextContentItem(args[0]);
  52752. break;
  52753. case OPS.nextLineSetSpacingShowText:
  52754. flushTextContentItem();
  52755. textState.wordSpacing = args[0];
  52756. textState.charSpacing = args[1];
  52757. textState.carriageReturn();
  52758. buildTextContentItem(args[2]);
  52759. break;
  52760. case OPS.paintXObject:
  52761. flushTextContentItem();
  52762. if (args[0].code) {
  52763. break;
  52764. }
  52765. if (!xobjs) {
  52766. xobjs = resources.get('XObject') || Dict.empty;
  52767. }
  52768. var name = args[0].name;
  52769. if (xobjsCache.key === name) {
  52770. if (xobjsCache.texts) {
  52771. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52772. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52773. }
  52774. break;
  52775. }
  52776. var xobj = xobjs.get(name);
  52777. if (!xobj) {
  52778. break;
  52779. }
  52780. assert(isStream(xobj), 'XObject should be a stream');
  52781. var type = xobj.dict.get('Subtype');
  52782. assert(isName(type), 'XObject should have a Name subtype');
  52783. if ('Form' !== type.name) {
  52784. xobjsCache.key = name;
  52785. xobjsCache.texts = null;
  52786. break;
  52787. }
  52788. stateManager.save();
  52789. var matrix = xobj.dict.getArray('Matrix');
  52790. if (isArray(matrix) && matrix.length === 6) {
  52791. stateManager.transform(matrix);
  52792. }
  52793. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52794. Util.appendToArray(textContent.items, formTextContent.items);
  52795. Util.extendObj(textContent.styles, formTextContent.styles);
  52796. stateManager.restore();
  52797. xobjsCache.key = name;
  52798. xobjsCache.texts = formTextContent;
  52799. }));
  52800. return;
  52801. case OPS.setGState:
  52802. flushTextContentItem();
  52803. var dictName = args[0];
  52804. var extGState = resources.get('ExtGState');
  52805. if (!isDict(extGState) || !isName(dictName)) {
  52806. break;
  52807. }
  52808. var gState = extGState.get(dictName.name);
  52809. if (!isDict(gState)) {
  52810. break;
  52811. }
  52812. var gStateFont = gState.get('Font');
  52813. if (gStateFont) {
  52814. textState.fontName = null;
  52815. textState.fontSize = gStateFont[1];
  52816. next(handleSetFont(null, gStateFont[0]));
  52817. return;
  52818. }
  52819. break;
  52820. }
  52821. }
  52822. if (stop) {
  52823. next(deferred);
  52824. return;
  52825. }
  52826. flushTextContentItem();
  52827. resolve(textContent);
  52828. });
  52829. },
  52830. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52831. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52832. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52833. if (properties.composite) {
  52834. var cidSystemInfo = dict.get('CIDSystemInfo');
  52835. if (isDict(cidSystemInfo)) {
  52836. properties.cidSystemInfo = {
  52837. registry: cidSystemInfo.get('Registry'),
  52838. ordering: cidSystemInfo.get('Ordering'),
  52839. supplement: cidSystemInfo.get('Supplement')
  52840. };
  52841. }
  52842. var cidToGidMap = dict.get('CIDToGIDMap');
  52843. if (isStream(cidToGidMap)) {
  52844. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52845. }
  52846. }
  52847. var differences = [];
  52848. var baseEncodingName = null;
  52849. var encoding;
  52850. if (dict.has('Encoding')) {
  52851. encoding = dict.get('Encoding');
  52852. if (isDict(encoding)) {
  52853. baseEncodingName = encoding.get('BaseEncoding');
  52854. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  52855. if (encoding.has('Differences')) {
  52856. var diffEncoding = encoding.get('Differences');
  52857. var index = 0;
  52858. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  52859. var data = xref.fetchIfRef(diffEncoding[j]);
  52860. if (isNum(data)) {
  52861. index = data;
  52862. } else if (isName(data)) {
  52863. differences[index++] = data.name;
  52864. } else {
  52865. error('Invalid entry in \'Differences\' array: ' + data);
  52866. }
  52867. }
  52868. }
  52869. } else if (isName(encoding)) {
  52870. baseEncodingName = encoding.name;
  52871. } else {
  52872. error('Encoding is not a Name nor a Dict');
  52873. }
  52874. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  52875. baseEncodingName = null;
  52876. }
  52877. }
  52878. if (baseEncodingName) {
  52879. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  52880. } else {
  52881. encoding = properties.type === 'TrueType' ? WinAnsiEncoding : StandardEncoding;
  52882. if (!!(properties.flags & FontFlags.Symbolic)) {
  52883. encoding = MacRomanEncoding;
  52884. if (!properties.file) {
  52885. if (/Symbol/i.test(properties.name)) {
  52886. encoding = SymbolSetEncoding;
  52887. } else if (/Dingbats/i.test(properties.name)) {
  52888. encoding = ZapfDingbatsEncoding;
  52889. }
  52890. }
  52891. }
  52892. properties.defaultEncoding = encoding;
  52893. }
  52894. properties.differences = differences;
  52895. properties.baseEncodingName = baseEncodingName;
  52896. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  52897. properties.dict = dict;
  52898. return toUnicodePromise.then(function (toUnicode) {
  52899. properties.toUnicode = toUnicode;
  52900. return this.buildToUnicode(properties);
  52901. }.bind(this)).then(function (toUnicode) {
  52902. properties.toUnicode = toUnicode;
  52903. return properties;
  52904. });
  52905. },
  52906. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  52907. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  52908. if (properties.hasIncludedToUnicodeMap) {
  52909. return Promise.resolve(properties.toUnicode);
  52910. }
  52911. var toUnicode, charcode, glyphName;
  52912. if (!properties.composite)
  52913. {
  52914. toUnicode = [];
  52915. var encoding = properties.defaultEncoding.slice();
  52916. var baseEncodingName = properties.baseEncodingName;
  52917. var differences = properties.differences;
  52918. for (charcode in differences) {
  52919. glyphName = differences[charcode];
  52920. if (glyphName === '.notdef') {
  52921. continue;
  52922. }
  52923. encoding[charcode] = glyphName;
  52924. }
  52925. var glyphsUnicodeMap = getGlyphsUnicode();
  52926. for (charcode in encoding) {
  52927. glyphName = encoding[charcode];
  52928. if (glyphName === '') {
  52929. continue;
  52930. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  52931. var code = 0;
  52932. switch (glyphName[0]) {
  52933. case 'G':
  52934. if (glyphName.length === 3) {
  52935. code = parseInt(glyphName.substr(1), 16);
  52936. }
  52937. break;
  52938. case 'g':
  52939. if (glyphName.length === 5) {
  52940. code = parseInt(glyphName.substr(1), 16);
  52941. }
  52942. break;
  52943. case 'C':
  52944. case 'c':
  52945. if (glyphName.length >= 3) {
  52946. code = +glyphName.substr(1);
  52947. }
  52948. break;
  52949. default:
  52950. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  52951. if (unicode !== -1) {
  52952. code = unicode;
  52953. }
  52954. }
  52955. if (code) {
  52956. if (baseEncodingName && code === +charcode) {
  52957. var baseEncoding = getEncoding(baseEncodingName);
  52958. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  52959. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52960. continue;
  52961. }
  52962. }
  52963. toUnicode[charcode] = String.fromCharCode(code);
  52964. }
  52965. continue;
  52966. }
  52967. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52968. }
  52969. return Promise.resolve(new ToUnicodeMap(toUnicode));
  52970. }
  52971. 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'))) {
  52972. var registry = properties.cidSystemInfo.registry;
  52973. var ordering = properties.cidSystemInfo.ordering;
  52974. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  52975. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  52976. var cMap = properties.cMap;
  52977. toUnicode = [];
  52978. cMap.forEach(function (charcode, cid) {
  52979. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  52980. var ucs2 = ucs2CMap.lookup(cid);
  52981. if (ucs2) {
  52982. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  52983. }
  52984. });
  52985. return new ToUnicodeMap(toUnicode);
  52986. });
  52987. }
  52988. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  52989. },
  52990. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  52991. var cmapObj = toUnicode;
  52992. if (isName(cmapObj)) {
  52993. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  52994. if (cmap instanceof IdentityCMap) {
  52995. return new IdentityToUnicodeMap(0, 0xFFFF);
  52996. }
  52997. return new ToUnicodeMap(cmap.getMap());
  52998. });
  52999. } else if (isStream(cmapObj)) {
  53000. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53001. if (cmap instanceof IdentityCMap) {
  53002. return new IdentityToUnicodeMap(0, 0xFFFF);
  53003. }
  53004. var map = new Array(cmap.length);
  53005. cmap.forEach(function (charCode, token) {
  53006. var str = [];
  53007. for (var k = 0; k < token.length; k += 2) {
  53008. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53009. if ((w1 & 0xF800) !== 0xD800) {
  53010. str.push(w1);
  53011. continue;
  53012. }
  53013. k += 2;
  53014. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53015. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53016. }
  53017. map[charCode] = String.fromCharCode.apply(String, str);
  53018. });
  53019. return new ToUnicodeMap(map);
  53020. });
  53021. }
  53022. return Promise.resolve(null);
  53023. },
  53024. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53025. var glyphsData = cidToGidStream.getBytes();
  53026. var result = [];
  53027. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53028. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53029. if (glyphID === 0) {
  53030. continue;
  53031. }
  53032. var code = j >> 1;
  53033. result[code] = glyphID;
  53034. }
  53035. return result;
  53036. },
  53037. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53038. var glyphsWidths = [];
  53039. var defaultWidth = 0;
  53040. var glyphsVMetrics = [];
  53041. var defaultVMetrics;
  53042. var i, ii, j, jj, start, code, widths;
  53043. if (properties.composite) {
  53044. defaultWidth = dict.get('DW') || 1000;
  53045. widths = dict.get('W');
  53046. if (widths) {
  53047. for (i = 0, ii = widths.length; i < ii; i++) {
  53048. start = widths[i++];
  53049. code = xref.fetchIfRef(widths[i]);
  53050. if (isArray(code)) {
  53051. for (j = 0, jj = code.length; j < jj; j++) {
  53052. glyphsWidths[start++] = code[j];
  53053. }
  53054. } else {
  53055. var width = widths[++i];
  53056. for (j = start; j <= code; j++) {
  53057. glyphsWidths[j] = width;
  53058. }
  53059. }
  53060. }
  53061. }
  53062. if (properties.vertical) {
  53063. var vmetrics = dict.get('DW2') || [
  53064. 880,
  53065. -1000
  53066. ];
  53067. defaultVMetrics = [
  53068. vmetrics[1],
  53069. defaultWidth * 0.5,
  53070. vmetrics[0]
  53071. ];
  53072. vmetrics = dict.get('W2');
  53073. if (vmetrics) {
  53074. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53075. start = vmetrics[i++];
  53076. code = xref.fetchIfRef(vmetrics[i]);
  53077. if (isArray(code)) {
  53078. for (j = 0, jj = code.length; j < jj; j++) {
  53079. glyphsVMetrics[start++] = [
  53080. code[j++],
  53081. code[j++],
  53082. code[j]
  53083. ];
  53084. }
  53085. } else {
  53086. var vmetric = [
  53087. vmetrics[++i],
  53088. vmetrics[++i],
  53089. vmetrics[++i]
  53090. ];
  53091. for (j = start; j <= code; j++) {
  53092. glyphsVMetrics[j] = vmetric;
  53093. }
  53094. }
  53095. }
  53096. }
  53097. }
  53098. } else {
  53099. var firstChar = properties.firstChar;
  53100. widths = dict.get('Widths');
  53101. if (widths) {
  53102. j = firstChar;
  53103. for (i = 0, ii = widths.length; i < ii; i++) {
  53104. glyphsWidths[j++] = widths[i];
  53105. }
  53106. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53107. } else {
  53108. var baseFontName = dict.get('BaseFont');
  53109. if (isName(baseFontName)) {
  53110. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53111. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53112. defaultWidth = metrics.defaultWidth;
  53113. }
  53114. }
  53115. }
  53116. var isMonospace = true;
  53117. var firstWidth = defaultWidth;
  53118. for (var glyph in glyphsWidths) {
  53119. var glyphWidth = glyphsWidths[glyph];
  53120. if (!glyphWidth) {
  53121. continue;
  53122. }
  53123. if (!firstWidth) {
  53124. firstWidth = glyphWidth;
  53125. continue;
  53126. }
  53127. if (firstWidth !== glyphWidth) {
  53128. isMonospace = false;
  53129. break;
  53130. }
  53131. }
  53132. if (isMonospace) {
  53133. properties.flags |= FontFlags.FixedPitch;
  53134. }
  53135. properties.defaultWidth = defaultWidth;
  53136. properties.widths = glyphsWidths;
  53137. properties.defaultVMetrics = defaultVMetrics;
  53138. properties.vmetrics = glyphsVMetrics;
  53139. },
  53140. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53141. var fontNameWoStyle = baseFontName.split('-')[0];
  53142. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53143. },
  53144. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53145. var defaultWidth = 0;
  53146. var widths = [];
  53147. var monospace = false;
  53148. var stdFontMap = getStdFontMap();
  53149. var lookupName = stdFontMap[name] || name;
  53150. var Metrics = getMetrics();
  53151. if (!(lookupName in Metrics)) {
  53152. if (this.isSerifFont(name)) {
  53153. lookupName = 'Times-Roman';
  53154. } else {
  53155. lookupName = 'Helvetica';
  53156. }
  53157. }
  53158. var glyphWidths = Metrics[lookupName];
  53159. if (isNum(glyphWidths)) {
  53160. defaultWidth = glyphWidths;
  53161. monospace = true;
  53162. } else {
  53163. widths = glyphWidths();
  53164. }
  53165. return {
  53166. defaultWidth: defaultWidth,
  53167. monospace: monospace,
  53168. widths: widths
  53169. };
  53170. },
  53171. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53172. var widths = Object.create(null);
  53173. var differences = properties.differences;
  53174. var encoding = properties.defaultEncoding;
  53175. for (var charCode = 0; charCode < 256; charCode++) {
  53176. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53177. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53178. continue;
  53179. }
  53180. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53181. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53182. continue;
  53183. }
  53184. }
  53185. return widths;
  53186. },
  53187. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53188. var baseDict = dict;
  53189. var type = dict.get('Subtype');
  53190. assert(isName(type), 'invalid font Subtype');
  53191. var composite = false;
  53192. var uint8array;
  53193. if (type.name === 'Type0') {
  53194. var df = dict.get('DescendantFonts');
  53195. if (!df) {
  53196. error('Descendant fonts are not specified');
  53197. }
  53198. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53199. type = dict.get('Subtype');
  53200. assert(isName(type), 'invalid font Subtype');
  53201. composite = true;
  53202. }
  53203. var descriptor = dict.get('FontDescriptor');
  53204. if (descriptor) {
  53205. var hash = new MurmurHash3_64();
  53206. var encoding = baseDict.getRaw('Encoding');
  53207. if (isName(encoding)) {
  53208. hash.update(encoding.name);
  53209. } else if (isRef(encoding)) {
  53210. hash.update(encoding.toString());
  53211. } else if (isDict(encoding)) {
  53212. var keys = encoding.getKeys();
  53213. for (var i = 0, ii = keys.length; i < ii; i++) {
  53214. var entry = encoding.getRaw(keys[i]);
  53215. if (isName(entry)) {
  53216. hash.update(entry.name);
  53217. } else if (isRef(entry)) {
  53218. hash.update(entry.toString());
  53219. } else if (isArray(entry)) {
  53220. hash.update(entry.length.toString());
  53221. }
  53222. }
  53223. }
  53224. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53225. if (isStream(toUnicode)) {
  53226. var stream = toUnicode.str || toUnicode;
  53227. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53228. hash.update(uint8array);
  53229. } else if (isName(toUnicode)) {
  53230. hash.update(toUnicode.name);
  53231. }
  53232. var widths = dict.get('Widths') || baseDict.get('Widths');
  53233. if (widths) {
  53234. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53235. hash.update(uint8array);
  53236. }
  53237. }
  53238. return {
  53239. descriptor: descriptor,
  53240. dict: dict,
  53241. baseDict: baseDict,
  53242. composite: composite,
  53243. type: type.name,
  53244. hash: hash ? hash.hexdigest() : ''
  53245. };
  53246. },
  53247. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53248. var baseDict = preEvaluatedFont.baseDict;
  53249. var dict = preEvaluatedFont.dict;
  53250. var composite = preEvaluatedFont.composite;
  53251. var descriptor = preEvaluatedFont.descriptor;
  53252. var type = preEvaluatedFont.type;
  53253. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53254. var cMapOptions = this.options.cMapOptions;
  53255. var properties;
  53256. if (!descriptor) {
  53257. if (type === 'Type3') {
  53258. descriptor = new Dict(null);
  53259. descriptor.set('FontName', Name.get(type));
  53260. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53261. } else {
  53262. var baseFontName = dict.get('BaseFont');
  53263. if (!isName(baseFontName)) {
  53264. error('Base font is not specified');
  53265. }
  53266. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53267. var metrics = this.getBaseFontMetrics(baseFontName);
  53268. var fontNameWoStyle = baseFontName.split('-')[0];
  53269. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53270. properties = {
  53271. type: type,
  53272. name: baseFontName,
  53273. widths: metrics.widths,
  53274. defaultWidth: metrics.defaultWidth,
  53275. flags: flags,
  53276. firstChar: 0,
  53277. lastChar: maxCharIndex
  53278. };
  53279. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53280. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53281. return new Font(baseFontName, null, properties);
  53282. }.bind(this));
  53283. }
  53284. }
  53285. var firstChar = dict.get('FirstChar') || 0;
  53286. var lastChar = dict.get('LastChar') || maxCharIndex;
  53287. var fontName = descriptor.get('FontName');
  53288. var baseFont = dict.get('BaseFont');
  53289. if (isString(fontName)) {
  53290. fontName = Name.get(fontName);
  53291. }
  53292. if (isString(baseFont)) {
  53293. baseFont = Name.get(baseFont);
  53294. }
  53295. if (type !== 'Type3') {
  53296. var fontNameStr = fontName && fontName.name;
  53297. var baseFontStr = baseFont && baseFont.name;
  53298. if (fontNameStr !== baseFontStr) {
  53299. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53300. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53301. fontName = baseFont;
  53302. }
  53303. }
  53304. }
  53305. fontName = fontName || baseFont;
  53306. assert(isName(fontName), 'invalid font name');
  53307. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53308. if (fontFile) {
  53309. if (fontFile.dict) {
  53310. var subtype = fontFile.dict.get('Subtype');
  53311. if (subtype) {
  53312. subtype = subtype.name;
  53313. }
  53314. var length1 = fontFile.dict.get('Length1');
  53315. var length2 = fontFile.dict.get('Length2');
  53316. var length3 = fontFile.dict.get('Length3');
  53317. }
  53318. }
  53319. properties = {
  53320. type: type,
  53321. name: fontName.name,
  53322. subtype: subtype,
  53323. file: fontFile,
  53324. length1: length1,
  53325. length2: length2,
  53326. length3: length3,
  53327. loadedName: baseDict.loadedName,
  53328. composite: composite,
  53329. wideChars: composite,
  53330. fixedPitch: false,
  53331. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53332. firstChar: firstChar || 0,
  53333. lastChar: lastChar || maxCharIndex,
  53334. bbox: descriptor.getArray('FontBBox'),
  53335. ascent: descriptor.get('Ascent'),
  53336. descent: descriptor.get('Descent'),
  53337. xHeight: descriptor.get('XHeight'),
  53338. capHeight: descriptor.get('CapHeight'),
  53339. flags: descriptor.get('Flags'),
  53340. italicAngle: descriptor.get('ItalicAngle'),
  53341. coded: false
  53342. };
  53343. var cMapPromise;
  53344. if (composite) {
  53345. var cidEncoding = baseDict.get('Encoding');
  53346. if (isName(cidEncoding)) {
  53347. properties.cidEncoding = cidEncoding.name;
  53348. }
  53349. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53350. properties.cMap = cMap;
  53351. properties.vertical = properties.cMap.vertical;
  53352. });
  53353. } else {
  53354. cMapPromise = Promise.resolve(undefined);
  53355. }
  53356. return cMapPromise.then(function () {
  53357. return this.extractDataStructures(dict, baseDict, xref, properties);
  53358. }.bind(this)).then(function (properties) {
  53359. this.extractWidths(dict, xref, descriptor, properties);
  53360. if (type === 'Type3') {
  53361. properties.isType3Font = true;
  53362. }
  53363. return new Font(fontName.name, fontFile, properties);
  53364. }.bind(this));
  53365. }
  53366. };
  53367. return PartialEvaluator;
  53368. }();
  53369. var TranslatedFont = function TranslatedFontClosure() {
  53370. function TranslatedFont(loadedName, font, dict) {
  53371. this.loadedName = loadedName;
  53372. this.font = font;
  53373. this.dict = dict;
  53374. this.type3Loaded = null;
  53375. this.sent = false;
  53376. }
  53377. TranslatedFont.prototype = {
  53378. send: function (handler) {
  53379. if (this.sent) {
  53380. return;
  53381. }
  53382. var fontData = this.font.exportData();
  53383. handler.send('commonobj', [
  53384. this.loadedName,
  53385. 'Font',
  53386. fontData
  53387. ]);
  53388. this.sent = true;
  53389. },
  53390. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53391. assert(this.font.isType3Font);
  53392. if (this.type3Loaded) {
  53393. return this.type3Loaded;
  53394. }
  53395. var translatedFont = this.font;
  53396. var loadCharProcsPromise = Promise.resolve();
  53397. var charProcs = this.dict.get('CharProcs');
  53398. var fontResources = this.dict.get('Resources') || resources;
  53399. var charProcKeys = charProcs.getKeys();
  53400. var charProcOperatorList = Object.create(null);
  53401. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53402. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53403. var glyphStream = charProcs.get(key);
  53404. var operatorList = new OperatorList();
  53405. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53406. charProcOperatorList[key] = operatorList.getIR();
  53407. parentOperatorList.addDependencies(operatorList.dependencies);
  53408. }, function (reason) {
  53409. warn('Type3 font resource \"' + key + '\" is not available');
  53410. var operatorList = new OperatorList();
  53411. charProcOperatorList[key] = operatorList.getIR();
  53412. });
  53413. }.bind(this, charProcKeys[i]));
  53414. }
  53415. this.type3Loaded = loadCharProcsPromise.then(function () {
  53416. translatedFont.charProcOperatorList = charProcOperatorList;
  53417. });
  53418. return this.type3Loaded;
  53419. }
  53420. };
  53421. return TranslatedFont;
  53422. }();
  53423. var OperatorList = function OperatorListClosure() {
  53424. var CHUNK_SIZE = 1000;
  53425. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53426. function getTransfers(queue) {
  53427. var transfers = [];
  53428. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53429. for (var i = 0, ii = queue.length; i < ii; i++) {
  53430. switch (fnArray[i]) {
  53431. case OPS.paintInlineImageXObject:
  53432. case OPS.paintInlineImageXObjectGroup:
  53433. case OPS.paintImageMaskXObject:
  53434. var arg = argsArray[i][0];
  53435. if (!arg.cached) {
  53436. transfers.push(arg.data.buffer);
  53437. }
  53438. break;
  53439. }
  53440. }
  53441. return transfers;
  53442. }
  53443. function OperatorList(intent, messageHandler, pageIndex) {
  53444. this.messageHandler = messageHandler;
  53445. this.fnArray = [];
  53446. this.argsArray = [];
  53447. this.dependencies = Object.create(null);
  53448. this._totalLength = 0;
  53449. this.pageIndex = pageIndex;
  53450. this.intent = intent;
  53451. }
  53452. OperatorList.prototype = {
  53453. get length() {
  53454. return this.argsArray.length;
  53455. },
  53456. get totalLength() {
  53457. return this._totalLength + this.length;
  53458. },
  53459. addOp: function (fn, args) {
  53460. this.fnArray.push(fn);
  53461. this.argsArray.push(args);
  53462. if (this.messageHandler) {
  53463. if (this.fnArray.length >= CHUNK_SIZE) {
  53464. this.flush();
  53465. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53466. this.flush();
  53467. }
  53468. }
  53469. },
  53470. addDependency: function (dependency) {
  53471. if (dependency in this.dependencies) {
  53472. return;
  53473. }
  53474. this.dependencies[dependency] = true;
  53475. this.addOp(OPS.dependency, [dependency]);
  53476. },
  53477. addDependencies: function (dependencies) {
  53478. for (var key in dependencies) {
  53479. this.addDependency(key);
  53480. }
  53481. },
  53482. addOpList: function (opList) {
  53483. Util.extendObj(this.dependencies, opList.dependencies);
  53484. for (var i = 0, ii = opList.length; i < ii; i++) {
  53485. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53486. }
  53487. },
  53488. getIR: function () {
  53489. return {
  53490. fnArray: this.fnArray,
  53491. argsArray: this.argsArray,
  53492. length: this.length
  53493. };
  53494. },
  53495. flush: function (lastChunk) {
  53496. if (this.intent !== 'oplist') {
  53497. new QueueOptimizer().optimize(this);
  53498. }
  53499. var transfers = getTransfers(this);
  53500. var length = this.length;
  53501. this._totalLength += length;
  53502. this.messageHandler.send('RenderPageChunk', {
  53503. operatorList: {
  53504. fnArray: this.fnArray,
  53505. argsArray: this.argsArray,
  53506. lastChunk: lastChunk,
  53507. length: length
  53508. },
  53509. pageIndex: this.pageIndex,
  53510. intent: this.intent
  53511. }, transfers);
  53512. this.dependencies = Object.create(null);
  53513. this.fnArray.length = 0;
  53514. this.argsArray.length = 0;
  53515. }
  53516. };
  53517. return OperatorList;
  53518. }();
  53519. var StateManager = function StateManagerClosure() {
  53520. function StateManager(initialState) {
  53521. this.state = initialState;
  53522. this.stateStack = [];
  53523. }
  53524. StateManager.prototype = {
  53525. save: function () {
  53526. var old = this.state;
  53527. this.stateStack.push(this.state);
  53528. this.state = old.clone();
  53529. },
  53530. restore: function () {
  53531. var prev = this.stateStack.pop();
  53532. if (prev) {
  53533. this.state = prev;
  53534. }
  53535. },
  53536. transform: function (args) {
  53537. this.state.ctm = Util.transform(this.state.ctm, args);
  53538. }
  53539. };
  53540. return StateManager;
  53541. }();
  53542. var TextState = function TextStateClosure() {
  53543. function TextState() {
  53544. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53545. this.fontName = null;
  53546. this.fontSize = 0;
  53547. this.font = null;
  53548. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53549. this.textMatrix = IDENTITY_MATRIX.slice();
  53550. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53551. this.charSpacing = 0;
  53552. this.wordSpacing = 0;
  53553. this.leading = 0;
  53554. this.textHScale = 1;
  53555. this.textRise = 0;
  53556. }
  53557. TextState.prototype = {
  53558. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53559. var m = this.textMatrix;
  53560. m[0] = a;
  53561. m[1] = b;
  53562. m[2] = c;
  53563. m[3] = d;
  53564. m[4] = e;
  53565. m[5] = f;
  53566. },
  53567. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53568. var m = this.textLineMatrix;
  53569. m[0] = a;
  53570. m[1] = b;
  53571. m[2] = c;
  53572. m[3] = d;
  53573. m[4] = e;
  53574. m[5] = f;
  53575. },
  53576. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53577. var m = this.textMatrix;
  53578. m[4] = m[0] * x + m[2] * y + m[4];
  53579. m[5] = m[1] * x + m[3] * y + m[5];
  53580. },
  53581. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53582. var m = this.textLineMatrix;
  53583. m[4] = m[0] * x + m[2] * y + m[4];
  53584. m[5] = m[1] * x + m[3] * y + m[5];
  53585. },
  53586. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53587. var font = this.font;
  53588. if (!font) {
  53589. return null;
  53590. }
  53591. var m = this.textLineMatrix;
  53592. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53593. return null;
  53594. }
  53595. var txDiff = e - m[4], tyDiff = f - m[5];
  53596. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53597. return null;
  53598. }
  53599. var tx, ty, denominator = a * d - b * c;
  53600. if (font.vertical) {
  53601. tx = -tyDiff * c / denominator;
  53602. ty = tyDiff * a / denominator;
  53603. } else {
  53604. tx = txDiff * d / denominator;
  53605. ty = -txDiff * b / denominator;
  53606. }
  53607. return {
  53608. width: tx,
  53609. height: ty,
  53610. value: font.vertical ? ty : tx
  53611. };
  53612. },
  53613. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53614. var tsm = [
  53615. this.fontSize * this.textHScale,
  53616. 0,
  53617. 0,
  53618. this.fontSize,
  53619. 0,
  53620. this.textRise
  53621. ];
  53622. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53623. },
  53624. carriageReturn: function TextState_carriageReturn() {
  53625. this.translateTextLineMatrix(0, -this.leading);
  53626. this.textMatrix = this.textLineMatrix.slice();
  53627. },
  53628. clone: function TextState_clone() {
  53629. var clone = Object.create(this);
  53630. clone.textMatrix = this.textMatrix.slice();
  53631. clone.textLineMatrix = this.textLineMatrix.slice();
  53632. clone.fontMatrix = this.fontMatrix.slice();
  53633. return clone;
  53634. }
  53635. };
  53636. return TextState;
  53637. }();
  53638. var EvalState = function EvalStateClosure() {
  53639. function EvalState() {
  53640. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53641. this.font = null;
  53642. this.textRenderingMode = TextRenderingMode.FILL;
  53643. this.fillColorSpace = ColorSpace.singletons.gray;
  53644. this.strokeColorSpace = ColorSpace.singletons.gray;
  53645. }
  53646. EvalState.prototype = {
  53647. clone: function CanvasExtraState_clone() {
  53648. return Object.create(this);
  53649. }
  53650. };
  53651. return EvalState;
  53652. }();
  53653. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53654. var getOPMap = getLookupTableFactory(function (t) {
  53655. t['w'] = {
  53656. id: OPS.setLineWidth,
  53657. numArgs: 1,
  53658. variableArgs: false
  53659. };
  53660. t['J'] = {
  53661. id: OPS.setLineCap,
  53662. numArgs: 1,
  53663. variableArgs: false
  53664. };
  53665. t['j'] = {
  53666. id: OPS.setLineJoin,
  53667. numArgs: 1,
  53668. variableArgs: false
  53669. };
  53670. t['M'] = {
  53671. id: OPS.setMiterLimit,
  53672. numArgs: 1,
  53673. variableArgs: false
  53674. };
  53675. t['d'] = {
  53676. id: OPS.setDash,
  53677. numArgs: 2,
  53678. variableArgs: false
  53679. };
  53680. t['ri'] = {
  53681. id: OPS.setRenderingIntent,
  53682. numArgs: 1,
  53683. variableArgs: false
  53684. };
  53685. t['i'] = {
  53686. id: OPS.setFlatness,
  53687. numArgs: 1,
  53688. variableArgs: false
  53689. };
  53690. t['gs'] = {
  53691. id: OPS.setGState,
  53692. numArgs: 1,
  53693. variableArgs: false
  53694. };
  53695. t['q'] = {
  53696. id: OPS.save,
  53697. numArgs: 0,
  53698. variableArgs: false
  53699. };
  53700. t['Q'] = {
  53701. id: OPS.restore,
  53702. numArgs: 0,
  53703. variableArgs: false
  53704. };
  53705. t['cm'] = {
  53706. id: OPS.transform,
  53707. numArgs: 6,
  53708. variableArgs: false
  53709. };
  53710. t['m'] = {
  53711. id: OPS.moveTo,
  53712. numArgs: 2,
  53713. variableArgs: false
  53714. };
  53715. t['l'] = {
  53716. id: OPS.lineTo,
  53717. numArgs: 2,
  53718. variableArgs: false
  53719. };
  53720. t['c'] = {
  53721. id: OPS.curveTo,
  53722. numArgs: 6,
  53723. variableArgs: false
  53724. };
  53725. t['v'] = {
  53726. id: OPS.curveTo2,
  53727. numArgs: 4,
  53728. variableArgs: false
  53729. };
  53730. t['y'] = {
  53731. id: OPS.curveTo3,
  53732. numArgs: 4,
  53733. variableArgs: false
  53734. };
  53735. t['h'] = {
  53736. id: OPS.closePath,
  53737. numArgs: 0,
  53738. variableArgs: false
  53739. };
  53740. t['re'] = {
  53741. id: OPS.rectangle,
  53742. numArgs: 4,
  53743. variableArgs: false
  53744. };
  53745. t['S'] = {
  53746. id: OPS.stroke,
  53747. numArgs: 0,
  53748. variableArgs: false
  53749. };
  53750. t['s'] = {
  53751. id: OPS.closeStroke,
  53752. numArgs: 0,
  53753. variableArgs: false
  53754. };
  53755. t['f'] = {
  53756. id: OPS.fill,
  53757. numArgs: 0,
  53758. variableArgs: false
  53759. };
  53760. t['F'] = {
  53761. id: OPS.fill,
  53762. numArgs: 0,
  53763. variableArgs: false
  53764. };
  53765. t['f*'] = {
  53766. id: OPS.eoFill,
  53767. numArgs: 0,
  53768. variableArgs: false
  53769. };
  53770. t['B'] = {
  53771. id: OPS.fillStroke,
  53772. numArgs: 0,
  53773. variableArgs: false
  53774. };
  53775. t['B*'] = {
  53776. id: OPS.eoFillStroke,
  53777. numArgs: 0,
  53778. variableArgs: false
  53779. };
  53780. t['b'] = {
  53781. id: OPS.closeFillStroke,
  53782. numArgs: 0,
  53783. variableArgs: false
  53784. };
  53785. t['b*'] = {
  53786. id: OPS.closeEOFillStroke,
  53787. numArgs: 0,
  53788. variableArgs: false
  53789. };
  53790. t['n'] = {
  53791. id: OPS.endPath,
  53792. numArgs: 0,
  53793. variableArgs: false
  53794. };
  53795. t['W'] = {
  53796. id: OPS.clip,
  53797. numArgs: 0,
  53798. variableArgs: false
  53799. };
  53800. t['W*'] = {
  53801. id: OPS.eoClip,
  53802. numArgs: 0,
  53803. variableArgs: false
  53804. };
  53805. t['BT'] = {
  53806. id: OPS.beginText,
  53807. numArgs: 0,
  53808. variableArgs: false
  53809. };
  53810. t['ET'] = {
  53811. id: OPS.endText,
  53812. numArgs: 0,
  53813. variableArgs: false
  53814. };
  53815. t['Tc'] = {
  53816. id: OPS.setCharSpacing,
  53817. numArgs: 1,
  53818. variableArgs: false
  53819. };
  53820. t['Tw'] = {
  53821. id: OPS.setWordSpacing,
  53822. numArgs: 1,
  53823. variableArgs: false
  53824. };
  53825. t['Tz'] = {
  53826. id: OPS.setHScale,
  53827. numArgs: 1,
  53828. variableArgs: false
  53829. };
  53830. t['TL'] = {
  53831. id: OPS.setLeading,
  53832. numArgs: 1,
  53833. variableArgs: false
  53834. };
  53835. t['Tf'] = {
  53836. id: OPS.setFont,
  53837. numArgs: 2,
  53838. variableArgs: false
  53839. };
  53840. t['Tr'] = {
  53841. id: OPS.setTextRenderingMode,
  53842. numArgs: 1,
  53843. variableArgs: false
  53844. };
  53845. t['Ts'] = {
  53846. id: OPS.setTextRise,
  53847. numArgs: 1,
  53848. variableArgs: false
  53849. };
  53850. t['Td'] = {
  53851. id: OPS.moveText,
  53852. numArgs: 2,
  53853. variableArgs: false
  53854. };
  53855. t['TD'] = {
  53856. id: OPS.setLeadingMoveText,
  53857. numArgs: 2,
  53858. variableArgs: false
  53859. };
  53860. t['Tm'] = {
  53861. id: OPS.setTextMatrix,
  53862. numArgs: 6,
  53863. variableArgs: false
  53864. };
  53865. t['T*'] = {
  53866. id: OPS.nextLine,
  53867. numArgs: 0,
  53868. variableArgs: false
  53869. };
  53870. t['Tj'] = {
  53871. id: OPS.showText,
  53872. numArgs: 1,
  53873. variableArgs: false
  53874. };
  53875. t['TJ'] = {
  53876. id: OPS.showSpacedText,
  53877. numArgs: 1,
  53878. variableArgs: false
  53879. };
  53880. t['\''] = {
  53881. id: OPS.nextLineShowText,
  53882. numArgs: 1,
  53883. variableArgs: false
  53884. };
  53885. t['"'] = {
  53886. id: OPS.nextLineSetSpacingShowText,
  53887. numArgs: 3,
  53888. variableArgs: false
  53889. };
  53890. t['d0'] = {
  53891. id: OPS.setCharWidth,
  53892. numArgs: 2,
  53893. variableArgs: false
  53894. };
  53895. t['d1'] = {
  53896. id: OPS.setCharWidthAndBounds,
  53897. numArgs: 6,
  53898. variableArgs: false
  53899. };
  53900. t['CS'] = {
  53901. id: OPS.setStrokeColorSpace,
  53902. numArgs: 1,
  53903. variableArgs: false
  53904. };
  53905. t['cs'] = {
  53906. id: OPS.setFillColorSpace,
  53907. numArgs: 1,
  53908. variableArgs: false
  53909. };
  53910. t['SC'] = {
  53911. id: OPS.setStrokeColor,
  53912. numArgs: 4,
  53913. variableArgs: true
  53914. };
  53915. t['SCN'] = {
  53916. id: OPS.setStrokeColorN,
  53917. numArgs: 33,
  53918. variableArgs: true
  53919. };
  53920. t['sc'] = {
  53921. id: OPS.setFillColor,
  53922. numArgs: 4,
  53923. variableArgs: true
  53924. };
  53925. t['scn'] = {
  53926. id: OPS.setFillColorN,
  53927. numArgs: 33,
  53928. variableArgs: true
  53929. };
  53930. t['G'] = {
  53931. id: OPS.setStrokeGray,
  53932. numArgs: 1,
  53933. variableArgs: false
  53934. };
  53935. t['g'] = {
  53936. id: OPS.setFillGray,
  53937. numArgs: 1,
  53938. variableArgs: false
  53939. };
  53940. t['RG'] = {
  53941. id: OPS.setStrokeRGBColor,
  53942. numArgs: 3,
  53943. variableArgs: false
  53944. };
  53945. t['rg'] = {
  53946. id: OPS.setFillRGBColor,
  53947. numArgs: 3,
  53948. variableArgs: false
  53949. };
  53950. t['K'] = {
  53951. id: OPS.setStrokeCMYKColor,
  53952. numArgs: 4,
  53953. variableArgs: false
  53954. };
  53955. t['k'] = {
  53956. id: OPS.setFillCMYKColor,
  53957. numArgs: 4,
  53958. variableArgs: false
  53959. };
  53960. t['sh'] = {
  53961. id: OPS.shadingFill,
  53962. numArgs: 1,
  53963. variableArgs: false
  53964. };
  53965. t['BI'] = {
  53966. id: OPS.beginInlineImage,
  53967. numArgs: 0,
  53968. variableArgs: false
  53969. };
  53970. t['ID'] = {
  53971. id: OPS.beginImageData,
  53972. numArgs: 0,
  53973. variableArgs: false
  53974. };
  53975. t['EI'] = {
  53976. id: OPS.endInlineImage,
  53977. numArgs: 1,
  53978. variableArgs: false
  53979. };
  53980. t['Do'] = {
  53981. id: OPS.paintXObject,
  53982. numArgs: 1,
  53983. variableArgs: false
  53984. };
  53985. t['MP'] = {
  53986. id: OPS.markPoint,
  53987. numArgs: 1,
  53988. variableArgs: false
  53989. };
  53990. t['DP'] = {
  53991. id: OPS.markPointProps,
  53992. numArgs: 2,
  53993. variableArgs: false
  53994. };
  53995. t['BMC'] = {
  53996. id: OPS.beginMarkedContent,
  53997. numArgs: 1,
  53998. variableArgs: false
  53999. };
  54000. t['BDC'] = {
  54001. id: OPS.beginMarkedContentProps,
  54002. numArgs: 2,
  54003. variableArgs: false
  54004. };
  54005. t['EMC'] = {
  54006. id: OPS.endMarkedContent,
  54007. numArgs: 0,
  54008. variableArgs: false
  54009. };
  54010. t['BX'] = {
  54011. id: OPS.beginCompat,
  54012. numArgs: 0,
  54013. variableArgs: false
  54014. };
  54015. t['EX'] = {
  54016. id: OPS.endCompat,
  54017. numArgs: 0,
  54018. variableArgs: false
  54019. };
  54020. t['BM'] = null;
  54021. t['BD'] = null;
  54022. t['true'] = null;
  54023. t['fa'] = null;
  54024. t['fal'] = null;
  54025. t['fals'] = null;
  54026. t['false'] = null;
  54027. t['nu'] = null;
  54028. t['nul'] = null;
  54029. t['null'] = null;
  54030. });
  54031. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54032. this.opMap = getOPMap();
  54033. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54034. this.stateManager = stateManager;
  54035. this.nonProcessedArgs = [];
  54036. }
  54037. EvaluatorPreprocessor.prototype = {
  54038. get savedStatesDepth() {
  54039. return this.stateManager.stateStack.length;
  54040. },
  54041. read: function EvaluatorPreprocessor_read(operation) {
  54042. var args = operation.args;
  54043. while (true) {
  54044. var obj = this.parser.getObj();
  54045. if (isCmd(obj)) {
  54046. var cmd = obj.cmd;
  54047. var opSpec = this.opMap[cmd];
  54048. if (!opSpec) {
  54049. warn('Unknown command "' + cmd + '"');
  54050. continue;
  54051. }
  54052. var fn = opSpec.id;
  54053. var numArgs = opSpec.numArgs;
  54054. var argsLength = args !== null ? args.length : 0;
  54055. if (!opSpec.variableArgs) {
  54056. if (argsLength !== numArgs) {
  54057. var nonProcessedArgs = this.nonProcessedArgs;
  54058. while (argsLength > numArgs) {
  54059. nonProcessedArgs.push(args.shift());
  54060. argsLength--;
  54061. }
  54062. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54063. if (args === null) {
  54064. args = [];
  54065. }
  54066. args.unshift(nonProcessedArgs.pop());
  54067. argsLength++;
  54068. }
  54069. }
  54070. if (argsLength < numArgs) {
  54071. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54072. if (args !== null) {
  54073. args.length = 0;
  54074. }
  54075. continue;
  54076. }
  54077. } else if (argsLength > numArgs) {
  54078. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54079. }
  54080. this.preprocessCommand(fn, args);
  54081. operation.fn = fn;
  54082. operation.args = args;
  54083. return true;
  54084. } else {
  54085. if (isEOF(obj)) {
  54086. return false;
  54087. }
  54088. if (obj !== null) {
  54089. if (args === null) {
  54090. args = [];
  54091. }
  54092. args.push(obj);
  54093. assert(args.length <= 33, 'Too many arguments');
  54094. }
  54095. }
  54096. }
  54097. },
  54098. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54099. switch (fn | 0) {
  54100. case OPS.save:
  54101. this.stateManager.save();
  54102. break;
  54103. case OPS.restore:
  54104. this.stateManager.restore();
  54105. break;
  54106. case OPS.transform:
  54107. this.stateManager.transform(args);
  54108. break;
  54109. }
  54110. }
  54111. };
  54112. return EvaluatorPreprocessor;
  54113. }();
  54114. var QueueOptimizer = function QueueOptimizerClosure() {
  54115. function addState(parentState, pattern, fn) {
  54116. var state = parentState;
  54117. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54118. var item = pattern[i];
  54119. state = state[item] || (state[item] = []);
  54120. }
  54121. state[pattern[pattern.length - 1]] = fn;
  54122. }
  54123. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54124. var iFirstPIMXO = iFirstSave + 2;
  54125. for (var i = 0; i < count; i++) {
  54126. var arg = argsArray[iFirstPIMXO + 4 * i];
  54127. var imageMask = arg.length === 1 && arg[0];
  54128. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54129. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54130. continue;
  54131. }
  54132. break;
  54133. }
  54134. return count - i;
  54135. }
  54136. var InitialState = [];
  54137. addState(InitialState, [
  54138. OPS.save,
  54139. OPS.transform,
  54140. OPS.paintInlineImageXObject,
  54141. OPS.restore
  54142. ], function foundInlineImageGroup(context) {
  54143. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54144. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54145. var MAX_WIDTH = 1000;
  54146. var IMAGE_PADDING = 1;
  54147. var fnArray = context.fnArray, argsArray = context.argsArray;
  54148. var curr = context.iCurr;
  54149. var iFirstSave = curr - 3;
  54150. var iFirstTransform = curr - 2;
  54151. var iFirstPIIXO = curr - 1;
  54152. var i = iFirstSave + 4;
  54153. var ii = fnArray.length;
  54154. while (i + 3 < ii) {
  54155. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54156. break;
  54157. }
  54158. i += 4;
  54159. }
  54160. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54161. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54162. return i;
  54163. }
  54164. var maxX = 0;
  54165. var map = [], maxLineHeight = 0;
  54166. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54167. var q;
  54168. for (q = 0; q < count; q++) {
  54169. var transform = argsArray[iFirstTransform + (q << 2)];
  54170. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54171. if (currentX + img.width > MAX_WIDTH) {
  54172. maxX = Math.max(maxX, currentX);
  54173. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54174. currentX = 0;
  54175. maxLineHeight = 0;
  54176. }
  54177. map.push({
  54178. transform: transform,
  54179. x: currentX,
  54180. y: currentY,
  54181. w: img.width,
  54182. h: img.height
  54183. });
  54184. currentX += img.width + 2 * IMAGE_PADDING;
  54185. maxLineHeight = Math.max(maxLineHeight, img.height);
  54186. }
  54187. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54188. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54189. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54190. var imgRowSize = imgWidth << 2;
  54191. for (q = 0; q < count; q++) {
  54192. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54193. var rowSize = map[q].w << 2;
  54194. var dataOffset = 0;
  54195. var offset = map[q].x + map[q].y * imgWidth << 2;
  54196. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54197. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54198. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54199. dataOffset += rowSize;
  54200. offset += imgRowSize;
  54201. }
  54202. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54203. while (offset >= 0) {
  54204. data[offset - 4] = data[offset];
  54205. data[offset - 3] = data[offset + 1];
  54206. data[offset - 2] = data[offset + 2];
  54207. data[offset - 1] = data[offset + 3];
  54208. data[offset + rowSize] = data[offset + rowSize - 4];
  54209. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54210. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54211. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54212. offset -= imgRowSize;
  54213. }
  54214. }
  54215. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54216. argsArray.splice(iFirstSave, count * 4, [
  54217. {
  54218. width: imgWidth,
  54219. height: imgHeight,
  54220. kind: ImageKind.RGBA_32BPP,
  54221. data: imgData
  54222. },
  54223. map
  54224. ]);
  54225. return iFirstSave + 1;
  54226. });
  54227. addState(InitialState, [
  54228. OPS.save,
  54229. OPS.transform,
  54230. OPS.paintImageMaskXObject,
  54231. OPS.restore
  54232. ], function foundImageMaskGroup(context) {
  54233. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54234. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54235. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54236. var fnArray = context.fnArray, argsArray = context.argsArray;
  54237. var curr = context.iCurr;
  54238. var iFirstSave = curr - 3;
  54239. var iFirstTransform = curr - 2;
  54240. var iFirstPIMXO = curr - 1;
  54241. var i = iFirstSave + 4;
  54242. var ii = fnArray.length;
  54243. while (i + 3 < ii) {
  54244. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54245. break;
  54246. }
  54247. i += 4;
  54248. }
  54249. var count = (i - iFirstSave) / 4;
  54250. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54251. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54252. return i;
  54253. }
  54254. var q;
  54255. var isSameImage = false;
  54256. var iTransform, transformArgs;
  54257. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54258. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54259. isSameImage = true;
  54260. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54261. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54262. iTransform = iFirstTransform + 4;
  54263. var iPIMXO = iFirstPIMXO + 4;
  54264. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54265. transformArgs = argsArray[iTransform];
  54266. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54267. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54268. isSameImage = false;
  54269. } else {
  54270. count = q;
  54271. }
  54272. break;
  54273. }
  54274. }
  54275. }
  54276. if (isSameImage) {
  54277. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54278. var positions = new Float32Array(count * 2);
  54279. iTransform = iFirstTransform;
  54280. for (q = 0; q < count; q++, iTransform += 4) {
  54281. transformArgs = argsArray[iTransform];
  54282. positions[q << 1] = transformArgs[4];
  54283. positions[(q << 1) + 1] = transformArgs[5];
  54284. }
  54285. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54286. argsArray.splice(iFirstSave, count * 4, [
  54287. firstPIMXOArg0,
  54288. firstTransformArg0,
  54289. firstTransformArg3,
  54290. positions
  54291. ]);
  54292. } else {
  54293. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54294. var images = [];
  54295. for (q = 0; q < count; q++) {
  54296. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54297. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54298. images.push({
  54299. data: maskParams.data,
  54300. width: maskParams.width,
  54301. height: maskParams.height,
  54302. transform: transformArgs
  54303. });
  54304. }
  54305. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54306. argsArray.splice(iFirstSave, count * 4, [images]);
  54307. }
  54308. return iFirstSave + 1;
  54309. });
  54310. addState(InitialState, [
  54311. OPS.save,
  54312. OPS.transform,
  54313. OPS.paintImageXObject,
  54314. OPS.restore
  54315. ], function (context) {
  54316. var MIN_IMAGES_IN_BLOCK = 3;
  54317. var MAX_IMAGES_IN_BLOCK = 1000;
  54318. var fnArray = context.fnArray, argsArray = context.argsArray;
  54319. var curr = context.iCurr;
  54320. var iFirstSave = curr - 3;
  54321. var iFirstTransform = curr - 2;
  54322. var iFirstPIXO = curr - 1;
  54323. var iFirstRestore = curr;
  54324. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54325. return iFirstRestore + 1;
  54326. }
  54327. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54328. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54329. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54330. var i = iFirstSave + 4;
  54331. var ii = fnArray.length;
  54332. while (i + 3 < ii) {
  54333. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54334. break;
  54335. }
  54336. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54337. break;
  54338. }
  54339. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54340. break;
  54341. }
  54342. i += 4;
  54343. }
  54344. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54345. if (count < MIN_IMAGES_IN_BLOCK) {
  54346. return i;
  54347. }
  54348. var positions = new Float32Array(count * 2);
  54349. var iTransform = iFirstTransform;
  54350. for (var q = 0; q < count; q++, iTransform += 4) {
  54351. var transformArgs = argsArray[iTransform];
  54352. positions[q << 1] = transformArgs[4];
  54353. positions[(q << 1) + 1] = transformArgs[5];
  54354. }
  54355. var args = [
  54356. firstPIXOArg0,
  54357. firstTransformArg0,
  54358. firstTransformArg3,
  54359. positions
  54360. ];
  54361. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54362. argsArray.splice(iFirstSave, count * 4, args);
  54363. return iFirstSave + 1;
  54364. });
  54365. addState(InitialState, [
  54366. OPS.beginText,
  54367. OPS.setFont,
  54368. OPS.setTextMatrix,
  54369. OPS.showText,
  54370. OPS.endText
  54371. ], function (context) {
  54372. var MIN_CHARS_IN_BLOCK = 3;
  54373. var MAX_CHARS_IN_BLOCK = 1000;
  54374. var fnArray = context.fnArray, argsArray = context.argsArray;
  54375. var curr = context.iCurr;
  54376. var iFirstBeginText = curr - 4;
  54377. var iFirstSetFont = curr - 3;
  54378. var iFirstSetTextMatrix = curr - 2;
  54379. var iFirstShowText = curr - 1;
  54380. var iFirstEndText = curr;
  54381. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54382. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54383. var i = iFirstBeginText + 5;
  54384. var ii = fnArray.length;
  54385. while (i + 4 < ii) {
  54386. 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) {
  54387. break;
  54388. }
  54389. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54390. break;
  54391. }
  54392. i += 5;
  54393. }
  54394. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54395. if (count < MIN_CHARS_IN_BLOCK) {
  54396. return i;
  54397. }
  54398. var iFirst = iFirstBeginText;
  54399. 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) {
  54400. count++;
  54401. iFirst -= 5;
  54402. }
  54403. var iEndText = iFirst + 4;
  54404. for (var q = 1; q < count; q++) {
  54405. fnArray.splice(iEndText, 3);
  54406. argsArray.splice(iEndText, 3);
  54407. iEndText += 2;
  54408. }
  54409. return iEndText + 1;
  54410. });
  54411. function QueueOptimizer() {
  54412. }
  54413. QueueOptimizer.prototype = {
  54414. optimize: function QueueOptimizer_optimize(queue) {
  54415. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54416. var context = {
  54417. iCurr: 0,
  54418. fnArray: fnArray,
  54419. argsArray: argsArray
  54420. };
  54421. var state;
  54422. var i = 0, ii = fnArray.length;
  54423. while (i < ii) {
  54424. state = (state || InitialState)[fnArray[i]];
  54425. if (typeof state === 'function') {
  54426. context.iCurr = i;
  54427. i = state(context);
  54428. state = undefined;
  54429. ii = context.fnArray.length;
  54430. } else {
  54431. i++;
  54432. }
  54433. }
  54434. }
  54435. };
  54436. return QueueOptimizer;
  54437. }();
  54438. exports.OperatorList = OperatorList;
  54439. exports.PartialEvaluator = PartialEvaluator;
  54440. }));
  54441. (function (root, factory) {
  54442. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54443. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54444. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54445. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54446. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54447. var AnnotationType = sharedUtil.AnnotationType;
  54448. var OPS = sharedUtil.OPS;
  54449. var Util = sharedUtil.Util;
  54450. var isString = sharedUtil.isString;
  54451. var isArray = sharedUtil.isArray;
  54452. var isInt = sharedUtil.isInt;
  54453. var stringToBytes = sharedUtil.stringToBytes;
  54454. var stringToPDFString = sharedUtil.stringToPDFString;
  54455. var warn = sharedUtil.warn;
  54456. var Dict = corePrimitives.Dict;
  54457. var isDict = corePrimitives.isDict;
  54458. var isName = corePrimitives.isName;
  54459. var isRef = corePrimitives.isRef;
  54460. var Stream = coreStream.Stream;
  54461. var ColorSpace = coreColorSpace.ColorSpace;
  54462. var Catalog = coreObj.Catalog;
  54463. var ObjectLoader = coreObj.ObjectLoader;
  54464. var FileSpec = coreObj.FileSpec;
  54465. var OperatorList = coreEvaluator.OperatorList;
  54466. function AnnotationFactory() {
  54467. }
  54468. AnnotationFactory.prototype = {
  54469. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  54470. var dict = xref.fetchIfRef(ref);
  54471. if (!isDict(dict)) {
  54472. return;
  54473. }
  54474. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  54475. var subtype = dict.get('Subtype');
  54476. subtype = isName(subtype) ? subtype.name : null;
  54477. var parameters = {
  54478. xref: xref,
  54479. dict: dict,
  54480. ref: isRef(ref) ? ref : null,
  54481. subtype: subtype,
  54482. id: id,
  54483. pdfManager: pdfManager
  54484. };
  54485. switch (subtype) {
  54486. case 'Link':
  54487. return new LinkAnnotation(parameters);
  54488. case 'Text':
  54489. return new TextAnnotation(parameters);
  54490. case 'Widget':
  54491. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54492. fieldType = isName(fieldType) ? fieldType.name : null;
  54493. switch (fieldType) {
  54494. case 'Tx':
  54495. return new TextWidgetAnnotation(parameters);
  54496. case 'Ch':
  54497. return new ChoiceWidgetAnnotation(parameters);
  54498. }
  54499. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54500. return new WidgetAnnotation(parameters);
  54501. case 'Popup':
  54502. return new PopupAnnotation(parameters);
  54503. case 'Highlight':
  54504. return new HighlightAnnotation(parameters);
  54505. case 'Underline':
  54506. return new UnderlineAnnotation(parameters);
  54507. case 'Squiggly':
  54508. return new SquigglyAnnotation(parameters);
  54509. case 'StrikeOut':
  54510. return new StrikeOutAnnotation(parameters);
  54511. case 'FileAttachment':
  54512. return new FileAttachmentAnnotation(parameters);
  54513. default:
  54514. if (!subtype) {
  54515. warn('Annotation is missing the required /Subtype.');
  54516. } else {
  54517. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54518. }
  54519. return new Annotation(parameters);
  54520. }
  54521. }
  54522. };
  54523. var Annotation = function AnnotationClosure() {
  54524. function getTransformMatrix(rect, bbox, matrix) {
  54525. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54526. var minX = bounds[0];
  54527. var minY = bounds[1];
  54528. var maxX = bounds[2];
  54529. var maxY = bounds[3];
  54530. if (minX === maxX || minY === maxY) {
  54531. return [
  54532. 1,
  54533. 0,
  54534. 0,
  54535. 1,
  54536. rect[0],
  54537. rect[1]
  54538. ];
  54539. }
  54540. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54541. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54542. return [
  54543. xRatio,
  54544. 0,
  54545. 0,
  54546. yRatio,
  54547. rect[0] - minX * xRatio,
  54548. rect[1] - minY * yRatio
  54549. ];
  54550. }
  54551. function getDefaultAppearance(dict) {
  54552. var appearanceState = dict.get('AP');
  54553. if (!isDict(appearanceState)) {
  54554. return;
  54555. }
  54556. var appearance;
  54557. var appearances = appearanceState.get('N');
  54558. if (isDict(appearances)) {
  54559. var as = dict.get('AS');
  54560. if (as && appearances.has(as.name)) {
  54561. appearance = appearances.get(as.name);
  54562. }
  54563. } else {
  54564. appearance = appearances;
  54565. }
  54566. return appearance;
  54567. }
  54568. function Annotation(params) {
  54569. var dict = params.dict;
  54570. this.setFlags(dict.get('F'));
  54571. this.setRectangle(dict.getArray('Rect'));
  54572. this.setColor(dict.getArray('C'));
  54573. this.setBorderStyle(dict);
  54574. this.appearance = getDefaultAppearance(dict);
  54575. this.data = {};
  54576. this.data.id = params.id;
  54577. this.data.subtype = params.subtype;
  54578. this.data.annotationFlags = this.flags;
  54579. this.data.rect = this.rectangle;
  54580. this.data.color = this.color;
  54581. this.data.borderStyle = this.borderStyle;
  54582. this.data.hasAppearance = !!this.appearance;
  54583. }
  54584. Annotation.prototype = {
  54585. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54586. return !!(flags & flag);
  54587. },
  54588. _isViewable: function Annotation_isViewable(flags) {
  54589. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54590. },
  54591. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54592. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54593. },
  54594. get viewable() {
  54595. if (this.flags === 0) {
  54596. return true;
  54597. }
  54598. return this._isViewable(this.flags);
  54599. },
  54600. get printable() {
  54601. if (this.flags === 0) {
  54602. return false;
  54603. }
  54604. return this._isPrintable(this.flags);
  54605. },
  54606. setFlags: function Annotation_setFlags(flags) {
  54607. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54608. },
  54609. hasFlag: function Annotation_hasFlag(flag) {
  54610. return this._hasFlag(this.flags, flag);
  54611. },
  54612. setRectangle: function Annotation_setRectangle(rectangle) {
  54613. if (isArray(rectangle) && rectangle.length === 4) {
  54614. this.rectangle = Util.normalizeRect(rectangle);
  54615. } else {
  54616. this.rectangle = [
  54617. 0,
  54618. 0,
  54619. 0,
  54620. 0
  54621. ];
  54622. }
  54623. },
  54624. setColor: function Annotation_setColor(color) {
  54625. var rgbColor = new Uint8Array(3);
  54626. if (!isArray(color)) {
  54627. this.color = rgbColor;
  54628. return;
  54629. }
  54630. switch (color.length) {
  54631. case 0:
  54632. this.color = null;
  54633. break;
  54634. case 1:
  54635. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54636. this.color = rgbColor;
  54637. break;
  54638. case 3:
  54639. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54640. this.color = rgbColor;
  54641. break;
  54642. case 4:
  54643. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54644. this.color = rgbColor;
  54645. break;
  54646. default:
  54647. this.color = rgbColor;
  54648. break;
  54649. }
  54650. },
  54651. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54652. this.borderStyle = new AnnotationBorderStyle();
  54653. if (!isDict(borderStyle)) {
  54654. return;
  54655. }
  54656. if (borderStyle.has('BS')) {
  54657. var dict = borderStyle.get('BS');
  54658. var dictType = dict.get('Type');
  54659. if (!dictType || isName(dictType, 'Border')) {
  54660. this.borderStyle.setWidth(dict.get('W'));
  54661. this.borderStyle.setStyle(dict.get('S'));
  54662. this.borderStyle.setDashArray(dict.getArray('D'));
  54663. }
  54664. } else if (borderStyle.has('Border')) {
  54665. var array = borderStyle.getArray('Border');
  54666. if (isArray(array) && array.length >= 3) {
  54667. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54668. this.borderStyle.setVerticalCornerRadius(array[1]);
  54669. this.borderStyle.setWidth(array[2]);
  54670. if (array.length === 4) {
  54671. this.borderStyle.setDashArray(array[3]);
  54672. }
  54673. }
  54674. } else {
  54675. this.borderStyle.setWidth(0);
  54676. }
  54677. },
  54678. _preparePopup: function Annotation_preparePopup(dict) {
  54679. if (!dict.has('C')) {
  54680. this.data.color = null;
  54681. }
  54682. this.data.hasPopup = dict.has('Popup');
  54683. this.data.title = stringToPDFString(dict.get('T') || '');
  54684. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54685. },
  54686. loadResources: function Annotation_loadResources(keys) {
  54687. return new Promise(function (resolve, reject) {
  54688. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54689. if (!resources) {
  54690. resolve();
  54691. return;
  54692. }
  54693. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54694. objectLoader.load().then(function () {
  54695. resolve(resources);
  54696. }, reject);
  54697. }, reject);
  54698. }.bind(this));
  54699. },
  54700. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54701. if (!this.appearance) {
  54702. return Promise.resolve(new OperatorList());
  54703. }
  54704. var data = this.data;
  54705. var appearanceDict = this.appearance.dict;
  54706. var resourcesPromise = this.loadResources([
  54707. 'ExtGState',
  54708. 'ColorSpace',
  54709. 'Pattern',
  54710. 'Shading',
  54711. 'XObject',
  54712. 'Font'
  54713. ]);
  54714. var bbox = appearanceDict.getArray('BBox') || [
  54715. 0,
  54716. 0,
  54717. 1,
  54718. 1
  54719. ];
  54720. var matrix = appearanceDict.getArray('Matrix') || [
  54721. 1,
  54722. 0,
  54723. 0,
  54724. 1,
  54725. 0,
  54726. 0
  54727. ];
  54728. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54729. var self = this;
  54730. return resourcesPromise.then(function (resources) {
  54731. var opList = new OperatorList();
  54732. opList.addOp(OPS.beginAnnotation, [
  54733. data.rect,
  54734. transform,
  54735. matrix
  54736. ]);
  54737. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54738. opList.addOp(OPS.endAnnotation, []);
  54739. self.appearance.reset();
  54740. return opList;
  54741. });
  54742. });
  54743. }
  54744. };
  54745. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54746. var annotationPromises = [];
  54747. for (var i = 0, n = annotations.length; i < n; ++i) {
  54748. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54749. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54750. }
  54751. }
  54752. return Promise.all(annotationPromises).then(function (operatorLists) {
  54753. opList.addOp(OPS.beginAnnotations, []);
  54754. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54755. opList.addOpList(operatorLists[i]);
  54756. }
  54757. opList.addOp(OPS.endAnnotations, []);
  54758. });
  54759. };
  54760. return Annotation;
  54761. }();
  54762. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54763. function AnnotationBorderStyle() {
  54764. this.width = 1;
  54765. this.style = AnnotationBorderStyleType.SOLID;
  54766. this.dashArray = [3];
  54767. this.horizontalCornerRadius = 0;
  54768. this.verticalCornerRadius = 0;
  54769. }
  54770. AnnotationBorderStyle.prototype = {
  54771. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54772. if (width === (width | 0)) {
  54773. this.width = width;
  54774. }
  54775. },
  54776. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54777. if (!style) {
  54778. return;
  54779. }
  54780. switch (style.name) {
  54781. case 'S':
  54782. this.style = AnnotationBorderStyleType.SOLID;
  54783. break;
  54784. case 'D':
  54785. this.style = AnnotationBorderStyleType.DASHED;
  54786. break;
  54787. case 'B':
  54788. this.style = AnnotationBorderStyleType.BEVELED;
  54789. break;
  54790. case 'I':
  54791. this.style = AnnotationBorderStyleType.INSET;
  54792. break;
  54793. case 'U':
  54794. this.style = AnnotationBorderStyleType.UNDERLINE;
  54795. break;
  54796. default:
  54797. break;
  54798. }
  54799. },
  54800. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54801. if (isArray(dashArray) && dashArray.length > 0) {
  54802. var isValid = true;
  54803. var allZeros = true;
  54804. for (var i = 0, len = dashArray.length; i < len; i++) {
  54805. var element = dashArray[i];
  54806. var validNumber = +element >= 0;
  54807. if (!validNumber) {
  54808. isValid = false;
  54809. break;
  54810. } else if (element > 0) {
  54811. allZeros = false;
  54812. }
  54813. }
  54814. if (isValid && !allZeros) {
  54815. this.dashArray = dashArray;
  54816. } else {
  54817. this.width = 0;
  54818. }
  54819. } else if (dashArray) {
  54820. this.width = 0;
  54821. }
  54822. },
  54823. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54824. if (radius === (radius | 0)) {
  54825. this.horizontalCornerRadius = radius;
  54826. }
  54827. },
  54828. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54829. if (radius === (radius | 0)) {
  54830. this.verticalCornerRadius = radius;
  54831. }
  54832. }
  54833. };
  54834. return AnnotationBorderStyle;
  54835. }();
  54836. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54837. function WidgetAnnotation(params) {
  54838. Annotation.call(this, params);
  54839. var dict = params.dict;
  54840. var data = this.data;
  54841. data.annotationType = AnnotationType.WIDGET;
  54842. data.fieldName = this._constructFieldName(dict);
  54843. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  54844. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  54845. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  54846. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54847. data.fieldType = isName(fieldType) ? fieldType.name : null;
  54848. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  54849. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  54850. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  54851. data.fieldFlags = 0;
  54852. }
  54853. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  54854. if (data.fieldType === 'Sig') {
  54855. this.setFlags(AnnotationFlag.HIDDEN);
  54856. }
  54857. }
  54858. Util.inherit(WidgetAnnotation, Annotation, {
  54859. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  54860. if (!dict.has('T') && !dict.has('Parent')) {
  54861. warn('Unknown field name, falling back to empty field name.');
  54862. return '';
  54863. }
  54864. if (!dict.has('Parent')) {
  54865. return stringToPDFString(dict.get('T'));
  54866. }
  54867. var fieldName = [];
  54868. if (dict.has('T')) {
  54869. fieldName.unshift(stringToPDFString(dict.get('T')));
  54870. }
  54871. var loopDict = dict;
  54872. while (loopDict.has('Parent')) {
  54873. loopDict = loopDict.get('Parent');
  54874. if (loopDict.has('T')) {
  54875. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  54876. }
  54877. }
  54878. return fieldName.join('.');
  54879. },
  54880. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  54881. return !!(this.data.fieldFlags & flag);
  54882. }
  54883. });
  54884. return WidgetAnnotation;
  54885. }();
  54886. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  54887. function TextWidgetAnnotation(params) {
  54888. WidgetAnnotation.call(this, params);
  54889. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  54890. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  54891. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  54892. alignment = null;
  54893. }
  54894. this.data.textAlignment = alignment;
  54895. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  54896. if (!isInt(maximumLength) || maximumLength < 0) {
  54897. maximumLength = null;
  54898. }
  54899. this.data.maxLen = maximumLength;
  54900. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  54901. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  54902. }
  54903. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  54904. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54905. var operatorList = new OperatorList();
  54906. if (renderForms) {
  54907. return Promise.resolve(operatorList);
  54908. }
  54909. if (this.appearance) {
  54910. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54911. }
  54912. if (!this.data.defaultAppearance) {
  54913. return Promise.resolve(operatorList);
  54914. }
  54915. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  54916. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  54917. return operatorList;
  54918. });
  54919. }
  54920. });
  54921. return TextWidgetAnnotation;
  54922. }();
  54923. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  54924. function ChoiceWidgetAnnotation(params) {
  54925. WidgetAnnotation.call(this, params);
  54926. this.data.options = [];
  54927. var options = params.dict.getArray('Opt');
  54928. if (isArray(options)) {
  54929. for (var i = 0, ii = options.length; i < ii; i++) {
  54930. var option = options[i];
  54931. this.data.options[i] = {
  54932. exportValue: isArray(option) ? option[0] : option,
  54933. displayValue: isArray(option) ? option[1] : option
  54934. };
  54935. }
  54936. }
  54937. if (!isArray(this.data.fieldValue)) {
  54938. this.data.fieldValue = [this.data.fieldValue];
  54939. }
  54940. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  54941. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  54942. }
  54943. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  54944. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54945. var operatorList = new OperatorList();
  54946. if (renderForms) {
  54947. return Promise.resolve(operatorList);
  54948. }
  54949. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54950. }
  54951. });
  54952. return ChoiceWidgetAnnotation;
  54953. }();
  54954. var TextAnnotation = function TextAnnotationClosure() {
  54955. var DEFAULT_ICON_SIZE = 22;
  54956. function TextAnnotation(parameters) {
  54957. Annotation.call(this, parameters);
  54958. this.data.annotationType = AnnotationType.TEXT;
  54959. if (this.data.hasAppearance) {
  54960. this.data.name = 'NoIcon';
  54961. } else {
  54962. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  54963. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  54964. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  54965. }
  54966. this._preparePopup(parameters.dict);
  54967. }
  54968. Util.inherit(TextAnnotation, Annotation, {});
  54969. return TextAnnotation;
  54970. }();
  54971. var LinkAnnotation = function LinkAnnotationClosure() {
  54972. function LinkAnnotation(params) {
  54973. Annotation.call(this, params);
  54974. var data = this.data;
  54975. data.annotationType = AnnotationType.LINK;
  54976. Catalog.parseDestDictionary({
  54977. destDict: params.dict,
  54978. resultObj: data,
  54979. docBaseUrl: params.pdfManager.docBaseUrl
  54980. });
  54981. }
  54982. Util.inherit(LinkAnnotation, Annotation, {});
  54983. return LinkAnnotation;
  54984. }();
  54985. var PopupAnnotation = function PopupAnnotationClosure() {
  54986. function PopupAnnotation(parameters) {
  54987. Annotation.call(this, parameters);
  54988. this.data.annotationType = AnnotationType.POPUP;
  54989. var dict = parameters.dict;
  54990. var parentItem = dict.get('Parent');
  54991. if (!parentItem) {
  54992. warn('Popup annotation has a missing or invalid parent annotation.');
  54993. return;
  54994. }
  54995. this.data.parentId = dict.getRaw('Parent').toString();
  54996. this.data.title = stringToPDFString(parentItem.get('T') || '');
  54997. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  54998. if (!parentItem.has('C')) {
  54999. this.data.color = null;
  55000. } else {
  55001. this.setColor(parentItem.getArray('C'));
  55002. this.data.color = this.color;
  55003. }
  55004. if (!this.viewable) {
  55005. var parentFlags = parentItem.get('F');
  55006. if (this._isViewable(parentFlags)) {
  55007. this.setFlags(parentFlags);
  55008. }
  55009. }
  55010. }
  55011. Util.inherit(PopupAnnotation, Annotation, {});
  55012. return PopupAnnotation;
  55013. }();
  55014. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55015. function HighlightAnnotation(parameters) {
  55016. Annotation.call(this, parameters);
  55017. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55018. this._preparePopup(parameters.dict);
  55019. this.data.borderStyle.setWidth(0);
  55020. }
  55021. Util.inherit(HighlightAnnotation, Annotation, {});
  55022. return HighlightAnnotation;
  55023. }();
  55024. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55025. function UnderlineAnnotation(parameters) {
  55026. Annotation.call(this, parameters);
  55027. this.data.annotationType = AnnotationType.UNDERLINE;
  55028. this._preparePopup(parameters.dict);
  55029. this.data.borderStyle.setWidth(0);
  55030. }
  55031. Util.inherit(UnderlineAnnotation, Annotation, {});
  55032. return UnderlineAnnotation;
  55033. }();
  55034. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55035. function SquigglyAnnotation(parameters) {
  55036. Annotation.call(this, parameters);
  55037. this.data.annotationType = AnnotationType.SQUIGGLY;
  55038. this._preparePopup(parameters.dict);
  55039. this.data.borderStyle.setWidth(0);
  55040. }
  55041. Util.inherit(SquigglyAnnotation, Annotation, {});
  55042. return SquigglyAnnotation;
  55043. }();
  55044. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55045. function StrikeOutAnnotation(parameters) {
  55046. Annotation.call(this, parameters);
  55047. this.data.annotationType = AnnotationType.STRIKEOUT;
  55048. this._preparePopup(parameters.dict);
  55049. this.data.borderStyle.setWidth(0);
  55050. }
  55051. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55052. return StrikeOutAnnotation;
  55053. }();
  55054. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55055. function FileAttachmentAnnotation(parameters) {
  55056. Annotation.call(this, parameters);
  55057. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55058. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55059. this.data.file = file.serializable;
  55060. this._preparePopup(parameters.dict);
  55061. }
  55062. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55063. return FileAttachmentAnnotation;
  55064. }();
  55065. exports.Annotation = Annotation;
  55066. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55067. exports.AnnotationFactory = AnnotationFactory;
  55068. }));
  55069. (function (root, factory) {
  55070. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55071. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55072. var MissingDataException = sharedUtil.MissingDataException;
  55073. var Util = sharedUtil.Util;
  55074. var assert = sharedUtil.assert;
  55075. var error = sharedUtil.error;
  55076. var info = sharedUtil.info;
  55077. var isArray = sharedUtil.isArray;
  55078. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55079. var isString = sharedUtil.isString;
  55080. var shadow = sharedUtil.shadow;
  55081. var stringToBytes = sharedUtil.stringToBytes;
  55082. var stringToPDFString = sharedUtil.stringToPDFString;
  55083. var warn = sharedUtil.warn;
  55084. var isSpace = sharedUtil.isSpace;
  55085. var Dict = corePrimitives.Dict;
  55086. var isDict = corePrimitives.isDict;
  55087. var isName = corePrimitives.isName;
  55088. var isStream = corePrimitives.isStream;
  55089. var NullStream = coreStream.NullStream;
  55090. var Stream = coreStream.Stream;
  55091. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55092. var Catalog = coreObj.Catalog;
  55093. var ObjectLoader = coreObj.ObjectLoader;
  55094. var XRef = coreObj.XRef;
  55095. var Linearization = coreParser.Linearization;
  55096. var calculateMD5 = coreCrypto.calculateMD5;
  55097. var OperatorList = coreEvaluator.OperatorList;
  55098. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55099. var Annotation = coreAnnotation.Annotation;
  55100. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55101. var Page = function PageClosure() {
  55102. var LETTER_SIZE_MEDIABOX = [
  55103. 0,
  55104. 0,
  55105. 612,
  55106. 792
  55107. ];
  55108. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55109. this.pdfManager = pdfManager;
  55110. this.pageIndex = pageIndex;
  55111. this.pageDict = pageDict;
  55112. this.xref = xref;
  55113. this.ref = ref;
  55114. this.fontCache = fontCache;
  55115. this.uniquePrefix = 'p' + this.pageIndex + '_';
  55116. this.idCounters = { obj: 0 };
  55117. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55118. this.resourcesPromise = null;
  55119. }
  55120. Page.prototype = {
  55121. getPageProp: function Page_getPageProp(key) {
  55122. return this.pageDict.get(key);
  55123. },
  55124. getInheritedPageProp: function Page_getInheritedPageProp(key) {
  55125. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55126. var MAX_LOOP_COUNT = 100;
  55127. while (dict) {
  55128. var value = dict.get(key);
  55129. if (value) {
  55130. if (!valueArray) {
  55131. valueArray = [];
  55132. }
  55133. valueArray.push(value);
  55134. }
  55135. if (++loopCount > MAX_LOOP_COUNT) {
  55136. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55137. break;
  55138. }
  55139. dict = dict.get('Parent');
  55140. }
  55141. if (!valueArray) {
  55142. return Dict.empty;
  55143. }
  55144. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55145. return valueArray[0];
  55146. }
  55147. return Dict.merge(this.xref, valueArray);
  55148. },
  55149. get content() {
  55150. return this.getPageProp('Contents');
  55151. },
  55152. get resources() {
  55153. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55154. },
  55155. get mediaBox() {
  55156. var obj = this.getInheritedPageProp('MediaBox');
  55157. if (!isArray(obj) || obj.length !== 4) {
  55158. obj = LETTER_SIZE_MEDIABOX;
  55159. }
  55160. return shadow(this, 'mediaBox', obj);
  55161. },
  55162. get view() {
  55163. var mediaBox = this.mediaBox;
  55164. var cropBox = this.getInheritedPageProp('CropBox');
  55165. if (!isArray(cropBox) || cropBox.length !== 4) {
  55166. return shadow(this, 'view', mediaBox);
  55167. }
  55168. cropBox = Util.intersect(cropBox, mediaBox);
  55169. if (!cropBox) {
  55170. return shadow(this, 'view', mediaBox);
  55171. }
  55172. return shadow(this, 'view', cropBox);
  55173. },
  55174. get rotate() {
  55175. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55176. if (rotate % 90 !== 0) {
  55177. rotate = 0;
  55178. } else if (rotate >= 360) {
  55179. rotate = rotate % 360;
  55180. } else if (rotate < 0) {
  55181. rotate = (rotate % 360 + 360) % 360;
  55182. }
  55183. return shadow(this, 'rotate', rotate);
  55184. },
  55185. getContentStream: function Page_getContentStream() {
  55186. var content = this.content;
  55187. var stream;
  55188. if (isArray(content)) {
  55189. var xref = this.xref;
  55190. var i, n = content.length;
  55191. var streams = [];
  55192. for (i = 0; i < n; ++i) {
  55193. streams.push(xref.fetchIfRef(content[i]));
  55194. }
  55195. stream = new StreamsSequenceStream(streams);
  55196. } else if (isStream(content)) {
  55197. stream = content;
  55198. } else {
  55199. stream = new NullStream();
  55200. }
  55201. return stream;
  55202. },
  55203. loadResources: function Page_loadResources(keys) {
  55204. if (!this.resourcesPromise) {
  55205. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55206. }
  55207. return this.resourcesPromise.then(function resourceSuccess() {
  55208. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55209. return objectLoader.load();
  55210. }.bind(this));
  55211. },
  55212. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55213. var self = this;
  55214. var pdfManager = this.pdfManager;
  55215. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55216. var resourcesPromise = this.loadResources([
  55217. 'ExtGState',
  55218. 'ColorSpace',
  55219. 'Pattern',
  55220. 'Shading',
  55221. 'XObject',
  55222. 'Font'
  55223. ]);
  55224. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  55225. var dataPromises = Promise.all([
  55226. contentStreamPromise,
  55227. resourcesPromise
  55228. ]);
  55229. var pageListPromise = dataPromises.then(function (data) {
  55230. var contentStream = data[0];
  55231. var opList = new OperatorList(intent, handler, self.pageIndex);
  55232. handler.send('StartRenderPage', {
  55233. transparency: partialEvaluator.hasBlendModes(self.resources),
  55234. pageIndex: self.pageIndex,
  55235. intent: intent
  55236. });
  55237. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55238. return opList;
  55239. });
  55240. });
  55241. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55242. return Promise.all([
  55243. pageListPromise,
  55244. annotationsPromise
  55245. ]).then(function (datas) {
  55246. var pageOpList = datas[0];
  55247. var annotations = datas[1];
  55248. if (annotations.length === 0) {
  55249. pageOpList.flush(true);
  55250. return pageOpList;
  55251. }
  55252. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55253. return annotationsReadyPromise.then(function () {
  55254. pageOpList.flush(true);
  55255. return pageOpList;
  55256. });
  55257. });
  55258. },
  55259. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55260. var handler = {
  55261. on: function nullHandlerOn() {
  55262. },
  55263. send: function nullHandlerSend() {
  55264. }
  55265. };
  55266. var self = this;
  55267. var pdfManager = this.pdfManager;
  55268. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55269. var resourcesPromise = this.loadResources([
  55270. 'ExtGState',
  55271. 'XObject',
  55272. 'Font'
  55273. ]);
  55274. var dataPromises = Promise.all([
  55275. contentStreamPromise,
  55276. resourcesPromise
  55277. ]);
  55278. return dataPromises.then(function (data) {
  55279. var contentStream = data[0];
  55280. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  55281. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55282. });
  55283. },
  55284. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55285. var annotations = this.annotations;
  55286. var annotationsData = [];
  55287. for (var i = 0, n = annotations.length; i < n; ++i) {
  55288. if (intent) {
  55289. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55290. continue;
  55291. }
  55292. }
  55293. annotationsData.push(annotations[i].data);
  55294. }
  55295. return annotationsData;
  55296. },
  55297. get annotations() {
  55298. var annotations = [];
  55299. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55300. var annotationFactory = new AnnotationFactory();
  55301. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55302. var annotationRef = annotationRefs[i];
  55303. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  55304. if (annotation) {
  55305. annotations.push(annotation);
  55306. }
  55307. }
  55308. return shadow(this, 'annotations', annotations);
  55309. }
  55310. };
  55311. return Page;
  55312. }();
  55313. var PDFDocument = function PDFDocumentClosure() {
  55314. var FINGERPRINT_FIRST_BYTES = 1024;
  55315. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55316. function PDFDocument(pdfManager, arg, password) {
  55317. if (isStream(arg)) {
  55318. init.call(this, pdfManager, arg, password);
  55319. } else if (isArrayBuffer(arg)) {
  55320. init.call(this, pdfManager, new Stream(arg), password);
  55321. } else {
  55322. error('PDFDocument: Unknown argument type');
  55323. }
  55324. }
  55325. function init(pdfManager, stream, password) {
  55326. assert(stream.length > 0, 'stream must have data');
  55327. this.pdfManager = pdfManager;
  55328. this.stream = stream;
  55329. var xref = new XRef(this.stream, password, pdfManager);
  55330. this.xref = xref;
  55331. }
  55332. function find(stream, needle, limit, backwards) {
  55333. var pos = stream.pos;
  55334. var end = stream.end;
  55335. var strBuf = [];
  55336. if (pos + limit > end) {
  55337. limit = end - pos;
  55338. }
  55339. for (var n = 0; n < limit; ++n) {
  55340. strBuf.push(String.fromCharCode(stream.getByte()));
  55341. }
  55342. var str = strBuf.join('');
  55343. stream.pos = pos;
  55344. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55345. if (index === -1) {
  55346. return false;
  55347. }
  55348. stream.pos += index;
  55349. return true;
  55350. }
  55351. var DocumentInfoValidators = {
  55352. get entries() {
  55353. return shadow(this, 'entries', {
  55354. Title: isString,
  55355. Author: isString,
  55356. Subject: isString,
  55357. Keywords: isString,
  55358. Creator: isString,
  55359. Producer: isString,
  55360. CreationDate: isString,
  55361. ModDate: isString,
  55362. Trapped: isName
  55363. });
  55364. }
  55365. };
  55366. PDFDocument.prototype = {
  55367. parse: function PDFDocument_parse(recoveryMode) {
  55368. this.setup(recoveryMode);
  55369. var version = this.catalog.catDict.get('Version');
  55370. if (isName(version)) {
  55371. this.pdfFormatVersion = version.name;
  55372. }
  55373. try {
  55374. this.acroForm = this.catalog.catDict.get('AcroForm');
  55375. if (this.acroForm) {
  55376. this.xfa = this.acroForm.get('XFA');
  55377. var fields = this.acroForm.get('Fields');
  55378. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55379. this.acroForm = null;
  55380. }
  55381. }
  55382. } catch (ex) {
  55383. info('Something wrong with AcroForm entry');
  55384. this.acroForm = null;
  55385. }
  55386. },
  55387. get linearization() {
  55388. var linearization = null;
  55389. if (this.stream.length) {
  55390. try {
  55391. linearization = Linearization.create(this.stream);
  55392. } catch (err) {
  55393. if (err instanceof MissingDataException) {
  55394. throw err;
  55395. }
  55396. info(err);
  55397. }
  55398. }
  55399. return shadow(this, 'linearization', linearization);
  55400. },
  55401. get startXRef() {
  55402. var stream = this.stream;
  55403. var startXRef = 0;
  55404. var linearization = this.linearization;
  55405. if (linearization) {
  55406. stream.reset();
  55407. if (find(stream, 'endobj', 1024)) {
  55408. startXRef = stream.pos + 6;
  55409. }
  55410. } else {
  55411. var step = 1024;
  55412. var found = false, pos = stream.end;
  55413. while (!found && pos > 0) {
  55414. pos -= step - 'startxref'.length;
  55415. if (pos < 0) {
  55416. pos = 0;
  55417. }
  55418. stream.pos = pos;
  55419. found = find(stream, 'startxref', step, true);
  55420. }
  55421. if (found) {
  55422. stream.skip(9);
  55423. var ch;
  55424. do {
  55425. ch = stream.getByte();
  55426. } while (isSpace(ch));
  55427. var str = '';
  55428. while (ch >= 0x20 && ch <= 0x39) {
  55429. str += String.fromCharCode(ch);
  55430. ch = stream.getByte();
  55431. }
  55432. startXRef = parseInt(str, 10);
  55433. if (isNaN(startXRef)) {
  55434. startXRef = 0;
  55435. }
  55436. }
  55437. }
  55438. return shadow(this, 'startXRef', startXRef);
  55439. },
  55440. get mainXRefEntriesOffset() {
  55441. var mainXRefEntriesOffset = 0;
  55442. var linearization = this.linearization;
  55443. if (linearization) {
  55444. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55445. }
  55446. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55447. },
  55448. checkHeader: function PDFDocument_checkHeader() {
  55449. var stream = this.stream;
  55450. stream.reset();
  55451. if (find(stream, '%PDF-', 1024)) {
  55452. stream.moveStart();
  55453. var MAX_VERSION_LENGTH = 12;
  55454. var version = '', ch;
  55455. while ((ch = stream.getByte()) > 0x20) {
  55456. if (version.length >= MAX_VERSION_LENGTH) {
  55457. break;
  55458. }
  55459. version += String.fromCharCode(ch);
  55460. }
  55461. if (!this.pdfFormatVersion) {
  55462. this.pdfFormatVersion = version.substring(5);
  55463. }
  55464. return;
  55465. }
  55466. },
  55467. parseStartXRef: function PDFDocument_parseStartXRef() {
  55468. var startXRef = this.startXRef;
  55469. this.xref.setStartXRef(startXRef);
  55470. },
  55471. setup: function PDFDocument_setup(recoveryMode) {
  55472. this.xref.parse(recoveryMode);
  55473. var self = this;
  55474. var pageFactory = {
  55475. createPage: function (pageIndex, dict, ref, fontCache) {
  55476. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55477. }
  55478. };
  55479. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55480. },
  55481. get numPages() {
  55482. var linearization = this.linearization;
  55483. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55484. return shadow(this, 'numPages', num);
  55485. },
  55486. get documentInfo() {
  55487. var docInfo = {
  55488. PDFFormatVersion: this.pdfFormatVersion,
  55489. IsAcroFormPresent: !!this.acroForm,
  55490. IsXFAPresent: !!this.xfa
  55491. };
  55492. var infoDict;
  55493. try {
  55494. infoDict = this.xref.trailer.get('Info');
  55495. } catch (err) {
  55496. info('The document information dictionary is invalid.');
  55497. }
  55498. if (infoDict) {
  55499. var validEntries = DocumentInfoValidators.entries;
  55500. for (var key in validEntries) {
  55501. if (infoDict.has(key)) {
  55502. var value = infoDict.get(key);
  55503. if (validEntries[key](value)) {
  55504. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55505. } else {
  55506. info('Bad value in document info for "' + key + '"');
  55507. }
  55508. }
  55509. }
  55510. }
  55511. return shadow(this, 'documentInfo', docInfo);
  55512. },
  55513. get fingerprint() {
  55514. var xref = this.xref, hash, fileID = '';
  55515. var idArray = xref.trailer.get('ID');
  55516. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55517. hash = stringToBytes(idArray[0]);
  55518. } else {
  55519. if (this.stream.ensureRange) {
  55520. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55521. }
  55522. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55523. }
  55524. for (var i = 0, n = hash.length; i < n; i++) {
  55525. var hex = hash[i].toString(16);
  55526. fileID += hex.length === 1 ? '0' + hex : hex;
  55527. }
  55528. return shadow(this, 'fingerprint', fileID);
  55529. },
  55530. getPage: function PDFDocument_getPage(pageIndex) {
  55531. return this.catalog.getPage(pageIndex);
  55532. },
  55533. cleanup: function PDFDocument_cleanup() {
  55534. return this.catalog.cleanup();
  55535. }
  55536. };
  55537. return PDFDocument;
  55538. }();
  55539. exports.Page = Page;
  55540. exports.PDFDocument = PDFDocument;
  55541. }));
  55542. (function (root, factory) {
  55543. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55544. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55545. var warn = sharedUtil.warn;
  55546. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55547. var shadow = sharedUtil.shadow;
  55548. var NotImplementedException = sharedUtil.NotImplementedException;
  55549. var MissingDataException = sharedUtil.MissingDataException;
  55550. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55551. var Util = sharedUtil.Util;
  55552. var Stream = coreStream.Stream;
  55553. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55554. var PDFDocument = coreDocument.PDFDocument;
  55555. var BasePdfManager = function BasePdfManagerClosure() {
  55556. function BasePdfManager() {
  55557. throw new Error('Cannot initialize BaseManagerManager');
  55558. }
  55559. BasePdfManager.prototype = {
  55560. get docId() {
  55561. return this._docId;
  55562. },
  55563. get docBaseUrl() {
  55564. var docBaseUrl = null;
  55565. if (this._docBaseUrl) {
  55566. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55567. if (absoluteUrl) {
  55568. docBaseUrl = absoluteUrl.href;
  55569. } else {
  55570. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55571. }
  55572. }
  55573. return shadow(this, 'docBaseUrl', docBaseUrl);
  55574. },
  55575. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55576. throw new NotImplementedException();
  55577. },
  55578. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55579. return this.ensure(this.pdfDocument, prop, args);
  55580. },
  55581. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55582. return this.ensure(this.pdfDocument.xref, prop, args);
  55583. },
  55584. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55585. return this.ensure(this.pdfDocument.catalog, prop, args);
  55586. },
  55587. getPage: function BasePdfManager_getPage(pageIndex) {
  55588. return this.pdfDocument.getPage(pageIndex);
  55589. },
  55590. cleanup: function BasePdfManager_cleanup() {
  55591. return this.pdfDocument.cleanup();
  55592. },
  55593. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55594. return new NotImplementedException();
  55595. },
  55596. requestRange: function BasePdfManager_requestRange(begin, end) {
  55597. return new NotImplementedException();
  55598. },
  55599. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55600. return new NotImplementedException();
  55601. },
  55602. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55603. return new NotImplementedException();
  55604. },
  55605. updatePassword: function BasePdfManager_updatePassword(password) {
  55606. this.pdfDocument.xref.password = this.password = password;
  55607. if (this._passwordChangedCapability) {
  55608. this._passwordChangedCapability.resolve();
  55609. }
  55610. },
  55611. passwordChanged: function BasePdfManager_passwordChanged() {
  55612. this._passwordChangedCapability = createPromiseCapability();
  55613. return this._passwordChangedCapability.promise;
  55614. },
  55615. terminate: function BasePdfManager_terminate() {
  55616. return new NotImplementedException();
  55617. }
  55618. };
  55619. return BasePdfManager;
  55620. }();
  55621. var LocalPdfManager = function LocalPdfManagerClosure() {
  55622. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55623. this._docId = docId;
  55624. this._docBaseUrl = docBaseUrl;
  55625. this.evaluatorOptions = evaluatorOptions;
  55626. var stream = new Stream(data);
  55627. this.pdfDocument = new PDFDocument(this, stream, password);
  55628. this._loadedStreamCapability = createPromiseCapability();
  55629. this._loadedStreamCapability.resolve(stream);
  55630. }
  55631. Util.inherit(LocalPdfManager, BasePdfManager, {
  55632. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55633. return new Promise(function (resolve, reject) {
  55634. try {
  55635. var value = obj[prop];
  55636. var result;
  55637. if (typeof value === 'function') {
  55638. result = value.apply(obj, args);
  55639. } else {
  55640. result = value;
  55641. }
  55642. resolve(result);
  55643. } catch (e) {
  55644. reject(e);
  55645. }
  55646. });
  55647. },
  55648. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55649. return Promise.resolve();
  55650. },
  55651. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55652. return;
  55653. },
  55654. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55655. return this._loadedStreamCapability.promise;
  55656. },
  55657. terminate: function LocalPdfManager_terminate() {
  55658. return;
  55659. }
  55660. });
  55661. return LocalPdfManager;
  55662. }();
  55663. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55664. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55665. this._docId = docId;
  55666. this._docBaseUrl = docBaseUrl;
  55667. this.msgHandler = args.msgHandler;
  55668. this.evaluatorOptions = evaluatorOptions;
  55669. var params = {
  55670. msgHandler: args.msgHandler,
  55671. url: args.url,
  55672. length: args.length,
  55673. disableAutoFetch: args.disableAutoFetch,
  55674. rangeChunkSize: args.rangeChunkSize
  55675. };
  55676. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55677. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  55678. }
  55679. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55680. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55681. var pdfManager = this;
  55682. return new Promise(function (resolve, reject) {
  55683. function ensureHelper() {
  55684. try {
  55685. var result;
  55686. var value = obj[prop];
  55687. if (typeof value === 'function') {
  55688. result = value.apply(obj, args);
  55689. } else {
  55690. result = value;
  55691. }
  55692. resolve(result);
  55693. } catch (e) {
  55694. if (!(e instanceof MissingDataException)) {
  55695. reject(e);
  55696. return;
  55697. }
  55698. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55699. }
  55700. }
  55701. ensureHelper();
  55702. });
  55703. },
  55704. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55705. return this.streamManager.requestRange(begin, end);
  55706. },
  55707. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55708. this.streamManager.requestAllChunks();
  55709. },
  55710. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55711. this.streamManager.onReceiveData({ chunk: chunk });
  55712. },
  55713. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55714. return this.streamManager.onLoadedStream();
  55715. },
  55716. terminate: function NetworkPdfManager_terminate() {
  55717. this.streamManager.abort();
  55718. }
  55719. });
  55720. return NetworkPdfManager;
  55721. }();
  55722. exports.LocalPdfManager = LocalPdfManager;
  55723. exports.NetworkPdfManager = NetworkPdfManager;
  55724. }));
  55725. (function (root, factory) {
  55726. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55727. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55728. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55729. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55730. var MessageHandler = sharedUtil.MessageHandler;
  55731. var MissingPDFException = sharedUtil.MissingPDFException;
  55732. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55733. var PasswordException = sharedUtil.PasswordException;
  55734. var PasswordResponses = sharedUtil.PasswordResponses;
  55735. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55736. var XRefParseException = sharedUtil.XRefParseException;
  55737. var arrayByteLength = sharedUtil.arrayByteLength;
  55738. var arraysToBytes = sharedUtil.arraysToBytes;
  55739. var assert = sharedUtil.assert;
  55740. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55741. var error = sharedUtil.error;
  55742. var info = sharedUtil.info;
  55743. var warn = sharedUtil.warn;
  55744. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55745. var Ref = corePrimitives.Ref;
  55746. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55747. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55748. var globalScope = sharedUtil.globalScope;
  55749. var WorkerTask = function WorkerTaskClosure() {
  55750. function WorkerTask(name) {
  55751. this.name = name;
  55752. this.terminated = false;
  55753. this._capability = createPromiseCapability();
  55754. }
  55755. WorkerTask.prototype = {
  55756. get finished() {
  55757. return this._capability.promise;
  55758. },
  55759. finish: function () {
  55760. this._capability.resolve();
  55761. },
  55762. terminate: function () {
  55763. this.terminated = true;
  55764. },
  55765. ensureNotTerminated: function () {
  55766. if (this.terminated) {
  55767. throw new Error('Worker task was terminated');
  55768. }
  55769. }
  55770. };
  55771. return WorkerTask;
  55772. }();
  55773. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  55774. function PDFWorkerStream(params, msgHandler) {
  55775. this._queuedChunks = [];
  55776. var initialData = params.initialData;
  55777. if (initialData && initialData.length > 0) {
  55778. this._queuedChunks.push(initialData);
  55779. }
  55780. this._msgHandler = msgHandler;
  55781. this._isRangeSupported = !params.disableRange;
  55782. this._isStreamingSupported = !params.disableStream;
  55783. this._contentLength = params.length;
  55784. this._fullRequestReader = null;
  55785. this._rangeReaders = [];
  55786. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  55787. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  55788. }
  55789. PDFWorkerStream.prototype = {
  55790. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  55791. if (args.begin === undefined) {
  55792. if (this._fullRequestReader) {
  55793. this._fullRequestReader._enqueue(args.chunk);
  55794. } else {
  55795. this._queuedChunks.push(args.chunk);
  55796. }
  55797. } else {
  55798. var found = this._rangeReaders.some(function (rangeReader) {
  55799. if (rangeReader._begin !== args.begin) {
  55800. return false;
  55801. }
  55802. rangeReader._enqueue(args.chunk);
  55803. return true;
  55804. });
  55805. assert(found);
  55806. }
  55807. },
  55808. _onProgress: function PDFWorkerStream_onProgress(evt) {
  55809. if (this._rangeReaders.length > 0) {
  55810. var firstReader = this._rangeReaders[0];
  55811. if (firstReader.onProgress) {
  55812. firstReader.onProgress({ loaded: evt.loaded });
  55813. }
  55814. }
  55815. },
  55816. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  55817. var i = this._rangeReaders.indexOf(reader);
  55818. if (i >= 0) {
  55819. this._rangeReaders.splice(i, 1);
  55820. }
  55821. },
  55822. getFullReader: function PDFWorkerStream_getFullReader() {
  55823. assert(!this._fullRequestReader);
  55824. var queuedChunks = this._queuedChunks;
  55825. this._queuedChunks = null;
  55826. return new PDFWorkerStreamReader(this, queuedChunks);
  55827. },
  55828. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  55829. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  55830. this._msgHandler.send('RequestDataRange', {
  55831. begin: begin,
  55832. end: end
  55833. });
  55834. this._rangeReaders.push(reader);
  55835. return reader;
  55836. },
  55837. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  55838. if (this._fullRequestReader) {
  55839. this._fullRequestReader.cancel(reason);
  55840. }
  55841. var readers = this._rangeReaders.slice(0);
  55842. readers.forEach(function (rangeReader) {
  55843. rangeReader.cancel(reason);
  55844. });
  55845. }
  55846. };
  55847. function PDFWorkerStreamReader(stream, queuedChunks) {
  55848. this._stream = stream;
  55849. this._done = false;
  55850. this._queuedChunks = queuedChunks || [];
  55851. this._requests = [];
  55852. this._headersReady = Promise.resolve();
  55853. stream._fullRequestReader = this;
  55854. this.onProgress = null;
  55855. }
  55856. PDFWorkerStreamReader.prototype = {
  55857. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  55858. if (this._done) {
  55859. return;
  55860. }
  55861. if (this._requests.length > 0) {
  55862. var requestCapability = this._requests.shift();
  55863. requestCapability.resolve({
  55864. value: chunk,
  55865. done: false
  55866. });
  55867. return;
  55868. }
  55869. this._queuedChunks.push(chunk);
  55870. },
  55871. get headersReady() {
  55872. return this._headersReady;
  55873. },
  55874. get isRangeSupported() {
  55875. return this._stream._isRangeSupported;
  55876. },
  55877. get isStreamingSupported() {
  55878. return this._stream._isStreamingSupported;
  55879. },
  55880. get contentLength() {
  55881. return this._stream._contentLength;
  55882. },
  55883. read: function PDFWorkerStreamReader_read() {
  55884. if (this._queuedChunks.length > 0) {
  55885. var chunk = this._queuedChunks.shift();
  55886. return Promise.resolve({
  55887. value: chunk,
  55888. done: false
  55889. });
  55890. }
  55891. if (this._done) {
  55892. return Promise.resolve({
  55893. value: undefined,
  55894. done: true
  55895. });
  55896. }
  55897. var requestCapability = createPromiseCapability();
  55898. this._requests.push(requestCapability);
  55899. return requestCapability.promise;
  55900. },
  55901. cancel: function PDFWorkerStreamReader_cancel(reason) {
  55902. this._done = true;
  55903. this._requests.forEach(function (requestCapability) {
  55904. requestCapability.resolve({
  55905. value: undefined,
  55906. done: true
  55907. });
  55908. });
  55909. this._requests = [];
  55910. }
  55911. };
  55912. function PDFWorkerStreamRangeReader(stream, begin, end) {
  55913. this._stream = stream;
  55914. this._begin = begin;
  55915. this._end = end;
  55916. this._queuedChunk = null;
  55917. this._requests = [];
  55918. this._done = false;
  55919. this.onProgress = null;
  55920. }
  55921. PDFWorkerStreamRangeReader.prototype = {
  55922. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  55923. if (this._done) {
  55924. return;
  55925. }
  55926. if (this._requests.length === 0) {
  55927. this._queuedChunk = chunk;
  55928. } else {
  55929. var requestsCapability = this._requests.shift();
  55930. requestsCapability.resolve({
  55931. value: chunk,
  55932. done: false
  55933. });
  55934. this._requests.forEach(function (requestCapability) {
  55935. requestCapability.resolve({
  55936. value: undefined,
  55937. done: true
  55938. });
  55939. });
  55940. this._requests = [];
  55941. }
  55942. this._done = true;
  55943. this._stream._removeRangeReader(this);
  55944. },
  55945. get isStreamingSupported() {
  55946. return false;
  55947. },
  55948. read: function PDFWorkerStreamRangeReader_read() {
  55949. if (this._queuedChunk) {
  55950. return Promise.resolve({
  55951. value: this._queuedChunk,
  55952. done: false
  55953. });
  55954. }
  55955. if (this._done) {
  55956. return Promise.resolve({
  55957. value: undefined,
  55958. done: true
  55959. });
  55960. }
  55961. var requestCapability = createPromiseCapability();
  55962. this._requests.push(requestCapability);
  55963. return requestCapability.promise;
  55964. },
  55965. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  55966. this._done = true;
  55967. this._requests.forEach(function (requestCapability) {
  55968. requestCapability.resolve({
  55969. value: undefined,
  55970. done: true
  55971. });
  55972. });
  55973. this._requests = [];
  55974. this._stream._removeRangeReader(this);
  55975. }
  55976. };
  55977. return PDFWorkerStream;
  55978. }();
  55979. var PDFNetworkStream;
  55980. function setPDFNetworkStreamClass(cls) {
  55981. PDFNetworkStream = cls;
  55982. }
  55983. var WorkerMessageHandler = {
  55984. setup: function wphSetup(handler, port) {
  55985. var testMessageProcessed = false;
  55986. handler.on('test', function wphSetupTest(data) {
  55987. if (testMessageProcessed) {
  55988. return;
  55989. }
  55990. testMessageProcessed = true;
  55991. if (!(data instanceof Uint8Array)) {
  55992. handler.send('test', 'main', false);
  55993. return;
  55994. }
  55995. var supportTransfers = data[0] === 255;
  55996. handler.postMessageTransfers = supportTransfers;
  55997. var xhr = new XMLHttpRequest();
  55998. var responseExists = 'response' in xhr;
  55999. try {
  56000. var dummy = xhr.responseType;
  56001. } catch (e) {
  56002. responseExists = false;
  56003. }
  56004. if (!responseExists) {
  56005. handler.send('test', false);
  56006. return;
  56007. }
  56008. handler.send('test', {
  56009. supportTypedArray: true,
  56010. supportTransfers: supportTransfers
  56011. });
  56012. });
  56013. handler.on('configure', function wphConfigure(data) {
  56014. setVerbosityLevel(data.verbosity);
  56015. });
  56016. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56017. return WorkerMessageHandler.createDocumentHandler(data, port);
  56018. });
  56019. },
  56020. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56021. var pdfManager;
  56022. var terminated = false;
  56023. var cancelXHRs = null;
  56024. var WorkerTasks = [];
  56025. var docId = docParams.docId;
  56026. var docBaseUrl = docParams.docBaseUrl;
  56027. var workerHandlerName = docParams.docId + '_worker';
  56028. var handler = new MessageHandler(workerHandlerName, docId, port);
  56029. handler.postMessageTransfers = docParams.postMessageTransfers;
  56030. function ensureNotTerminated() {
  56031. if (terminated) {
  56032. throw new Error('Worker was terminated');
  56033. }
  56034. }
  56035. function startWorkerTask(task) {
  56036. WorkerTasks.push(task);
  56037. }
  56038. function finishWorkerTask(task) {
  56039. task.finish();
  56040. var i = WorkerTasks.indexOf(task);
  56041. WorkerTasks.splice(i, 1);
  56042. }
  56043. function loadDocument(recoveryMode) {
  56044. var loadDocumentCapability = createPromiseCapability();
  56045. var parseSuccess = function parseSuccess() {
  56046. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56047. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56048. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56049. Promise.all([
  56050. numPagesPromise,
  56051. fingerprintPromise,
  56052. encryptedPromise
  56053. ]).then(function onDocReady(results) {
  56054. var doc = {
  56055. numPages: results[0],
  56056. fingerprint: results[1],
  56057. encrypted: !!results[2]
  56058. };
  56059. loadDocumentCapability.resolve(doc);
  56060. }, parseFailure);
  56061. };
  56062. var parseFailure = function parseFailure(e) {
  56063. loadDocumentCapability.reject(e);
  56064. };
  56065. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56066. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56067. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56068. }, parseFailure);
  56069. }, parseFailure);
  56070. return loadDocumentCapability.promise;
  56071. }
  56072. function getPdfManager(data, evaluatorOptions) {
  56073. var pdfManagerCapability = createPromiseCapability();
  56074. var pdfManager;
  56075. var source = data.source;
  56076. if (source.data) {
  56077. try {
  56078. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56079. pdfManagerCapability.resolve(pdfManager);
  56080. } catch (ex) {
  56081. pdfManagerCapability.reject(ex);
  56082. }
  56083. return pdfManagerCapability.promise;
  56084. }
  56085. var pdfStream;
  56086. try {
  56087. if (source.chunkedViewerLoading) {
  56088. pdfStream = new PDFWorkerStream(source, handler);
  56089. } else {
  56090. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56091. pdfStream = new PDFNetworkStream(data);
  56092. }
  56093. } catch (ex) {
  56094. pdfManagerCapability.reject(ex);
  56095. return pdfManagerCapability.promise;
  56096. }
  56097. var fullRequest = pdfStream.getFullReader();
  56098. fullRequest.headersReady.then(function () {
  56099. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56100. fullRequest.onProgress = function (evt) {
  56101. handler.send('DocProgress', {
  56102. loaded: evt.loaded,
  56103. total: evt.total
  56104. });
  56105. };
  56106. }
  56107. if (!fullRequest.isRangeSupported) {
  56108. return;
  56109. }
  56110. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56111. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56112. msgHandler: handler,
  56113. url: source.url,
  56114. password: source.password,
  56115. length: fullRequest.contentLength,
  56116. disableAutoFetch: disableAutoFetch,
  56117. rangeChunkSize: source.rangeChunkSize
  56118. }, evaluatorOptions, docBaseUrl);
  56119. pdfManagerCapability.resolve(pdfManager);
  56120. cancelXHRs = null;
  56121. }).catch(function (reason) {
  56122. pdfManagerCapability.reject(reason);
  56123. cancelXHRs = null;
  56124. });
  56125. var cachedChunks = [], loaded = 0;
  56126. var flushChunks = function () {
  56127. var pdfFile = arraysToBytes(cachedChunks);
  56128. if (source.length && pdfFile.length !== source.length) {
  56129. warn('reported HTTP length is different from actual');
  56130. }
  56131. try {
  56132. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56133. pdfManagerCapability.resolve(pdfManager);
  56134. } catch (ex) {
  56135. pdfManagerCapability.reject(ex);
  56136. }
  56137. cachedChunks = [];
  56138. };
  56139. var readPromise = new Promise(function (resolve, reject) {
  56140. var readChunk = function (chunk) {
  56141. try {
  56142. ensureNotTerminated();
  56143. if (chunk.done) {
  56144. if (!pdfManager) {
  56145. flushChunks();
  56146. }
  56147. cancelXHRs = null;
  56148. return;
  56149. }
  56150. var data = chunk.value;
  56151. loaded += arrayByteLength(data);
  56152. if (!fullRequest.isStreamingSupported) {
  56153. handler.send('DocProgress', {
  56154. loaded: loaded,
  56155. total: Math.max(loaded, fullRequest.contentLength || 0)
  56156. });
  56157. }
  56158. if (pdfManager) {
  56159. pdfManager.sendProgressiveData(data);
  56160. } else {
  56161. cachedChunks.push(data);
  56162. }
  56163. fullRequest.read().then(readChunk, reject);
  56164. } catch (e) {
  56165. reject(e);
  56166. }
  56167. };
  56168. fullRequest.read().then(readChunk, reject);
  56169. });
  56170. readPromise.catch(function (e) {
  56171. pdfManagerCapability.reject(e);
  56172. cancelXHRs = null;
  56173. });
  56174. cancelXHRs = function () {
  56175. pdfStream.cancelAllRequests('abort');
  56176. };
  56177. return pdfManagerCapability.promise;
  56178. }
  56179. var setupDoc = function (data) {
  56180. var onSuccess = function (doc) {
  56181. ensureNotTerminated();
  56182. handler.send('GetDoc', { pdfInfo: doc });
  56183. };
  56184. var onFailure = function (e) {
  56185. if (e instanceof PasswordException) {
  56186. if (e.code === PasswordResponses.NEED_PASSWORD) {
  56187. handler.send('NeedPassword', e);
  56188. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  56189. handler.send('IncorrectPassword', e);
  56190. }
  56191. } else if (e instanceof InvalidPDFException) {
  56192. handler.send('InvalidPDF', e);
  56193. } else if (e instanceof MissingPDFException) {
  56194. handler.send('MissingPDF', e);
  56195. } else if (e instanceof UnexpectedResponseException) {
  56196. handler.send('UnexpectedResponse', e);
  56197. } else {
  56198. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56199. }
  56200. };
  56201. ensureNotTerminated();
  56202. var cMapOptions = {
  56203. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56204. packed: data.cMapPacked === true
  56205. };
  56206. var evaluatorOptions = {
  56207. forceDataSchema: data.disableCreateObjectURL,
  56208. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56209. disableFontFace: data.disableFontFace,
  56210. cMapOptions: cMapOptions
  56211. };
  56212. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56213. if (terminated) {
  56214. newPdfManager.terminate();
  56215. throw new Error('Worker was terminated');
  56216. }
  56217. pdfManager = newPdfManager;
  56218. handler.send('PDFManagerReady', null);
  56219. pdfManager.onLoadedStream().then(function (stream) {
  56220. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56221. });
  56222. }).then(function pdfManagerReady() {
  56223. ensureNotTerminated();
  56224. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56225. ensureNotTerminated();
  56226. if (!(ex instanceof XRefParseException)) {
  56227. if (ex instanceof PasswordException) {
  56228. pdfManager.passwordChanged().then(pdfManagerReady);
  56229. }
  56230. onFailure(ex);
  56231. return;
  56232. }
  56233. pdfManager.requestLoadedStream();
  56234. pdfManager.onLoadedStream().then(function () {
  56235. ensureNotTerminated();
  56236. loadDocument(true).then(onSuccess, onFailure);
  56237. });
  56238. }, onFailure);
  56239. }, onFailure);
  56240. };
  56241. handler.on('GetPage', function wphSetupGetPage(data) {
  56242. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56243. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56244. var refPromise = pdfManager.ensure(page, 'ref');
  56245. var viewPromise = pdfManager.ensure(page, 'view');
  56246. return Promise.all([
  56247. rotatePromise,
  56248. refPromise,
  56249. viewPromise
  56250. ]).then(function (results) {
  56251. return {
  56252. rotate: results[0],
  56253. ref: results[1],
  56254. view: results[2]
  56255. };
  56256. });
  56257. });
  56258. });
  56259. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56260. var ref = new Ref(data.ref.num, data.ref.gen);
  56261. var catalog = pdfManager.pdfDocument.catalog;
  56262. return catalog.getPageIndex(ref);
  56263. });
  56264. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56265. return pdfManager.ensureCatalog('destinations');
  56266. });
  56267. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56268. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56269. });
  56270. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56271. return pdfManager.ensureCatalog('pageLabels');
  56272. });
  56273. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56274. return pdfManager.ensureCatalog('attachments');
  56275. });
  56276. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56277. return pdfManager.ensureCatalog('javaScript');
  56278. });
  56279. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56280. return pdfManager.ensureCatalog('documentOutline');
  56281. });
  56282. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56283. return Promise.all([
  56284. pdfManager.ensureDoc('documentInfo'),
  56285. pdfManager.ensureCatalog('metadata')
  56286. ]);
  56287. });
  56288. handler.on('GetData', function wphSetupGetData(data) {
  56289. pdfManager.requestLoadedStream();
  56290. return pdfManager.onLoadedStream().then(function (stream) {
  56291. return stream.bytes;
  56292. });
  56293. });
  56294. handler.on('GetStats', function wphSetupGetStats(data) {
  56295. return pdfManager.pdfDocument.xref.stats;
  56296. });
  56297. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  56298. pdfManager.updatePassword(data);
  56299. });
  56300. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56301. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56302. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56303. });
  56304. });
  56305. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56306. var pageIndex = data.pageIndex;
  56307. pdfManager.getPage(pageIndex).then(function (page) {
  56308. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56309. startWorkerTask(task);
  56310. var pageNum = pageIndex + 1;
  56311. var start = Date.now();
  56312. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56313. finishWorkerTask(task);
  56314. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56315. }, function (e) {
  56316. finishWorkerTask(task);
  56317. if (task.terminated) {
  56318. return;
  56319. }
  56320. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56321. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56322. var wrappedException;
  56323. if (typeof e === 'string') {
  56324. wrappedException = {
  56325. message: e,
  56326. stack: minimumStackMessage
  56327. };
  56328. } else if (typeof e === 'object') {
  56329. wrappedException = {
  56330. message: e.message || e.toString(),
  56331. stack: e.stack || minimumStackMessage
  56332. };
  56333. } else {
  56334. wrappedException = {
  56335. message: 'Unknown exception type: ' + typeof e,
  56336. stack: minimumStackMessage
  56337. };
  56338. }
  56339. handler.send('PageError', {
  56340. pageNum: pageNum,
  56341. error: wrappedException,
  56342. intent: data.intent
  56343. });
  56344. });
  56345. });
  56346. }, this);
  56347. handler.on('GetTextContent', function wphExtractText(data) {
  56348. var pageIndex = data.pageIndex;
  56349. var normalizeWhitespace = data.normalizeWhitespace;
  56350. var combineTextItems = data.combineTextItems;
  56351. return pdfManager.getPage(pageIndex).then(function (page) {
  56352. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56353. startWorkerTask(task);
  56354. var pageNum = pageIndex + 1;
  56355. var start = Date.now();
  56356. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56357. finishWorkerTask(task);
  56358. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56359. return textContent;
  56360. }, function (reason) {
  56361. finishWorkerTask(task);
  56362. if (task.terminated) {
  56363. return;
  56364. }
  56365. throw reason;
  56366. });
  56367. });
  56368. });
  56369. handler.on('Cleanup', function wphCleanup(data) {
  56370. return pdfManager.cleanup();
  56371. });
  56372. handler.on('Terminate', function wphTerminate(data) {
  56373. terminated = true;
  56374. if (pdfManager) {
  56375. pdfManager.terminate();
  56376. pdfManager = null;
  56377. }
  56378. if (cancelXHRs) {
  56379. cancelXHRs();
  56380. }
  56381. var waitOn = [];
  56382. WorkerTasks.forEach(function (task) {
  56383. waitOn.push(task.finished);
  56384. task.terminate();
  56385. });
  56386. return Promise.all(waitOn).then(function () {
  56387. handler.destroy();
  56388. handler = null;
  56389. });
  56390. });
  56391. handler.on('Ready', function wphReady(data) {
  56392. setupDoc(docParams);
  56393. docParams = null;
  56394. });
  56395. return workerHandlerName;
  56396. }
  56397. };
  56398. function initializeWorker() {
  56399. if (!('console' in globalScope)) {
  56400. var consoleTimer = {};
  56401. var workerConsole = {
  56402. log: function log() {
  56403. var args = Array.prototype.slice.call(arguments);
  56404. globalScope.postMessage({
  56405. targetName: 'main',
  56406. action: 'console_log',
  56407. data: args
  56408. });
  56409. },
  56410. error: function error() {
  56411. var args = Array.prototype.slice.call(arguments);
  56412. globalScope.postMessage({
  56413. targetName: 'main',
  56414. action: 'console_error',
  56415. data: args
  56416. });
  56417. throw 'pdf.js execution error';
  56418. },
  56419. time: function time(name) {
  56420. consoleTimer[name] = Date.now();
  56421. },
  56422. timeEnd: function timeEnd(name) {
  56423. var time = consoleTimer[name];
  56424. if (!time) {
  56425. error('Unknown timer name ' + name);
  56426. }
  56427. this.log('Timer:', name, Date.now() - time);
  56428. }
  56429. };
  56430. globalScope.console = workerConsole;
  56431. }
  56432. var handler = new MessageHandler('worker', 'main', self);
  56433. WorkerMessageHandler.setup(handler, self);
  56434. handler.send('ready', null);
  56435. }
  56436. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56437. initializeWorker();
  56438. }
  56439. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56440. exports.WorkerTask = WorkerTask;
  56441. exports.WorkerMessageHandler = WorkerMessageHandler;
  56442. }));
  56443. (function (root, factory) {
  56444. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56445. }(this, function (exports, sharedUtil, coreWorker) {
  56446. var OK_RESPONSE = 200;
  56447. var PARTIAL_CONTENT_RESPONSE = 206;
  56448. function NetworkManager(url, args) {
  56449. this.url = url;
  56450. args = args || {};
  56451. this.isHttp = /^https?:/i.test(url);
  56452. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56453. this.withCredentials = args.withCredentials || false;
  56454. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56455. return new XMLHttpRequest();
  56456. };
  56457. this.currXhrId = 0;
  56458. this.pendingRequests = Object.create(null);
  56459. this.loadedRequests = Object.create(null);
  56460. }
  56461. function getArrayBuffer(xhr) {
  56462. var data = xhr.response;
  56463. if (typeof data !== 'string') {
  56464. return data;
  56465. }
  56466. var length = data.length;
  56467. var array = new Uint8Array(length);
  56468. for (var i = 0; i < length; i++) {
  56469. array[i] = data.charCodeAt(i) & 0xFF;
  56470. }
  56471. return array.buffer;
  56472. }
  56473. var supportsMozChunked = function supportsMozChunkedClosure() {
  56474. try {
  56475. var x = new XMLHttpRequest();
  56476. x.open('GET', 'https://example.com');
  56477. x.responseType = 'moz-chunked-arraybuffer';
  56478. return x.responseType === 'moz-chunked-arraybuffer';
  56479. } catch (e) {
  56480. return false;
  56481. }
  56482. }();
  56483. NetworkManager.prototype = {
  56484. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56485. var args = {
  56486. begin: begin,
  56487. end: end
  56488. };
  56489. for (var prop in listeners) {
  56490. args[prop] = listeners[prop];
  56491. }
  56492. return this.request(args);
  56493. },
  56494. requestFull: function NetworkManager_requestFull(listeners) {
  56495. return this.request(listeners);
  56496. },
  56497. request: function NetworkManager_request(args) {
  56498. var xhr = this.getXhr();
  56499. var xhrId = this.currXhrId++;
  56500. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56501. xhr.open('GET', this.url);
  56502. xhr.withCredentials = this.withCredentials;
  56503. for (var property in this.httpHeaders) {
  56504. var value = this.httpHeaders[property];
  56505. if (typeof value === 'undefined') {
  56506. continue;
  56507. }
  56508. xhr.setRequestHeader(property, value);
  56509. }
  56510. if (this.isHttp && 'begin' in args && 'end' in args) {
  56511. var rangeStr = args.begin + '-' + (args.end - 1);
  56512. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56513. pendingRequest.expectedStatus = 206;
  56514. } else {
  56515. pendingRequest.expectedStatus = 200;
  56516. }
  56517. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56518. if (useMozChunkedLoading) {
  56519. xhr.responseType = 'moz-chunked-arraybuffer';
  56520. pendingRequest.onProgressiveData = args.onProgressiveData;
  56521. pendingRequest.mozChunked = true;
  56522. } else {
  56523. xhr.responseType = 'arraybuffer';
  56524. }
  56525. if (args.onError) {
  56526. xhr.onerror = function (evt) {
  56527. args.onError(xhr.status);
  56528. };
  56529. }
  56530. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56531. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56532. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56533. pendingRequest.onDone = args.onDone;
  56534. pendingRequest.onError = args.onError;
  56535. pendingRequest.onProgress = args.onProgress;
  56536. xhr.send(null);
  56537. return xhrId;
  56538. },
  56539. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56540. var pendingRequest = this.pendingRequests[xhrId];
  56541. if (!pendingRequest) {
  56542. return;
  56543. }
  56544. if (pendingRequest.mozChunked) {
  56545. var chunk = getArrayBuffer(pendingRequest.xhr);
  56546. pendingRequest.onProgressiveData(chunk);
  56547. }
  56548. var onProgress = pendingRequest.onProgress;
  56549. if (onProgress) {
  56550. onProgress(evt);
  56551. }
  56552. },
  56553. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56554. var pendingRequest = this.pendingRequests[xhrId];
  56555. if (!pendingRequest) {
  56556. return;
  56557. }
  56558. var xhr = pendingRequest.xhr;
  56559. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56560. pendingRequest.onHeadersReceived();
  56561. delete pendingRequest.onHeadersReceived;
  56562. }
  56563. if (xhr.readyState !== 4) {
  56564. return;
  56565. }
  56566. if (!(xhrId in this.pendingRequests)) {
  56567. return;
  56568. }
  56569. delete this.pendingRequests[xhrId];
  56570. if (xhr.status === 0 && this.isHttp) {
  56571. if (pendingRequest.onError) {
  56572. pendingRequest.onError(xhr.status);
  56573. }
  56574. return;
  56575. }
  56576. var xhrStatus = xhr.status || OK_RESPONSE;
  56577. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56578. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56579. if (pendingRequest.onError) {
  56580. pendingRequest.onError(xhr.status);
  56581. }
  56582. return;
  56583. }
  56584. this.loadedRequests[xhrId] = true;
  56585. var chunk = getArrayBuffer(xhr);
  56586. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56587. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56588. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56589. var begin = parseInt(matches[1], 10);
  56590. pendingRequest.onDone({
  56591. begin: begin,
  56592. chunk: chunk
  56593. });
  56594. } else if (pendingRequest.onProgressiveData) {
  56595. pendingRequest.onDone(null);
  56596. } else if (chunk) {
  56597. pendingRequest.onDone({
  56598. begin: 0,
  56599. chunk: chunk
  56600. });
  56601. } else if (pendingRequest.onError) {
  56602. pendingRequest.onError(xhr.status);
  56603. }
  56604. },
  56605. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56606. for (var xhrId in this.pendingRequests) {
  56607. return true;
  56608. }
  56609. return false;
  56610. },
  56611. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56612. return this.pendingRequests[xhrId].xhr;
  56613. },
  56614. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56615. return !!this.pendingRequests[xhrId].onProgressiveData;
  56616. },
  56617. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56618. return xhrId in this.pendingRequests;
  56619. },
  56620. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56621. return xhrId in this.loadedRequests;
  56622. },
  56623. abortAllRequests: function NetworkManager_abortAllRequests() {
  56624. for (var xhrId in this.pendingRequests) {
  56625. this.abortRequest(xhrId | 0);
  56626. }
  56627. },
  56628. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56629. var xhr = this.pendingRequests[xhrId].xhr;
  56630. delete this.pendingRequests[xhrId];
  56631. xhr.abort();
  56632. }
  56633. };
  56634. var assert = sharedUtil.assert;
  56635. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56636. var isInt = sharedUtil.isInt;
  56637. var MissingPDFException = sharedUtil.MissingPDFException;
  56638. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56639. function PDFNetworkStream(options) {
  56640. this._options = options;
  56641. var source = options.source;
  56642. this._manager = new NetworkManager(source.url, {
  56643. httpHeaders: source.httpHeaders,
  56644. withCredentials: source.withCredentials
  56645. });
  56646. this._rangeChunkSize = source.rangeChunkSize;
  56647. this._fullRequestReader = null;
  56648. this._rangeRequestReaders = [];
  56649. }
  56650. PDFNetworkStream.prototype = {
  56651. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56652. var i = this._rangeRequestReaders.indexOf(reader);
  56653. if (i >= 0) {
  56654. this._rangeRequestReaders.splice(i, 1);
  56655. }
  56656. },
  56657. getFullReader: function PDFNetworkStream_getFullReader() {
  56658. assert(!this._fullRequestReader);
  56659. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56660. return this._fullRequestReader;
  56661. },
  56662. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56663. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56664. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56665. this._rangeRequestReaders.push(reader);
  56666. return reader;
  56667. },
  56668. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56669. if (this._fullRequestReader) {
  56670. this._fullRequestReader.cancel(reason);
  56671. }
  56672. var readers = this._rangeRequestReaders.slice(0);
  56673. readers.forEach(function (reader) {
  56674. reader.cancel(reason);
  56675. });
  56676. }
  56677. };
  56678. function PDFNetworkStreamFullRequestReader(manager, options) {
  56679. this._manager = manager;
  56680. var source = options.source;
  56681. var args = {
  56682. onHeadersReceived: this._onHeadersReceived.bind(this),
  56683. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56684. onDone: this._onDone.bind(this),
  56685. onError: this._onError.bind(this),
  56686. onProgress: this._onProgress.bind(this)
  56687. };
  56688. this._url = source.url;
  56689. this._fullRequestId = manager.requestFull(args);
  56690. this._headersReceivedCapability = createPromiseCapability();
  56691. this._disableRange = options.disableRange || false;
  56692. this._contentLength = source.length;
  56693. this._rangeChunkSize = source.rangeChunkSize;
  56694. if (!this._rangeChunkSize && !this._disableRange) {
  56695. this._disableRange = true;
  56696. }
  56697. this._isStreamingSupported = false;
  56698. this._isRangeSupported = false;
  56699. this._cachedChunks = [];
  56700. this._requests = [];
  56701. this._done = false;
  56702. this._storedError = undefined;
  56703. this.onProgress = null;
  56704. }
  56705. PDFNetworkStreamFullRequestReader.prototype = {
  56706. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56707. if (this._disableRange) {
  56708. return false;
  56709. }
  56710. var networkManager = this._manager;
  56711. if (!networkManager.isHttp) {
  56712. return false;
  56713. }
  56714. var fullRequestXhrId = this._fullRequestId;
  56715. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56716. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56717. return false;
  56718. }
  56719. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56720. if (contentEncoding !== 'identity') {
  56721. return false;
  56722. }
  56723. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56724. length = parseInt(length, 10);
  56725. if (!isInt(length)) {
  56726. return false;
  56727. }
  56728. this._contentLength = length;
  56729. if (length <= 2 * this._rangeChunkSize) {
  56730. return false;
  56731. }
  56732. return true;
  56733. },
  56734. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56735. if (this._validateRangeRequestCapabilities()) {
  56736. this._isRangeSupported = true;
  56737. }
  56738. var networkManager = this._manager;
  56739. var fullRequestXhrId = this._fullRequestId;
  56740. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56741. this._isStreamingSupported = true;
  56742. } else if (this._isRangeSupported) {
  56743. networkManager.abortRequest(fullRequestXhrId);
  56744. }
  56745. this._headersReceivedCapability.resolve();
  56746. },
  56747. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56748. if (this._requests.length > 0) {
  56749. var requestCapability = this._requests.shift();
  56750. requestCapability.resolve({
  56751. value: chunk,
  56752. done: false
  56753. });
  56754. } else {
  56755. this._cachedChunks.push(chunk);
  56756. }
  56757. },
  56758. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56759. if (args) {
  56760. this._onProgressiveData(args.chunk);
  56761. }
  56762. this._done = true;
  56763. if (this._cachedChunks.length > 0) {
  56764. return;
  56765. }
  56766. this._requests.forEach(function (requestCapability) {
  56767. requestCapability.resolve({
  56768. value: undefined,
  56769. done: true
  56770. });
  56771. });
  56772. this._requests = [];
  56773. },
  56774. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  56775. var url = this._url;
  56776. var exception;
  56777. if (status === 404 || status === 0 && /^file:/.test(url)) {
  56778. exception = new MissingPDFException('Missing PDF "' + url + '".');
  56779. } else {
  56780. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  56781. }
  56782. this._storedError = exception;
  56783. this._headersReceivedCapability.reject(exception);
  56784. this._requests.forEach(function (requestCapability) {
  56785. requestCapability.reject(exception);
  56786. });
  56787. this._requests = [];
  56788. this._cachedChunks = [];
  56789. },
  56790. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  56791. if (this.onProgress) {
  56792. this.onProgress({
  56793. loaded: data.loaded,
  56794. total: data.lengthComputable ? data.total : this._contentLength
  56795. });
  56796. }
  56797. },
  56798. get isRangeSupported() {
  56799. return this._isRangeSupported;
  56800. },
  56801. get isStreamingSupported() {
  56802. return this._isStreamingSupported;
  56803. },
  56804. get contentLength() {
  56805. return this._contentLength;
  56806. },
  56807. get headersReady() {
  56808. return this._headersReceivedCapability.promise;
  56809. },
  56810. read: function PDFNetworkStreamFullRequestReader_read() {
  56811. if (this._storedError) {
  56812. return Promise.reject(this._storedError);
  56813. }
  56814. if (this._cachedChunks.length > 0) {
  56815. var chunk = this._cachedChunks.shift();
  56816. return Promise.resolve(chunk);
  56817. }
  56818. if (this._done) {
  56819. return Promise.resolve({
  56820. value: undefined,
  56821. done: true
  56822. });
  56823. }
  56824. var requestCapability = createPromiseCapability();
  56825. this._requests.push(requestCapability);
  56826. return requestCapability.promise;
  56827. },
  56828. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  56829. this._done = true;
  56830. this._headersReceivedCapability.reject(reason);
  56831. this._requests.forEach(function (requestCapability) {
  56832. requestCapability.resolve({
  56833. value: undefined,
  56834. done: true
  56835. });
  56836. });
  56837. this._requests = [];
  56838. if (this._manager.isPendingRequest(this._fullRequestId)) {
  56839. this._manager.abortRequest(this._fullRequestId);
  56840. }
  56841. this._fullRequestReader = null;
  56842. }
  56843. };
  56844. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  56845. this._manager = manager;
  56846. var args = {
  56847. onDone: this._onDone.bind(this),
  56848. onProgress: this._onProgress.bind(this)
  56849. };
  56850. this._requestId = manager.requestRange(begin, end, args);
  56851. this._requests = [];
  56852. this._queuedChunk = null;
  56853. this._done = false;
  56854. this.onProgress = null;
  56855. this.onClosed = null;
  56856. }
  56857. PDFNetworkStreamRangeRequestReader.prototype = {
  56858. _close: function PDFNetworkStreamRangeRequestReader_close() {
  56859. if (this.onClosed) {
  56860. this.onClosed(this);
  56861. }
  56862. },
  56863. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  56864. var chunk = data.chunk;
  56865. if (this._requests.length > 0) {
  56866. var requestCapability = this._requests.shift();
  56867. requestCapability.resolve({
  56868. value: chunk,
  56869. done: false
  56870. });
  56871. } else {
  56872. this._queuedChunk = chunk;
  56873. }
  56874. this._done = true;
  56875. this._requests.forEach(function (requestCapability) {
  56876. requestCapability.resolve({
  56877. value: undefined,
  56878. done: true
  56879. });
  56880. });
  56881. this._requests = [];
  56882. this._close();
  56883. },
  56884. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  56885. if (!this.isStreamingSupported && this.onProgress) {
  56886. this.onProgress({ loaded: evt.loaded });
  56887. }
  56888. },
  56889. get isStreamingSupported() {
  56890. return false;
  56891. },
  56892. read: function PDFNetworkStreamRangeRequestReader_read() {
  56893. if (this._queuedChunk !== null) {
  56894. var chunk = this._queuedChunk;
  56895. this._queuedChunk = null;
  56896. return Promise.resolve({
  56897. value: chunk,
  56898. done: false
  56899. });
  56900. }
  56901. if (this._done) {
  56902. return Promise.resolve({
  56903. value: undefined,
  56904. done: true
  56905. });
  56906. }
  56907. var requestCapability = createPromiseCapability();
  56908. this._requests.push(requestCapability);
  56909. return requestCapability.promise;
  56910. },
  56911. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  56912. this._done = true;
  56913. this._requests.forEach(function (requestCapability) {
  56914. requestCapability.resolve({
  56915. value: undefined,
  56916. done: true
  56917. });
  56918. });
  56919. this._requests = [];
  56920. if (this._manager.isPendingRequest(this._requestId)) {
  56921. this._manager.abortRequest(this._requestId);
  56922. }
  56923. this._close();
  56924. }
  56925. };
  56926. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  56927. exports.PDFNetworkStream = PDFNetworkStream;
  56928. exports.NetworkManager = NetworkManager;
  56929. }));
  56930. }.call(pdfjsLibs));
  56931. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  56932. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  56933. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  56934. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  56935. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  56936. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  56937. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  56938. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56939. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  56940. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  56941. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  56942. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  56943. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  56944. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  56945. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  56946. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56947. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  56948. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  56949. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  56950. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  56951. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  56952. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  56953. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56954. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  56955. }));