pdf.combined.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/ // The require function
  29. /******/ function __w_pdfjs_require__(moduleId) {
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId])
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __w_pdfjs_require__.m = modules;
  48. /******/ // expose the module cache
  49. /******/ __w_pdfjs_require__.c = installedModules;
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  52. /******/ // define getter function for harmony exports
  53. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  54. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/ // getDefaultExport function for compatibility with non-harmony modules
  63. /******/ __w_pdfjs_require__.n = function(module) {
  64. /******/ var getter = module && module.__esModule ?
  65. /******/ function getDefault() { return module['default']; } :
  66. /******/ function getModuleExports() { return module; };
  67. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  68. /******/ return getter;
  69. /******/ };
  70. /******/ // Object.prototype.hasOwnProperty.call
  71. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  72. /******/ // __webpack_public_path__
  73. /******/ __w_pdfjs_require__.p = "";
  74. /******/ // Load entry module and return exports
  75. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 47);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  84. var FONT_IDENTITY_MATRIX = [
  85. 0.001,
  86. 0,
  87. 0,
  88. 0.001,
  89. 0,
  90. 0
  91. ];
  92. var TextRenderingMode = {
  93. FILL: 0,
  94. STROKE: 1,
  95. FILL_STROKE: 2,
  96. INVISIBLE: 3,
  97. FILL_ADD_TO_PATH: 4,
  98. STROKE_ADD_TO_PATH: 5,
  99. FILL_STROKE_ADD_TO_PATH: 6,
  100. ADD_TO_PATH: 7,
  101. FILL_STROKE_MASK: 3,
  102. ADD_TO_PATH_FLAG: 4
  103. };
  104. var ImageKind = {
  105. GRAYSCALE_1BPP: 1,
  106. RGB_24BPP: 2,
  107. RGBA_32BPP: 3
  108. };
  109. var AnnotationType = {
  110. TEXT: 1,
  111. LINK: 2,
  112. FREETEXT: 3,
  113. LINE: 4,
  114. SQUARE: 5,
  115. CIRCLE: 6,
  116. POLYGON: 7,
  117. POLYLINE: 8,
  118. HIGHLIGHT: 9,
  119. UNDERLINE: 10,
  120. SQUIGGLY: 11,
  121. STRIKEOUT: 12,
  122. STAMP: 13,
  123. CARET: 14,
  124. INK: 15,
  125. POPUP: 16,
  126. FILEATTACHMENT: 17,
  127. SOUND: 18,
  128. MOVIE: 19,
  129. WIDGET: 20,
  130. SCREEN: 21,
  131. PRINTERMARK: 22,
  132. TRAPNET: 23,
  133. WATERMARK: 24,
  134. THREED: 25,
  135. REDACT: 26
  136. };
  137. var AnnotationFlag = {
  138. INVISIBLE: 0x01,
  139. HIDDEN: 0x02,
  140. PRINT: 0x04,
  141. NOZOOM: 0x08,
  142. NOROTATE: 0x10,
  143. NOVIEW: 0x20,
  144. READONLY: 0x40,
  145. LOCKED: 0x80,
  146. TOGGLENOVIEW: 0x100,
  147. LOCKEDCONTENTS: 0x200
  148. };
  149. var AnnotationFieldFlag = {
  150. READONLY: 0x0000001,
  151. REQUIRED: 0x0000002,
  152. NOEXPORT: 0x0000004,
  153. MULTILINE: 0x0001000,
  154. PASSWORD: 0x0002000,
  155. NOTOGGLETOOFF: 0x0004000,
  156. RADIO: 0x0008000,
  157. PUSHBUTTON: 0x0010000,
  158. COMBO: 0x0020000,
  159. EDIT: 0x0040000,
  160. SORT: 0x0080000,
  161. FILESELECT: 0x0100000,
  162. MULTISELECT: 0x0200000,
  163. DONOTSPELLCHECK: 0x0400000,
  164. DONOTSCROLL: 0x0800000,
  165. COMB: 0x1000000,
  166. RICHTEXT: 0x2000000,
  167. RADIOSINUNISON: 0x2000000,
  168. COMMITONSELCHANGE: 0x4000000
  169. };
  170. var AnnotationBorderStyleType = {
  171. SOLID: 1,
  172. DASHED: 2,
  173. BEVELED: 3,
  174. INSET: 4,
  175. UNDERLINE: 5
  176. };
  177. var StreamType = {
  178. UNKNOWN: 0,
  179. FLATE: 1,
  180. LZW: 2,
  181. DCT: 3,
  182. JPX: 4,
  183. JBIG: 5,
  184. A85: 6,
  185. AHX: 7,
  186. CCF: 8,
  187. RL: 9
  188. };
  189. var FontType = {
  190. UNKNOWN: 0,
  191. TYPE1: 1,
  192. TYPE1C: 2,
  193. CIDFONTTYPE0: 3,
  194. CIDFONTTYPE0C: 4,
  195. TRUETYPE: 5,
  196. CIDFONTTYPE2: 6,
  197. TYPE3: 7,
  198. OPENTYPE: 8,
  199. TYPE0: 9,
  200. MMTYPE1: 10
  201. };
  202. var VERBOSITY_LEVELS = {
  203. errors: 0,
  204. warnings: 1,
  205. infos: 5
  206. };
  207. var CMapCompressionType = {
  208. NONE: 0,
  209. BINARY: 1,
  210. STREAM: 2
  211. };
  212. var OPS = {
  213. dependency: 1,
  214. setLineWidth: 2,
  215. setLineCap: 3,
  216. setLineJoin: 4,
  217. setMiterLimit: 5,
  218. setDash: 6,
  219. setRenderingIntent: 7,
  220. setFlatness: 8,
  221. setGState: 9,
  222. save: 10,
  223. restore: 11,
  224. transform: 12,
  225. moveTo: 13,
  226. lineTo: 14,
  227. curveTo: 15,
  228. curveTo2: 16,
  229. curveTo3: 17,
  230. closePath: 18,
  231. rectangle: 19,
  232. stroke: 20,
  233. closeStroke: 21,
  234. fill: 22,
  235. eoFill: 23,
  236. fillStroke: 24,
  237. eoFillStroke: 25,
  238. closeFillStroke: 26,
  239. closeEOFillStroke: 27,
  240. endPath: 28,
  241. clip: 29,
  242. eoClip: 30,
  243. beginText: 31,
  244. endText: 32,
  245. setCharSpacing: 33,
  246. setWordSpacing: 34,
  247. setHScale: 35,
  248. setLeading: 36,
  249. setFont: 37,
  250. setTextRenderingMode: 38,
  251. setTextRise: 39,
  252. moveText: 40,
  253. setLeadingMoveText: 41,
  254. setTextMatrix: 42,
  255. nextLine: 43,
  256. showText: 44,
  257. showSpacedText: 45,
  258. nextLineShowText: 46,
  259. nextLineSetSpacingShowText: 47,
  260. setCharWidth: 48,
  261. setCharWidthAndBounds: 49,
  262. setStrokeColorSpace: 50,
  263. setFillColorSpace: 51,
  264. setStrokeColor: 52,
  265. setStrokeColorN: 53,
  266. setFillColor: 54,
  267. setFillColorN: 55,
  268. setStrokeGray: 56,
  269. setFillGray: 57,
  270. setStrokeRGBColor: 58,
  271. setFillRGBColor: 59,
  272. setStrokeCMYKColor: 60,
  273. setFillCMYKColor: 61,
  274. shadingFill: 62,
  275. beginInlineImage: 63,
  276. beginImageData: 64,
  277. endInlineImage: 65,
  278. paintXObject: 66,
  279. markPoint: 67,
  280. markPointProps: 68,
  281. beginMarkedContent: 69,
  282. beginMarkedContentProps: 70,
  283. endMarkedContent: 71,
  284. beginCompat: 72,
  285. endCompat: 73,
  286. paintFormXObjectBegin: 74,
  287. paintFormXObjectEnd: 75,
  288. beginGroup: 76,
  289. endGroup: 77,
  290. beginAnnotations: 78,
  291. endAnnotations: 79,
  292. beginAnnotation: 80,
  293. endAnnotation: 81,
  294. paintJpegXObject: 82,
  295. paintImageMaskXObject: 83,
  296. paintImageMaskXObjectGroup: 84,
  297. paintImageXObject: 85,
  298. paintInlineImageXObject: 86,
  299. paintInlineImageXObjectGroup: 87,
  300. paintImageXObjectRepeat: 88,
  301. paintImageMaskXObjectRepeat: 89,
  302. paintSolidColorImageMask: 90,
  303. constructPath: 91
  304. };
  305. var verbosity = VERBOSITY_LEVELS.warnings;
  306. function setVerbosityLevel(level) {
  307. verbosity = level;
  308. }
  309. function getVerbosityLevel() {
  310. return verbosity;
  311. }
  312. function info(msg) {
  313. if (verbosity >= VERBOSITY_LEVELS.infos) {
  314. console.log('Info: ' + msg);
  315. }
  316. }
  317. function warn(msg) {
  318. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  319. console.log('Warning: ' + msg);
  320. }
  321. }
  322. function deprecated(details) {
  323. console.log('Deprecated API usage: ' + details);
  324. }
  325. function error(msg) {
  326. if (verbosity >= VERBOSITY_LEVELS.errors) {
  327. console.log('Error: ' + msg);
  328. console.log(backtrace());
  329. }
  330. throw new Error(msg);
  331. }
  332. function backtrace() {
  333. try {
  334. throw new Error();
  335. } catch (e) {
  336. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  337. }
  338. }
  339. function assert(cond, msg) {
  340. if (!cond) {
  341. error(msg);
  342. }
  343. }
  344. var UNSUPPORTED_FEATURES = {
  345. unknown: 'unknown',
  346. forms: 'forms',
  347. javaScript: 'javaScript',
  348. smask: 'smask',
  349. shadingPattern: 'shadingPattern',
  350. font: 'font'
  351. };
  352. function isSameOrigin(baseUrl, otherUrl) {
  353. try {
  354. var base = new URL(baseUrl);
  355. if (!base.origin || base.origin === 'null') {
  356. return false;
  357. }
  358. } catch (e) {
  359. return false;
  360. }
  361. var other = new URL(otherUrl, base);
  362. return base.origin === other.origin;
  363. }
  364. function isValidProtocol(url) {
  365. if (!url) {
  366. return false;
  367. }
  368. switch (url.protocol) {
  369. case 'http:':
  370. case 'https:':
  371. case 'ftp:':
  372. case 'mailto:':
  373. case 'tel:':
  374. return true;
  375. default:
  376. return false;
  377. }
  378. }
  379. function createValidAbsoluteUrl(url, baseUrl) {
  380. if (!url) {
  381. return null;
  382. }
  383. try {
  384. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  385. if (isValidProtocol(absoluteUrl)) {
  386. return absoluteUrl;
  387. }
  388. } catch (ex) {
  389. }
  390. return null;
  391. }
  392. function shadow(obj, prop, value) {
  393. Object.defineProperty(obj, prop, {
  394. value: value,
  395. enumerable: true,
  396. configurable: true,
  397. writable: false
  398. });
  399. return value;
  400. }
  401. function getLookupTableFactory(initializer) {
  402. var lookup;
  403. return function () {
  404. if (initializer) {
  405. lookup = Object.create(null);
  406. initializer(lookup);
  407. initializer = null;
  408. }
  409. return lookup;
  410. };
  411. }
  412. var PasswordResponses = {
  413. NEED_PASSWORD: 1,
  414. INCORRECT_PASSWORD: 2
  415. };
  416. var PasswordException = function PasswordExceptionClosure() {
  417. function PasswordException(msg, code) {
  418. this.name = 'PasswordException';
  419. this.message = msg;
  420. this.code = code;
  421. }
  422. PasswordException.prototype = new Error();
  423. PasswordException.constructor = PasswordException;
  424. return PasswordException;
  425. }();
  426. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  427. function UnknownErrorException(msg, details) {
  428. this.name = 'UnknownErrorException';
  429. this.message = msg;
  430. this.details = details;
  431. }
  432. UnknownErrorException.prototype = new Error();
  433. UnknownErrorException.constructor = UnknownErrorException;
  434. return UnknownErrorException;
  435. }();
  436. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  437. function InvalidPDFException(msg) {
  438. this.name = 'InvalidPDFException';
  439. this.message = msg;
  440. }
  441. InvalidPDFException.prototype = new Error();
  442. InvalidPDFException.constructor = InvalidPDFException;
  443. return InvalidPDFException;
  444. }();
  445. var MissingPDFException = function MissingPDFExceptionClosure() {
  446. function MissingPDFException(msg) {
  447. this.name = 'MissingPDFException';
  448. this.message = msg;
  449. }
  450. MissingPDFException.prototype = new Error();
  451. MissingPDFException.constructor = MissingPDFException;
  452. return MissingPDFException;
  453. }();
  454. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  455. function UnexpectedResponseException(msg, status) {
  456. this.name = 'UnexpectedResponseException';
  457. this.message = msg;
  458. this.status = status;
  459. }
  460. UnexpectedResponseException.prototype = new Error();
  461. UnexpectedResponseException.constructor = UnexpectedResponseException;
  462. return UnexpectedResponseException;
  463. }();
  464. var NotImplementedException = function NotImplementedExceptionClosure() {
  465. function NotImplementedException(msg) {
  466. this.message = msg;
  467. }
  468. NotImplementedException.prototype = new Error();
  469. NotImplementedException.prototype.name = 'NotImplementedException';
  470. NotImplementedException.constructor = NotImplementedException;
  471. return NotImplementedException;
  472. }();
  473. var MissingDataException = function MissingDataExceptionClosure() {
  474. function MissingDataException(begin, end) {
  475. this.begin = begin;
  476. this.end = end;
  477. this.message = 'Missing data [' + begin + ', ' + end + ')';
  478. }
  479. MissingDataException.prototype = new Error();
  480. MissingDataException.prototype.name = 'MissingDataException';
  481. MissingDataException.constructor = MissingDataException;
  482. return MissingDataException;
  483. }();
  484. var XRefParseException = function XRefParseExceptionClosure() {
  485. function XRefParseException(msg) {
  486. this.message = msg;
  487. }
  488. XRefParseException.prototype = new Error();
  489. XRefParseException.prototype.name = 'XRefParseException';
  490. XRefParseException.constructor = XRefParseException;
  491. return XRefParseException;
  492. }();
  493. var NullCharactersRegExp = /\x00/g;
  494. function removeNullCharacters(str) {
  495. if (typeof str !== 'string') {
  496. warn('The argument for removeNullCharacters must be a string.');
  497. return str;
  498. }
  499. return str.replace(NullCharactersRegExp, '');
  500. }
  501. function bytesToString(bytes) {
  502. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  503. var length = bytes.length;
  504. var MAX_ARGUMENT_COUNT = 8192;
  505. if (length < MAX_ARGUMENT_COUNT) {
  506. return String.fromCharCode.apply(null, bytes);
  507. }
  508. var strBuf = [];
  509. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  510. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  511. var chunk = bytes.subarray(i, chunkEnd);
  512. strBuf.push(String.fromCharCode.apply(null, chunk));
  513. }
  514. return strBuf.join('');
  515. }
  516. function stringToBytes(str) {
  517. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  518. var length = str.length;
  519. var bytes = new Uint8Array(length);
  520. for (var i = 0; i < length; ++i) {
  521. bytes[i] = str.charCodeAt(i) & 0xFF;
  522. }
  523. return bytes;
  524. }
  525. function arrayByteLength(arr) {
  526. if (arr.length !== undefined) {
  527. return arr.length;
  528. }
  529. assert(arr.byteLength !== undefined);
  530. return arr.byteLength;
  531. }
  532. function arraysToBytes(arr) {
  533. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  534. return arr[0];
  535. }
  536. var resultLength = 0;
  537. var i, ii = arr.length;
  538. var item, itemLength;
  539. for (i = 0; i < ii; i++) {
  540. item = arr[i];
  541. itemLength = arrayByteLength(item);
  542. resultLength += itemLength;
  543. }
  544. var pos = 0;
  545. var data = new Uint8Array(resultLength);
  546. for (i = 0; i < ii; i++) {
  547. item = arr[i];
  548. if (!(item instanceof Uint8Array)) {
  549. if (typeof item === 'string') {
  550. item = stringToBytes(item);
  551. } else {
  552. item = new Uint8Array(item);
  553. }
  554. }
  555. itemLength = item.byteLength;
  556. data.set(item, pos);
  557. pos += itemLength;
  558. }
  559. return data;
  560. }
  561. function string32(value) {
  562. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  563. }
  564. function log2(x) {
  565. var n = 1, i = 0;
  566. while (x > n) {
  567. n <<= 1;
  568. i++;
  569. }
  570. return i;
  571. }
  572. function readInt8(data, start) {
  573. return data[start] << 24 >> 24;
  574. }
  575. function readUint16(data, offset) {
  576. return data[offset] << 8 | data[offset + 1];
  577. }
  578. function readUint32(data, offset) {
  579. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  580. }
  581. function isLittleEndian() {
  582. var buffer8 = new Uint8Array(2);
  583. buffer8[0] = 1;
  584. var buffer16 = new Uint16Array(buffer8.buffer);
  585. return buffer16[0] === 1;
  586. }
  587. function isEvalSupported() {
  588. try {
  589. new Function('');
  590. return true;
  591. } catch (e) {
  592. return false;
  593. }
  594. }
  595. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  596. function Uint32ArrayView(buffer, length) {
  597. this.buffer = buffer;
  598. this.byteLength = buffer.length;
  599. this.length = length === undefined ? this.byteLength >> 2 : length;
  600. ensureUint32ArrayViewProps(this.length);
  601. }
  602. Uint32ArrayView.prototype = Object.create(null);
  603. var uint32ArrayViewSetters = 0;
  604. function createUint32ArrayProp(index) {
  605. return {
  606. get: function () {
  607. var buffer = this.buffer, offset = index << 2;
  608. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  609. },
  610. set: function (value) {
  611. var buffer = this.buffer, offset = index << 2;
  612. buffer[offset] = value & 255;
  613. buffer[offset + 1] = value >> 8 & 255;
  614. buffer[offset + 2] = value >> 16 & 255;
  615. buffer[offset + 3] = value >>> 24 & 255;
  616. }
  617. };
  618. }
  619. function ensureUint32ArrayViewProps(length) {
  620. while (uint32ArrayViewSetters < length) {
  621. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  622. uint32ArrayViewSetters++;
  623. }
  624. }
  625. return Uint32ArrayView;
  626. }();
  627. exports.Uint32ArrayView = Uint32ArrayView;
  628. var IDENTITY_MATRIX = [
  629. 1,
  630. 0,
  631. 0,
  632. 1,
  633. 0,
  634. 0
  635. ];
  636. var Util = function UtilClosure() {
  637. function Util() {
  638. }
  639. var rgbBuf = [
  640. 'rgb(',
  641. 0,
  642. ',',
  643. 0,
  644. ',',
  645. 0,
  646. ')'
  647. ];
  648. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  649. rgbBuf[1] = r;
  650. rgbBuf[3] = g;
  651. rgbBuf[5] = b;
  652. return rgbBuf.join('');
  653. };
  654. Util.transform = function Util_transform(m1, m2) {
  655. return [
  656. m1[0] * m2[0] + m1[2] * m2[1],
  657. m1[1] * m2[0] + m1[3] * m2[1],
  658. m1[0] * m2[2] + m1[2] * m2[3],
  659. m1[1] * m2[2] + m1[3] * m2[3],
  660. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  661. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  662. ];
  663. };
  664. Util.applyTransform = function Util_applyTransform(p, m) {
  665. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  666. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  667. return [
  668. xt,
  669. yt
  670. ];
  671. };
  672. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  673. var d = m[0] * m[3] - m[1] * m[2];
  674. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  675. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  676. return [
  677. xt,
  678. yt
  679. ];
  680. };
  681. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  682. var p1 = Util.applyTransform(r, m);
  683. var p2 = Util.applyTransform(r.slice(2, 4), m);
  684. var p3 = Util.applyTransform([
  685. r[0],
  686. r[3]
  687. ], m);
  688. var p4 = Util.applyTransform([
  689. r[2],
  690. r[1]
  691. ], m);
  692. return [
  693. Math.min(p1[0], p2[0], p3[0], p4[0]),
  694. Math.min(p1[1], p2[1], p3[1], p4[1]),
  695. Math.max(p1[0], p2[0], p3[0], p4[0]),
  696. Math.max(p1[1], p2[1], p3[1], p4[1])
  697. ];
  698. };
  699. Util.inverseTransform = function Util_inverseTransform(m) {
  700. var d = m[0] * m[3] - m[1] * m[2];
  701. return [
  702. m[3] / d,
  703. -m[1] / d,
  704. -m[2] / d,
  705. m[0] / d,
  706. (m[2] * m[5] - m[4] * m[3]) / d,
  707. (m[4] * m[1] - m[5] * m[0]) / d
  708. ];
  709. };
  710. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  711. return [
  712. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  713. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  714. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  715. ];
  716. };
  717. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  718. var transpose = [
  719. m[0],
  720. m[2],
  721. m[1],
  722. m[3]
  723. ];
  724. var a = m[0] * transpose[0] + m[1] * transpose[2];
  725. var b = m[0] * transpose[1] + m[1] * transpose[3];
  726. var c = m[2] * transpose[0] + m[3] * transpose[2];
  727. var d = m[2] * transpose[1] + m[3] * transpose[3];
  728. var first = (a + d) / 2;
  729. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  730. var sx = first + second || 1;
  731. var sy = first - second || 1;
  732. return [
  733. Math.sqrt(sx),
  734. Math.sqrt(sy)
  735. ];
  736. };
  737. Util.normalizeRect = function Util_normalizeRect(rect) {
  738. var r = rect.slice(0);
  739. if (rect[0] > rect[2]) {
  740. r[0] = rect[2];
  741. r[2] = rect[0];
  742. }
  743. if (rect[1] > rect[3]) {
  744. r[1] = rect[3];
  745. r[3] = rect[1];
  746. }
  747. return r;
  748. };
  749. Util.intersect = function Util_intersect(rect1, rect2) {
  750. function compare(a, b) {
  751. return a - b;
  752. }
  753. var orderedX = [
  754. rect1[0],
  755. rect1[2],
  756. rect2[0],
  757. rect2[2]
  758. ].sort(compare), orderedY = [
  759. rect1[1],
  760. rect1[3],
  761. rect2[1],
  762. rect2[3]
  763. ].sort(compare), result = [];
  764. rect1 = Util.normalizeRect(rect1);
  765. rect2 = Util.normalizeRect(rect2);
  766. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  767. result[0] = orderedX[1];
  768. result[2] = orderedX[2];
  769. } else {
  770. return false;
  771. }
  772. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  773. result[1] = orderedY[1];
  774. result[3] = orderedY[2];
  775. } else {
  776. return false;
  777. }
  778. return result;
  779. };
  780. Util.sign = function Util_sign(num) {
  781. return num < 0 ? -1 : 1;
  782. };
  783. var ROMAN_NUMBER_MAP = [
  784. '',
  785. 'C',
  786. 'CC',
  787. 'CCC',
  788. 'CD',
  789. 'D',
  790. 'DC',
  791. 'DCC',
  792. 'DCCC',
  793. 'CM',
  794. '',
  795. 'X',
  796. 'XX',
  797. 'XXX',
  798. 'XL',
  799. 'L',
  800. 'LX',
  801. 'LXX',
  802. 'LXXX',
  803. 'XC',
  804. '',
  805. 'I',
  806. 'II',
  807. 'III',
  808. 'IV',
  809. 'V',
  810. 'VI',
  811. 'VII',
  812. 'VIII',
  813. 'IX'
  814. ];
  815. Util.toRoman = function Util_toRoman(number, lowerCase) {
  816. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  817. var pos, romanBuf = [];
  818. while (number >= 1000) {
  819. number -= 1000;
  820. romanBuf.push('M');
  821. }
  822. pos = number / 100 | 0;
  823. number %= 100;
  824. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  825. pos = number / 10 | 0;
  826. number %= 10;
  827. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  828. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  829. var romanStr = romanBuf.join('');
  830. return lowerCase ? romanStr.toLowerCase() : romanStr;
  831. };
  832. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  833. Array.prototype.push.apply(arr1, arr2);
  834. };
  835. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  836. Array.prototype.unshift.apply(arr1, arr2);
  837. };
  838. Util.extendObj = function extendObj(obj1, obj2) {
  839. for (var key in obj2) {
  840. obj1[key] = obj2[key];
  841. }
  842. };
  843. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  844. while (dict && !dict.has(name)) {
  845. dict = dict.get('Parent');
  846. }
  847. if (!dict) {
  848. return null;
  849. }
  850. return getArray ? dict.getArray(name) : dict.get(name);
  851. };
  852. Util.inherit = function Util_inherit(sub, base, prototype) {
  853. sub.prototype = Object.create(base.prototype);
  854. sub.prototype.constructor = sub;
  855. for (var prop in prototype) {
  856. sub.prototype[prop] = prototype[prop];
  857. }
  858. };
  859. Util.loadScript = function Util_loadScript(src, callback) {
  860. var script = document.createElement('script');
  861. var loaded = false;
  862. script.setAttribute('src', src);
  863. if (callback) {
  864. script.onload = function () {
  865. if (!loaded) {
  866. callback();
  867. }
  868. loaded = true;
  869. };
  870. }
  871. document.getElementsByTagName('head')[0].appendChild(script);
  872. };
  873. return Util;
  874. }();
  875. var PageViewport = function PageViewportClosure() {
  876. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  877. this.viewBox = viewBox;
  878. this.scale = scale;
  879. this.rotation = rotation;
  880. this.offsetX = offsetX;
  881. this.offsetY = offsetY;
  882. var centerX = (viewBox[2] + viewBox[0]) / 2;
  883. var centerY = (viewBox[3] + viewBox[1]) / 2;
  884. var rotateA, rotateB, rotateC, rotateD;
  885. rotation = rotation % 360;
  886. rotation = rotation < 0 ? rotation + 360 : rotation;
  887. switch (rotation) {
  888. case 180:
  889. rotateA = -1;
  890. rotateB = 0;
  891. rotateC = 0;
  892. rotateD = 1;
  893. break;
  894. case 90:
  895. rotateA = 0;
  896. rotateB = 1;
  897. rotateC = 1;
  898. rotateD = 0;
  899. break;
  900. case 270:
  901. rotateA = 0;
  902. rotateB = -1;
  903. rotateC = -1;
  904. rotateD = 0;
  905. break;
  906. default:
  907. rotateA = 1;
  908. rotateB = 0;
  909. rotateC = 0;
  910. rotateD = -1;
  911. break;
  912. }
  913. if (dontFlip) {
  914. rotateC = -rotateC;
  915. rotateD = -rotateD;
  916. }
  917. var offsetCanvasX, offsetCanvasY;
  918. var width, height;
  919. if (rotateA === 0) {
  920. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  921. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  922. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  923. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  924. } else {
  925. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  926. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  927. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  928. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  929. }
  930. this.transform = [
  931. rotateA * scale,
  932. rotateB * scale,
  933. rotateC * scale,
  934. rotateD * scale,
  935. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  936. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  937. ];
  938. this.width = width;
  939. this.height = height;
  940. this.fontScale = scale;
  941. }
  942. PageViewport.prototype = {
  943. clone: function PageViewPort_clone(args) {
  944. args = args || {};
  945. var scale = 'scale' in args ? args.scale : this.scale;
  946. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  947. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  948. },
  949. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  950. return Util.applyTransform([
  951. x,
  952. y
  953. ], this.transform);
  954. },
  955. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  956. var tl = Util.applyTransform([
  957. rect[0],
  958. rect[1]
  959. ], this.transform);
  960. var br = Util.applyTransform([
  961. rect[2],
  962. rect[3]
  963. ], this.transform);
  964. return [
  965. tl[0],
  966. tl[1],
  967. br[0],
  968. br[1]
  969. ];
  970. },
  971. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  972. return Util.applyInverseTransform([
  973. x,
  974. y
  975. ], this.transform);
  976. }
  977. };
  978. return PageViewport;
  979. }();
  980. var PDFStringTranslateTable = [
  981. 0,
  982. 0,
  983. 0,
  984. 0,
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0,
  993. 0,
  994. 0,
  995. 0,
  996. 0,
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0x2D8,
  1006. 0x2C7,
  1007. 0x2C6,
  1008. 0x2D9,
  1009. 0x2DD,
  1010. 0x2DB,
  1011. 0x2DA,
  1012. 0x2DC,
  1013. 0,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0,
  1022. 0,
  1023. 0,
  1024. 0,
  1025. 0,
  1026. 0,
  1027. 0,
  1028. 0,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0x2022,
  1110. 0x2020,
  1111. 0x2021,
  1112. 0x2026,
  1113. 0x2014,
  1114. 0x2013,
  1115. 0x192,
  1116. 0x2044,
  1117. 0x2039,
  1118. 0x203A,
  1119. 0x2212,
  1120. 0x2030,
  1121. 0x201E,
  1122. 0x201C,
  1123. 0x201D,
  1124. 0x2018,
  1125. 0x2019,
  1126. 0x201A,
  1127. 0x2122,
  1128. 0xFB01,
  1129. 0xFB02,
  1130. 0x141,
  1131. 0x152,
  1132. 0x160,
  1133. 0x178,
  1134. 0x17D,
  1135. 0x131,
  1136. 0x142,
  1137. 0x153,
  1138. 0x161,
  1139. 0x17E,
  1140. 0,
  1141. 0x20AC
  1142. ];
  1143. function stringToPDFString(str) {
  1144. var i, n = str.length, strBuf = [];
  1145. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1146. for (i = 2; i < n; i += 2) {
  1147. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1148. }
  1149. } else {
  1150. for (i = 0; i < n; ++i) {
  1151. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1152. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1153. }
  1154. }
  1155. return strBuf.join('');
  1156. }
  1157. function stringToUTF8String(str) {
  1158. return decodeURIComponent(escape(str));
  1159. }
  1160. function utf8StringToString(str) {
  1161. return unescape(encodeURIComponent(str));
  1162. }
  1163. function isEmptyObj(obj) {
  1164. for (var key in obj) {
  1165. return false;
  1166. }
  1167. return true;
  1168. }
  1169. function isBool(v) {
  1170. return typeof v === 'boolean';
  1171. }
  1172. function isInt(v) {
  1173. return typeof v === 'number' && (v | 0) === v;
  1174. }
  1175. function isNum(v) {
  1176. return typeof v === 'number';
  1177. }
  1178. function isString(v) {
  1179. return typeof v === 'string';
  1180. }
  1181. function isArray(v) {
  1182. return v instanceof Array;
  1183. }
  1184. function isArrayBuffer(v) {
  1185. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1186. }
  1187. function isSpace(ch) {
  1188. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1189. }
  1190. function createPromiseCapability() {
  1191. var capability = {};
  1192. capability.promise = new Promise(function (resolve, reject) {
  1193. capability.resolve = resolve;
  1194. capability.reject = reject;
  1195. });
  1196. return capability;
  1197. }
  1198. (function PromiseClosure() {
  1199. if (globalScope.Promise) {
  1200. if (typeof globalScope.Promise.all !== 'function') {
  1201. globalScope.Promise.all = function (iterable) {
  1202. var count = 0, results = [], resolve, reject;
  1203. var promise = new globalScope.Promise(function (resolve_, reject_) {
  1204. resolve = resolve_;
  1205. reject = reject_;
  1206. });
  1207. iterable.forEach(function (p, i) {
  1208. count++;
  1209. p.then(function (result) {
  1210. results[i] = result;
  1211. count--;
  1212. if (count === 0) {
  1213. resolve(results);
  1214. }
  1215. }, reject);
  1216. });
  1217. if (count === 0) {
  1218. resolve(results);
  1219. }
  1220. return promise;
  1221. };
  1222. }
  1223. if (typeof globalScope.Promise.resolve !== 'function') {
  1224. globalScope.Promise.resolve = function (value) {
  1225. return new globalScope.Promise(function (resolve) {
  1226. resolve(value);
  1227. });
  1228. };
  1229. }
  1230. if (typeof globalScope.Promise.reject !== 'function') {
  1231. globalScope.Promise.reject = function (reason) {
  1232. return new globalScope.Promise(function (resolve, reject) {
  1233. reject(reason);
  1234. });
  1235. };
  1236. }
  1237. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  1238. globalScope.Promise.prototype.catch = function (onReject) {
  1239. return globalScope.Promise.prototype.then(undefined, onReject);
  1240. };
  1241. }
  1242. return;
  1243. }
  1244. var STATUS_PENDING = 0;
  1245. var STATUS_RESOLVED = 1;
  1246. var STATUS_REJECTED = 2;
  1247. var REJECTION_TIMEOUT = 500;
  1248. var HandlerManager = {
  1249. handlers: [],
  1250. running: false,
  1251. unhandledRejections: [],
  1252. pendingRejectionCheck: false,
  1253. scheduleHandlers: function scheduleHandlers(promise) {
  1254. if (promise._status === STATUS_PENDING) {
  1255. return;
  1256. }
  1257. this.handlers = this.handlers.concat(promise._handlers);
  1258. promise._handlers = [];
  1259. if (this.running) {
  1260. return;
  1261. }
  1262. this.running = true;
  1263. setTimeout(this.runHandlers.bind(this), 0);
  1264. },
  1265. runHandlers: function runHandlers() {
  1266. var RUN_TIMEOUT = 1;
  1267. var timeoutAt = Date.now() + RUN_TIMEOUT;
  1268. while (this.handlers.length > 0) {
  1269. var handler = this.handlers.shift();
  1270. var nextStatus = handler.thisPromise._status;
  1271. var nextValue = handler.thisPromise._value;
  1272. try {
  1273. if (nextStatus === STATUS_RESOLVED) {
  1274. if (typeof handler.onResolve === 'function') {
  1275. nextValue = handler.onResolve(nextValue);
  1276. }
  1277. } else if (typeof handler.onReject === 'function') {
  1278. nextValue = handler.onReject(nextValue);
  1279. nextStatus = STATUS_RESOLVED;
  1280. if (handler.thisPromise._unhandledRejection) {
  1281. this.removeUnhandeledRejection(handler.thisPromise);
  1282. }
  1283. }
  1284. } catch (ex) {
  1285. nextStatus = STATUS_REJECTED;
  1286. nextValue = ex;
  1287. }
  1288. handler.nextPromise._updateStatus(nextStatus, nextValue);
  1289. if (Date.now() >= timeoutAt) {
  1290. break;
  1291. }
  1292. }
  1293. if (this.handlers.length > 0) {
  1294. setTimeout(this.runHandlers.bind(this), 0);
  1295. return;
  1296. }
  1297. this.running = false;
  1298. },
  1299. addUnhandledRejection: function addUnhandledRejection(promise) {
  1300. this.unhandledRejections.push({
  1301. promise: promise,
  1302. time: Date.now()
  1303. });
  1304. this.scheduleRejectionCheck();
  1305. },
  1306. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  1307. promise._unhandledRejection = false;
  1308. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1309. if (this.unhandledRejections[i].promise === promise) {
  1310. this.unhandledRejections.splice(i);
  1311. i--;
  1312. }
  1313. }
  1314. },
  1315. scheduleRejectionCheck: function scheduleRejectionCheck() {
  1316. if (this.pendingRejectionCheck) {
  1317. return;
  1318. }
  1319. this.pendingRejectionCheck = true;
  1320. setTimeout(function rejectionCheck() {
  1321. this.pendingRejectionCheck = false;
  1322. var now = Date.now();
  1323. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1324. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  1325. var unhandled = this.unhandledRejections[i].promise._value;
  1326. var msg = 'Unhandled rejection: ' + unhandled;
  1327. if (unhandled.stack) {
  1328. msg += '\n' + unhandled.stack;
  1329. }
  1330. warn(msg);
  1331. this.unhandledRejections.splice(i);
  1332. i--;
  1333. }
  1334. }
  1335. if (this.unhandledRejections.length) {
  1336. this.scheduleRejectionCheck();
  1337. }
  1338. }.bind(this), REJECTION_TIMEOUT);
  1339. }
  1340. };
  1341. var Promise = function Promise(resolver) {
  1342. this._status = STATUS_PENDING;
  1343. this._handlers = [];
  1344. try {
  1345. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  1346. } catch (e) {
  1347. this._reject(e);
  1348. }
  1349. };
  1350. Promise.all = function Promise_all(promises) {
  1351. var resolveAll, rejectAll;
  1352. var deferred = new Promise(function (resolve, reject) {
  1353. resolveAll = resolve;
  1354. rejectAll = reject;
  1355. });
  1356. var unresolved = promises.length;
  1357. var results = [];
  1358. if (unresolved === 0) {
  1359. resolveAll(results);
  1360. return deferred;
  1361. }
  1362. function reject(reason) {
  1363. if (deferred._status === STATUS_REJECTED) {
  1364. return;
  1365. }
  1366. results = [];
  1367. rejectAll(reason);
  1368. }
  1369. for (var i = 0, ii = promises.length; i < ii; ++i) {
  1370. var promise = promises[i];
  1371. var resolve = function (i) {
  1372. return function (value) {
  1373. if (deferred._status === STATUS_REJECTED) {
  1374. return;
  1375. }
  1376. results[i] = value;
  1377. unresolved--;
  1378. if (unresolved === 0) {
  1379. resolveAll(results);
  1380. }
  1381. };
  1382. }(i);
  1383. if (Promise.isPromise(promise)) {
  1384. promise.then(resolve, reject);
  1385. } else {
  1386. resolve(promise);
  1387. }
  1388. }
  1389. return deferred;
  1390. };
  1391. Promise.isPromise = function Promise_isPromise(value) {
  1392. return value && typeof value.then === 'function';
  1393. };
  1394. Promise.resolve = function Promise_resolve(value) {
  1395. return new Promise(function (resolve) {
  1396. resolve(value);
  1397. });
  1398. };
  1399. Promise.reject = function Promise_reject(reason) {
  1400. return new Promise(function (resolve, reject) {
  1401. reject(reason);
  1402. });
  1403. };
  1404. Promise.prototype = {
  1405. _status: null,
  1406. _value: null,
  1407. _handlers: null,
  1408. _unhandledRejection: null,
  1409. _updateStatus: function Promise__updateStatus(status, value) {
  1410. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  1411. return;
  1412. }
  1413. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  1414. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  1415. return;
  1416. }
  1417. this._status = status;
  1418. this._value = value;
  1419. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  1420. this._unhandledRejection = true;
  1421. HandlerManager.addUnhandledRejection(this);
  1422. }
  1423. HandlerManager.scheduleHandlers(this);
  1424. },
  1425. _resolve: function Promise_resolve(value) {
  1426. this._updateStatus(STATUS_RESOLVED, value);
  1427. },
  1428. _reject: function Promise_reject(reason) {
  1429. this._updateStatus(STATUS_REJECTED, reason);
  1430. },
  1431. then: function Promise_then(onResolve, onReject) {
  1432. var nextPromise = new Promise(function (resolve, reject) {
  1433. this.resolve = resolve;
  1434. this.reject = reject;
  1435. });
  1436. this._handlers.push({
  1437. thisPromise: this,
  1438. onResolve: onResolve,
  1439. onReject: onReject,
  1440. nextPromise: nextPromise
  1441. });
  1442. HandlerManager.scheduleHandlers(this);
  1443. return nextPromise;
  1444. },
  1445. catch: function Promise_catch(onReject) {
  1446. return this.then(undefined, onReject);
  1447. }
  1448. };
  1449. globalScope.Promise = Promise;
  1450. }());
  1451. (function WeakMapClosure() {
  1452. if (globalScope.WeakMap) {
  1453. return;
  1454. }
  1455. var id = 0;
  1456. function WeakMap() {
  1457. this.id = '$weakmap' + id++;
  1458. }
  1459. WeakMap.prototype = {
  1460. has: function (obj) {
  1461. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  1462. },
  1463. get: function (obj, defaultValue) {
  1464. return this.has(obj) ? obj[this.id] : defaultValue;
  1465. },
  1466. set: function (obj, value) {
  1467. Object.defineProperty(obj, this.id, {
  1468. value: value,
  1469. enumerable: false,
  1470. configurable: true
  1471. });
  1472. },
  1473. delete: function (obj) {
  1474. delete obj[this.id];
  1475. }
  1476. };
  1477. globalScope.WeakMap = WeakMap;
  1478. }());
  1479. var StatTimer = function StatTimerClosure() {
  1480. function rpad(str, pad, length) {
  1481. while (str.length < length) {
  1482. str += pad;
  1483. }
  1484. return str;
  1485. }
  1486. function StatTimer() {
  1487. this.started = Object.create(null);
  1488. this.times = [];
  1489. this.enabled = true;
  1490. }
  1491. StatTimer.prototype = {
  1492. time: function StatTimer_time(name) {
  1493. if (!this.enabled) {
  1494. return;
  1495. }
  1496. if (name in this.started) {
  1497. warn('Timer is already running for ' + name);
  1498. }
  1499. this.started[name] = Date.now();
  1500. },
  1501. timeEnd: function StatTimer_timeEnd(name) {
  1502. if (!this.enabled) {
  1503. return;
  1504. }
  1505. if (!(name in this.started)) {
  1506. warn('Timer has not been started for ' + name);
  1507. }
  1508. this.times.push({
  1509. 'name': name,
  1510. 'start': this.started[name],
  1511. 'end': Date.now()
  1512. });
  1513. delete this.started[name];
  1514. },
  1515. toString: function StatTimer_toString() {
  1516. var i, ii;
  1517. var times = this.times;
  1518. var out = '';
  1519. var longest = 0;
  1520. for (i = 0, ii = times.length; i < ii; ++i) {
  1521. var name = times[i]['name'];
  1522. if (name.length > longest) {
  1523. longest = name.length;
  1524. }
  1525. }
  1526. for (i = 0, ii = times.length; i < ii; ++i) {
  1527. var span = times[i];
  1528. var duration = span.end - span.start;
  1529. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1530. }
  1531. return out;
  1532. }
  1533. };
  1534. return StatTimer;
  1535. }();
  1536. var createBlob = function createBlob(data, contentType) {
  1537. if (typeof Blob !== 'undefined') {
  1538. return new Blob([data], { type: contentType });
  1539. }
  1540. warn('The "Blob" constructor is not supported.');
  1541. };
  1542. var createObjectURL = function createObjectURLClosure() {
  1543. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1544. return function createObjectURL(data, contentType, forceDataSchema) {
  1545. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1546. var blob = createBlob(data, contentType);
  1547. return URL.createObjectURL(blob);
  1548. }
  1549. var buffer = 'data:' + contentType + ';base64,';
  1550. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1551. var b1 = data[i] & 0xFF;
  1552. var b2 = data[i + 1] & 0xFF;
  1553. var b3 = data[i + 2] & 0xFF;
  1554. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1555. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1556. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1557. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1558. }
  1559. return buffer;
  1560. };
  1561. }();
  1562. function MessageHandler(sourceName, targetName, comObj) {
  1563. this.sourceName = sourceName;
  1564. this.targetName = targetName;
  1565. this.comObj = comObj;
  1566. this.callbackIndex = 1;
  1567. this.postMessageTransfers = true;
  1568. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1569. var ah = this.actionHandler = Object.create(null);
  1570. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1571. var data = event.data;
  1572. if (data.targetName !== this.sourceName) {
  1573. return;
  1574. }
  1575. if (data.isReply) {
  1576. var callbackId = data.callbackId;
  1577. if (data.callbackId in callbacksCapabilities) {
  1578. var callback = callbacksCapabilities[callbackId];
  1579. delete callbacksCapabilities[callbackId];
  1580. if ('error' in data) {
  1581. callback.reject(data.error);
  1582. } else {
  1583. callback.resolve(data.data);
  1584. }
  1585. } else {
  1586. error('Cannot resolve callback ' + callbackId);
  1587. }
  1588. } else if (data.action in ah) {
  1589. var action = ah[data.action];
  1590. if (data.callbackId) {
  1591. var sourceName = this.sourceName;
  1592. var targetName = data.sourceName;
  1593. Promise.resolve().then(function () {
  1594. return action[0].call(action[1], data.data);
  1595. }).then(function (result) {
  1596. comObj.postMessage({
  1597. sourceName: sourceName,
  1598. targetName: targetName,
  1599. isReply: true,
  1600. callbackId: data.callbackId,
  1601. data: result
  1602. });
  1603. }, function (reason) {
  1604. if (reason instanceof Error) {
  1605. reason = reason + '';
  1606. }
  1607. comObj.postMessage({
  1608. sourceName: sourceName,
  1609. targetName: targetName,
  1610. isReply: true,
  1611. callbackId: data.callbackId,
  1612. error: reason
  1613. });
  1614. });
  1615. } else {
  1616. action[0].call(action[1], data.data);
  1617. }
  1618. } else {
  1619. error('Unknown action from worker: ' + data.action);
  1620. }
  1621. }.bind(this);
  1622. comObj.addEventListener('message', this._onComObjOnMessage);
  1623. }
  1624. MessageHandler.prototype = {
  1625. on: function messageHandlerOn(actionName, handler, scope) {
  1626. var ah = this.actionHandler;
  1627. if (ah[actionName]) {
  1628. error('There is already an actionName called "' + actionName + '"');
  1629. }
  1630. ah[actionName] = [
  1631. handler,
  1632. scope
  1633. ];
  1634. },
  1635. send: function messageHandlerSend(actionName, data, transfers) {
  1636. var message = {
  1637. sourceName: this.sourceName,
  1638. targetName: this.targetName,
  1639. action: actionName,
  1640. data: data
  1641. };
  1642. this.postMessage(message, transfers);
  1643. },
  1644. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1645. var callbackId = this.callbackIndex++;
  1646. var message = {
  1647. sourceName: this.sourceName,
  1648. targetName: this.targetName,
  1649. action: actionName,
  1650. data: data,
  1651. callbackId: callbackId
  1652. };
  1653. var capability = createPromiseCapability();
  1654. this.callbacksCapabilities[callbackId] = capability;
  1655. try {
  1656. this.postMessage(message, transfers);
  1657. } catch (e) {
  1658. capability.reject(e);
  1659. }
  1660. return capability.promise;
  1661. },
  1662. postMessage: function (message, transfers) {
  1663. if (transfers && this.postMessageTransfers) {
  1664. this.comObj.postMessage(message, transfers);
  1665. } else {
  1666. this.comObj.postMessage(message);
  1667. }
  1668. },
  1669. destroy: function () {
  1670. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1671. }
  1672. };
  1673. function loadJpegStream(id, imageUrl, objs) {
  1674. var img = new Image();
  1675. img.onload = function loadJpegStream_onloadClosure() {
  1676. objs.resolve(id, img);
  1677. };
  1678. img.onerror = function loadJpegStream_onerrorClosure() {
  1679. objs.resolve(id, null);
  1680. warn('Error during JPEG image loading');
  1681. };
  1682. img.src = imageUrl;
  1683. }
  1684. (function checkURLConstructor(scope) {
  1685. var hasWorkingUrl = false;
  1686. try {
  1687. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  1688. var u = new URL('b', 'http://a');
  1689. u.pathname = 'c%20d';
  1690. hasWorkingUrl = u.href === 'http://a/c%20d';
  1691. }
  1692. } catch (e) {
  1693. }
  1694. if (hasWorkingUrl) {
  1695. return;
  1696. }
  1697. var relative = Object.create(null);
  1698. relative['ftp'] = 21;
  1699. relative['file'] = 0;
  1700. relative['gopher'] = 70;
  1701. relative['http'] = 80;
  1702. relative['https'] = 443;
  1703. relative['ws'] = 80;
  1704. relative['wss'] = 443;
  1705. var relativePathDotMapping = Object.create(null);
  1706. relativePathDotMapping['%2e'] = '.';
  1707. relativePathDotMapping['.%2e'] = '..';
  1708. relativePathDotMapping['%2e.'] = '..';
  1709. relativePathDotMapping['%2e%2e'] = '..';
  1710. function isRelativeScheme(scheme) {
  1711. return relative[scheme] !== undefined;
  1712. }
  1713. function invalid() {
  1714. clear.call(this);
  1715. this._isInvalid = true;
  1716. }
  1717. function IDNAToASCII(h) {
  1718. if (h === '') {
  1719. invalid.call(this);
  1720. }
  1721. return h.toLowerCase();
  1722. }
  1723. function percentEscape(c) {
  1724. var unicode = c.charCodeAt(0);
  1725. if (unicode > 0x20 && unicode < 0x7F && [
  1726. 0x22,
  1727. 0x23,
  1728. 0x3C,
  1729. 0x3E,
  1730. 0x3F,
  1731. 0x60
  1732. ].indexOf(unicode) === -1) {
  1733. return c;
  1734. }
  1735. return encodeURIComponent(c);
  1736. }
  1737. function percentEscapeQuery(c) {
  1738. var unicode = c.charCodeAt(0);
  1739. if (unicode > 0x20 && unicode < 0x7F && [
  1740. 0x22,
  1741. 0x23,
  1742. 0x3C,
  1743. 0x3E,
  1744. 0x60
  1745. ].indexOf(unicode) === -1) {
  1746. return c;
  1747. }
  1748. return encodeURIComponent(c);
  1749. }
  1750. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  1751. function parse(input, stateOverride, base) {
  1752. function err(message) {
  1753. errors.push(message);
  1754. }
  1755. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  1756. loop:
  1757. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  1758. var c = input[cursor];
  1759. switch (state) {
  1760. case 'scheme start':
  1761. if (c && ALPHA.test(c)) {
  1762. buffer += c.toLowerCase();
  1763. state = 'scheme';
  1764. } else if (!stateOverride) {
  1765. buffer = '';
  1766. state = 'no scheme';
  1767. continue;
  1768. } else {
  1769. err('Invalid scheme.');
  1770. break loop;
  1771. }
  1772. break;
  1773. case 'scheme':
  1774. if (c && ALPHANUMERIC.test(c)) {
  1775. buffer += c.toLowerCase();
  1776. } else if (c === ':') {
  1777. this._scheme = buffer;
  1778. buffer = '';
  1779. if (stateOverride) {
  1780. break loop;
  1781. }
  1782. if (isRelativeScheme(this._scheme)) {
  1783. this._isRelative = true;
  1784. }
  1785. if (this._scheme === 'file') {
  1786. state = 'relative';
  1787. } else if (this._isRelative && base && base._scheme === this._scheme) {
  1788. state = 'relative or authority';
  1789. } else if (this._isRelative) {
  1790. state = 'authority first slash';
  1791. } else {
  1792. state = 'scheme data';
  1793. }
  1794. } else if (!stateOverride) {
  1795. buffer = '';
  1796. cursor = 0;
  1797. state = 'no scheme';
  1798. continue;
  1799. } else if (EOF === c) {
  1800. break loop;
  1801. } else {
  1802. err('Code point not allowed in scheme: ' + c);
  1803. break loop;
  1804. }
  1805. break;
  1806. case 'scheme data':
  1807. if (c === '?') {
  1808. this._query = '?';
  1809. state = 'query';
  1810. } else if (c === '#') {
  1811. this._fragment = '#';
  1812. state = 'fragment';
  1813. } else {
  1814. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  1815. this._schemeData += percentEscape(c);
  1816. }
  1817. }
  1818. break;
  1819. case 'no scheme':
  1820. if (!base || !isRelativeScheme(base._scheme)) {
  1821. err('Missing scheme.');
  1822. invalid.call(this);
  1823. } else {
  1824. state = 'relative';
  1825. continue;
  1826. }
  1827. break;
  1828. case 'relative or authority':
  1829. if (c === '/' && input[cursor + 1] === '/') {
  1830. state = 'authority ignore slashes';
  1831. } else {
  1832. err('Expected /, got: ' + c);
  1833. state = 'relative';
  1834. continue;
  1835. }
  1836. break;
  1837. case 'relative':
  1838. this._isRelative = true;
  1839. if ('file' !== this._scheme) {
  1840. this._scheme = base._scheme;
  1841. }
  1842. if (EOF === c) {
  1843. this._host = base._host;
  1844. this._port = base._port;
  1845. this._path = base._path.slice();
  1846. this._query = base._query;
  1847. this._username = base._username;
  1848. this._password = base._password;
  1849. break loop;
  1850. } else if (c === '/' || c === '\\') {
  1851. if (c === '\\') {
  1852. err('\\ is an invalid code point.');
  1853. }
  1854. state = 'relative slash';
  1855. } else if (c === '?') {
  1856. this._host = base._host;
  1857. this._port = base._port;
  1858. this._path = base._path.slice();
  1859. this._query = '?';
  1860. this._username = base._username;
  1861. this._password = base._password;
  1862. state = 'query';
  1863. } else if (c === '#') {
  1864. this._host = base._host;
  1865. this._port = base._port;
  1866. this._path = base._path.slice();
  1867. this._query = base._query;
  1868. this._fragment = '#';
  1869. this._username = base._username;
  1870. this._password = base._password;
  1871. state = 'fragment';
  1872. } else {
  1873. var nextC = input[cursor + 1];
  1874. var nextNextC = input[cursor + 2];
  1875. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  1876. this._host = base._host;
  1877. this._port = base._port;
  1878. this._username = base._username;
  1879. this._password = base._password;
  1880. this._path = base._path.slice();
  1881. this._path.pop();
  1882. }
  1883. state = 'relative path';
  1884. continue;
  1885. }
  1886. break;
  1887. case 'relative slash':
  1888. if (c === '/' || c === '\\') {
  1889. if (c === '\\') {
  1890. err('\\ is an invalid code point.');
  1891. }
  1892. if (this._scheme === 'file') {
  1893. state = 'file host';
  1894. } else {
  1895. state = 'authority ignore slashes';
  1896. }
  1897. } else {
  1898. if ('file' !== this._scheme) {
  1899. this._host = base._host;
  1900. this._port = base._port;
  1901. this._username = base._username;
  1902. this._password = base._password;
  1903. }
  1904. state = 'relative path';
  1905. continue;
  1906. }
  1907. break;
  1908. case 'authority first slash':
  1909. if (c === '/') {
  1910. state = 'authority second slash';
  1911. } else {
  1912. err('Expected \'/\', got: ' + c);
  1913. state = 'authority ignore slashes';
  1914. continue;
  1915. }
  1916. break;
  1917. case 'authority second slash':
  1918. state = 'authority ignore slashes';
  1919. if ('/' !== c) {
  1920. err('Expected \'/\', got: ' + c);
  1921. continue;
  1922. }
  1923. break;
  1924. case 'authority ignore slashes':
  1925. if ('/' !== c && '\\' !== c) {
  1926. state = 'authority';
  1927. continue;
  1928. } else {
  1929. err('Expected authority, got: ' + c);
  1930. }
  1931. break;
  1932. case 'authority':
  1933. if (c === '@') {
  1934. if (seenAt) {
  1935. err('@ already seen.');
  1936. buffer += '%40';
  1937. }
  1938. seenAt = true;
  1939. for (var i = 0; i < buffer.length; i++) {
  1940. var cp = buffer[i];
  1941. if (cp === '\t' || cp === '\n' || cp === '\r') {
  1942. err('Invalid whitespace in authority.');
  1943. continue;
  1944. }
  1945. if (cp === ':' && this._password === null) {
  1946. this._password = '';
  1947. continue;
  1948. }
  1949. var tempC = percentEscape(cp);
  1950. if (null !== this._password) {
  1951. this._password += tempC;
  1952. } else {
  1953. this._username += tempC;
  1954. }
  1955. }
  1956. buffer = '';
  1957. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1958. cursor -= buffer.length;
  1959. buffer = '';
  1960. state = 'host';
  1961. continue;
  1962. } else {
  1963. buffer += c;
  1964. }
  1965. break;
  1966. case 'file host':
  1967. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1968. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  1969. state = 'relative path';
  1970. } else if (buffer.length === 0) {
  1971. state = 'relative path start';
  1972. } else {
  1973. this._host = IDNAToASCII.call(this, buffer);
  1974. buffer = '';
  1975. state = 'relative path start';
  1976. }
  1977. continue;
  1978. } else if (c === '\t' || c === '\n' || c === '\r') {
  1979. err('Invalid whitespace in file host.');
  1980. } else {
  1981. buffer += c;
  1982. }
  1983. break;
  1984. case 'host':
  1985. case 'hostname':
  1986. if (c === ':' && !seenBracket) {
  1987. this._host = IDNAToASCII.call(this, buffer);
  1988. buffer = '';
  1989. state = 'port';
  1990. if (stateOverride === 'hostname') {
  1991. break loop;
  1992. }
  1993. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1994. this._host = IDNAToASCII.call(this, buffer);
  1995. buffer = '';
  1996. state = 'relative path start';
  1997. if (stateOverride) {
  1998. break loop;
  1999. }
  2000. continue;
  2001. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2002. if (c === '[') {
  2003. seenBracket = true;
  2004. } else if (c === ']') {
  2005. seenBracket = false;
  2006. }
  2007. buffer += c;
  2008. } else {
  2009. err('Invalid code point in host/hostname: ' + c);
  2010. }
  2011. break;
  2012. case 'port':
  2013. if (/[0-9]/.test(c)) {
  2014. buffer += c;
  2015. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  2016. if ('' !== buffer) {
  2017. var temp = parseInt(buffer, 10);
  2018. if (temp !== relative[this._scheme]) {
  2019. this._port = temp + '';
  2020. }
  2021. buffer = '';
  2022. }
  2023. if (stateOverride) {
  2024. break loop;
  2025. }
  2026. state = 'relative path start';
  2027. continue;
  2028. } else if (c === '\t' || c === '\n' || c === '\r') {
  2029. err('Invalid code point in port: ' + c);
  2030. } else {
  2031. invalid.call(this);
  2032. }
  2033. break;
  2034. case 'relative path start':
  2035. if (c === '\\') {
  2036. err('\'\\\' not allowed in path.');
  2037. }
  2038. state = 'relative path';
  2039. if ('/' !== c && '\\' !== c) {
  2040. continue;
  2041. }
  2042. break;
  2043. case 'relative path':
  2044. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  2045. if (c === '\\') {
  2046. err('\\ not allowed in relative path.');
  2047. }
  2048. var tmp;
  2049. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  2050. buffer = tmp;
  2051. }
  2052. if (buffer === '..') {
  2053. this._path.pop();
  2054. if ('/' !== c && '\\' !== c) {
  2055. this._path.push('');
  2056. }
  2057. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  2058. this._path.push('');
  2059. } else if ('.' !== buffer) {
  2060. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  2061. buffer = buffer[0] + ':';
  2062. }
  2063. this._path.push(buffer);
  2064. }
  2065. buffer = '';
  2066. if (c === '?') {
  2067. this._query = '?';
  2068. state = 'query';
  2069. } else if (c === '#') {
  2070. this._fragment = '#';
  2071. state = 'fragment';
  2072. }
  2073. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2074. buffer += percentEscape(c);
  2075. }
  2076. break;
  2077. case 'query':
  2078. if (!stateOverride && c === '#') {
  2079. this._fragment = '#';
  2080. state = 'fragment';
  2081. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2082. this._query += percentEscapeQuery(c);
  2083. }
  2084. break;
  2085. case 'fragment':
  2086. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2087. this._fragment += c;
  2088. }
  2089. break;
  2090. }
  2091. cursor++;
  2092. }
  2093. }
  2094. function clear() {
  2095. this._scheme = '';
  2096. this._schemeData = '';
  2097. this._username = '';
  2098. this._password = null;
  2099. this._host = '';
  2100. this._port = '';
  2101. this._path = [];
  2102. this._query = '';
  2103. this._fragment = '';
  2104. this._isInvalid = false;
  2105. this._isRelative = false;
  2106. }
  2107. function JURL(url, base) {
  2108. if (base !== undefined && !(base instanceof JURL)) {
  2109. base = new JURL(String(base));
  2110. }
  2111. this._url = url;
  2112. clear.call(this);
  2113. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  2114. parse.call(this, input, null, base);
  2115. }
  2116. JURL.prototype = {
  2117. toString: function () {
  2118. return this.href;
  2119. },
  2120. get href() {
  2121. if (this._isInvalid) {
  2122. return this._url;
  2123. }
  2124. var authority = '';
  2125. if ('' !== this._username || null !== this._password) {
  2126. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  2127. }
  2128. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  2129. },
  2130. set href(href) {
  2131. clear.call(this);
  2132. parse.call(this, href);
  2133. },
  2134. get protocol() {
  2135. return this._scheme + ':';
  2136. },
  2137. set protocol(protocol) {
  2138. if (this._isInvalid) {
  2139. return;
  2140. }
  2141. parse.call(this, protocol + ':', 'scheme start');
  2142. },
  2143. get host() {
  2144. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  2145. },
  2146. set host(host) {
  2147. if (this._isInvalid || !this._isRelative) {
  2148. return;
  2149. }
  2150. parse.call(this, host, 'host');
  2151. },
  2152. get hostname() {
  2153. return this._host;
  2154. },
  2155. set hostname(hostname) {
  2156. if (this._isInvalid || !this._isRelative) {
  2157. return;
  2158. }
  2159. parse.call(this, hostname, 'hostname');
  2160. },
  2161. get port() {
  2162. return this._port;
  2163. },
  2164. set port(port) {
  2165. if (this._isInvalid || !this._isRelative) {
  2166. return;
  2167. }
  2168. parse.call(this, port, 'port');
  2169. },
  2170. get pathname() {
  2171. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  2172. },
  2173. set pathname(pathname) {
  2174. if (this._isInvalid || !this._isRelative) {
  2175. return;
  2176. }
  2177. this._path = [];
  2178. parse.call(this, pathname, 'relative path start');
  2179. },
  2180. get search() {
  2181. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  2182. },
  2183. set search(search) {
  2184. if (this._isInvalid || !this._isRelative) {
  2185. return;
  2186. }
  2187. this._query = '?';
  2188. if (search[0] === '?') {
  2189. search = search.slice(1);
  2190. }
  2191. parse.call(this, search, 'query');
  2192. },
  2193. get hash() {
  2194. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  2195. },
  2196. set hash(hash) {
  2197. if (this._isInvalid) {
  2198. return;
  2199. }
  2200. this._fragment = '#';
  2201. if (hash[0] === '#') {
  2202. hash = hash.slice(1);
  2203. }
  2204. parse.call(this, hash, 'fragment');
  2205. },
  2206. get origin() {
  2207. var host;
  2208. if (this._isInvalid || !this._scheme) {
  2209. return '';
  2210. }
  2211. switch (this._scheme) {
  2212. case 'data':
  2213. case 'file':
  2214. case 'javascript':
  2215. case 'mailto':
  2216. return 'null';
  2217. }
  2218. host = this.host;
  2219. if (!host) {
  2220. return '';
  2221. }
  2222. return this._scheme + '://' + host;
  2223. }
  2224. };
  2225. var OriginalURL = scope.URL;
  2226. if (OriginalURL) {
  2227. JURL.createObjectURL = function (blob) {
  2228. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  2229. };
  2230. JURL.revokeObjectURL = function (url) {
  2231. OriginalURL.revokeObjectURL(url);
  2232. };
  2233. }
  2234. scope.URL = JURL;
  2235. }(globalScope));
  2236. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  2237. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  2238. exports.OPS = OPS;
  2239. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  2240. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  2241. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  2242. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  2243. exports.AnnotationFlag = AnnotationFlag;
  2244. exports.AnnotationType = AnnotationType;
  2245. exports.FontType = FontType;
  2246. exports.ImageKind = ImageKind;
  2247. exports.CMapCompressionType = CMapCompressionType;
  2248. exports.InvalidPDFException = InvalidPDFException;
  2249. exports.MessageHandler = MessageHandler;
  2250. exports.MissingDataException = MissingDataException;
  2251. exports.MissingPDFException = MissingPDFException;
  2252. exports.NotImplementedException = NotImplementedException;
  2253. exports.PageViewport = PageViewport;
  2254. exports.PasswordException = PasswordException;
  2255. exports.PasswordResponses = PasswordResponses;
  2256. exports.StatTimer = StatTimer;
  2257. exports.StreamType = StreamType;
  2258. exports.TextRenderingMode = TextRenderingMode;
  2259. exports.UnexpectedResponseException = UnexpectedResponseException;
  2260. exports.UnknownErrorException = UnknownErrorException;
  2261. exports.Util = Util;
  2262. exports.XRefParseException = XRefParseException;
  2263. exports.arrayByteLength = arrayByteLength;
  2264. exports.arraysToBytes = arraysToBytes;
  2265. exports.assert = assert;
  2266. exports.bytesToString = bytesToString;
  2267. exports.createBlob = createBlob;
  2268. exports.createPromiseCapability = createPromiseCapability;
  2269. exports.createObjectURL = createObjectURL;
  2270. exports.deprecated = deprecated;
  2271. exports.error = error;
  2272. exports.getLookupTableFactory = getLookupTableFactory;
  2273. exports.getVerbosityLevel = getVerbosityLevel;
  2274. exports.globalScope = globalScope;
  2275. exports.info = info;
  2276. exports.isArray = isArray;
  2277. exports.isArrayBuffer = isArrayBuffer;
  2278. exports.isBool = isBool;
  2279. exports.isEmptyObj = isEmptyObj;
  2280. exports.isInt = isInt;
  2281. exports.isNum = isNum;
  2282. exports.isString = isString;
  2283. exports.isSpace = isSpace;
  2284. exports.isSameOrigin = isSameOrigin;
  2285. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  2286. exports.isLittleEndian = isLittleEndian;
  2287. exports.isEvalSupported = isEvalSupported;
  2288. exports.loadJpegStream = loadJpegStream;
  2289. exports.log2 = log2;
  2290. exports.readInt8 = readInt8;
  2291. exports.readUint16 = readUint16;
  2292. exports.readUint32 = readUint32;
  2293. exports.removeNullCharacters = removeNullCharacters;
  2294. exports.setVerbosityLevel = setVerbosityLevel;
  2295. exports.shadow = shadow;
  2296. exports.string32 = string32;
  2297. exports.stringToBytes = stringToBytes;
  2298. exports.stringToPDFString = stringToPDFString;
  2299. exports.stringToUTF8String = stringToUTF8String;
  2300. exports.utf8StringToString = utf8StringToString;
  2301. exports.warn = warn;
  2302. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(26)))
  2303. /***/ }),
  2304. /* 1 */
  2305. /***/ (function(module, exports, __w_pdfjs_require__) {
  2306. "use strict";
  2307. var sharedUtil = __w_pdfjs_require__(0);
  2308. var isArray = sharedUtil.isArray;
  2309. var EOF = {};
  2310. var Name = function NameClosure() {
  2311. function Name(name) {
  2312. this.name = name;
  2313. }
  2314. Name.prototype = {};
  2315. var nameCache = Object.create(null);
  2316. Name.get = function Name_get(name) {
  2317. var nameValue = nameCache[name];
  2318. return nameValue ? nameValue : nameCache[name] = new Name(name);
  2319. };
  2320. return Name;
  2321. }();
  2322. var Cmd = function CmdClosure() {
  2323. function Cmd(cmd) {
  2324. this.cmd = cmd;
  2325. }
  2326. Cmd.prototype = {};
  2327. var cmdCache = Object.create(null);
  2328. Cmd.get = function Cmd_get(cmd) {
  2329. var cmdValue = cmdCache[cmd];
  2330. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  2331. };
  2332. return Cmd;
  2333. }();
  2334. var Dict = function DictClosure() {
  2335. var nonSerializable = function nonSerializableClosure() {
  2336. return nonSerializable;
  2337. };
  2338. function Dict(xref) {
  2339. this.map = Object.create(null);
  2340. this.xref = xref;
  2341. this.objId = null;
  2342. this.suppressEncryption = false;
  2343. this.__nonSerializable__ = nonSerializable;
  2344. }
  2345. Dict.prototype = {
  2346. assignXref: function Dict_assignXref(newXref) {
  2347. this.xref = newXref;
  2348. },
  2349. get: function Dict_get(key1, key2, key3) {
  2350. var value;
  2351. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2352. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2353. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2354. }
  2355. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2356. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2357. }
  2358. value = this.map[key3] || null;
  2359. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2360. },
  2361. getAsync: function Dict_getAsync(key1, key2, key3) {
  2362. var value;
  2363. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2364. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2365. if (xref) {
  2366. return xref.fetchIfRefAsync(value, suppressEncryption);
  2367. }
  2368. return Promise.resolve(value);
  2369. }
  2370. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2371. if (xref) {
  2372. return xref.fetchIfRefAsync(value, suppressEncryption);
  2373. }
  2374. return Promise.resolve(value);
  2375. }
  2376. value = this.map[key3] || null;
  2377. if (xref) {
  2378. return xref.fetchIfRefAsync(value, suppressEncryption);
  2379. }
  2380. return Promise.resolve(value);
  2381. },
  2382. getArray: function Dict_getArray(key1, key2, key3) {
  2383. var value = this.get(key1, key2, key3);
  2384. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2385. if (!isArray(value) || !xref) {
  2386. return value;
  2387. }
  2388. value = value.slice();
  2389. for (var i = 0, ii = value.length; i < ii; i++) {
  2390. if (!isRef(value[i])) {
  2391. continue;
  2392. }
  2393. value[i] = xref.fetch(value[i], suppressEncryption);
  2394. }
  2395. return value;
  2396. },
  2397. getRaw: function Dict_getRaw(key) {
  2398. return this.map[key];
  2399. },
  2400. getKeys: function Dict_getKeys() {
  2401. return Object.keys(this.map);
  2402. },
  2403. set: function Dict_set(key, value) {
  2404. this.map[key] = value;
  2405. },
  2406. has: function Dict_has(key) {
  2407. return key in this.map;
  2408. },
  2409. forEach: function Dict_forEach(callback) {
  2410. for (var key in this.map) {
  2411. callback(key, this.get(key));
  2412. }
  2413. }
  2414. };
  2415. Dict.empty = new Dict(null);
  2416. Dict.merge = function Dict_merge(xref, dictArray) {
  2417. var mergedDict = new Dict(xref);
  2418. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  2419. var dict = dictArray[i];
  2420. if (!isDict(dict)) {
  2421. continue;
  2422. }
  2423. for (var keyName in dict.map) {
  2424. if (mergedDict.map[keyName]) {
  2425. continue;
  2426. }
  2427. mergedDict.map[keyName] = dict.map[keyName];
  2428. }
  2429. }
  2430. return mergedDict;
  2431. };
  2432. return Dict;
  2433. }();
  2434. var Ref = function RefClosure() {
  2435. function Ref(num, gen) {
  2436. this.num = num;
  2437. this.gen = gen;
  2438. }
  2439. Ref.prototype = {
  2440. toString: function Ref_toString() {
  2441. var str = this.num + 'R';
  2442. if (this.gen !== 0) {
  2443. str += this.gen;
  2444. }
  2445. return str;
  2446. }
  2447. };
  2448. return Ref;
  2449. }();
  2450. var RefSet = function RefSetClosure() {
  2451. function RefSet() {
  2452. this.dict = Object.create(null);
  2453. }
  2454. RefSet.prototype = {
  2455. has: function RefSet_has(ref) {
  2456. return ref.toString() in this.dict;
  2457. },
  2458. put: function RefSet_put(ref) {
  2459. this.dict[ref.toString()] = true;
  2460. },
  2461. remove: function RefSet_remove(ref) {
  2462. delete this.dict[ref.toString()];
  2463. }
  2464. };
  2465. return RefSet;
  2466. }();
  2467. var RefSetCache = function RefSetCacheClosure() {
  2468. function RefSetCache() {
  2469. this.dict = Object.create(null);
  2470. }
  2471. RefSetCache.prototype = {
  2472. get: function RefSetCache_get(ref) {
  2473. return this.dict[ref.toString()];
  2474. },
  2475. has: function RefSetCache_has(ref) {
  2476. return ref.toString() in this.dict;
  2477. },
  2478. put: function RefSetCache_put(ref, obj) {
  2479. this.dict[ref.toString()] = obj;
  2480. },
  2481. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  2482. this.dict[ref.toString()] = this.get(aliasRef);
  2483. },
  2484. forEach: function RefSetCache_forEach(fn, thisArg) {
  2485. for (var i in this.dict) {
  2486. fn.call(thisArg, this.dict[i]);
  2487. }
  2488. },
  2489. clear: function RefSetCache_clear() {
  2490. this.dict = Object.create(null);
  2491. }
  2492. };
  2493. return RefSetCache;
  2494. }();
  2495. function isEOF(v) {
  2496. return v === EOF;
  2497. }
  2498. function isName(v, name) {
  2499. return v instanceof Name && (name === undefined || v.name === name);
  2500. }
  2501. function isCmd(v, cmd) {
  2502. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  2503. }
  2504. function isDict(v, type) {
  2505. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  2506. }
  2507. function isRef(v) {
  2508. return v instanceof Ref;
  2509. }
  2510. function isRefsEqual(v1, v2) {
  2511. return v1.num === v2.num && v1.gen === v2.gen;
  2512. }
  2513. function isStream(v) {
  2514. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  2515. }
  2516. exports.EOF = EOF;
  2517. exports.Cmd = Cmd;
  2518. exports.Dict = Dict;
  2519. exports.Name = Name;
  2520. exports.Ref = Ref;
  2521. exports.RefSet = RefSet;
  2522. exports.RefSetCache = RefSetCache;
  2523. exports.isEOF = isEOF;
  2524. exports.isCmd = isCmd;
  2525. exports.isDict = isDict;
  2526. exports.isName = isName;
  2527. exports.isRef = isRef;
  2528. exports.isRefsEqual = isRefsEqual;
  2529. exports.isStream = isStream;
  2530. /***/ }),
  2531. /* 2 */
  2532. /***/ (function(module, exports, __w_pdfjs_require__) {
  2533. "use strict";
  2534. var sharedUtil = __w_pdfjs_require__(0);
  2535. var corePrimitives = __w_pdfjs_require__(1);
  2536. var coreJbig2 = __w_pdfjs_require__(35);
  2537. var coreJpg = __w_pdfjs_require__(36);
  2538. var coreJpx = __w_pdfjs_require__(18);
  2539. var Util = sharedUtil.Util;
  2540. var error = sharedUtil.error;
  2541. var info = sharedUtil.info;
  2542. var isInt = sharedUtil.isInt;
  2543. var isArray = sharedUtil.isArray;
  2544. var createObjectURL = sharedUtil.createObjectURL;
  2545. var shadow = sharedUtil.shadow;
  2546. var isSpace = sharedUtil.isSpace;
  2547. var Dict = corePrimitives.Dict;
  2548. var isDict = corePrimitives.isDict;
  2549. var isStream = corePrimitives.isStream;
  2550. var Jbig2Image = coreJbig2.Jbig2Image;
  2551. var JpegImage = coreJpg.JpegImage;
  2552. var JpxImage = coreJpx.JpxImage;
  2553. var Stream = function StreamClosure() {
  2554. function Stream(arrayBuffer, start, length, dict) {
  2555. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  2556. this.start = start || 0;
  2557. this.pos = this.start;
  2558. this.end = start + length || this.bytes.length;
  2559. this.dict = dict;
  2560. }
  2561. Stream.prototype = {
  2562. get length() {
  2563. return this.end - this.start;
  2564. },
  2565. get isEmpty() {
  2566. return this.length === 0;
  2567. },
  2568. getByte: function Stream_getByte() {
  2569. if (this.pos >= this.end) {
  2570. return -1;
  2571. }
  2572. return this.bytes[this.pos++];
  2573. },
  2574. getUint16: function Stream_getUint16() {
  2575. var b0 = this.getByte();
  2576. var b1 = this.getByte();
  2577. if (b0 === -1 || b1 === -1) {
  2578. return -1;
  2579. }
  2580. return (b0 << 8) + b1;
  2581. },
  2582. getInt32: function Stream_getInt32() {
  2583. var b0 = this.getByte();
  2584. var b1 = this.getByte();
  2585. var b2 = this.getByte();
  2586. var b3 = this.getByte();
  2587. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2588. },
  2589. getBytes: function Stream_getBytes(length) {
  2590. var bytes = this.bytes;
  2591. var pos = this.pos;
  2592. var strEnd = this.end;
  2593. if (!length) {
  2594. return bytes.subarray(pos, strEnd);
  2595. }
  2596. var end = pos + length;
  2597. if (end > strEnd) {
  2598. end = strEnd;
  2599. }
  2600. this.pos = end;
  2601. return bytes.subarray(pos, end);
  2602. },
  2603. peekByte: function Stream_peekByte() {
  2604. var peekedByte = this.getByte();
  2605. this.pos--;
  2606. return peekedByte;
  2607. },
  2608. peekBytes: function Stream_peekBytes(length) {
  2609. var bytes = this.getBytes(length);
  2610. this.pos -= bytes.length;
  2611. return bytes;
  2612. },
  2613. skip: function Stream_skip(n) {
  2614. if (!n) {
  2615. n = 1;
  2616. }
  2617. this.pos += n;
  2618. },
  2619. reset: function Stream_reset() {
  2620. this.pos = this.start;
  2621. },
  2622. moveStart: function Stream_moveStart() {
  2623. this.start = this.pos;
  2624. },
  2625. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  2626. return new Stream(this.bytes.buffer, start, length, dict);
  2627. }
  2628. };
  2629. return Stream;
  2630. }();
  2631. var StringStream = function StringStreamClosure() {
  2632. function StringStream(str) {
  2633. var length = str.length;
  2634. var bytes = new Uint8Array(length);
  2635. for (var n = 0; n < length; ++n) {
  2636. bytes[n] = str.charCodeAt(n);
  2637. }
  2638. Stream.call(this, bytes);
  2639. }
  2640. StringStream.prototype = Stream.prototype;
  2641. return StringStream;
  2642. }();
  2643. var DecodeStream = function DecodeStreamClosure() {
  2644. var emptyBuffer = new Uint8Array(0);
  2645. function DecodeStream(maybeMinBufferLength) {
  2646. this.pos = 0;
  2647. this.bufferLength = 0;
  2648. this.eof = false;
  2649. this.buffer = emptyBuffer;
  2650. this.minBufferLength = 512;
  2651. if (maybeMinBufferLength) {
  2652. while (this.minBufferLength < maybeMinBufferLength) {
  2653. this.minBufferLength *= 2;
  2654. }
  2655. }
  2656. }
  2657. DecodeStream.prototype = {
  2658. get isEmpty() {
  2659. while (!this.eof && this.bufferLength === 0) {
  2660. this.readBlock();
  2661. }
  2662. return this.bufferLength === 0;
  2663. },
  2664. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  2665. var buffer = this.buffer;
  2666. if (requested <= buffer.byteLength) {
  2667. return buffer;
  2668. }
  2669. var size = this.minBufferLength;
  2670. while (size < requested) {
  2671. size *= 2;
  2672. }
  2673. var buffer2 = new Uint8Array(size);
  2674. buffer2.set(buffer);
  2675. return this.buffer = buffer2;
  2676. },
  2677. getByte: function DecodeStream_getByte() {
  2678. var pos = this.pos;
  2679. while (this.bufferLength <= pos) {
  2680. if (this.eof) {
  2681. return -1;
  2682. }
  2683. this.readBlock();
  2684. }
  2685. return this.buffer[this.pos++];
  2686. },
  2687. getUint16: function DecodeStream_getUint16() {
  2688. var b0 = this.getByte();
  2689. var b1 = this.getByte();
  2690. if (b0 === -1 || b1 === -1) {
  2691. return -1;
  2692. }
  2693. return (b0 << 8) + b1;
  2694. },
  2695. getInt32: function DecodeStream_getInt32() {
  2696. var b0 = this.getByte();
  2697. var b1 = this.getByte();
  2698. var b2 = this.getByte();
  2699. var b3 = this.getByte();
  2700. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2701. },
  2702. getBytes: function DecodeStream_getBytes(length) {
  2703. var end, pos = this.pos;
  2704. if (length) {
  2705. this.ensureBuffer(pos + length);
  2706. end = pos + length;
  2707. while (!this.eof && this.bufferLength < end) {
  2708. this.readBlock();
  2709. }
  2710. var bufEnd = this.bufferLength;
  2711. if (end > bufEnd) {
  2712. end = bufEnd;
  2713. }
  2714. } else {
  2715. while (!this.eof) {
  2716. this.readBlock();
  2717. }
  2718. end = this.bufferLength;
  2719. }
  2720. this.pos = end;
  2721. return this.buffer.subarray(pos, end);
  2722. },
  2723. peekByte: function DecodeStream_peekByte() {
  2724. var peekedByte = this.getByte();
  2725. this.pos--;
  2726. return peekedByte;
  2727. },
  2728. peekBytes: function DecodeStream_peekBytes(length) {
  2729. var bytes = this.getBytes(length);
  2730. this.pos -= bytes.length;
  2731. return bytes;
  2732. },
  2733. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  2734. var end = start + length;
  2735. while (this.bufferLength <= end && !this.eof) {
  2736. this.readBlock();
  2737. }
  2738. return new Stream(this.buffer, start, length, dict);
  2739. },
  2740. skip: function DecodeStream_skip(n) {
  2741. if (!n) {
  2742. n = 1;
  2743. }
  2744. this.pos += n;
  2745. },
  2746. reset: function DecodeStream_reset() {
  2747. this.pos = 0;
  2748. },
  2749. getBaseStreams: function DecodeStream_getBaseStreams() {
  2750. if (this.str && this.str.getBaseStreams) {
  2751. return this.str.getBaseStreams();
  2752. }
  2753. return [];
  2754. }
  2755. };
  2756. return DecodeStream;
  2757. }();
  2758. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  2759. function StreamsSequenceStream(streams) {
  2760. this.streams = streams;
  2761. DecodeStream.call(this, null);
  2762. }
  2763. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  2764. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  2765. var streams = this.streams;
  2766. if (streams.length === 0) {
  2767. this.eof = true;
  2768. return;
  2769. }
  2770. var stream = streams.shift();
  2771. var chunk = stream.getBytes();
  2772. var bufferLength = this.bufferLength;
  2773. var newLength = bufferLength + chunk.length;
  2774. var buffer = this.ensureBuffer(newLength);
  2775. buffer.set(chunk, bufferLength);
  2776. this.bufferLength = newLength;
  2777. };
  2778. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  2779. var baseStreams = [];
  2780. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  2781. var stream = this.streams[i];
  2782. if (stream.getBaseStreams) {
  2783. Util.appendToArray(baseStreams, stream.getBaseStreams());
  2784. }
  2785. }
  2786. return baseStreams;
  2787. };
  2788. return StreamsSequenceStream;
  2789. }();
  2790. var FlateStream = function FlateStreamClosure() {
  2791. var codeLenCodeMap = new Int32Array([
  2792. 16,
  2793. 17,
  2794. 18,
  2795. 0,
  2796. 8,
  2797. 7,
  2798. 9,
  2799. 6,
  2800. 10,
  2801. 5,
  2802. 11,
  2803. 4,
  2804. 12,
  2805. 3,
  2806. 13,
  2807. 2,
  2808. 14,
  2809. 1,
  2810. 15
  2811. ]);
  2812. var lengthDecode = new Int32Array([
  2813. 0x00003,
  2814. 0x00004,
  2815. 0x00005,
  2816. 0x00006,
  2817. 0x00007,
  2818. 0x00008,
  2819. 0x00009,
  2820. 0x0000a,
  2821. 0x1000b,
  2822. 0x1000d,
  2823. 0x1000f,
  2824. 0x10011,
  2825. 0x20013,
  2826. 0x20017,
  2827. 0x2001b,
  2828. 0x2001f,
  2829. 0x30023,
  2830. 0x3002b,
  2831. 0x30033,
  2832. 0x3003b,
  2833. 0x40043,
  2834. 0x40053,
  2835. 0x40063,
  2836. 0x40073,
  2837. 0x50083,
  2838. 0x500a3,
  2839. 0x500c3,
  2840. 0x500e3,
  2841. 0x00102,
  2842. 0x00102,
  2843. 0x00102
  2844. ]);
  2845. var distDecode = new Int32Array([
  2846. 0x00001,
  2847. 0x00002,
  2848. 0x00003,
  2849. 0x00004,
  2850. 0x10005,
  2851. 0x10007,
  2852. 0x20009,
  2853. 0x2000d,
  2854. 0x30011,
  2855. 0x30019,
  2856. 0x40021,
  2857. 0x40031,
  2858. 0x50041,
  2859. 0x50061,
  2860. 0x60081,
  2861. 0x600c1,
  2862. 0x70101,
  2863. 0x70181,
  2864. 0x80201,
  2865. 0x80301,
  2866. 0x90401,
  2867. 0x90601,
  2868. 0xa0801,
  2869. 0xa0c01,
  2870. 0xb1001,
  2871. 0xb1801,
  2872. 0xc2001,
  2873. 0xc3001,
  2874. 0xd4001,
  2875. 0xd6001
  2876. ]);
  2877. var fixedLitCodeTab = [
  2878. new Int32Array([
  2879. 0x70100,
  2880. 0x80050,
  2881. 0x80010,
  2882. 0x80118,
  2883. 0x70110,
  2884. 0x80070,
  2885. 0x80030,
  2886. 0x900c0,
  2887. 0x70108,
  2888. 0x80060,
  2889. 0x80020,
  2890. 0x900a0,
  2891. 0x80000,
  2892. 0x80080,
  2893. 0x80040,
  2894. 0x900e0,
  2895. 0x70104,
  2896. 0x80058,
  2897. 0x80018,
  2898. 0x90090,
  2899. 0x70114,
  2900. 0x80078,
  2901. 0x80038,
  2902. 0x900d0,
  2903. 0x7010c,
  2904. 0x80068,
  2905. 0x80028,
  2906. 0x900b0,
  2907. 0x80008,
  2908. 0x80088,
  2909. 0x80048,
  2910. 0x900f0,
  2911. 0x70102,
  2912. 0x80054,
  2913. 0x80014,
  2914. 0x8011c,
  2915. 0x70112,
  2916. 0x80074,
  2917. 0x80034,
  2918. 0x900c8,
  2919. 0x7010a,
  2920. 0x80064,
  2921. 0x80024,
  2922. 0x900a8,
  2923. 0x80004,
  2924. 0x80084,
  2925. 0x80044,
  2926. 0x900e8,
  2927. 0x70106,
  2928. 0x8005c,
  2929. 0x8001c,
  2930. 0x90098,
  2931. 0x70116,
  2932. 0x8007c,
  2933. 0x8003c,
  2934. 0x900d8,
  2935. 0x7010e,
  2936. 0x8006c,
  2937. 0x8002c,
  2938. 0x900b8,
  2939. 0x8000c,
  2940. 0x8008c,
  2941. 0x8004c,
  2942. 0x900f8,
  2943. 0x70101,
  2944. 0x80052,
  2945. 0x80012,
  2946. 0x8011a,
  2947. 0x70111,
  2948. 0x80072,
  2949. 0x80032,
  2950. 0x900c4,
  2951. 0x70109,
  2952. 0x80062,
  2953. 0x80022,
  2954. 0x900a4,
  2955. 0x80002,
  2956. 0x80082,
  2957. 0x80042,
  2958. 0x900e4,
  2959. 0x70105,
  2960. 0x8005a,
  2961. 0x8001a,
  2962. 0x90094,
  2963. 0x70115,
  2964. 0x8007a,
  2965. 0x8003a,
  2966. 0x900d4,
  2967. 0x7010d,
  2968. 0x8006a,
  2969. 0x8002a,
  2970. 0x900b4,
  2971. 0x8000a,
  2972. 0x8008a,
  2973. 0x8004a,
  2974. 0x900f4,
  2975. 0x70103,
  2976. 0x80056,
  2977. 0x80016,
  2978. 0x8011e,
  2979. 0x70113,
  2980. 0x80076,
  2981. 0x80036,
  2982. 0x900cc,
  2983. 0x7010b,
  2984. 0x80066,
  2985. 0x80026,
  2986. 0x900ac,
  2987. 0x80006,
  2988. 0x80086,
  2989. 0x80046,
  2990. 0x900ec,
  2991. 0x70107,
  2992. 0x8005e,
  2993. 0x8001e,
  2994. 0x9009c,
  2995. 0x70117,
  2996. 0x8007e,
  2997. 0x8003e,
  2998. 0x900dc,
  2999. 0x7010f,
  3000. 0x8006e,
  3001. 0x8002e,
  3002. 0x900bc,
  3003. 0x8000e,
  3004. 0x8008e,
  3005. 0x8004e,
  3006. 0x900fc,
  3007. 0x70100,
  3008. 0x80051,
  3009. 0x80011,
  3010. 0x80119,
  3011. 0x70110,
  3012. 0x80071,
  3013. 0x80031,
  3014. 0x900c2,
  3015. 0x70108,
  3016. 0x80061,
  3017. 0x80021,
  3018. 0x900a2,
  3019. 0x80001,
  3020. 0x80081,
  3021. 0x80041,
  3022. 0x900e2,
  3023. 0x70104,
  3024. 0x80059,
  3025. 0x80019,
  3026. 0x90092,
  3027. 0x70114,
  3028. 0x80079,
  3029. 0x80039,
  3030. 0x900d2,
  3031. 0x7010c,
  3032. 0x80069,
  3033. 0x80029,
  3034. 0x900b2,
  3035. 0x80009,
  3036. 0x80089,
  3037. 0x80049,
  3038. 0x900f2,
  3039. 0x70102,
  3040. 0x80055,
  3041. 0x80015,
  3042. 0x8011d,
  3043. 0x70112,
  3044. 0x80075,
  3045. 0x80035,
  3046. 0x900ca,
  3047. 0x7010a,
  3048. 0x80065,
  3049. 0x80025,
  3050. 0x900aa,
  3051. 0x80005,
  3052. 0x80085,
  3053. 0x80045,
  3054. 0x900ea,
  3055. 0x70106,
  3056. 0x8005d,
  3057. 0x8001d,
  3058. 0x9009a,
  3059. 0x70116,
  3060. 0x8007d,
  3061. 0x8003d,
  3062. 0x900da,
  3063. 0x7010e,
  3064. 0x8006d,
  3065. 0x8002d,
  3066. 0x900ba,
  3067. 0x8000d,
  3068. 0x8008d,
  3069. 0x8004d,
  3070. 0x900fa,
  3071. 0x70101,
  3072. 0x80053,
  3073. 0x80013,
  3074. 0x8011b,
  3075. 0x70111,
  3076. 0x80073,
  3077. 0x80033,
  3078. 0x900c6,
  3079. 0x70109,
  3080. 0x80063,
  3081. 0x80023,
  3082. 0x900a6,
  3083. 0x80003,
  3084. 0x80083,
  3085. 0x80043,
  3086. 0x900e6,
  3087. 0x70105,
  3088. 0x8005b,
  3089. 0x8001b,
  3090. 0x90096,
  3091. 0x70115,
  3092. 0x8007b,
  3093. 0x8003b,
  3094. 0x900d6,
  3095. 0x7010d,
  3096. 0x8006b,
  3097. 0x8002b,
  3098. 0x900b6,
  3099. 0x8000b,
  3100. 0x8008b,
  3101. 0x8004b,
  3102. 0x900f6,
  3103. 0x70103,
  3104. 0x80057,
  3105. 0x80017,
  3106. 0x8011f,
  3107. 0x70113,
  3108. 0x80077,
  3109. 0x80037,
  3110. 0x900ce,
  3111. 0x7010b,
  3112. 0x80067,
  3113. 0x80027,
  3114. 0x900ae,
  3115. 0x80007,
  3116. 0x80087,
  3117. 0x80047,
  3118. 0x900ee,
  3119. 0x70107,
  3120. 0x8005f,
  3121. 0x8001f,
  3122. 0x9009e,
  3123. 0x70117,
  3124. 0x8007f,
  3125. 0x8003f,
  3126. 0x900de,
  3127. 0x7010f,
  3128. 0x8006f,
  3129. 0x8002f,
  3130. 0x900be,
  3131. 0x8000f,
  3132. 0x8008f,
  3133. 0x8004f,
  3134. 0x900fe,
  3135. 0x70100,
  3136. 0x80050,
  3137. 0x80010,
  3138. 0x80118,
  3139. 0x70110,
  3140. 0x80070,
  3141. 0x80030,
  3142. 0x900c1,
  3143. 0x70108,
  3144. 0x80060,
  3145. 0x80020,
  3146. 0x900a1,
  3147. 0x80000,
  3148. 0x80080,
  3149. 0x80040,
  3150. 0x900e1,
  3151. 0x70104,
  3152. 0x80058,
  3153. 0x80018,
  3154. 0x90091,
  3155. 0x70114,
  3156. 0x80078,
  3157. 0x80038,
  3158. 0x900d1,
  3159. 0x7010c,
  3160. 0x80068,
  3161. 0x80028,
  3162. 0x900b1,
  3163. 0x80008,
  3164. 0x80088,
  3165. 0x80048,
  3166. 0x900f1,
  3167. 0x70102,
  3168. 0x80054,
  3169. 0x80014,
  3170. 0x8011c,
  3171. 0x70112,
  3172. 0x80074,
  3173. 0x80034,
  3174. 0x900c9,
  3175. 0x7010a,
  3176. 0x80064,
  3177. 0x80024,
  3178. 0x900a9,
  3179. 0x80004,
  3180. 0x80084,
  3181. 0x80044,
  3182. 0x900e9,
  3183. 0x70106,
  3184. 0x8005c,
  3185. 0x8001c,
  3186. 0x90099,
  3187. 0x70116,
  3188. 0x8007c,
  3189. 0x8003c,
  3190. 0x900d9,
  3191. 0x7010e,
  3192. 0x8006c,
  3193. 0x8002c,
  3194. 0x900b9,
  3195. 0x8000c,
  3196. 0x8008c,
  3197. 0x8004c,
  3198. 0x900f9,
  3199. 0x70101,
  3200. 0x80052,
  3201. 0x80012,
  3202. 0x8011a,
  3203. 0x70111,
  3204. 0x80072,
  3205. 0x80032,
  3206. 0x900c5,
  3207. 0x70109,
  3208. 0x80062,
  3209. 0x80022,
  3210. 0x900a5,
  3211. 0x80002,
  3212. 0x80082,
  3213. 0x80042,
  3214. 0x900e5,
  3215. 0x70105,
  3216. 0x8005a,
  3217. 0x8001a,
  3218. 0x90095,
  3219. 0x70115,
  3220. 0x8007a,
  3221. 0x8003a,
  3222. 0x900d5,
  3223. 0x7010d,
  3224. 0x8006a,
  3225. 0x8002a,
  3226. 0x900b5,
  3227. 0x8000a,
  3228. 0x8008a,
  3229. 0x8004a,
  3230. 0x900f5,
  3231. 0x70103,
  3232. 0x80056,
  3233. 0x80016,
  3234. 0x8011e,
  3235. 0x70113,
  3236. 0x80076,
  3237. 0x80036,
  3238. 0x900cd,
  3239. 0x7010b,
  3240. 0x80066,
  3241. 0x80026,
  3242. 0x900ad,
  3243. 0x80006,
  3244. 0x80086,
  3245. 0x80046,
  3246. 0x900ed,
  3247. 0x70107,
  3248. 0x8005e,
  3249. 0x8001e,
  3250. 0x9009d,
  3251. 0x70117,
  3252. 0x8007e,
  3253. 0x8003e,
  3254. 0x900dd,
  3255. 0x7010f,
  3256. 0x8006e,
  3257. 0x8002e,
  3258. 0x900bd,
  3259. 0x8000e,
  3260. 0x8008e,
  3261. 0x8004e,
  3262. 0x900fd,
  3263. 0x70100,
  3264. 0x80051,
  3265. 0x80011,
  3266. 0x80119,
  3267. 0x70110,
  3268. 0x80071,
  3269. 0x80031,
  3270. 0x900c3,
  3271. 0x70108,
  3272. 0x80061,
  3273. 0x80021,
  3274. 0x900a3,
  3275. 0x80001,
  3276. 0x80081,
  3277. 0x80041,
  3278. 0x900e3,
  3279. 0x70104,
  3280. 0x80059,
  3281. 0x80019,
  3282. 0x90093,
  3283. 0x70114,
  3284. 0x80079,
  3285. 0x80039,
  3286. 0x900d3,
  3287. 0x7010c,
  3288. 0x80069,
  3289. 0x80029,
  3290. 0x900b3,
  3291. 0x80009,
  3292. 0x80089,
  3293. 0x80049,
  3294. 0x900f3,
  3295. 0x70102,
  3296. 0x80055,
  3297. 0x80015,
  3298. 0x8011d,
  3299. 0x70112,
  3300. 0x80075,
  3301. 0x80035,
  3302. 0x900cb,
  3303. 0x7010a,
  3304. 0x80065,
  3305. 0x80025,
  3306. 0x900ab,
  3307. 0x80005,
  3308. 0x80085,
  3309. 0x80045,
  3310. 0x900eb,
  3311. 0x70106,
  3312. 0x8005d,
  3313. 0x8001d,
  3314. 0x9009b,
  3315. 0x70116,
  3316. 0x8007d,
  3317. 0x8003d,
  3318. 0x900db,
  3319. 0x7010e,
  3320. 0x8006d,
  3321. 0x8002d,
  3322. 0x900bb,
  3323. 0x8000d,
  3324. 0x8008d,
  3325. 0x8004d,
  3326. 0x900fb,
  3327. 0x70101,
  3328. 0x80053,
  3329. 0x80013,
  3330. 0x8011b,
  3331. 0x70111,
  3332. 0x80073,
  3333. 0x80033,
  3334. 0x900c7,
  3335. 0x70109,
  3336. 0x80063,
  3337. 0x80023,
  3338. 0x900a7,
  3339. 0x80003,
  3340. 0x80083,
  3341. 0x80043,
  3342. 0x900e7,
  3343. 0x70105,
  3344. 0x8005b,
  3345. 0x8001b,
  3346. 0x90097,
  3347. 0x70115,
  3348. 0x8007b,
  3349. 0x8003b,
  3350. 0x900d7,
  3351. 0x7010d,
  3352. 0x8006b,
  3353. 0x8002b,
  3354. 0x900b7,
  3355. 0x8000b,
  3356. 0x8008b,
  3357. 0x8004b,
  3358. 0x900f7,
  3359. 0x70103,
  3360. 0x80057,
  3361. 0x80017,
  3362. 0x8011f,
  3363. 0x70113,
  3364. 0x80077,
  3365. 0x80037,
  3366. 0x900cf,
  3367. 0x7010b,
  3368. 0x80067,
  3369. 0x80027,
  3370. 0x900af,
  3371. 0x80007,
  3372. 0x80087,
  3373. 0x80047,
  3374. 0x900ef,
  3375. 0x70107,
  3376. 0x8005f,
  3377. 0x8001f,
  3378. 0x9009f,
  3379. 0x70117,
  3380. 0x8007f,
  3381. 0x8003f,
  3382. 0x900df,
  3383. 0x7010f,
  3384. 0x8006f,
  3385. 0x8002f,
  3386. 0x900bf,
  3387. 0x8000f,
  3388. 0x8008f,
  3389. 0x8004f,
  3390. 0x900ff
  3391. ]),
  3392. 9
  3393. ];
  3394. var fixedDistCodeTab = [
  3395. new Int32Array([
  3396. 0x50000,
  3397. 0x50010,
  3398. 0x50008,
  3399. 0x50018,
  3400. 0x50004,
  3401. 0x50014,
  3402. 0x5000c,
  3403. 0x5001c,
  3404. 0x50002,
  3405. 0x50012,
  3406. 0x5000a,
  3407. 0x5001a,
  3408. 0x50006,
  3409. 0x50016,
  3410. 0x5000e,
  3411. 0x00000,
  3412. 0x50001,
  3413. 0x50011,
  3414. 0x50009,
  3415. 0x50019,
  3416. 0x50005,
  3417. 0x50015,
  3418. 0x5000d,
  3419. 0x5001d,
  3420. 0x50003,
  3421. 0x50013,
  3422. 0x5000b,
  3423. 0x5001b,
  3424. 0x50007,
  3425. 0x50017,
  3426. 0x5000f,
  3427. 0x00000
  3428. ]),
  3429. 5
  3430. ];
  3431. function FlateStream(str, maybeLength) {
  3432. this.str = str;
  3433. this.dict = str.dict;
  3434. var cmf = str.getByte();
  3435. var flg = str.getByte();
  3436. if (cmf === -1 || flg === -1) {
  3437. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  3438. }
  3439. if ((cmf & 0x0f) !== 0x08) {
  3440. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  3441. }
  3442. if (((cmf << 8) + flg) % 31 !== 0) {
  3443. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  3444. }
  3445. if (flg & 0x20) {
  3446. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  3447. }
  3448. this.codeSize = 0;
  3449. this.codeBuf = 0;
  3450. DecodeStream.call(this, maybeLength);
  3451. }
  3452. FlateStream.prototype = Object.create(DecodeStream.prototype);
  3453. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  3454. var str = this.str;
  3455. var codeSize = this.codeSize;
  3456. var codeBuf = this.codeBuf;
  3457. var b;
  3458. while (codeSize < bits) {
  3459. if ((b = str.getByte()) === -1) {
  3460. error('Bad encoding in flate stream');
  3461. }
  3462. codeBuf |= b << codeSize;
  3463. codeSize += 8;
  3464. }
  3465. b = codeBuf & (1 << bits) - 1;
  3466. this.codeBuf = codeBuf >> bits;
  3467. this.codeSize = codeSize -= bits;
  3468. return b;
  3469. };
  3470. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  3471. var str = this.str;
  3472. var codes = table[0];
  3473. var maxLen = table[1];
  3474. var codeSize = this.codeSize;
  3475. var codeBuf = this.codeBuf;
  3476. var b;
  3477. while (codeSize < maxLen) {
  3478. if ((b = str.getByte()) === -1) {
  3479. break;
  3480. }
  3481. codeBuf |= b << codeSize;
  3482. codeSize += 8;
  3483. }
  3484. var code = codes[codeBuf & (1 << maxLen) - 1];
  3485. var codeLen = code >> 16;
  3486. var codeVal = code & 0xffff;
  3487. if (codeLen < 1 || codeSize < codeLen) {
  3488. error('Bad encoding in flate stream');
  3489. }
  3490. this.codeBuf = codeBuf >> codeLen;
  3491. this.codeSize = codeSize - codeLen;
  3492. return codeVal;
  3493. };
  3494. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  3495. var n = lengths.length;
  3496. var maxLen = 0;
  3497. var i;
  3498. for (i = 0; i < n; ++i) {
  3499. if (lengths[i] > maxLen) {
  3500. maxLen = lengths[i];
  3501. }
  3502. }
  3503. var size = 1 << maxLen;
  3504. var codes = new Int32Array(size);
  3505. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  3506. for (var val = 0; val < n; ++val) {
  3507. if (lengths[val] === len) {
  3508. var code2 = 0;
  3509. var t = code;
  3510. for (i = 0; i < len; ++i) {
  3511. code2 = code2 << 1 | t & 1;
  3512. t >>= 1;
  3513. }
  3514. for (i = code2; i < size; i += skip) {
  3515. codes[i] = len << 16 | val;
  3516. }
  3517. ++code;
  3518. }
  3519. }
  3520. }
  3521. return [
  3522. codes,
  3523. maxLen
  3524. ];
  3525. };
  3526. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  3527. var buffer, len;
  3528. var str = this.str;
  3529. var hdr = this.getBits(3);
  3530. if (hdr & 1) {
  3531. this.eof = true;
  3532. }
  3533. hdr >>= 1;
  3534. if (hdr === 0) {
  3535. var b;
  3536. if ((b = str.getByte()) === -1) {
  3537. error('Bad block header in flate stream');
  3538. }
  3539. var blockLen = b;
  3540. if ((b = str.getByte()) === -1) {
  3541. error('Bad block header in flate stream');
  3542. }
  3543. blockLen |= b << 8;
  3544. if ((b = str.getByte()) === -1) {
  3545. error('Bad block header in flate stream');
  3546. }
  3547. var check = b;
  3548. if ((b = str.getByte()) === -1) {
  3549. error('Bad block header in flate stream');
  3550. }
  3551. check |= b << 8;
  3552. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  3553. error('Bad uncompressed block length in flate stream');
  3554. }
  3555. this.codeBuf = 0;
  3556. this.codeSize = 0;
  3557. var bufferLength = this.bufferLength;
  3558. buffer = this.ensureBuffer(bufferLength + blockLen);
  3559. var end = bufferLength + blockLen;
  3560. this.bufferLength = end;
  3561. if (blockLen === 0) {
  3562. if (str.peekByte() === -1) {
  3563. this.eof = true;
  3564. }
  3565. } else {
  3566. for (var n = bufferLength; n < end; ++n) {
  3567. if ((b = str.getByte()) === -1) {
  3568. this.eof = true;
  3569. break;
  3570. }
  3571. buffer[n] = b;
  3572. }
  3573. }
  3574. return;
  3575. }
  3576. var litCodeTable;
  3577. var distCodeTable;
  3578. if (hdr === 1) {
  3579. litCodeTable = fixedLitCodeTab;
  3580. distCodeTable = fixedDistCodeTab;
  3581. } else if (hdr === 2) {
  3582. var numLitCodes = this.getBits(5) + 257;
  3583. var numDistCodes = this.getBits(5) + 1;
  3584. var numCodeLenCodes = this.getBits(4) + 4;
  3585. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  3586. var i;
  3587. for (i = 0; i < numCodeLenCodes; ++i) {
  3588. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  3589. }
  3590. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  3591. len = 0;
  3592. i = 0;
  3593. var codes = numLitCodes + numDistCodes;
  3594. var codeLengths = new Uint8Array(codes);
  3595. var bitsLength, bitsOffset, what;
  3596. while (i < codes) {
  3597. var code = this.getCode(codeLenCodeTab);
  3598. if (code === 16) {
  3599. bitsLength = 2;
  3600. bitsOffset = 3;
  3601. what = len;
  3602. } else if (code === 17) {
  3603. bitsLength = 3;
  3604. bitsOffset = 3;
  3605. what = len = 0;
  3606. } else if (code === 18) {
  3607. bitsLength = 7;
  3608. bitsOffset = 11;
  3609. what = len = 0;
  3610. } else {
  3611. codeLengths[i++] = len = code;
  3612. continue;
  3613. }
  3614. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  3615. while (repeatLength-- > 0) {
  3616. codeLengths[i++] = what;
  3617. }
  3618. }
  3619. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  3620. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  3621. } else {
  3622. error('Unknown block type in flate stream');
  3623. }
  3624. buffer = this.buffer;
  3625. var limit = buffer ? buffer.length : 0;
  3626. var pos = this.bufferLength;
  3627. while (true) {
  3628. var code1 = this.getCode(litCodeTable);
  3629. if (code1 < 256) {
  3630. if (pos + 1 >= limit) {
  3631. buffer = this.ensureBuffer(pos + 1);
  3632. limit = buffer.length;
  3633. }
  3634. buffer[pos++] = code1;
  3635. continue;
  3636. }
  3637. if (code1 === 256) {
  3638. this.bufferLength = pos;
  3639. return;
  3640. }
  3641. code1 -= 257;
  3642. code1 = lengthDecode[code1];
  3643. var code2 = code1 >> 16;
  3644. if (code2 > 0) {
  3645. code2 = this.getBits(code2);
  3646. }
  3647. len = (code1 & 0xffff) + code2;
  3648. code1 = this.getCode(distCodeTable);
  3649. code1 = distDecode[code1];
  3650. code2 = code1 >> 16;
  3651. if (code2 > 0) {
  3652. code2 = this.getBits(code2);
  3653. }
  3654. var dist = (code1 & 0xffff) + code2;
  3655. if (pos + len >= limit) {
  3656. buffer = this.ensureBuffer(pos + len);
  3657. limit = buffer.length;
  3658. }
  3659. for (var k = 0; k < len; ++k, ++pos) {
  3660. buffer[pos] = buffer[pos - dist];
  3661. }
  3662. }
  3663. };
  3664. return FlateStream;
  3665. }();
  3666. var PredictorStream = function PredictorStreamClosure() {
  3667. function PredictorStream(str, maybeLength, params) {
  3668. if (!isDict(params)) {
  3669. return str;
  3670. }
  3671. var predictor = this.predictor = params.get('Predictor') || 1;
  3672. if (predictor <= 1) {
  3673. return str;
  3674. }
  3675. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  3676. error('Unsupported predictor: ' + predictor);
  3677. }
  3678. if (predictor === 2) {
  3679. this.readBlock = this.readBlockTiff;
  3680. } else {
  3681. this.readBlock = this.readBlockPng;
  3682. }
  3683. this.str = str;
  3684. this.dict = str.dict;
  3685. var colors = this.colors = params.get('Colors') || 1;
  3686. var bits = this.bits = params.get('BitsPerComponent') || 8;
  3687. var columns = this.columns = params.get('Columns') || 1;
  3688. this.pixBytes = colors * bits + 7 >> 3;
  3689. this.rowBytes = columns * colors * bits + 7 >> 3;
  3690. DecodeStream.call(this, maybeLength);
  3691. return this;
  3692. }
  3693. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  3694. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  3695. var rowBytes = this.rowBytes;
  3696. var bufferLength = this.bufferLength;
  3697. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3698. var bits = this.bits;
  3699. var colors = this.colors;
  3700. var rawBytes = this.str.getBytes(rowBytes);
  3701. this.eof = !rawBytes.length;
  3702. if (this.eof) {
  3703. return;
  3704. }
  3705. var inbuf = 0, outbuf = 0;
  3706. var inbits = 0, outbits = 0;
  3707. var pos = bufferLength;
  3708. var i;
  3709. if (bits === 1 && colors === 1) {
  3710. for (i = 0; i < rowBytes; ++i) {
  3711. var c = rawBytes[i] ^ inbuf;
  3712. c ^= c >> 1;
  3713. c ^= c >> 2;
  3714. c ^= c >> 4;
  3715. inbuf = (c & 1) << 7;
  3716. buffer[pos++] = c;
  3717. }
  3718. } else if (bits === 8) {
  3719. for (i = 0; i < colors; ++i) {
  3720. buffer[pos++] = rawBytes[i];
  3721. }
  3722. for (; i < rowBytes; ++i) {
  3723. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  3724. pos++;
  3725. }
  3726. } else {
  3727. var compArray = new Uint8Array(colors + 1);
  3728. var bitMask = (1 << bits) - 1;
  3729. var j = 0, k = bufferLength;
  3730. var columns = this.columns;
  3731. for (i = 0; i < columns; ++i) {
  3732. for (var kk = 0; kk < colors; ++kk) {
  3733. if (inbits < bits) {
  3734. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  3735. inbits += 8;
  3736. }
  3737. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  3738. inbits -= bits;
  3739. outbuf = outbuf << bits | compArray[kk];
  3740. outbits += bits;
  3741. if (outbits >= 8) {
  3742. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  3743. outbits -= 8;
  3744. }
  3745. }
  3746. }
  3747. if (outbits > 0) {
  3748. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  3749. }
  3750. }
  3751. this.bufferLength += rowBytes;
  3752. };
  3753. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  3754. var rowBytes = this.rowBytes;
  3755. var pixBytes = this.pixBytes;
  3756. var predictor = this.str.getByte();
  3757. var rawBytes = this.str.getBytes(rowBytes);
  3758. this.eof = !rawBytes.length;
  3759. if (this.eof) {
  3760. return;
  3761. }
  3762. var bufferLength = this.bufferLength;
  3763. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3764. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  3765. if (prevRow.length === 0) {
  3766. prevRow = new Uint8Array(rowBytes);
  3767. }
  3768. var i, j = bufferLength, up, c;
  3769. switch (predictor) {
  3770. case 0:
  3771. for (i = 0; i < rowBytes; ++i) {
  3772. buffer[j++] = rawBytes[i];
  3773. }
  3774. break;
  3775. case 1:
  3776. for (i = 0; i < pixBytes; ++i) {
  3777. buffer[j++] = rawBytes[i];
  3778. }
  3779. for (; i < rowBytes; ++i) {
  3780. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  3781. j++;
  3782. }
  3783. break;
  3784. case 2:
  3785. for (i = 0; i < rowBytes; ++i) {
  3786. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  3787. }
  3788. break;
  3789. case 3:
  3790. for (i = 0; i < pixBytes; ++i) {
  3791. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  3792. }
  3793. for (; i < rowBytes; ++i) {
  3794. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  3795. j++;
  3796. }
  3797. break;
  3798. case 4:
  3799. for (i = 0; i < pixBytes; ++i) {
  3800. up = prevRow[i];
  3801. c = rawBytes[i];
  3802. buffer[j++] = up + c;
  3803. }
  3804. for (; i < rowBytes; ++i) {
  3805. up = prevRow[i];
  3806. var upLeft = prevRow[i - pixBytes];
  3807. var left = buffer[j - pixBytes];
  3808. var p = left + up - upLeft;
  3809. var pa = p - left;
  3810. if (pa < 0) {
  3811. pa = -pa;
  3812. }
  3813. var pb = p - up;
  3814. if (pb < 0) {
  3815. pb = -pb;
  3816. }
  3817. var pc = p - upLeft;
  3818. if (pc < 0) {
  3819. pc = -pc;
  3820. }
  3821. c = rawBytes[i];
  3822. if (pa <= pb && pa <= pc) {
  3823. buffer[j++] = left + c;
  3824. } else if (pb <= pc) {
  3825. buffer[j++] = up + c;
  3826. } else {
  3827. buffer[j++] = upLeft + c;
  3828. }
  3829. }
  3830. break;
  3831. default:
  3832. error('Unsupported predictor: ' + predictor);
  3833. }
  3834. this.bufferLength += rowBytes;
  3835. };
  3836. return PredictorStream;
  3837. }();
  3838. var JpegStream = function JpegStreamClosure() {
  3839. function JpegStream(stream, maybeLength, dict, params) {
  3840. var ch;
  3841. while ((ch = stream.getByte()) !== -1) {
  3842. if (ch === 0xFF) {
  3843. stream.skip(-1);
  3844. break;
  3845. }
  3846. }
  3847. this.stream = stream;
  3848. this.maybeLength = maybeLength;
  3849. this.dict = dict;
  3850. this.params = params;
  3851. DecodeStream.call(this, maybeLength);
  3852. }
  3853. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3854. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3855. get: function JpegStream_bytes() {
  3856. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3857. },
  3858. configurable: true
  3859. });
  3860. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3861. if (this.bufferLength) {
  3862. return;
  3863. }
  3864. var jpegImage = new JpegImage();
  3865. var decodeArr = this.dict.getArray('Decode', 'D');
  3866. if (this.forceRGB && isArray(decodeArr)) {
  3867. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3868. var decodeArrLength = decodeArr.length;
  3869. var transform = new Int32Array(decodeArrLength);
  3870. var transformNeeded = false;
  3871. var maxValue = (1 << bitsPerComponent) - 1;
  3872. for (var i = 0; i < decodeArrLength; i += 2) {
  3873. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3874. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3875. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3876. transformNeeded = true;
  3877. }
  3878. }
  3879. if (transformNeeded) {
  3880. jpegImage.decodeTransform = transform;
  3881. }
  3882. }
  3883. if (isDict(this.params)) {
  3884. var colorTransform = this.params.get('ColorTransform');
  3885. if (isInt(colorTransform)) {
  3886. jpegImage.colorTransform = colorTransform;
  3887. }
  3888. }
  3889. jpegImage.parse(this.bytes);
  3890. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3891. this.buffer = data;
  3892. this.bufferLength = data.length;
  3893. this.eof = true;
  3894. };
  3895. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3896. this.ensureBuffer();
  3897. return this.buffer;
  3898. };
  3899. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3900. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3901. };
  3902. return JpegStream;
  3903. }();
  3904. var JpxStream = function JpxStreamClosure() {
  3905. function JpxStream(stream, maybeLength, dict, params) {
  3906. this.stream = stream;
  3907. this.maybeLength = maybeLength;
  3908. this.dict = dict;
  3909. this.params = params;
  3910. DecodeStream.call(this, maybeLength);
  3911. }
  3912. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3913. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3914. get: function JpxStream_bytes() {
  3915. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3916. },
  3917. configurable: true
  3918. });
  3919. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3920. if (this.bufferLength) {
  3921. return;
  3922. }
  3923. var jpxImage = new JpxImage();
  3924. jpxImage.parse(this.bytes);
  3925. var width = jpxImage.width;
  3926. var height = jpxImage.height;
  3927. var componentsCount = jpxImage.componentsCount;
  3928. var tileCount = jpxImage.tiles.length;
  3929. if (tileCount === 1) {
  3930. this.buffer = jpxImage.tiles[0].items;
  3931. } else {
  3932. var data = new Uint8Array(width * height * componentsCount);
  3933. for (var k = 0; k < tileCount; k++) {
  3934. var tileComponents = jpxImage.tiles[k];
  3935. var tileWidth = tileComponents.width;
  3936. var tileHeight = tileComponents.height;
  3937. var tileLeft = tileComponents.left;
  3938. var tileTop = tileComponents.top;
  3939. var src = tileComponents.items;
  3940. var srcPosition = 0;
  3941. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3942. var imgRowSize = width * componentsCount;
  3943. var tileRowSize = tileWidth * componentsCount;
  3944. for (var j = 0; j < tileHeight; j++) {
  3945. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3946. data.set(rowBytes, dataPosition);
  3947. srcPosition += tileRowSize;
  3948. dataPosition += imgRowSize;
  3949. }
  3950. }
  3951. this.buffer = data;
  3952. }
  3953. this.bufferLength = this.buffer.length;
  3954. this.eof = true;
  3955. };
  3956. return JpxStream;
  3957. }();
  3958. var Jbig2Stream = function Jbig2StreamClosure() {
  3959. function Jbig2Stream(stream, maybeLength, dict, params) {
  3960. this.stream = stream;
  3961. this.maybeLength = maybeLength;
  3962. this.dict = dict;
  3963. this.params = params;
  3964. DecodeStream.call(this, maybeLength);
  3965. }
  3966. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3967. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3968. get: function Jbig2Stream_bytes() {
  3969. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3970. },
  3971. configurable: true
  3972. });
  3973. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3974. if (this.bufferLength) {
  3975. return;
  3976. }
  3977. var jbig2Image = new Jbig2Image();
  3978. var chunks = [];
  3979. if (isDict(this.params)) {
  3980. var globalsStream = this.params.get('JBIG2Globals');
  3981. if (isStream(globalsStream)) {
  3982. var globals = globalsStream.getBytes();
  3983. chunks.push({
  3984. data: globals,
  3985. start: 0,
  3986. end: globals.length
  3987. });
  3988. }
  3989. }
  3990. chunks.push({
  3991. data: this.bytes,
  3992. start: 0,
  3993. end: this.bytes.length
  3994. });
  3995. var data = jbig2Image.parseChunks(chunks);
  3996. var dataLength = data.length;
  3997. for (var i = 0; i < dataLength; i++) {
  3998. data[i] ^= 0xFF;
  3999. }
  4000. this.buffer = data;
  4001. this.bufferLength = dataLength;
  4002. this.eof = true;
  4003. };
  4004. return Jbig2Stream;
  4005. }();
  4006. var DecryptStream = function DecryptStreamClosure() {
  4007. function DecryptStream(str, maybeLength, decrypt) {
  4008. this.str = str;
  4009. this.dict = str.dict;
  4010. this.decrypt = decrypt;
  4011. this.nextChunk = null;
  4012. this.initialized = false;
  4013. DecodeStream.call(this, maybeLength);
  4014. }
  4015. var chunkSize = 512;
  4016. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  4017. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  4018. var chunk;
  4019. if (this.initialized) {
  4020. chunk = this.nextChunk;
  4021. } else {
  4022. chunk = this.str.getBytes(chunkSize);
  4023. this.initialized = true;
  4024. }
  4025. if (!chunk || chunk.length === 0) {
  4026. this.eof = true;
  4027. return;
  4028. }
  4029. this.nextChunk = this.str.getBytes(chunkSize);
  4030. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  4031. var decrypt = this.decrypt;
  4032. chunk = decrypt(chunk, !hasMoreData);
  4033. var bufferLength = this.bufferLength;
  4034. var i, n = chunk.length;
  4035. var buffer = this.ensureBuffer(bufferLength + n);
  4036. for (i = 0; i < n; i++) {
  4037. buffer[bufferLength++] = chunk[i];
  4038. }
  4039. this.bufferLength = bufferLength;
  4040. };
  4041. return DecryptStream;
  4042. }();
  4043. var Ascii85Stream = function Ascii85StreamClosure() {
  4044. function Ascii85Stream(str, maybeLength) {
  4045. this.str = str;
  4046. this.dict = str.dict;
  4047. this.input = new Uint8Array(5);
  4048. if (maybeLength) {
  4049. maybeLength = 0.8 * maybeLength;
  4050. }
  4051. DecodeStream.call(this, maybeLength);
  4052. }
  4053. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  4054. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  4055. var TILDA_CHAR = 0x7E;
  4056. var Z_LOWER_CHAR = 0x7A;
  4057. var EOF = -1;
  4058. var str = this.str;
  4059. var c = str.getByte();
  4060. while (isSpace(c)) {
  4061. c = str.getByte();
  4062. }
  4063. if (c === EOF || c === TILDA_CHAR) {
  4064. this.eof = true;
  4065. return;
  4066. }
  4067. var bufferLength = this.bufferLength, buffer;
  4068. var i;
  4069. if (c === Z_LOWER_CHAR) {
  4070. buffer = this.ensureBuffer(bufferLength + 4);
  4071. for (i = 0; i < 4; ++i) {
  4072. buffer[bufferLength + i] = 0;
  4073. }
  4074. this.bufferLength += 4;
  4075. } else {
  4076. var input = this.input;
  4077. input[0] = c;
  4078. for (i = 1; i < 5; ++i) {
  4079. c = str.getByte();
  4080. while (isSpace(c)) {
  4081. c = str.getByte();
  4082. }
  4083. input[i] = c;
  4084. if (c === EOF || c === TILDA_CHAR) {
  4085. break;
  4086. }
  4087. }
  4088. buffer = this.ensureBuffer(bufferLength + i - 1);
  4089. this.bufferLength += i - 1;
  4090. if (i < 5) {
  4091. for (; i < 5; ++i) {
  4092. input[i] = 0x21 + 84;
  4093. }
  4094. this.eof = true;
  4095. }
  4096. var t = 0;
  4097. for (i = 0; i < 5; ++i) {
  4098. t = t * 85 + (input[i] - 0x21);
  4099. }
  4100. for (i = 3; i >= 0; --i) {
  4101. buffer[bufferLength + i] = t & 0xFF;
  4102. t >>= 8;
  4103. }
  4104. }
  4105. };
  4106. return Ascii85Stream;
  4107. }();
  4108. var AsciiHexStream = function AsciiHexStreamClosure() {
  4109. function AsciiHexStream(str, maybeLength) {
  4110. this.str = str;
  4111. this.dict = str.dict;
  4112. this.firstDigit = -1;
  4113. if (maybeLength) {
  4114. maybeLength = 0.5 * maybeLength;
  4115. }
  4116. DecodeStream.call(this, maybeLength);
  4117. }
  4118. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  4119. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  4120. var UPSTREAM_BLOCK_SIZE = 8000;
  4121. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  4122. if (!bytes.length) {
  4123. this.eof = true;
  4124. return;
  4125. }
  4126. var maxDecodeLength = bytes.length + 1 >> 1;
  4127. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  4128. var bufferLength = this.bufferLength;
  4129. var firstDigit = this.firstDigit;
  4130. for (var i = 0, ii = bytes.length; i < ii; i++) {
  4131. var ch = bytes[i], digit;
  4132. if (ch >= 0x30 && ch <= 0x39) {
  4133. digit = ch & 0x0F;
  4134. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  4135. digit = (ch & 0x0F) + 9;
  4136. } else if (ch === 0x3E) {
  4137. this.eof = true;
  4138. break;
  4139. } else {
  4140. continue;
  4141. }
  4142. if (firstDigit < 0) {
  4143. firstDigit = digit;
  4144. } else {
  4145. buffer[bufferLength++] = firstDigit << 4 | digit;
  4146. firstDigit = -1;
  4147. }
  4148. }
  4149. if (firstDigit >= 0 && this.eof) {
  4150. buffer[bufferLength++] = firstDigit << 4;
  4151. firstDigit = -1;
  4152. }
  4153. this.firstDigit = firstDigit;
  4154. this.bufferLength = bufferLength;
  4155. };
  4156. return AsciiHexStream;
  4157. }();
  4158. var RunLengthStream = function RunLengthStreamClosure() {
  4159. function RunLengthStream(str, maybeLength) {
  4160. this.str = str;
  4161. this.dict = str.dict;
  4162. DecodeStream.call(this, maybeLength);
  4163. }
  4164. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  4165. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  4166. var repeatHeader = this.str.getBytes(2);
  4167. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  4168. this.eof = true;
  4169. return;
  4170. }
  4171. var buffer;
  4172. var bufferLength = this.bufferLength;
  4173. var n = repeatHeader[0];
  4174. if (n < 128) {
  4175. buffer = this.ensureBuffer(bufferLength + n + 1);
  4176. buffer[bufferLength++] = repeatHeader[1];
  4177. if (n > 0) {
  4178. var source = this.str.getBytes(n);
  4179. buffer.set(source, bufferLength);
  4180. bufferLength += n;
  4181. }
  4182. } else {
  4183. n = 257 - n;
  4184. var b = repeatHeader[1];
  4185. buffer = this.ensureBuffer(bufferLength + n + 1);
  4186. for (var i = 0; i < n; i++) {
  4187. buffer[bufferLength++] = b;
  4188. }
  4189. }
  4190. this.bufferLength = bufferLength;
  4191. };
  4192. return RunLengthStream;
  4193. }();
  4194. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  4195. var ccittEOL = -2;
  4196. var ccittEOF = -1;
  4197. var twoDimPass = 0;
  4198. var twoDimHoriz = 1;
  4199. var twoDimVert0 = 2;
  4200. var twoDimVertR1 = 3;
  4201. var twoDimVertL1 = 4;
  4202. var twoDimVertR2 = 5;
  4203. var twoDimVertL2 = 6;
  4204. var twoDimVertR3 = 7;
  4205. var twoDimVertL3 = 8;
  4206. var twoDimTable = [
  4207. [
  4208. -1,
  4209. -1
  4210. ],
  4211. [
  4212. -1,
  4213. -1
  4214. ],
  4215. [
  4216. 7,
  4217. twoDimVertL3
  4218. ],
  4219. [
  4220. 7,
  4221. twoDimVertR3
  4222. ],
  4223. [
  4224. 6,
  4225. twoDimVertL2
  4226. ],
  4227. [
  4228. 6,
  4229. twoDimVertL2
  4230. ],
  4231. [
  4232. 6,
  4233. twoDimVertR2
  4234. ],
  4235. [
  4236. 6,
  4237. twoDimVertR2
  4238. ],
  4239. [
  4240. 4,
  4241. twoDimPass
  4242. ],
  4243. [
  4244. 4,
  4245. twoDimPass
  4246. ],
  4247. [
  4248. 4,
  4249. twoDimPass
  4250. ],
  4251. [
  4252. 4,
  4253. twoDimPass
  4254. ],
  4255. [
  4256. 4,
  4257. twoDimPass
  4258. ],
  4259. [
  4260. 4,
  4261. twoDimPass
  4262. ],
  4263. [
  4264. 4,
  4265. twoDimPass
  4266. ],
  4267. [
  4268. 4,
  4269. twoDimPass
  4270. ],
  4271. [
  4272. 3,
  4273. twoDimHoriz
  4274. ],
  4275. [
  4276. 3,
  4277. twoDimHoriz
  4278. ],
  4279. [
  4280. 3,
  4281. twoDimHoriz
  4282. ],
  4283. [
  4284. 3,
  4285. twoDimHoriz
  4286. ],
  4287. [
  4288. 3,
  4289. twoDimHoriz
  4290. ],
  4291. [
  4292. 3,
  4293. twoDimHoriz
  4294. ],
  4295. [
  4296. 3,
  4297. twoDimHoriz
  4298. ],
  4299. [
  4300. 3,
  4301. twoDimHoriz
  4302. ],
  4303. [
  4304. 3,
  4305. twoDimHoriz
  4306. ],
  4307. [
  4308. 3,
  4309. twoDimHoriz
  4310. ],
  4311. [
  4312. 3,
  4313. twoDimHoriz
  4314. ],
  4315. [
  4316. 3,
  4317. twoDimHoriz
  4318. ],
  4319. [
  4320. 3,
  4321. twoDimHoriz
  4322. ],
  4323. [
  4324. 3,
  4325. twoDimHoriz
  4326. ],
  4327. [
  4328. 3,
  4329. twoDimHoriz
  4330. ],
  4331. [
  4332. 3,
  4333. twoDimHoriz
  4334. ],
  4335. [
  4336. 3,
  4337. twoDimVertL1
  4338. ],
  4339. [
  4340. 3,
  4341. twoDimVertL1
  4342. ],
  4343. [
  4344. 3,
  4345. twoDimVertL1
  4346. ],
  4347. [
  4348. 3,
  4349. twoDimVertL1
  4350. ],
  4351. [
  4352. 3,
  4353. twoDimVertL1
  4354. ],
  4355. [
  4356. 3,
  4357. twoDimVertL1
  4358. ],
  4359. [
  4360. 3,
  4361. twoDimVertL1
  4362. ],
  4363. [
  4364. 3,
  4365. twoDimVertL1
  4366. ],
  4367. [
  4368. 3,
  4369. twoDimVertL1
  4370. ],
  4371. [
  4372. 3,
  4373. twoDimVertL1
  4374. ],
  4375. [
  4376. 3,
  4377. twoDimVertL1
  4378. ],
  4379. [
  4380. 3,
  4381. twoDimVertL1
  4382. ],
  4383. [
  4384. 3,
  4385. twoDimVertL1
  4386. ],
  4387. [
  4388. 3,
  4389. twoDimVertL1
  4390. ],
  4391. [
  4392. 3,
  4393. twoDimVertL1
  4394. ],
  4395. [
  4396. 3,
  4397. twoDimVertL1
  4398. ],
  4399. [
  4400. 3,
  4401. twoDimVertR1
  4402. ],
  4403. [
  4404. 3,
  4405. twoDimVertR1
  4406. ],
  4407. [
  4408. 3,
  4409. twoDimVertR1
  4410. ],
  4411. [
  4412. 3,
  4413. twoDimVertR1
  4414. ],
  4415. [
  4416. 3,
  4417. twoDimVertR1
  4418. ],
  4419. [
  4420. 3,
  4421. twoDimVertR1
  4422. ],
  4423. [
  4424. 3,
  4425. twoDimVertR1
  4426. ],
  4427. [
  4428. 3,
  4429. twoDimVertR1
  4430. ],
  4431. [
  4432. 3,
  4433. twoDimVertR1
  4434. ],
  4435. [
  4436. 3,
  4437. twoDimVertR1
  4438. ],
  4439. [
  4440. 3,
  4441. twoDimVertR1
  4442. ],
  4443. [
  4444. 3,
  4445. twoDimVertR1
  4446. ],
  4447. [
  4448. 3,
  4449. twoDimVertR1
  4450. ],
  4451. [
  4452. 3,
  4453. twoDimVertR1
  4454. ],
  4455. [
  4456. 3,
  4457. twoDimVertR1
  4458. ],
  4459. [
  4460. 3,
  4461. twoDimVertR1
  4462. ],
  4463. [
  4464. 1,
  4465. twoDimVert0
  4466. ],
  4467. [
  4468. 1,
  4469. twoDimVert0
  4470. ],
  4471. [
  4472. 1,
  4473. twoDimVert0
  4474. ],
  4475. [
  4476. 1,
  4477. twoDimVert0
  4478. ],
  4479. [
  4480. 1,
  4481. twoDimVert0
  4482. ],
  4483. [
  4484. 1,
  4485. twoDimVert0
  4486. ],
  4487. [
  4488. 1,
  4489. twoDimVert0
  4490. ],
  4491. [
  4492. 1,
  4493. twoDimVert0
  4494. ],
  4495. [
  4496. 1,
  4497. twoDimVert0
  4498. ],
  4499. [
  4500. 1,
  4501. twoDimVert0
  4502. ],
  4503. [
  4504. 1,
  4505. twoDimVert0
  4506. ],
  4507. [
  4508. 1,
  4509. twoDimVert0
  4510. ],
  4511. [
  4512. 1,
  4513. twoDimVert0
  4514. ],
  4515. [
  4516. 1,
  4517. twoDimVert0
  4518. ],
  4519. [
  4520. 1,
  4521. twoDimVert0
  4522. ],
  4523. [
  4524. 1,
  4525. twoDimVert0
  4526. ],
  4527. [
  4528. 1,
  4529. twoDimVert0
  4530. ],
  4531. [
  4532. 1,
  4533. twoDimVert0
  4534. ],
  4535. [
  4536. 1,
  4537. twoDimVert0
  4538. ],
  4539. [
  4540. 1,
  4541. twoDimVert0
  4542. ],
  4543. [
  4544. 1,
  4545. twoDimVert0
  4546. ],
  4547. [
  4548. 1,
  4549. twoDimVert0
  4550. ],
  4551. [
  4552. 1,
  4553. twoDimVert0
  4554. ],
  4555. [
  4556. 1,
  4557. twoDimVert0
  4558. ],
  4559. [
  4560. 1,
  4561. twoDimVert0
  4562. ],
  4563. [
  4564. 1,
  4565. twoDimVert0
  4566. ],
  4567. [
  4568. 1,
  4569. twoDimVert0
  4570. ],
  4571. [
  4572. 1,
  4573. twoDimVert0
  4574. ],
  4575. [
  4576. 1,
  4577. twoDimVert0
  4578. ],
  4579. [
  4580. 1,
  4581. twoDimVert0
  4582. ],
  4583. [
  4584. 1,
  4585. twoDimVert0
  4586. ],
  4587. [
  4588. 1,
  4589. twoDimVert0
  4590. ],
  4591. [
  4592. 1,
  4593. twoDimVert0
  4594. ],
  4595. [
  4596. 1,
  4597. twoDimVert0
  4598. ],
  4599. [
  4600. 1,
  4601. twoDimVert0
  4602. ],
  4603. [
  4604. 1,
  4605. twoDimVert0
  4606. ],
  4607. [
  4608. 1,
  4609. twoDimVert0
  4610. ],
  4611. [
  4612. 1,
  4613. twoDimVert0
  4614. ],
  4615. [
  4616. 1,
  4617. twoDimVert0
  4618. ],
  4619. [
  4620. 1,
  4621. twoDimVert0
  4622. ],
  4623. [
  4624. 1,
  4625. twoDimVert0
  4626. ],
  4627. [
  4628. 1,
  4629. twoDimVert0
  4630. ],
  4631. [
  4632. 1,
  4633. twoDimVert0
  4634. ],
  4635. [
  4636. 1,
  4637. twoDimVert0
  4638. ],
  4639. [
  4640. 1,
  4641. twoDimVert0
  4642. ],
  4643. [
  4644. 1,
  4645. twoDimVert0
  4646. ],
  4647. [
  4648. 1,
  4649. twoDimVert0
  4650. ],
  4651. [
  4652. 1,
  4653. twoDimVert0
  4654. ],
  4655. [
  4656. 1,
  4657. twoDimVert0
  4658. ],
  4659. [
  4660. 1,
  4661. twoDimVert0
  4662. ],
  4663. [
  4664. 1,
  4665. twoDimVert0
  4666. ],
  4667. [
  4668. 1,
  4669. twoDimVert0
  4670. ],
  4671. [
  4672. 1,
  4673. twoDimVert0
  4674. ],
  4675. [
  4676. 1,
  4677. twoDimVert0
  4678. ],
  4679. [
  4680. 1,
  4681. twoDimVert0
  4682. ],
  4683. [
  4684. 1,
  4685. twoDimVert0
  4686. ],
  4687. [
  4688. 1,
  4689. twoDimVert0
  4690. ],
  4691. [
  4692. 1,
  4693. twoDimVert0
  4694. ],
  4695. [
  4696. 1,
  4697. twoDimVert0
  4698. ],
  4699. [
  4700. 1,
  4701. twoDimVert0
  4702. ],
  4703. [
  4704. 1,
  4705. twoDimVert0
  4706. ],
  4707. [
  4708. 1,
  4709. twoDimVert0
  4710. ],
  4711. [
  4712. 1,
  4713. twoDimVert0
  4714. ],
  4715. [
  4716. 1,
  4717. twoDimVert0
  4718. ]
  4719. ];
  4720. var whiteTable1 = [
  4721. [
  4722. -1,
  4723. -1
  4724. ],
  4725. [
  4726. 12,
  4727. ccittEOL
  4728. ],
  4729. [
  4730. -1,
  4731. -1
  4732. ],
  4733. [
  4734. -1,
  4735. -1
  4736. ],
  4737. [
  4738. -1,
  4739. -1
  4740. ],
  4741. [
  4742. -1,
  4743. -1
  4744. ],
  4745. [
  4746. -1,
  4747. -1
  4748. ],
  4749. [
  4750. -1,
  4751. -1
  4752. ],
  4753. [
  4754. -1,
  4755. -1
  4756. ],
  4757. [
  4758. -1,
  4759. -1
  4760. ],
  4761. [
  4762. -1,
  4763. -1
  4764. ],
  4765. [
  4766. -1,
  4767. -1
  4768. ],
  4769. [
  4770. -1,
  4771. -1
  4772. ],
  4773. [
  4774. -1,
  4775. -1
  4776. ],
  4777. [
  4778. -1,
  4779. -1
  4780. ],
  4781. [
  4782. -1,
  4783. -1
  4784. ],
  4785. [
  4786. 11,
  4787. 1792
  4788. ],
  4789. [
  4790. 11,
  4791. 1792
  4792. ],
  4793. [
  4794. 12,
  4795. 1984
  4796. ],
  4797. [
  4798. 12,
  4799. 2048
  4800. ],
  4801. [
  4802. 12,
  4803. 2112
  4804. ],
  4805. [
  4806. 12,
  4807. 2176
  4808. ],
  4809. [
  4810. 12,
  4811. 2240
  4812. ],
  4813. [
  4814. 12,
  4815. 2304
  4816. ],
  4817. [
  4818. 11,
  4819. 1856
  4820. ],
  4821. [
  4822. 11,
  4823. 1856
  4824. ],
  4825. [
  4826. 11,
  4827. 1920
  4828. ],
  4829. [
  4830. 11,
  4831. 1920
  4832. ],
  4833. [
  4834. 12,
  4835. 2368
  4836. ],
  4837. [
  4838. 12,
  4839. 2432
  4840. ],
  4841. [
  4842. 12,
  4843. 2496
  4844. ],
  4845. [
  4846. 12,
  4847. 2560
  4848. ]
  4849. ];
  4850. var whiteTable2 = [
  4851. [
  4852. -1,
  4853. -1
  4854. ],
  4855. [
  4856. -1,
  4857. -1
  4858. ],
  4859. [
  4860. -1,
  4861. -1
  4862. ],
  4863. [
  4864. -1,
  4865. -1
  4866. ],
  4867. [
  4868. 8,
  4869. 29
  4870. ],
  4871. [
  4872. 8,
  4873. 29
  4874. ],
  4875. [
  4876. 8,
  4877. 30
  4878. ],
  4879. [
  4880. 8,
  4881. 30
  4882. ],
  4883. [
  4884. 8,
  4885. 45
  4886. ],
  4887. [
  4888. 8,
  4889. 45
  4890. ],
  4891. [
  4892. 8,
  4893. 46
  4894. ],
  4895. [
  4896. 8,
  4897. 46
  4898. ],
  4899. [
  4900. 7,
  4901. 22
  4902. ],
  4903. [
  4904. 7,
  4905. 22
  4906. ],
  4907. [
  4908. 7,
  4909. 22
  4910. ],
  4911. [
  4912. 7,
  4913. 22
  4914. ],
  4915. [
  4916. 7,
  4917. 23
  4918. ],
  4919. [
  4920. 7,
  4921. 23
  4922. ],
  4923. [
  4924. 7,
  4925. 23
  4926. ],
  4927. [
  4928. 7,
  4929. 23
  4930. ],
  4931. [
  4932. 8,
  4933. 47
  4934. ],
  4935. [
  4936. 8,
  4937. 47
  4938. ],
  4939. [
  4940. 8,
  4941. 48
  4942. ],
  4943. [
  4944. 8,
  4945. 48
  4946. ],
  4947. [
  4948. 6,
  4949. 13
  4950. ],
  4951. [
  4952. 6,
  4953. 13
  4954. ],
  4955. [
  4956. 6,
  4957. 13
  4958. ],
  4959. [
  4960. 6,
  4961. 13
  4962. ],
  4963. [
  4964. 6,
  4965. 13
  4966. ],
  4967. [
  4968. 6,
  4969. 13
  4970. ],
  4971. [
  4972. 6,
  4973. 13
  4974. ],
  4975. [
  4976. 6,
  4977. 13
  4978. ],
  4979. [
  4980. 7,
  4981. 20
  4982. ],
  4983. [
  4984. 7,
  4985. 20
  4986. ],
  4987. [
  4988. 7,
  4989. 20
  4990. ],
  4991. [
  4992. 7,
  4993. 20
  4994. ],
  4995. [
  4996. 8,
  4997. 33
  4998. ],
  4999. [
  5000. 8,
  5001. 33
  5002. ],
  5003. [
  5004. 8,
  5005. 34
  5006. ],
  5007. [
  5008. 8,
  5009. 34
  5010. ],
  5011. [
  5012. 8,
  5013. 35
  5014. ],
  5015. [
  5016. 8,
  5017. 35
  5018. ],
  5019. [
  5020. 8,
  5021. 36
  5022. ],
  5023. [
  5024. 8,
  5025. 36
  5026. ],
  5027. [
  5028. 8,
  5029. 37
  5030. ],
  5031. [
  5032. 8,
  5033. 37
  5034. ],
  5035. [
  5036. 8,
  5037. 38
  5038. ],
  5039. [
  5040. 8,
  5041. 38
  5042. ],
  5043. [
  5044. 7,
  5045. 19
  5046. ],
  5047. [
  5048. 7,
  5049. 19
  5050. ],
  5051. [
  5052. 7,
  5053. 19
  5054. ],
  5055. [
  5056. 7,
  5057. 19
  5058. ],
  5059. [
  5060. 8,
  5061. 31
  5062. ],
  5063. [
  5064. 8,
  5065. 31
  5066. ],
  5067. [
  5068. 8,
  5069. 32
  5070. ],
  5071. [
  5072. 8,
  5073. 32
  5074. ],
  5075. [
  5076. 6,
  5077. 1
  5078. ],
  5079. [
  5080. 6,
  5081. 1
  5082. ],
  5083. [
  5084. 6,
  5085. 1
  5086. ],
  5087. [
  5088. 6,
  5089. 1
  5090. ],
  5091. [
  5092. 6,
  5093. 1
  5094. ],
  5095. [
  5096. 6,
  5097. 1
  5098. ],
  5099. [
  5100. 6,
  5101. 1
  5102. ],
  5103. [
  5104. 6,
  5105. 1
  5106. ],
  5107. [
  5108. 6,
  5109. 12
  5110. ],
  5111. [
  5112. 6,
  5113. 12
  5114. ],
  5115. [
  5116. 6,
  5117. 12
  5118. ],
  5119. [
  5120. 6,
  5121. 12
  5122. ],
  5123. [
  5124. 6,
  5125. 12
  5126. ],
  5127. [
  5128. 6,
  5129. 12
  5130. ],
  5131. [
  5132. 6,
  5133. 12
  5134. ],
  5135. [
  5136. 6,
  5137. 12
  5138. ],
  5139. [
  5140. 8,
  5141. 53
  5142. ],
  5143. [
  5144. 8,
  5145. 53
  5146. ],
  5147. [
  5148. 8,
  5149. 54
  5150. ],
  5151. [
  5152. 8,
  5153. 54
  5154. ],
  5155. [
  5156. 7,
  5157. 26
  5158. ],
  5159. [
  5160. 7,
  5161. 26
  5162. ],
  5163. [
  5164. 7,
  5165. 26
  5166. ],
  5167. [
  5168. 7,
  5169. 26
  5170. ],
  5171. [
  5172. 8,
  5173. 39
  5174. ],
  5175. [
  5176. 8,
  5177. 39
  5178. ],
  5179. [
  5180. 8,
  5181. 40
  5182. ],
  5183. [
  5184. 8,
  5185. 40
  5186. ],
  5187. [
  5188. 8,
  5189. 41
  5190. ],
  5191. [
  5192. 8,
  5193. 41
  5194. ],
  5195. [
  5196. 8,
  5197. 42
  5198. ],
  5199. [
  5200. 8,
  5201. 42
  5202. ],
  5203. [
  5204. 8,
  5205. 43
  5206. ],
  5207. [
  5208. 8,
  5209. 43
  5210. ],
  5211. [
  5212. 8,
  5213. 44
  5214. ],
  5215. [
  5216. 8,
  5217. 44
  5218. ],
  5219. [
  5220. 7,
  5221. 21
  5222. ],
  5223. [
  5224. 7,
  5225. 21
  5226. ],
  5227. [
  5228. 7,
  5229. 21
  5230. ],
  5231. [
  5232. 7,
  5233. 21
  5234. ],
  5235. [
  5236. 7,
  5237. 28
  5238. ],
  5239. [
  5240. 7,
  5241. 28
  5242. ],
  5243. [
  5244. 7,
  5245. 28
  5246. ],
  5247. [
  5248. 7,
  5249. 28
  5250. ],
  5251. [
  5252. 8,
  5253. 61
  5254. ],
  5255. [
  5256. 8,
  5257. 61
  5258. ],
  5259. [
  5260. 8,
  5261. 62
  5262. ],
  5263. [
  5264. 8,
  5265. 62
  5266. ],
  5267. [
  5268. 8,
  5269. 63
  5270. ],
  5271. [
  5272. 8,
  5273. 63
  5274. ],
  5275. [
  5276. 8,
  5277. 0
  5278. ],
  5279. [
  5280. 8,
  5281. 0
  5282. ],
  5283. [
  5284. 8,
  5285. 320
  5286. ],
  5287. [
  5288. 8,
  5289. 320
  5290. ],
  5291. [
  5292. 8,
  5293. 384
  5294. ],
  5295. [
  5296. 8,
  5297. 384
  5298. ],
  5299. [
  5300. 5,
  5301. 10
  5302. ],
  5303. [
  5304. 5,
  5305. 10
  5306. ],
  5307. [
  5308. 5,
  5309. 10
  5310. ],
  5311. [
  5312. 5,
  5313. 10
  5314. ],
  5315. [
  5316. 5,
  5317. 10
  5318. ],
  5319. [
  5320. 5,
  5321. 10
  5322. ],
  5323. [
  5324. 5,
  5325. 10
  5326. ],
  5327. [
  5328. 5,
  5329. 10
  5330. ],
  5331. [
  5332. 5,
  5333. 10
  5334. ],
  5335. [
  5336. 5,
  5337. 10
  5338. ],
  5339. [
  5340. 5,
  5341. 10
  5342. ],
  5343. [
  5344. 5,
  5345. 10
  5346. ],
  5347. [
  5348. 5,
  5349. 10
  5350. ],
  5351. [
  5352. 5,
  5353. 10
  5354. ],
  5355. [
  5356. 5,
  5357. 10
  5358. ],
  5359. [
  5360. 5,
  5361. 10
  5362. ],
  5363. [
  5364. 5,
  5365. 11
  5366. ],
  5367. [
  5368. 5,
  5369. 11
  5370. ],
  5371. [
  5372. 5,
  5373. 11
  5374. ],
  5375. [
  5376. 5,
  5377. 11
  5378. ],
  5379. [
  5380. 5,
  5381. 11
  5382. ],
  5383. [
  5384. 5,
  5385. 11
  5386. ],
  5387. [
  5388. 5,
  5389. 11
  5390. ],
  5391. [
  5392. 5,
  5393. 11
  5394. ],
  5395. [
  5396. 5,
  5397. 11
  5398. ],
  5399. [
  5400. 5,
  5401. 11
  5402. ],
  5403. [
  5404. 5,
  5405. 11
  5406. ],
  5407. [
  5408. 5,
  5409. 11
  5410. ],
  5411. [
  5412. 5,
  5413. 11
  5414. ],
  5415. [
  5416. 5,
  5417. 11
  5418. ],
  5419. [
  5420. 5,
  5421. 11
  5422. ],
  5423. [
  5424. 5,
  5425. 11
  5426. ],
  5427. [
  5428. 7,
  5429. 27
  5430. ],
  5431. [
  5432. 7,
  5433. 27
  5434. ],
  5435. [
  5436. 7,
  5437. 27
  5438. ],
  5439. [
  5440. 7,
  5441. 27
  5442. ],
  5443. [
  5444. 8,
  5445. 59
  5446. ],
  5447. [
  5448. 8,
  5449. 59
  5450. ],
  5451. [
  5452. 8,
  5453. 60
  5454. ],
  5455. [
  5456. 8,
  5457. 60
  5458. ],
  5459. [
  5460. 9,
  5461. 1472
  5462. ],
  5463. [
  5464. 9,
  5465. 1536
  5466. ],
  5467. [
  5468. 9,
  5469. 1600
  5470. ],
  5471. [
  5472. 9,
  5473. 1728
  5474. ],
  5475. [
  5476. 7,
  5477. 18
  5478. ],
  5479. [
  5480. 7,
  5481. 18
  5482. ],
  5483. [
  5484. 7,
  5485. 18
  5486. ],
  5487. [
  5488. 7,
  5489. 18
  5490. ],
  5491. [
  5492. 7,
  5493. 24
  5494. ],
  5495. [
  5496. 7,
  5497. 24
  5498. ],
  5499. [
  5500. 7,
  5501. 24
  5502. ],
  5503. [
  5504. 7,
  5505. 24
  5506. ],
  5507. [
  5508. 8,
  5509. 49
  5510. ],
  5511. [
  5512. 8,
  5513. 49
  5514. ],
  5515. [
  5516. 8,
  5517. 50
  5518. ],
  5519. [
  5520. 8,
  5521. 50
  5522. ],
  5523. [
  5524. 8,
  5525. 51
  5526. ],
  5527. [
  5528. 8,
  5529. 51
  5530. ],
  5531. [
  5532. 8,
  5533. 52
  5534. ],
  5535. [
  5536. 8,
  5537. 52
  5538. ],
  5539. [
  5540. 7,
  5541. 25
  5542. ],
  5543. [
  5544. 7,
  5545. 25
  5546. ],
  5547. [
  5548. 7,
  5549. 25
  5550. ],
  5551. [
  5552. 7,
  5553. 25
  5554. ],
  5555. [
  5556. 8,
  5557. 55
  5558. ],
  5559. [
  5560. 8,
  5561. 55
  5562. ],
  5563. [
  5564. 8,
  5565. 56
  5566. ],
  5567. [
  5568. 8,
  5569. 56
  5570. ],
  5571. [
  5572. 8,
  5573. 57
  5574. ],
  5575. [
  5576. 8,
  5577. 57
  5578. ],
  5579. [
  5580. 8,
  5581. 58
  5582. ],
  5583. [
  5584. 8,
  5585. 58
  5586. ],
  5587. [
  5588. 6,
  5589. 192
  5590. ],
  5591. [
  5592. 6,
  5593. 192
  5594. ],
  5595. [
  5596. 6,
  5597. 192
  5598. ],
  5599. [
  5600. 6,
  5601. 192
  5602. ],
  5603. [
  5604. 6,
  5605. 192
  5606. ],
  5607. [
  5608. 6,
  5609. 192
  5610. ],
  5611. [
  5612. 6,
  5613. 192
  5614. ],
  5615. [
  5616. 6,
  5617. 192
  5618. ],
  5619. [
  5620. 6,
  5621. 1664
  5622. ],
  5623. [
  5624. 6,
  5625. 1664
  5626. ],
  5627. [
  5628. 6,
  5629. 1664
  5630. ],
  5631. [
  5632. 6,
  5633. 1664
  5634. ],
  5635. [
  5636. 6,
  5637. 1664
  5638. ],
  5639. [
  5640. 6,
  5641. 1664
  5642. ],
  5643. [
  5644. 6,
  5645. 1664
  5646. ],
  5647. [
  5648. 6,
  5649. 1664
  5650. ],
  5651. [
  5652. 8,
  5653. 448
  5654. ],
  5655. [
  5656. 8,
  5657. 448
  5658. ],
  5659. [
  5660. 8,
  5661. 512
  5662. ],
  5663. [
  5664. 8,
  5665. 512
  5666. ],
  5667. [
  5668. 9,
  5669. 704
  5670. ],
  5671. [
  5672. 9,
  5673. 768
  5674. ],
  5675. [
  5676. 8,
  5677. 640
  5678. ],
  5679. [
  5680. 8,
  5681. 640
  5682. ],
  5683. [
  5684. 8,
  5685. 576
  5686. ],
  5687. [
  5688. 8,
  5689. 576
  5690. ],
  5691. [
  5692. 9,
  5693. 832
  5694. ],
  5695. [
  5696. 9,
  5697. 896
  5698. ],
  5699. [
  5700. 9,
  5701. 960
  5702. ],
  5703. [
  5704. 9,
  5705. 1024
  5706. ],
  5707. [
  5708. 9,
  5709. 1088
  5710. ],
  5711. [
  5712. 9,
  5713. 1152
  5714. ],
  5715. [
  5716. 9,
  5717. 1216
  5718. ],
  5719. [
  5720. 9,
  5721. 1280
  5722. ],
  5723. [
  5724. 9,
  5725. 1344
  5726. ],
  5727. [
  5728. 9,
  5729. 1408
  5730. ],
  5731. [
  5732. 7,
  5733. 256
  5734. ],
  5735. [
  5736. 7,
  5737. 256
  5738. ],
  5739. [
  5740. 7,
  5741. 256
  5742. ],
  5743. [
  5744. 7,
  5745. 256
  5746. ],
  5747. [
  5748. 4,
  5749. 2
  5750. ],
  5751. [
  5752. 4,
  5753. 2
  5754. ],
  5755. [
  5756. 4,
  5757. 2
  5758. ],
  5759. [
  5760. 4,
  5761. 2
  5762. ],
  5763. [
  5764. 4,
  5765. 2
  5766. ],
  5767. [
  5768. 4,
  5769. 2
  5770. ],
  5771. [
  5772. 4,
  5773. 2
  5774. ],
  5775. [
  5776. 4,
  5777. 2
  5778. ],
  5779. [
  5780. 4,
  5781. 2
  5782. ],
  5783. [
  5784. 4,
  5785. 2
  5786. ],
  5787. [
  5788. 4,
  5789. 2
  5790. ],
  5791. [
  5792. 4,
  5793. 2
  5794. ],
  5795. [
  5796. 4,
  5797. 2
  5798. ],
  5799. [
  5800. 4,
  5801. 2
  5802. ],
  5803. [
  5804. 4,
  5805. 2
  5806. ],
  5807. [
  5808. 4,
  5809. 2
  5810. ],
  5811. [
  5812. 4,
  5813. 2
  5814. ],
  5815. [
  5816. 4,
  5817. 2
  5818. ],
  5819. [
  5820. 4,
  5821. 2
  5822. ],
  5823. [
  5824. 4,
  5825. 2
  5826. ],
  5827. [
  5828. 4,
  5829. 2
  5830. ],
  5831. [
  5832. 4,
  5833. 2
  5834. ],
  5835. [
  5836. 4,
  5837. 2
  5838. ],
  5839. [
  5840. 4,
  5841. 2
  5842. ],
  5843. [
  5844. 4,
  5845. 2
  5846. ],
  5847. [
  5848. 4,
  5849. 2
  5850. ],
  5851. [
  5852. 4,
  5853. 2
  5854. ],
  5855. [
  5856. 4,
  5857. 2
  5858. ],
  5859. [
  5860. 4,
  5861. 2
  5862. ],
  5863. [
  5864. 4,
  5865. 2
  5866. ],
  5867. [
  5868. 4,
  5869. 2
  5870. ],
  5871. [
  5872. 4,
  5873. 2
  5874. ],
  5875. [
  5876. 4,
  5877. 3
  5878. ],
  5879. [
  5880. 4,
  5881. 3
  5882. ],
  5883. [
  5884. 4,
  5885. 3
  5886. ],
  5887. [
  5888. 4,
  5889. 3
  5890. ],
  5891. [
  5892. 4,
  5893. 3
  5894. ],
  5895. [
  5896. 4,
  5897. 3
  5898. ],
  5899. [
  5900. 4,
  5901. 3
  5902. ],
  5903. [
  5904. 4,
  5905. 3
  5906. ],
  5907. [
  5908. 4,
  5909. 3
  5910. ],
  5911. [
  5912. 4,
  5913. 3
  5914. ],
  5915. [
  5916. 4,
  5917. 3
  5918. ],
  5919. [
  5920. 4,
  5921. 3
  5922. ],
  5923. [
  5924. 4,
  5925. 3
  5926. ],
  5927. [
  5928. 4,
  5929. 3
  5930. ],
  5931. [
  5932. 4,
  5933. 3
  5934. ],
  5935. [
  5936. 4,
  5937. 3
  5938. ],
  5939. [
  5940. 4,
  5941. 3
  5942. ],
  5943. [
  5944. 4,
  5945. 3
  5946. ],
  5947. [
  5948. 4,
  5949. 3
  5950. ],
  5951. [
  5952. 4,
  5953. 3
  5954. ],
  5955. [
  5956. 4,
  5957. 3
  5958. ],
  5959. [
  5960. 4,
  5961. 3
  5962. ],
  5963. [
  5964. 4,
  5965. 3
  5966. ],
  5967. [
  5968. 4,
  5969. 3
  5970. ],
  5971. [
  5972. 4,
  5973. 3
  5974. ],
  5975. [
  5976. 4,
  5977. 3
  5978. ],
  5979. [
  5980. 4,
  5981. 3
  5982. ],
  5983. [
  5984. 4,
  5985. 3
  5986. ],
  5987. [
  5988. 4,
  5989. 3
  5990. ],
  5991. [
  5992. 4,
  5993. 3
  5994. ],
  5995. [
  5996. 4,
  5997. 3
  5998. ],
  5999. [
  6000. 4,
  6001. 3
  6002. ],
  6003. [
  6004. 5,
  6005. 128
  6006. ],
  6007. [
  6008. 5,
  6009. 128
  6010. ],
  6011. [
  6012. 5,
  6013. 128
  6014. ],
  6015. [
  6016. 5,
  6017. 128
  6018. ],
  6019. [
  6020. 5,
  6021. 128
  6022. ],
  6023. [
  6024. 5,
  6025. 128
  6026. ],
  6027. [
  6028. 5,
  6029. 128
  6030. ],
  6031. [
  6032. 5,
  6033. 128
  6034. ],
  6035. [
  6036. 5,
  6037. 128
  6038. ],
  6039. [
  6040. 5,
  6041. 128
  6042. ],
  6043. [
  6044. 5,
  6045. 128
  6046. ],
  6047. [
  6048. 5,
  6049. 128
  6050. ],
  6051. [
  6052. 5,
  6053. 128
  6054. ],
  6055. [
  6056. 5,
  6057. 128
  6058. ],
  6059. [
  6060. 5,
  6061. 128
  6062. ],
  6063. [
  6064. 5,
  6065. 128
  6066. ],
  6067. [
  6068. 5,
  6069. 8
  6070. ],
  6071. [
  6072. 5,
  6073. 8
  6074. ],
  6075. [
  6076. 5,
  6077. 8
  6078. ],
  6079. [
  6080. 5,
  6081. 8
  6082. ],
  6083. [
  6084. 5,
  6085. 8
  6086. ],
  6087. [
  6088. 5,
  6089. 8
  6090. ],
  6091. [
  6092. 5,
  6093. 8
  6094. ],
  6095. [
  6096. 5,
  6097. 8
  6098. ],
  6099. [
  6100. 5,
  6101. 8
  6102. ],
  6103. [
  6104. 5,
  6105. 8
  6106. ],
  6107. [
  6108. 5,
  6109. 8
  6110. ],
  6111. [
  6112. 5,
  6113. 8
  6114. ],
  6115. [
  6116. 5,
  6117. 8
  6118. ],
  6119. [
  6120. 5,
  6121. 8
  6122. ],
  6123. [
  6124. 5,
  6125. 8
  6126. ],
  6127. [
  6128. 5,
  6129. 8
  6130. ],
  6131. [
  6132. 5,
  6133. 9
  6134. ],
  6135. [
  6136. 5,
  6137. 9
  6138. ],
  6139. [
  6140. 5,
  6141. 9
  6142. ],
  6143. [
  6144. 5,
  6145. 9
  6146. ],
  6147. [
  6148. 5,
  6149. 9
  6150. ],
  6151. [
  6152. 5,
  6153. 9
  6154. ],
  6155. [
  6156. 5,
  6157. 9
  6158. ],
  6159. [
  6160. 5,
  6161. 9
  6162. ],
  6163. [
  6164. 5,
  6165. 9
  6166. ],
  6167. [
  6168. 5,
  6169. 9
  6170. ],
  6171. [
  6172. 5,
  6173. 9
  6174. ],
  6175. [
  6176. 5,
  6177. 9
  6178. ],
  6179. [
  6180. 5,
  6181. 9
  6182. ],
  6183. [
  6184. 5,
  6185. 9
  6186. ],
  6187. [
  6188. 5,
  6189. 9
  6190. ],
  6191. [
  6192. 5,
  6193. 9
  6194. ],
  6195. [
  6196. 6,
  6197. 16
  6198. ],
  6199. [
  6200. 6,
  6201. 16
  6202. ],
  6203. [
  6204. 6,
  6205. 16
  6206. ],
  6207. [
  6208. 6,
  6209. 16
  6210. ],
  6211. [
  6212. 6,
  6213. 16
  6214. ],
  6215. [
  6216. 6,
  6217. 16
  6218. ],
  6219. [
  6220. 6,
  6221. 16
  6222. ],
  6223. [
  6224. 6,
  6225. 16
  6226. ],
  6227. [
  6228. 6,
  6229. 17
  6230. ],
  6231. [
  6232. 6,
  6233. 17
  6234. ],
  6235. [
  6236. 6,
  6237. 17
  6238. ],
  6239. [
  6240. 6,
  6241. 17
  6242. ],
  6243. [
  6244. 6,
  6245. 17
  6246. ],
  6247. [
  6248. 6,
  6249. 17
  6250. ],
  6251. [
  6252. 6,
  6253. 17
  6254. ],
  6255. [
  6256. 6,
  6257. 17
  6258. ],
  6259. [
  6260. 4,
  6261. 4
  6262. ],
  6263. [
  6264. 4,
  6265. 4
  6266. ],
  6267. [
  6268. 4,
  6269. 4
  6270. ],
  6271. [
  6272. 4,
  6273. 4
  6274. ],
  6275. [
  6276. 4,
  6277. 4
  6278. ],
  6279. [
  6280. 4,
  6281. 4
  6282. ],
  6283. [
  6284. 4,
  6285. 4
  6286. ],
  6287. [
  6288. 4,
  6289. 4
  6290. ],
  6291. [
  6292. 4,
  6293. 4
  6294. ],
  6295. [
  6296. 4,
  6297. 4
  6298. ],
  6299. [
  6300. 4,
  6301. 4
  6302. ],
  6303. [
  6304. 4,
  6305. 4
  6306. ],
  6307. [
  6308. 4,
  6309. 4
  6310. ],
  6311. [
  6312. 4,
  6313. 4
  6314. ],
  6315. [
  6316. 4,
  6317. 4
  6318. ],
  6319. [
  6320. 4,
  6321. 4
  6322. ],
  6323. [
  6324. 4,
  6325. 4
  6326. ],
  6327. [
  6328. 4,
  6329. 4
  6330. ],
  6331. [
  6332. 4,
  6333. 4
  6334. ],
  6335. [
  6336. 4,
  6337. 4
  6338. ],
  6339. [
  6340. 4,
  6341. 4
  6342. ],
  6343. [
  6344. 4,
  6345. 4
  6346. ],
  6347. [
  6348. 4,
  6349. 4
  6350. ],
  6351. [
  6352. 4,
  6353. 4
  6354. ],
  6355. [
  6356. 4,
  6357. 4
  6358. ],
  6359. [
  6360. 4,
  6361. 4
  6362. ],
  6363. [
  6364. 4,
  6365. 4
  6366. ],
  6367. [
  6368. 4,
  6369. 4
  6370. ],
  6371. [
  6372. 4,
  6373. 4
  6374. ],
  6375. [
  6376. 4,
  6377. 4
  6378. ],
  6379. [
  6380. 4,
  6381. 4
  6382. ],
  6383. [
  6384. 4,
  6385. 4
  6386. ],
  6387. [
  6388. 4,
  6389. 5
  6390. ],
  6391. [
  6392. 4,
  6393. 5
  6394. ],
  6395. [
  6396. 4,
  6397. 5
  6398. ],
  6399. [
  6400. 4,
  6401. 5
  6402. ],
  6403. [
  6404. 4,
  6405. 5
  6406. ],
  6407. [
  6408. 4,
  6409. 5
  6410. ],
  6411. [
  6412. 4,
  6413. 5
  6414. ],
  6415. [
  6416. 4,
  6417. 5
  6418. ],
  6419. [
  6420. 4,
  6421. 5
  6422. ],
  6423. [
  6424. 4,
  6425. 5
  6426. ],
  6427. [
  6428. 4,
  6429. 5
  6430. ],
  6431. [
  6432. 4,
  6433. 5
  6434. ],
  6435. [
  6436. 4,
  6437. 5
  6438. ],
  6439. [
  6440. 4,
  6441. 5
  6442. ],
  6443. [
  6444. 4,
  6445. 5
  6446. ],
  6447. [
  6448. 4,
  6449. 5
  6450. ],
  6451. [
  6452. 4,
  6453. 5
  6454. ],
  6455. [
  6456. 4,
  6457. 5
  6458. ],
  6459. [
  6460. 4,
  6461. 5
  6462. ],
  6463. [
  6464. 4,
  6465. 5
  6466. ],
  6467. [
  6468. 4,
  6469. 5
  6470. ],
  6471. [
  6472. 4,
  6473. 5
  6474. ],
  6475. [
  6476. 4,
  6477. 5
  6478. ],
  6479. [
  6480. 4,
  6481. 5
  6482. ],
  6483. [
  6484. 4,
  6485. 5
  6486. ],
  6487. [
  6488. 4,
  6489. 5
  6490. ],
  6491. [
  6492. 4,
  6493. 5
  6494. ],
  6495. [
  6496. 4,
  6497. 5
  6498. ],
  6499. [
  6500. 4,
  6501. 5
  6502. ],
  6503. [
  6504. 4,
  6505. 5
  6506. ],
  6507. [
  6508. 4,
  6509. 5
  6510. ],
  6511. [
  6512. 4,
  6513. 5
  6514. ],
  6515. [
  6516. 6,
  6517. 14
  6518. ],
  6519. [
  6520. 6,
  6521. 14
  6522. ],
  6523. [
  6524. 6,
  6525. 14
  6526. ],
  6527. [
  6528. 6,
  6529. 14
  6530. ],
  6531. [
  6532. 6,
  6533. 14
  6534. ],
  6535. [
  6536. 6,
  6537. 14
  6538. ],
  6539. [
  6540. 6,
  6541. 14
  6542. ],
  6543. [
  6544. 6,
  6545. 14
  6546. ],
  6547. [
  6548. 6,
  6549. 15
  6550. ],
  6551. [
  6552. 6,
  6553. 15
  6554. ],
  6555. [
  6556. 6,
  6557. 15
  6558. ],
  6559. [
  6560. 6,
  6561. 15
  6562. ],
  6563. [
  6564. 6,
  6565. 15
  6566. ],
  6567. [
  6568. 6,
  6569. 15
  6570. ],
  6571. [
  6572. 6,
  6573. 15
  6574. ],
  6575. [
  6576. 6,
  6577. 15
  6578. ],
  6579. [
  6580. 5,
  6581. 64
  6582. ],
  6583. [
  6584. 5,
  6585. 64
  6586. ],
  6587. [
  6588. 5,
  6589. 64
  6590. ],
  6591. [
  6592. 5,
  6593. 64
  6594. ],
  6595. [
  6596. 5,
  6597. 64
  6598. ],
  6599. [
  6600. 5,
  6601. 64
  6602. ],
  6603. [
  6604. 5,
  6605. 64
  6606. ],
  6607. [
  6608. 5,
  6609. 64
  6610. ],
  6611. [
  6612. 5,
  6613. 64
  6614. ],
  6615. [
  6616. 5,
  6617. 64
  6618. ],
  6619. [
  6620. 5,
  6621. 64
  6622. ],
  6623. [
  6624. 5,
  6625. 64
  6626. ],
  6627. [
  6628. 5,
  6629. 64
  6630. ],
  6631. [
  6632. 5,
  6633. 64
  6634. ],
  6635. [
  6636. 5,
  6637. 64
  6638. ],
  6639. [
  6640. 5,
  6641. 64
  6642. ],
  6643. [
  6644. 4,
  6645. 6
  6646. ],
  6647. [
  6648. 4,
  6649. 6
  6650. ],
  6651. [
  6652. 4,
  6653. 6
  6654. ],
  6655. [
  6656. 4,
  6657. 6
  6658. ],
  6659. [
  6660. 4,
  6661. 6
  6662. ],
  6663. [
  6664. 4,
  6665. 6
  6666. ],
  6667. [
  6668. 4,
  6669. 6
  6670. ],
  6671. [
  6672. 4,
  6673. 6
  6674. ],
  6675. [
  6676. 4,
  6677. 6
  6678. ],
  6679. [
  6680. 4,
  6681. 6
  6682. ],
  6683. [
  6684. 4,
  6685. 6
  6686. ],
  6687. [
  6688. 4,
  6689. 6
  6690. ],
  6691. [
  6692. 4,
  6693. 6
  6694. ],
  6695. [
  6696. 4,
  6697. 6
  6698. ],
  6699. [
  6700. 4,
  6701. 6
  6702. ],
  6703. [
  6704. 4,
  6705. 6
  6706. ],
  6707. [
  6708. 4,
  6709. 6
  6710. ],
  6711. [
  6712. 4,
  6713. 6
  6714. ],
  6715. [
  6716. 4,
  6717. 6
  6718. ],
  6719. [
  6720. 4,
  6721. 6
  6722. ],
  6723. [
  6724. 4,
  6725. 6
  6726. ],
  6727. [
  6728. 4,
  6729. 6
  6730. ],
  6731. [
  6732. 4,
  6733. 6
  6734. ],
  6735. [
  6736. 4,
  6737. 6
  6738. ],
  6739. [
  6740. 4,
  6741. 6
  6742. ],
  6743. [
  6744. 4,
  6745. 6
  6746. ],
  6747. [
  6748. 4,
  6749. 6
  6750. ],
  6751. [
  6752. 4,
  6753. 6
  6754. ],
  6755. [
  6756. 4,
  6757. 6
  6758. ],
  6759. [
  6760. 4,
  6761. 6
  6762. ],
  6763. [
  6764. 4,
  6765. 6
  6766. ],
  6767. [
  6768. 4,
  6769. 6
  6770. ],
  6771. [
  6772. 4,
  6773. 7
  6774. ],
  6775. [
  6776. 4,
  6777. 7
  6778. ],
  6779. [
  6780. 4,
  6781. 7
  6782. ],
  6783. [
  6784. 4,
  6785. 7
  6786. ],
  6787. [
  6788. 4,
  6789. 7
  6790. ],
  6791. [
  6792. 4,
  6793. 7
  6794. ],
  6795. [
  6796. 4,
  6797. 7
  6798. ],
  6799. [
  6800. 4,
  6801. 7
  6802. ],
  6803. [
  6804. 4,
  6805. 7
  6806. ],
  6807. [
  6808. 4,
  6809. 7
  6810. ],
  6811. [
  6812. 4,
  6813. 7
  6814. ],
  6815. [
  6816. 4,
  6817. 7
  6818. ],
  6819. [
  6820. 4,
  6821. 7
  6822. ],
  6823. [
  6824. 4,
  6825. 7
  6826. ],
  6827. [
  6828. 4,
  6829. 7
  6830. ],
  6831. [
  6832. 4,
  6833. 7
  6834. ],
  6835. [
  6836. 4,
  6837. 7
  6838. ],
  6839. [
  6840. 4,
  6841. 7
  6842. ],
  6843. [
  6844. 4,
  6845. 7
  6846. ],
  6847. [
  6848. 4,
  6849. 7
  6850. ],
  6851. [
  6852. 4,
  6853. 7
  6854. ],
  6855. [
  6856. 4,
  6857. 7
  6858. ],
  6859. [
  6860. 4,
  6861. 7
  6862. ],
  6863. [
  6864. 4,
  6865. 7
  6866. ],
  6867. [
  6868. 4,
  6869. 7
  6870. ],
  6871. [
  6872. 4,
  6873. 7
  6874. ],
  6875. [
  6876. 4,
  6877. 7
  6878. ],
  6879. [
  6880. 4,
  6881. 7
  6882. ],
  6883. [
  6884. 4,
  6885. 7
  6886. ],
  6887. [
  6888. 4,
  6889. 7
  6890. ],
  6891. [
  6892. 4,
  6893. 7
  6894. ],
  6895. [
  6896. 4,
  6897. 7
  6898. ]
  6899. ];
  6900. var blackTable1 = [
  6901. [
  6902. -1,
  6903. -1
  6904. ],
  6905. [
  6906. -1,
  6907. -1
  6908. ],
  6909. [
  6910. 12,
  6911. ccittEOL
  6912. ],
  6913. [
  6914. 12,
  6915. ccittEOL
  6916. ],
  6917. [
  6918. -1,
  6919. -1
  6920. ],
  6921. [
  6922. -1,
  6923. -1
  6924. ],
  6925. [
  6926. -1,
  6927. -1
  6928. ],
  6929. [
  6930. -1,
  6931. -1
  6932. ],
  6933. [
  6934. -1,
  6935. -1
  6936. ],
  6937. [
  6938. -1,
  6939. -1
  6940. ],
  6941. [
  6942. -1,
  6943. -1
  6944. ],
  6945. [
  6946. -1,
  6947. -1
  6948. ],
  6949. [
  6950. -1,
  6951. -1
  6952. ],
  6953. [
  6954. -1,
  6955. -1
  6956. ],
  6957. [
  6958. -1,
  6959. -1
  6960. ],
  6961. [
  6962. -1,
  6963. -1
  6964. ],
  6965. [
  6966. -1,
  6967. -1
  6968. ],
  6969. [
  6970. -1,
  6971. -1
  6972. ],
  6973. [
  6974. -1,
  6975. -1
  6976. ],
  6977. [
  6978. -1,
  6979. -1
  6980. ],
  6981. [
  6982. -1,
  6983. -1
  6984. ],
  6985. [
  6986. -1,
  6987. -1
  6988. ],
  6989. [
  6990. -1,
  6991. -1
  6992. ],
  6993. [
  6994. -1,
  6995. -1
  6996. ],
  6997. [
  6998. -1,
  6999. -1
  7000. ],
  7001. [
  7002. -1,
  7003. -1
  7004. ],
  7005. [
  7006. -1,
  7007. -1
  7008. ],
  7009. [
  7010. -1,
  7011. -1
  7012. ],
  7013. [
  7014. -1,
  7015. -1
  7016. ],
  7017. [
  7018. -1,
  7019. -1
  7020. ],
  7021. [
  7022. -1,
  7023. -1
  7024. ],
  7025. [
  7026. -1,
  7027. -1
  7028. ],
  7029. [
  7030. 11,
  7031. 1792
  7032. ],
  7033. [
  7034. 11,
  7035. 1792
  7036. ],
  7037. [
  7038. 11,
  7039. 1792
  7040. ],
  7041. [
  7042. 11,
  7043. 1792
  7044. ],
  7045. [
  7046. 12,
  7047. 1984
  7048. ],
  7049. [
  7050. 12,
  7051. 1984
  7052. ],
  7053. [
  7054. 12,
  7055. 2048
  7056. ],
  7057. [
  7058. 12,
  7059. 2048
  7060. ],
  7061. [
  7062. 12,
  7063. 2112
  7064. ],
  7065. [
  7066. 12,
  7067. 2112
  7068. ],
  7069. [
  7070. 12,
  7071. 2176
  7072. ],
  7073. [
  7074. 12,
  7075. 2176
  7076. ],
  7077. [
  7078. 12,
  7079. 2240
  7080. ],
  7081. [
  7082. 12,
  7083. 2240
  7084. ],
  7085. [
  7086. 12,
  7087. 2304
  7088. ],
  7089. [
  7090. 12,
  7091. 2304
  7092. ],
  7093. [
  7094. 11,
  7095. 1856
  7096. ],
  7097. [
  7098. 11,
  7099. 1856
  7100. ],
  7101. [
  7102. 11,
  7103. 1856
  7104. ],
  7105. [
  7106. 11,
  7107. 1856
  7108. ],
  7109. [
  7110. 11,
  7111. 1920
  7112. ],
  7113. [
  7114. 11,
  7115. 1920
  7116. ],
  7117. [
  7118. 11,
  7119. 1920
  7120. ],
  7121. [
  7122. 11,
  7123. 1920
  7124. ],
  7125. [
  7126. 12,
  7127. 2368
  7128. ],
  7129. [
  7130. 12,
  7131. 2368
  7132. ],
  7133. [
  7134. 12,
  7135. 2432
  7136. ],
  7137. [
  7138. 12,
  7139. 2432
  7140. ],
  7141. [
  7142. 12,
  7143. 2496
  7144. ],
  7145. [
  7146. 12,
  7147. 2496
  7148. ],
  7149. [
  7150. 12,
  7151. 2560
  7152. ],
  7153. [
  7154. 12,
  7155. 2560
  7156. ],
  7157. [
  7158. 10,
  7159. 18
  7160. ],
  7161. [
  7162. 10,
  7163. 18
  7164. ],
  7165. [
  7166. 10,
  7167. 18
  7168. ],
  7169. [
  7170. 10,
  7171. 18
  7172. ],
  7173. [
  7174. 10,
  7175. 18
  7176. ],
  7177. [
  7178. 10,
  7179. 18
  7180. ],
  7181. [
  7182. 10,
  7183. 18
  7184. ],
  7185. [
  7186. 10,
  7187. 18
  7188. ],
  7189. [
  7190. 12,
  7191. 52
  7192. ],
  7193. [
  7194. 12,
  7195. 52
  7196. ],
  7197. [
  7198. 13,
  7199. 640
  7200. ],
  7201. [
  7202. 13,
  7203. 704
  7204. ],
  7205. [
  7206. 13,
  7207. 768
  7208. ],
  7209. [
  7210. 13,
  7211. 832
  7212. ],
  7213. [
  7214. 12,
  7215. 55
  7216. ],
  7217. [
  7218. 12,
  7219. 55
  7220. ],
  7221. [
  7222. 12,
  7223. 56
  7224. ],
  7225. [
  7226. 12,
  7227. 56
  7228. ],
  7229. [
  7230. 13,
  7231. 1280
  7232. ],
  7233. [
  7234. 13,
  7235. 1344
  7236. ],
  7237. [
  7238. 13,
  7239. 1408
  7240. ],
  7241. [
  7242. 13,
  7243. 1472
  7244. ],
  7245. [
  7246. 12,
  7247. 59
  7248. ],
  7249. [
  7250. 12,
  7251. 59
  7252. ],
  7253. [
  7254. 12,
  7255. 60
  7256. ],
  7257. [
  7258. 12,
  7259. 60
  7260. ],
  7261. [
  7262. 13,
  7263. 1536
  7264. ],
  7265. [
  7266. 13,
  7267. 1600
  7268. ],
  7269. [
  7270. 11,
  7271. 24
  7272. ],
  7273. [
  7274. 11,
  7275. 24
  7276. ],
  7277. [
  7278. 11,
  7279. 24
  7280. ],
  7281. [
  7282. 11,
  7283. 24
  7284. ],
  7285. [
  7286. 11,
  7287. 25
  7288. ],
  7289. [
  7290. 11,
  7291. 25
  7292. ],
  7293. [
  7294. 11,
  7295. 25
  7296. ],
  7297. [
  7298. 11,
  7299. 25
  7300. ],
  7301. [
  7302. 13,
  7303. 1664
  7304. ],
  7305. [
  7306. 13,
  7307. 1728
  7308. ],
  7309. [
  7310. 12,
  7311. 320
  7312. ],
  7313. [
  7314. 12,
  7315. 320
  7316. ],
  7317. [
  7318. 12,
  7319. 384
  7320. ],
  7321. [
  7322. 12,
  7323. 384
  7324. ],
  7325. [
  7326. 12,
  7327. 448
  7328. ],
  7329. [
  7330. 12,
  7331. 448
  7332. ],
  7333. [
  7334. 13,
  7335. 512
  7336. ],
  7337. [
  7338. 13,
  7339. 576
  7340. ],
  7341. [
  7342. 12,
  7343. 53
  7344. ],
  7345. [
  7346. 12,
  7347. 53
  7348. ],
  7349. [
  7350. 12,
  7351. 54
  7352. ],
  7353. [
  7354. 12,
  7355. 54
  7356. ],
  7357. [
  7358. 13,
  7359. 896
  7360. ],
  7361. [
  7362. 13,
  7363. 960
  7364. ],
  7365. [
  7366. 13,
  7367. 1024
  7368. ],
  7369. [
  7370. 13,
  7371. 1088
  7372. ],
  7373. [
  7374. 13,
  7375. 1152
  7376. ],
  7377. [
  7378. 13,
  7379. 1216
  7380. ],
  7381. [
  7382. 10,
  7383. 64
  7384. ],
  7385. [
  7386. 10,
  7387. 64
  7388. ],
  7389. [
  7390. 10,
  7391. 64
  7392. ],
  7393. [
  7394. 10,
  7395. 64
  7396. ],
  7397. [
  7398. 10,
  7399. 64
  7400. ],
  7401. [
  7402. 10,
  7403. 64
  7404. ],
  7405. [
  7406. 10,
  7407. 64
  7408. ],
  7409. [
  7410. 10,
  7411. 64
  7412. ]
  7413. ];
  7414. var blackTable2 = [
  7415. [
  7416. 8,
  7417. 13
  7418. ],
  7419. [
  7420. 8,
  7421. 13
  7422. ],
  7423. [
  7424. 8,
  7425. 13
  7426. ],
  7427. [
  7428. 8,
  7429. 13
  7430. ],
  7431. [
  7432. 8,
  7433. 13
  7434. ],
  7435. [
  7436. 8,
  7437. 13
  7438. ],
  7439. [
  7440. 8,
  7441. 13
  7442. ],
  7443. [
  7444. 8,
  7445. 13
  7446. ],
  7447. [
  7448. 8,
  7449. 13
  7450. ],
  7451. [
  7452. 8,
  7453. 13
  7454. ],
  7455. [
  7456. 8,
  7457. 13
  7458. ],
  7459. [
  7460. 8,
  7461. 13
  7462. ],
  7463. [
  7464. 8,
  7465. 13
  7466. ],
  7467. [
  7468. 8,
  7469. 13
  7470. ],
  7471. [
  7472. 8,
  7473. 13
  7474. ],
  7475. [
  7476. 8,
  7477. 13
  7478. ],
  7479. [
  7480. 11,
  7481. 23
  7482. ],
  7483. [
  7484. 11,
  7485. 23
  7486. ],
  7487. [
  7488. 12,
  7489. 50
  7490. ],
  7491. [
  7492. 12,
  7493. 51
  7494. ],
  7495. [
  7496. 12,
  7497. 44
  7498. ],
  7499. [
  7500. 12,
  7501. 45
  7502. ],
  7503. [
  7504. 12,
  7505. 46
  7506. ],
  7507. [
  7508. 12,
  7509. 47
  7510. ],
  7511. [
  7512. 12,
  7513. 57
  7514. ],
  7515. [
  7516. 12,
  7517. 58
  7518. ],
  7519. [
  7520. 12,
  7521. 61
  7522. ],
  7523. [
  7524. 12,
  7525. 256
  7526. ],
  7527. [
  7528. 10,
  7529. 16
  7530. ],
  7531. [
  7532. 10,
  7533. 16
  7534. ],
  7535. [
  7536. 10,
  7537. 16
  7538. ],
  7539. [
  7540. 10,
  7541. 16
  7542. ],
  7543. [
  7544. 10,
  7545. 17
  7546. ],
  7547. [
  7548. 10,
  7549. 17
  7550. ],
  7551. [
  7552. 10,
  7553. 17
  7554. ],
  7555. [
  7556. 10,
  7557. 17
  7558. ],
  7559. [
  7560. 12,
  7561. 48
  7562. ],
  7563. [
  7564. 12,
  7565. 49
  7566. ],
  7567. [
  7568. 12,
  7569. 62
  7570. ],
  7571. [
  7572. 12,
  7573. 63
  7574. ],
  7575. [
  7576. 12,
  7577. 30
  7578. ],
  7579. [
  7580. 12,
  7581. 31
  7582. ],
  7583. [
  7584. 12,
  7585. 32
  7586. ],
  7587. [
  7588. 12,
  7589. 33
  7590. ],
  7591. [
  7592. 12,
  7593. 40
  7594. ],
  7595. [
  7596. 12,
  7597. 41
  7598. ],
  7599. [
  7600. 11,
  7601. 22
  7602. ],
  7603. [
  7604. 11,
  7605. 22
  7606. ],
  7607. [
  7608. 8,
  7609. 14
  7610. ],
  7611. [
  7612. 8,
  7613. 14
  7614. ],
  7615. [
  7616. 8,
  7617. 14
  7618. ],
  7619. [
  7620. 8,
  7621. 14
  7622. ],
  7623. [
  7624. 8,
  7625. 14
  7626. ],
  7627. [
  7628. 8,
  7629. 14
  7630. ],
  7631. [
  7632. 8,
  7633. 14
  7634. ],
  7635. [
  7636. 8,
  7637. 14
  7638. ],
  7639. [
  7640. 8,
  7641. 14
  7642. ],
  7643. [
  7644. 8,
  7645. 14
  7646. ],
  7647. [
  7648. 8,
  7649. 14
  7650. ],
  7651. [
  7652. 8,
  7653. 14
  7654. ],
  7655. [
  7656. 8,
  7657. 14
  7658. ],
  7659. [
  7660. 8,
  7661. 14
  7662. ],
  7663. [
  7664. 8,
  7665. 14
  7666. ],
  7667. [
  7668. 8,
  7669. 14
  7670. ],
  7671. [
  7672. 7,
  7673. 10
  7674. ],
  7675. [
  7676. 7,
  7677. 10
  7678. ],
  7679. [
  7680. 7,
  7681. 10
  7682. ],
  7683. [
  7684. 7,
  7685. 10
  7686. ],
  7687. [
  7688. 7,
  7689. 10
  7690. ],
  7691. [
  7692. 7,
  7693. 10
  7694. ],
  7695. [
  7696. 7,
  7697. 10
  7698. ],
  7699. [
  7700. 7,
  7701. 10
  7702. ],
  7703. [
  7704. 7,
  7705. 10
  7706. ],
  7707. [
  7708. 7,
  7709. 10
  7710. ],
  7711. [
  7712. 7,
  7713. 10
  7714. ],
  7715. [
  7716. 7,
  7717. 10
  7718. ],
  7719. [
  7720. 7,
  7721. 10
  7722. ],
  7723. [
  7724. 7,
  7725. 10
  7726. ],
  7727. [
  7728. 7,
  7729. 10
  7730. ],
  7731. [
  7732. 7,
  7733. 10
  7734. ],
  7735. [
  7736. 7,
  7737. 10
  7738. ],
  7739. [
  7740. 7,
  7741. 10
  7742. ],
  7743. [
  7744. 7,
  7745. 10
  7746. ],
  7747. [
  7748. 7,
  7749. 10
  7750. ],
  7751. [
  7752. 7,
  7753. 10
  7754. ],
  7755. [
  7756. 7,
  7757. 10
  7758. ],
  7759. [
  7760. 7,
  7761. 10
  7762. ],
  7763. [
  7764. 7,
  7765. 10
  7766. ],
  7767. [
  7768. 7,
  7769. 10
  7770. ],
  7771. [
  7772. 7,
  7773. 10
  7774. ],
  7775. [
  7776. 7,
  7777. 10
  7778. ],
  7779. [
  7780. 7,
  7781. 10
  7782. ],
  7783. [
  7784. 7,
  7785. 10
  7786. ],
  7787. [
  7788. 7,
  7789. 10
  7790. ],
  7791. [
  7792. 7,
  7793. 10
  7794. ],
  7795. [
  7796. 7,
  7797. 10
  7798. ],
  7799. [
  7800. 7,
  7801. 11
  7802. ],
  7803. [
  7804. 7,
  7805. 11
  7806. ],
  7807. [
  7808. 7,
  7809. 11
  7810. ],
  7811. [
  7812. 7,
  7813. 11
  7814. ],
  7815. [
  7816. 7,
  7817. 11
  7818. ],
  7819. [
  7820. 7,
  7821. 11
  7822. ],
  7823. [
  7824. 7,
  7825. 11
  7826. ],
  7827. [
  7828. 7,
  7829. 11
  7830. ],
  7831. [
  7832. 7,
  7833. 11
  7834. ],
  7835. [
  7836. 7,
  7837. 11
  7838. ],
  7839. [
  7840. 7,
  7841. 11
  7842. ],
  7843. [
  7844. 7,
  7845. 11
  7846. ],
  7847. [
  7848. 7,
  7849. 11
  7850. ],
  7851. [
  7852. 7,
  7853. 11
  7854. ],
  7855. [
  7856. 7,
  7857. 11
  7858. ],
  7859. [
  7860. 7,
  7861. 11
  7862. ],
  7863. [
  7864. 7,
  7865. 11
  7866. ],
  7867. [
  7868. 7,
  7869. 11
  7870. ],
  7871. [
  7872. 7,
  7873. 11
  7874. ],
  7875. [
  7876. 7,
  7877. 11
  7878. ],
  7879. [
  7880. 7,
  7881. 11
  7882. ],
  7883. [
  7884. 7,
  7885. 11
  7886. ],
  7887. [
  7888. 7,
  7889. 11
  7890. ],
  7891. [
  7892. 7,
  7893. 11
  7894. ],
  7895. [
  7896. 7,
  7897. 11
  7898. ],
  7899. [
  7900. 7,
  7901. 11
  7902. ],
  7903. [
  7904. 7,
  7905. 11
  7906. ],
  7907. [
  7908. 7,
  7909. 11
  7910. ],
  7911. [
  7912. 7,
  7913. 11
  7914. ],
  7915. [
  7916. 7,
  7917. 11
  7918. ],
  7919. [
  7920. 7,
  7921. 11
  7922. ],
  7923. [
  7924. 7,
  7925. 11
  7926. ],
  7927. [
  7928. 9,
  7929. 15
  7930. ],
  7931. [
  7932. 9,
  7933. 15
  7934. ],
  7935. [
  7936. 9,
  7937. 15
  7938. ],
  7939. [
  7940. 9,
  7941. 15
  7942. ],
  7943. [
  7944. 9,
  7945. 15
  7946. ],
  7947. [
  7948. 9,
  7949. 15
  7950. ],
  7951. [
  7952. 9,
  7953. 15
  7954. ],
  7955. [
  7956. 9,
  7957. 15
  7958. ],
  7959. [
  7960. 12,
  7961. 128
  7962. ],
  7963. [
  7964. 12,
  7965. 192
  7966. ],
  7967. [
  7968. 12,
  7969. 26
  7970. ],
  7971. [
  7972. 12,
  7973. 27
  7974. ],
  7975. [
  7976. 12,
  7977. 28
  7978. ],
  7979. [
  7980. 12,
  7981. 29
  7982. ],
  7983. [
  7984. 11,
  7985. 19
  7986. ],
  7987. [
  7988. 11,
  7989. 19
  7990. ],
  7991. [
  7992. 11,
  7993. 20
  7994. ],
  7995. [
  7996. 11,
  7997. 20
  7998. ],
  7999. [
  8000. 12,
  8001. 34
  8002. ],
  8003. [
  8004. 12,
  8005. 35
  8006. ],
  8007. [
  8008. 12,
  8009. 36
  8010. ],
  8011. [
  8012. 12,
  8013. 37
  8014. ],
  8015. [
  8016. 12,
  8017. 38
  8018. ],
  8019. [
  8020. 12,
  8021. 39
  8022. ],
  8023. [
  8024. 11,
  8025. 21
  8026. ],
  8027. [
  8028. 11,
  8029. 21
  8030. ],
  8031. [
  8032. 12,
  8033. 42
  8034. ],
  8035. [
  8036. 12,
  8037. 43
  8038. ],
  8039. [
  8040. 10,
  8041. 0
  8042. ],
  8043. [
  8044. 10,
  8045. 0
  8046. ],
  8047. [
  8048. 10,
  8049. 0
  8050. ],
  8051. [
  8052. 10,
  8053. 0
  8054. ],
  8055. [
  8056. 7,
  8057. 12
  8058. ],
  8059. [
  8060. 7,
  8061. 12
  8062. ],
  8063. [
  8064. 7,
  8065. 12
  8066. ],
  8067. [
  8068. 7,
  8069. 12
  8070. ],
  8071. [
  8072. 7,
  8073. 12
  8074. ],
  8075. [
  8076. 7,
  8077. 12
  8078. ],
  8079. [
  8080. 7,
  8081. 12
  8082. ],
  8083. [
  8084. 7,
  8085. 12
  8086. ],
  8087. [
  8088. 7,
  8089. 12
  8090. ],
  8091. [
  8092. 7,
  8093. 12
  8094. ],
  8095. [
  8096. 7,
  8097. 12
  8098. ],
  8099. [
  8100. 7,
  8101. 12
  8102. ],
  8103. [
  8104. 7,
  8105. 12
  8106. ],
  8107. [
  8108. 7,
  8109. 12
  8110. ],
  8111. [
  8112. 7,
  8113. 12
  8114. ],
  8115. [
  8116. 7,
  8117. 12
  8118. ],
  8119. [
  8120. 7,
  8121. 12
  8122. ],
  8123. [
  8124. 7,
  8125. 12
  8126. ],
  8127. [
  8128. 7,
  8129. 12
  8130. ],
  8131. [
  8132. 7,
  8133. 12
  8134. ],
  8135. [
  8136. 7,
  8137. 12
  8138. ],
  8139. [
  8140. 7,
  8141. 12
  8142. ],
  8143. [
  8144. 7,
  8145. 12
  8146. ],
  8147. [
  8148. 7,
  8149. 12
  8150. ],
  8151. [
  8152. 7,
  8153. 12
  8154. ],
  8155. [
  8156. 7,
  8157. 12
  8158. ],
  8159. [
  8160. 7,
  8161. 12
  8162. ],
  8163. [
  8164. 7,
  8165. 12
  8166. ],
  8167. [
  8168. 7,
  8169. 12
  8170. ],
  8171. [
  8172. 7,
  8173. 12
  8174. ],
  8175. [
  8176. 7,
  8177. 12
  8178. ],
  8179. [
  8180. 7,
  8181. 12
  8182. ]
  8183. ];
  8184. var blackTable3 = [
  8185. [
  8186. -1,
  8187. -1
  8188. ],
  8189. [
  8190. -1,
  8191. -1
  8192. ],
  8193. [
  8194. -1,
  8195. -1
  8196. ],
  8197. [
  8198. -1,
  8199. -1
  8200. ],
  8201. [
  8202. 6,
  8203. 9
  8204. ],
  8205. [
  8206. 6,
  8207. 8
  8208. ],
  8209. [
  8210. 5,
  8211. 7
  8212. ],
  8213. [
  8214. 5,
  8215. 7
  8216. ],
  8217. [
  8218. 4,
  8219. 6
  8220. ],
  8221. [
  8222. 4,
  8223. 6
  8224. ],
  8225. [
  8226. 4,
  8227. 6
  8228. ],
  8229. [
  8230. 4,
  8231. 6
  8232. ],
  8233. [
  8234. 4,
  8235. 5
  8236. ],
  8237. [
  8238. 4,
  8239. 5
  8240. ],
  8241. [
  8242. 4,
  8243. 5
  8244. ],
  8245. [
  8246. 4,
  8247. 5
  8248. ],
  8249. [
  8250. 3,
  8251. 1
  8252. ],
  8253. [
  8254. 3,
  8255. 1
  8256. ],
  8257. [
  8258. 3,
  8259. 1
  8260. ],
  8261. [
  8262. 3,
  8263. 1
  8264. ],
  8265. [
  8266. 3,
  8267. 1
  8268. ],
  8269. [
  8270. 3,
  8271. 1
  8272. ],
  8273. [
  8274. 3,
  8275. 1
  8276. ],
  8277. [
  8278. 3,
  8279. 1
  8280. ],
  8281. [
  8282. 3,
  8283. 4
  8284. ],
  8285. [
  8286. 3,
  8287. 4
  8288. ],
  8289. [
  8290. 3,
  8291. 4
  8292. ],
  8293. [
  8294. 3,
  8295. 4
  8296. ],
  8297. [
  8298. 3,
  8299. 4
  8300. ],
  8301. [
  8302. 3,
  8303. 4
  8304. ],
  8305. [
  8306. 3,
  8307. 4
  8308. ],
  8309. [
  8310. 3,
  8311. 4
  8312. ],
  8313. [
  8314. 2,
  8315. 3
  8316. ],
  8317. [
  8318. 2,
  8319. 3
  8320. ],
  8321. [
  8322. 2,
  8323. 3
  8324. ],
  8325. [
  8326. 2,
  8327. 3
  8328. ],
  8329. [
  8330. 2,
  8331. 3
  8332. ],
  8333. [
  8334. 2,
  8335. 3
  8336. ],
  8337. [
  8338. 2,
  8339. 3
  8340. ],
  8341. [
  8342. 2,
  8343. 3
  8344. ],
  8345. [
  8346. 2,
  8347. 3
  8348. ],
  8349. [
  8350. 2,
  8351. 3
  8352. ],
  8353. [
  8354. 2,
  8355. 3
  8356. ],
  8357. [
  8358. 2,
  8359. 3
  8360. ],
  8361. [
  8362. 2,
  8363. 3
  8364. ],
  8365. [
  8366. 2,
  8367. 3
  8368. ],
  8369. [
  8370. 2,
  8371. 3
  8372. ],
  8373. [
  8374. 2,
  8375. 3
  8376. ],
  8377. [
  8378. 2,
  8379. 2
  8380. ],
  8381. [
  8382. 2,
  8383. 2
  8384. ],
  8385. [
  8386. 2,
  8387. 2
  8388. ],
  8389. [
  8390. 2,
  8391. 2
  8392. ],
  8393. [
  8394. 2,
  8395. 2
  8396. ],
  8397. [
  8398. 2,
  8399. 2
  8400. ],
  8401. [
  8402. 2,
  8403. 2
  8404. ],
  8405. [
  8406. 2,
  8407. 2
  8408. ],
  8409. [
  8410. 2,
  8411. 2
  8412. ],
  8413. [
  8414. 2,
  8415. 2
  8416. ],
  8417. [
  8418. 2,
  8419. 2
  8420. ],
  8421. [
  8422. 2,
  8423. 2
  8424. ],
  8425. [
  8426. 2,
  8427. 2
  8428. ],
  8429. [
  8430. 2,
  8431. 2
  8432. ],
  8433. [
  8434. 2,
  8435. 2
  8436. ],
  8437. [
  8438. 2,
  8439. 2
  8440. ]
  8441. ];
  8442. function CCITTFaxStream(str, maybeLength, params) {
  8443. this.str = str;
  8444. this.dict = str.dict;
  8445. params = params || Dict.empty;
  8446. this.encoding = params.get('K') || 0;
  8447. this.eoline = params.get('EndOfLine') || false;
  8448. this.byteAlign = params.get('EncodedByteAlign') || false;
  8449. this.columns = params.get('Columns') || 1728;
  8450. this.rows = params.get('Rows') || 0;
  8451. var eoblock = params.get('EndOfBlock');
  8452. if (eoblock === null || eoblock === undefined) {
  8453. eoblock = true;
  8454. }
  8455. this.eoblock = eoblock;
  8456. this.black = params.get('BlackIs1') || false;
  8457. this.codingLine = new Uint32Array(this.columns + 1);
  8458. this.refLine = new Uint32Array(this.columns + 2);
  8459. this.codingLine[0] = this.columns;
  8460. this.codingPos = 0;
  8461. this.row = 0;
  8462. this.nextLine2D = this.encoding < 0;
  8463. this.inputBits = 0;
  8464. this.inputBuf = 0;
  8465. this.outputBits = 0;
  8466. var code1;
  8467. while ((code1 = this.lookBits(12)) === 0) {
  8468. this.eatBits(1);
  8469. }
  8470. if (code1 === 1) {
  8471. this.eatBits(12);
  8472. }
  8473. if (this.encoding > 0) {
  8474. this.nextLine2D = !this.lookBits(1);
  8475. this.eatBits(1);
  8476. }
  8477. DecodeStream.call(this, maybeLength);
  8478. }
  8479. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  8480. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  8481. while (!this.eof) {
  8482. var c = this.lookChar();
  8483. this.ensureBuffer(this.bufferLength + 1);
  8484. this.buffer[this.bufferLength++] = c;
  8485. }
  8486. };
  8487. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  8488. var codingLine = this.codingLine;
  8489. var codingPos = this.codingPos;
  8490. if (a1 > codingLine[codingPos]) {
  8491. if (a1 > this.columns) {
  8492. info('row is wrong length');
  8493. this.err = true;
  8494. a1 = this.columns;
  8495. }
  8496. if (codingPos & 1 ^ blackPixels) {
  8497. ++codingPos;
  8498. }
  8499. codingLine[codingPos] = a1;
  8500. }
  8501. this.codingPos = codingPos;
  8502. };
  8503. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  8504. var codingLine = this.codingLine;
  8505. var codingPos = this.codingPos;
  8506. if (a1 > codingLine[codingPos]) {
  8507. if (a1 > this.columns) {
  8508. info('row is wrong length');
  8509. this.err = true;
  8510. a1 = this.columns;
  8511. }
  8512. if (codingPos & 1 ^ blackPixels) {
  8513. ++codingPos;
  8514. }
  8515. codingLine[codingPos] = a1;
  8516. } else if (a1 < codingLine[codingPos]) {
  8517. if (a1 < 0) {
  8518. info('invalid code');
  8519. this.err = true;
  8520. a1 = 0;
  8521. }
  8522. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  8523. --codingPos;
  8524. }
  8525. codingLine[codingPos] = a1;
  8526. }
  8527. this.codingPos = codingPos;
  8528. };
  8529. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  8530. var refLine = this.refLine;
  8531. var codingLine = this.codingLine;
  8532. var columns = this.columns;
  8533. var refPos, blackPixels, bits, i;
  8534. if (this.outputBits === 0) {
  8535. if (this.eof) {
  8536. return null;
  8537. }
  8538. this.err = false;
  8539. var code1, code2, code3;
  8540. if (this.nextLine2D) {
  8541. for (i = 0; codingLine[i] < columns; ++i) {
  8542. refLine[i] = codingLine[i];
  8543. }
  8544. refLine[i++] = columns;
  8545. refLine[i] = columns;
  8546. codingLine[0] = 0;
  8547. this.codingPos = 0;
  8548. refPos = 0;
  8549. blackPixels = 0;
  8550. while (codingLine[this.codingPos] < columns) {
  8551. code1 = this.getTwoDimCode();
  8552. switch (code1) {
  8553. case twoDimPass:
  8554. this.addPixels(refLine[refPos + 1], blackPixels);
  8555. if (refLine[refPos + 1] < columns) {
  8556. refPos += 2;
  8557. }
  8558. break;
  8559. case twoDimHoriz:
  8560. code1 = code2 = 0;
  8561. if (blackPixels) {
  8562. do {
  8563. code1 += code3 = this.getBlackCode();
  8564. } while (code3 >= 64);
  8565. do {
  8566. code2 += code3 = this.getWhiteCode();
  8567. } while (code3 >= 64);
  8568. } else {
  8569. do {
  8570. code1 += code3 = this.getWhiteCode();
  8571. } while (code3 >= 64);
  8572. do {
  8573. code2 += code3 = this.getBlackCode();
  8574. } while (code3 >= 64);
  8575. }
  8576. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8577. if (codingLine[this.codingPos] < columns) {
  8578. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  8579. }
  8580. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8581. refPos += 2;
  8582. }
  8583. break;
  8584. case twoDimVertR3:
  8585. this.addPixels(refLine[refPos] + 3, blackPixels);
  8586. blackPixels ^= 1;
  8587. if (codingLine[this.codingPos] < columns) {
  8588. ++refPos;
  8589. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8590. refPos += 2;
  8591. }
  8592. }
  8593. break;
  8594. case twoDimVertR2:
  8595. this.addPixels(refLine[refPos] + 2, blackPixels);
  8596. blackPixels ^= 1;
  8597. if (codingLine[this.codingPos] < columns) {
  8598. ++refPos;
  8599. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8600. refPos += 2;
  8601. }
  8602. }
  8603. break;
  8604. case twoDimVertR1:
  8605. this.addPixels(refLine[refPos] + 1, blackPixels);
  8606. blackPixels ^= 1;
  8607. if (codingLine[this.codingPos] < columns) {
  8608. ++refPos;
  8609. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8610. refPos += 2;
  8611. }
  8612. }
  8613. break;
  8614. case twoDimVert0:
  8615. this.addPixels(refLine[refPos], blackPixels);
  8616. blackPixels ^= 1;
  8617. if (codingLine[this.codingPos] < columns) {
  8618. ++refPos;
  8619. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8620. refPos += 2;
  8621. }
  8622. }
  8623. break;
  8624. case twoDimVertL3:
  8625. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  8626. blackPixels ^= 1;
  8627. if (codingLine[this.codingPos] < columns) {
  8628. if (refPos > 0) {
  8629. --refPos;
  8630. } else {
  8631. ++refPos;
  8632. }
  8633. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8634. refPos += 2;
  8635. }
  8636. }
  8637. break;
  8638. case twoDimVertL2:
  8639. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  8640. blackPixels ^= 1;
  8641. if (codingLine[this.codingPos] < columns) {
  8642. if (refPos > 0) {
  8643. --refPos;
  8644. } else {
  8645. ++refPos;
  8646. }
  8647. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8648. refPos += 2;
  8649. }
  8650. }
  8651. break;
  8652. case twoDimVertL1:
  8653. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  8654. blackPixels ^= 1;
  8655. if (codingLine[this.codingPos] < columns) {
  8656. if (refPos > 0) {
  8657. --refPos;
  8658. } else {
  8659. ++refPos;
  8660. }
  8661. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8662. refPos += 2;
  8663. }
  8664. }
  8665. break;
  8666. case ccittEOF:
  8667. this.addPixels(columns, 0);
  8668. this.eof = true;
  8669. break;
  8670. default:
  8671. info('bad 2d code');
  8672. this.addPixels(columns, 0);
  8673. this.err = true;
  8674. }
  8675. }
  8676. } else {
  8677. codingLine[0] = 0;
  8678. this.codingPos = 0;
  8679. blackPixels = 0;
  8680. while (codingLine[this.codingPos] < columns) {
  8681. code1 = 0;
  8682. if (blackPixels) {
  8683. do {
  8684. code1 += code3 = this.getBlackCode();
  8685. } while (code3 >= 64);
  8686. } else {
  8687. do {
  8688. code1 += code3 = this.getWhiteCode();
  8689. } while (code3 >= 64);
  8690. }
  8691. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8692. blackPixels ^= 1;
  8693. }
  8694. }
  8695. var gotEOL = false;
  8696. if (this.byteAlign) {
  8697. this.inputBits &= ~7;
  8698. }
  8699. if (!this.eoblock && this.row === this.rows - 1) {
  8700. this.eof = true;
  8701. } else {
  8702. code1 = this.lookBits(12);
  8703. if (this.eoline) {
  8704. while (code1 !== ccittEOF && code1 !== 1) {
  8705. this.eatBits(1);
  8706. code1 = this.lookBits(12);
  8707. }
  8708. } else {
  8709. while (code1 === 0) {
  8710. this.eatBits(1);
  8711. code1 = this.lookBits(12);
  8712. }
  8713. }
  8714. if (code1 === 1) {
  8715. this.eatBits(12);
  8716. gotEOL = true;
  8717. } else if (code1 === ccittEOF) {
  8718. this.eof = true;
  8719. }
  8720. }
  8721. if (!this.eof && this.encoding > 0) {
  8722. this.nextLine2D = !this.lookBits(1);
  8723. this.eatBits(1);
  8724. }
  8725. if (this.eoblock && gotEOL && this.byteAlign) {
  8726. code1 = this.lookBits(12);
  8727. if (code1 === 1) {
  8728. this.eatBits(12);
  8729. if (this.encoding > 0) {
  8730. this.lookBits(1);
  8731. this.eatBits(1);
  8732. }
  8733. if (this.encoding >= 0) {
  8734. for (i = 0; i < 4; ++i) {
  8735. code1 = this.lookBits(12);
  8736. if (code1 !== 1) {
  8737. info('bad rtc code: ' + code1);
  8738. }
  8739. this.eatBits(12);
  8740. if (this.encoding > 0) {
  8741. this.lookBits(1);
  8742. this.eatBits(1);
  8743. }
  8744. }
  8745. }
  8746. this.eof = true;
  8747. }
  8748. } else if (this.err && this.eoline) {
  8749. while (true) {
  8750. code1 = this.lookBits(13);
  8751. if (code1 === ccittEOF) {
  8752. this.eof = true;
  8753. return null;
  8754. }
  8755. if (code1 >> 1 === 1) {
  8756. break;
  8757. }
  8758. this.eatBits(1);
  8759. }
  8760. this.eatBits(12);
  8761. if (this.encoding > 0) {
  8762. this.eatBits(1);
  8763. this.nextLine2D = !(code1 & 1);
  8764. }
  8765. }
  8766. if (codingLine[0] > 0) {
  8767. this.outputBits = codingLine[this.codingPos = 0];
  8768. } else {
  8769. this.outputBits = codingLine[this.codingPos = 1];
  8770. }
  8771. this.row++;
  8772. }
  8773. var c;
  8774. if (this.outputBits >= 8) {
  8775. c = this.codingPos & 1 ? 0 : 0xFF;
  8776. this.outputBits -= 8;
  8777. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  8778. this.codingPos++;
  8779. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8780. }
  8781. } else {
  8782. bits = 8;
  8783. c = 0;
  8784. do {
  8785. if (this.outputBits > bits) {
  8786. c <<= bits;
  8787. if (!(this.codingPos & 1)) {
  8788. c |= 0xFF >> 8 - bits;
  8789. }
  8790. this.outputBits -= bits;
  8791. bits = 0;
  8792. } else {
  8793. c <<= this.outputBits;
  8794. if (!(this.codingPos & 1)) {
  8795. c |= 0xFF >> 8 - this.outputBits;
  8796. }
  8797. bits -= this.outputBits;
  8798. this.outputBits = 0;
  8799. if (codingLine[this.codingPos] < columns) {
  8800. this.codingPos++;
  8801. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8802. } else if (bits > 0) {
  8803. c <<= bits;
  8804. bits = 0;
  8805. }
  8806. }
  8807. } while (bits);
  8808. }
  8809. if (this.black) {
  8810. c ^= 0xFF;
  8811. }
  8812. return c;
  8813. };
  8814. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8815. var limitValue = limit || 0;
  8816. for (var i = start; i <= end; ++i) {
  8817. var code = this.lookBits(i);
  8818. if (code === ccittEOF) {
  8819. return [
  8820. true,
  8821. 1,
  8822. false
  8823. ];
  8824. }
  8825. if (i < end) {
  8826. code <<= end - i;
  8827. }
  8828. if (!limitValue || code >= limitValue) {
  8829. var p = table[code - limitValue];
  8830. if (p[0] === i) {
  8831. this.eatBits(i);
  8832. return [
  8833. true,
  8834. p[1],
  8835. true
  8836. ];
  8837. }
  8838. }
  8839. }
  8840. return [
  8841. false,
  8842. 0,
  8843. false
  8844. ];
  8845. };
  8846. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8847. var code = 0;
  8848. var p;
  8849. if (this.eoblock) {
  8850. code = this.lookBits(7);
  8851. p = twoDimTable[code];
  8852. if (p && p[0] > 0) {
  8853. this.eatBits(p[0]);
  8854. return p[1];
  8855. }
  8856. } else {
  8857. var result = this.findTableCode(1, 7, twoDimTable);
  8858. if (result[0] && result[2]) {
  8859. return result[1];
  8860. }
  8861. }
  8862. info('Bad two dim code');
  8863. return ccittEOF;
  8864. };
  8865. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8866. var code = 0;
  8867. var p;
  8868. if (this.eoblock) {
  8869. code = this.lookBits(12);
  8870. if (code === ccittEOF) {
  8871. return 1;
  8872. }
  8873. if (code >> 5 === 0) {
  8874. p = whiteTable1[code];
  8875. } else {
  8876. p = whiteTable2[code >> 3];
  8877. }
  8878. if (p[0] > 0) {
  8879. this.eatBits(p[0]);
  8880. return p[1];
  8881. }
  8882. } else {
  8883. var result = this.findTableCode(1, 9, whiteTable2);
  8884. if (result[0]) {
  8885. return result[1];
  8886. }
  8887. result = this.findTableCode(11, 12, whiteTable1);
  8888. if (result[0]) {
  8889. return result[1];
  8890. }
  8891. }
  8892. info('bad white code');
  8893. this.eatBits(1);
  8894. return 1;
  8895. };
  8896. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8897. var code, p;
  8898. if (this.eoblock) {
  8899. code = this.lookBits(13);
  8900. if (code === ccittEOF) {
  8901. return 1;
  8902. }
  8903. if (code >> 7 === 0) {
  8904. p = blackTable1[code];
  8905. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8906. p = blackTable2[(code >> 1) - 64];
  8907. } else {
  8908. p = blackTable3[code >> 7];
  8909. }
  8910. if (p[0] > 0) {
  8911. this.eatBits(p[0]);
  8912. return p[1];
  8913. }
  8914. } else {
  8915. var result = this.findTableCode(2, 6, blackTable3);
  8916. if (result[0]) {
  8917. return result[1];
  8918. }
  8919. result = this.findTableCode(7, 12, blackTable2, 64);
  8920. if (result[0]) {
  8921. return result[1];
  8922. }
  8923. result = this.findTableCode(10, 13, blackTable1);
  8924. if (result[0]) {
  8925. return result[1];
  8926. }
  8927. }
  8928. info('bad black code');
  8929. this.eatBits(1);
  8930. return 1;
  8931. };
  8932. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8933. var c;
  8934. while (this.inputBits < n) {
  8935. if ((c = this.str.getByte()) === -1) {
  8936. if (this.inputBits === 0) {
  8937. return ccittEOF;
  8938. }
  8939. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8940. }
  8941. this.inputBuf = this.inputBuf << 8 | c;
  8942. this.inputBits += 8;
  8943. }
  8944. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8945. };
  8946. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8947. if ((this.inputBits -= n) < 0) {
  8948. this.inputBits = 0;
  8949. }
  8950. };
  8951. return CCITTFaxStream;
  8952. }();
  8953. var LZWStream = function LZWStreamClosure() {
  8954. function LZWStream(str, maybeLength, earlyChange) {
  8955. this.str = str;
  8956. this.dict = str.dict;
  8957. this.cachedData = 0;
  8958. this.bitsCached = 0;
  8959. var maxLzwDictionarySize = 4096;
  8960. var lzwState = {
  8961. earlyChange: earlyChange,
  8962. codeLength: 9,
  8963. nextCode: 258,
  8964. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8965. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8966. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8967. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8968. currentSequenceLength: 0
  8969. };
  8970. for (var i = 0; i < 256; ++i) {
  8971. lzwState.dictionaryValues[i] = i;
  8972. lzwState.dictionaryLengths[i] = 1;
  8973. }
  8974. this.lzwState = lzwState;
  8975. DecodeStream.call(this, maybeLength);
  8976. }
  8977. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8978. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8979. var bitsCached = this.bitsCached;
  8980. var cachedData = this.cachedData;
  8981. while (bitsCached < n) {
  8982. var c = this.str.getByte();
  8983. if (c === -1) {
  8984. this.eof = true;
  8985. return null;
  8986. }
  8987. cachedData = cachedData << 8 | c;
  8988. bitsCached += 8;
  8989. }
  8990. this.bitsCached = bitsCached -= n;
  8991. this.cachedData = cachedData;
  8992. this.lastCode = null;
  8993. return cachedData >>> bitsCached & (1 << n) - 1;
  8994. };
  8995. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8996. var blockSize = 512;
  8997. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8998. var i, j, q;
  8999. var lzwState = this.lzwState;
  9000. if (!lzwState) {
  9001. return;
  9002. }
  9003. var earlyChange = lzwState.earlyChange;
  9004. var nextCode = lzwState.nextCode;
  9005. var dictionaryValues = lzwState.dictionaryValues;
  9006. var dictionaryLengths = lzwState.dictionaryLengths;
  9007. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  9008. var codeLength = lzwState.codeLength;
  9009. var prevCode = lzwState.prevCode;
  9010. var currentSequence = lzwState.currentSequence;
  9011. var currentSequenceLength = lzwState.currentSequenceLength;
  9012. var decodedLength = 0;
  9013. var currentBufferLength = this.bufferLength;
  9014. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9015. for (i = 0; i < blockSize; i++) {
  9016. var code = this.readBits(codeLength);
  9017. var hasPrev = currentSequenceLength > 0;
  9018. if (code < 256) {
  9019. currentSequence[0] = code;
  9020. currentSequenceLength = 1;
  9021. } else if (code >= 258) {
  9022. if (code < nextCode) {
  9023. currentSequenceLength = dictionaryLengths[code];
  9024. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  9025. currentSequence[j] = dictionaryValues[q];
  9026. q = dictionaryPrevCodes[q];
  9027. }
  9028. } else {
  9029. currentSequence[currentSequenceLength++] = currentSequence[0];
  9030. }
  9031. } else if (code === 256) {
  9032. codeLength = 9;
  9033. nextCode = 258;
  9034. currentSequenceLength = 0;
  9035. continue;
  9036. } else {
  9037. this.eof = true;
  9038. delete this.lzwState;
  9039. break;
  9040. }
  9041. if (hasPrev) {
  9042. dictionaryPrevCodes[nextCode] = prevCode;
  9043. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  9044. dictionaryValues[nextCode] = currentSequence[0];
  9045. nextCode++;
  9046. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  9047. }
  9048. prevCode = code;
  9049. decodedLength += currentSequenceLength;
  9050. if (estimatedDecodedSize < decodedLength) {
  9051. do {
  9052. estimatedDecodedSize += decodedSizeDelta;
  9053. } while (estimatedDecodedSize < decodedLength);
  9054. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9055. }
  9056. for (j = 0; j < currentSequenceLength; j++) {
  9057. buffer[currentBufferLength++] = currentSequence[j];
  9058. }
  9059. }
  9060. lzwState.nextCode = nextCode;
  9061. lzwState.codeLength = codeLength;
  9062. lzwState.prevCode = prevCode;
  9063. lzwState.currentSequenceLength = currentSequenceLength;
  9064. this.bufferLength = currentBufferLength;
  9065. };
  9066. return LZWStream;
  9067. }();
  9068. var NullStream = function NullStreamClosure() {
  9069. function NullStream() {
  9070. Stream.call(this, new Uint8Array(0));
  9071. }
  9072. NullStream.prototype = Stream.prototype;
  9073. return NullStream;
  9074. }();
  9075. exports.Ascii85Stream = Ascii85Stream;
  9076. exports.AsciiHexStream = AsciiHexStream;
  9077. exports.CCITTFaxStream = CCITTFaxStream;
  9078. exports.DecryptStream = DecryptStream;
  9079. exports.DecodeStream = DecodeStream;
  9080. exports.FlateStream = FlateStream;
  9081. exports.Jbig2Stream = Jbig2Stream;
  9082. exports.JpegStream = JpegStream;
  9083. exports.JpxStream = JpxStream;
  9084. exports.NullStream = NullStream;
  9085. exports.PredictorStream = PredictorStream;
  9086. exports.RunLengthStream = RunLengthStream;
  9087. exports.Stream = Stream;
  9088. exports.StreamsSequenceStream = StreamsSequenceStream;
  9089. exports.StringStream = StringStream;
  9090. exports.LZWStream = LZWStream;
  9091. /***/ }),
  9092. /* 3 */
  9093. /***/ (function(module, exports, __w_pdfjs_require__) {
  9094. "use strict";
  9095. var sharedUtil = __w_pdfjs_require__(0);
  9096. var assert = sharedUtil.assert;
  9097. var removeNullCharacters = sharedUtil.removeNullCharacters;
  9098. var warn = sharedUtil.warn;
  9099. var deprecated = sharedUtil.deprecated;
  9100. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  9101. var stringToBytes = sharedUtil.stringToBytes;
  9102. var CMapCompressionType = sharedUtil.CMapCompressionType;
  9103. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  9104. function DOMCanvasFactory() {
  9105. }
  9106. DOMCanvasFactory.prototype = {
  9107. create: function DOMCanvasFactory_create(width, height) {
  9108. assert(width > 0 && height > 0, 'invalid canvas size');
  9109. var canvas = document.createElement('canvas');
  9110. var context = canvas.getContext('2d');
  9111. canvas.width = width;
  9112. canvas.height = height;
  9113. return {
  9114. canvas: canvas,
  9115. context: context
  9116. };
  9117. },
  9118. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  9119. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9120. assert(width > 0 && height > 0, 'invalid canvas size');
  9121. canvasAndContextPair.canvas.width = width;
  9122. canvasAndContextPair.canvas.height = height;
  9123. },
  9124. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  9125. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9126. canvasAndContextPair.canvas.width = 0;
  9127. canvasAndContextPair.canvas.height = 0;
  9128. canvasAndContextPair.canvas = null;
  9129. canvasAndContextPair.context = null;
  9130. }
  9131. };
  9132. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  9133. function DOMCMapReaderFactory(params) {
  9134. this.baseUrl = params.baseUrl || null;
  9135. this.isCompressed = params.isCompressed || false;
  9136. }
  9137. DOMCMapReaderFactory.prototype = {
  9138. fetch: function (params) {
  9139. if (!params.name) {
  9140. return Promise.reject(new Error('CMap name must be specified.'));
  9141. }
  9142. return new Promise(function (resolve, reject) {
  9143. var url = this.baseUrl + params.name;
  9144. var request = new XMLHttpRequest();
  9145. if (this.isCompressed) {
  9146. url += '.bcmap';
  9147. request.responseType = 'arraybuffer';
  9148. }
  9149. request.onreadystatechange = function () {
  9150. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  9151. var data;
  9152. if (this.isCompressed && request.response) {
  9153. data = new Uint8Array(request.response);
  9154. } else if (!this.isCompressed && request.responseText) {
  9155. data = stringToBytes(request.responseText);
  9156. }
  9157. if (data) {
  9158. resolve({
  9159. cMapData: data,
  9160. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  9161. });
  9162. return;
  9163. }
  9164. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  9165. }
  9166. }.bind(this);
  9167. request.open('GET', url, true);
  9168. request.send(null);
  9169. }.bind(this));
  9170. }
  9171. };
  9172. return DOMCMapReaderFactory;
  9173. }();
  9174. var CustomStyle = function CustomStyleClosure() {
  9175. var prefixes = [
  9176. 'ms',
  9177. 'Moz',
  9178. 'Webkit',
  9179. 'O'
  9180. ];
  9181. var _cache = Object.create(null);
  9182. function CustomStyle() {
  9183. }
  9184. CustomStyle.getProp = function get(propName, element) {
  9185. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  9186. return _cache[propName];
  9187. }
  9188. element = element || document.documentElement;
  9189. var style = element.style, prefixed, uPropName;
  9190. if (typeof style[propName] === 'string') {
  9191. return _cache[propName] = propName;
  9192. }
  9193. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  9194. for (var i = 0, l = prefixes.length; i < l; i++) {
  9195. prefixed = prefixes[i] + uPropName;
  9196. if (typeof style[prefixed] === 'string') {
  9197. return _cache[propName] = prefixed;
  9198. }
  9199. }
  9200. return _cache[propName] = 'undefined';
  9201. };
  9202. CustomStyle.setProp = function set(propName, element, str) {
  9203. var prop = this.getProp(propName);
  9204. if (prop !== 'undefined') {
  9205. element.style[prop] = str;
  9206. }
  9207. };
  9208. return CustomStyle;
  9209. }();
  9210. var hasCanvasTypedArrays;
  9211. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  9212. var canvas = document.createElement('canvas');
  9213. canvas.width = canvas.height = 1;
  9214. var ctx = canvas.getContext('2d');
  9215. var imageData = ctx.createImageData(1, 1);
  9216. return typeof imageData.data.buffer !== 'undefined';
  9217. };
  9218. var LinkTarget = {
  9219. NONE: 0,
  9220. SELF: 1,
  9221. BLANK: 2,
  9222. PARENT: 3,
  9223. TOP: 4
  9224. };
  9225. var LinkTargetStringMap = [
  9226. '',
  9227. '_self',
  9228. '_blank',
  9229. '_parent',
  9230. '_top'
  9231. ];
  9232. function addLinkAttributes(link, params) {
  9233. var url = params && params.url;
  9234. link.href = link.title = url ? removeNullCharacters(url) : '';
  9235. if (url) {
  9236. var target = params.target;
  9237. if (typeof target === 'undefined') {
  9238. target = getDefaultSetting('externalLinkTarget');
  9239. }
  9240. link.target = LinkTargetStringMap[target];
  9241. var rel = params.rel;
  9242. if (typeof rel === 'undefined') {
  9243. rel = getDefaultSetting('externalLinkRel');
  9244. }
  9245. link.rel = rel;
  9246. }
  9247. }
  9248. function getFilenameFromUrl(url) {
  9249. var anchor = url.indexOf('#');
  9250. var query = url.indexOf('?');
  9251. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  9252. return url.substring(url.lastIndexOf('/', end) + 1, end);
  9253. }
  9254. function getDefaultSetting(id) {
  9255. var globalSettings = sharedUtil.globalScope.PDFJS;
  9256. switch (id) {
  9257. case 'pdfBug':
  9258. return globalSettings ? globalSettings.pdfBug : false;
  9259. case 'disableAutoFetch':
  9260. return globalSettings ? globalSettings.disableAutoFetch : false;
  9261. case 'disableStream':
  9262. return globalSettings ? globalSettings.disableStream : false;
  9263. case 'disableRange':
  9264. return globalSettings ? globalSettings.disableRange : false;
  9265. case 'disableFontFace':
  9266. return globalSettings ? globalSettings.disableFontFace : false;
  9267. case 'disableCreateObjectURL':
  9268. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  9269. case 'disableWebGL':
  9270. return globalSettings ? globalSettings.disableWebGL : true;
  9271. case 'cMapUrl':
  9272. return globalSettings ? globalSettings.cMapUrl : null;
  9273. case 'cMapPacked':
  9274. return globalSettings ? globalSettings.cMapPacked : false;
  9275. case 'postMessageTransfers':
  9276. return globalSettings ? globalSettings.postMessageTransfers : true;
  9277. case 'workerSrc':
  9278. return globalSettings ? globalSettings.workerSrc : null;
  9279. case 'disableWorker':
  9280. return globalSettings ? globalSettings.disableWorker : false;
  9281. case 'maxImageSize':
  9282. return globalSettings ? globalSettings.maxImageSize : -1;
  9283. case 'imageResourcesPath':
  9284. return globalSettings ? globalSettings.imageResourcesPath : '';
  9285. case 'isEvalSupported':
  9286. return globalSettings ? globalSettings.isEvalSupported : true;
  9287. case 'externalLinkTarget':
  9288. if (!globalSettings) {
  9289. return LinkTarget.NONE;
  9290. }
  9291. switch (globalSettings.externalLinkTarget) {
  9292. case LinkTarget.NONE:
  9293. case LinkTarget.SELF:
  9294. case LinkTarget.BLANK:
  9295. case LinkTarget.PARENT:
  9296. case LinkTarget.TOP:
  9297. return globalSettings.externalLinkTarget;
  9298. }
  9299. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  9300. globalSettings.externalLinkTarget = LinkTarget.NONE;
  9301. return LinkTarget.NONE;
  9302. case 'externalLinkRel':
  9303. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  9304. case 'enableStats':
  9305. return !!(globalSettings && globalSettings.enableStats);
  9306. default:
  9307. throw new Error('Unknown default setting: ' + id);
  9308. }
  9309. }
  9310. function isExternalLinkTargetSet() {
  9311. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  9312. switch (externalLinkTarget) {
  9313. case LinkTarget.NONE:
  9314. return false;
  9315. case LinkTarget.SELF:
  9316. case LinkTarget.BLANK:
  9317. case LinkTarget.PARENT:
  9318. case LinkTarget.TOP:
  9319. return true;
  9320. }
  9321. }
  9322. function isValidUrl(url, allowRelative) {
  9323. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  9324. var baseUrl = allowRelative ? 'http://example.com' : null;
  9325. return createValidAbsoluteUrl(url, baseUrl) !== null;
  9326. }
  9327. exports.CustomStyle = CustomStyle;
  9328. exports.addLinkAttributes = addLinkAttributes;
  9329. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  9330. exports.isValidUrl = isValidUrl;
  9331. exports.getFilenameFromUrl = getFilenameFromUrl;
  9332. exports.LinkTarget = LinkTarget;
  9333. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  9334. exports.getDefaultSetting = getDefaultSetting;
  9335. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  9336. exports.DOMCanvasFactory = DOMCanvasFactory;
  9337. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  9338. /***/ }),
  9339. /* 4 */
  9340. /***/ (function(module, exports, __w_pdfjs_require__) {
  9341. "use strict";
  9342. var sharedUtil = __w_pdfjs_require__(0);
  9343. var corePrimitives = __w_pdfjs_require__(1);
  9344. var coreFunction = __w_pdfjs_require__(7);
  9345. var error = sharedUtil.error;
  9346. var info = sharedUtil.info;
  9347. var isArray = sharedUtil.isArray;
  9348. var isString = sharedUtil.isString;
  9349. var shadow = sharedUtil.shadow;
  9350. var warn = sharedUtil.warn;
  9351. var isDict = corePrimitives.isDict;
  9352. var isName = corePrimitives.isName;
  9353. var isStream = corePrimitives.isStream;
  9354. var PDFFunction = coreFunction.PDFFunction;
  9355. var ColorSpace = function ColorSpaceClosure() {
  9356. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  9357. var COMPONENTS = 3;
  9358. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  9359. var xRatio = w1 / w2;
  9360. var yRatio = h1 / h2;
  9361. var i, j, py, newIndex = 0, oldIndex;
  9362. var xScaled = new Uint16Array(w2);
  9363. var w1Scanline = w1 * COMPONENTS;
  9364. for (i = 0; i < w2; i++) {
  9365. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  9366. }
  9367. for (i = 0; i < h2; i++) {
  9368. py = Math.floor(i * yRatio) * w1Scanline;
  9369. for (j = 0; j < w2; j++) {
  9370. oldIndex = py + xScaled[j];
  9371. dest[newIndex++] = src[oldIndex++];
  9372. dest[newIndex++] = src[oldIndex++];
  9373. dest[newIndex++] = src[oldIndex++];
  9374. newIndex += alpha01;
  9375. }
  9376. }
  9377. }
  9378. function ColorSpace() {
  9379. error('should not call ColorSpace constructor');
  9380. }
  9381. ColorSpace.prototype = {
  9382. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  9383. var rgb = new Uint8Array(3);
  9384. this.getRgbItem(src, srcOffset, rgb, 0);
  9385. return rgb;
  9386. },
  9387. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  9388. error('Should not call ColorSpace.getRgbItem');
  9389. },
  9390. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9391. error('Should not call ColorSpace.getRgbBuffer');
  9392. },
  9393. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  9394. error('Should not call ColorSpace.getOutputLength');
  9395. },
  9396. isPassthrough: function ColorSpace_isPassthrough(bits) {
  9397. return false;
  9398. },
  9399. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  9400. var count = originalWidth * originalHeight;
  9401. var rgbBuf = null;
  9402. var numComponentColors = 1 << bpc;
  9403. var needsResizing = originalHeight !== height || originalWidth !== width;
  9404. var i, ii;
  9405. if (this.isPassthrough(bpc)) {
  9406. rgbBuf = comps;
  9407. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  9408. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  9409. var key;
  9410. for (i = 0; i < numComponentColors; i++) {
  9411. allColors[i] = i;
  9412. }
  9413. var colorMap = new Uint8Array(numComponentColors * 3);
  9414. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  9415. var destPos, rgbPos;
  9416. if (!needsResizing) {
  9417. destPos = 0;
  9418. for (i = 0; i < count; ++i) {
  9419. key = comps[i] * 3;
  9420. dest[destPos++] = colorMap[key];
  9421. dest[destPos++] = colorMap[key + 1];
  9422. dest[destPos++] = colorMap[key + 2];
  9423. destPos += alpha01;
  9424. }
  9425. } else {
  9426. rgbBuf = new Uint8Array(count * 3);
  9427. rgbPos = 0;
  9428. for (i = 0; i < count; ++i) {
  9429. key = comps[i] * 3;
  9430. rgbBuf[rgbPos++] = colorMap[key];
  9431. rgbBuf[rgbPos++] = colorMap[key + 1];
  9432. rgbBuf[rgbPos++] = colorMap[key + 2];
  9433. }
  9434. }
  9435. } else {
  9436. if (!needsResizing) {
  9437. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  9438. } else {
  9439. rgbBuf = new Uint8Array(count * 3);
  9440. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  9441. }
  9442. }
  9443. if (rgbBuf) {
  9444. if (needsResizing) {
  9445. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  9446. } else {
  9447. rgbPos = 0;
  9448. destPos = 0;
  9449. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  9450. dest[destPos++] = rgbBuf[rgbPos++];
  9451. dest[destPos++] = rgbBuf[rgbPos++];
  9452. dest[destPos++] = rgbBuf[rgbPos++];
  9453. destPos += alpha01;
  9454. }
  9455. }
  9456. }
  9457. },
  9458. usesZeroToOneRange: true
  9459. };
  9460. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  9461. var IR = ColorSpace.parseToIR(cs, xref, res);
  9462. if (IR instanceof AlternateCS) {
  9463. return IR;
  9464. }
  9465. return ColorSpace.fromIR(IR);
  9466. };
  9467. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  9468. var name = isArray(IR) ? IR[0] : IR;
  9469. var whitePoint, blackPoint, gamma;
  9470. switch (name) {
  9471. case 'DeviceGrayCS':
  9472. return this.singletons.gray;
  9473. case 'DeviceRgbCS':
  9474. return this.singletons.rgb;
  9475. case 'DeviceCmykCS':
  9476. return this.singletons.cmyk;
  9477. case 'CalGrayCS':
  9478. whitePoint = IR[1];
  9479. blackPoint = IR[2];
  9480. gamma = IR[3];
  9481. return new CalGrayCS(whitePoint, blackPoint, gamma);
  9482. case 'CalRGBCS':
  9483. whitePoint = IR[1];
  9484. blackPoint = IR[2];
  9485. gamma = IR[3];
  9486. var matrix = IR[4];
  9487. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  9488. case 'PatternCS':
  9489. var basePatternCS = IR[1];
  9490. if (basePatternCS) {
  9491. basePatternCS = ColorSpace.fromIR(basePatternCS);
  9492. }
  9493. return new PatternCS(basePatternCS);
  9494. case 'IndexedCS':
  9495. var baseIndexedCS = IR[1];
  9496. var hiVal = IR[2];
  9497. var lookup = IR[3];
  9498. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  9499. case 'AlternateCS':
  9500. var numComps = IR[1];
  9501. var alt = IR[2];
  9502. var tintFnIR = IR[3];
  9503. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  9504. case 'LabCS':
  9505. whitePoint = IR[1];
  9506. blackPoint = IR[2];
  9507. var range = IR[3];
  9508. return new LabCS(whitePoint, blackPoint, range);
  9509. default:
  9510. error('Unknown name ' + name);
  9511. }
  9512. return null;
  9513. };
  9514. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  9515. if (isName(cs)) {
  9516. var colorSpaces = res.get('ColorSpace');
  9517. if (isDict(colorSpaces)) {
  9518. var refcs = colorSpaces.get(cs.name);
  9519. if (refcs) {
  9520. cs = refcs;
  9521. }
  9522. }
  9523. }
  9524. cs = xref.fetchIfRef(cs);
  9525. if (isName(cs)) {
  9526. switch (cs.name) {
  9527. case 'DeviceGray':
  9528. case 'G':
  9529. return 'DeviceGrayCS';
  9530. case 'DeviceRGB':
  9531. case 'RGB':
  9532. return 'DeviceRgbCS';
  9533. case 'DeviceCMYK':
  9534. case 'CMYK':
  9535. return 'DeviceCmykCS';
  9536. case 'Pattern':
  9537. return [
  9538. 'PatternCS',
  9539. null
  9540. ];
  9541. default:
  9542. error('unrecognized colorspace ' + cs.name);
  9543. }
  9544. } else if (isArray(cs)) {
  9545. var mode = xref.fetchIfRef(cs[0]).name;
  9546. var numComps, params, alt, whitePoint, blackPoint, gamma;
  9547. switch (mode) {
  9548. case 'DeviceGray':
  9549. case 'G':
  9550. return 'DeviceGrayCS';
  9551. case 'DeviceRGB':
  9552. case 'RGB':
  9553. return 'DeviceRgbCS';
  9554. case 'DeviceCMYK':
  9555. case 'CMYK':
  9556. return 'DeviceCmykCS';
  9557. case 'CalGray':
  9558. params = xref.fetchIfRef(cs[1]);
  9559. whitePoint = params.getArray('WhitePoint');
  9560. blackPoint = params.getArray('BlackPoint');
  9561. gamma = params.get('Gamma');
  9562. return [
  9563. 'CalGrayCS',
  9564. whitePoint,
  9565. blackPoint,
  9566. gamma
  9567. ];
  9568. case 'CalRGB':
  9569. params = xref.fetchIfRef(cs[1]);
  9570. whitePoint = params.getArray('WhitePoint');
  9571. blackPoint = params.getArray('BlackPoint');
  9572. gamma = params.getArray('Gamma');
  9573. var matrix = params.getArray('Matrix');
  9574. return [
  9575. 'CalRGBCS',
  9576. whitePoint,
  9577. blackPoint,
  9578. gamma,
  9579. matrix
  9580. ];
  9581. case 'ICCBased':
  9582. var stream = xref.fetchIfRef(cs[1]);
  9583. var dict = stream.dict;
  9584. numComps = dict.get('N');
  9585. alt = dict.get('Alternate');
  9586. if (alt) {
  9587. var altIR = ColorSpace.parseToIR(alt, xref, res);
  9588. var altCS = ColorSpace.fromIR(altIR);
  9589. if (altCS.numComps === numComps) {
  9590. return altIR;
  9591. }
  9592. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  9593. }
  9594. if (numComps === 1) {
  9595. return 'DeviceGrayCS';
  9596. } else if (numComps === 3) {
  9597. return 'DeviceRgbCS';
  9598. } else if (numComps === 4) {
  9599. return 'DeviceCmykCS';
  9600. }
  9601. break;
  9602. case 'Pattern':
  9603. var basePatternCS = cs[1] || null;
  9604. if (basePatternCS) {
  9605. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  9606. }
  9607. return [
  9608. 'PatternCS',
  9609. basePatternCS
  9610. ];
  9611. case 'Indexed':
  9612. case 'I':
  9613. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  9614. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  9615. var lookup = xref.fetchIfRef(cs[3]);
  9616. if (isStream(lookup)) {
  9617. lookup = lookup.getBytes();
  9618. }
  9619. return [
  9620. 'IndexedCS',
  9621. baseIndexedCS,
  9622. hiVal,
  9623. lookup
  9624. ];
  9625. case 'Separation':
  9626. case 'DeviceN':
  9627. var name = xref.fetchIfRef(cs[1]);
  9628. numComps = isArray(name) ? name.length : 1;
  9629. alt = ColorSpace.parseToIR(cs[2], xref, res);
  9630. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  9631. return [
  9632. 'AlternateCS',
  9633. numComps,
  9634. alt,
  9635. tintFnIR
  9636. ];
  9637. case 'Lab':
  9638. params = xref.fetchIfRef(cs[1]);
  9639. whitePoint = params.getArray('WhitePoint');
  9640. blackPoint = params.getArray('BlackPoint');
  9641. var range = params.getArray('Range');
  9642. return [
  9643. 'LabCS',
  9644. whitePoint,
  9645. blackPoint,
  9646. range
  9647. ];
  9648. default:
  9649. error('unimplemented color space object "' + mode + '"');
  9650. }
  9651. } else {
  9652. error('unrecognized color space object: "' + cs + '"');
  9653. }
  9654. return null;
  9655. };
  9656. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  9657. if (!isArray(decode)) {
  9658. return true;
  9659. }
  9660. if (n * 2 !== decode.length) {
  9661. warn('The decode map is not the correct length');
  9662. return true;
  9663. }
  9664. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  9665. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  9666. return false;
  9667. }
  9668. }
  9669. return true;
  9670. };
  9671. ColorSpace.singletons = {
  9672. get gray() {
  9673. return shadow(this, 'gray', new DeviceGrayCS());
  9674. },
  9675. get rgb() {
  9676. return shadow(this, 'rgb', new DeviceRgbCS());
  9677. },
  9678. get cmyk() {
  9679. return shadow(this, 'cmyk', new DeviceCmykCS());
  9680. }
  9681. };
  9682. return ColorSpace;
  9683. }();
  9684. var AlternateCS = function AlternateCSClosure() {
  9685. function AlternateCS(numComps, base, tintFn) {
  9686. this.name = 'Alternate';
  9687. this.numComps = numComps;
  9688. this.defaultColor = new Float32Array(numComps);
  9689. for (var i = 0; i < numComps; ++i) {
  9690. this.defaultColor[i] = 1;
  9691. }
  9692. this.base = base;
  9693. this.tintFn = tintFn;
  9694. this.tmpBuf = new Float32Array(base.numComps);
  9695. }
  9696. AlternateCS.prototype = {
  9697. getRgb: ColorSpace.prototype.getRgb,
  9698. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9699. var tmpBuf = this.tmpBuf;
  9700. this.tintFn(src, srcOffset, tmpBuf, 0);
  9701. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  9702. },
  9703. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9704. var tintFn = this.tintFn;
  9705. var base = this.base;
  9706. var scale = 1 / ((1 << bits) - 1);
  9707. var baseNumComps = base.numComps;
  9708. var usesZeroToOneRange = base.usesZeroToOneRange;
  9709. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  9710. var pos = isPassthrough ? destOffset : 0;
  9711. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  9712. var numComps = this.numComps;
  9713. var scaled = new Float32Array(numComps);
  9714. var tinted = new Float32Array(baseNumComps);
  9715. var i, j;
  9716. for (i = 0; i < count; i++) {
  9717. for (j = 0; j < numComps; j++) {
  9718. scaled[j] = src[srcOffset++] * scale;
  9719. }
  9720. tintFn(scaled, 0, tinted, 0);
  9721. if (usesZeroToOneRange) {
  9722. for (j = 0; j < baseNumComps; j++) {
  9723. baseBuf[pos++] = tinted[j] * 255;
  9724. }
  9725. } else {
  9726. base.getRgbItem(tinted, 0, baseBuf, pos);
  9727. pos += baseNumComps;
  9728. }
  9729. }
  9730. if (!isPassthrough) {
  9731. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  9732. }
  9733. },
  9734. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  9735. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  9736. },
  9737. isPassthrough: ColorSpace.prototype.isPassthrough,
  9738. fillRgb: ColorSpace.prototype.fillRgb,
  9739. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  9740. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9741. },
  9742. usesZeroToOneRange: true
  9743. };
  9744. return AlternateCS;
  9745. }();
  9746. var PatternCS = function PatternCSClosure() {
  9747. function PatternCS(baseCS) {
  9748. this.name = 'Pattern';
  9749. this.base = baseCS;
  9750. }
  9751. PatternCS.prototype = {};
  9752. return PatternCS;
  9753. }();
  9754. var IndexedCS = function IndexedCSClosure() {
  9755. function IndexedCS(base, highVal, lookup) {
  9756. this.name = 'Indexed';
  9757. this.numComps = 1;
  9758. this.defaultColor = new Uint8Array(this.numComps);
  9759. this.base = base;
  9760. this.highVal = highVal;
  9761. var baseNumComps = base.numComps;
  9762. var length = baseNumComps * highVal;
  9763. if (isStream(lookup)) {
  9764. this.lookup = new Uint8Array(length);
  9765. var bytes = lookup.getBytes(length);
  9766. this.lookup.set(bytes);
  9767. } else if (isString(lookup)) {
  9768. this.lookup = new Uint8Array(length);
  9769. for (var i = 0; i < length; ++i) {
  9770. this.lookup[i] = lookup.charCodeAt(i);
  9771. }
  9772. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  9773. this.lookup = lookup;
  9774. } else {
  9775. error('Unrecognized lookup table: ' + lookup);
  9776. }
  9777. }
  9778. IndexedCS.prototype = {
  9779. getRgb: ColorSpace.prototype.getRgb,
  9780. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9781. var numComps = this.base.numComps;
  9782. var start = src[srcOffset] * numComps;
  9783. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  9784. },
  9785. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9786. var base = this.base;
  9787. var numComps = base.numComps;
  9788. var outputDelta = base.getOutputLength(numComps, alpha01);
  9789. var lookup = this.lookup;
  9790. for (var i = 0; i < count; ++i) {
  9791. var lookupPos = src[srcOffset++] * numComps;
  9792. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  9793. destOffset += outputDelta;
  9794. }
  9795. },
  9796. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  9797. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  9798. },
  9799. isPassthrough: ColorSpace.prototype.isPassthrough,
  9800. fillRgb: ColorSpace.prototype.fillRgb,
  9801. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  9802. return true;
  9803. },
  9804. usesZeroToOneRange: true
  9805. };
  9806. return IndexedCS;
  9807. }();
  9808. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9809. function DeviceGrayCS() {
  9810. this.name = 'DeviceGray';
  9811. this.numComps = 1;
  9812. this.defaultColor = new Float32Array(this.numComps);
  9813. }
  9814. DeviceGrayCS.prototype = {
  9815. getRgb: ColorSpace.prototype.getRgb,
  9816. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9817. var c = src[srcOffset] * 255 | 0;
  9818. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9819. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9820. },
  9821. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9822. var scale = 255 / ((1 << bits) - 1);
  9823. var j = srcOffset, q = destOffset;
  9824. for (var i = 0; i < count; ++i) {
  9825. var c = scale * src[j++] | 0;
  9826. dest[q++] = c;
  9827. dest[q++] = c;
  9828. dest[q++] = c;
  9829. q += alpha01;
  9830. }
  9831. },
  9832. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9833. return inputLength * (3 + alpha01);
  9834. },
  9835. isPassthrough: ColorSpace.prototype.isPassthrough,
  9836. fillRgb: ColorSpace.prototype.fillRgb,
  9837. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9838. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9839. },
  9840. usesZeroToOneRange: true
  9841. };
  9842. return DeviceGrayCS;
  9843. }();
  9844. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9845. function DeviceRgbCS() {
  9846. this.name = 'DeviceRGB';
  9847. this.numComps = 3;
  9848. this.defaultColor = new Float32Array(this.numComps);
  9849. }
  9850. DeviceRgbCS.prototype = {
  9851. getRgb: ColorSpace.prototype.getRgb,
  9852. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9853. var r = src[srcOffset] * 255 | 0;
  9854. var g = src[srcOffset + 1] * 255 | 0;
  9855. var b = src[srcOffset + 2] * 255 | 0;
  9856. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9857. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9858. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9859. },
  9860. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9861. if (bits === 8 && alpha01 === 0) {
  9862. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9863. return;
  9864. }
  9865. var scale = 255 / ((1 << bits) - 1);
  9866. var j = srcOffset, q = destOffset;
  9867. for (var i = 0; i < count; ++i) {
  9868. dest[q++] = scale * src[j++] | 0;
  9869. dest[q++] = scale * src[j++] | 0;
  9870. dest[q++] = scale * src[j++] | 0;
  9871. q += alpha01;
  9872. }
  9873. },
  9874. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9875. return inputLength * (3 + alpha01) / 3 | 0;
  9876. },
  9877. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9878. return bits === 8;
  9879. },
  9880. fillRgb: ColorSpace.prototype.fillRgb,
  9881. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9882. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9883. },
  9884. usesZeroToOneRange: true
  9885. };
  9886. return DeviceRgbCS;
  9887. }();
  9888. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9889. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9890. var c = src[srcOffset + 0] * srcScale;
  9891. var m = src[srcOffset + 1] * srcScale;
  9892. var y = src[srcOffset + 2] * srcScale;
  9893. var k = src[srcOffset + 3] * srcScale;
  9894. 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;
  9895. 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;
  9896. 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;
  9897. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9898. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9899. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9900. }
  9901. function DeviceCmykCS() {
  9902. this.name = 'DeviceCMYK';
  9903. this.numComps = 4;
  9904. this.defaultColor = new Float32Array(this.numComps);
  9905. this.defaultColor[3] = 1;
  9906. }
  9907. DeviceCmykCS.prototype = {
  9908. getRgb: ColorSpace.prototype.getRgb,
  9909. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9910. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9911. },
  9912. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9913. var scale = 1 / ((1 << bits) - 1);
  9914. for (var i = 0; i < count; i++) {
  9915. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9916. srcOffset += 4;
  9917. destOffset += 3 + alpha01;
  9918. }
  9919. },
  9920. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9921. return inputLength / 4 * (3 + alpha01) | 0;
  9922. },
  9923. isPassthrough: ColorSpace.prototype.isPassthrough,
  9924. fillRgb: ColorSpace.prototype.fillRgb,
  9925. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9926. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9927. },
  9928. usesZeroToOneRange: true
  9929. };
  9930. return DeviceCmykCS;
  9931. }();
  9932. var CalGrayCS = function CalGrayCSClosure() {
  9933. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9934. this.name = 'CalGray';
  9935. this.numComps = 1;
  9936. this.defaultColor = new Float32Array(this.numComps);
  9937. if (!whitePoint) {
  9938. error('WhitePoint missing - required for color space CalGray');
  9939. }
  9940. blackPoint = blackPoint || [
  9941. 0,
  9942. 0,
  9943. 0
  9944. ];
  9945. gamma = gamma || 1;
  9946. this.XW = whitePoint[0];
  9947. this.YW = whitePoint[1];
  9948. this.ZW = whitePoint[2];
  9949. this.XB = blackPoint[0];
  9950. this.YB = blackPoint[1];
  9951. this.ZB = blackPoint[2];
  9952. this.G = gamma;
  9953. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9954. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9955. }
  9956. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9957. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9958. this.XB = this.YB = this.ZB = 0;
  9959. }
  9960. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9961. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9962. }
  9963. if (this.G < 1) {
  9964. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9965. this.G = 1;
  9966. }
  9967. }
  9968. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9969. var A = src[srcOffset] * scale;
  9970. var AG = Math.pow(A, cs.G);
  9971. var L = cs.YW * AG;
  9972. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9973. dest[destOffset] = val;
  9974. dest[destOffset + 1] = val;
  9975. dest[destOffset + 2] = val;
  9976. }
  9977. CalGrayCS.prototype = {
  9978. getRgb: ColorSpace.prototype.getRgb,
  9979. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9980. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9981. },
  9982. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9983. var scale = 1 / ((1 << bits) - 1);
  9984. for (var i = 0; i < count; ++i) {
  9985. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9986. srcOffset += 1;
  9987. destOffset += 3 + alpha01;
  9988. }
  9989. },
  9990. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9991. return inputLength * (3 + alpha01);
  9992. },
  9993. isPassthrough: ColorSpace.prototype.isPassthrough,
  9994. fillRgb: ColorSpace.prototype.fillRgb,
  9995. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9996. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9997. },
  9998. usesZeroToOneRange: true
  9999. };
  10000. return CalGrayCS;
  10001. }();
  10002. var CalRGBCS = function CalRGBCSClosure() {
  10003. var BRADFORD_SCALE_MATRIX = new Float32Array([
  10004. 0.8951,
  10005. 0.2664,
  10006. -0.1614,
  10007. -0.7502,
  10008. 1.7135,
  10009. 0.0367,
  10010. 0.0389,
  10011. -0.0685,
  10012. 1.0296
  10013. ]);
  10014. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  10015. 0.9869929,
  10016. -0.1470543,
  10017. 0.1599627,
  10018. 0.4323053,
  10019. 0.5183603,
  10020. 0.0492912,
  10021. -0.0085287,
  10022. 0.0400428,
  10023. 0.9684867
  10024. ]);
  10025. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  10026. 3.2404542,
  10027. -1.5371385,
  10028. -0.4985314,
  10029. -0.9692660,
  10030. 1.8760108,
  10031. 0.0415560,
  10032. 0.0556434,
  10033. -0.2040259,
  10034. 1.0572252
  10035. ]);
  10036. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  10037. 1,
  10038. 1,
  10039. 1
  10040. ]);
  10041. var tempNormalizeMatrix = new Float32Array(3);
  10042. var tempConvertMatrix1 = new Float32Array(3);
  10043. var tempConvertMatrix2 = new Float32Array(3);
  10044. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  10045. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  10046. this.name = 'CalRGB';
  10047. this.numComps = 3;
  10048. this.defaultColor = new Float32Array(this.numComps);
  10049. if (!whitePoint) {
  10050. error('WhitePoint missing - required for color space CalRGB');
  10051. }
  10052. blackPoint = blackPoint || new Float32Array(3);
  10053. gamma = gamma || new Float32Array([
  10054. 1,
  10055. 1,
  10056. 1
  10057. ]);
  10058. matrix = matrix || new Float32Array([
  10059. 1,
  10060. 0,
  10061. 0,
  10062. 0,
  10063. 1,
  10064. 0,
  10065. 0,
  10066. 0,
  10067. 1
  10068. ]);
  10069. var XW = whitePoint[0];
  10070. var YW = whitePoint[1];
  10071. var ZW = whitePoint[2];
  10072. this.whitePoint = whitePoint;
  10073. var XB = blackPoint[0];
  10074. var YB = blackPoint[1];
  10075. var ZB = blackPoint[2];
  10076. this.blackPoint = blackPoint;
  10077. this.GR = gamma[0];
  10078. this.GG = gamma[1];
  10079. this.GB = gamma[2];
  10080. this.MXA = matrix[0];
  10081. this.MYA = matrix[1];
  10082. this.MZA = matrix[2];
  10083. this.MXB = matrix[3];
  10084. this.MYB = matrix[4];
  10085. this.MZB = matrix[5];
  10086. this.MXC = matrix[6];
  10087. this.MYC = matrix[7];
  10088. this.MZC = matrix[8];
  10089. if (XW < 0 || ZW < 0 || YW !== 1) {
  10090. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  10091. }
  10092. if (XB < 0 || YB < 0 || ZB < 0) {
  10093. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  10094. this.blackPoint = new Float32Array(3);
  10095. }
  10096. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  10097. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  10098. this.GR = this.GG = this.GB = 1;
  10099. }
  10100. 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) {
  10101. 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');
  10102. this.MXA = this.MYB = this.MZC = 1;
  10103. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  10104. }
  10105. }
  10106. function matrixProduct(a, b, result) {
  10107. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  10108. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  10109. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  10110. }
  10111. function convertToFlat(sourceWhitePoint, LMS, result) {
  10112. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  10113. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  10114. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  10115. }
  10116. function convertToD65(sourceWhitePoint, LMS, result) {
  10117. var D65X = 0.95047;
  10118. var D65Y = 1;
  10119. var D65Z = 1.08883;
  10120. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  10121. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  10122. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  10123. }
  10124. function sRGBTransferFunction(color) {
  10125. if (color <= 0.0031308) {
  10126. return adjustToRange(0, 1, 12.92 * color);
  10127. }
  10128. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  10129. }
  10130. function adjustToRange(min, max, value) {
  10131. return Math.max(min, Math.min(max, value));
  10132. }
  10133. function decodeL(L) {
  10134. if (L < 0) {
  10135. return -decodeL(-L);
  10136. }
  10137. if (L > 8.0) {
  10138. return Math.pow((L + 16) / 116, 3);
  10139. }
  10140. return L * DECODE_L_CONSTANT;
  10141. }
  10142. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  10143. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  10144. result[0] = XYZ_Flat[0];
  10145. result[1] = XYZ_Flat[1];
  10146. result[2] = XYZ_Flat[2];
  10147. return;
  10148. }
  10149. var zeroDecodeL = decodeL(0);
  10150. var X_DST = zeroDecodeL;
  10151. var X_SRC = decodeL(sourceBlackPoint[0]);
  10152. var Y_DST = zeroDecodeL;
  10153. var Y_SRC = decodeL(sourceBlackPoint[1]);
  10154. var Z_DST = zeroDecodeL;
  10155. var Z_SRC = decodeL(sourceBlackPoint[2]);
  10156. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  10157. var X_Offset = 1 - X_Scale;
  10158. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  10159. var Y_Offset = 1 - Y_Scale;
  10160. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  10161. var Z_Offset = 1 - Z_Scale;
  10162. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  10163. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  10164. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  10165. }
  10166. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  10167. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  10168. result[0] = XYZ_In[0];
  10169. result[1] = XYZ_In[1];
  10170. result[2] = XYZ_In[2];
  10171. return;
  10172. }
  10173. var LMS = result;
  10174. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10175. var LMS_Flat = tempNormalizeMatrix;
  10176. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  10177. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  10178. }
  10179. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  10180. var LMS = result;
  10181. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10182. var LMS_D65 = tempNormalizeMatrix;
  10183. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  10184. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  10185. }
  10186. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  10187. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  10188. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  10189. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  10190. var AGR = Math.pow(A, cs.GR);
  10191. var BGG = Math.pow(B, cs.GG);
  10192. var CGB = Math.pow(C, cs.GB);
  10193. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  10194. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  10195. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  10196. var XYZ = tempConvertMatrix1;
  10197. XYZ[0] = X;
  10198. XYZ[1] = Y;
  10199. XYZ[2] = Z;
  10200. var XYZ_Flat = tempConvertMatrix2;
  10201. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  10202. var XYZ_Black = tempConvertMatrix1;
  10203. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  10204. var XYZ_D65 = tempConvertMatrix2;
  10205. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  10206. var SRGB = tempConvertMatrix1;
  10207. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  10208. var sR = sRGBTransferFunction(SRGB[0]);
  10209. var sG = sRGBTransferFunction(SRGB[1]);
  10210. var sB = sRGBTransferFunction(SRGB[2]);
  10211. dest[destOffset] = Math.round(sR * 255);
  10212. dest[destOffset + 1] = Math.round(sG * 255);
  10213. dest[destOffset + 2] = Math.round(sB * 255);
  10214. }
  10215. CalRGBCS.prototype = {
  10216. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  10217. var rgb = new Uint8Array(3);
  10218. this.getRgbItem(src, srcOffset, rgb, 0);
  10219. return rgb;
  10220. },
  10221. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10222. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  10223. },
  10224. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10225. var scale = 1 / ((1 << bits) - 1);
  10226. for (var i = 0; i < count; ++i) {
  10227. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  10228. srcOffset += 3;
  10229. destOffset += 3 + alpha01;
  10230. }
  10231. },
  10232. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  10233. return inputLength * (3 + alpha01) / 3 | 0;
  10234. },
  10235. isPassthrough: ColorSpace.prototype.isPassthrough,
  10236. fillRgb: ColorSpace.prototype.fillRgb,
  10237. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  10238. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10239. },
  10240. usesZeroToOneRange: true
  10241. };
  10242. return CalRGBCS;
  10243. }();
  10244. var LabCS = function LabCSClosure() {
  10245. function LabCS(whitePoint, blackPoint, range) {
  10246. this.name = 'Lab';
  10247. this.numComps = 3;
  10248. this.defaultColor = new Float32Array(this.numComps);
  10249. if (!whitePoint) {
  10250. error('WhitePoint missing - required for color space Lab');
  10251. }
  10252. blackPoint = blackPoint || [
  10253. 0,
  10254. 0,
  10255. 0
  10256. ];
  10257. range = range || [
  10258. -100,
  10259. 100,
  10260. -100,
  10261. 100
  10262. ];
  10263. this.XW = whitePoint[0];
  10264. this.YW = whitePoint[1];
  10265. this.ZW = whitePoint[2];
  10266. this.amin = range[0];
  10267. this.amax = range[1];
  10268. this.bmin = range[2];
  10269. this.bmax = range[3];
  10270. this.XB = blackPoint[0];
  10271. this.YB = blackPoint[1];
  10272. this.ZB = blackPoint[2];
  10273. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  10274. error('Invalid WhitePoint components, no fallback available');
  10275. }
  10276. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  10277. info('Invalid BlackPoint, falling back to default');
  10278. this.XB = this.YB = this.ZB = 0;
  10279. }
  10280. if (this.amin > this.amax || this.bmin > this.bmax) {
  10281. info('Invalid Range, falling back to defaults');
  10282. this.amin = -100;
  10283. this.amax = 100;
  10284. this.bmin = -100;
  10285. this.bmax = 100;
  10286. }
  10287. }
  10288. function fn_g(x) {
  10289. var result;
  10290. if (x >= 6 / 29) {
  10291. result = x * x * x;
  10292. } else {
  10293. result = 108 / 841 * (x - 4 / 29);
  10294. }
  10295. return result;
  10296. }
  10297. function decode(value, high1, low2, high2) {
  10298. return low2 + value * (high2 - low2) / high1;
  10299. }
  10300. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  10301. var Ls = src[srcOffset];
  10302. var as = src[srcOffset + 1];
  10303. var bs = src[srcOffset + 2];
  10304. if (maxVal !== false) {
  10305. Ls = decode(Ls, maxVal, 0, 100);
  10306. as = decode(as, maxVal, cs.amin, cs.amax);
  10307. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  10308. }
  10309. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  10310. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  10311. var M = (Ls + 16) / 116;
  10312. var L = M + as / 500;
  10313. var N = M - bs / 200;
  10314. var X = cs.XW * fn_g(L);
  10315. var Y = cs.YW * fn_g(M);
  10316. var Z = cs.ZW * fn_g(N);
  10317. var r, g, b;
  10318. if (cs.ZW < 1) {
  10319. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  10320. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  10321. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  10322. } else {
  10323. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  10324. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  10325. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  10326. }
  10327. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  10328. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  10329. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  10330. }
  10331. LabCS.prototype = {
  10332. getRgb: ColorSpace.prototype.getRgb,
  10333. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10334. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  10335. },
  10336. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10337. var maxVal = (1 << bits) - 1;
  10338. for (var i = 0; i < count; i++) {
  10339. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  10340. srcOffset += 3;
  10341. destOffset += 3 + alpha01;
  10342. }
  10343. },
  10344. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  10345. return inputLength * (3 + alpha01) / 3 | 0;
  10346. },
  10347. isPassthrough: ColorSpace.prototype.isPassthrough,
  10348. fillRgb: ColorSpace.prototype.fillRgb,
  10349. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  10350. return true;
  10351. },
  10352. usesZeroToOneRange: false
  10353. };
  10354. return LabCS;
  10355. }();
  10356. exports.ColorSpace = ColorSpace;
  10357. /***/ }),
  10358. /* 5 */
  10359. /***/ (function(module, exports, __w_pdfjs_require__) {
  10360. "use strict";
  10361. var ExpertEncoding = [
  10362. '',
  10363. '',
  10364. '',
  10365. '',
  10366. '',
  10367. '',
  10368. '',
  10369. '',
  10370. '',
  10371. '',
  10372. '',
  10373. '',
  10374. '',
  10375. '',
  10376. '',
  10377. '',
  10378. '',
  10379. '',
  10380. '',
  10381. '',
  10382. '',
  10383. '',
  10384. '',
  10385. '',
  10386. '',
  10387. '',
  10388. '',
  10389. '',
  10390. '',
  10391. '',
  10392. '',
  10393. '',
  10394. 'space',
  10395. 'exclamsmall',
  10396. 'Hungarumlautsmall',
  10397. '',
  10398. 'dollaroldstyle',
  10399. 'dollarsuperior',
  10400. 'ampersandsmall',
  10401. 'Acutesmall',
  10402. 'parenleftsuperior',
  10403. 'parenrightsuperior',
  10404. 'twodotenleader',
  10405. 'onedotenleader',
  10406. 'comma',
  10407. 'hyphen',
  10408. 'period',
  10409. 'fraction',
  10410. 'zerooldstyle',
  10411. 'oneoldstyle',
  10412. 'twooldstyle',
  10413. 'threeoldstyle',
  10414. 'fouroldstyle',
  10415. 'fiveoldstyle',
  10416. 'sixoldstyle',
  10417. 'sevenoldstyle',
  10418. 'eightoldstyle',
  10419. 'nineoldstyle',
  10420. 'colon',
  10421. 'semicolon',
  10422. 'commasuperior',
  10423. 'threequartersemdash',
  10424. 'periodsuperior',
  10425. 'questionsmall',
  10426. '',
  10427. 'asuperior',
  10428. 'bsuperior',
  10429. 'centsuperior',
  10430. 'dsuperior',
  10431. 'esuperior',
  10432. '',
  10433. '',
  10434. 'isuperior',
  10435. '',
  10436. '',
  10437. 'lsuperior',
  10438. 'msuperior',
  10439. 'nsuperior',
  10440. 'osuperior',
  10441. '',
  10442. '',
  10443. 'rsuperior',
  10444. 'ssuperior',
  10445. 'tsuperior',
  10446. '',
  10447. 'ff',
  10448. 'fi',
  10449. 'fl',
  10450. 'ffi',
  10451. 'ffl',
  10452. 'parenleftinferior',
  10453. '',
  10454. 'parenrightinferior',
  10455. 'Circumflexsmall',
  10456. 'hyphensuperior',
  10457. 'Gravesmall',
  10458. 'Asmall',
  10459. 'Bsmall',
  10460. 'Csmall',
  10461. 'Dsmall',
  10462. 'Esmall',
  10463. 'Fsmall',
  10464. 'Gsmall',
  10465. 'Hsmall',
  10466. 'Ismall',
  10467. 'Jsmall',
  10468. 'Ksmall',
  10469. 'Lsmall',
  10470. 'Msmall',
  10471. 'Nsmall',
  10472. 'Osmall',
  10473. 'Psmall',
  10474. 'Qsmall',
  10475. 'Rsmall',
  10476. 'Ssmall',
  10477. 'Tsmall',
  10478. 'Usmall',
  10479. 'Vsmall',
  10480. 'Wsmall',
  10481. 'Xsmall',
  10482. 'Ysmall',
  10483. 'Zsmall',
  10484. 'colonmonetary',
  10485. 'onefitted',
  10486. 'rupiah',
  10487. 'Tildesmall',
  10488. '',
  10489. '',
  10490. '',
  10491. '',
  10492. '',
  10493. '',
  10494. '',
  10495. '',
  10496. '',
  10497. '',
  10498. '',
  10499. '',
  10500. '',
  10501. '',
  10502. '',
  10503. '',
  10504. '',
  10505. '',
  10506. '',
  10507. '',
  10508. '',
  10509. '',
  10510. '',
  10511. '',
  10512. '',
  10513. '',
  10514. '',
  10515. '',
  10516. '',
  10517. '',
  10518. '',
  10519. '',
  10520. '',
  10521. '',
  10522. 'exclamdownsmall',
  10523. 'centoldstyle',
  10524. 'Lslashsmall',
  10525. '',
  10526. '',
  10527. 'Scaronsmall',
  10528. 'Zcaronsmall',
  10529. 'Dieresissmall',
  10530. 'Brevesmall',
  10531. 'Caronsmall',
  10532. '',
  10533. 'Dotaccentsmall',
  10534. '',
  10535. '',
  10536. 'Macronsmall',
  10537. '',
  10538. '',
  10539. 'figuredash',
  10540. 'hypheninferior',
  10541. '',
  10542. '',
  10543. 'Ogoneksmall',
  10544. 'Ringsmall',
  10545. 'Cedillasmall',
  10546. '',
  10547. '',
  10548. '',
  10549. 'onequarter',
  10550. 'onehalf',
  10551. 'threequarters',
  10552. 'questiondownsmall',
  10553. 'oneeighth',
  10554. 'threeeighths',
  10555. 'fiveeighths',
  10556. 'seveneighths',
  10557. 'onethird',
  10558. 'twothirds',
  10559. '',
  10560. '',
  10561. 'zerosuperior',
  10562. 'onesuperior',
  10563. 'twosuperior',
  10564. 'threesuperior',
  10565. 'foursuperior',
  10566. 'fivesuperior',
  10567. 'sixsuperior',
  10568. 'sevensuperior',
  10569. 'eightsuperior',
  10570. 'ninesuperior',
  10571. 'zeroinferior',
  10572. 'oneinferior',
  10573. 'twoinferior',
  10574. 'threeinferior',
  10575. 'fourinferior',
  10576. 'fiveinferior',
  10577. 'sixinferior',
  10578. 'seveninferior',
  10579. 'eightinferior',
  10580. 'nineinferior',
  10581. 'centinferior',
  10582. 'dollarinferior',
  10583. 'periodinferior',
  10584. 'commainferior',
  10585. 'Agravesmall',
  10586. 'Aacutesmall',
  10587. 'Acircumflexsmall',
  10588. 'Atildesmall',
  10589. 'Adieresissmall',
  10590. 'Aringsmall',
  10591. 'AEsmall',
  10592. 'Ccedillasmall',
  10593. 'Egravesmall',
  10594. 'Eacutesmall',
  10595. 'Ecircumflexsmall',
  10596. 'Edieresissmall',
  10597. 'Igravesmall',
  10598. 'Iacutesmall',
  10599. 'Icircumflexsmall',
  10600. 'Idieresissmall',
  10601. 'Ethsmall',
  10602. 'Ntildesmall',
  10603. 'Ogravesmall',
  10604. 'Oacutesmall',
  10605. 'Ocircumflexsmall',
  10606. 'Otildesmall',
  10607. 'Odieresissmall',
  10608. 'OEsmall',
  10609. 'Oslashsmall',
  10610. 'Ugravesmall',
  10611. 'Uacutesmall',
  10612. 'Ucircumflexsmall',
  10613. 'Udieresissmall',
  10614. 'Yacutesmall',
  10615. 'Thornsmall',
  10616. 'Ydieresissmall'
  10617. ];
  10618. var MacExpertEncoding = [
  10619. '',
  10620. '',
  10621. '',
  10622. '',
  10623. '',
  10624. '',
  10625. '',
  10626. '',
  10627. '',
  10628. '',
  10629. '',
  10630. '',
  10631. '',
  10632. '',
  10633. '',
  10634. '',
  10635. '',
  10636. '',
  10637. '',
  10638. '',
  10639. '',
  10640. '',
  10641. '',
  10642. '',
  10643. '',
  10644. '',
  10645. '',
  10646. '',
  10647. '',
  10648. '',
  10649. '',
  10650. '',
  10651. 'space',
  10652. 'exclamsmall',
  10653. 'Hungarumlautsmall',
  10654. 'centoldstyle',
  10655. 'dollaroldstyle',
  10656. 'dollarsuperior',
  10657. 'ampersandsmall',
  10658. 'Acutesmall',
  10659. 'parenleftsuperior',
  10660. 'parenrightsuperior',
  10661. 'twodotenleader',
  10662. 'onedotenleader',
  10663. 'comma',
  10664. 'hyphen',
  10665. 'period',
  10666. 'fraction',
  10667. 'zerooldstyle',
  10668. 'oneoldstyle',
  10669. 'twooldstyle',
  10670. 'threeoldstyle',
  10671. 'fouroldstyle',
  10672. 'fiveoldstyle',
  10673. 'sixoldstyle',
  10674. 'sevenoldstyle',
  10675. 'eightoldstyle',
  10676. 'nineoldstyle',
  10677. 'colon',
  10678. 'semicolon',
  10679. '',
  10680. 'threequartersemdash',
  10681. '',
  10682. 'questionsmall',
  10683. '',
  10684. '',
  10685. '',
  10686. '',
  10687. 'Ethsmall',
  10688. '',
  10689. '',
  10690. 'onequarter',
  10691. 'onehalf',
  10692. 'threequarters',
  10693. 'oneeighth',
  10694. 'threeeighths',
  10695. 'fiveeighths',
  10696. 'seveneighths',
  10697. 'onethird',
  10698. 'twothirds',
  10699. '',
  10700. '',
  10701. '',
  10702. '',
  10703. '',
  10704. '',
  10705. 'ff',
  10706. 'fi',
  10707. 'fl',
  10708. 'ffi',
  10709. 'ffl',
  10710. 'parenleftinferior',
  10711. '',
  10712. 'parenrightinferior',
  10713. 'Circumflexsmall',
  10714. 'hypheninferior',
  10715. 'Gravesmall',
  10716. 'Asmall',
  10717. 'Bsmall',
  10718. 'Csmall',
  10719. 'Dsmall',
  10720. 'Esmall',
  10721. 'Fsmall',
  10722. 'Gsmall',
  10723. 'Hsmall',
  10724. 'Ismall',
  10725. 'Jsmall',
  10726. 'Ksmall',
  10727. 'Lsmall',
  10728. 'Msmall',
  10729. 'Nsmall',
  10730. 'Osmall',
  10731. 'Psmall',
  10732. 'Qsmall',
  10733. 'Rsmall',
  10734. 'Ssmall',
  10735. 'Tsmall',
  10736. 'Usmall',
  10737. 'Vsmall',
  10738. 'Wsmall',
  10739. 'Xsmall',
  10740. 'Ysmall',
  10741. 'Zsmall',
  10742. 'colonmonetary',
  10743. 'onefitted',
  10744. 'rupiah',
  10745. 'Tildesmall',
  10746. '',
  10747. '',
  10748. 'asuperior',
  10749. 'centsuperior',
  10750. '',
  10751. '',
  10752. '',
  10753. '',
  10754. 'Aacutesmall',
  10755. 'Agravesmall',
  10756. 'Acircumflexsmall',
  10757. 'Adieresissmall',
  10758. 'Atildesmall',
  10759. 'Aringsmall',
  10760. 'Ccedillasmall',
  10761. 'Eacutesmall',
  10762. 'Egravesmall',
  10763. 'Ecircumflexsmall',
  10764. 'Edieresissmall',
  10765. 'Iacutesmall',
  10766. 'Igravesmall',
  10767. 'Icircumflexsmall',
  10768. 'Idieresissmall',
  10769. 'Ntildesmall',
  10770. 'Oacutesmall',
  10771. 'Ogravesmall',
  10772. 'Ocircumflexsmall',
  10773. 'Odieresissmall',
  10774. 'Otildesmall',
  10775. 'Uacutesmall',
  10776. 'Ugravesmall',
  10777. 'Ucircumflexsmall',
  10778. 'Udieresissmall',
  10779. '',
  10780. 'eightsuperior',
  10781. 'fourinferior',
  10782. 'threeinferior',
  10783. 'sixinferior',
  10784. 'eightinferior',
  10785. 'seveninferior',
  10786. 'Scaronsmall',
  10787. '',
  10788. 'centinferior',
  10789. 'twoinferior',
  10790. '',
  10791. 'Dieresissmall',
  10792. '',
  10793. 'Caronsmall',
  10794. 'osuperior',
  10795. 'fiveinferior',
  10796. '',
  10797. 'commainferior',
  10798. 'periodinferior',
  10799. 'Yacutesmall',
  10800. '',
  10801. 'dollarinferior',
  10802. '',
  10803. 'Thornsmall',
  10804. '',
  10805. 'nineinferior',
  10806. 'zeroinferior',
  10807. 'Zcaronsmall',
  10808. 'AEsmall',
  10809. 'Oslashsmall',
  10810. 'questiondownsmall',
  10811. 'oneinferior',
  10812. 'Lslashsmall',
  10813. '',
  10814. '',
  10815. '',
  10816. '',
  10817. '',
  10818. '',
  10819. 'Cedillasmall',
  10820. '',
  10821. '',
  10822. '',
  10823. '',
  10824. '',
  10825. 'OEsmall',
  10826. 'figuredash',
  10827. 'hyphensuperior',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. 'exclamdownsmall',
  10833. '',
  10834. 'Ydieresissmall',
  10835. '',
  10836. 'onesuperior',
  10837. 'twosuperior',
  10838. 'threesuperior',
  10839. 'foursuperior',
  10840. 'fivesuperior',
  10841. 'sixsuperior',
  10842. 'sevensuperior',
  10843. 'ninesuperior',
  10844. 'zerosuperior',
  10845. '',
  10846. 'esuperior',
  10847. 'rsuperior',
  10848. 'tsuperior',
  10849. '',
  10850. '',
  10851. 'isuperior',
  10852. 'ssuperior',
  10853. 'dsuperior',
  10854. '',
  10855. '',
  10856. '',
  10857. '',
  10858. '',
  10859. 'lsuperior',
  10860. 'Ogoneksmall',
  10861. 'Brevesmall',
  10862. 'Macronsmall',
  10863. 'bsuperior',
  10864. 'nsuperior',
  10865. 'msuperior',
  10866. 'commasuperior',
  10867. 'periodsuperior',
  10868. 'Dotaccentsmall',
  10869. 'Ringsmall'
  10870. ];
  10871. var MacRomanEncoding = [
  10872. '',
  10873. '',
  10874. '',
  10875. '',
  10876. '',
  10877. '',
  10878. '',
  10879. '',
  10880. '',
  10881. '',
  10882. '',
  10883. '',
  10884. '',
  10885. '',
  10886. '',
  10887. '',
  10888. '',
  10889. '',
  10890. '',
  10891. '',
  10892. '',
  10893. '',
  10894. '',
  10895. '',
  10896. '',
  10897. '',
  10898. '',
  10899. '',
  10900. '',
  10901. '',
  10902. '',
  10903. '',
  10904. 'space',
  10905. 'exclam',
  10906. 'quotedbl',
  10907. 'numbersign',
  10908. 'dollar',
  10909. 'percent',
  10910. 'ampersand',
  10911. 'quotesingle',
  10912. 'parenleft',
  10913. 'parenright',
  10914. 'asterisk',
  10915. 'plus',
  10916. 'comma',
  10917. 'hyphen',
  10918. 'period',
  10919. 'slash',
  10920. 'zero',
  10921. 'one',
  10922. 'two',
  10923. 'three',
  10924. 'four',
  10925. 'five',
  10926. 'six',
  10927. 'seven',
  10928. 'eight',
  10929. 'nine',
  10930. 'colon',
  10931. 'semicolon',
  10932. 'less',
  10933. 'equal',
  10934. 'greater',
  10935. 'question',
  10936. 'at',
  10937. 'A',
  10938. 'B',
  10939. 'C',
  10940. 'D',
  10941. 'E',
  10942. 'F',
  10943. 'G',
  10944. 'H',
  10945. 'I',
  10946. 'J',
  10947. 'K',
  10948. 'L',
  10949. 'M',
  10950. 'N',
  10951. 'O',
  10952. 'P',
  10953. 'Q',
  10954. 'R',
  10955. 'S',
  10956. 'T',
  10957. 'U',
  10958. 'V',
  10959. 'W',
  10960. 'X',
  10961. 'Y',
  10962. 'Z',
  10963. 'bracketleft',
  10964. 'backslash',
  10965. 'bracketright',
  10966. 'asciicircum',
  10967. 'underscore',
  10968. 'grave',
  10969. 'a',
  10970. 'b',
  10971. 'c',
  10972. 'd',
  10973. 'e',
  10974. 'f',
  10975. 'g',
  10976. 'h',
  10977. 'i',
  10978. 'j',
  10979. 'k',
  10980. 'l',
  10981. 'm',
  10982. 'n',
  10983. 'o',
  10984. 'p',
  10985. 'q',
  10986. 'r',
  10987. 's',
  10988. 't',
  10989. 'u',
  10990. 'v',
  10991. 'w',
  10992. 'x',
  10993. 'y',
  10994. 'z',
  10995. 'braceleft',
  10996. 'bar',
  10997. 'braceright',
  10998. 'asciitilde',
  10999. '',
  11000. 'Adieresis',
  11001. 'Aring',
  11002. 'Ccedilla',
  11003. 'Eacute',
  11004. 'Ntilde',
  11005. 'Odieresis',
  11006. 'Udieresis',
  11007. 'aacute',
  11008. 'agrave',
  11009. 'acircumflex',
  11010. 'adieresis',
  11011. 'atilde',
  11012. 'aring',
  11013. 'ccedilla',
  11014. 'eacute',
  11015. 'egrave',
  11016. 'ecircumflex',
  11017. 'edieresis',
  11018. 'iacute',
  11019. 'igrave',
  11020. 'icircumflex',
  11021. 'idieresis',
  11022. 'ntilde',
  11023. 'oacute',
  11024. 'ograve',
  11025. 'ocircumflex',
  11026. 'odieresis',
  11027. 'otilde',
  11028. 'uacute',
  11029. 'ugrave',
  11030. 'ucircumflex',
  11031. 'udieresis',
  11032. 'dagger',
  11033. 'degree',
  11034. 'cent',
  11035. 'sterling',
  11036. 'section',
  11037. 'bullet',
  11038. 'paragraph',
  11039. 'germandbls',
  11040. 'registered',
  11041. 'copyright',
  11042. 'trademark',
  11043. 'acute',
  11044. 'dieresis',
  11045. 'notequal',
  11046. 'AE',
  11047. 'Oslash',
  11048. 'infinity',
  11049. 'plusminus',
  11050. 'lessequal',
  11051. 'greaterequal',
  11052. 'yen',
  11053. 'mu',
  11054. 'partialdiff',
  11055. 'summation',
  11056. 'product',
  11057. 'pi',
  11058. 'integral',
  11059. 'ordfeminine',
  11060. 'ordmasculine',
  11061. 'Omega',
  11062. 'ae',
  11063. 'oslash',
  11064. 'questiondown',
  11065. 'exclamdown',
  11066. 'logicalnot',
  11067. 'radical',
  11068. 'florin',
  11069. 'approxequal',
  11070. 'Delta',
  11071. 'guillemotleft',
  11072. 'guillemotright',
  11073. 'ellipsis',
  11074. 'space',
  11075. 'Agrave',
  11076. 'Atilde',
  11077. 'Otilde',
  11078. 'OE',
  11079. 'oe',
  11080. 'endash',
  11081. 'emdash',
  11082. 'quotedblleft',
  11083. 'quotedblright',
  11084. 'quoteleft',
  11085. 'quoteright',
  11086. 'divide',
  11087. 'lozenge',
  11088. 'ydieresis',
  11089. 'Ydieresis',
  11090. 'fraction',
  11091. 'currency',
  11092. 'guilsinglleft',
  11093. 'guilsinglright',
  11094. 'fi',
  11095. 'fl',
  11096. 'daggerdbl',
  11097. 'periodcentered',
  11098. 'quotesinglbase',
  11099. 'quotedblbase',
  11100. 'perthousand',
  11101. 'Acircumflex',
  11102. 'Ecircumflex',
  11103. 'Aacute',
  11104. 'Edieresis',
  11105. 'Egrave',
  11106. 'Iacute',
  11107. 'Icircumflex',
  11108. 'Idieresis',
  11109. 'Igrave',
  11110. 'Oacute',
  11111. 'Ocircumflex',
  11112. 'apple',
  11113. 'Ograve',
  11114. 'Uacute',
  11115. 'Ucircumflex',
  11116. 'Ugrave',
  11117. 'dotlessi',
  11118. 'circumflex',
  11119. 'tilde',
  11120. 'macron',
  11121. 'breve',
  11122. 'dotaccent',
  11123. 'ring',
  11124. 'cedilla',
  11125. 'hungarumlaut',
  11126. 'ogonek',
  11127. 'caron'
  11128. ];
  11129. var StandardEncoding = [
  11130. '',
  11131. '',
  11132. '',
  11133. '',
  11134. '',
  11135. '',
  11136. '',
  11137. '',
  11138. '',
  11139. '',
  11140. '',
  11141. '',
  11142. '',
  11143. '',
  11144. '',
  11145. '',
  11146. '',
  11147. '',
  11148. '',
  11149. '',
  11150. '',
  11151. '',
  11152. '',
  11153. '',
  11154. '',
  11155. '',
  11156. '',
  11157. '',
  11158. '',
  11159. '',
  11160. '',
  11161. '',
  11162. 'space',
  11163. 'exclam',
  11164. 'quotedbl',
  11165. 'numbersign',
  11166. 'dollar',
  11167. 'percent',
  11168. 'ampersand',
  11169. 'quoteright',
  11170. 'parenleft',
  11171. 'parenright',
  11172. 'asterisk',
  11173. 'plus',
  11174. 'comma',
  11175. 'hyphen',
  11176. 'period',
  11177. 'slash',
  11178. 'zero',
  11179. 'one',
  11180. 'two',
  11181. 'three',
  11182. 'four',
  11183. 'five',
  11184. 'six',
  11185. 'seven',
  11186. 'eight',
  11187. 'nine',
  11188. 'colon',
  11189. 'semicolon',
  11190. 'less',
  11191. 'equal',
  11192. 'greater',
  11193. 'question',
  11194. 'at',
  11195. 'A',
  11196. 'B',
  11197. 'C',
  11198. 'D',
  11199. 'E',
  11200. 'F',
  11201. 'G',
  11202. 'H',
  11203. 'I',
  11204. 'J',
  11205. 'K',
  11206. 'L',
  11207. 'M',
  11208. 'N',
  11209. 'O',
  11210. 'P',
  11211. 'Q',
  11212. 'R',
  11213. 'S',
  11214. 'T',
  11215. 'U',
  11216. 'V',
  11217. 'W',
  11218. 'X',
  11219. 'Y',
  11220. 'Z',
  11221. 'bracketleft',
  11222. 'backslash',
  11223. 'bracketright',
  11224. 'asciicircum',
  11225. 'underscore',
  11226. 'quoteleft',
  11227. 'a',
  11228. 'b',
  11229. 'c',
  11230. 'd',
  11231. 'e',
  11232. 'f',
  11233. 'g',
  11234. 'h',
  11235. 'i',
  11236. 'j',
  11237. 'k',
  11238. 'l',
  11239. 'm',
  11240. 'n',
  11241. 'o',
  11242. 'p',
  11243. 'q',
  11244. 'r',
  11245. 's',
  11246. 't',
  11247. 'u',
  11248. 'v',
  11249. 'w',
  11250. 'x',
  11251. 'y',
  11252. 'z',
  11253. 'braceleft',
  11254. 'bar',
  11255. 'braceright',
  11256. 'asciitilde',
  11257. '',
  11258. '',
  11259. '',
  11260. '',
  11261. '',
  11262. '',
  11263. '',
  11264. '',
  11265. '',
  11266. '',
  11267. '',
  11268. '',
  11269. '',
  11270. '',
  11271. '',
  11272. '',
  11273. '',
  11274. '',
  11275. '',
  11276. '',
  11277. '',
  11278. '',
  11279. '',
  11280. '',
  11281. '',
  11282. '',
  11283. '',
  11284. '',
  11285. '',
  11286. '',
  11287. '',
  11288. '',
  11289. '',
  11290. '',
  11291. 'exclamdown',
  11292. 'cent',
  11293. 'sterling',
  11294. 'fraction',
  11295. 'yen',
  11296. 'florin',
  11297. 'section',
  11298. 'currency',
  11299. 'quotesingle',
  11300. 'quotedblleft',
  11301. 'guillemotleft',
  11302. 'guilsinglleft',
  11303. 'guilsinglright',
  11304. 'fi',
  11305. 'fl',
  11306. '',
  11307. 'endash',
  11308. 'dagger',
  11309. 'daggerdbl',
  11310. 'periodcentered',
  11311. '',
  11312. 'paragraph',
  11313. 'bullet',
  11314. 'quotesinglbase',
  11315. 'quotedblbase',
  11316. 'quotedblright',
  11317. 'guillemotright',
  11318. 'ellipsis',
  11319. 'perthousand',
  11320. '',
  11321. 'questiondown',
  11322. '',
  11323. 'grave',
  11324. 'acute',
  11325. 'circumflex',
  11326. 'tilde',
  11327. 'macron',
  11328. 'breve',
  11329. 'dotaccent',
  11330. 'dieresis',
  11331. '',
  11332. 'ring',
  11333. 'cedilla',
  11334. '',
  11335. 'hungarumlaut',
  11336. 'ogonek',
  11337. 'caron',
  11338. 'emdash',
  11339. '',
  11340. '',
  11341. '',
  11342. '',
  11343. '',
  11344. '',
  11345. '',
  11346. '',
  11347. '',
  11348. '',
  11349. '',
  11350. '',
  11351. '',
  11352. '',
  11353. '',
  11354. '',
  11355. 'AE',
  11356. '',
  11357. 'ordfeminine',
  11358. '',
  11359. '',
  11360. '',
  11361. '',
  11362. 'Lslash',
  11363. 'Oslash',
  11364. 'OE',
  11365. 'ordmasculine',
  11366. '',
  11367. '',
  11368. '',
  11369. '',
  11370. '',
  11371. 'ae',
  11372. '',
  11373. '',
  11374. '',
  11375. 'dotlessi',
  11376. '',
  11377. '',
  11378. 'lslash',
  11379. 'oslash',
  11380. 'oe',
  11381. 'germandbls'
  11382. ];
  11383. var WinAnsiEncoding = [
  11384. '',
  11385. '',
  11386. '',
  11387. '',
  11388. '',
  11389. '',
  11390. '',
  11391. '',
  11392. '',
  11393. '',
  11394. '',
  11395. '',
  11396. '',
  11397. '',
  11398. '',
  11399. '',
  11400. '',
  11401. '',
  11402. '',
  11403. '',
  11404. '',
  11405. '',
  11406. '',
  11407. '',
  11408. '',
  11409. '',
  11410. '',
  11411. '',
  11412. '',
  11413. '',
  11414. '',
  11415. '',
  11416. 'space',
  11417. 'exclam',
  11418. 'quotedbl',
  11419. 'numbersign',
  11420. 'dollar',
  11421. 'percent',
  11422. 'ampersand',
  11423. 'quotesingle',
  11424. 'parenleft',
  11425. 'parenright',
  11426. 'asterisk',
  11427. 'plus',
  11428. 'comma',
  11429. 'hyphen',
  11430. 'period',
  11431. 'slash',
  11432. 'zero',
  11433. 'one',
  11434. 'two',
  11435. 'three',
  11436. 'four',
  11437. 'five',
  11438. 'six',
  11439. 'seven',
  11440. 'eight',
  11441. 'nine',
  11442. 'colon',
  11443. 'semicolon',
  11444. 'less',
  11445. 'equal',
  11446. 'greater',
  11447. 'question',
  11448. 'at',
  11449. 'A',
  11450. 'B',
  11451. 'C',
  11452. 'D',
  11453. 'E',
  11454. 'F',
  11455. 'G',
  11456. 'H',
  11457. 'I',
  11458. 'J',
  11459. 'K',
  11460. 'L',
  11461. 'M',
  11462. 'N',
  11463. 'O',
  11464. 'P',
  11465. 'Q',
  11466. 'R',
  11467. 'S',
  11468. 'T',
  11469. 'U',
  11470. 'V',
  11471. 'W',
  11472. 'X',
  11473. 'Y',
  11474. 'Z',
  11475. 'bracketleft',
  11476. 'backslash',
  11477. 'bracketright',
  11478. 'asciicircum',
  11479. 'underscore',
  11480. 'grave',
  11481. 'a',
  11482. 'b',
  11483. 'c',
  11484. 'd',
  11485. 'e',
  11486. 'f',
  11487. 'g',
  11488. 'h',
  11489. 'i',
  11490. 'j',
  11491. 'k',
  11492. 'l',
  11493. 'm',
  11494. 'n',
  11495. 'o',
  11496. 'p',
  11497. 'q',
  11498. 'r',
  11499. 's',
  11500. 't',
  11501. 'u',
  11502. 'v',
  11503. 'w',
  11504. 'x',
  11505. 'y',
  11506. 'z',
  11507. 'braceleft',
  11508. 'bar',
  11509. 'braceright',
  11510. 'asciitilde',
  11511. 'bullet',
  11512. 'Euro',
  11513. 'bullet',
  11514. 'quotesinglbase',
  11515. 'florin',
  11516. 'quotedblbase',
  11517. 'ellipsis',
  11518. 'dagger',
  11519. 'daggerdbl',
  11520. 'circumflex',
  11521. 'perthousand',
  11522. 'Scaron',
  11523. 'guilsinglleft',
  11524. 'OE',
  11525. 'bullet',
  11526. 'Zcaron',
  11527. 'bullet',
  11528. 'bullet',
  11529. 'quoteleft',
  11530. 'quoteright',
  11531. 'quotedblleft',
  11532. 'quotedblright',
  11533. 'bullet',
  11534. 'endash',
  11535. 'emdash',
  11536. 'tilde',
  11537. 'trademark',
  11538. 'scaron',
  11539. 'guilsinglright',
  11540. 'oe',
  11541. 'bullet',
  11542. 'zcaron',
  11543. 'Ydieresis',
  11544. 'space',
  11545. 'exclamdown',
  11546. 'cent',
  11547. 'sterling',
  11548. 'currency',
  11549. 'yen',
  11550. 'brokenbar',
  11551. 'section',
  11552. 'dieresis',
  11553. 'copyright',
  11554. 'ordfeminine',
  11555. 'guillemotleft',
  11556. 'logicalnot',
  11557. 'hyphen',
  11558. 'registered',
  11559. 'macron',
  11560. 'degree',
  11561. 'plusminus',
  11562. 'twosuperior',
  11563. 'threesuperior',
  11564. 'acute',
  11565. 'mu',
  11566. 'paragraph',
  11567. 'periodcentered',
  11568. 'cedilla',
  11569. 'onesuperior',
  11570. 'ordmasculine',
  11571. 'guillemotright',
  11572. 'onequarter',
  11573. 'onehalf',
  11574. 'threequarters',
  11575. 'questiondown',
  11576. 'Agrave',
  11577. 'Aacute',
  11578. 'Acircumflex',
  11579. 'Atilde',
  11580. 'Adieresis',
  11581. 'Aring',
  11582. 'AE',
  11583. 'Ccedilla',
  11584. 'Egrave',
  11585. 'Eacute',
  11586. 'Ecircumflex',
  11587. 'Edieresis',
  11588. 'Igrave',
  11589. 'Iacute',
  11590. 'Icircumflex',
  11591. 'Idieresis',
  11592. 'Eth',
  11593. 'Ntilde',
  11594. 'Ograve',
  11595. 'Oacute',
  11596. 'Ocircumflex',
  11597. 'Otilde',
  11598. 'Odieresis',
  11599. 'multiply',
  11600. 'Oslash',
  11601. 'Ugrave',
  11602. 'Uacute',
  11603. 'Ucircumflex',
  11604. 'Udieresis',
  11605. 'Yacute',
  11606. 'Thorn',
  11607. 'germandbls',
  11608. 'agrave',
  11609. 'aacute',
  11610. 'acircumflex',
  11611. 'atilde',
  11612. 'adieresis',
  11613. 'aring',
  11614. 'ae',
  11615. 'ccedilla',
  11616. 'egrave',
  11617. 'eacute',
  11618. 'ecircumflex',
  11619. 'edieresis',
  11620. 'igrave',
  11621. 'iacute',
  11622. 'icircumflex',
  11623. 'idieresis',
  11624. 'eth',
  11625. 'ntilde',
  11626. 'ograve',
  11627. 'oacute',
  11628. 'ocircumflex',
  11629. 'otilde',
  11630. 'odieresis',
  11631. 'divide',
  11632. 'oslash',
  11633. 'ugrave',
  11634. 'uacute',
  11635. 'ucircumflex',
  11636. 'udieresis',
  11637. 'yacute',
  11638. 'thorn',
  11639. 'ydieresis'
  11640. ];
  11641. var SymbolSetEncoding = [
  11642. '',
  11643. '',
  11644. '',
  11645. '',
  11646. '',
  11647. '',
  11648. '',
  11649. '',
  11650. '',
  11651. '',
  11652. '',
  11653. '',
  11654. '',
  11655. '',
  11656. '',
  11657. '',
  11658. '',
  11659. '',
  11660. '',
  11661. '',
  11662. '',
  11663. '',
  11664. '',
  11665. '',
  11666. '',
  11667. '',
  11668. '',
  11669. '',
  11670. '',
  11671. '',
  11672. '',
  11673. '',
  11674. 'space',
  11675. 'exclam',
  11676. 'universal',
  11677. 'numbersign',
  11678. 'existential',
  11679. 'percent',
  11680. 'ampersand',
  11681. 'suchthat',
  11682. 'parenleft',
  11683. 'parenright',
  11684. 'asteriskmath',
  11685. 'plus',
  11686. 'comma',
  11687. 'minus',
  11688. 'period',
  11689. 'slash',
  11690. 'zero',
  11691. 'one',
  11692. 'two',
  11693. 'three',
  11694. 'four',
  11695. 'five',
  11696. 'six',
  11697. 'seven',
  11698. 'eight',
  11699. 'nine',
  11700. 'colon',
  11701. 'semicolon',
  11702. 'less',
  11703. 'equal',
  11704. 'greater',
  11705. 'question',
  11706. 'congruent',
  11707. 'Alpha',
  11708. 'Beta',
  11709. 'Chi',
  11710. 'Delta',
  11711. 'Epsilon',
  11712. 'Phi',
  11713. 'Gamma',
  11714. 'Eta',
  11715. 'Iota',
  11716. 'theta1',
  11717. 'Kappa',
  11718. 'Lambda',
  11719. 'Mu',
  11720. 'Nu',
  11721. 'Omicron',
  11722. 'Pi',
  11723. 'Theta',
  11724. 'Rho',
  11725. 'Sigma',
  11726. 'Tau',
  11727. 'Upsilon',
  11728. 'sigma1',
  11729. 'Omega',
  11730. 'Xi',
  11731. 'Psi',
  11732. 'Zeta',
  11733. 'bracketleft',
  11734. 'therefore',
  11735. 'bracketright',
  11736. 'perpendicular',
  11737. 'underscore',
  11738. 'radicalex',
  11739. 'alpha',
  11740. 'beta',
  11741. 'chi',
  11742. 'delta',
  11743. 'epsilon',
  11744. 'phi',
  11745. 'gamma',
  11746. 'eta',
  11747. 'iota',
  11748. 'phi1',
  11749. 'kappa',
  11750. 'lambda',
  11751. 'mu',
  11752. 'nu',
  11753. 'omicron',
  11754. 'pi',
  11755. 'theta',
  11756. 'rho',
  11757. 'sigma',
  11758. 'tau',
  11759. 'upsilon',
  11760. 'omega1',
  11761. 'omega',
  11762. 'xi',
  11763. 'psi',
  11764. 'zeta',
  11765. 'braceleft',
  11766. 'bar',
  11767. 'braceright',
  11768. 'similar',
  11769. '',
  11770. '',
  11771. '',
  11772. '',
  11773. '',
  11774. '',
  11775. '',
  11776. '',
  11777. '',
  11778. '',
  11779. '',
  11780. '',
  11781. '',
  11782. '',
  11783. '',
  11784. '',
  11785. '',
  11786. '',
  11787. '',
  11788. '',
  11789. '',
  11790. '',
  11791. '',
  11792. '',
  11793. '',
  11794. '',
  11795. '',
  11796. '',
  11797. '',
  11798. '',
  11799. '',
  11800. '',
  11801. '',
  11802. 'Euro',
  11803. 'Upsilon1',
  11804. 'minute',
  11805. 'lessequal',
  11806. 'fraction',
  11807. 'infinity',
  11808. 'florin',
  11809. 'club',
  11810. 'diamond',
  11811. 'heart',
  11812. 'spade',
  11813. 'arrowboth',
  11814. 'arrowleft',
  11815. 'arrowup',
  11816. 'arrowright',
  11817. 'arrowdown',
  11818. 'degree',
  11819. 'plusminus',
  11820. 'second',
  11821. 'greaterequal',
  11822. 'multiply',
  11823. 'proportional',
  11824. 'partialdiff',
  11825. 'bullet',
  11826. 'divide',
  11827. 'notequal',
  11828. 'equivalence',
  11829. 'approxequal',
  11830. 'ellipsis',
  11831. 'arrowvertex',
  11832. 'arrowhorizex',
  11833. 'carriagereturn',
  11834. 'aleph',
  11835. 'Ifraktur',
  11836. 'Rfraktur',
  11837. 'weierstrass',
  11838. 'circlemultiply',
  11839. 'circleplus',
  11840. 'emptyset',
  11841. 'intersection',
  11842. 'union',
  11843. 'propersuperset',
  11844. 'reflexsuperset',
  11845. 'notsubset',
  11846. 'propersubset',
  11847. 'reflexsubset',
  11848. 'element',
  11849. 'notelement',
  11850. 'angle',
  11851. 'gradient',
  11852. 'registerserif',
  11853. 'copyrightserif',
  11854. 'trademarkserif',
  11855. 'product',
  11856. 'radical',
  11857. 'dotmath',
  11858. 'logicalnot',
  11859. 'logicaland',
  11860. 'logicalor',
  11861. 'arrowdblboth',
  11862. 'arrowdblleft',
  11863. 'arrowdblup',
  11864. 'arrowdblright',
  11865. 'arrowdbldown',
  11866. 'lozenge',
  11867. 'angleleft',
  11868. 'registersans',
  11869. 'copyrightsans',
  11870. 'trademarksans',
  11871. 'summation',
  11872. 'parenlefttp',
  11873. 'parenleftex',
  11874. 'parenleftbt',
  11875. 'bracketlefttp',
  11876. 'bracketleftex',
  11877. 'bracketleftbt',
  11878. 'bracelefttp',
  11879. 'braceleftmid',
  11880. 'braceleftbt',
  11881. 'braceex',
  11882. '',
  11883. 'angleright',
  11884. 'integral',
  11885. 'integraltp',
  11886. 'integralex',
  11887. 'integralbt',
  11888. 'parenrighttp',
  11889. 'parenrightex',
  11890. 'parenrightbt',
  11891. 'bracketrighttp',
  11892. 'bracketrightex',
  11893. 'bracketrightbt',
  11894. 'bracerighttp',
  11895. 'bracerightmid',
  11896. 'bracerightbt'
  11897. ];
  11898. var ZapfDingbatsEncoding = [
  11899. '',
  11900. '',
  11901. '',
  11902. '',
  11903. '',
  11904. '',
  11905. '',
  11906. '',
  11907. '',
  11908. '',
  11909. '',
  11910. '',
  11911. '',
  11912. '',
  11913. '',
  11914. '',
  11915. '',
  11916. '',
  11917. '',
  11918. '',
  11919. '',
  11920. '',
  11921. '',
  11922. '',
  11923. '',
  11924. '',
  11925. '',
  11926. '',
  11927. '',
  11928. '',
  11929. '',
  11930. '',
  11931. 'space',
  11932. 'a1',
  11933. 'a2',
  11934. 'a202',
  11935. 'a3',
  11936. 'a4',
  11937. 'a5',
  11938. 'a119',
  11939. 'a118',
  11940. 'a117',
  11941. 'a11',
  11942. 'a12',
  11943. 'a13',
  11944. 'a14',
  11945. 'a15',
  11946. 'a16',
  11947. 'a105',
  11948. 'a17',
  11949. 'a18',
  11950. 'a19',
  11951. 'a20',
  11952. 'a21',
  11953. 'a22',
  11954. 'a23',
  11955. 'a24',
  11956. 'a25',
  11957. 'a26',
  11958. 'a27',
  11959. 'a28',
  11960. 'a6',
  11961. 'a7',
  11962. 'a8',
  11963. 'a9',
  11964. 'a10',
  11965. 'a29',
  11966. 'a30',
  11967. 'a31',
  11968. 'a32',
  11969. 'a33',
  11970. 'a34',
  11971. 'a35',
  11972. 'a36',
  11973. 'a37',
  11974. 'a38',
  11975. 'a39',
  11976. 'a40',
  11977. 'a41',
  11978. 'a42',
  11979. 'a43',
  11980. 'a44',
  11981. 'a45',
  11982. 'a46',
  11983. 'a47',
  11984. 'a48',
  11985. 'a49',
  11986. 'a50',
  11987. 'a51',
  11988. 'a52',
  11989. 'a53',
  11990. 'a54',
  11991. 'a55',
  11992. 'a56',
  11993. 'a57',
  11994. 'a58',
  11995. 'a59',
  11996. 'a60',
  11997. 'a61',
  11998. 'a62',
  11999. 'a63',
  12000. 'a64',
  12001. 'a65',
  12002. 'a66',
  12003. 'a67',
  12004. 'a68',
  12005. 'a69',
  12006. 'a70',
  12007. 'a71',
  12008. 'a72',
  12009. 'a73',
  12010. 'a74',
  12011. 'a203',
  12012. 'a75',
  12013. 'a204',
  12014. 'a76',
  12015. 'a77',
  12016. 'a78',
  12017. 'a79',
  12018. 'a81',
  12019. 'a82',
  12020. 'a83',
  12021. 'a84',
  12022. 'a97',
  12023. 'a98',
  12024. 'a99',
  12025. 'a100',
  12026. '',
  12027. 'a89',
  12028. 'a90',
  12029. 'a93',
  12030. 'a94',
  12031. 'a91',
  12032. 'a92',
  12033. 'a205',
  12034. 'a85',
  12035. 'a206',
  12036. 'a86',
  12037. 'a87',
  12038. 'a88',
  12039. 'a95',
  12040. 'a96',
  12041. '',
  12042. '',
  12043. '',
  12044. '',
  12045. '',
  12046. '',
  12047. '',
  12048. '',
  12049. '',
  12050. '',
  12051. '',
  12052. '',
  12053. '',
  12054. '',
  12055. '',
  12056. '',
  12057. '',
  12058. '',
  12059. '',
  12060. 'a101',
  12061. 'a102',
  12062. 'a103',
  12063. 'a104',
  12064. 'a106',
  12065. 'a107',
  12066. 'a108',
  12067. 'a112',
  12068. 'a111',
  12069. 'a110',
  12070. 'a109',
  12071. 'a120',
  12072. 'a121',
  12073. 'a122',
  12074. 'a123',
  12075. 'a124',
  12076. 'a125',
  12077. 'a126',
  12078. 'a127',
  12079. 'a128',
  12080. 'a129',
  12081. 'a130',
  12082. 'a131',
  12083. 'a132',
  12084. 'a133',
  12085. 'a134',
  12086. 'a135',
  12087. 'a136',
  12088. 'a137',
  12089. 'a138',
  12090. 'a139',
  12091. 'a140',
  12092. 'a141',
  12093. 'a142',
  12094. 'a143',
  12095. 'a144',
  12096. 'a145',
  12097. 'a146',
  12098. 'a147',
  12099. 'a148',
  12100. 'a149',
  12101. 'a150',
  12102. 'a151',
  12103. 'a152',
  12104. 'a153',
  12105. 'a154',
  12106. 'a155',
  12107. 'a156',
  12108. 'a157',
  12109. 'a158',
  12110. 'a159',
  12111. 'a160',
  12112. 'a161',
  12113. 'a163',
  12114. 'a164',
  12115. 'a196',
  12116. 'a165',
  12117. 'a192',
  12118. 'a166',
  12119. 'a167',
  12120. 'a168',
  12121. 'a169',
  12122. 'a170',
  12123. 'a171',
  12124. 'a172',
  12125. 'a173',
  12126. 'a162',
  12127. 'a174',
  12128. 'a175',
  12129. 'a176',
  12130. 'a177',
  12131. 'a178',
  12132. 'a179',
  12133. 'a193',
  12134. 'a180',
  12135. 'a199',
  12136. 'a181',
  12137. 'a200',
  12138. 'a182',
  12139. '',
  12140. 'a201',
  12141. 'a183',
  12142. 'a184',
  12143. 'a197',
  12144. 'a185',
  12145. 'a194',
  12146. 'a198',
  12147. 'a186',
  12148. 'a195',
  12149. 'a187',
  12150. 'a188',
  12151. 'a189',
  12152. 'a190',
  12153. 'a191'
  12154. ];
  12155. function getEncoding(encodingName) {
  12156. switch (encodingName) {
  12157. case 'WinAnsiEncoding':
  12158. return WinAnsiEncoding;
  12159. case 'StandardEncoding':
  12160. return StandardEncoding;
  12161. case 'MacRomanEncoding':
  12162. return MacRomanEncoding;
  12163. case 'SymbolSetEncoding':
  12164. return SymbolSetEncoding;
  12165. case 'ZapfDingbatsEncoding':
  12166. return ZapfDingbatsEncoding;
  12167. case 'ExpertEncoding':
  12168. return ExpertEncoding;
  12169. case 'MacExpertEncoding':
  12170. return MacExpertEncoding;
  12171. default:
  12172. return null;
  12173. }
  12174. }
  12175. exports.WinAnsiEncoding = WinAnsiEncoding;
  12176. exports.StandardEncoding = StandardEncoding;
  12177. exports.MacRomanEncoding = MacRomanEncoding;
  12178. exports.SymbolSetEncoding = SymbolSetEncoding;
  12179. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  12180. exports.ExpertEncoding = ExpertEncoding;
  12181. exports.getEncoding = getEncoding;
  12182. /***/ }),
  12183. /* 6 */
  12184. /***/ (function(module, exports, __w_pdfjs_require__) {
  12185. "use strict";
  12186. var sharedUtil = __w_pdfjs_require__(0);
  12187. var corePrimitives = __w_pdfjs_require__(1);
  12188. var coreStream = __w_pdfjs_require__(2);
  12189. var MissingDataException = sharedUtil.MissingDataException;
  12190. var StreamType = sharedUtil.StreamType;
  12191. var assert = sharedUtil.assert;
  12192. var error = sharedUtil.error;
  12193. var info = sharedUtil.info;
  12194. var isArray = sharedUtil.isArray;
  12195. var isInt = sharedUtil.isInt;
  12196. var isNum = sharedUtil.isNum;
  12197. var isString = sharedUtil.isString;
  12198. var warn = sharedUtil.warn;
  12199. var EOF = corePrimitives.EOF;
  12200. var Cmd = corePrimitives.Cmd;
  12201. var Dict = corePrimitives.Dict;
  12202. var Name = corePrimitives.Name;
  12203. var Ref = corePrimitives.Ref;
  12204. var isEOF = corePrimitives.isEOF;
  12205. var isCmd = corePrimitives.isCmd;
  12206. var isDict = corePrimitives.isDict;
  12207. var isName = corePrimitives.isName;
  12208. var Ascii85Stream = coreStream.Ascii85Stream;
  12209. var AsciiHexStream = coreStream.AsciiHexStream;
  12210. var CCITTFaxStream = coreStream.CCITTFaxStream;
  12211. var FlateStream = coreStream.FlateStream;
  12212. var Jbig2Stream = coreStream.Jbig2Stream;
  12213. var JpegStream = coreStream.JpegStream;
  12214. var JpxStream = coreStream.JpxStream;
  12215. var LZWStream = coreStream.LZWStream;
  12216. var NullStream = coreStream.NullStream;
  12217. var PredictorStream = coreStream.PredictorStream;
  12218. var RunLengthStream = coreStream.RunLengthStream;
  12219. var MAX_LENGTH_TO_CACHE = 1000;
  12220. var Parser = function ParserClosure() {
  12221. function Parser(lexer, allowStreams, xref, recoveryMode) {
  12222. this.lexer = lexer;
  12223. this.allowStreams = allowStreams;
  12224. this.xref = xref;
  12225. this.recoveryMode = recoveryMode || false;
  12226. this.imageCache = Object.create(null);
  12227. this.refill();
  12228. }
  12229. Parser.prototype = {
  12230. refill: function Parser_refill() {
  12231. this.buf1 = this.lexer.getObj();
  12232. this.buf2 = this.lexer.getObj();
  12233. },
  12234. shift: function Parser_shift() {
  12235. if (isCmd(this.buf2, 'ID')) {
  12236. this.buf1 = this.buf2;
  12237. this.buf2 = null;
  12238. } else {
  12239. this.buf1 = this.buf2;
  12240. this.buf2 = this.lexer.getObj();
  12241. }
  12242. },
  12243. tryShift: function Parser_tryShift() {
  12244. try {
  12245. this.shift();
  12246. return true;
  12247. } catch (e) {
  12248. if (e instanceof MissingDataException) {
  12249. throw e;
  12250. }
  12251. return false;
  12252. }
  12253. },
  12254. getObj: function Parser_getObj(cipherTransform) {
  12255. var buf1 = this.buf1;
  12256. this.shift();
  12257. if (buf1 instanceof Cmd) {
  12258. switch (buf1.cmd) {
  12259. case 'BI':
  12260. return this.makeInlineImage(cipherTransform);
  12261. case '[':
  12262. var array = [];
  12263. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  12264. array.push(this.getObj(cipherTransform));
  12265. }
  12266. if (isEOF(this.buf1)) {
  12267. if (!this.recoveryMode) {
  12268. error('End of file inside array');
  12269. }
  12270. return array;
  12271. }
  12272. this.shift();
  12273. return array;
  12274. case '<<':
  12275. var dict = new Dict(this.xref);
  12276. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  12277. if (!isName(this.buf1)) {
  12278. info('Malformed dictionary: key must be a name object');
  12279. this.shift();
  12280. continue;
  12281. }
  12282. var key = this.buf1.name;
  12283. this.shift();
  12284. if (isEOF(this.buf1)) {
  12285. break;
  12286. }
  12287. dict.set(key, this.getObj(cipherTransform));
  12288. }
  12289. if (isEOF(this.buf1)) {
  12290. if (!this.recoveryMode) {
  12291. error('End of file inside dictionary');
  12292. }
  12293. return dict;
  12294. }
  12295. if (isCmd(this.buf2, 'stream')) {
  12296. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  12297. }
  12298. this.shift();
  12299. return dict;
  12300. default:
  12301. return buf1;
  12302. }
  12303. }
  12304. if (isInt(buf1)) {
  12305. var num = buf1;
  12306. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  12307. var ref = new Ref(num, this.buf1);
  12308. this.shift();
  12309. this.shift();
  12310. return ref;
  12311. }
  12312. return num;
  12313. }
  12314. if (isString(buf1)) {
  12315. var str = buf1;
  12316. if (cipherTransform) {
  12317. str = cipherTransform.decryptString(str);
  12318. }
  12319. return str;
  12320. }
  12321. return buf1;
  12322. },
  12323. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  12324. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  12325. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  12326. while ((ch = stream.getByte()) !== -1) {
  12327. if (state === 0) {
  12328. state = ch === E ? 1 : 0;
  12329. } else if (state === 1) {
  12330. state = ch === I ? 2 : 0;
  12331. } else {
  12332. assert(state === 2);
  12333. if (ch === SPACE || ch === LF || ch === CR) {
  12334. n = 5;
  12335. followingBytes = stream.peekBytes(n);
  12336. for (i = 0; i < n; i++) {
  12337. ch = followingBytes[i];
  12338. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  12339. state = 0;
  12340. break;
  12341. }
  12342. }
  12343. if (state === 2) {
  12344. break;
  12345. }
  12346. } else {
  12347. state = 0;
  12348. }
  12349. }
  12350. }
  12351. return stream.pos - 4 - startPos;
  12352. },
  12353. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  12354. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  12355. while ((b = stream.getByte()) !== -1) {
  12356. if (b !== 0xFF) {
  12357. continue;
  12358. }
  12359. switch (stream.getByte()) {
  12360. case 0x00:
  12361. break;
  12362. case 0xFF:
  12363. stream.skip(-1);
  12364. break;
  12365. case 0xD9:
  12366. foundEOI = true;
  12367. break;
  12368. case 0xC0:
  12369. case 0xC1:
  12370. case 0xC2:
  12371. case 0xC3:
  12372. case 0xC5:
  12373. case 0xC6:
  12374. case 0xC7:
  12375. case 0xC9:
  12376. case 0xCA:
  12377. case 0xCB:
  12378. case 0xCD:
  12379. case 0xCE:
  12380. case 0xCF:
  12381. case 0xC4:
  12382. case 0xCC:
  12383. case 0xDA:
  12384. case 0xDB:
  12385. case 0xDC:
  12386. case 0xDD:
  12387. case 0xDE:
  12388. case 0xDF:
  12389. case 0xE0:
  12390. case 0xE1:
  12391. case 0xE2:
  12392. case 0xE3:
  12393. case 0xE4:
  12394. case 0xE5:
  12395. case 0xE6:
  12396. case 0xE7:
  12397. case 0xE8:
  12398. case 0xE9:
  12399. case 0xEA:
  12400. case 0xEB:
  12401. case 0xEC:
  12402. case 0xED:
  12403. case 0xEE:
  12404. case 0xEF:
  12405. case 0xFE:
  12406. markerLength = stream.getUint16();
  12407. if (markerLength > 2) {
  12408. stream.skip(markerLength - 2);
  12409. } else {
  12410. stream.skip(-2);
  12411. }
  12412. break;
  12413. }
  12414. if (foundEOI) {
  12415. break;
  12416. }
  12417. }
  12418. length = stream.pos - startPos;
  12419. if (b === -1) {
  12420. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  12421. stream.skip(-length);
  12422. return this.findDefaultInlineStreamEnd(stream);
  12423. }
  12424. this.inlineStreamSkipEI(stream);
  12425. return length;
  12426. },
  12427. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  12428. var TILDE = 0x7E, GT = 0x3E;
  12429. var startPos = stream.pos, ch, length;
  12430. while ((ch = stream.getByte()) !== -1) {
  12431. if (ch === TILDE && stream.peekByte() === GT) {
  12432. stream.skip();
  12433. break;
  12434. }
  12435. }
  12436. length = stream.pos - startPos;
  12437. if (ch === -1) {
  12438. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12439. stream.skip(-length);
  12440. return this.findDefaultInlineStreamEnd(stream);
  12441. }
  12442. this.inlineStreamSkipEI(stream);
  12443. return length;
  12444. },
  12445. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  12446. var GT = 0x3E;
  12447. var startPos = stream.pos, ch, length;
  12448. while ((ch = stream.getByte()) !== -1) {
  12449. if (ch === GT) {
  12450. break;
  12451. }
  12452. }
  12453. length = stream.pos - startPos;
  12454. if (ch === -1) {
  12455. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12456. stream.skip(-length);
  12457. return this.findDefaultInlineStreamEnd(stream);
  12458. }
  12459. this.inlineStreamSkipEI(stream);
  12460. return length;
  12461. },
  12462. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  12463. var E = 0x45, I = 0x49;
  12464. var state = 0, ch;
  12465. while ((ch = stream.getByte()) !== -1) {
  12466. if (state === 0) {
  12467. state = ch === E ? 1 : 0;
  12468. } else if (state === 1) {
  12469. state = ch === I ? 2 : 0;
  12470. } else if (state === 2) {
  12471. break;
  12472. }
  12473. }
  12474. },
  12475. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  12476. var lexer = this.lexer;
  12477. var stream = lexer.stream;
  12478. var dict = new Dict(this.xref);
  12479. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  12480. if (!isName(this.buf1)) {
  12481. error('Dictionary key must be a name object');
  12482. }
  12483. var key = this.buf1.name;
  12484. this.shift();
  12485. if (isEOF(this.buf1)) {
  12486. break;
  12487. }
  12488. dict.set(key, this.getObj(cipherTransform));
  12489. }
  12490. var filter = dict.get('Filter', 'F'), filterName;
  12491. if (isName(filter)) {
  12492. filterName = filter.name;
  12493. } else if (isArray(filter)) {
  12494. var filterZero = this.xref.fetchIfRef(filter[0]);
  12495. if (isName(filterZero)) {
  12496. filterName = filterZero.name;
  12497. }
  12498. }
  12499. var startPos = stream.pos, length, i, ii;
  12500. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  12501. length = this.findDCTDecodeInlineStreamEnd(stream);
  12502. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  12503. length = this.findASCII85DecodeInlineStreamEnd(stream);
  12504. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  12505. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  12506. } else {
  12507. length = this.findDefaultInlineStreamEnd(stream);
  12508. }
  12509. var imageStream = stream.makeSubStream(startPos, length, dict);
  12510. var adler32;
  12511. if (length < MAX_LENGTH_TO_CACHE) {
  12512. var imageBytes = imageStream.getBytes();
  12513. imageStream.reset();
  12514. var a = 1;
  12515. var b = 0;
  12516. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  12517. a += imageBytes[i] & 0xff;
  12518. b += a;
  12519. }
  12520. adler32 = b % 65521 << 16 | a % 65521;
  12521. if (this.imageCache.adler32 === adler32) {
  12522. this.buf2 = Cmd.get('EI');
  12523. this.shift();
  12524. this.imageCache[adler32].reset();
  12525. return this.imageCache[adler32];
  12526. }
  12527. }
  12528. if (cipherTransform) {
  12529. imageStream = cipherTransform.createStream(imageStream, length);
  12530. }
  12531. imageStream = this.filter(imageStream, dict, length);
  12532. imageStream.dict = dict;
  12533. if (adler32 !== undefined) {
  12534. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  12535. this.imageCache[adler32] = imageStream;
  12536. }
  12537. this.buf2 = Cmd.get('EI');
  12538. this.shift();
  12539. return imageStream;
  12540. },
  12541. makeStream: function Parser_makeStream(dict, cipherTransform) {
  12542. var lexer = this.lexer;
  12543. var stream = lexer.stream;
  12544. lexer.skipToNextLine();
  12545. var pos = stream.pos - 1;
  12546. var length = dict.get('Length');
  12547. if (!isInt(length)) {
  12548. info('Bad ' + length + ' attribute in stream');
  12549. length = 0;
  12550. }
  12551. stream.pos = pos + length;
  12552. lexer.nextChar();
  12553. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  12554. this.shift();
  12555. } else {
  12556. stream.pos = pos;
  12557. var SCAN_BLOCK_SIZE = 2048;
  12558. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  12559. var ENDSTREAM_SIGNATURE = [
  12560. 0x65,
  12561. 0x6E,
  12562. 0x64,
  12563. 0x73,
  12564. 0x74,
  12565. 0x72,
  12566. 0x65,
  12567. 0x61,
  12568. 0x6D
  12569. ];
  12570. var skipped = 0, found = false, i, j;
  12571. while (stream.pos < stream.end) {
  12572. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  12573. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  12574. if (scanLength <= 0) {
  12575. break;
  12576. }
  12577. found = false;
  12578. i = 0;
  12579. while (i < scanLength) {
  12580. j = 0;
  12581. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  12582. j++;
  12583. }
  12584. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  12585. found = true;
  12586. break;
  12587. }
  12588. i++;
  12589. }
  12590. if (found) {
  12591. skipped += i;
  12592. stream.pos += i;
  12593. break;
  12594. }
  12595. skipped += scanLength;
  12596. stream.pos += scanLength;
  12597. }
  12598. if (!found) {
  12599. error('Missing endstream');
  12600. }
  12601. length = skipped;
  12602. lexer.nextChar();
  12603. this.shift();
  12604. this.shift();
  12605. }
  12606. this.shift();
  12607. stream = stream.makeSubStream(pos, length, dict);
  12608. if (cipherTransform) {
  12609. stream = cipherTransform.createStream(stream, length);
  12610. }
  12611. stream = this.filter(stream, dict, length);
  12612. stream.dict = dict;
  12613. return stream;
  12614. },
  12615. filter: function Parser_filter(stream, dict, length) {
  12616. var filter = dict.get('Filter', 'F');
  12617. var params = dict.get('DecodeParms', 'DP');
  12618. if (isName(filter)) {
  12619. if (isArray(params)) {
  12620. params = this.xref.fetchIfRef(params[0]);
  12621. }
  12622. return this.makeFilter(stream, filter.name, length, params);
  12623. }
  12624. var maybeLength = length;
  12625. if (isArray(filter)) {
  12626. var filterArray = filter;
  12627. var paramsArray = params;
  12628. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  12629. filter = this.xref.fetchIfRef(filterArray[i]);
  12630. if (!isName(filter)) {
  12631. error('Bad filter name: ' + filter);
  12632. }
  12633. params = null;
  12634. if (isArray(paramsArray) && i in paramsArray) {
  12635. params = this.xref.fetchIfRef(paramsArray[i]);
  12636. }
  12637. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  12638. maybeLength = null;
  12639. }
  12640. }
  12641. return stream;
  12642. },
  12643. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  12644. if (maybeLength === 0) {
  12645. warn('Empty "' + name + '" stream.');
  12646. return new NullStream(stream);
  12647. }
  12648. try {
  12649. var xrefStreamStats = this.xref.stats.streamTypes;
  12650. if (name === 'FlateDecode' || name === 'Fl') {
  12651. xrefStreamStats[StreamType.FLATE] = true;
  12652. if (params) {
  12653. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  12654. }
  12655. return new FlateStream(stream, maybeLength);
  12656. }
  12657. if (name === 'LZWDecode' || name === 'LZW') {
  12658. xrefStreamStats[StreamType.LZW] = true;
  12659. var earlyChange = 1;
  12660. if (params) {
  12661. if (params.has('EarlyChange')) {
  12662. earlyChange = params.get('EarlyChange');
  12663. }
  12664. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  12665. }
  12666. return new LZWStream(stream, maybeLength, earlyChange);
  12667. }
  12668. if (name === 'DCTDecode' || name === 'DCT') {
  12669. xrefStreamStats[StreamType.DCT] = true;
  12670. return new JpegStream(stream, maybeLength, stream.dict, params);
  12671. }
  12672. if (name === 'JPXDecode' || name === 'JPX') {
  12673. xrefStreamStats[StreamType.JPX] = true;
  12674. return new JpxStream(stream, maybeLength, stream.dict, params);
  12675. }
  12676. if (name === 'ASCII85Decode' || name === 'A85') {
  12677. xrefStreamStats[StreamType.A85] = true;
  12678. return new Ascii85Stream(stream, maybeLength);
  12679. }
  12680. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  12681. xrefStreamStats[StreamType.AHX] = true;
  12682. return new AsciiHexStream(stream, maybeLength);
  12683. }
  12684. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  12685. xrefStreamStats[StreamType.CCF] = true;
  12686. return new CCITTFaxStream(stream, maybeLength, params);
  12687. }
  12688. if (name === 'RunLengthDecode' || name === 'RL') {
  12689. xrefStreamStats[StreamType.RL] = true;
  12690. return new RunLengthStream(stream, maybeLength);
  12691. }
  12692. if (name === 'JBIG2Decode') {
  12693. xrefStreamStats[StreamType.JBIG] = true;
  12694. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  12695. }
  12696. warn('filter "' + name + '" not supported yet');
  12697. return stream;
  12698. } catch (ex) {
  12699. if (ex instanceof MissingDataException) {
  12700. throw ex;
  12701. }
  12702. warn('Invalid stream: \"' + ex + '\"');
  12703. return new NullStream(stream);
  12704. }
  12705. }
  12706. };
  12707. return Parser;
  12708. }();
  12709. var Lexer = function LexerClosure() {
  12710. function Lexer(stream, knownCommands) {
  12711. this.stream = stream;
  12712. this.nextChar();
  12713. this.strBuf = [];
  12714. this.knownCommands = knownCommands;
  12715. }
  12716. var specialChars = [
  12717. 1,
  12718. 0,
  12719. 0,
  12720. 0,
  12721. 0,
  12722. 0,
  12723. 0,
  12724. 0,
  12725. 0,
  12726. 1,
  12727. 1,
  12728. 0,
  12729. 1,
  12730. 1,
  12731. 0,
  12732. 0,
  12733. 0,
  12734. 0,
  12735. 0,
  12736. 0,
  12737. 0,
  12738. 0,
  12739. 0,
  12740. 0,
  12741. 0,
  12742. 0,
  12743. 0,
  12744. 0,
  12745. 0,
  12746. 0,
  12747. 0,
  12748. 0,
  12749. 1,
  12750. 0,
  12751. 0,
  12752. 0,
  12753. 0,
  12754. 2,
  12755. 0,
  12756. 0,
  12757. 2,
  12758. 2,
  12759. 0,
  12760. 0,
  12761. 0,
  12762. 0,
  12763. 0,
  12764. 2,
  12765. 0,
  12766. 0,
  12767. 0,
  12768. 0,
  12769. 0,
  12770. 0,
  12771. 0,
  12772. 0,
  12773. 0,
  12774. 0,
  12775. 0,
  12776. 0,
  12777. 2,
  12778. 0,
  12779. 2,
  12780. 0,
  12781. 0,
  12782. 0,
  12783. 0,
  12784. 0,
  12785. 0,
  12786. 0,
  12787. 0,
  12788. 0,
  12789. 0,
  12790. 0,
  12791. 0,
  12792. 0,
  12793. 0,
  12794. 0,
  12795. 0,
  12796. 0,
  12797. 0,
  12798. 0,
  12799. 0,
  12800. 0,
  12801. 0,
  12802. 0,
  12803. 0,
  12804. 0,
  12805. 0,
  12806. 0,
  12807. 0,
  12808. 2,
  12809. 0,
  12810. 2,
  12811. 0,
  12812. 0,
  12813. 0,
  12814. 0,
  12815. 0,
  12816. 0,
  12817. 0,
  12818. 0,
  12819. 0,
  12820. 0,
  12821. 0,
  12822. 0,
  12823. 0,
  12824. 0,
  12825. 0,
  12826. 0,
  12827. 0,
  12828. 0,
  12829. 0,
  12830. 0,
  12831. 0,
  12832. 0,
  12833. 0,
  12834. 0,
  12835. 0,
  12836. 0,
  12837. 0,
  12838. 0,
  12839. 0,
  12840. 2,
  12841. 0,
  12842. 2,
  12843. 0,
  12844. 0,
  12845. 0,
  12846. 0,
  12847. 0,
  12848. 0,
  12849. 0,
  12850. 0,
  12851. 0,
  12852. 0,
  12853. 0,
  12854. 0,
  12855. 0,
  12856. 0,
  12857. 0,
  12858. 0,
  12859. 0,
  12860. 0,
  12861. 0,
  12862. 0,
  12863. 0,
  12864. 0,
  12865. 0,
  12866. 0,
  12867. 0,
  12868. 0,
  12869. 0,
  12870. 0,
  12871. 0,
  12872. 0,
  12873. 0,
  12874. 0,
  12875. 0,
  12876. 0,
  12877. 0,
  12878. 0,
  12879. 0,
  12880. 0,
  12881. 0,
  12882. 0,
  12883. 0,
  12884. 0,
  12885. 0,
  12886. 0,
  12887. 0,
  12888. 0,
  12889. 0,
  12890. 0,
  12891. 0,
  12892. 0,
  12893. 0,
  12894. 0,
  12895. 0,
  12896. 0,
  12897. 0,
  12898. 0,
  12899. 0,
  12900. 0,
  12901. 0,
  12902. 0,
  12903. 0,
  12904. 0,
  12905. 0,
  12906. 0,
  12907. 0,
  12908. 0,
  12909. 0,
  12910. 0,
  12911. 0,
  12912. 0,
  12913. 0,
  12914. 0,
  12915. 0,
  12916. 0,
  12917. 0,
  12918. 0,
  12919. 0,
  12920. 0,
  12921. 0,
  12922. 0,
  12923. 0,
  12924. 0,
  12925. 0,
  12926. 0,
  12927. 0,
  12928. 0,
  12929. 0,
  12930. 0,
  12931. 0,
  12932. 0,
  12933. 0,
  12934. 0,
  12935. 0,
  12936. 0,
  12937. 0,
  12938. 0,
  12939. 0,
  12940. 0,
  12941. 0,
  12942. 0,
  12943. 0,
  12944. 0,
  12945. 0,
  12946. 0,
  12947. 0,
  12948. 0,
  12949. 0,
  12950. 0,
  12951. 0,
  12952. 0,
  12953. 0,
  12954. 0,
  12955. 0,
  12956. 0,
  12957. 0,
  12958. 0,
  12959. 0,
  12960. 0,
  12961. 0,
  12962. 0,
  12963. 0,
  12964. 0,
  12965. 0,
  12966. 0,
  12967. 0,
  12968. 0,
  12969. 0,
  12970. 0,
  12971. 0,
  12972. 0
  12973. ];
  12974. function toHexDigit(ch) {
  12975. if (ch >= 0x30 && ch <= 0x39) {
  12976. return ch & 0x0F;
  12977. }
  12978. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12979. return (ch & 0x0F) + 9;
  12980. }
  12981. return -1;
  12982. }
  12983. Lexer.prototype = {
  12984. nextChar: function Lexer_nextChar() {
  12985. return this.currentChar = this.stream.getByte();
  12986. },
  12987. peekChar: function Lexer_peekChar() {
  12988. return this.stream.peekByte();
  12989. },
  12990. getNumber: function Lexer_getNumber() {
  12991. var ch = this.currentChar;
  12992. var eNotation = false;
  12993. var divideBy = 0;
  12994. var sign = 1;
  12995. if (ch === 0x2D) {
  12996. sign = -1;
  12997. ch = this.nextChar();
  12998. if (ch === 0x2D) {
  12999. ch = this.nextChar();
  13000. }
  13001. } else if (ch === 0x2B) {
  13002. ch = this.nextChar();
  13003. }
  13004. if (ch === 0x2E) {
  13005. divideBy = 10;
  13006. ch = this.nextChar();
  13007. }
  13008. if (ch < 0x30 || ch > 0x39) {
  13009. error('Invalid number: ' + String.fromCharCode(ch));
  13010. return 0;
  13011. }
  13012. var baseValue = ch - 0x30;
  13013. var powerValue = 0;
  13014. var powerValueSign = 1;
  13015. while ((ch = this.nextChar()) >= 0) {
  13016. if (0x30 <= ch && ch <= 0x39) {
  13017. var currentDigit = ch - 0x30;
  13018. if (eNotation) {
  13019. powerValue = powerValue * 10 + currentDigit;
  13020. } else {
  13021. if (divideBy !== 0) {
  13022. divideBy *= 10;
  13023. }
  13024. baseValue = baseValue * 10 + currentDigit;
  13025. }
  13026. } else if (ch === 0x2E) {
  13027. if (divideBy === 0) {
  13028. divideBy = 1;
  13029. } else {
  13030. break;
  13031. }
  13032. } else if (ch === 0x2D) {
  13033. warn('Badly formatted number');
  13034. } else if (ch === 0x45 || ch === 0x65) {
  13035. ch = this.peekChar();
  13036. if (ch === 0x2B || ch === 0x2D) {
  13037. powerValueSign = ch === 0x2D ? -1 : 1;
  13038. this.nextChar();
  13039. } else if (ch < 0x30 || ch > 0x39) {
  13040. break;
  13041. }
  13042. eNotation = true;
  13043. } else {
  13044. break;
  13045. }
  13046. }
  13047. if (divideBy !== 0) {
  13048. baseValue /= divideBy;
  13049. }
  13050. if (eNotation) {
  13051. baseValue *= Math.pow(10, powerValueSign * powerValue);
  13052. }
  13053. return sign * baseValue;
  13054. },
  13055. getString: function Lexer_getString() {
  13056. var numParen = 1;
  13057. var done = false;
  13058. var strBuf = this.strBuf;
  13059. strBuf.length = 0;
  13060. var ch = this.nextChar();
  13061. while (true) {
  13062. var charBuffered = false;
  13063. switch (ch | 0) {
  13064. case -1:
  13065. warn('Unterminated string');
  13066. done = true;
  13067. break;
  13068. case 0x28:
  13069. ++numParen;
  13070. strBuf.push('(');
  13071. break;
  13072. case 0x29:
  13073. if (--numParen === 0) {
  13074. this.nextChar();
  13075. done = true;
  13076. } else {
  13077. strBuf.push(')');
  13078. }
  13079. break;
  13080. case 0x5C:
  13081. ch = this.nextChar();
  13082. switch (ch) {
  13083. case -1:
  13084. warn('Unterminated string');
  13085. done = true;
  13086. break;
  13087. case 0x6E:
  13088. strBuf.push('\n');
  13089. break;
  13090. case 0x72:
  13091. strBuf.push('\r');
  13092. break;
  13093. case 0x74:
  13094. strBuf.push('\t');
  13095. break;
  13096. case 0x62:
  13097. strBuf.push('\b');
  13098. break;
  13099. case 0x66:
  13100. strBuf.push('\f');
  13101. break;
  13102. case 0x5C:
  13103. case 0x28:
  13104. case 0x29:
  13105. strBuf.push(String.fromCharCode(ch));
  13106. break;
  13107. case 0x30:
  13108. case 0x31:
  13109. case 0x32:
  13110. case 0x33:
  13111. case 0x34:
  13112. case 0x35:
  13113. case 0x36:
  13114. case 0x37:
  13115. var x = ch & 0x0F;
  13116. ch = this.nextChar();
  13117. charBuffered = true;
  13118. if (ch >= 0x30 && ch <= 0x37) {
  13119. x = (x << 3) + (ch & 0x0F);
  13120. ch = this.nextChar();
  13121. if (ch >= 0x30 && ch <= 0x37) {
  13122. charBuffered = false;
  13123. x = (x << 3) + (ch & 0x0F);
  13124. }
  13125. }
  13126. strBuf.push(String.fromCharCode(x));
  13127. break;
  13128. case 0x0D:
  13129. if (this.peekChar() === 0x0A) {
  13130. this.nextChar();
  13131. }
  13132. break;
  13133. case 0x0A:
  13134. break;
  13135. default:
  13136. strBuf.push(String.fromCharCode(ch));
  13137. break;
  13138. }
  13139. break;
  13140. default:
  13141. strBuf.push(String.fromCharCode(ch));
  13142. break;
  13143. }
  13144. if (done) {
  13145. break;
  13146. }
  13147. if (!charBuffered) {
  13148. ch = this.nextChar();
  13149. }
  13150. }
  13151. return strBuf.join('');
  13152. },
  13153. getName: function Lexer_getName() {
  13154. var ch, previousCh;
  13155. var strBuf = this.strBuf;
  13156. strBuf.length = 0;
  13157. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13158. if (ch === 0x23) {
  13159. ch = this.nextChar();
  13160. if (specialChars[ch]) {
  13161. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  13162. strBuf.push('#');
  13163. break;
  13164. }
  13165. var x = toHexDigit(ch);
  13166. if (x !== -1) {
  13167. previousCh = ch;
  13168. ch = this.nextChar();
  13169. var x2 = toHexDigit(ch);
  13170. if (x2 === -1) {
  13171. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  13172. strBuf.push('#', String.fromCharCode(previousCh));
  13173. if (specialChars[ch]) {
  13174. break;
  13175. }
  13176. strBuf.push(String.fromCharCode(ch));
  13177. continue;
  13178. }
  13179. strBuf.push(String.fromCharCode(x << 4 | x2));
  13180. } else {
  13181. strBuf.push('#', String.fromCharCode(ch));
  13182. }
  13183. } else {
  13184. strBuf.push(String.fromCharCode(ch));
  13185. }
  13186. }
  13187. if (strBuf.length > 127) {
  13188. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  13189. }
  13190. return Name.get(strBuf.join(''));
  13191. },
  13192. getHexString: function Lexer_getHexString() {
  13193. var strBuf = this.strBuf;
  13194. strBuf.length = 0;
  13195. var ch = this.currentChar;
  13196. var isFirstHex = true;
  13197. var firstDigit;
  13198. var secondDigit;
  13199. while (true) {
  13200. if (ch < 0) {
  13201. warn('Unterminated hex string');
  13202. break;
  13203. } else if (ch === 0x3E) {
  13204. this.nextChar();
  13205. break;
  13206. } else if (specialChars[ch] === 1) {
  13207. ch = this.nextChar();
  13208. continue;
  13209. } else {
  13210. if (isFirstHex) {
  13211. firstDigit = toHexDigit(ch);
  13212. if (firstDigit === -1) {
  13213. warn('Ignoring invalid character "' + ch + '" in hex string');
  13214. ch = this.nextChar();
  13215. continue;
  13216. }
  13217. } else {
  13218. secondDigit = toHexDigit(ch);
  13219. if (secondDigit === -1) {
  13220. warn('Ignoring invalid character "' + ch + '" in hex string');
  13221. ch = this.nextChar();
  13222. continue;
  13223. }
  13224. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  13225. }
  13226. isFirstHex = !isFirstHex;
  13227. ch = this.nextChar();
  13228. }
  13229. }
  13230. return strBuf.join('');
  13231. },
  13232. getObj: function Lexer_getObj() {
  13233. var comment = false;
  13234. var ch = this.currentChar;
  13235. while (true) {
  13236. if (ch < 0) {
  13237. return EOF;
  13238. }
  13239. if (comment) {
  13240. if (ch === 0x0A || ch === 0x0D) {
  13241. comment = false;
  13242. }
  13243. } else if (ch === 0x25) {
  13244. comment = true;
  13245. } else if (specialChars[ch] !== 1) {
  13246. break;
  13247. }
  13248. ch = this.nextChar();
  13249. }
  13250. switch (ch | 0) {
  13251. case 0x30:
  13252. case 0x31:
  13253. case 0x32:
  13254. case 0x33:
  13255. case 0x34:
  13256. case 0x35:
  13257. case 0x36:
  13258. case 0x37:
  13259. case 0x38:
  13260. case 0x39:
  13261. case 0x2B:
  13262. case 0x2D:
  13263. case 0x2E:
  13264. return this.getNumber();
  13265. case 0x28:
  13266. return this.getString();
  13267. case 0x2F:
  13268. return this.getName();
  13269. case 0x5B:
  13270. this.nextChar();
  13271. return Cmd.get('[');
  13272. case 0x5D:
  13273. this.nextChar();
  13274. return Cmd.get(']');
  13275. case 0x3C:
  13276. ch = this.nextChar();
  13277. if (ch === 0x3C) {
  13278. this.nextChar();
  13279. return Cmd.get('<<');
  13280. }
  13281. return this.getHexString();
  13282. case 0x3E:
  13283. ch = this.nextChar();
  13284. if (ch === 0x3E) {
  13285. this.nextChar();
  13286. return Cmd.get('>>');
  13287. }
  13288. return Cmd.get('>');
  13289. case 0x7B:
  13290. this.nextChar();
  13291. return Cmd.get('{');
  13292. case 0x7D:
  13293. this.nextChar();
  13294. return Cmd.get('}');
  13295. case 0x29:
  13296. this.nextChar();
  13297. error('Illegal character: ' + ch);
  13298. break;
  13299. }
  13300. var str = String.fromCharCode(ch);
  13301. var knownCommands = this.knownCommands;
  13302. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13303. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13304. var possibleCommand = str + String.fromCharCode(ch);
  13305. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  13306. break;
  13307. }
  13308. if (str.length === 128) {
  13309. error('Command token too long: ' + str.length);
  13310. }
  13311. str = possibleCommand;
  13312. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13313. }
  13314. if (str === 'true') {
  13315. return true;
  13316. }
  13317. if (str === 'false') {
  13318. return false;
  13319. }
  13320. if (str === 'null') {
  13321. return null;
  13322. }
  13323. return Cmd.get(str);
  13324. },
  13325. skipToNextLine: function Lexer_skipToNextLine() {
  13326. var ch = this.currentChar;
  13327. while (ch >= 0) {
  13328. if (ch === 0x0D) {
  13329. ch = this.nextChar();
  13330. if (ch === 0x0A) {
  13331. this.nextChar();
  13332. }
  13333. break;
  13334. } else if (ch === 0x0A) {
  13335. this.nextChar();
  13336. break;
  13337. }
  13338. ch = this.nextChar();
  13339. }
  13340. }
  13341. };
  13342. return Lexer;
  13343. }();
  13344. var Linearization = {
  13345. create: function LinearizationCreate(stream) {
  13346. function getInt(name, allowZeroValue) {
  13347. var obj = linDict.get(name);
  13348. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  13349. return obj;
  13350. }
  13351. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  13352. }
  13353. function getHints() {
  13354. var hints = linDict.get('H'), hintsLength, item;
  13355. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  13356. for (var index = 0; index < hintsLength; index++) {
  13357. if (!(isInt(item = hints[index]) && item > 0)) {
  13358. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  13359. }
  13360. }
  13361. return hints;
  13362. }
  13363. throw new Error('Hint array in the linearization dictionary is invalid.');
  13364. }
  13365. var parser = new Parser(new Lexer(stream), false, null);
  13366. var obj1 = parser.getObj();
  13367. var obj2 = parser.getObj();
  13368. var obj3 = parser.getObj();
  13369. var linDict = parser.getObj();
  13370. var obj, length;
  13371. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  13372. return null;
  13373. } else if ((length = getInt('L')) !== stream.length) {
  13374. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  13375. }
  13376. return {
  13377. length: length,
  13378. hints: getHints(),
  13379. objectNumberFirst: getInt('O'),
  13380. endFirst: getInt('E'),
  13381. numPages: getInt('N'),
  13382. mainXRefEntriesOffset: getInt('T'),
  13383. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  13384. };
  13385. }
  13386. };
  13387. exports.Lexer = Lexer;
  13388. exports.Linearization = Linearization;
  13389. exports.Parser = Parser;
  13390. /***/ }),
  13391. /* 7 */
  13392. /***/ (function(module, exports, __w_pdfjs_require__) {
  13393. "use strict";
  13394. var sharedUtil = __w_pdfjs_require__(0);
  13395. var corePrimitives = __w_pdfjs_require__(1);
  13396. var corePsParser = __w_pdfjs_require__(42);
  13397. var error = sharedUtil.error;
  13398. var info = sharedUtil.info;
  13399. var isArray = sharedUtil.isArray;
  13400. var isBool = sharedUtil.isBool;
  13401. var isDict = corePrimitives.isDict;
  13402. var isStream = corePrimitives.isStream;
  13403. var PostScriptLexer = corePsParser.PostScriptLexer;
  13404. var PostScriptParser = corePsParser.PostScriptParser;
  13405. var PDFFunction = function PDFFunctionClosure() {
  13406. var CONSTRUCT_SAMPLED = 0;
  13407. var CONSTRUCT_INTERPOLATED = 2;
  13408. var CONSTRUCT_STICHED = 3;
  13409. var CONSTRUCT_POSTSCRIPT = 4;
  13410. return {
  13411. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  13412. var i, ii;
  13413. var length = 1;
  13414. for (i = 0, ii = size.length; i < ii; i++) {
  13415. length *= size[i];
  13416. }
  13417. length *= outputSize;
  13418. var array = new Array(length);
  13419. var codeSize = 0;
  13420. var codeBuf = 0;
  13421. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  13422. var strBytes = str.getBytes((length * bps + 7) / 8);
  13423. var strIdx = 0;
  13424. for (i = 0; i < length; i++) {
  13425. while (codeSize < bps) {
  13426. codeBuf <<= 8;
  13427. codeBuf |= strBytes[strIdx++];
  13428. codeSize += 8;
  13429. }
  13430. codeSize -= bps;
  13431. array[i] = (codeBuf >> codeSize) * sampleMul;
  13432. codeBuf &= (1 << codeSize) - 1;
  13433. }
  13434. return array;
  13435. },
  13436. getIR: function PDFFunction_getIR(xref, fn) {
  13437. var dict = fn.dict;
  13438. if (!dict) {
  13439. dict = fn;
  13440. }
  13441. var types = [
  13442. this.constructSampled,
  13443. null,
  13444. this.constructInterpolated,
  13445. this.constructStiched,
  13446. this.constructPostScript
  13447. ];
  13448. var typeNum = dict.get('FunctionType');
  13449. var typeFn = types[typeNum];
  13450. if (!typeFn) {
  13451. error('Unknown type of function');
  13452. }
  13453. return typeFn.call(this, fn, dict, xref);
  13454. },
  13455. fromIR: function PDFFunction_fromIR(IR) {
  13456. var type = IR[0];
  13457. switch (type) {
  13458. case CONSTRUCT_SAMPLED:
  13459. return this.constructSampledFromIR(IR);
  13460. case CONSTRUCT_INTERPOLATED:
  13461. return this.constructInterpolatedFromIR(IR);
  13462. case CONSTRUCT_STICHED:
  13463. return this.constructStichedFromIR(IR);
  13464. default:
  13465. return this.constructPostScriptFromIR(IR);
  13466. }
  13467. },
  13468. parse: function PDFFunction_parse(xref, fn) {
  13469. var IR = this.getIR(xref, fn);
  13470. return this.fromIR(IR);
  13471. },
  13472. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  13473. if (!isArray(fnObj)) {
  13474. return this.parse(xref, fnObj);
  13475. }
  13476. var fnArray = [];
  13477. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  13478. var obj = xref.fetchIfRef(fnObj[j]);
  13479. fnArray.push(PDFFunction.parse(xref, obj));
  13480. }
  13481. return function (src, srcOffset, dest, destOffset) {
  13482. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  13483. fnArray[i](src, srcOffset, dest, destOffset + i);
  13484. }
  13485. };
  13486. },
  13487. constructSampled: function PDFFunction_constructSampled(str, dict) {
  13488. function toMultiArray(arr) {
  13489. var inputLength = arr.length;
  13490. var out = [];
  13491. var index = 0;
  13492. for (var i = 0; i < inputLength; i += 2) {
  13493. out[index] = [
  13494. arr[i],
  13495. arr[i + 1]
  13496. ];
  13497. ++index;
  13498. }
  13499. return out;
  13500. }
  13501. var domain = dict.getArray('Domain');
  13502. var range = dict.getArray('Range');
  13503. if (!domain || !range) {
  13504. error('No domain or range');
  13505. }
  13506. var inputSize = domain.length / 2;
  13507. var outputSize = range.length / 2;
  13508. domain = toMultiArray(domain);
  13509. range = toMultiArray(range);
  13510. var size = dict.get('Size');
  13511. var bps = dict.get('BitsPerSample');
  13512. var order = dict.get('Order') || 1;
  13513. if (order !== 1) {
  13514. info('No support for cubic spline interpolation: ' + order);
  13515. }
  13516. var encode = dict.getArray('Encode');
  13517. if (!encode) {
  13518. encode = [];
  13519. for (var i = 0; i < inputSize; ++i) {
  13520. encode.push(0);
  13521. encode.push(size[i] - 1);
  13522. }
  13523. }
  13524. encode = toMultiArray(encode);
  13525. var decode = dict.getArray('Decode');
  13526. if (!decode) {
  13527. decode = range;
  13528. } else {
  13529. decode = toMultiArray(decode);
  13530. }
  13531. var samples = this.getSampleArray(size, outputSize, bps, str);
  13532. return [
  13533. CONSTRUCT_SAMPLED,
  13534. inputSize,
  13535. domain,
  13536. encode,
  13537. decode,
  13538. samples,
  13539. size,
  13540. outputSize,
  13541. Math.pow(2, bps) - 1,
  13542. range
  13543. ];
  13544. },
  13545. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  13546. function interpolate(x, xmin, xmax, ymin, ymax) {
  13547. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  13548. }
  13549. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  13550. var m = IR[1];
  13551. var domain = IR[2];
  13552. var encode = IR[3];
  13553. var decode = IR[4];
  13554. var samples = IR[5];
  13555. var size = IR[6];
  13556. var n = IR[7];
  13557. var range = IR[9];
  13558. var cubeVertices = 1 << m;
  13559. var cubeN = new Float64Array(cubeVertices);
  13560. var cubeVertex = new Uint32Array(cubeVertices);
  13561. var i, j;
  13562. for (j = 0; j < cubeVertices; j++) {
  13563. cubeN[j] = 1;
  13564. }
  13565. var k = n, pos = 1;
  13566. for (i = 0; i < m; ++i) {
  13567. var domain_2i = domain[i][0];
  13568. var domain_2i_1 = domain[i][1];
  13569. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  13570. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  13571. var size_i = size[i];
  13572. e = Math.min(Math.max(e, 0), size_i - 1);
  13573. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  13574. var n0 = e0 + 1 - e;
  13575. var n1 = e - e0;
  13576. var offset0 = e0 * k;
  13577. var offset1 = offset0 + k;
  13578. for (j = 0; j < cubeVertices; j++) {
  13579. if (j & pos) {
  13580. cubeN[j] *= n1;
  13581. cubeVertex[j] += offset1;
  13582. } else {
  13583. cubeN[j] *= n0;
  13584. cubeVertex[j] += offset0;
  13585. }
  13586. }
  13587. k *= size_i;
  13588. pos <<= 1;
  13589. }
  13590. for (j = 0; j < n; ++j) {
  13591. var rj = 0;
  13592. for (i = 0; i < cubeVertices; i++) {
  13593. rj += samples[cubeVertex[i] + j] * cubeN[i];
  13594. }
  13595. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  13596. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  13597. }
  13598. };
  13599. },
  13600. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  13601. var c0 = dict.getArray('C0') || [0];
  13602. var c1 = dict.getArray('C1') || [1];
  13603. var n = dict.get('N');
  13604. if (!isArray(c0) || !isArray(c1)) {
  13605. error('Illegal dictionary for interpolated function');
  13606. }
  13607. var length = c0.length;
  13608. var diff = [];
  13609. for (var i = 0; i < length; ++i) {
  13610. diff.push(c1[i] - c0[i]);
  13611. }
  13612. return [
  13613. CONSTRUCT_INTERPOLATED,
  13614. c0,
  13615. diff,
  13616. n
  13617. ];
  13618. },
  13619. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  13620. var c0 = IR[1];
  13621. var diff = IR[2];
  13622. var n = IR[3];
  13623. var length = diff.length;
  13624. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  13625. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  13626. for (var j = 0; j < length; ++j) {
  13627. dest[destOffset + j] = c0[j] + x * diff[j];
  13628. }
  13629. };
  13630. },
  13631. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  13632. var domain = dict.getArray('Domain');
  13633. if (!domain) {
  13634. error('No domain');
  13635. }
  13636. var inputSize = domain.length / 2;
  13637. if (inputSize !== 1) {
  13638. error('Bad domain for stiched function');
  13639. }
  13640. var fnRefs = dict.get('Functions');
  13641. var fns = [];
  13642. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  13643. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  13644. }
  13645. var bounds = dict.getArray('Bounds');
  13646. var encode = dict.getArray('Encode');
  13647. return [
  13648. CONSTRUCT_STICHED,
  13649. domain,
  13650. bounds,
  13651. encode,
  13652. fns
  13653. ];
  13654. },
  13655. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  13656. var domain = IR[1];
  13657. var bounds = IR[2];
  13658. var encode = IR[3];
  13659. var fnsIR = IR[4];
  13660. var fns = [];
  13661. var tmpBuf = new Float32Array(1);
  13662. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  13663. fns.push(PDFFunction.fromIR(fnsIR[i]));
  13664. }
  13665. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  13666. var clip = function constructStichedFromIRClip(v, min, max) {
  13667. if (v > max) {
  13668. v = max;
  13669. } else if (v < min) {
  13670. v = min;
  13671. }
  13672. return v;
  13673. };
  13674. var v = clip(src[srcOffset], domain[0], domain[1]);
  13675. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  13676. if (v < bounds[i]) {
  13677. break;
  13678. }
  13679. }
  13680. var dmin = domain[0];
  13681. if (i > 0) {
  13682. dmin = bounds[i - 1];
  13683. }
  13684. var dmax = domain[1];
  13685. if (i < bounds.length) {
  13686. dmax = bounds[i];
  13687. }
  13688. var rmin = encode[2 * i];
  13689. var rmax = encode[2 * i + 1];
  13690. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  13691. fns[i](tmpBuf, 0, dest, destOffset);
  13692. };
  13693. },
  13694. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  13695. var domain = dict.getArray('Domain');
  13696. var range = dict.getArray('Range');
  13697. if (!domain) {
  13698. error('No domain.');
  13699. }
  13700. if (!range) {
  13701. error('No range.');
  13702. }
  13703. var lexer = new PostScriptLexer(fn);
  13704. var parser = new PostScriptParser(lexer);
  13705. var code = parser.parse();
  13706. return [
  13707. CONSTRUCT_POSTSCRIPT,
  13708. domain,
  13709. range,
  13710. code
  13711. ];
  13712. },
  13713. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  13714. var domain = IR[1];
  13715. var range = IR[2];
  13716. var code = IR[3];
  13717. var compiled = new PostScriptCompiler().compile(code, domain, range);
  13718. if (compiled) {
  13719. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  13720. }
  13721. info('Unable to compile PS function');
  13722. var numOutputs = range.length >> 1;
  13723. var numInputs = domain.length >> 1;
  13724. var evaluator = new PostScriptEvaluator(code);
  13725. var cache = Object.create(null);
  13726. var MAX_CACHE_SIZE = 2048 * 4;
  13727. var cache_available = MAX_CACHE_SIZE;
  13728. var tmpBuf = new Float32Array(numInputs);
  13729. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  13730. var i, value;
  13731. var key = '';
  13732. var input = tmpBuf;
  13733. for (i = 0; i < numInputs; i++) {
  13734. value = src[srcOffset + i];
  13735. input[i] = value;
  13736. key += value + '_';
  13737. }
  13738. var cachedValue = cache[key];
  13739. if (cachedValue !== undefined) {
  13740. dest.set(cachedValue, destOffset);
  13741. return;
  13742. }
  13743. var output = new Float32Array(numOutputs);
  13744. var stack = evaluator.execute(input);
  13745. var stackIndex = stack.length - numOutputs;
  13746. for (i = 0; i < numOutputs; i++) {
  13747. value = stack[stackIndex + i];
  13748. var bound = range[i * 2];
  13749. if (value < bound) {
  13750. value = bound;
  13751. } else {
  13752. bound = range[i * 2 + 1];
  13753. if (value > bound) {
  13754. value = bound;
  13755. }
  13756. }
  13757. output[i] = value;
  13758. }
  13759. if (cache_available > 0) {
  13760. cache_available--;
  13761. cache[key] = output;
  13762. }
  13763. dest.set(output, destOffset);
  13764. };
  13765. }
  13766. };
  13767. }();
  13768. function isPDFFunction(v) {
  13769. var fnDict;
  13770. if (typeof v !== 'object') {
  13771. return false;
  13772. } else if (isDict(v)) {
  13773. fnDict = v;
  13774. } else if (isStream(v)) {
  13775. fnDict = v.dict;
  13776. } else {
  13777. return false;
  13778. }
  13779. return fnDict.has('FunctionType');
  13780. }
  13781. var PostScriptStack = function PostScriptStackClosure() {
  13782. var MAX_STACK_SIZE = 100;
  13783. function PostScriptStack(initialStack) {
  13784. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  13785. }
  13786. PostScriptStack.prototype = {
  13787. push: function PostScriptStack_push(value) {
  13788. if (this.stack.length >= MAX_STACK_SIZE) {
  13789. error('PostScript function stack overflow.');
  13790. }
  13791. this.stack.push(value);
  13792. },
  13793. pop: function PostScriptStack_pop() {
  13794. if (this.stack.length <= 0) {
  13795. error('PostScript function stack underflow.');
  13796. }
  13797. return this.stack.pop();
  13798. },
  13799. copy: function PostScriptStack_copy(n) {
  13800. if (this.stack.length + n >= MAX_STACK_SIZE) {
  13801. error('PostScript function stack overflow.');
  13802. }
  13803. var stack = this.stack;
  13804. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  13805. stack.push(stack[i]);
  13806. }
  13807. },
  13808. index: function PostScriptStack_index(n) {
  13809. this.push(this.stack[this.stack.length - n - 1]);
  13810. },
  13811. roll: function PostScriptStack_roll(n, p) {
  13812. var stack = this.stack;
  13813. var l = stack.length - n;
  13814. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13815. for (i = l, j = r; i < j; i++, j--) {
  13816. t = stack[i];
  13817. stack[i] = stack[j];
  13818. stack[j] = t;
  13819. }
  13820. for (i = l, j = c - 1; i < j; i++, j--) {
  13821. t = stack[i];
  13822. stack[i] = stack[j];
  13823. stack[j] = t;
  13824. }
  13825. for (i = c, j = r; i < j; i++, j--) {
  13826. t = stack[i];
  13827. stack[i] = stack[j];
  13828. stack[j] = t;
  13829. }
  13830. }
  13831. };
  13832. return PostScriptStack;
  13833. }();
  13834. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13835. function PostScriptEvaluator(operators) {
  13836. this.operators = operators;
  13837. }
  13838. PostScriptEvaluator.prototype = {
  13839. execute: function PostScriptEvaluator_execute(initialStack) {
  13840. var stack = new PostScriptStack(initialStack);
  13841. var counter = 0;
  13842. var operators = this.operators;
  13843. var length = operators.length;
  13844. var operator, a, b;
  13845. while (counter < length) {
  13846. operator = operators[counter++];
  13847. if (typeof operator === 'number') {
  13848. stack.push(operator);
  13849. continue;
  13850. }
  13851. switch (operator) {
  13852. case 'jz':
  13853. b = stack.pop();
  13854. a = stack.pop();
  13855. if (!a) {
  13856. counter = b;
  13857. }
  13858. break;
  13859. case 'j':
  13860. a = stack.pop();
  13861. counter = a;
  13862. break;
  13863. case 'abs':
  13864. a = stack.pop();
  13865. stack.push(Math.abs(a));
  13866. break;
  13867. case 'add':
  13868. b = stack.pop();
  13869. a = stack.pop();
  13870. stack.push(a + b);
  13871. break;
  13872. case 'and':
  13873. b = stack.pop();
  13874. a = stack.pop();
  13875. if (isBool(a) && isBool(b)) {
  13876. stack.push(a && b);
  13877. } else {
  13878. stack.push(a & b);
  13879. }
  13880. break;
  13881. case 'atan':
  13882. a = stack.pop();
  13883. stack.push(Math.atan(a));
  13884. break;
  13885. case 'bitshift':
  13886. b = stack.pop();
  13887. a = stack.pop();
  13888. if (a > 0) {
  13889. stack.push(a << b);
  13890. } else {
  13891. stack.push(a >> b);
  13892. }
  13893. break;
  13894. case 'ceiling':
  13895. a = stack.pop();
  13896. stack.push(Math.ceil(a));
  13897. break;
  13898. case 'copy':
  13899. a = stack.pop();
  13900. stack.copy(a);
  13901. break;
  13902. case 'cos':
  13903. a = stack.pop();
  13904. stack.push(Math.cos(a));
  13905. break;
  13906. case 'cvi':
  13907. a = stack.pop() | 0;
  13908. stack.push(a);
  13909. break;
  13910. case 'cvr':
  13911. break;
  13912. case 'div':
  13913. b = stack.pop();
  13914. a = stack.pop();
  13915. stack.push(a / b);
  13916. break;
  13917. case 'dup':
  13918. stack.copy(1);
  13919. break;
  13920. case 'eq':
  13921. b = stack.pop();
  13922. a = stack.pop();
  13923. stack.push(a === b);
  13924. break;
  13925. case 'exch':
  13926. stack.roll(2, 1);
  13927. break;
  13928. case 'exp':
  13929. b = stack.pop();
  13930. a = stack.pop();
  13931. stack.push(Math.pow(a, b));
  13932. break;
  13933. case 'false':
  13934. stack.push(false);
  13935. break;
  13936. case 'floor':
  13937. a = stack.pop();
  13938. stack.push(Math.floor(a));
  13939. break;
  13940. case 'ge':
  13941. b = stack.pop();
  13942. a = stack.pop();
  13943. stack.push(a >= b);
  13944. break;
  13945. case 'gt':
  13946. b = stack.pop();
  13947. a = stack.pop();
  13948. stack.push(a > b);
  13949. break;
  13950. case 'idiv':
  13951. b = stack.pop();
  13952. a = stack.pop();
  13953. stack.push(a / b | 0);
  13954. break;
  13955. case 'index':
  13956. a = stack.pop();
  13957. stack.index(a);
  13958. break;
  13959. case 'le':
  13960. b = stack.pop();
  13961. a = stack.pop();
  13962. stack.push(a <= b);
  13963. break;
  13964. case 'ln':
  13965. a = stack.pop();
  13966. stack.push(Math.log(a));
  13967. break;
  13968. case 'log':
  13969. a = stack.pop();
  13970. stack.push(Math.log(a) / Math.LN10);
  13971. break;
  13972. case 'lt':
  13973. b = stack.pop();
  13974. a = stack.pop();
  13975. stack.push(a < b);
  13976. break;
  13977. case 'mod':
  13978. b = stack.pop();
  13979. a = stack.pop();
  13980. stack.push(a % b);
  13981. break;
  13982. case 'mul':
  13983. b = stack.pop();
  13984. a = stack.pop();
  13985. stack.push(a * b);
  13986. break;
  13987. case 'ne':
  13988. b = stack.pop();
  13989. a = stack.pop();
  13990. stack.push(a !== b);
  13991. break;
  13992. case 'neg':
  13993. a = stack.pop();
  13994. stack.push(-a);
  13995. break;
  13996. case 'not':
  13997. a = stack.pop();
  13998. if (isBool(a)) {
  13999. stack.push(!a);
  14000. } else {
  14001. stack.push(~a);
  14002. }
  14003. break;
  14004. case 'or':
  14005. b = stack.pop();
  14006. a = stack.pop();
  14007. if (isBool(a) && isBool(b)) {
  14008. stack.push(a || b);
  14009. } else {
  14010. stack.push(a | b);
  14011. }
  14012. break;
  14013. case 'pop':
  14014. stack.pop();
  14015. break;
  14016. case 'roll':
  14017. b = stack.pop();
  14018. a = stack.pop();
  14019. stack.roll(a, b);
  14020. break;
  14021. case 'round':
  14022. a = stack.pop();
  14023. stack.push(Math.round(a));
  14024. break;
  14025. case 'sin':
  14026. a = stack.pop();
  14027. stack.push(Math.sin(a));
  14028. break;
  14029. case 'sqrt':
  14030. a = stack.pop();
  14031. stack.push(Math.sqrt(a));
  14032. break;
  14033. case 'sub':
  14034. b = stack.pop();
  14035. a = stack.pop();
  14036. stack.push(a - b);
  14037. break;
  14038. case 'true':
  14039. stack.push(true);
  14040. break;
  14041. case 'truncate':
  14042. a = stack.pop();
  14043. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  14044. stack.push(a);
  14045. break;
  14046. case 'xor':
  14047. b = stack.pop();
  14048. a = stack.pop();
  14049. if (isBool(a) && isBool(b)) {
  14050. stack.push(a !== b);
  14051. } else {
  14052. stack.push(a ^ b);
  14053. }
  14054. break;
  14055. default:
  14056. error('Unknown operator ' + operator);
  14057. break;
  14058. }
  14059. }
  14060. return stack.stack;
  14061. }
  14062. };
  14063. return PostScriptEvaluator;
  14064. }();
  14065. var PostScriptCompiler = function PostScriptCompilerClosure() {
  14066. function AstNode(type) {
  14067. this.type = type;
  14068. }
  14069. AstNode.prototype.visit = function (visitor) {
  14070. throw new Error('abstract method');
  14071. };
  14072. function AstArgument(index, min, max) {
  14073. AstNode.call(this, 'args');
  14074. this.index = index;
  14075. this.min = min;
  14076. this.max = max;
  14077. }
  14078. AstArgument.prototype = Object.create(AstNode.prototype);
  14079. AstArgument.prototype.visit = function (visitor) {
  14080. visitor.visitArgument(this);
  14081. };
  14082. function AstLiteral(number) {
  14083. AstNode.call(this, 'literal');
  14084. this.number = number;
  14085. this.min = number;
  14086. this.max = number;
  14087. }
  14088. AstLiteral.prototype = Object.create(AstNode.prototype);
  14089. AstLiteral.prototype.visit = function (visitor) {
  14090. visitor.visitLiteral(this);
  14091. };
  14092. function AstBinaryOperation(op, arg1, arg2, min, max) {
  14093. AstNode.call(this, 'binary');
  14094. this.op = op;
  14095. this.arg1 = arg1;
  14096. this.arg2 = arg2;
  14097. this.min = min;
  14098. this.max = max;
  14099. }
  14100. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  14101. AstBinaryOperation.prototype.visit = function (visitor) {
  14102. visitor.visitBinaryOperation(this);
  14103. };
  14104. function AstMin(arg, max) {
  14105. AstNode.call(this, 'max');
  14106. this.arg = arg;
  14107. this.min = arg.min;
  14108. this.max = max;
  14109. }
  14110. AstMin.prototype = Object.create(AstNode.prototype);
  14111. AstMin.prototype.visit = function (visitor) {
  14112. visitor.visitMin(this);
  14113. };
  14114. function AstVariable(index, min, max) {
  14115. AstNode.call(this, 'var');
  14116. this.index = index;
  14117. this.min = min;
  14118. this.max = max;
  14119. }
  14120. AstVariable.prototype = Object.create(AstNode.prototype);
  14121. AstVariable.prototype.visit = function (visitor) {
  14122. visitor.visitVariable(this);
  14123. };
  14124. function AstVariableDefinition(variable, arg) {
  14125. AstNode.call(this, 'definition');
  14126. this.variable = variable;
  14127. this.arg = arg;
  14128. }
  14129. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  14130. AstVariableDefinition.prototype.visit = function (visitor) {
  14131. visitor.visitVariableDefinition(this);
  14132. };
  14133. function ExpressionBuilderVisitor() {
  14134. this.parts = [];
  14135. }
  14136. ExpressionBuilderVisitor.prototype = {
  14137. visitArgument: function (arg) {
  14138. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  14139. },
  14140. visitVariable: function (variable) {
  14141. this.parts.push('v', variable.index);
  14142. },
  14143. visitLiteral: function (literal) {
  14144. this.parts.push(literal.number);
  14145. },
  14146. visitBinaryOperation: function (operation) {
  14147. this.parts.push('(');
  14148. operation.arg1.visit(this);
  14149. this.parts.push(' ', operation.op, ' ');
  14150. operation.arg2.visit(this);
  14151. this.parts.push(')');
  14152. },
  14153. visitVariableDefinition: function (definition) {
  14154. this.parts.push('var ');
  14155. definition.variable.visit(this);
  14156. this.parts.push(' = ');
  14157. definition.arg.visit(this);
  14158. this.parts.push(';');
  14159. },
  14160. visitMin: function (max) {
  14161. this.parts.push('Math.min(');
  14162. max.arg.visit(this);
  14163. this.parts.push(', ', max.max, ')');
  14164. },
  14165. toString: function () {
  14166. return this.parts.join('');
  14167. }
  14168. };
  14169. function buildAddOperation(num1, num2) {
  14170. if (num2.type === 'literal' && num2.number === 0) {
  14171. return num1;
  14172. }
  14173. if (num1.type === 'literal' && num1.number === 0) {
  14174. return num2;
  14175. }
  14176. if (num2.type === 'literal' && num1.type === 'literal') {
  14177. return new AstLiteral(num1.number + num2.number);
  14178. }
  14179. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  14180. }
  14181. function buildMulOperation(num1, num2) {
  14182. if (num2.type === 'literal') {
  14183. if (num2.number === 0) {
  14184. return new AstLiteral(0);
  14185. } else if (num2.number === 1) {
  14186. return num1;
  14187. } else if (num1.type === 'literal') {
  14188. return new AstLiteral(num1.number * num2.number);
  14189. }
  14190. }
  14191. if (num1.type === 'literal') {
  14192. if (num1.number === 0) {
  14193. return new AstLiteral(0);
  14194. } else if (num1.number === 1) {
  14195. return num2;
  14196. }
  14197. }
  14198. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14199. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14200. return new AstBinaryOperation('*', num1, num2, min, max);
  14201. }
  14202. function buildSubOperation(num1, num2) {
  14203. if (num2.type === 'literal') {
  14204. if (num2.number === 0) {
  14205. return num1;
  14206. } else if (num1.type === 'literal') {
  14207. return new AstLiteral(num1.number - num2.number);
  14208. }
  14209. }
  14210. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  14211. return num2.arg2;
  14212. }
  14213. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  14214. }
  14215. function buildMinOperation(num1, max) {
  14216. if (num1.min >= max) {
  14217. return new AstLiteral(max);
  14218. } else if (num1.max <= max) {
  14219. return num1;
  14220. }
  14221. return new AstMin(num1, max);
  14222. }
  14223. function PostScriptCompiler() {
  14224. }
  14225. PostScriptCompiler.prototype = {
  14226. compile: function PostScriptCompiler_compile(code, domain, range) {
  14227. var stack = [];
  14228. var i, ii;
  14229. var instructions = [];
  14230. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  14231. var lastRegister = 0;
  14232. var n, j;
  14233. var num1, num2, ast1, ast2, tmpVar, item;
  14234. for (i = 0; i < inputSize; i++) {
  14235. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  14236. }
  14237. for (i = 0, ii = code.length; i < ii; i++) {
  14238. item = code[i];
  14239. if (typeof item === 'number') {
  14240. stack.push(new AstLiteral(item));
  14241. continue;
  14242. }
  14243. switch (item) {
  14244. case 'add':
  14245. if (stack.length < 2) {
  14246. return null;
  14247. }
  14248. num2 = stack.pop();
  14249. num1 = stack.pop();
  14250. stack.push(buildAddOperation(num1, num2));
  14251. break;
  14252. case 'cvr':
  14253. if (stack.length < 1) {
  14254. return null;
  14255. }
  14256. break;
  14257. case 'mul':
  14258. if (stack.length < 2) {
  14259. return null;
  14260. }
  14261. num2 = stack.pop();
  14262. num1 = stack.pop();
  14263. stack.push(buildMulOperation(num1, num2));
  14264. break;
  14265. case 'sub':
  14266. if (stack.length < 2) {
  14267. return null;
  14268. }
  14269. num2 = stack.pop();
  14270. num1 = stack.pop();
  14271. stack.push(buildSubOperation(num1, num2));
  14272. break;
  14273. case 'exch':
  14274. if (stack.length < 2) {
  14275. return null;
  14276. }
  14277. ast1 = stack.pop();
  14278. ast2 = stack.pop();
  14279. stack.push(ast1, ast2);
  14280. break;
  14281. case 'pop':
  14282. if (stack.length < 1) {
  14283. return null;
  14284. }
  14285. stack.pop();
  14286. break;
  14287. case 'index':
  14288. if (stack.length < 1) {
  14289. return null;
  14290. }
  14291. num1 = stack.pop();
  14292. if (num1.type !== 'literal') {
  14293. return null;
  14294. }
  14295. n = num1.number;
  14296. if (n < 0 || (n | 0) !== n || stack.length < n) {
  14297. return null;
  14298. }
  14299. ast1 = stack[stack.length - n - 1];
  14300. if (ast1.type === 'literal' || ast1.type === 'var') {
  14301. stack.push(ast1);
  14302. break;
  14303. }
  14304. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14305. stack[stack.length - n - 1] = tmpVar;
  14306. stack.push(tmpVar);
  14307. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14308. break;
  14309. case 'dup':
  14310. if (stack.length < 1) {
  14311. return null;
  14312. }
  14313. 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]) {
  14314. num1 = stack.pop();
  14315. stack.push(buildMinOperation(num1, code[i + 1]));
  14316. i += 6;
  14317. break;
  14318. }
  14319. ast1 = stack[stack.length - 1];
  14320. if (ast1.type === 'literal' || ast1.type === 'var') {
  14321. stack.push(ast1);
  14322. break;
  14323. }
  14324. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14325. stack[stack.length - 1] = tmpVar;
  14326. stack.push(tmpVar);
  14327. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14328. break;
  14329. case 'roll':
  14330. if (stack.length < 2) {
  14331. return null;
  14332. }
  14333. num2 = stack.pop();
  14334. num1 = stack.pop();
  14335. if (num2.type !== 'literal' || num1.type !== 'literal') {
  14336. return null;
  14337. }
  14338. j = num2.number;
  14339. n = num1.number;
  14340. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  14341. return null;
  14342. }
  14343. j = (j % n + n) % n;
  14344. if (j === 0) {
  14345. break;
  14346. }
  14347. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  14348. break;
  14349. default:
  14350. return null;
  14351. }
  14352. }
  14353. if (stack.length !== outputSize) {
  14354. return null;
  14355. }
  14356. var result = [];
  14357. instructions.forEach(function (instruction) {
  14358. var statementBuilder = new ExpressionBuilderVisitor();
  14359. instruction.visit(statementBuilder);
  14360. result.push(statementBuilder.toString());
  14361. });
  14362. stack.forEach(function (expr, i) {
  14363. var statementBuilder = new ExpressionBuilderVisitor();
  14364. expr.visit(statementBuilder);
  14365. var min = range[i * 2], max = range[i * 2 + 1];
  14366. var out = [statementBuilder.toString()];
  14367. if (min > expr.min) {
  14368. out.unshift('Math.max(', min, ', ');
  14369. out.push(')');
  14370. }
  14371. if (max < expr.max) {
  14372. out.unshift('Math.min(', max, ', ');
  14373. out.push(')');
  14374. }
  14375. out.unshift('dest[destOffset + ', i, '] = ');
  14376. out.push(';');
  14377. result.push(out.join(''));
  14378. });
  14379. return result.join('\n');
  14380. }
  14381. };
  14382. return PostScriptCompiler;
  14383. }();
  14384. exports.isPDFFunction = isPDFFunction;
  14385. exports.PDFFunction = PDFFunction;
  14386. exports.PostScriptEvaluator = PostScriptEvaluator;
  14387. exports.PostScriptCompiler = PostScriptCompiler;
  14388. /***/ }),
  14389. /* 8 */
  14390. /***/ (function(module, exports, __w_pdfjs_require__) {
  14391. "use strict";
  14392. var sharedUtil = __w_pdfjs_require__(0);
  14393. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  14394. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  14395. t['A'] = 0x0041;
  14396. t['AE'] = 0x00C6;
  14397. t['AEacute'] = 0x01FC;
  14398. t['AEmacron'] = 0x01E2;
  14399. t['AEsmall'] = 0xF7E6;
  14400. t['Aacute'] = 0x00C1;
  14401. t['Aacutesmall'] = 0xF7E1;
  14402. t['Abreve'] = 0x0102;
  14403. t['Abreveacute'] = 0x1EAE;
  14404. t['Abrevecyrillic'] = 0x04D0;
  14405. t['Abrevedotbelow'] = 0x1EB6;
  14406. t['Abrevegrave'] = 0x1EB0;
  14407. t['Abrevehookabove'] = 0x1EB2;
  14408. t['Abrevetilde'] = 0x1EB4;
  14409. t['Acaron'] = 0x01CD;
  14410. t['Acircle'] = 0x24B6;
  14411. t['Acircumflex'] = 0x00C2;
  14412. t['Acircumflexacute'] = 0x1EA4;
  14413. t['Acircumflexdotbelow'] = 0x1EAC;
  14414. t['Acircumflexgrave'] = 0x1EA6;
  14415. t['Acircumflexhookabove'] = 0x1EA8;
  14416. t['Acircumflexsmall'] = 0xF7E2;
  14417. t['Acircumflextilde'] = 0x1EAA;
  14418. t['Acute'] = 0xF6C9;
  14419. t['Acutesmall'] = 0xF7B4;
  14420. t['Acyrillic'] = 0x0410;
  14421. t['Adblgrave'] = 0x0200;
  14422. t['Adieresis'] = 0x00C4;
  14423. t['Adieresiscyrillic'] = 0x04D2;
  14424. t['Adieresismacron'] = 0x01DE;
  14425. t['Adieresissmall'] = 0xF7E4;
  14426. t['Adotbelow'] = 0x1EA0;
  14427. t['Adotmacron'] = 0x01E0;
  14428. t['Agrave'] = 0x00C0;
  14429. t['Agravesmall'] = 0xF7E0;
  14430. t['Ahookabove'] = 0x1EA2;
  14431. t['Aiecyrillic'] = 0x04D4;
  14432. t['Ainvertedbreve'] = 0x0202;
  14433. t['Alpha'] = 0x0391;
  14434. t['Alphatonos'] = 0x0386;
  14435. t['Amacron'] = 0x0100;
  14436. t['Amonospace'] = 0xFF21;
  14437. t['Aogonek'] = 0x0104;
  14438. t['Aring'] = 0x00C5;
  14439. t['Aringacute'] = 0x01FA;
  14440. t['Aringbelow'] = 0x1E00;
  14441. t['Aringsmall'] = 0xF7E5;
  14442. t['Asmall'] = 0xF761;
  14443. t['Atilde'] = 0x00C3;
  14444. t['Atildesmall'] = 0xF7E3;
  14445. t['Aybarmenian'] = 0x0531;
  14446. t['B'] = 0x0042;
  14447. t['Bcircle'] = 0x24B7;
  14448. t['Bdotaccent'] = 0x1E02;
  14449. t['Bdotbelow'] = 0x1E04;
  14450. t['Becyrillic'] = 0x0411;
  14451. t['Benarmenian'] = 0x0532;
  14452. t['Beta'] = 0x0392;
  14453. t['Bhook'] = 0x0181;
  14454. t['Blinebelow'] = 0x1E06;
  14455. t['Bmonospace'] = 0xFF22;
  14456. t['Brevesmall'] = 0xF6F4;
  14457. t['Bsmall'] = 0xF762;
  14458. t['Btopbar'] = 0x0182;
  14459. t['C'] = 0x0043;
  14460. t['Caarmenian'] = 0x053E;
  14461. t['Cacute'] = 0x0106;
  14462. t['Caron'] = 0xF6CA;
  14463. t['Caronsmall'] = 0xF6F5;
  14464. t['Ccaron'] = 0x010C;
  14465. t['Ccedilla'] = 0x00C7;
  14466. t['Ccedillaacute'] = 0x1E08;
  14467. t['Ccedillasmall'] = 0xF7E7;
  14468. t['Ccircle'] = 0x24B8;
  14469. t['Ccircumflex'] = 0x0108;
  14470. t['Cdot'] = 0x010A;
  14471. t['Cdotaccent'] = 0x010A;
  14472. t['Cedillasmall'] = 0xF7B8;
  14473. t['Chaarmenian'] = 0x0549;
  14474. t['Cheabkhasiancyrillic'] = 0x04BC;
  14475. t['Checyrillic'] = 0x0427;
  14476. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  14477. t['Chedescendercyrillic'] = 0x04B6;
  14478. t['Chedieresiscyrillic'] = 0x04F4;
  14479. t['Cheharmenian'] = 0x0543;
  14480. t['Chekhakassiancyrillic'] = 0x04CB;
  14481. t['Cheverticalstrokecyrillic'] = 0x04B8;
  14482. t['Chi'] = 0x03A7;
  14483. t['Chook'] = 0x0187;
  14484. t['Circumflexsmall'] = 0xF6F6;
  14485. t['Cmonospace'] = 0xFF23;
  14486. t['Coarmenian'] = 0x0551;
  14487. t['Csmall'] = 0xF763;
  14488. t['D'] = 0x0044;
  14489. t['DZ'] = 0x01F1;
  14490. t['DZcaron'] = 0x01C4;
  14491. t['Daarmenian'] = 0x0534;
  14492. t['Dafrican'] = 0x0189;
  14493. t['Dcaron'] = 0x010E;
  14494. t['Dcedilla'] = 0x1E10;
  14495. t['Dcircle'] = 0x24B9;
  14496. t['Dcircumflexbelow'] = 0x1E12;
  14497. t['Dcroat'] = 0x0110;
  14498. t['Ddotaccent'] = 0x1E0A;
  14499. t['Ddotbelow'] = 0x1E0C;
  14500. t['Decyrillic'] = 0x0414;
  14501. t['Deicoptic'] = 0x03EE;
  14502. t['Delta'] = 0x2206;
  14503. t['Deltagreek'] = 0x0394;
  14504. t['Dhook'] = 0x018A;
  14505. t['Dieresis'] = 0xF6CB;
  14506. t['DieresisAcute'] = 0xF6CC;
  14507. t['DieresisGrave'] = 0xF6CD;
  14508. t['Dieresissmall'] = 0xF7A8;
  14509. t['Digammagreek'] = 0x03DC;
  14510. t['Djecyrillic'] = 0x0402;
  14511. t['Dlinebelow'] = 0x1E0E;
  14512. t['Dmonospace'] = 0xFF24;
  14513. t['Dotaccentsmall'] = 0xF6F7;
  14514. t['Dslash'] = 0x0110;
  14515. t['Dsmall'] = 0xF764;
  14516. t['Dtopbar'] = 0x018B;
  14517. t['Dz'] = 0x01F2;
  14518. t['Dzcaron'] = 0x01C5;
  14519. t['Dzeabkhasiancyrillic'] = 0x04E0;
  14520. t['Dzecyrillic'] = 0x0405;
  14521. t['Dzhecyrillic'] = 0x040F;
  14522. t['E'] = 0x0045;
  14523. t['Eacute'] = 0x00C9;
  14524. t['Eacutesmall'] = 0xF7E9;
  14525. t['Ebreve'] = 0x0114;
  14526. t['Ecaron'] = 0x011A;
  14527. t['Ecedillabreve'] = 0x1E1C;
  14528. t['Echarmenian'] = 0x0535;
  14529. t['Ecircle'] = 0x24BA;
  14530. t['Ecircumflex'] = 0x00CA;
  14531. t['Ecircumflexacute'] = 0x1EBE;
  14532. t['Ecircumflexbelow'] = 0x1E18;
  14533. t['Ecircumflexdotbelow'] = 0x1EC6;
  14534. t['Ecircumflexgrave'] = 0x1EC0;
  14535. t['Ecircumflexhookabove'] = 0x1EC2;
  14536. t['Ecircumflexsmall'] = 0xF7EA;
  14537. t['Ecircumflextilde'] = 0x1EC4;
  14538. t['Ecyrillic'] = 0x0404;
  14539. t['Edblgrave'] = 0x0204;
  14540. t['Edieresis'] = 0x00CB;
  14541. t['Edieresissmall'] = 0xF7EB;
  14542. t['Edot'] = 0x0116;
  14543. t['Edotaccent'] = 0x0116;
  14544. t['Edotbelow'] = 0x1EB8;
  14545. t['Efcyrillic'] = 0x0424;
  14546. t['Egrave'] = 0x00C8;
  14547. t['Egravesmall'] = 0xF7E8;
  14548. t['Eharmenian'] = 0x0537;
  14549. t['Ehookabove'] = 0x1EBA;
  14550. t['Eightroman'] = 0x2167;
  14551. t['Einvertedbreve'] = 0x0206;
  14552. t['Eiotifiedcyrillic'] = 0x0464;
  14553. t['Elcyrillic'] = 0x041B;
  14554. t['Elevenroman'] = 0x216A;
  14555. t['Emacron'] = 0x0112;
  14556. t['Emacronacute'] = 0x1E16;
  14557. t['Emacrongrave'] = 0x1E14;
  14558. t['Emcyrillic'] = 0x041C;
  14559. t['Emonospace'] = 0xFF25;
  14560. t['Encyrillic'] = 0x041D;
  14561. t['Endescendercyrillic'] = 0x04A2;
  14562. t['Eng'] = 0x014A;
  14563. t['Enghecyrillic'] = 0x04A4;
  14564. t['Enhookcyrillic'] = 0x04C7;
  14565. t['Eogonek'] = 0x0118;
  14566. t['Eopen'] = 0x0190;
  14567. t['Epsilon'] = 0x0395;
  14568. t['Epsilontonos'] = 0x0388;
  14569. t['Ercyrillic'] = 0x0420;
  14570. t['Ereversed'] = 0x018E;
  14571. t['Ereversedcyrillic'] = 0x042D;
  14572. t['Escyrillic'] = 0x0421;
  14573. t['Esdescendercyrillic'] = 0x04AA;
  14574. t['Esh'] = 0x01A9;
  14575. t['Esmall'] = 0xF765;
  14576. t['Eta'] = 0x0397;
  14577. t['Etarmenian'] = 0x0538;
  14578. t['Etatonos'] = 0x0389;
  14579. t['Eth'] = 0x00D0;
  14580. t['Ethsmall'] = 0xF7F0;
  14581. t['Etilde'] = 0x1EBC;
  14582. t['Etildebelow'] = 0x1E1A;
  14583. t['Euro'] = 0x20AC;
  14584. t['Ezh'] = 0x01B7;
  14585. t['Ezhcaron'] = 0x01EE;
  14586. t['Ezhreversed'] = 0x01B8;
  14587. t['F'] = 0x0046;
  14588. t['Fcircle'] = 0x24BB;
  14589. t['Fdotaccent'] = 0x1E1E;
  14590. t['Feharmenian'] = 0x0556;
  14591. t['Feicoptic'] = 0x03E4;
  14592. t['Fhook'] = 0x0191;
  14593. t['Fitacyrillic'] = 0x0472;
  14594. t['Fiveroman'] = 0x2164;
  14595. t['Fmonospace'] = 0xFF26;
  14596. t['Fourroman'] = 0x2163;
  14597. t['Fsmall'] = 0xF766;
  14598. t['G'] = 0x0047;
  14599. t['GBsquare'] = 0x3387;
  14600. t['Gacute'] = 0x01F4;
  14601. t['Gamma'] = 0x0393;
  14602. t['Gammaafrican'] = 0x0194;
  14603. t['Gangiacoptic'] = 0x03EA;
  14604. t['Gbreve'] = 0x011E;
  14605. t['Gcaron'] = 0x01E6;
  14606. t['Gcedilla'] = 0x0122;
  14607. t['Gcircle'] = 0x24BC;
  14608. t['Gcircumflex'] = 0x011C;
  14609. t['Gcommaaccent'] = 0x0122;
  14610. t['Gdot'] = 0x0120;
  14611. t['Gdotaccent'] = 0x0120;
  14612. t['Gecyrillic'] = 0x0413;
  14613. t['Ghadarmenian'] = 0x0542;
  14614. t['Ghemiddlehookcyrillic'] = 0x0494;
  14615. t['Ghestrokecyrillic'] = 0x0492;
  14616. t['Gheupturncyrillic'] = 0x0490;
  14617. t['Ghook'] = 0x0193;
  14618. t['Gimarmenian'] = 0x0533;
  14619. t['Gjecyrillic'] = 0x0403;
  14620. t['Gmacron'] = 0x1E20;
  14621. t['Gmonospace'] = 0xFF27;
  14622. t['Grave'] = 0xF6CE;
  14623. t['Gravesmall'] = 0xF760;
  14624. t['Gsmall'] = 0xF767;
  14625. t['Gsmallhook'] = 0x029B;
  14626. t['Gstroke'] = 0x01E4;
  14627. t['H'] = 0x0048;
  14628. t['H18533'] = 0x25CF;
  14629. t['H18543'] = 0x25AA;
  14630. t['H18551'] = 0x25AB;
  14631. t['H22073'] = 0x25A1;
  14632. t['HPsquare'] = 0x33CB;
  14633. t['Haabkhasiancyrillic'] = 0x04A8;
  14634. t['Hadescendercyrillic'] = 0x04B2;
  14635. t['Hardsigncyrillic'] = 0x042A;
  14636. t['Hbar'] = 0x0126;
  14637. t['Hbrevebelow'] = 0x1E2A;
  14638. t['Hcedilla'] = 0x1E28;
  14639. t['Hcircle'] = 0x24BD;
  14640. t['Hcircumflex'] = 0x0124;
  14641. t['Hdieresis'] = 0x1E26;
  14642. t['Hdotaccent'] = 0x1E22;
  14643. t['Hdotbelow'] = 0x1E24;
  14644. t['Hmonospace'] = 0xFF28;
  14645. t['Hoarmenian'] = 0x0540;
  14646. t['Horicoptic'] = 0x03E8;
  14647. t['Hsmall'] = 0xF768;
  14648. t['Hungarumlaut'] = 0xF6CF;
  14649. t['Hungarumlautsmall'] = 0xF6F8;
  14650. t['Hzsquare'] = 0x3390;
  14651. t['I'] = 0x0049;
  14652. t['IAcyrillic'] = 0x042F;
  14653. t['IJ'] = 0x0132;
  14654. t['IUcyrillic'] = 0x042E;
  14655. t['Iacute'] = 0x00CD;
  14656. t['Iacutesmall'] = 0xF7ED;
  14657. t['Ibreve'] = 0x012C;
  14658. t['Icaron'] = 0x01CF;
  14659. t['Icircle'] = 0x24BE;
  14660. t['Icircumflex'] = 0x00CE;
  14661. t['Icircumflexsmall'] = 0xF7EE;
  14662. t['Icyrillic'] = 0x0406;
  14663. t['Idblgrave'] = 0x0208;
  14664. t['Idieresis'] = 0x00CF;
  14665. t['Idieresisacute'] = 0x1E2E;
  14666. t['Idieresiscyrillic'] = 0x04E4;
  14667. t['Idieresissmall'] = 0xF7EF;
  14668. t['Idot'] = 0x0130;
  14669. t['Idotaccent'] = 0x0130;
  14670. t['Idotbelow'] = 0x1ECA;
  14671. t['Iebrevecyrillic'] = 0x04D6;
  14672. t['Iecyrillic'] = 0x0415;
  14673. t['Ifraktur'] = 0x2111;
  14674. t['Igrave'] = 0x00CC;
  14675. t['Igravesmall'] = 0xF7EC;
  14676. t['Ihookabove'] = 0x1EC8;
  14677. t['Iicyrillic'] = 0x0418;
  14678. t['Iinvertedbreve'] = 0x020A;
  14679. t['Iishortcyrillic'] = 0x0419;
  14680. t['Imacron'] = 0x012A;
  14681. t['Imacroncyrillic'] = 0x04E2;
  14682. t['Imonospace'] = 0xFF29;
  14683. t['Iniarmenian'] = 0x053B;
  14684. t['Iocyrillic'] = 0x0401;
  14685. t['Iogonek'] = 0x012E;
  14686. t['Iota'] = 0x0399;
  14687. t['Iotaafrican'] = 0x0196;
  14688. t['Iotadieresis'] = 0x03AA;
  14689. t['Iotatonos'] = 0x038A;
  14690. t['Ismall'] = 0xF769;
  14691. t['Istroke'] = 0x0197;
  14692. t['Itilde'] = 0x0128;
  14693. t['Itildebelow'] = 0x1E2C;
  14694. t['Izhitsacyrillic'] = 0x0474;
  14695. t['Izhitsadblgravecyrillic'] = 0x0476;
  14696. t['J'] = 0x004A;
  14697. t['Jaarmenian'] = 0x0541;
  14698. t['Jcircle'] = 0x24BF;
  14699. t['Jcircumflex'] = 0x0134;
  14700. t['Jecyrillic'] = 0x0408;
  14701. t['Jheharmenian'] = 0x054B;
  14702. t['Jmonospace'] = 0xFF2A;
  14703. t['Jsmall'] = 0xF76A;
  14704. t['K'] = 0x004B;
  14705. t['KBsquare'] = 0x3385;
  14706. t['KKsquare'] = 0x33CD;
  14707. t['Kabashkircyrillic'] = 0x04A0;
  14708. t['Kacute'] = 0x1E30;
  14709. t['Kacyrillic'] = 0x041A;
  14710. t['Kadescendercyrillic'] = 0x049A;
  14711. t['Kahookcyrillic'] = 0x04C3;
  14712. t['Kappa'] = 0x039A;
  14713. t['Kastrokecyrillic'] = 0x049E;
  14714. t['Kaverticalstrokecyrillic'] = 0x049C;
  14715. t['Kcaron'] = 0x01E8;
  14716. t['Kcedilla'] = 0x0136;
  14717. t['Kcircle'] = 0x24C0;
  14718. t['Kcommaaccent'] = 0x0136;
  14719. t['Kdotbelow'] = 0x1E32;
  14720. t['Keharmenian'] = 0x0554;
  14721. t['Kenarmenian'] = 0x053F;
  14722. t['Khacyrillic'] = 0x0425;
  14723. t['Kheicoptic'] = 0x03E6;
  14724. t['Khook'] = 0x0198;
  14725. t['Kjecyrillic'] = 0x040C;
  14726. t['Klinebelow'] = 0x1E34;
  14727. t['Kmonospace'] = 0xFF2B;
  14728. t['Koppacyrillic'] = 0x0480;
  14729. t['Koppagreek'] = 0x03DE;
  14730. t['Ksicyrillic'] = 0x046E;
  14731. t['Ksmall'] = 0xF76B;
  14732. t['L'] = 0x004C;
  14733. t['LJ'] = 0x01C7;
  14734. t['LL'] = 0xF6BF;
  14735. t['Lacute'] = 0x0139;
  14736. t['Lambda'] = 0x039B;
  14737. t['Lcaron'] = 0x013D;
  14738. t['Lcedilla'] = 0x013B;
  14739. t['Lcircle'] = 0x24C1;
  14740. t['Lcircumflexbelow'] = 0x1E3C;
  14741. t['Lcommaaccent'] = 0x013B;
  14742. t['Ldot'] = 0x013F;
  14743. t['Ldotaccent'] = 0x013F;
  14744. t['Ldotbelow'] = 0x1E36;
  14745. t['Ldotbelowmacron'] = 0x1E38;
  14746. t['Liwnarmenian'] = 0x053C;
  14747. t['Lj'] = 0x01C8;
  14748. t['Ljecyrillic'] = 0x0409;
  14749. t['Llinebelow'] = 0x1E3A;
  14750. t['Lmonospace'] = 0xFF2C;
  14751. t['Lslash'] = 0x0141;
  14752. t['Lslashsmall'] = 0xF6F9;
  14753. t['Lsmall'] = 0xF76C;
  14754. t['M'] = 0x004D;
  14755. t['MBsquare'] = 0x3386;
  14756. t['Macron'] = 0xF6D0;
  14757. t['Macronsmall'] = 0xF7AF;
  14758. t['Macute'] = 0x1E3E;
  14759. t['Mcircle'] = 0x24C2;
  14760. t['Mdotaccent'] = 0x1E40;
  14761. t['Mdotbelow'] = 0x1E42;
  14762. t['Menarmenian'] = 0x0544;
  14763. t['Mmonospace'] = 0xFF2D;
  14764. t['Msmall'] = 0xF76D;
  14765. t['Mturned'] = 0x019C;
  14766. t['Mu'] = 0x039C;
  14767. t['N'] = 0x004E;
  14768. t['NJ'] = 0x01CA;
  14769. t['Nacute'] = 0x0143;
  14770. t['Ncaron'] = 0x0147;
  14771. t['Ncedilla'] = 0x0145;
  14772. t['Ncircle'] = 0x24C3;
  14773. t['Ncircumflexbelow'] = 0x1E4A;
  14774. t['Ncommaaccent'] = 0x0145;
  14775. t['Ndotaccent'] = 0x1E44;
  14776. t['Ndotbelow'] = 0x1E46;
  14777. t['Nhookleft'] = 0x019D;
  14778. t['Nineroman'] = 0x2168;
  14779. t['Nj'] = 0x01CB;
  14780. t['Njecyrillic'] = 0x040A;
  14781. t['Nlinebelow'] = 0x1E48;
  14782. t['Nmonospace'] = 0xFF2E;
  14783. t['Nowarmenian'] = 0x0546;
  14784. t['Nsmall'] = 0xF76E;
  14785. t['Ntilde'] = 0x00D1;
  14786. t['Ntildesmall'] = 0xF7F1;
  14787. t['Nu'] = 0x039D;
  14788. t['O'] = 0x004F;
  14789. t['OE'] = 0x0152;
  14790. t['OEsmall'] = 0xF6FA;
  14791. t['Oacute'] = 0x00D3;
  14792. t['Oacutesmall'] = 0xF7F3;
  14793. t['Obarredcyrillic'] = 0x04E8;
  14794. t['Obarreddieresiscyrillic'] = 0x04EA;
  14795. t['Obreve'] = 0x014E;
  14796. t['Ocaron'] = 0x01D1;
  14797. t['Ocenteredtilde'] = 0x019F;
  14798. t['Ocircle'] = 0x24C4;
  14799. t['Ocircumflex'] = 0x00D4;
  14800. t['Ocircumflexacute'] = 0x1ED0;
  14801. t['Ocircumflexdotbelow'] = 0x1ED8;
  14802. t['Ocircumflexgrave'] = 0x1ED2;
  14803. t['Ocircumflexhookabove'] = 0x1ED4;
  14804. t['Ocircumflexsmall'] = 0xF7F4;
  14805. t['Ocircumflextilde'] = 0x1ED6;
  14806. t['Ocyrillic'] = 0x041E;
  14807. t['Odblacute'] = 0x0150;
  14808. t['Odblgrave'] = 0x020C;
  14809. t['Odieresis'] = 0x00D6;
  14810. t['Odieresiscyrillic'] = 0x04E6;
  14811. t['Odieresissmall'] = 0xF7F6;
  14812. t['Odotbelow'] = 0x1ECC;
  14813. t['Ogoneksmall'] = 0xF6FB;
  14814. t['Ograve'] = 0x00D2;
  14815. t['Ogravesmall'] = 0xF7F2;
  14816. t['Oharmenian'] = 0x0555;
  14817. t['Ohm'] = 0x2126;
  14818. t['Ohookabove'] = 0x1ECE;
  14819. t['Ohorn'] = 0x01A0;
  14820. t['Ohornacute'] = 0x1EDA;
  14821. t['Ohorndotbelow'] = 0x1EE2;
  14822. t['Ohorngrave'] = 0x1EDC;
  14823. t['Ohornhookabove'] = 0x1EDE;
  14824. t['Ohorntilde'] = 0x1EE0;
  14825. t['Ohungarumlaut'] = 0x0150;
  14826. t['Oi'] = 0x01A2;
  14827. t['Oinvertedbreve'] = 0x020E;
  14828. t['Omacron'] = 0x014C;
  14829. t['Omacronacute'] = 0x1E52;
  14830. t['Omacrongrave'] = 0x1E50;
  14831. t['Omega'] = 0x2126;
  14832. t['Omegacyrillic'] = 0x0460;
  14833. t['Omegagreek'] = 0x03A9;
  14834. t['Omegaroundcyrillic'] = 0x047A;
  14835. t['Omegatitlocyrillic'] = 0x047C;
  14836. t['Omegatonos'] = 0x038F;
  14837. t['Omicron'] = 0x039F;
  14838. t['Omicrontonos'] = 0x038C;
  14839. t['Omonospace'] = 0xFF2F;
  14840. t['Oneroman'] = 0x2160;
  14841. t['Oogonek'] = 0x01EA;
  14842. t['Oogonekmacron'] = 0x01EC;
  14843. t['Oopen'] = 0x0186;
  14844. t['Oslash'] = 0x00D8;
  14845. t['Oslashacute'] = 0x01FE;
  14846. t['Oslashsmall'] = 0xF7F8;
  14847. t['Osmall'] = 0xF76F;
  14848. t['Ostrokeacute'] = 0x01FE;
  14849. t['Otcyrillic'] = 0x047E;
  14850. t['Otilde'] = 0x00D5;
  14851. t['Otildeacute'] = 0x1E4C;
  14852. t['Otildedieresis'] = 0x1E4E;
  14853. t['Otildesmall'] = 0xF7F5;
  14854. t['P'] = 0x0050;
  14855. t['Pacute'] = 0x1E54;
  14856. t['Pcircle'] = 0x24C5;
  14857. t['Pdotaccent'] = 0x1E56;
  14858. t['Pecyrillic'] = 0x041F;
  14859. t['Peharmenian'] = 0x054A;
  14860. t['Pemiddlehookcyrillic'] = 0x04A6;
  14861. t['Phi'] = 0x03A6;
  14862. t['Phook'] = 0x01A4;
  14863. t['Pi'] = 0x03A0;
  14864. t['Piwrarmenian'] = 0x0553;
  14865. t['Pmonospace'] = 0xFF30;
  14866. t['Psi'] = 0x03A8;
  14867. t['Psicyrillic'] = 0x0470;
  14868. t['Psmall'] = 0xF770;
  14869. t['Q'] = 0x0051;
  14870. t['Qcircle'] = 0x24C6;
  14871. t['Qmonospace'] = 0xFF31;
  14872. t['Qsmall'] = 0xF771;
  14873. t['R'] = 0x0052;
  14874. t['Raarmenian'] = 0x054C;
  14875. t['Racute'] = 0x0154;
  14876. t['Rcaron'] = 0x0158;
  14877. t['Rcedilla'] = 0x0156;
  14878. t['Rcircle'] = 0x24C7;
  14879. t['Rcommaaccent'] = 0x0156;
  14880. t['Rdblgrave'] = 0x0210;
  14881. t['Rdotaccent'] = 0x1E58;
  14882. t['Rdotbelow'] = 0x1E5A;
  14883. t['Rdotbelowmacron'] = 0x1E5C;
  14884. t['Reharmenian'] = 0x0550;
  14885. t['Rfraktur'] = 0x211C;
  14886. t['Rho'] = 0x03A1;
  14887. t['Ringsmall'] = 0xF6FC;
  14888. t['Rinvertedbreve'] = 0x0212;
  14889. t['Rlinebelow'] = 0x1E5E;
  14890. t['Rmonospace'] = 0xFF32;
  14891. t['Rsmall'] = 0xF772;
  14892. t['Rsmallinverted'] = 0x0281;
  14893. t['Rsmallinvertedsuperior'] = 0x02B6;
  14894. t['S'] = 0x0053;
  14895. t['SF010000'] = 0x250C;
  14896. t['SF020000'] = 0x2514;
  14897. t['SF030000'] = 0x2510;
  14898. t['SF040000'] = 0x2518;
  14899. t['SF050000'] = 0x253C;
  14900. t['SF060000'] = 0x252C;
  14901. t['SF070000'] = 0x2534;
  14902. t['SF080000'] = 0x251C;
  14903. t['SF090000'] = 0x2524;
  14904. t['SF100000'] = 0x2500;
  14905. t['SF110000'] = 0x2502;
  14906. t['SF190000'] = 0x2561;
  14907. t['SF200000'] = 0x2562;
  14908. t['SF210000'] = 0x2556;
  14909. t['SF220000'] = 0x2555;
  14910. t['SF230000'] = 0x2563;
  14911. t['SF240000'] = 0x2551;
  14912. t['SF250000'] = 0x2557;
  14913. t['SF260000'] = 0x255D;
  14914. t['SF270000'] = 0x255C;
  14915. t['SF280000'] = 0x255B;
  14916. t['SF360000'] = 0x255E;
  14917. t['SF370000'] = 0x255F;
  14918. t['SF380000'] = 0x255A;
  14919. t['SF390000'] = 0x2554;
  14920. t['SF400000'] = 0x2569;
  14921. t['SF410000'] = 0x2566;
  14922. t['SF420000'] = 0x2560;
  14923. t['SF430000'] = 0x2550;
  14924. t['SF440000'] = 0x256C;
  14925. t['SF450000'] = 0x2567;
  14926. t['SF460000'] = 0x2568;
  14927. t['SF470000'] = 0x2564;
  14928. t['SF480000'] = 0x2565;
  14929. t['SF490000'] = 0x2559;
  14930. t['SF500000'] = 0x2558;
  14931. t['SF510000'] = 0x2552;
  14932. t['SF520000'] = 0x2553;
  14933. t['SF530000'] = 0x256B;
  14934. t['SF540000'] = 0x256A;
  14935. t['Sacute'] = 0x015A;
  14936. t['Sacutedotaccent'] = 0x1E64;
  14937. t['Sampigreek'] = 0x03E0;
  14938. t['Scaron'] = 0x0160;
  14939. t['Scarondotaccent'] = 0x1E66;
  14940. t['Scaronsmall'] = 0xF6FD;
  14941. t['Scedilla'] = 0x015E;
  14942. t['Schwa'] = 0x018F;
  14943. t['Schwacyrillic'] = 0x04D8;
  14944. t['Schwadieresiscyrillic'] = 0x04DA;
  14945. t['Scircle'] = 0x24C8;
  14946. t['Scircumflex'] = 0x015C;
  14947. t['Scommaaccent'] = 0x0218;
  14948. t['Sdotaccent'] = 0x1E60;
  14949. t['Sdotbelow'] = 0x1E62;
  14950. t['Sdotbelowdotaccent'] = 0x1E68;
  14951. t['Seharmenian'] = 0x054D;
  14952. t['Sevenroman'] = 0x2166;
  14953. t['Shaarmenian'] = 0x0547;
  14954. t['Shacyrillic'] = 0x0428;
  14955. t['Shchacyrillic'] = 0x0429;
  14956. t['Sheicoptic'] = 0x03E2;
  14957. t['Shhacyrillic'] = 0x04BA;
  14958. t['Shimacoptic'] = 0x03EC;
  14959. t['Sigma'] = 0x03A3;
  14960. t['Sixroman'] = 0x2165;
  14961. t['Smonospace'] = 0xFF33;
  14962. t['Softsigncyrillic'] = 0x042C;
  14963. t['Ssmall'] = 0xF773;
  14964. t['Stigmagreek'] = 0x03DA;
  14965. t['T'] = 0x0054;
  14966. t['Tau'] = 0x03A4;
  14967. t['Tbar'] = 0x0166;
  14968. t['Tcaron'] = 0x0164;
  14969. t['Tcedilla'] = 0x0162;
  14970. t['Tcircle'] = 0x24C9;
  14971. t['Tcircumflexbelow'] = 0x1E70;
  14972. t['Tcommaaccent'] = 0x0162;
  14973. t['Tdotaccent'] = 0x1E6A;
  14974. t['Tdotbelow'] = 0x1E6C;
  14975. t['Tecyrillic'] = 0x0422;
  14976. t['Tedescendercyrillic'] = 0x04AC;
  14977. t['Tenroman'] = 0x2169;
  14978. t['Tetsecyrillic'] = 0x04B4;
  14979. t['Theta'] = 0x0398;
  14980. t['Thook'] = 0x01AC;
  14981. t['Thorn'] = 0x00DE;
  14982. t['Thornsmall'] = 0xF7FE;
  14983. t['Threeroman'] = 0x2162;
  14984. t['Tildesmall'] = 0xF6FE;
  14985. t['Tiwnarmenian'] = 0x054F;
  14986. t['Tlinebelow'] = 0x1E6E;
  14987. t['Tmonospace'] = 0xFF34;
  14988. t['Toarmenian'] = 0x0539;
  14989. t['Tonefive'] = 0x01BC;
  14990. t['Tonesix'] = 0x0184;
  14991. t['Tonetwo'] = 0x01A7;
  14992. t['Tretroflexhook'] = 0x01AE;
  14993. t['Tsecyrillic'] = 0x0426;
  14994. t['Tshecyrillic'] = 0x040B;
  14995. t['Tsmall'] = 0xF774;
  14996. t['Twelveroman'] = 0x216B;
  14997. t['Tworoman'] = 0x2161;
  14998. t['U'] = 0x0055;
  14999. t['Uacute'] = 0x00DA;
  15000. t['Uacutesmall'] = 0xF7FA;
  15001. t['Ubreve'] = 0x016C;
  15002. t['Ucaron'] = 0x01D3;
  15003. t['Ucircle'] = 0x24CA;
  15004. t['Ucircumflex'] = 0x00DB;
  15005. t['Ucircumflexbelow'] = 0x1E76;
  15006. t['Ucircumflexsmall'] = 0xF7FB;
  15007. t['Ucyrillic'] = 0x0423;
  15008. t['Udblacute'] = 0x0170;
  15009. t['Udblgrave'] = 0x0214;
  15010. t['Udieresis'] = 0x00DC;
  15011. t['Udieresisacute'] = 0x01D7;
  15012. t['Udieresisbelow'] = 0x1E72;
  15013. t['Udieresiscaron'] = 0x01D9;
  15014. t['Udieresiscyrillic'] = 0x04F0;
  15015. t['Udieresisgrave'] = 0x01DB;
  15016. t['Udieresismacron'] = 0x01D5;
  15017. t['Udieresissmall'] = 0xF7FC;
  15018. t['Udotbelow'] = 0x1EE4;
  15019. t['Ugrave'] = 0x00D9;
  15020. t['Ugravesmall'] = 0xF7F9;
  15021. t['Uhookabove'] = 0x1EE6;
  15022. t['Uhorn'] = 0x01AF;
  15023. t['Uhornacute'] = 0x1EE8;
  15024. t['Uhorndotbelow'] = 0x1EF0;
  15025. t['Uhorngrave'] = 0x1EEA;
  15026. t['Uhornhookabove'] = 0x1EEC;
  15027. t['Uhorntilde'] = 0x1EEE;
  15028. t['Uhungarumlaut'] = 0x0170;
  15029. t['Uhungarumlautcyrillic'] = 0x04F2;
  15030. t['Uinvertedbreve'] = 0x0216;
  15031. t['Ukcyrillic'] = 0x0478;
  15032. t['Umacron'] = 0x016A;
  15033. t['Umacroncyrillic'] = 0x04EE;
  15034. t['Umacrondieresis'] = 0x1E7A;
  15035. t['Umonospace'] = 0xFF35;
  15036. t['Uogonek'] = 0x0172;
  15037. t['Upsilon'] = 0x03A5;
  15038. t['Upsilon1'] = 0x03D2;
  15039. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  15040. t['Upsilonafrican'] = 0x01B1;
  15041. t['Upsilondieresis'] = 0x03AB;
  15042. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  15043. t['Upsilonhooksymbol'] = 0x03D2;
  15044. t['Upsilontonos'] = 0x038E;
  15045. t['Uring'] = 0x016E;
  15046. t['Ushortcyrillic'] = 0x040E;
  15047. t['Usmall'] = 0xF775;
  15048. t['Ustraightcyrillic'] = 0x04AE;
  15049. t['Ustraightstrokecyrillic'] = 0x04B0;
  15050. t['Utilde'] = 0x0168;
  15051. t['Utildeacute'] = 0x1E78;
  15052. t['Utildebelow'] = 0x1E74;
  15053. t['V'] = 0x0056;
  15054. t['Vcircle'] = 0x24CB;
  15055. t['Vdotbelow'] = 0x1E7E;
  15056. t['Vecyrillic'] = 0x0412;
  15057. t['Vewarmenian'] = 0x054E;
  15058. t['Vhook'] = 0x01B2;
  15059. t['Vmonospace'] = 0xFF36;
  15060. t['Voarmenian'] = 0x0548;
  15061. t['Vsmall'] = 0xF776;
  15062. t['Vtilde'] = 0x1E7C;
  15063. t['W'] = 0x0057;
  15064. t['Wacute'] = 0x1E82;
  15065. t['Wcircle'] = 0x24CC;
  15066. t['Wcircumflex'] = 0x0174;
  15067. t['Wdieresis'] = 0x1E84;
  15068. t['Wdotaccent'] = 0x1E86;
  15069. t['Wdotbelow'] = 0x1E88;
  15070. t['Wgrave'] = 0x1E80;
  15071. t['Wmonospace'] = 0xFF37;
  15072. t['Wsmall'] = 0xF777;
  15073. t['X'] = 0x0058;
  15074. t['Xcircle'] = 0x24CD;
  15075. t['Xdieresis'] = 0x1E8C;
  15076. t['Xdotaccent'] = 0x1E8A;
  15077. t['Xeharmenian'] = 0x053D;
  15078. t['Xi'] = 0x039E;
  15079. t['Xmonospace'] = 0xFF38;
  15080. t['Xsmall'] = 0xF778;
  15081. t['Y'] = 0x0059;
  15082. t['Yacute'] = 0x00DD;
  15083. t['Yacutesmall'] = 0xF7FD;
  15084. t['Yatcyrillic'] = 0x0462;
  15085. t['Ycircle'] = 0x24CE;
  15086. t['Ycircumflex'] = 0x0176;
  15087. t['Ydieresis'] = 0x0178;
  15088. t['Ydieresissmall'] = 0xF7FF;
  15089. t['Ydotaccent'] = 0x1E8E;
  15090. t['Ydotbelow'] = 0x1EF4;
  15091. t['Yericyrillic'] = 0x042B;
  15092. t['Yerudieresiscyrillic'] = 0x04F8;
  15093. t['Ygrave'] = 0x1EF2;
  15094. t['Yhook'] = 0x01B3;
  15095. t['Yhookabove'] = 0x1EF6;
  15096. t['Yiarmenian'] = 0x0545;
  15097. t['Yicyrillic'] = 0x0407;
  15098. t['Yiwnarmenian'] = 0x0552;
  15099. t['Ymonospace'] = 0xFF39;
  15100. t['Ysmall'] = 0xF779;
  15101. t['Ytilde'] = 0x1EF8;
  15102. t['Yusbigcyrillic'] = 0x046A;
  15103. t['Yusbigiotifiedcyrillic'] = 0x046C;
  15104. t['Yuslittlecyrillic'] = 0x0466;
  15105. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  15106. t['Z'] = 0x005A;
  15107. t['Zaarmenian'] = 0x0536;
  15108. t['Zacute'] = 0x0179;
  15109. t['Zcaron'] = 0x017D;
  15110. t['Zcaronsmall'] = 0xF6FF;
  15111. t['Zcircle'] = 0x24CF;
  15112. t['Zcircumflex'] = 0x1E90;
  15113. t['Zdot'] = 0x017B;
  15114. t['Zdotaccent'] = 0x017B;
  15115. t['Zdotbelow'] = 0x1E92;
  15116. t['Zecyrillic'] = 0x0417;
  15117. t['Zedescendercyrillic'] = 0x0498;
  15118. t['Zedieresiscyrillic'] = 0x04DE;
  15119. t['Zeta'] = 0x0396;
  15120. t['Zhearmenian'] = 0x053A;
  15121. t['Zhebrevecyrillic'] = 0x04C1;
  15122. t['Zhecyrillic'] = 0x0416;
  15123. t['Zhedescendercyrillic'] = 0x0496;
  15124. t['Zhedieresiscyrillic'] = 0x04DC;
  15125. t['Zlinebelow'] = 0x1E94;
  15126. t['Zmonospace'] = 0xFF3A;
  15127. t['Zsmall'] = 0xF77A;
  15128. t['Zstroke'] = 0x01B5;
  15129. t['a'] = 0x0061;
  15130. t['aabengali'] = 0x0986;
  15131. t['aacute'] = 0x00E1;
  15132. t['aadeva'] = 0x0906;
  15133. t['aagujarati'] = 0x0A86;
  15134. t['aagurmukhi'] = 0x0A06;
  15135. t['aamatragurmukhi'] = 0x0A3E;
  15136. t['aarusquare'] = 0x3303;
  15137. t['aavowelsignbengali'] = 0x09BE;
  15138. t['aavowelsigndeva'] = 0x093E;
  15139. t['aavowelsigngujarati'] = 0x0ABE;
  15140. t['abbreviationmarkarmenian'] = 0x055F;
  15141. t['abbreviationsigndeva'] = 0x0970;
  15142. t['abengali'] = 0x0985;
  15143. t['abopomofo'] = 0x311A;
  15144. t['abreve'] = 0x0103;
  15145. t['abreveacute'] = 0x1EAF;
  15146. t['abrevecyrillic'] = 0x04D1;
  15147. t['abrevedotbelow'] = 0x1EB7;
  15148. t['abrevegrave'] = 0x1EB1;
  15149. t['abrevehookabove'] = 0x1EB3;
  15150. t['abrevetilde'] = 0x1EB5;
  15151. t['acaron'] = 0x01CE;
  15152. t['acircle'] = 0x24D0;
  15153. t['acircumflex'] = 0x00E2;
  15154. t['acircumflexacute'] = 0x1EA5;
  15155. t['acircumflexdotbelow'] = 0x1EAD;
  15156. t['acircumflexgrave'] = 0x1EA7;
  15157. t['acircumflexhookabove'] = 0x1EA9;
  15158. t['acircumflextilde'] = 0x1EAB;
  15159. t['acute'] = 0x00B4;
  15160. t['acutebelowcmb'] = 0x0317;
  15161. t['acutecmb'] = 0x0301;
  15162. t['acutecomb'] = 0x0301;
  15163. t['acutedeva'] = 0x0954;
  15164. t['acutelowmod'] = 0x02CF;
  15165. t['acutetonecmb'] = 0x0341;
  15166. t['acyrillic'] = 0x0430;
  15167. t['adblgrave'] = 0x0201;
  15168. t['addakgurmukhi'] = 0x0A71;
  15169. t['adeva'] = 0x0905;
  15170. t['adieresis'] = 0x00E4;
  15171. t['adieresiscyrillic'] = 0x04D3;
  15172. t['adieresismacron'] = 0x01DF;
  15173. t['adotbelow'] = 0x1EA1;
  15174. t['adotmacron'] = 0x01E1;
  15175. t['ae'] = 0x00E6;
  15176. t['aeacute'] = 0x01FD;
  15177. t['aekorean'] = 0x3150;
  15178. t['aemacron'] = 0x01E3;
  15179. t['afii00208'] = 0x2015;
  15180. t['afii08941'] = 0x20A4;
  15181. t['afii10017'] = 0x0410;
  15182. t['afii10018'] = 0x0411;
  15183. t['afii10019'] = 0x0412;
  15184. t['afii10020'] = 0x0413;
  15185. t['afii10021'] = 0x0414;
  15186. t['afii10022'] = 0x0415;
  15187. t['afii10023'] = 0x0401;
  15188. t['afii10024'] = 0x0416;
  15189. t['afii10025'] = 0x0417;
  15190. t['afii10026'] = 0x0418;
  15191. t['afii10027'] = 0x0419;
  15192. t['afii10028'] = 0x041A;
  15193. t['afii10029'] = 0x041B;
  15194. t['afii10030'] = 0x041C;
  15195. t['afii10031'] = 0x041D;
  15196. t['afii10032'] = 0x041E;
  15197. t['afii10033'] = 0x041F;
  15198. t['afii10034'] = 0x0420;
  15199. t['afii10035'] = 0x0421;
  15200. t['afii10036'] = 0x0422;
  15201. t['afii10037'] = 0x0423;
  15202. t['afii10038'] = 0x0424;
  15203. t['afii10039'] = 0x0425;
  15204. t['afii10040'] = 0x0426;
  15205. t['afii10041'] = 0x0427;
  15206. t['afii10042'] = 0x0428;
  15207. t['afii10043'] = 0x0429;
  15208. t['afii10044'] = 0x042A;
  15209. t['afii10045'] = 0x042B;
  15210. t['afii10046'] = 0x042C;
  15211. t['afii10047'] = 0x042D;
  15212. t['afii10048'] = 0x042E;
  15213. t['afii10049'] = 0x042F;
  15214. t['afii10050'] = 0x0490;
  15215. t['afii10051'] = 0x0402;
  15216. t['afii10052'] = 0x0403;
  15217. t['afii10053'] = 0x0404;
  15218. t['afii10054'] = 0x0405;
  15219. t['afii10055'] = 0x0406;
  15220. t['afii10056'] = 0x0407;
  15221. t['afii10057'] = 0x0408;
  15222. t['afii10058'] = 0x0409;
  15223. t['afii10059'] = 0x040A;
  15224. t['afii10060'] = 0x040B;
  15225. t['afii10061'] = 0x040C;
  15226. t['afii10062'] = 0x040E;
  15227. t['afii10063'] = 0xF6C4;
  15228. t['afii10064'] = 0xF6C5;
  15229. t['afii10065'] = 0x0430;
  15230. t['afii10066'] = 0x0431;
  15231. t['afii10067'] = 0x0432;
  15232. t['afii10068'] = 0x0433;
  15233. t['afii10069'] = 0x0434;
  15234. t['afii10070'] = 0x0435;
  15235. t['afii10071'] = 0x0451;
  15236. t['afii10072'] = 0x0436;
  15237. t['afii10073'] = 0x0437;
  15238. t['afii10074'] = 0x0438;
  15239. t['afii10075'] = 0x0439;
  15240. t['afii10076'] = 0x043A;
  15241. t['afii10077'] = 0x043B;
  15242. t['afii10078'] = 0x043C;
  15243. t['afii10079'] = 0x043D;
  15244. t['afii10080'] = 0x043E;
  15245. t['afii10081'] = 0x043F;
  15246. t['afii10082'] = 0x0440;
  15247. t['afii10083'] = 0x0441;
  15248. t['afii10084'] = 0x0442;
  15249. t['afii10085'] = 0x0443;
  15250. t['afii10086'] = 0x0444;
  15251. t['afii10087'] = 0x0445;
  15252. t['afii10088'] = 0x0446;
  15253. t['afii10089'] = 0x0447;
  15254. t['afii10090'] = 0x0448;
  15255. t['afii10091'] = 0x0449;
  15256. t['afii10092'] = 0x044A;
  15257. t['afii10093'] = 0x044B;
  15258. t['afii10094'] = 0x044C;
  15259. t['afii10095'] = 0x044D;
  15260. t['afii10096'] = 0x044E;
  15261. t['afii10097'] = 0x044F;
  15262. t['afii10098'] = 0x0491;
  15263. t['afii10099'] = 0x0452;
  15264. t['afii10100'] = 0x0453;
  15265. t['afii10101'] = 0x0454;
  15266. t['afii10102'] = 0x0455;
  15267. t['afii10103'] = 0x0456;
  15268. t['afii10104'] = 0x0457;
  15269. t['afii10105'] = 0x0458;
  15270. t['afii10106'] = 0x0459;
  15271. t['afii10107'] = 0x045A;
  15272. t['afii10108'] = 0x045B;
  15273. t['afii10109'] = 0x045C;
  15274. t['afii10110'] = 0x045E;
  15275. t['afii10145'] = 0x040F;
  15276. t['afii10146'] = 0x0462;
  15277. t['afii10147'] = 0x0472;
  15278. t['afii10148'] = 0x0474;
  15279. t['afii10192'] = 0xF6C6;
  15280. t['afii10193'] = 0x045F;
  15281. t['afii10194'] = 0x0463;
  15282. t['afii10195'] = 0x0473;
  15283. t['afii10196'] = 0x0475;
  15284. t['afii10831'] = 0xF6C7;
  15285. t['afii10832'] = 0xF6C8;
  15286. t['afii10846'] = 0x04D9;
  15287. t['afii299'] = 0x200E;
  15288. t['afii300'] = 0x200F;
  15289. t['afii301'] = 0x200D;
  15290. t['afii57381'] = 0x066A;
  15291. t['afii57388'] = 0x060C;
  15292. t['afii57392'] = 0x0660;
  15293. t['afii57393'] = 0x0661;
  15294. t['afii57394'] = 0x0662;
  15295. t['afii57395'] = 0x0663;
  15296. t['afii57396'] = 0x0664;
  15297. t['afii57397'] = 0x0665;
  15298. t['afii57398'] = 0x0666;
  15299. t['afii57399'] = 0x0667;
  15300. t['afii57400'] = 0x0668;
  15301. t['afii57401'] = 0x0669;
  15302. t['afii57403'] = 0x061B;
  15303. t['afii57407'] = 0x061F;
  15304. t['afii57409'] = 0x0621;
  15305. t['afii57410'] = 0x0622;
  15306. t['afii57411'] = 0x0623;
  15307. t['afii57412'] = 0x0624;
  15308. t['afii57413'] = 0x0625;
  15309. t['afii57414'] = 0x0626;
  15310. t['afii57415'] = 0x0627;
  15311. t['afii57416'] = 0x0628;
  15312. t['afii57417'] = 0x0629;
  15313. t['afii57418'] = 0x062A;
  15314. t['afii57419'] = 0x062B;
  15315. t['afii57420'] = 0x062C;
  15316. t['afii57421'] = 0x062D;
  15317. t['afii57422'] = 0x062E;
  15318. t['afii57423'] = 0x062F;
  15319. t['afii57424'] = 0x0630;
  15320. t['afii57425'] = 0x0631;
  15321. t['afii57426'] = 0x0632;
  15322. t['afii57427'] = 0x0633;
  15323. t['afii57428'] = 0x0634;
  15324. t['afii57429'] = 0x0635;
  15325. t['afii57430'] = 0x0636;
  15326. t['afii57431'] = 0x0637;
  15327. t['afii57432'] = 0x0638;
  15328. t['afii57433'] = 0x0639;
  15329. t['afii57434'] = 0x063A;
  15330. t['afii57440'] = 0x0640;
  15331. t['afii57441'] = 0x0641;
  15332. t['afii57442'] = 0x0642;
  15333. t['afii57443'] = 0x0643;
  15334. t['afii57444'] = 0x0644;
  15335. t['afii57445'] = 0x0645;
  15336. t['afii57446'] = 0x0646;
  15337. t['afii57448'] = 0x0648;
  15338. t['afii57449'] = 0x0649;
  15339. t['afii57450'] = 0x064A;
  15340. t['afii57451'] = 0x064B;
  15341. t['afii57452'] = 0x064C;
  15342. t['afii57453'] = 0x064D;
  15343. t['afii57454'] = 0x064E;
  15344. t['afii57455'] = 0x064F;
  15345. t['afii57456'] = 0x0650;
  15346. t['afii57457'] = 0x0651;
  15347. t['afii57458'] = 0x0652;
  15348. t['afii57470'] = 0x0647;
  15349. t['afii57505'] = 0x06A4;
  15350. t['afii57506'] = 0x067E;
  15351. t['afii57507'] = 0x0686;
  15352. t['afii57508'] = 0x0698;
  15353. t['afii57509'] = 0x06AF;
  15354. t['afii57511'] = 0x0679;
  15355. t['afii57512'] = 0x0688;
  15356. t['afii57513'] = 0x0691;
  15357. t['afii57514'] = 0x06BA;
  15358. t['afii57519'] = 0x06D2;
  15359. t['afii57534'] = 0x06D5;
  15360. t['afii57636'] = 0x20AA;
  15361. t['afii57645'] = 0x05BE;
  15362. t['afii57658'] = 0x05C3;
  15363. t['afii57664'] = 0x05D0;
  15364. t['afii57665'] = 0x05D1;
  15365. t['afii57666'] = 0x05D2;
  15366. t['afii57667'] = 0x05D3;
  15367. t['afii57668'] = 0x05D4;
  15368. t['afii57669'] = 0x05D5;
  15369. t['afii57670'] = 0x05D6;
  15370. t['afii57671'] = 0x05D7;
  15371. t['afii57672'] = 0x05D8;
  15372. t['afii57673'] = 0x05D9;
  15373. t['afii57674'] = 0x05DA;
  15374. t['afii57675'] = 0x05DB;
  15375. t['afii57676'] = 0x05DC;
  15376. t['afii57677'] = 0x05DD;
  15377. t['afii57678'] = 0x05DE;
  15378. t['afii57679'] = 0x05DF;
  15379. t['afii57680'] = 0x05E0;
  15380. t['afii57681'] = 0x05E1;
  15381. t['afii57682'] = 0x05E2;
  15382. t['afii57683'] = 0x05E3;
  15383. t['afii57684'] = 0x05E4;
  15384. t['afii57685'] = 0x05E5;
  15385. t['afii57686'] = 0x05E6;
  15386. t['afii57687'] = 0x05E7;
  15387. t['afii57688'] = 0x05E8;
  15388. t['afii57689'] = 0x05E9;
  15389. t['afii57690'] = 0x05EA;
  15390. t['afii57694'] = 0xFB2A;
  15391. t['afii57695'] = 0xFB2B;
  15392. t['afii57700'] = 0xFB4B;
  15393. t['afii57705'] = 0xFB1F;
  15394. t['afii57716'] = 0x05F0;
  15395. t['afii57717'] = 0x05F1;
  15396. t['afii57718'] = 0x05F2;
  15397. t['afii57723'] = 0xFB35;
  15398. t['afii57793'] = 0x05B4;
  15399. t['afii57794'] = 0x05B5;
  15400. t['afii57795'] = 0x05B6;
  15401. t['afii57796'] = 0x05BB;
  15402. t['afii57797'] = 0x05B8;
  15403. t['afii57798'] = 0x05B7;
  15404. t['afii57799'] = 0x05B0;
  15405. t['afii57800'] = 0x05B2;
  15406. t['afii57801'] = 0x05B1;
  15407. t['afii57802'] = 0x05B3;
  15408. t['afii57803'] = 0x05C2;
  15409. t['afii57804'] = 0x05C1;
  15410. t['afii57806'] = 0x05B9;
  15411. t['afii57807'] = 0x05BC;
  15412. t['afii57839'] = 0x05BD;
  15413. t['afii57841'] = 0x05BF;
  15414. t['afii57842'] = 0x05C0;
  15415. t['afii57929'] = 0x02BC;
  15416. t['afii61248'] = 0x2105;
  15417. t['afii61289'] = 0x2113;
  15418. t['afii61352'] = 0x2116;
  15419. t['afii61573'] = 0x202C;
  15420. t['afii61574'] = 0x202D;
  15421. t['afii61575'] = 0x202E;
  15422. t['afii61664'] = 0x200C;
  15423. t['afii63167'] = 0x066D;
  15424. t['afii64937'] = 0x02BD;
  15425. t['agrave'] = 0x00E0;
  15426. t['agujarati'] = 0x0A85;
  15427. t['agurmukhi'] = 0x0A05;
  15428. t['ahiragana'] = 0x3042;
  15429. t['ahookabove'] = 0x1EA3;
  15430. t['aibengali'] = 0x0990;
  15431. t['aibopomofo'] = 0x311E;
  15432. t['aideva'] = 0x0910;
  15433. t['aiecyrillic'] = 0x04D5;
  15434. t['aigujarati'] = 0x0A90;
  15435. t['aigurmukhi'] = 0x0A10;
  15436. t['aimatragurmukhi'] = 0x0A48;
  15437. t['ainarabic'] = 0x0639;
  15438. t['ainfinalarabic'] = 0xFECA;
  15439. t['aininitialarabic'] = 0xFECB;
  15440. t['ainmedialarabic'] = 0xFECC;
  15441. t['ainvertedbreve'] = 0x0203;
  15442. t['aivowelsignbengali'] = 0x09C8;
  15443. t['aivowelsigndeva'] = 0x0948;
  15444. t['aivowelsigngujarati'] = 0x0AC8;
  15445. t['akatakana'] = 0x30A2;
  15446. t['akatakanahalfwidth'] = 0xFF71;
  15447. t['akorean'] = 0x314F;
  15448. t['alef'] = 0x05D0;
  15449. t['alefarabic'] = 0x0627;
  15450. t['alefdageshhebrew'] = 0xFB30;
  15451. t['aleffinalarabic'] = 0xFE8E;
  15452. t['alefhamzaabovearabic'] = 0x0623;
  15453. t['alefhamzaabovefinalarabic'] = 0xFE84;
  15454. t['alefhamzabelowarabic'] = 0x0625;
  15455. t['alefhamzabelowfinalarabic'] = 0xFE88;
  15456. t['alefhebrew'] = 0x05D0;
  15457. t['aleflamedhebrew'] = 0xFB4F;
  15458. t['alefmaddaabovearabic'] = 0x0622;
  15459. t['alefmaddaabovefinalarabic'] = 0xFE82;
  15460. t['alefmaksuraarabic'] = 0x0649;
  15461. t['alefmaksurafinalarabic'] = 0xFEF0;
  15462. t['alefmaksurainitialarabic'] = 0xFEF3;
  15463. t['alefmaksuramedialarabic'] = 0xFEF4;
  15464. t['alefpatahhebrew'] = 0xFB2E;
  15465. t['alefqamatshebrew'] = 0xFB2F;
  15466. t['aleph'] = 0x2135;
  15467. t['allequal'] = 0x224C;
  15468. t['alpha'] = 0x03B1;
  15469. t['alphatonos'] = 0x03AC;
  15470. t['amacron'] = 0x0101;
  15471. t['amonospace'] = 0xFF41;
  15472. t['ampersand'] = 0x0026;
  15473. t['ampersandmonospace'] = 0xFF06;
  15474. t['ampersandsmall'] = 0xF726;
  15475. t['amsquare'] = 0x33C2;
  15476. t['anbopomofo'] = 0x3122;
  15477. t['angbopomofo'] = 0x3124;
  15478. t['angbracketleft'] = 0x3008;
  15479. t['angbracketright'] = 0x3009;
  15480. t['angkhankhuthai'] = 0x0E5A;
  15481. t['angle'] = 0x2220;
  15482. t['anglebracketleft'] = 0x3008;
  15483. t['anglebracketleftvertical'] = 0xFE3F;
  15484. t['anglebracketright'] = 0x3009;
  15485. t['anglebracketrightvertical'] = 0xFE40;
  15486. t['angleleft'] = 0x2329;
  15487. t['angleright'] = 0x232A;
  15488. t['angstrom'] = 0x212B;
  15489. t['anoteleia'] = 0x0387;
  15490. t['anudattadeva'] = 0x0952;
  15491. t['anusvarabengali'] = 0x0982;
  15492. t['anusvaradeva'] = 0x0902;
  15493. t['anusvaragujarati'] = 0x0A82;
  15494. t['aogonek'] = 0x0105;
  15495. t['apaatosquare'] = 0x3300;
  15496. t['aparen'] = 0x249C;
  15497. t['apostrophearmenian'] = 0x055A;
  15498. t['apostrophemod'] = 0x02BC;
  15499. t['apple'] = 0xF8FF;
  15500. t['approaches'] = 0x2250;
  15501. t['approxequal'] = 0x2248;
  15502. t['approxequalorimage'] = 0x2252;
  15503. t['approximatelyequal'] = 0x2245;
  15504. t['araeaekorean'] = 0x318E;
  15505. t['araeakorean'] = 0x318D;
  15506. t['arc'] = 0x2312;
  15507. t['arighthalfring'] = 0x1E9A;
  15508. t['aring'] = 0x00E5;
  15509. t['aringacute'] = 0x01FB;
  15510. t['aringbelow'] = 0x1E01;
  15511. t['arrowboth'] = 0x2194;
  15512. t['arrowdashdown'] = 0x21E3;
  15513. t['arrowdashleft'] = 0x21E0;
  15514. t['arrowdashright'] = 0x21E2;
  15515. t['arrowdashup'] = 0x21E1;
  15516. t['arrowdblboth'] = 0x21D4;
  15517. t['arrowdbldown'] = 0x21D3;
  15518. t['arrowdblleft'] = 0x21D0;
  15519. t['arrowdblright'] = 0x21D2;
  15520. t['arrowdblup'] = 0x21D1;
  15521. t['arrowdown'] = 0x2193;
  15522. t['arrowdownleft'] = 0x2199;
  15523. t['arrowdownright'] = 0x2198;
  15524. t['arrowdownwhite'] = 0x21E9;
  15525. t['arrowheaddownmod'] = 0x02C5;
  15526. t['arrowheadleftmod'] = 0x02C2;
  15527. t['arrowheadrightmod'] = 0x02C3;
  15528. t['arrowheadupmod'] = 0x02C4;
  15529. t['arrowhorizex'] = 0xF8E7;
  15530. t['arrowleft'] = 0x2190;
  15531. t['arrowleftdbl'] = 0x21D0;
  15532. t['arrowleftdblstroke'] = 0x21CD;
  15533. t['arrowleftoverright'] = 0x21C6;
  15534. t['arrowleftwhite'] = 0x21E6;
  15535. t['arrowright'] = 0x2192;
  15536. t['arrowrightdblstroke'] = 0x21CF;
  15537. t['arrowrightheavy'] = 0x279E;
  15538. t['arrowrightoverleft'] = 0x21C4;
  15539. t['arrowrightwhite'] = 0x21E8;
  15540. t['arrowtableft'] = 0x21E4;
  15541. t['arrowtabright'] = 0x21E5;
  15542. t['arrowup'] = 0x2191;
  15543. t['arrowupdn'] = 0x2195;
  15544. t['arrowupdnbse'] = 0x21A8;
  15545. t['arrowupdownbase'] = 0x21A8;
  15546. t['arrowupleft'] = 0x2196;
  15547. t['arrowupleftofdown'] = 0x21C5;
  15548. t['arrowupright'] = 0x2197;
  15549. t['arrowupwhite'] = 0x21E7;
  15550. t['arrowvertex'] = 0xF8E6;
  15551. t['asciicircum'] = 0x005E;
  15552. t['asciicircummonospace'] = 0xFF3E;
  15553. t['asciitilde'] = 0x007E;
  15554. t['asciitildemonospace'] = 0xFF5E;
  15555. t['ascript'] = 0x0251;
  15556. t['ascriptturned'] = 0x0252;
  15557. t['asmallhiragana'] = 0x3041;
  15558. t['asmallkatakana'] = 0x30A1;
  15559. t['asmallkatakanahalfwidth'] = 0xFF67;
  15560. t['asterisk'] = 0x002A;
  15561. t['asteriskaltonearabic'] = 0x066D;
  15562. t['asteriskarabic'] = 0x066D;
  15563. t['asteriskmath'] = 0x2217;
  15564. t['asteriskmonospace'] = 0xFF0A;
  15565. t['asterisksmall'] = 0xFE61;
  15566. t['asterism'] = 0x2042;
  15567. t['asuperior'] = 0xF6E9;
  15568. t['asymptoticallyequal'] = 0x2243;
  15569. t['at'] = 0x0040;
  15570. t['atilde'] = 0x00E3;
  15571. t['atmonospace'] = 0xFF20;
  15572. t['atsmall'] = 0xFE6B;
  15573. t['aturned'] = 0x0250;
  15574. t['aubengali'] = 0x0994;
  15575. t['aubopomofo'] = 0x3120;
  15576. t['audeva'] = 0x0914;
  15577. t['augujarati'] = 0x0A94;
  15578. t['augurmukhi'] = 0x0A14;
  15579. t['aulengthmarkbengali'] = 0x09D7;
  15580. t['aumatragurmukhi'] = 0x0A4C;
  15581. t['auvowelsignbengali'] = 0x09CC;
  15582. t['auvowelsigndeva'] = 0x094C;
  15583. t['auvowelsigngujarati'] = 0x0ACC;
  15584. t['avagrahadeva'] = 0x093D;
  15585. t['aybarmenian'] = 0x0561;
  15586. t['ayin'] = 0x05E2;
  15587. t['ayinaltonehebrew'] = 0xFB20;
  15588. t['ayinhebrew'] = 0x05E2;
  15589. t['b'] = 0x0062;
  15590. t['babengali'] = 0x09AC;
  15591. t['backslash'] = 0x005C;
  15592. t['backslashmonospace'] = 0xFF3C;
  15593. t['badeva'] = 0x092C;
  15594. t['bagujarati'] = 0x0AAC;
  15595. t['bagurmukhi'] = 0x0A2C;
  15596. t['bahiragana'] = 0x3070;
  15597. t['bahtthai'] = 0x0E3F;
  15598. t['bakatakana'] = 0x30D0;
  15599. t['bar'] = 0x007C;
  15600. t['barmonospace'] = 0xFF5C;
  15601. t['bbopomofo'] = 0x3105;
  15602. t['bcircle'] = 0x24D1;
  15603. t['bdotaccent'] = 0x1E03;
  15604. t['bdotbelow'] = 0x1E05;
  15605. t['beamedsixteenthnotes'] = 0x266C;
  15606. t['because'] = 0x2235;
  15607. t['becyrillic'] = 0x0431;
  15608. t['beharabic'] = 0x0628;
  15609. t['behfinalarabic'] = 0xFE90;
  15610. t['behinitialarabic'] = 0xFE91;
  15611. t['behiragana'] = 0x3079;
  15612. t['behmedialarabic'] = 0xFE92;
  15613. t['behmeeminitialarabic'] = 0xFC9F;
  15614. t['behmeemisolatedarabic'] = 0xFC08;
  15615. t['behnoonfinalarabic'] = 0xFC6D;
  15616. t['bekatakana'] = 0x30D9;
  15617. t['benarmenian'] = 0x0562;
  15618. t['bet'] = 0x05D1;
  15619. t['beta'] = 0x03B2;
  15620. t['betasymbolgreek'] = 0x03D0;
  15621. t['betdagesh'] = 0xFB31;
  15622. t['betdageshhebrew'] = 0xFB31;
  15623. t['bethebrew'] = 0x05D1;
  15624. t['betrafehebrew'] = 0xFB4C;
  15625. t['bhabengali'] = 0x09AD;
  15626. t['bhadeva'] = 0x092D;
  15627. t['bhagujarati'] = 0x0AAD;
  15628. t['bhagurmukhi'] = 0x0A2D;
  15629. t['bhook'] = 0x0253;
  15630. t['bihiragana'] = 0x3073;
  15631. t['bikatakana'] = 0x30D3;
  15632. t['bilabialclick'] = 0x0298;
  15633. t['bindigurmukhi'] = 0x0A02;
  15634. t['birusquare'] = 0x3331;
  15635. t['blackcircle'] = 0x25CF;
  15636. t['blackdiamond'] = 0x25C6;
  15637. t['blackdownpointingtriangle'] = 0x25BC;
  15638. t['blackleftpointingpointer'] = 0x25C4;
  15639. t['blackleftpointingtriangle'] = 0x25C0;
  15640. t['blacklenticularbracketleft'] = 0x3010;
  15641. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  15642. t['blacklenticularbracketright'] = 0x3011;
  15643. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  15644. t['blacklowerlefttriangle'] = 0x25E3;
  15645. t['blacklowerrighttriangle'] = 0x25E2;
  15646. t['blackrectangle'] = 0x25AC;
  15647. t['blackrightpointingpointer'] = 0x25BA;
  15648. t['blackrightpointingtriangle'] = 0x25B6;
  15649. t['blacksmallsquare'] = 0x25AA;
  15650. t['blacksmilingface'] = 0x263B;
  15651. t['blacksquare'] = 0x25A0;
  15652. t['blackstar'] = 0x2605;
  15653. t['blackupperlefttriangle'] = 0x25E4;
  15654. t['blackupperrighttriangle'] = 0x25E5;
  15655. t['blackuppointingsmalltriangle'] = 0x25B4;
  15656. t['blackuppointingtriangle'] = 0x25B2;
  15657. t['blank'] = 0x2423;
  15658. t['blinebelow'] = 0x1E07;
  15659. t['block'] = 0x2588;
  15660. t['bmonospace'] = 0xFF42;
  15661. t['bobaimaithai'] = 0x0E1A;
  15662. t['bohiragana'] = 0x307C;
  15663. t['bokatakana'] = 0x30DC;
  15664. t['bparen'] = 0x249D;
  15665. t['bqsquare'] = 0x33C3;
  15666. t['braceex'] = 0xF8F4;
  15667. t['braceleft'] = 0x007B;
  15668. t['braceleftbt'] = 0xF8F3;
  15669. t['braceleftmid'] = 0xF8F2;
  15670. t['braceleftmonospace'] = 0xFF5B;
  15671. t['braceleftsmall'] = 0xFE5B;
  15672. t['bracelefttp'] = 0xF8F1;
  15673. t['braceleftvertical'] = 0xFE37;
  15674. t['braceright'] = 0x007D;
  15675. t['bracerightbt'] = 0xF8FE;
  15676. t['bracerightmid'] = 0xF8FD;
  15677. t['bracerightmonospace'] = 0xFF5D;
  15678. t['bracerightsmall'] = 0xFE5C;
  15679. t['bracerighttp'] = 0xF8FC;
  15680. t['bracerightvertical'] = 0xFE38;
  15681. t['bracketleft'] = 0x005B;
  15682. t['bracketleftbt'] = 0xF8F0;
  15683. t['bracketleftex'] = 0xF8EF;
  15684. t['bracketleftmonospace'] = 0xFF3B;
  15685. t['bracketlefttp'] = 0xF8EE;
  15686. t['bracketright'] = 0x005D;
  15687. t['bracketrightbt'] = 0xF8FB;
  15688. t['bracketrightex'] = 0xF8FA;
  15689. t['bracketrightmonospace'] = 0xFF3D;
  15690. t['bracketrighttp'] = 0xF8F9;
  15691. t['breve'] = 0x02D8;
  15692. t['brevebelowcmb'] = 0x032E;
  15693. t['brevecmb'] = 0x0306;
  15694. t['breveinvertedbelowcmb'] = 0x032F;
  15695. t['breveinvertedcmb'] = 0x0311;
  15696. t['breveinverteddoublecmb'] = 0x0361;
  15697. t['bridgebelowcmb'] = 0x032A;
  15698. t['bridgeinvertedbelowcmb'] = 0x033A;
  15699. t['brokenbar'] = 0x00A6;
  15700. t['bstroke'] = 0x0180;
  15701. t['bsuperior'] = 0xF6EA;
  15702. t['btopbar'] = 0x0183;
  15703. t['buhiragana'] = 0x3076;
  15704. t['bukatakana'] = 0x30D6;
  15705. t['bullet'] = 0x2022;
  15706. t['bulletinverse'] = 0x25D8;
  15707. t['bulletoperator'] = 0x2219;
  15708. t['bullseye'] = 0x25CE;
  15709. t['c'] = 0x0063;
  15710. t['caarmenian'] = 0x056E;
  15711. t['cabengali'] = 0x099A;
  15712. t['cacute'] = 0x0107;
  15713. t['cadeva'] = 0x091A;
  15714. t['cagujarati'] = 0x0A9A;
  15715. t['cagurmukhi'] = 0x0A1A;
  15716. t['calsquare'] = 0x3388;
  15717. t['candrabindubengali'] = 0x0981;
  15718. t['candrabinducmb'] = 0x0310;
  15719. t['candrabindudeva'] = 0x0901;
  15720. t['candrabindugujarati'] = 0x0A81;
  15721. t['capslock'] = 0x21EA;
  15722. t['careof'] = 0x2105;
  15723. t['caron'] = 0x02C7;
  15724. t['caronbelowcmb'] = 0x032C;
  15725. t['caroncmb'] = 0x030C;
  15726. t['carriagereturn'] = 0x21B5;
  15727. t['cbopomofo'] = 0x3118;
  15728. t['ccaron'] = 0x010D;
  15729. t['ccedilla'] = 0x00E7;
  15730. t['ccedillaacute'] = 0x1E09;
  15731. t['ccircle'] = 0x24D2;
  15732. t['ccircumflex'] = 0x0109;
  15733. t['ccurl'] = 0x0255;
  15734. t['cdot'] = 0x010B;
  15735. t['cdotaccent'] = 0x010B;
  15736. t['cdsquare'] = 0x33C5;
  15737. t['cedilla'] = 0x00B8;
  15738. t['cedillacmb'] = 0x0327;
  15739. t['cent'] = 0x00A2;
  15740. t['centigrade'] = 0x2103;
  15741. t['centinferior'] = 0xF6DF;
  15742. t['centmonospace'] = 0xFFE0;
  15743. t['centoldstyle'] = 0xF7A2;
  15744. t['centsuperior'] = 0xF6E0;
  15745. t['chaarmenian'] = 0x0579;
  15746. t['chabengali'] = 0x099B;
  15747. t['chadeva'] = 0x091B;
  15748. t['chagujarati'] = 0x0A9B;
  15749. t['chagurmukhi'] = 0x0A1B;
  15750. t['chbopomofo'] = 0x3114;
  15751. t['cheabkhasiancyrillic'] = 0x04BD;
  15752. t['checkmark'] = 0x2713;
  15753. t['checyrillic'] = 0x0447;
  15754. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  15755. t['chedescendercyrillic'] = 0x04B7;
  15756. t['chedieresiscyrillic'] = 0x04F5;
  15757. t['cheharmenian'] = 0x0573;
  15758. t['chekhakassiancyrillic'] = 0x04CC;
  15759. t['cheverticalstrokecyrillic'] = 0x04B9;
  15760. t['chi'] = 0x03C7;
  15761. t['chieuchacirclekorean'] = 0x3277;
  15762. t['chieuchaparenkorean'] = 0x3217;
  15763. t['chieuchcirclekorean'] = 0x3269;
  15764. t['chieuchkorean'] = 0x314A;
  15765. t['chieuchparenkorean'] = 0x3209;
  15766. t['chochangthai'] = 0x0E0A;
  15767. t['chochanthai'] = 0x0E08;
  15768. t['chochingthai'] = 0x0E09;
  15769. t['chochoethai'] = 0x0E0C;
  15770. t['chook'] = 0x0188;
  15771. t['cieucacirclekorean'] = 0x3276;
  15772. t['cieucaparenkorean'] = 0x3216;
  15773. t['cieuccirclekorean'] = 0x3268;
  15774. t['cieuckorean'] = 0x3148;
  15775. t['cieucparenkorean'] = 0x3208;
  15776. t['cieucuparenkorean'] = 0x321C;
  15777. t['circle'] = 0x25CB;
  15778. t['circlecopyrt'] = 0x00A9;
  15779. t['circlemultiply'] = 0x2297;
  15780. t['circleot'] = 0x2299;
  15781. t['circleplus'] = 0x2295;
  15782. t['circlepostalmark'] = 0x3036;
  15783. t['circlewithlefthalfblack'] = 0x25D0;
  15784. t['circlewithrighthalfblack'] = 0x25D1;
  15785. t['circumflex'] = 0x02C6;
  15786. t['circumflexbelowcmb'] = 0x032D;
  15787. t['circumflexcmb'] = 0x0302;
  15788. t['clear'] = 0x2327;
  15789. t['clickalveolar'] = 0x01C2;
  15790. t['clickdental'] = 0x01C0;
  15791. t['clicklateral'] = 0x01C1;
  15792. t['clickretroflex'] = 0x01C3;
  15793. t['club'] = 0x2663;
  15794. t['clubsuitblack'] = 0x2663;
  15795. t['clubsuitwhite'] = 0x2667;
  15796. t['cmcubedsquare'] = 0x33A4;
  15797. t['cmonospace'] = 0xFF43;
  15798. t['cmsquaredsquare'] = 0x33A0;
  15799. t['coarmenian'] = 0x0581;
  15800. t['colon'] = 0x003A;
  15801. t['colonmonetary'] = 0x20A1;
  15802. t['colonmonospace'] = 0xFF1A;
  15803. t['colonsign'] = 0x20A1;
  15804. t['colonsmall'] = 0xFE55;
  15805. t['colontriangularhalfmod'] = 0x02D1;
  15806. t['colontriangularmod'] = 0x02D0;
  15807. t['comma'] = 0x002C;
  15808. t['commaabovecmb'] = 0x0313;
  15809. t['commaaboverightcmb'] = 0x0315;
  15810. t['commaaccent'] = 0xF6C3;
  15811. t['commaarabic'] = 0x060C;
  15812. t['commaarmenian'] = 0x055D;
  15813. t['commainferior'] = 0xF6E1;
  15814. t['commamonospace'] = 0xFF0C;
  15815. t['commareversedabovecmb'] = 0x0314;
  15816. t['commareversedmod'] = 0x02BD;
  15817. t['commasmall'] = 0xFE50;
  15818. t['commasuperior'] = 0xF6E2;
  15819. t['commaturnedabovecmb'] = 0x0312;
  15820. t['commaturnedmod'] = 0x02BB;
  15821. t['compass'] = 0x263C;
  15822. t['congruent'] = 0x2245;
  15823. t['contourintegral'] = 0x222E;
  15824. t['control'] = 0x2303;
  15825. t['controlACK'] = 0x0006;
  15826. t['controlBEL'] = 0x0007;
  15827. t['controlBS'] = 0x0008;
  15828. t['controlCAN'] = 0x0018;
  15829. t['controlCR'] = 0x000D;
  15830. t['controlDC1'] = 0x0011;
  15831. t['controlDC2'] = 0x0012;
  15832. t['controlDC3'] = 0x0013;
  15833. t['controlDC4'] = 0x0014;
  15834. t['controlDEL'] = 0x007F;
  15835. t['controlDLE'] = 0x0010;
  15836. t['controlEM'] = 0x0019;
  15837. t['controlENQ'] = 0x0005;
  15838. t['controlEOT'] = 0x0004;
  15839. t['controlESC'] = 0x001B;
  15840. t['controlETB'] = 0x0017;
  15841. t['controlETX'] = 0x0003;
  15842. t['controlFF'] = 0x000C;
  15843. t['controlFS'] = 0x001C;
  15844. t['controlGS'] = 0x001D;
  15845. t['controlHT'] = 0x0009;
  15846. t['controlLF'] = 0x000A;
  15847. t['controlNAK'] = 0x0015;
  15848. t['controlNULL'] = 0x0000;
  15849. t['controlRS'] = 0x001E;
  15850. t['controlSI'] = 0x000F;
  15851. t['controlSO'] = 0x000E;
  15852. t['controlSOT'] = 0x0002;
  15853. t['controlSTX'] = 0x0001;
  15854. t['controlSUB'] = 0x001A;
  15855. t['controlSYN'] = 0x0016;
  15856. t['controlUS'] = 0x001F;
  15857. t['controlVT'] = 0x000B;
  15858. t['copyright'] = 0x00A9;
  15859. t['copyrightsans'] = 0xF8E9;
  15860. t['copyrightserif'] = 0xF6D9;
  15861. t['cornerbracketleft'] = 0x300C;
  15862. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15863. t['cornerbracketleftvertical'] = 0xFE41;
  15864. t['cornerbracketright'] = 0x300D;
  15865. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15866. t['cornerbracketrightvertical'] = 0xFE42;
  15867. t['corporationsquare'] = 0x337F;
  15868. t['cosquare'] = 0x33C7;
  15869. t['coverkgsquare'] = 0x33C6;
  15870. t['cparen'] = 0x249E;
  15871. t['cruzeiro'] = 0x20A2;
  15872. t['cstretched'] = 0x0297;
  15873. t['curlyand'] = 0x22CF;
  15874. t['curlyor'] = 0x22CE;
  15875. t['currency'] = 0x00A4;
  15876. t['cyrBreve'] = 0xF6D1;
  15877. t['cyrFlex'] = 0xF6D2;
  15878. t['cyrbreve'] = 0xF6D4;
  15879. t['cyrflex'] = 0xF6D5;
  15880. t['d'] = 0x0064;
  15881. t['daarmenian'] = 0x0564;
  15882. t['dabengali'] = 0x09A6;
  15883. t['dadarabic'] = 0x0636;
  15884. t['dadeva'] = 0x0926;
  15885. t['dadfinalarabic'] = 0xFEBE;
  15886. t['dadinitialarabic'] = 0xFEBF;
  15887. t['dadmedialarabic'] = 0xFEC0;
  15888. t['dagesh'] = 0x05BC;
  15889. t['dageshhebrew'] = 0x05BC;
  15890. t['dagger'] = 0x2020;
  15891. t['daggerdbl'] = 0x2021;
  15892. t['dagujarati'] = 0x0AA6;
  15893. t['dagurmukhi'] = 0x0A26;
  15894. t['dahiragana'] = 0x3060;
  15895. t['dakatakana'] = 0x30C0;
  15896. t['dalarabic'] = 0x062F;
  15897. t['dalet'] = 0x05D3;
  15898. t['daletdagesh'] = 0xFB33;
  15899. t['daletdageshhebrew'] = 0xFB33;
  15900. t['dalethebrew'] = 0x05D3;
  15901. t['dalfinalarabic'] = 0xFEAA;
  15902. t['dammaarabic'] = 0x064F;
  15903. t['dammalowarabic'] = 0x064F;
  15904. t['dammatanaltonearabic'] = 0x064C;
  15905. t['dammatanarabic'] = 0x064C;
  15906. t['danda'] = 0x0964;
  15907. t['dargahebrew'] = 0x05A7;
  15908. t['dargalefthebrew'] = 0x05A7;
  15909. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15910. t['dblGrave'] = 0xF6D3;
  15911. t['dblanglebracketleft'] = 0x300A;
  15912. t['dblanglebracketleftvertical'] = 0xFE3D;
  15913. t['dblanglebracketright'] = 0x300B;
  15914. t['dblanglebracketrightvertical'] = 0xFE3E;
  15915. t['dblarchinvertedbelowcmb'] = 0x032B;
  15916. t['dblarrowleft'] = 0x21D4;
  15917. t['dblarrowright'] = 0x21D2;
  15918. t['dbldanda'] = 0x0965;
  15919. t['dblgrave'] = 0xF6D6;
  15920. t['dblgravecmb'] = 0x030F;
  15921. t['dblintegral'] = 0x222C;
  15922. t['dbllowline'] = 0x2017;
  15923. t['dbllowlinecmb'] = 0x0333;
  15924. t['dbloverlinecmb'] = 0x033F;
  15925. t['dblprimemod'] = 0x02BA;
  15926. t['dblverticalbar'] = 0x2016;
  15927. t['dblverticallineabovecmb'] = 0x030E;
  15928. t['dbopomofo'] = 0x3109;
  15929. t['dbsquare'] = 0x33C8;
  15930. t['dcaron'] = 0x010F;
  15931. t['dcedilla'] = 0x1E11;
  15932. t['dcircle'] = 0x24D3;
  15933. t['dcircumflexbelow'] = 0x1E13;
  15934. t['dcroat'] = 0x0111;
  15935. t['ddabengali'] = 0x09A1;
  15936. t['ddadeva'] = 0x0921;
  15937. t['ddagujarati'] = 0x0AA1;
  15938. t['ddagurmukhi'] = 0x0A21;
  15939. t['ddalarabic'] = 0x0688;
  15940. t['ddalfinalarabic'] = 0xFB89;
  15941. t['dddhadeva'] = 0x095C;
  15942. t['ddhabengali'] = 0x09A2;
  15943. t['ddhadeva'] = 0x0922;
  15944. t['ddhagujarati'] = 0x0AA2;
  15945. t['ddhagurmukhi'] = 0x0A22;
  15946. t['ddotaccent'] = 0x1E0B;
  15947. t['ddotbelow'] = 0x1E0D;
  15948. t['decimalseparatorarabic'] = 0x066B;
  15949. t['decimalseparatorpersian'] = 0x066B;
  15950. t['decyrillic'] = 0x0434;
  15951. t['degree'] = 0x00B0;
  15952. t['dehihebrew'] = 0x05AD;
  15953. t['dehiragana'] = 0x3067;
  15954. t['deicoptic'] = 0x03EF;
  15955. t['dekatakana'] = 0x30C7;
  15956. t['deleteleft'] = 0x232B;
  15957. t['deleteright'] = 0x2326;
  15958. t['delta'] = 0x03B4;
  15959. t['deltaturned'] = 0x018D;
  15960. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15961. t['dezh'] = 0x02A4;
  15962. t['dhabengali'] = 0x09A7;
  15963. t['dhadeva'] = 0x0927;
  15964. t['dhagujarati'] = 0x0AA7;
  15965. t['dhagurmukhi'] = 0x0A27;
  15966. t['dhook'] = 0x0257;
  15967. t['dialytikatonos'] = 0x0385;
  15968. t['dialytikatonoscmb'] = 0x0344;
  15969. t['diamond'] = 0x2666;
  15970. t['diamondsuitwhite'] = 0x2662;
  15971. t['dieresis'] = 0x00A8;
  15972. t['dieresisacute'] = 0xF6D7;
  15973. t['dieresisbelowcmb'] = 0x0324;
  15974. t['dieresiscmb'] = 0x0308;
  15975. t['dieresisgrave'] = 0xF6D8;
  15976. t['dieresistonos'] = 0x0385;
  15977. t['dihiragana'] = 0x3062;
  15978. t['dikatakana'] = 0x30C2;
  15979. t['dittomark'] = 0x3003;
  15980. t['divide'] = 0x00F7;
  15981. t['divides'] = 0x2223;
  15982. t['divisionslash'] = 0x2215;
  15983. t['djecyrillic'] = 0x0452;
  15984. t['dkshade'] = 0x2593;
  15985. t['dlinebelow'] = 0x1E0F;
  15986. t['dlsquare'] = 0x3397;
  15987. t['dmacron'] = 0x0111;
  15988. t['dmonospace'] = 0xFF44;
  15989. t['dnblock'] = 0x2584;
  15990. t['dochadathai'] = 0x0E0E;
  15991. t['dodekthai'] = 0x0E14;
  15992. t['dohiragana'] = 0x3069;
  15993. t['dokatakana'] = 0x30C9;
  15994. t['dollar'] = 0x0024;
  15995. t['dollarinferior'] = 0xF6E3;
  15996. t['dollarmonospace'] = 0xFF04;
  15997. t['dollaroldstyle'] = 0xF724;
  15998. t['dollarsmall'] = 0xFE69;
  15999. t['dollarsuperior'] = 0xF6E4;
  16000. t['dong'] = 0x20AB;
  16001. t['dorusquare'] = 0x3326;
  16002. t['dotaccent'] = 0x02D9;
  16003. t['dotaccentcmb'] = 0x0307;
  16004. t['dotbelowcmb'] = 0x0323;
  16005. t['dotbelowcomb'] = 0x0323;
  16006. t['dotkatakana'] = 0x30FB;
  16007. t['dotlessi'] = 0x0131;
  16008. t['dotlessj'] = 0xF6BE;
  16009. t['dotlessjstrokehook'] = 0x0284;
  16010. t['dotmath'] = 0x22C5;
  16011. t['dottedcircle'] = 0x25CC;
  16012. t['doubleyodpatah'] = 0xFB1F;
  16013. t['doubleyodpatahhebrew'] = 0xFB1F;
  16014. t['downtackbelowcmb'] = 0x031E;
  16015. t['downtackmod'] = 0x02D5;
  16016. t['dparen'] = 0x249F;
  16017. t['dsuperior'] = 0xF6EB;
  16018. t['dtail'] = 0x0256;
  16019. t['dtopbar'] = 0x018C;
  16020. t['duhiragana'] = 0x3065;
  16021. t['dukatakana'] = 0x30C5;
  16022. t['dz'] = 0x01F3;
  16023. t['dzaltone'] = 0x02A3;
  16024. t['dzcaron'] = 0x01C6;
  16025. t['dzcurl'] = 0x02A5;
  16026. t['dzeabkhasiancyrillic'] = 0x04E1;
  16027. t['dzecyrillic'] = 0x0455;
  16028. t['dzhecyrillic'] = 0x045F;
  16029. t['e'] = 0x0065;
  16030. t['eacute'] = 0x00E9;
  16031. t['earth'] = 0x2641;
  16032. t['ebengali'] = 0x098F;
  16033. t['ebopomofo'] = 0x311C;
  16034. t['ebreve'] = 0x0115;
  16035. t['ecandradeva'] = 0x090D;
  16036. t['ecandragujarati'] = 0x0A8D;
  16037. t['ecandravowelsigndeva'] = 0x0945;
  16038. t['ecandravowelsigngujarati'] = 0x0AC5;
  16039. t['ecaron'] = 0x011B;
  16040. t['ecedillabreve'] = 0x1E1D;
  16041. t['echarmenian'] = 0x0565;
  16042. t['echyiwnarmenian'] = 0x0587;
  16043. t['ecircle'] = 0x24D4;
  16044. t['ecircumflex'] = 0x00EA;
  16045. t['ecircumflexacute'] = 0x1EBF;
  16046. t['ecircumflexbelow'] = 0x1E19;
  16047. t['ecircumflexdotbelow'] = 0x1EC7;
  16048. t['ecircumflexgrave'] = 0x1EC1;
  16049. t['ecircumflexhookabove'] = 0x1EC3;
  16050. t['ecircumflextilde'] = 0x1EC5;
  16051. t['ecyrillic'] = 0x0454;
  16052. t['edblgrave'] = 0x0205;
  16053. t['edeva'] = 0x090F;
  16054. t['edieresis'] = 0x00EB;
  16055. t['edot'] = 0x0117;
  16056. t['edotaccent'] = 0x0117;
  16057. t['edotbelow'] = 0x1EB9;
  16058. t['eegurmukhi'] = 0x0A0F;
  16059. t['eematragurmukhi'] = 0x0A47;
  16060. t['efcyrillic'] = 0x0444;
  16061. t['egrave'] = 0x00E8;
  16062. t['egujarati'] = 0x0A8F;
  16063. t['eharmenian'] = 0x0567;
  16064. t['ehbopomofo'] = 0x311D;
  16065. t['ehiragana'] = 0x3048;
  16066. t['ehookabove'] = 0x1EBB;
  16067. t['eibopomofo'] = 0x311F;
  16068. t['eight'] = 0x0038;
  16069. t['eightarabic'] = 0x0668;
  16070. t['eightbengali'] = 0x09EE;
  16071. t['eightcircle'] = 0x2467;
  16072. t['eightcircleinversesansserif'] = 0x2791;
  16073. t['eightdeva'] = 0x096E;
  16074. t['eighteencircle'] = 0x2471;
  16075. t['eighteenparen'] = 0x2485;
  16076. t['eighteenperiod'] = 0x2499;
  16077. t['eightgujarati'] = 0x0AEE;
  16078. t['eightgurmukhi'] = 0x0A6E;
  16079. t['eighthackarabic'] = 0x0668;
  16080. t['eighthangzhou'] = 0x3028;
  16081. t['eighthnotebeamed'] = 0x266B;
  16082. t['eightideographicparen'] = 0x3227;
  16083. t['eightinferior'] = 0x2088;
  16084. t['eightmonospace'] = 0xFF18;
  16085. t['eightoldstyle'] = 0xF738;
  16086. t['eightparen'] = 0x247B;
  16087. t['eightperiod'] = 0x248F;
  16088. t['eightpersian'] = 0x06F8;
  16089. t['eightroman'] = 0x2177;
  16090. t['eightsuperior'] = 0x2078;
  16091. t['eightthai'] = 0x0E58;
  16092. t['einvertedbreve'] = 0x0207;
  16093. t['eiotifiedcyrillic'] = 0x0465;
  16094. t['ekatakana'] = 0x30A8;
  16095. t['ekatakanahalfwidth'] = 0xFF74;
  16096. t['ekonkargurmukhi'] = 0x0A74;
  16097. t['ekorean'] = 0x3154;
  16098. t['elcyrillic'] = 0x043B;
  16099. t['element'] = 0x2208;
  16100. t['elevencircle'] = 0x246A;
  16101. t['elevenparen'] = 0x247E;
  16102. t['elevenperiod'] = 0x2492;
  16103. t['elevenroman'] = 0x217A;
  16104. t['ellipsis'] = 0x2026;
  16105. t['ellipsisvertical'] = 0x22EE;
  16106. t['emacron'] = 0x0113;
  16107. t['emacronacute'] = 0x1E17;
  16108. t['emacrongrave'] = 0x1E15;
  16109. t['emcyrillic'] = 0x043C;
  16110. t['emdash'] = 0x2014;
  16111. t['emdashvertical'] = 0xFE31;
  16112. t['emonospace'] = 0xFF45;
  16113. t['emphasismarkarmenian'] = 0x055B;
  16114. t['emptyset'] = 0x2205;
  16115. t['enbopomofo'] = 0x3123;
  16116. t['encyrillic'] = 0x043D;
  16117. t['endash'] = 0x2013;
  16118. t['endashvertical'] = 0xFE32;
  16119. t['endescendercyrillic'] = 0x04A3;
  16120. t['eng'] = 0x014B;
  16121. t['engbopomofo'] = 0x3125;
  16122. t['enghecyrillic'] = 0x04A5;
  16123. t['enhookcyrillic'] = 0x04C8;
  16124. t['enspace'] = 0x2002;
  16125. t['eogonek'] = 0x0119;
  16126. t['eokorean'] = 0x3153;
  16127. t['eopen'] = 0x025B;
  16128. t['eopenclosed'] = 0x029A;
  16129. t['eopenreversed'] = 0x025C;
  16130. t['eopenreversedclosed'] = 0x025E;
  16131. t['eopenreversedhook'] = 0x025D;
  16132. t['eparen'] = 0x24A0;
  16133. t['epsilon'] = 0x03B5;
  16134. t['epsilontonos'] = 0x03AD;
  16135. t['equal'] = 0x003D;
  16136. t['equalmonospace'] = 0xFF1D;
  16137. t['equalsmall'] = 0xFE66;
  16138. t['equalsuperior'] = 0x207C;
  16139. t['equivalence'] = 0x2261;
  16140. t['erbopomofo'] = 0x3126;
  16141. t['ercyrillic'] = 0x0440;
  16142. t['ereversed'] = 0x0258;
  16143. t['ereversedcyrillic'] = 0x044D;
  16144. t['escyrillic'] = 0x0441;
  16145. t['esdescendercyrillic'] = 0x04AB;
  16146. t['esh'] = 0x0283;
  16147. t['eshcurl'] = 0x0286;
  16148. t['eshortdeva'] = 0x090E;
  16149. t['eshortvowelsigndeva'] = 0x0946;
  16150. t['eshreversedloop'] = 0x01AA;
  16151. t['eshsquatreversed'] = 0x0285;
  16152. t['esmallhiragana'] = 0x3047;
  16153. t['esmallkatakana'] = 0x30A7;
  16154. t['esmallkatakanahalfwidth'] = 0xFF6A;
  16155. t['estimated'] = 0x212E;
  16156. t['esuperior'] = 0xF6EC;
  16157. t['eta'] = 0x03B7;
  16158. t['etarmenian'] = 0x0568;
  16159. t['etatonos'] = 0x03AE;
  16160. t['eth'] = 0x00F0;
  16161. t['etilde'] = 0x1EBD;
  16162. t['etildebelow'] = 0x1E1B;
  16163. t['etnahtafoukhhebrew'] = 0x0591;
  16164. t['etnahtafoukhlefthebrew'] = 0x0591;
  16165. t['etnahtahebrew'] = 0x0591;
  16166. t['etnahtalefthebrew'] = 0x0591;
  16167. t['eturned'] = 0x01DD;
  16168. t['eukorean'] = 0x3161;
  16169. t['euro'] = 0x20AC;
  16170. t['evowelsignbengali'] = 0x09C7;
  16171. t['evowelsigndeva'] = 0x0947;
  16172. t['evowelsigngujarati'] = 0x0AC7;
  16173. t['exclam'] = 0x0021;
  16174. t['exclamarmenian'] = 0x055C;
  16175. t['exclamdbl'] = 0x203C;
  16176. t['exclamdown'] = 0x00A1;
  16177. t['exclamdownsmall'] = 0xF7A1;
  16178. t['exclammonospace'] = 0xFF01;
  16179. t['exclamsmall'] = 0xF721;
  16180. t['existential'] = 0x2203;
  16181. t['ezh'] = 0x0292;
  16182. t['ezhcaron'] = 0x01EF;
  16183. t['ezhcurl'] = 0x0293;
  16184. t['ezhreversed'] = 0x01B9;
  16185. t['ezhtail'] = 0x01BA;
  16186. t['f'] = 0x0066;
  16187. t['fadeva'] = 0x095E;
  16188. t['fagurmukhi'] = 0x0A5E;
  16189. t['fahrenheit'] = 0x2109;
  16190. t['fathaarabic'] = 0x064E;
  16191. t['fathalowarabic'] = 0x064E;
  16192. t['fathatanarabic'] = 0x064B;
  16193. t['fbopomofo'] = 0x3108;
  16194. t['fcircle'] = 0x24D5;
  16195. t['fdotaccent'] = 0x1E1F;
  16196. t['feharabic'] = 0x0641;
  16197. t['feharmenian'] = 0x0586;
  16198. t['fehfinalarabic'] = 0xFED2;
  16199. t['fehinitialarabic'] = 0xFED3;
  16200. t['fehmedialarabic'] = 0xFED4;
  16201. t['feicoptic'] = 0x03E5;
  16202. t['female'] = 0x2640;
  16203. t['ff'] = 0xFB00;
  16204. t['ffi'] = 0xFB03;
  16205. t['ffl'] = 0xFB04;
  16206. t['fi'] = 0xFB01;
  16207. t['fifteencircle'] = 0x246E;
  16208. t['fifteenparen'] = 0x2482;
  16209. t['fifteenperiod'] = 0x2496;
  16210. t['figuredash'] = 0x2012;
  16211. t['filledbox'] = 0x25A0;
  16212. t['filledrect'] = 0x25AC;
  16213. t['finalkaf'] = 0x05DA;
  16214. t['finalkafdagesh'] = 0xFB3A;
  16215. t['finalkafdageshhebrew'] = 0xFB3A;
  16216. t['finalkafhebrew'] = 0x05DA;
  16217. t['finalmem'] = 0x05DD;
  16218. t['finalmemhebrew'] = 0x05DD;
  16219. t['finalnun'] = 0x05DF;
  16220. t['finalnunhebrew'] = 0x05DF;
  16221. t['finalpe'] = 0x05E3;
  16222. t['finalpehebrew'] = 0x05E3;
  16223. t['finaltsadi'] = 0x05E5;
  16224. t['finaltsadihebrew'] = 0x05E5;
  16225. t['firsttonechinese'] = 0x02C9;
  16226. t['fisheye'] = 0x25C9;
  16227. t['fitacyrillic'] = 0x0473;
  16228. t['five'] = 0x0035;
  16229. t['fivearabic'] = 0x0665;
  16230. t['fivebengali'] = 0x09EB;
  16231. t['fivecircle'] = 0x2464;
  16232. t['fivecircleinversesansserif'] = 0x278E;
  16233. t['fivedeva'] = 0x096B;
  16234. t['fiveeighths'] = 0x215D;
  16235. t['fivegujarati'] = 0x0AEB;
  16236. t['fivegurmukhi'] = 0x0A6B;
  16237. t['fivehackarabic'] = 0x0665;
  16238. t['fivehangzhou'] = 0x3025;
  16239. t['fiveideographicparen'] = 0x3224;
  16240. t['fiveinferior'] = 0x2085;
  16241. t['fivemonospace'] = 0xFF15;
  16242. t['fiveoldstyle'] = 0xF735;
  16243. t['fiveparen'] = 0x2478;
  16244. t['fiveperiod'] = 0x248C;
  16245. t['fivepersian'] = 0x06F5;
  16246. t['fiveroman'] = 0x2174;
  16247. t['fivesuperior'] = 0x2075;
  16248. t['fivethai'] = 0x0E55;
  16249. t['fl'] = 0xFB02;
  16250. t['florin'] = 0x0192;
  16251. t['fmonospace'] = 0xFF46;
  16252. t['fmsquare'] = 0x3399;
  16253. t['fofanthai'] = 0x0E1F;
  16254. t['fofathai'] = 0x0E1D;
  16255. t['fongmanthai'] = 0x0E4F;
  16256. t['forall'] = 0x2200;
  16257. t['four'] = 0x0034;
  16258. t['fourarabic'] = 0x0664;
  16259. t['fourbengali'] = 0x09EA;
  16260. t['fourcircle'] = 0x2463;
  16261. t['fourcircleinversesansserif'] = 0x278D;
  16262. t['fourdeva'] = 0x096A;
  16263. t['fourgujarati'] = 0x0AEA;
  16264. t['fourgurmukhi'] = 0x0A6A;
  16265. t['fourhackarabic'] = 0x0664;
  16266. t['fourhangzhou'] = 0x3024;
  16267. t['fourideographicparen'] = 0x3223;
  16268. t['fourinferior'] = 0x2084;
  16269. t['fourmonospace'] = 0xFF14;
  16270. t['fournumeratorbengali'] = 0x09F7;
  16271. t['fouroldstyle'] = 0xF734;
  16272. t['fourparen'] = 0x2477;
  16273. t['fourperiod'] = 0x248B;
  16274. t['fourpersian'] = 0x06F4;
  16275. t['fourroman'] = 0x2173;
  16276. t['foursuperior'] = 0x2074;
  16277. t['fourteencircle'] = 0x246D;
  16278. t['fourteenparen'] = 0x2481;
  16279. t['fourteenperiod'] = 0x2495;
  16280. t['fourthai'] = 0x0E54;
  16281. t['fourthtonechinese'] = 0x02CB;
  16282. t['fparen'] = 0x24A1;
  16283. t['fraction'] = 0x2044;
  16284. t['franc'] = 0x20A3;
  16285. t['g'] = 0x0067;
  16286. t['gabengali'] = 0x0997;
  16287. t['gacute'] = 0x01F5;
  16288. t['gadeva'] = 0x0917;
  16289. t['gafarabic'] = 0x06AF;
  16290. t['gaffinalarabic'] = 0xFB93;
  16291. t['gafinitialarabic'] = 0xFB94;
  16292. t['gafmedialarabic'] = 0xFB95;
  16293. t['gagujarati'] = 0x0A97;
  16294. t['gagurmukhi'] = 0x0A17;
  16295. t['gahiragana'] = 0x304C;
  16296. t['gakatakana'] = 0x30AC;
  16297. t['gamma'] = 0x03B3;
  16298. t['gammalatinsmall'] = 0x0263;
  16299. t['gammasuperior'] = 0x02E0;
  16300. t['gangiacoptic'] = 0x03EB;
  16301. t['gbopomofo'] = 0x310D;
  16302. t['gbreve'] = 0x011F;
  16303. t['gcaron'] = 0x01E7;
  16304. t['gcedilla'] = 0x0123;
  16305. t['gcircle'] = 0x24D6;
  16306. t['gcircumflex'] = 0x011D;
  16307. t['gcommaaccent'] = 0x0123;
  16308. t['gdot'] = 0x0121;
  16309. t['gdotaccent'] = 0x0121;
  16310. t['gecyrillic'] = 0x0433;
  16311. t['gehiragana'] = 0x3052;
  16312. t['gekatakana'] = 0x30B2;
  16313. t['geometricallyequal'] = 0x2251;
  16314. t['gereshaccenthebrew'] = 0x059C;
  16315. t['gereshhebrew'] = 0x05F3;
  16316. t['gereshmuqdamhebrew'] = 0x059D;
  16317. t['germandbls'] = 0x00DF;
  16318. t['gershayimaccenthebrew'] = 0x059E;
  16319. t['gershayimhebrew'] = 0x05F4;
  16320. t['getamark'] = 0x3013;
  16321. t['ghabengali'] = 0x0998;
  16322. t['ghadarmenian'] = 0x0572;
  16323. t['ghadeva'] = 0x0918;
  16324. t['ghagujarati'] = 0x0A98;
  16325. t['ghagurmukhi'] = 0x0A18;
  16326. t['ghainarabic'] = 0x063A;
  16327. t['ghainfinalarabic'] = 0xFECE;
  16328. t['ghaininitialarabic'] = 0xFECF;
  16329. t['ghainmedialarabic'] = 0xFED0;
  16330. t['ghemiddlehookcyrillic'] = 0x0495;
  16331. t['ghestrokecyrillic'] = 0x0493;
  16332. t['gheupturncyrillic'] = 0x0491;
  16333. t['ghhadeva'] = 0x095A;
  16334. t['ghhagurmukhi'] = 0x0A5A;
  16335. t['ghook'] = 0x0260;
  16336. t['ghzsquare'] = 0x3393;
  16337. t['gihiragana'] = 0x304E;
  16338. t['gikatakana'] = 0x30AE;
  16339. t['gimarmenian'] = 0x0563;
  16340. t['gimel'] = 0x05D2;
  16341. t['gimeldagesh'] = 0xFB32;
  16342. t['gimeldageshhebrew'] = 0xFB32;
  16343. t['gimelhebrew'] = 0x05D2;
  16344. t['gjecyrillic'] = 0x0453;
  16345. t['glottalinvertedstroke'] = 0x01BE;
  16346. t['glottalstop'] = 0x0294;
  16347. t['glottalstopinverted'] = 0x0296;
  16348. t['glottalstopmod'] = 0x02C0;
  16349. t['glottalstopreversed'] = 0x0295;
  16350. t['glottalstopreversedmod'] = 0x02C1;
  16351. t['glottalstopreversedsuperior'] = 0x02E4;
  16352. t['glottalstopstroke'] = 0x02A1;
  16353. t['glottalstopstrokereversed'] = 0x02A2;
  16354. t['gmacron'] = 0x1E21;
  16355. t['gmonospace'] = 0xFF47;
  16356. t['gohiragana'] = 0x3054;
  16357. t['gokatakana'] = 0x30B4;
  16358. t['gparen'] = 0x24A2;
  16359. t['gpasquare'] = 0x33AC;
  16360. t['gradient'] = 0x2207;
  16361. t['grave'] = 0x0060;
  16362. t['gravebelowcmb'] = 0x0316;
  16363. t['gravecmb'] = 0x0300;
  16364. t['gravecomb'] = 0x0300;
  16365. t['gravedeva'] = 0x0953;
  16366. t['gravelowmod'] = 0x02CE;
  16367. t['gravemonospace'] = 0xFF40;
  16368. t['gravetonecmb'] = 0x0340;
  16369. t['greater'] = 0x003E;
  16370. t['greaterequal'] = 0x2265;
  16371. t['greaterequalorless'] = 0x22DB;
  16372. t['greatermonospace'] = 0xFF1E;
  16373. t['greaterorequivalent'] = 0x2273;
  16374. t['greaterorless'] = 0x2277;
  16375. t['greateroverequal'] = 0x2267;
  16376. t['greatersmall'] = 0xFE65;
  16377. t['gscript'] = 0x0261;
  16378. t['gstroke'] = 0x01E5;
  16379. t['guhiragana'] = 0x3050;
  16380. t['guillemotleft'] = 0x00AB;
  16381. t['guillemotright'] = 0x00BB;
  16382. t['guilsinglleft'] = 0x2039;
  16383. t['guilsinglright'] = 0x203A;
  16384. t['gukatakana'] = 0x30B0;
  16385. t['guramusquare'] = 0x3318;
  16386. t['gysquare'] = 0x33C9;
  16387. t['h'] = 0x0068;
  16388. t['haabkhasiancyrillic'] = 0x04A9;
  16389. t['haaltonearabic'] = 0x06C1;
  16390. t['habengali'] = 0x09B9;
  16391. t['hadescendercyrillic'] = 0x04B3;
  16392. t['hadeva'] = 0x0939;
  16393. t['hagujarati'] = 0x0AB9;
  16394. t['hagurmukhi'] = 0x0A39;
  16395. t['haharabic'] = 0x062D;
  16396. t['hahfinalarabic'] = 0xFEA2;
  16397. t['hahinitialarabic'] = 0xFEA3;
  16398. t['hahiragana'] = 0x306F;
  16399. t['hahmedialarabic'] = 0xFEA4;
  16400. t['haitusquare'] = 0x332A;
  16401. t['hakatakana'] = 0x30CF;
  16402. t['hakatakanahalfwidth'] = 0xFF8A;
  16403. t['halantgurmukhi'] = 0x0A4D;
  16404. t['hamzaarabic'] = 0x0621;
  16405. t['hamzalowarabic'] = 0x0621;
  16406. t['hangulfiller'] = 0x3164;
  16407. t['hardsigncyrillic'] = 0x044A;
  16408. t['harpoonleftbarbup'] = 0x21BC;
  16409. t['harpoonrightbarbup'] = 0x21C0;
  16410. t['hasquare'] = 0x33CA;
  16411. t['hatafpatah'] = 0x05B2;
  16412. t['hatafpatah16'] = 0x05B2;
  16413. t['hatafpatah23'] = 0x05B2;
  16414. t['hatafpatah2f'] = 0x05B2;
  16415. t['hatafpatahhebrew'] = 0x05B2;
  16416. t['hatafpatahnarrowhebrew'] = 0x05B2;
  16417. t['hatafpatahquarterhebrew'] = 0x05B2;
  16418. t['hatafpatahwidehebrew'] = 0x05B2;
  16419. t['hatafqamats'] = 0x05B3;
  16420. t['hatafqamats1b'] = 0x05B3;
  16421. t['hatafqamats28'] = 0x05B3;
  16422. t['hatafqamats34'] = 0x05B3;
  16423. t['hatafqamatshebrew'] = 0x05B3;
  16424. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  16425. t['hatafqamatsquarterhebrew'] = 0x05B3;
  16426. t['hatafqamatswidehebrew'] = 0x05B3;
  16427. t['hatafsegol'] = 0x05B1;
  16428. t['hatafsegol17'] = 0x05B1;
  16429. t['hatafsegol24'] = 0x05B1;
  16430. t['hatafsegol30'] = 0x05B1;
  16431. t['hatafsegolhebrew'] = 0x05B1;
  16432. t['hatafsegolnarrowhebrew'] = 0x05B1;
  16433. t['hatafsegolquarterhebrew'] = 0x05B1;
  16434. t['hatafsegolwidehebrew'] = 0x05B1;
  16435. t['hbar'] = 0x0127;
  16436. t['hbopomofo'] = 0x310F;
  16437. t['hbrevebelow'] = 0x1E2B;
  16438. t['hcedilla'] = 0x1E29;
  16439. t['hcircle'] = 0x24D7;
  16440. t['hcircumflex'] = 0x0125;
  16441. t['hdieresis'] = 0x1E27;
  16442. t['hdotaccent'] = 0x1E23;
  16443. t['hdotbelow'] = 0x1E25;
  16444. t['he'] = 0x05D4;
  16445. t['heart'] = 0x2665;
  16446. t['heartsuitblack'] = 0x2665;
  16447. t['heartsuitwhite'] = 0x2661;
  16448. t['hedagesh'] = 0xFB34;
  16449. t['hedageshhebrew'] = 0xFB34;
  16450. t['hehaltonearabic'] = 0x06C1;
  16451. t['heharabic'] = 0x0647;
  16452. t['hehebrew'] = 0x05D4;
  16453. t['hehfinalaltonearabic'] = 0xFBA7;
  16454. t['hehfinalalttwoarabic'] = 0xFEEA;
  16455. t['hehfinalarabic'] = 0xFEEA;
  16456. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  16457. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  16458. t['hehinitialaltonearabic'] = 0xFBA8;
  16459. t['hehinitialarabic'] = 0xFEEB;
  16460. t['hehiragana'] = 0x3078;
  16461. t['hehmedialaltonearabic'] = 0xFBA9;
  16462. t['hehmedialarabic'] = 0xFEEC;
  16463. t['heiseierasquare'] = 0x337B;
  16464. t['hekatakana'] = 0x30D8;
  16465. t['hekatakanahalfwidth'] = 0xFF8D;
  16466. t['hekutaarusquare'] = 0x3336;
  16467. t['henghook'] = 0x0267;
  16468. t['herutusquare'] = 0x3339;
  16469. t['het'] = 0x05D7;
  16470. t['hethebrew'] = 0x05D7;
  16471. t['hhook'] = 0x0266;
  16472. t['hhooksuperior'] = 0x02B1;
  16473. t['hieuhacirclekorean'] = 0x327B;
  16474. t['hieuhaparenkorean'] = 0x321B;
  16475. t['hieuhcirclekorean'] = 0x326D;
  16476. t['hieuhkorean'] = 0x314E;
  16477. t['hieuhparenkorean'] = 0x320D;
  16478. t['hihiragana'] = 0x3072;
  16479. t['hikatakana'] = 0x30D2;
  16480. t['hikatakanahalfwidth'] = 0xFF8B;
  16481. t['hiriq'] = 0x05B4;
  16482. t['hiriq14'] = 0x05B4;
  16483. t['hiriq21'] = 0x05B4;
  16484. t['hiriq2d'] = 0x05B4;
  16485. t['hiriqhebrew'] = 0x05B4;
  16486. t['hiriqnarrowhebrew'] = 0x05B4;
  16487. t['hiriqquarterhebrew'] = 0x05B4;
  16488. t['hiriqwidehebrew'] = 0x05B4;
  16489. t['hlinebelow'] = 0x1E96;
  16490. t['hmonospace'] = 0xFF48;
  16491. t['hoarmenian'] = 0x0570;
  16492. t['hohipthai'] = 0x0E2B;
  16493. t['hohiragana'] = 0x307B;
  16494. t['hokatakana'] = 0x30DB;
  16495. t['hokatakanahalfwidth'] = 0xFF8E;
  16496. t['holam'] = 0x05B9;
  16497. t['holam19'] = 0x05B9;
  16498. t['holam26'] = 0x05B9;
  16499. t['holam32'] = 0x05B9;
  16500. t['holamhebrew'] = 0x05B9;
  16501. t['holamnarrowhebrew'] = 0x05B9;
  16502. t['holamquarterhebrew'] = 0x05B9;
  16503. t['holamwidehebrew'] = 0x05B9;
  16504. t['honokhukthai'] = 0x0E2E;
  16505. t['hookabovecomb'] = 0x0309;
  16506. t['hookcmb'] = 0x0309;
  16507. t['hookpalatalizedbelowcmb'] = 0x0321;
  16508. t['hookretroflexbelowcmb'] = 0x0322;
  16509. t['hoonsquare'] = 0x3342;
  16510. t['horicoptic'] = 0x03E9;
  16511. t['horizontalbar'] = 0x2015;
  16512. t['horncmb'] = 0x031B;
  16513. t['hotsprings'] = 0x2668;
  16514. t['house'] = 0x2302;
  16515. t['hparen'] = 0x24A3;
  16516. t['hsuperior'] = 0x02B0;
  16517. t['hturned'] = 0x0265;
  16518. t['huhiragana'] = 0x3075;
  16519. t['huiitosquare'] = 0x3333;
  16520. t['hukatakana'] = 0x30D5;
  16521. t['hukatakanahalfwidth'] = 0xFF8C;
  16522. t['hungarumlaut'] = 0x02DD;
  16523. t['hungarumlautcmb'] = 0x030B;
  16524. t['hv'] = 0x0195;
  16525. t['hyphen'] = 0x002D;
  16526. t['hypheninferior'] = 0xF6E5;
  16527. t['hyphenmonospace'] = 0xFF0D;
  16528. t['hyphensmall'] = 0xFE63;
  16529. t['hyphensuperior'] = 0xF6E6;
  16530. t['hyphentwo'] = 0x2010;
  16531. t['i'] = 0x0069;
  16532. t['iacute'] = 0x00ED;
  16533. t['iacyrillic'] = 0x044F;
  16534. t['ibengali'] = 0x0987;
  16535. t['ibopomofo'] = 0x3127;
  16536. t['ibreve'] = 0x012D;
  16537. t['icaron'] = 0x01D0;
  16538. t['icircle'] = 0x24D8;
  16539. t['icircumflex'] = 0x00EE;
  16540. t['icyrillic'] = 0x0456;
  16541. t['idblgrave'] = 0x0209;
  16542. t['ideographearthcircle'] = 0x328F;
  16543. t['ideographfirecircle'] = 0x328B;
  16544. t['ideographicallianceparen'] = 0x323F;
  16545. t['ideographiccallparen'] = 0x323A;
  16546. t['ideographiccentrecircle'] = 0x32A5;
  16547. t['ideographicclose'] = 0x3006;
  16548. t['ideographiccomma'] = 0x3001;
  16549. t['ideographiccommaleft'] = 0xFF64;
  16550. t['ideographiccongratulationparen'] = 0x3237;
  16551. t['ideographiccorrectcircle'] = 0x32A3;
  16552. t['ideographicearthparen'] = 0x322F;
  16553. t['ideographicenterpriseparen'] = 0x323D;
  16554. t['ideographicexcellentcircle'] = 0x329D;
  16555. t['ideographicfestivalparen'] = 0x3240;
  16556. t['ideographicfinancialcircle'] = 0x3296;
  16557. t['ideographicfinancialparen'] = 0x3236;
  16558. t['ideographicfireparen'] = 0x322B;
  16559. t['ideographichaveparen'] = 0x3232;
  16560. t['ideographichighcircle'] = 0x32A4;
  16561. t['ideographiciterationmark'] = 0x3005;
  16562. t['ideographiclaborcircle'] = 0x3298;
  16563. t['ideographiclaborparen'] = 0x3238;
  16564. t['ideographicleftcircle'] = 0x32A7;
  16565. t['ideographiclowcircle'] = 0x32A6;
  16566. t['ideographicmedicinecircle'] = 0x32A9;
  16567. t['ideographicmetalparen'] = 0x322E;
  16568. t['ideographicmoonparen'] = 0x322A;
  16569. t['ideographicnameparen'] = 0x3234;
  16570. t['ideographicperiod'] = 0x3002;
  16571. t['ideographicprintcircle'] = 0x329E;
  16572. t['ideographicreachparen'] = 0x3243;
  16573. t['ideographicrepresentparen'] = 0x3239;
  16574. t['ideographicresourceparen'] = 0x323E;
  16575. t['ideographicrightcircle'] = 0x32A8;
  16576. t['ideographicsecretcircle'] = 0x3299;
  16577. t['ideographicselfparen'] = 0x3242;
  16578. t['ideographicsocietyparen'] = 0x3233;
  16579. t['ideographicspace'] = 0x3000;
  16580. t['ideographicspecialparen'] = 0x3235;
  16581. t['ideographicstockparen'] = 0x3231;
  16582. t['ideographicstudyparen'] = 0x323B;
  16583. t['ideographicsunparen'] = 0x3230;
  16584. t['ideographicsuperviseparen'] = 0x323C;
  16585. t['ideographicwaterparen'] = 0x322C;
  16586. t['ideographicwoodparen'] = 0x322D;
  16587. t['ideographiczero'] = 0x3007;
  16588. t['ideographmetalcircle'] = 0x328E;
  16589. t['ideographmooncircle'] = 0x328A;
  16590. t['ideographnamecircle'] = 0x3294;
  16591. t['ideographsuncircle'] = 0x3290;
  16592. t['ideographwatercircle'] = 0x328C;
  16593. t['ideographwoodcircle'] = 0x328D;
  16594. t['ideva'] = 0x0907;
  16595. t['idieresis'] = 0x00EF;
  16596. t['idieresisacute'] = 0x1E2F;
  16597. t['idieresiscyrillic'] = 0x04E5;
  16598. t['idotbelow'] = 0x1ECB;
  16599. t['iebrevecyrillic'] = 0x04D7;
  16600. t['iecyrillic'] = 0x0435;
  16601. t['ieungacirclekorean'] = 0x3275;
  16602. t['ieungaparenkorean'] = 0x3215;
  16603. t['ieungcirclekorean'] = 0x3267;
  16604. t['ieungkorean'] = 0x3147;
  16605. t['ieungparenkorean'] = 0x3207;
  16606. t['igrave'] = 0x00EC;
  16607. t['igujarati'] = 0x0A87;
  16608. t['igurmukhi'] = 0x0A07;
  16609. t['ihiragana'] = 0x3044;
  16610. t['ihookabove'] = 0x1EC9;
  16611. t['iibengali'] = 0x0988;
  16612. t['iicyrillic'] = 0x0438;
  16613. t['iideva'] = 0x0908;
  16614. t['iigujarati'] = 0x0A88;
  16615. t['iigurmukhi'] = 0x0A08;
  16616. t['iimatragurmukhi'] = 0x0A40;
  16617. t['iinvertedbreve'] = 0x020B;
  16618. t['iishortcyrillic'] = 0x0439;
  16619. t['iivowelsignbengali'] = 0x09C0;
  16620. t['iivowelsigndeva'] = 0x0940;
  16621. t['iivowelsigngujarati'] = 0x0AC0;
  16622. t['ij'] = 0x0133;
  16623. t['ikatakana'] = 0x30A4;
  16624. t['ikatakanahalfwidth'] = 0xFF72;
  16625. t['ikorean'] = 0x3163;
  16626. t['ilde'] = 0x02DC;
  16627. t['iluyhebrew'] = 0x05AC;
  16628. t['imacron'] = 0x012B;
  16629. t['imacroncyrillic'] = 0x04E3;
  16630. t['imageorapproximatelyequal'] = 0x2253;
  16631. t['imatragurmukhi'] = 0x0A3F;
  16632. t['imonospace'] = 0xFF49;
  16633. t['increment'] = 0x2206;
  16634. t['infinity'] = 0x221E;
  16635. t['iniarmenian'] = 0x056B;
  16636. t['integral'] = 0x222B;
  16637. t['integralbottom'] = 0x2321;
  16638. t['integralbt'] = 0x2321;
  16639. t['integralex'] = 0xF8F5;
  16640. t['integraltop'] = 0x2320;
  16641. t['integraltp'] = 0x2320;
  16642. t['intersection'] = 0x2229;
  16643. t['intisquare'] = 0x3305;
  16644. t['invbullet'] = 0x25D8;
  16645. t['invcircle'] = 0x25D9;
  16646. t['invsmileface'] = 0x263B;
  16647. t['iocyrillic'] = 0x0451;
  16648. t['iogonek'] = 0x012F;
  16649. t['iota'] = 0x03B9;
  16650. t['iotadieresis'] = 0x03CA;
  16651. t['iotadieresistonos'] = 0x0390;
  16652. t['iotalatin'] = 0x0269;
  16653. t['iotatonos'] = 0x03AF;
  16654. t['iparen'] = 0x24A4;
  16655. t['irigurmukhi'] = 0x0A72;
  16656. t['ismallhiragana'] = 0x3043;
  16657. t['ismallkatakana'] = 0x30A3;
  16658. t['ismallkatakanahalfwidth'] = 0xFF68;
  16659. t['issharbengali'] = 0x09FA;
  16660. t['istroke'] = 0x0268;
  16661. t['isuperior'] = 0xF6ED;
  16662. t['iterationhiragana'] = 0x309D;
  16663. t['iterationkatakana'] = 0x30FD;
  16664. t['itilde'] = 0x0129;
  16665. t['itildebelow'] = 0x1E2D;
  16666. t['iubopomofo'] = 0x3129;
  16667. t['iucyrillic'] = 0x044E;
  16668. t['ivowelsignbengali'] = 0x09BF;
  16669. t['ivowelsigndeva'] = 0x093F;
  16670. t['ivowelsigngujarati'] = 0x0ABF;
  16671. t['izhitsacyrillic'] = 0x0475;
  16672. t['izhitsadblgravecyrillic'] = 0x0477;
  16673. t['j'] = 0x006A;
  16674. t['jaarmenian'] = 0x0571;
  16675. t['jabengali'] = 0x099C;
  16676. t['jadeva'] = 0x091C;
  16677. t['jagujarati'] = 0x0A9C;
  16678. t['jagurmukhi'] = 0x0A1C;
  16679. t['jbopomofo'] = 0x3110;
  16680. t['jcaron'] = 0x01F0;
  16681. t['jcircle'] = 0x24D9;
  16682. t['jcircumflex'] = 0x0135;
  16683. t['jcrossedtail'] = 0x029D;
  16684. t['jdotlessstroke'] = 0x025F;
  16685. t['jecyrillic'] = 0x0458;
  16686. t['jeemarabic'] = 0x062C;
  16687. t['jeemfinalarabic'] = 0xFE9E;
  16688. t['jeeminitialarabic'] = 0xFE9F;
  16689. t['jeemmedialarabic'] = 0xFEA0;
  16690. t['jeharabic'] = 0x0698;
  16691. t['jehfinalarabic'] = 0xFB8B;
  16692. t['jhabengali'] = 0x099D;
  16693. t['jhadeva'] = 0x091D;
  16694. t['jhagujarati'] = 0x0A9D;
  16695. t['jhagurmukhi'] = 0x0A1D;
  16696. t['jheharmenian'] = 0x057B;
  16697. t['jis'] = 0x3004;
  16698. t['jmonospace'] = 0xFF4A;
  16699. t['jparen'] = 0x24A5;
  16700. t['jsuperior'] = 0x02B2;
  16701. t['k'] = 0x006B;
  16702. t['kabashkircyrillic'] = 0x04A1;
  16703. t['kabengali'] = 0x0995;
  16704. t['kacute'] = 0x1E31;
  16705. t['kacyrillic'] = 0x043A;
  16706. t['kadescendercyrillic'] = 0x049B;
  16707. t['kadeva'] = 0x0915;
  16708. t['kaf'] = 0x05DB;
  16709. t['kafarabic'] = 0x0643;
  16710. t['kafdagesh'] = 0xFB3B;
  16711. t['kafdageshhebrew'] = 0xFB3B;
  16712. t['kaffinalarabic'] = 0xFEDA;
  16713. t['kafhebrew'] = 0x05DB;
  16714. t['kafinitialarabic'] = 0xFEDB;
  16715. t['kafmedialarabic'] = 0xFEDC;
  16716. t['kafrafehebrew'] = 0xFB4D;
  16717. t['kagujarati'] = 0x0A95;
  16718. t['kagurmukhi'] = 0x0A15;
  16719. t['kahiragana'] = 0x304B;
  16720. t['kahookcyrillic'] = 0x04C4;
  16721. t['kakatakana'] = 0x30AB;
  16722. t['kakatakanahalfwidth'] = 0xFF76;
  16723. t['kappa'] = 0x03BA;
  16724. t['kappasymbolgreek'] = 0x03F0;
  16725. t['kapyeounmieumkorean'] = 0x3171;
  16726. t['kapyeounphieuphkorean'] = 0x3184;
  16727. t['kapyeounpieupkorean'] = 0x3178;
  16728. t['kapyeounssangpieupkorean'] = 0x3179;
  16729. t['karoriisquare'] = 0x330D;
  16730. t['kashidaautoarabic'] = 0x0640;
  16731. t['kashidaautonosidebearingarabic'] = 0x0640;
  16732. t['kasmallkatakana'] = 0x30F5;
  16733. t['kasquare'] = 0x3384;
  16734. t['kasraarabic'] = 0x0650;
  16735. t['kasratanarabic'] = 0x064D;
  16736. t['kastrokecyrillic'] = 0x049F;
  16737. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  16738. t['kaverticalstrokecyrillic'] = 0x049D;
  16739. t['kbopomofo'] = 0x310E;
  16740. t['kcalsquare'] = 0x3389;
  16741. t['kcaron'] = 0x01E9;
  16742. t['kcedilla'] = 0x0137;
  16743. t['kcircle'] = 0x24DA;
  16744. t['kcommaaccent'] = 0x0137;
  16745. t['kdotbelow'] = 0x1E33;
  16746. t['keharmenian'] = 0x0584;
  16747. t['kehiragana'] = 0x3051;
  16748. t['kekatakana'] = 0x30B1;
  16749. t['kekatakanahalfwidth'] = 0xFF79;
  16750. t['kenarmenian'] = 0x056F;
  16751. t['kesmallkatakana'] = 0x30F6;
  16752. t['kgreenlandic'] = 0x0138;
  16753. t['khabengali'] = 0x0996;
  16754. t['khacyrillic'] = 0x0445;
  16755. t['khadeva'] = 0x0916;
  16756. t['khagujarati'] = 0x0A96;
  16757. t['khagurmukhi'] = 0x0A16;
  16758. t['khaharabic'] = 0x062E;
  16759. t['khahfinalarabic'] = 0xFEA6;
  16760. t['khahinitialarabic'] = 0xFEA7;
  16761. t['khahmedialarabic'] = 0xFEA8;
  16762. t['kheicoptic'] = 0x03E7;
  16763. t['khhadeva'] = 0x0959;
  16764. t['khhagurmukhi'] = 0x0A59;
  16765. t['khieukhacirclekorean'] = 0x3278;
  16766. t['khieukhaparenkorean'] = 0x3218;
  16767. t['khieukhcirclekorean'] = 0x326A;
  16768. t['khieukhkorean'] = 0x314B;
  16769. t['khieukhparenkorean'] = 0x320A;
  16770. t['khokhaithai'] = 0x0E02;
  16771. t['khokhonthai'] = 0x0E05;
  16772. t['khokhuatthai'] = 0x0E03;
  16773. t['khokhwaithai'] = 0x0E04;
  16774. t['khomutthai'] = 0x0E5B;
  16775. t['khook'] = 0x0199;
  16776. t['khorakhangthai'] = 0x0E06;
  16777. t['khzsquare'] = 0x3391;
  16778. t['kihiragana'] = 0x304D;
  16779. t['kikatakana'] = 0x30AD;
  16780. t['kikatakanahalfwidth'] = 0xFF77;
  16781. t['kiroguramusquare'] = 0x3315;
  16782. t['kiromeetorusquare'] = 0x3316;
  16783. t['kirosquare'] = 0x3314;
  16784. t['kiyeokacirclekorean'] = 0x326E;
  16785. t['kiyeokaparenkorean'] = 0x320E;
  16786. t['kiyeokcirclekorean'] = 0x3260;
  16787. t['kiyeokkorean'] = 0x3131;
  16788. t['kiyeokparenkorean'] = 0x3200;
  16789. t['kiyeoksioskorean'] = 0x3133;
  16790. t['kjecyrillic'] = 0x045C;
  16791. t['klinebelow'] = 0x1E35;
  16792. t['klsquare'] = 0x3398;
  16793. t['kmcubedsquare'] = 0x33A6;
  16794. t['kmonospace'] = 0xFF4B;
  16795. t['kmsquaredsquare'] = 0x33A2;
  16796. t['kohiragana'] = 0x3053;
  16797. t['kohmsquare'] = 0x33C0;
  16798. t['kokaithai'] = 0x0E01;
  16799. t['kokatakana'] = 0x30B3;
  16800. t['kokatakanahalfwidth'] = 0xFF7A;
  16801. t['kooposquare'] = 0x331E;
  16802. t['koppacyrillic'] = 0x0481;
  16803. t['koreanstandardsymbol'] = 0x327F;
  16804. t['koroniscmb'] = 0x0343;
  16805. t['kparen'] = 0x24A6;
  16806. t['kpasquare'] = 0x33AA;
  16807. t['ksicyrillic'] = 0x046F;
  16808. t['ktsquare'] = 0x33CF;
  16809. t['kturned'] = 0x029E;
  16810. t['kuhiragana'] = 0x304F;
  16811. t['kukatakana'] = 0x30AF;
  16812. t['kukatakanahalfwidth'] = 0xFF78;
  16813. t['kvsquare'] = 0x33B8;
  16814. t['kwsquare'] = 0x33BE;
  16815. t['l'] = 0x006C;
  16816. t['labengali'] = 0x09B2;
  16817. t['lacute'] = 0x013A;
  16818. t['ladeva'] = 0x0932;
  16819. t['lagujarati'] = 0x0AB2;
  16820. t['lagurmukhi'] = 0x0A32;
  16821. t['lakkhangyaothai'] = 0x0E45;
  16822. t['lamaleffinalarabic'] = 0xFEFC;
  16823. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16824. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16825. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16826. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16827. t['lamalefisolatedarabic'] = 0xFEFB;
  16828. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16829. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16830. t['lamarabic'] = 0x0644;
  16831. t['lambda'] = 0x03BB;
  16832. t['lambdastroke'] = 0x019B;
  16833. t['lamed'] = 0x05DC;
  16834. t['lameddagesh'] = 0xFB3C;
  16835. t['lameddageshhebrew'] = 0xFB3C;
  16836. t['lamedhebrew'] = 0x05DC;
  16837. t['lamfinalarabic'] = 0xFEDE;
  16838. t['lamhahinitialarabic'] = 0xFCCA;
  16839. t['laminitialarabic'] = 0xFEDF;
  16840. t['lamjeeminitialarabic'] = 0xFCC9;
  16841. t['lamkhahinitialarabic'] = 0xFCCB;
  16842. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16843. t['lammedialarabic'] = 0xFEE0;
  16844. t['lammeemhahinitialarabic'] = 0xFD88;
  16845. t['lammeeminitialarabic'] = 0xFCCC;
  16846. t['largecircle'] = 0x25EF;
  16847. t['lbar'] = 0x019A;
  16848. t['lbelt'] = 0x026C;
  16849. t['lbopomofo'] = 0x310C;
  16850. t['lcaron'] = 0x013E;
  16851. t['lcedilla'] = 0x013C;
  16852. t['lcircle'] = 0x24DB;
  16853. t['lcircumflexbelow'] = 0x1E3D;
  16854. t['lcommaaccent'] = 0x013C;
  16855. t['ldot'] = 0x0140;
  16856. t['ldotaccent'] = 0x0140;
  16857. t['ldotbelow'] = 0x1E37;
  16858. t['ldotbelowmacron'] = 0x1E39;
  16859. t['leftangleabovecmb'] = 0x031A;
  16860. t['lefttackbelowcmb'] = 0x0318;
  16861. t['less'] = 0x003C;
  16862. t['lessequal'] = 0x2264;
  16863. t['lessequalorgreater'] = 0x22DA;
  16864. t['lessmonospace'] = 0xFF1C;
  16865. t['lessorequivalent'] = 0x2272;
  16866. t['lessorgreater'] = 0x2276;
  16867. t['lessoverequal'] = 0x2266;
  16868. t['lesssmall'] = 0xFE64;
  16869. t['lezh'] = 0x026E;
  16870. t['lfblock'] = 0x258C;
  16871. t['lhookretroflex'] = 0x026D;
  16872. t['lira'] = 0x20A4;
  16873. t['liwnarmenian'] = 0x056C;
  16874. t['lj'] = 0x01C9;
  16875. t['ljecyrillic'] = 0x0459;
  16876. t['ll'] = 0xF6C0;
  16877. t['lladeva'] = 0x0933;
  16878. t['llagujarati'] = 0x0AB3;
  16879. t['llinebelow'] = 0x1E3B;
  16880. t['llladeva'] = 0x0934;
  16881. t['llvocalicbengali'] = 0x09E1;
  16882. t['llvocalicdeva'] = 0x0961;
  16883. t['llvocalicvowelsignbengali'] = 0x09E3;
  16884. t['llvocalicvowelsigndeva'] = 0x0963;
  16885. t['lmiddletilde'] = 0x026B;
  16886. t['lmonospace'] = 0xFF4C;
  16887. t['lmsquare'] = 0x33D0;
  16888. t['lochulathai'] = 0x0E2C;
  16889. t['logicaland'] = 0x2227;
  16890. t['logicalnot'] = 0x00AC;
  16891. t['logicalnotreversed'] = 0x2310;
  16892. t['logicalor'] = 0x2228;
  16893. t['lolingthai'] = 0x0E25;
  16894. t['longs'] = 0x017F;
  16895. t['lowlinecenterline'] = 0xFE4E;
  16896. t['lowlinecmb'] = 0x0332;
  16897. t['lowlinedashed'] = 0xFE4D;
  16898. t['lozenge'] = 0x25CA;
  16899. t['lparen'] = 0x24A7;
  16900. t['lslash'] = 0x0142;
  16901. t['lsquare'] = 0x2113;
  16902. t['lsuperior'] = 0xF6EE;
  16903. t['ltshade'] = 0x2591;
  16904. t['luthai'] = 0x0E26;
  16905. t['lvocalicbengali'] = 0x098C;
  16906. t['lvocalicdeva'] = 0x090C;
  16907. t['lvocalicvowelsignbengali'] = 0x09E2;
  16908. t['lvocalicvowelsigndeva'] = 0x0962;
  16909. t['lxsquare'] = 0x33D3;
  16910. t['m'] = 0x006D;
  16911. t['mabengali'] = 0x09AE;
  16912. t['macron'] = 0x00AF;
  16913. t['macronbelowcmb'] = 0x0331;
  16914. t['macroncmb'] = 0x0304;
  16915. t['macronlowmod'] = 0x02CD;
  16916. t['macronmonospace'] = 0xFFE3;
  16917. t['macute'] = 0x1E3F;
  16918. t['madeva'] = 0x092E;
  16919. t['magujarati'] = 0x0AAE;
  16920. t['magurmukhi'] = 0x0A2E;
  16921. t['mahapakhhebrew'] = 0x05A4;
  16922. t['mahapakhlefthebrew'] = 0x05A4;
  16923. t['mahiragana'] = 0x307E;
  16924. t['maichattawalowleftthai'] = 0xF895;
  16925. t['maichattawalowrightthai'] = 0xF894;
  16926. t['maichattawathai'] = 0x0E4B;
  16927. t['maichattawaupperleftthai'] = 0xF893;
  16928. t['maieklowleftthai'] = 0xF88C;
  16929. t['maieklowrightthai'] = 0xF88B;
  16930. t['maiekthai'] = 0x0E48;
  16931. t['maiekupperleftthai'] = 0xF88A;
  16932. t['maihanakatleftthai'] = 0xF884;
  16933. t['maihanakatthai'] = 0x0E31;
  16934. t['maitaikhuleftthai'] = 0xF889;
  16935. t['maitaikhuthai'] = 0x0E47;
  16936. t['maitholowleftthai'] = 0xF88F;
  16937. t['maitholowrightthai'] = 0xF88E;
  16938. t['maithothai'] = 0x0E49;
  16939. t['maithoupperleftthai'] = 0xF88D;
  16940. t['maitrilowleftthai'] = 0xF892;
  16941. t['maitrilowrightthai'] = 0xF891;
  16942. t['maitrithai'] = 0x0E4A;
  16943. t['maitriupperleftthai'] = 0xF890;
  16944. t['maiyamokthai'] = 0x0E46;
  16945. t['makatakana'] = 0x30DE;
  16946. t['makatakanahalfwidth'] = 0xFF8F;
  16947. t['male'] = 0x2642;
  16948. t['mansyonsquare'] = 0x3347;
  16949. t['maqafhebrew'] = 0x05BE;
  16950. t['mars'] = 0x2642;
  16951. t['masoracirclehebrew'] = 0x05AF;
  16952. t['masquare'] = 0x3383;
  16953. t['mbopomofo'] = 0x3107;
  16954. t['mbsquare'] = 0x33D4;
  16955. t['mcircle'] = 0x24DC;
  16956. t['mcubedsquare'] = 0x33A5;
  16957. t['mdotaccent'] = 0x1E41;
  16958. t['mdotbelow'] = 0x1E43;
  16959. t['meemarabic'] = 0x0645;
  16960. t['meemfinalarabic'] = 0xFEE2;
  16961. t['meeminitialarabic'] = 0xFEE3;
  16962. t['meemmedialarabic'] = 0xFEE4;
  16963. t['meemmeeminitialarabic'] = 0xFCD1;
  16964. t['meemmeemisolatedarabic'] = 0xFC48;
  16965. t['meetorusquare'] = 0x334D;
  16966. t['mehiragana'] = 0x3081;
  16967. t['meizierasquare'] = 0x337E;
  16968. t['mekatakana'] = 0x30E1;
  16969. t['mekatakanahalfwidth'] = 0xFF92;
  16970. t['mem'] = 0x05DE;
  16971. t['memdagesh'] = 0xFB3E;
  16972. t['memdageshhebrew'] = 0xFB3E;
  16973. t['memhebrew'] = 0x05DE;
  16974. t['menarmenian'] = 0x0574;
  16975. t['merkhahebrew'] = 0x05A5;
  16976. t['merkhakefulahebrew'] = 0x05A6;
  16977. t['merkhakefulalefthebrew'] = 0x05A6;
  16978. t['merkhalefthebrew'] = 0x05A5;
  16979. t['mhook'] = 0x0271;
  16980. t['mhzsquare'] = 0x3392;
  16981. t['middledotkatakanahalfwidth'] = 0xFF65;
  16982. t['middot'] = 0x00B7;
  16983. t['mieumacirclekorean'] = 0x3272;
  16984. t['mieumaparenkorean'] = 0x3212;
  16985. t['mieumcirclekorean'] = 0x3264;
  16986. t['mieumkorean'] = 0x3141;
  16987. t['mieumpansioskorean'] = 0x3170;
  16988. t['mieumparenkorean'] = 0x3204;
  16989. t['mieumpieupkorean'] = 0x316E;
  16990. t['mieumsioskorean'] = 0x316F;
  16991. t['mihiragana'] = 0x307F;
  16992. t['mikatakana'] = 0x30DF;
  16993. t['mikatakanahalfwidth'] = 0xFF90;
  16994. t['minus'] = 0x2212;
  16995. t['minusbelowcmb'] = 0x0320;
  16996. t['minuscircle'] = 0x2296;
  16997. t['minusmod'] = 0x02D7;
  16998. t['minusplus'] = 0x2213;
  16999. t['minute'] = 0x2032;
  17000. t['miribaarusquare'] = 0x334A;
  17001. t['mirisquare'] = 0x3349;
  17002. t['mlonglegturned'] = 0x0270;
  17003. t['mlsquare'] = 0x3396;
  17004. t['mmcubedsquare'] = 0x33A3;
  17005. t['mmonospace'] = 0xFF4D;
  17006. t['mmsquaredsquare'] = 0x339F;
  17007. t['mohiragana'] = 0x3082;
  17008. t['mohmsquare'] = 0x33C1;
  17009. t['mokatakana'] = 0x30E2;
  17010. t['mokatakanahalfwidth'] = 0xFF93;
  17011. t['molsquare'] = 0x33D6;
  17012. t['momathai'] = 0x0E21;
  17013. t['moverssquare'] = 0x33A7;
  17014. t['moverssquaredsquare'] = 0x33A8;
  17015. t['mparen'] = 0x24A8;
  17016. t['mpasquare'] = 0x33AB;
  17017. t['mssquare'] = 0x33B3;
  17018. t['msuperior'] = 0xF6EF;
  17019. t['mturned'] = 0x026F;
  17020. t['mu'] = 0x00B5;
  17021. t['mu1'] = 0x00B5;
  17022. t['muasquare'] = 0x3382;
  17023. t['muchgreater'] = 0x226B;
  17024. t['muchless'] = 0x226A;
  17025. t['mufsquare'] = 0x338C;
  17026. t['mugreek'] = 0x03BC;
  17027. t['mugsquare'] = 0x338D;
  17028. t['muhiragana'] = 0x3080;
  17029. t['mukatakana'] = 0x30E0;
  17030. t['mukatakanahalfwidth'] = 0xFF91;
  17031. t['mulsquare'] = 0x3395;
  17032. t['multiply'] = 0x00D7;
  17033. t['mumsquare'] = 0x339B;
  17034. t['munahhebrew'] = 0x05A3;
  17035. t['munahlefthebrew'] = 0x05A3;
  17036. t['musicalnote'] = 0x266A;
  17037. t['musicalnotedbl'] = 0x266B;
  17038. t['musicflatsign'] = 0x266D;
  17039. t['musicsharpsign'] = 0x266F;
  17040. t['mussquare'] = 0x33B2;
  17041. t['muvsquare'] = 0x33B6;
  17042. t['muwsquare'] = 0x33BC;
  17043. t['mvmegasquare'] = 0x33B9;
  17044. t['mvsquare'] = 0x33B7;
  17045. t['mwmegasquare'] = 0x33BF;
  17046. t['mwsquare'] = 0x33BD;
  17047. t['n'] = 0x006E;
  17048. t['nabengali'] = 0x09A8;
  17049. t['nabla'] = 0x2207;
  17050. t['nacute'] = 0x0144;
  17051. t['nadeva'] = 0x0928;
  17052. t['nagujarati'] = 0x0AA8;
  17053. t['nagurmukhi'] = 0x0A28;
  17054. t['nahiragana'] = 0x306A;
  17055. t['nakatakana'] = 0x30CA;
  17056. t['nakatakanahalfwidth'] = 0xFF85;
  17057. t['napostrophe'] = 0x0149;
  17058. t['nasquare'] = 0x3381;
  17059. t['nbopomofo'] = 0x310B;
  17060. t['nbspace'] = 0x00A0;
  17061. t['ncaron'] = 0x0148;
  17062. t['ncedilla'] = 0x0146;
  17063. t['ncircle'] = 0x24DD;
  17064. t['ncircumflexbelow'] = 0x1E4B;
  17065. t['ncommaaccent'] = 0x0146;
  17066. t['ndotaccent'] = 0x1E45;
  17067. t['ndotbelow'] = 0x1E47;
  17068. t['nehiragana'] = 0x306D;
  17069. t['nekatakana'] = 0x30CD;
  17070. t['nekatakanahalfwidth'] = 0xFF88;
  17071. t['newsheqelsign'] = 0x20AA;
  17072. t['nfsquare'] = 0x338B;
  17073. t['ngabengali'] = 0x0999;
  17074. t['ngadeva'] = 0x0919;
  17075. t['ngagujarati'] = 0x0A99;
  17076. t['ngagurmukhi'] = 0x0A19;
  17077. t['ngonguthai'] = 0x0E07;
  17078. t['nhiragana'] = 0x3093;
  17079. t['nhookleft'] = 0x0272;
  17080. t['nhookretroflex'] = 0x0273;
  17081. t['nieunacirclekorean'] = 0x326F;
  17082. t['nieunaparenkorean'] = 0x320F;
  17083. t['nieuncieuckorean'] = 0x3135;
  17084. t['nieuncirclekorean'] = 0x3261;
  17085. t['nieunhieuhkorean'] = 0x3136;
  17086. t['nieunkorean'] = 0x3134;
  17087. t['nieunpansioskorean'] = 0x3168;
  17088. t['nieunparenkorean'] = 0x3201;
  17089. t['nieunsioskorean'] = 0x3167;
  17090. t['nieuntikeutkorean'] = 0x3166;
  17091. t['nihiragana'] = 0x306B;
  17092. t['nikatakana'] = 0x30CB;
  17093. t['nikatakanahalfwidth'] = 0xFF86;
  17094. t['nikhahitleftthai'] = 0xF899;
  17095. t['nikhahitthai'] = 0x0E4D;
  17096. t['nine'] = 0x0039;
  17097. t['ninearabic'] = 0x0669;
  17098. t['ninebengali'] = 0x09EF;
  17099. t['ninecircle'] = 0x2468;
  17100. t['ninecircleinversesansserif'] = 0x2792;
  17101. t['ninedeva'] = 0x096F;
  17102. t['ninegujarati'] = 0x0AEF;
  17103. t['ninegurmukhi'] = 0x0A6F;
  17104. t['ninehackarabic'] = 0x0669;
  17105. t['ninehangzhou'] = 0x3029;
  17106. t['nineideographicparen'] = 0x3228;
  17107. t['nineinferior'] = 0x2089;
  17108. t['ninemonospace'] = 0xFF19;
  17109. t['nineoldstyle'] = 0xF739;
  17110. t['nineparen'] = 0x247C;
  17111. t['nineperiod'] = 0x2490;
  17112. t['ninepersian'] = 0x06F9;
  17113. t['nineroman'] = 0x2178;
  17114. t['ninesuperior'] = 0x2079;
  17115. t['nineteencircle'] = 0x2472;
  17116. t['nineteenparen'] = 0x2486;
  17117. t['nineteenperiod'] = 0x249A;
  17118. t['ninethai'] = 0x0E59;
  17119. t['nj'] = 0x01CC;
  17120. t['njecyrillic'] = 0x045A;
  17121. t['nkatakana'] = 0x30F3;
  17122. t['nkatakanahalfwidth'] = 0xFF9D;
  17123. t['nlegrightlong'] = 0x019E;
  17124. t['nlinebelow'] = 0x1E49;
  17125. t['nmonospace'] = 0xFF4E;
  17126. t['nmsquare'] = 0x339A;
  17127. t['nnabengali'] = 0x09A3;
  17128. t['nnadeva'] = 0x0923;
  17129. t['nnagujarati'] = 0x0AA3;
  17130. t['nnagurmukhi'] = 0x0A23;
  17131. t['nnnadeva'] = 0x0929;
  17132. t['nohiragana'] = 0x306E;
  17133. t['nokatakana'] = 0x30CE;
  17134. t['nokatakanahalfwidth'] = 0xFF89;
  17135. t['nonbreakingspace'] = 0x00A0;
  17136. t['nonenthai'] = 0x0E13;
  17137. t['nonuthai'] = 0x0E19;
  17138. t['noonarabic'] = 0x0646;
  17139. t['noonfinalarabic'] = 0xFEE6;
  17140. t['noonghunnaarabic'] = 0x06BA;
  17141. t['noonghunnafinalarabic'] = 0xFB9F;
  17142. t['nooninitialarabic'] = 0xFEE7;
  17143. t['noonjeeminitialarabic'] = 0xFCD2;
  17144. t['noonjeemisolatedarabic'] = 0xFC4B;
  17145. t['noonmedialarabic'] = 0xFEE8;
  17146. t['noonmeeminitialarabic'] = 0xFCD5;
  17147. t['noonmeemisolatedarabic'] = 0xFC4E;
  17148. t['noonnoonfinalarabic'] = 0xFC8D;
  17149. t['notcontains'] = 0x220C;
  17150. t['notelement'] = 0x2209;
  17151. t['notelementof'] = 0x2209;
  17152. t['notequal'] = 0x2260;
  17153. t['notgreater'] = 0x226F;
  17154. t['notgreaternorequal'] = 0x2271;
  17155. t['notgreaternorless'] = 0x2279;
  17156. t['notidentical'] = 0x2262;
  17157. t['notless'] = 0x226E;
  17158. t['notlessnorequal'] = 0x2270;
  17159. t['notparallel'] = 0x2226;
  17160. t['notprecedes'] = 0x2280;
  17161. t['notsubset'] = 0x2284;
  17162. t['notsucceeds'] = 0x2281;
  17163. t['notsuperset'] = 0x2285;
  17164. t['nowarmenian'] = 0x0576;
  17165. t['nparen'] = 0x24A9;
  17166. t['nssquare'] = 0x33B1;
  17167. t['nsuperior'] = 0x207F;
  17168. t['ntilde'] = 0x00F1;
  17169. t['nu'] = 0x03BD;
  17170. t['nuhiragana'] = 0x306C;
  17171. t['nukatakana'] = 0x30CC;
  17172. t['nukatakanahalfwidth'] = 0xFF87;
  17173. t['nuktabengali'] = 0x09BC;
  17174. t['nuktadeva'] = 0x093C;
  17175. t['nuktagujarati'] = 0x0ABC;
  17176. t['nuktagurmukhi'] = 0x0A3C;
  17177. t['numbersign'] = 0x0023;
  17178. t['numbersignmonospace'] = 0xFF03;
  17179. t['numbersignsmall'] = 0xFE5F;
  17180. t['numeralsigngreek'] = 0x0374;
  17181. t['numeralsignlowergreek'] = 0x0375;
  17182. t['numero'] = 0x2116;
  17183. t['nun'] = 0x05E0;
  17184. t['nundagesh'] = 0xFB40;
  17185. t['nundageshhebrew'] = 0xFB40;
  17186. t['nunhebrew'] = 0x05E0;
  17187. t['nvsquare'] = 0x33B5;
  17188. t['nwsquare'] = 0x33BB;
  17189. t['nyabengali'] = 0x099E;
  17190. t['nyadeva'] = 0x091E;
  17191. t['nyagujarati'] = 0x0A9E;
  17192. t['nyagurmukhi'] = 0x0A1E;
  17193. t['o'] = 0x006F;
  17194. t['oacute'] = 0x00F3;
  17195. t['oangthai'] = 0x0E2D;
  17196. t['obarred'] = 0x0275;
  17197. t['obarredcyrillic'] = 0x04E9;
  17198. t['obarreddieresiscyrillic'] = 0x04EB;
  17199. t['obengali'] = 0x0993;
  17200. t['obopomofo'] = 0x311B;
  17201. t['obreve'] = 0x014F;
  17202. t['ocandradeva'] = 0x0911;
  17203. t['ocandragujarati'] = 0x0A91;
  17204. t['ocandravowelsigndeva'] = 0x0949;
  17205. t['ocandravowelsigngujarati'] = 0x0AC9;
  17206. t['ocaron'] = 0x01D2;
  17207. t['ocircle'] = 0x24DE;
  17208. t['ocircumflex'] = 0x00F4;
  17209. t['ocircumflexacute'] = 0x1ED1;
  17210. t['ocircumflexdotbelow'] = 0x1ED9;
  17211. t['ocircumflexgrave'] = 0x1ED3;
  17212. t['ocircumflexhookabove'] = 0x1ED5;
  17213. t['ocircumflextilde'] = 0x1ED7;
  17214. t['ocyrillic'] = 0x043E;
  17215. t['odblacute'] = 0x0151;
  17216. t['odblgrave'] = 0x020D;
  17217. t['odeva'] = 0x0913;
  17218. t['odieresis'] = 0x00F6;
  17219. t['odieresiscyrillic'] = 0x04E7;
  17220. t['odotbelow'] = 0x1ECD;
  17221. t['oe'] = 0x0153;
  17222. t['oekorean'] = 0x315A;
  17223. t['ogonek'] = 0x02DB;
  17224. t['ogonekcmb'] = 0x0328;
  17225. t['ograve'] = 0x00F2;
  17226. t['ogujarati'] = 0x0A93;
  17227. t['oharmenian'] = 0x0585;
  17228. t['ohiragana'] = 0x304A;
  17229. t['ohookabove'] = 0x1ECF;
  17230. t['ohorn'] = 0x01A1;
  17231. t['ohornacute'] = 0x1EDB;
  17232. t['ohorndotbelow'] = 0x1EE3;
  17233. t['ohorngrave'] = 0x1EDD;
  17234. t['ohornhookabove'] = 0x1EDF;
  17235. t['ohorntilde'] = 0x1EE1;
  17236. t['ohungarumlaut'] = 0x0151;
  17237. t['oi'] = 0x01A3;
  17238. t['oinvertedbreve'] = 0x020F;
  17239. t['okatakana'] = 0x30AA;
  17240. t['okatakanahalfwidth'] = 0xFF75;
  17241. t['okorean'] = 0x3157;
  17242. t['olehebrew'] = 0x05AB;
  17243. t['omacron'] = 0x014D;
  17244. t['omacronacute'] = 0x1E53;
  17245. t['omacrongrave'] = 0x1E51;
  17246. t['omdeva'] = 0x0950;
  17247. t['omega'] = 0x03C9;
  17248. t['omega1'] = 0x03D6;
  17249. t['omegacyrillic'] = 0x0461;
  17250. t['omegalatinclosed'] = 0x0277;
  17251. t['omegaroundcyrillic'] = 0x047B;
  17252. t['omegatitlocyrillic'] = 0x047D;
  17253. t['omegatonos'] = 0x03CE;
  17254. t['omgujarati'] = 0x0AD0;
  17255. t['omicron'] = 0x03BF;
  17256. t['omicrontonos'] = 0x03CC;
  17257. t['omonospace'] = 0xFF4F;
  17258. t['one'] = 0x0031;
  17259. t['onearabic'] = 0x0661;
  17260. t['onebengali'] = 0x09E7;
  17261. t['onecircle'] = 0x2460;
  17262. t['onecircleinversesansserif'] = 0x278A;
  17263. t['onedeva'] = 0x0967;
  17264. t['onedotenleader'] = 0x2024;
  17265. t['oneeighth'] = 0x215B;
  17266. t['onefitted'] = 0xF6DC;
  17267. t['onegujarati'] = 0x0AE7;
  17268. t['onegurmukhi'] = 0x0A67;
  17269. t['onehackarabic'] = 0x0661;
  17270. t['onehalf'] = 0x00BD;
  17271. t['onehangzhou'] = 0x3021;
  17272. t['oneideographicparen'] = 0x3220;
  17273. t['oneinferior'] = 0x2081;
  17274. t['onemonospace'] = 0xFF11;
  17275. t['onenumeratorbengali'] = 0x09F4;
  17276. t['oneoldstyle'] = 0xF731;
  17277. t['oneparen'] = 0x2474;
  17278. t['oneperiod'] = 0x2488;
  17279. t['onepersian'] = 0x06F1;
  17280. t['onequarter'] = 0x00BC;
  17281. t['oneroman'] = 0x2170;
  17282. t['onesuperior'] = 0x00B9;
  17283. t['onethai'] = 0x0E51;
  17284. t['onethird'] = 0x2153;
  17285. t['oogonek'] = 0x01EB;
  17286. t['oogonekmacron'] = 0x01ED;
  17287. t['oogurmukhi'] = 0x0A13;
  17288. t['oomatragurmukhi'] = 0x0A4B;
  17289. t['oopen'] = 0x0254;
  17290. t['oparen'] = 0x24AA;
  17291. t['openbullet'] = 0x25E6;
  17292. t['option'] = 0x2325;
  17293. t['ordfeminine'] = 0x00AA;
  17294. t['ordmasculine'] = 0x00BA;
  17295. t['orthogonal'] = 0x221F;
  17296. t['oshortdeva'] = 0x0912;
  17297. t['oshortvowelsigndeva'] = 0x094A;
  17298. t['oslash'] = 0x00F8;
  17299. t['oslashacute'] = 0x01FF;
  17300. t['osmallhiragana'] = 0x3049;
  17301. t['osmallkatakana'] = 0x30A9;
  17302. t['osmallkatakanahalfwidth'] = 0xFF6B;
  17303. t['ostrokeacute'] = 0x01FF;
  17304. t['osuperior'] = 0xF6F0;
  17305. t['otcyrillic'] = 0x047F;
  17306. t['otilde'] = 0x00F5;
  17307. t['otildeacute'] = 0x1E4D;
  17308. t['otildedieresis'] = 0x1E4F;
  17309. t['oubopomofo'] = 0x3121;
  17310. t['overline'] = 0x203E;
  17311. t['overlinecenterline'] = 0xFE4A;
  17312. t['overlinecmb'] = 0x0305;
  17313. t['overlinedashed'] = 0xFE49;
  17314. t['overlinedblwavy'] = 0xFE4C;
  17315. t['overlinewavy'] = 0xFE4B;
  17316. t['overscore'] = 0x00AF;
  17317. t['ovowelsignbengali'] = 0x09CB;
  17318. t['ovowelsigndeva'] = 0x094B;
  17319. t['ovowelsigngujarati'] = 0x0ACB;
  17320. t['p'] = 0x0070;
  17321. t['paampssquare'] = 0x3380;
  17322. t['paasentosquare'] = 0x332B;
  17323. t['pabengali'] = 0x09AA;
  17324. t['pacute'] = 0x1E55;
  17325. t['padeva'] = 0x092A;
  17326. t['pagedown'] = 0x21DF;
  17327. t['pageup'] = 0x21DE;
  17328. t['pagujarati'] = 0x0AAA;
  17329. t['pagurmukhi'] = 0x0A2A;
  17330. t['pahiragana'] = 0x3071;
  17331. t['paiyannoithai'] = 0x0E2F;
  17332. t['pakatakana'] = 0x30D1;
  17333. t['palatalizationcyrilliccmb'] = 0x0484;
  17334. t['palochkacyrillic'] = 0x04C0;
  17335. t['pansioskorean'] = 0x317F;
  17336. t['paragraph'] = 0x00B6;
  17337. t['parallel'] = 0x2225;
  17338. t['parenleft'] = 0x0028;
  17339. t['parenleftaltonearabic'] = 0xFD3E;
  17340. t['parenleftbt'] = 0xF8ED;
  17341. t['parenleftex'] = 0xF8EC;
  17342. t['parenleftinferior'] = 0x208D;
  17343. t['parenleftmonospace'] = 0xFF08;
  17344. t['parenleftsmall'] = 0xFE59;
  17345. t['parenleftsuperior'] = 0x207D;
  17346. t['parenlefttp'] = 0xF8EB;
  17347. t['parenleftvertical'] = 0xFE35;
  17348. t['parenright'] = 0x0029;
  17349. t['parenrightaltonearabic'] = 0xFD3F;
  17350. t['parenrightbt'] = 0xF8F8;
  17351. t['parenrightex'] = 0xF8F7;
  17352. t['parenrightinferior'] = 0x208E;
  17353. t['parenrightmonospace'] = 0xFF09;
  17354. t['parenrightsmall'] = 0xFE5A;
  17355. t['parenrightsuperior'] = 0x207E;
  17356. t['parenrighttp'] = 0xF8F6;
  17357. t['parenrightvertical'] = 0xFE36;
  17358. t['partialdiff'] = 0x2202;
  17359. t['paseqhebrew'] = 0x05C0;
  17360. t['pashtahebrew'] = 0x0599;
  17361. t['pasquare'] = 0x33A9;
  17362. t['patah'] = 0x05B7;
  17363. t['patah11'] = 0x05B7;
  17364. t['patah1d'] = 0x05B7;
  17365. t['patah2a'] = 0x05B7;
  17366. t['patahhebrew'] = 0x05B7;
  17367. t['patahnarrowhebrew'] = 0x05B7;
  17368. t['patahquarterhebrew'] = 0x05B7;
  17369. t['patahwidehebrew'] = 0x05B7;
  17370. t['pazerhebrew'] = 0x05A1;
  17371. t['pbopomofo'] = 0x3106;
  17372. t['pcircle'] = 0x24DF;
  17373. t['pdotaccent'] = 0x1E57;
  17374. t['pe'] = 0x05E4;
  17375. t['pecyrillic'] = 0x043F;
  17376. t['pedagesh'] = 0xFB44;
  17377. t['pedageshhebrew'] = 0xFB44;
  17378. t['peezisquare'] = 0x333B;
  17379. t['pefinaldageshhebrew'] = 0xFB43;
  17380. t['peharabic'] = 0x067E;
  17381. t['peharmenian'] = 0x057A;
  17382. t['pehebrew'] = 0x05E4;
  17383. t['pehfinalarabic'] = 0xFB57;
  17384. t['pehinitialarabic'] = 0xFB58;
  17385. t['pehiragana'] = 0x307A;
  17386. t['pehmedialarabic'] = 0xFB59;
  17387. t['pekatakana'] = 0x30DA;
  17388. t['pemiddlehookcyrillic'] = 0x04A7;
  17389. t['perafehebrew'] = 0xFB4E;
  17390. t['percent'] = 0x0025;
  17391. t['percentarabic'] = 0x066A;
  17392. t['percentmonospace'] = 0xFF05;
  17393. t['percentsmall'] = 0xFE6A;
  17394. t['period'] = 0x002E;
  17395. t['periodarmenian'] = 0x0589;
  17396. t['periodcentered'] = 0x00B7;
  17397. t['periodhalfwidth'] = 0xFF61;
  17398. t['periodinferior'] = 0xF6E7;
  17399. t['periodmonospace'] = 0xFF0E;
  17400. t['periodsmall'] = 0xFE52;
  17401. t['periodsuperior'] = 0xF6E8;
  17402. t['perispomenigreekcmb'] = 0x0342;
  17403. t['perpendicular'] = 0x22A5;
  17404. t['perthousand'] = 0x2030;
  17405. t['peseta'] = 0x20A7;
  17406. t['pfsquare'] = 0x338A;
  17407. t['phabengali'] = 0x09AB;
  17408. t['phadeva'] = 0x092B;
  17409. t['phagujarati'] = 0x0AAB;
  17410. t['phagurmukhi'] = 0x0A2B;
  17411. t['phi'] = 0x03C6;
  17412. t['phi1'] = 0x03D5;
  17413. t['phieuphacirclekorean'] = 0x327A;
  17414. t['phieuphaparenkorean'] = 0x321A;
  17415. t['phieuphcirclekorean'] = 0x326C;
  17416. t['phieuphkorean'] = 0x314D;
  17417. t['phieuphparenkorean'] = 0x320C;
  17418. t['philatin'] = 0x0278;
  17419. t['phinthuthai'] = 0x0E3A;
  17420. t['phisymbolgreek'] = 0x03D5;
  17421. t['phook'] = 0x01A5;
  17422. t['phophanthai'] = 0x0E1E;
  17423. t['phophungthai'] = 0x0E1C;
  17424. t['phosamphaothai'] = 0x0E20;
  17425. t['pi'] = 0x03C0;
  17426. t['pieupacirclekorean'] = 0x3273;
  17427. t['pieupaparenkorean'] = 0x3213;
  17428. t['pieupcieuckorean'] = 0x3176;
  17429. t['pieupcirclekorean'] = 0x3265;
  17430. t['pieupkiyeokkorean'] = 0x3172;
  17431. t['pieupkorean'] = 0x3142;
  17432. t['pieupparenkorean'] = 0x3205;
  17433. t['pieupsioskiyeokkorean'] = 0x3174;
  17434. t['pieupsioskorean'] = 0x3144;
  17435. t['pieupsiostikeutkorean'] = 0x3175;
  17436. t['pieupthieuthkorean'] = 0x3177;
  17437. t['pieuptikeutkorean'] = 0x3173;
  17438. t['pihiragana'] = 0x3074;
  17439. t['pikatakana'] = 0x30D4;
  17440. t['pisymbolgreek'] = 0x03D6;
  17441. t['piwrarmenian'] = 0x0583;
  17442. t['plus'] = 0x002B;
  17443. t['plusbelowcmb'] = 0x031F;
  17444. t['pluscircle'] = 0x2295;
  17445. t['plusminus'] = 0x00B1;
  17446. t['plusmod'] = 0x02D6;
  17447. t['plusmonospace'] = 0xFF0B;
  17448. t['plussmall'] = 0xFE62;
  17449. t['plussuperior'] = 0x207A;
  17450. t['pmonospace'] = 0xFF50;
  17451. t['pmsquare'] = 0x33D8;
  17452. t['pohiragana'] = 0x307D;
  17453. t['pointingindexdownwhite'] = 0x261F;
  17454. t['pointingindexleftwhite'] = 0x261C;
  17455. t['pointingindexrightwhite'] = 0x261E;
  17456. t['pointingindexupwhite'] = 0x261D;
  17457. t['pokatakana'] = 0x30DD;
  17458. t['poplathai'] = 0x0E1B;
  17459. t['postalmark'] = 0x3012;
  17460. t['postalmarkface'] = 0x3020;
  17461. t['pparen'] = 0x24AB;
  17462. t['precedes'] = 0x227A;
  17463. t['prescription'] = 0x211E;
  17464. t['primemod'] = 0x02B9;
  17465. t['primereversed'] = 0x2035;
  17466. t['product'] = 0x220F;
  17467. t['projective'] = 0x2305;
  17468. t['prolongedkana'] = 0x30FC;
  17469. t['propellor'] = 0x2318;
  17470. t['propersubset'] = 0x2282;
  17471. t['propersuperset'] = 0x2283;
  17472. t['proportion'] = 0x2237;
  17473. t['proportional'] = 0x221D;
  17474. t['psi'] = 0x03C8;
  17475. t['psicyrillic'] = 0x0471;
  17476. t['psilipneumatacyrilliccmb'] = 0x0486;
  17477. t['pssquare'] = 0x33B0;
  17478. t['puhiragana'] = 0x3077;
  17479. t['pukatakana'] = 0x30D7;
  17480. t['pvsquare'] = 0x33B4;
  17481. t['pwsquare'] = 0x33BA;
  17482. t['q'] = 0x0071;
  17483. t['qadeva'] = 0x0958;
  17484. t['qadmahebrew'] = 0x05A8;
  17485. t['qafarabic'] = 0x0642;
  17486. t['qaffinalarabic'] = 0xFED6;
  17487. t['qafinitialarabic'] = 0xFED7;
  17488. t['qafmedialarabic'] = 0xFED8;
  17489. t['qamats'] = 0x05B8;
  17490. t['qamats10'] = 0x05B8;
  17491. t['qamats1a'] = 0x05B8;
  17492. t['qamats1c'] = 0x05B8;
  17493. t['qamats27'] = 0x05B8;
  17494. t['qamats29'] = 0x05B8;
  17495. t['qamats33'] = 0x05B8;
  17496. t['qamatsde'] = 0x05B8;
  17497. t['qamatshebrew'] = 0x05B8;
  17498. t['qamatsnarrowhebrew'] = 0x05B8;
  17499. t['qamatsqatanhebrew'] = 0x05B8;
  17500. t['qamatsqatannarrowhebrew'] = 0x05B8;
  17501. t['qamatsqatanquarterhebrew'] = 0x05B8;
  17502. t['qamatsqatanwidehebrew'] = 0x05B8;
  17503. t['qamatsquarterhebrew'] = 0x05B8;
  17504. t['qamatswidehebrew'] = 0x05B8;
  17505. t['qarneyparahebrew'] = 0x059F;
  17506. t['qbopomofo'] = 0x3111;
  17507. t['qcircle'] = 0x24E0;
  17508. t['qhook'] = 0x02A0;
  17509. t['qmonospace'] = 0xFF51;
  17510. t['qof'] = 0x05E7;
  17511. t['qofdagesh'] = 0xFB47;
  17512. t['qofdageshhebrew'] = 0xFB47;
  17513. t['qofhebrew'] = 0x05E7;
  17514. t['qparen'] = 0x24AC;
  17515. t['quarternote'] = 0x2669;
  17516. t['qubuts'] = 0x05BB;
  17517. t['qubuts18'] = 0x05BB;
  17518. t['qubuts25'] = 0x05BB;
  17519. t['qubuts31'] = 0x05BB;
  17520. t['qubutshebrew'] = 0x05BB;
  17521. t['qubutsnarrowhebrew'] = 0x05BB;
  17522. t['qubutsquarterhebrew'] = 0x05BB;
  17523. t['qubutswidehebrew'] = 0x05BB;
  17524. t['question'] = 0x003F;
  17525. t['questionarabic'] = 0x061F;
  17526. t['questionarmenian'] = 0x055E;
  17527. t['questiondown'] = 0x00BF;
  17528. t['questiondownsmall'] = 0xF7BF;
  17529. t['questiongreek'] = 0x037E;
  17530. t['questionmonospace'] = 0xFF1F;
  17531. t['questionsmall'] = 0xF73F;
  17532. t['quotedbl'] = 0x0022;
  17533. t['quotedblbase'] = 0x201E;
  17534. t['quotedblleft'] = 0x201C;
  17535. t['quotedblmonospace'] = 0xFF02;
  17536. t['quotedblprime'] = 0x301E;
  17537. t['quotedblprimereversed'] = 0x301D;
  17538. t['quotedblright'] = 0x201D;
  17539. t['quoteleft'] = 0x2018;
  17540. t['quoteleftreversed'] = 0x201B;
  17541. t['quotereversed'] = 0x201B;
  17542. t['quoteright'] = 0x2019;
  17543. t['quoterightn'] = 0x0149;
  17544. t['quotesinglbase'] = 0x201A;
  17545. t['quotesingle'] = 0x0027;
  17546. t['quotesinglemonospace'] = 0xFF07;
  17547. t['r'] = 0x0072;
  17548. t['raarmenian'] = 0x057C;
  17549. t['rabengali'] = 0x09B0;
  17550. t['racute'] = 0x0155;
  17551. t['radeva'] = 0x0930;
  17552. t['radical'] = 0x221A;
  17553. t['radicalex'] = 0xF8E5;
  17554. t['radoverssquare'] = 0x33AE;
  17555. t['radoverssquaredsquare'] = 0x33AF;
  17556. t['radsquare'] = 0x33AD;
  17557. t['rafe'] = 0x05BF;
  17558. t['rafehebrew'] = 0x05BF;
  17559. t['ragujarati'] = 0x0AB0;
  17560. t['ragurmukhi'] = 0x0A30;
  17561. t['rahiragana'] = 0x3089;
  17562. t['rakatakana'] = 0x30E9;
  17563. t['rakatakanahalfwidth'] = 0xFF97;
  17564. t['ralowerdiagonalbengali'] = 0x09F1;
  17565. t['ramiddlediagonalbengali'] = 0x09F0;
  17566. t['ramshorn'] = 0x0264;
  17567. t['ratio'] = 0x2236;
  17568. t['rbopomofo'] = 0x3116;
  17569. t['rcaron'] = 0x0159;
  17570. t['rcedilla'] = 0x0157;
  17571. t['rcircle'] = 0x24E1;
  17572. t['rcommaaccent'] = 0x0157;
  17573. t['rdblgrave'] = 0x0211;
  17574. t['rdotaccent'] = 0x1E59;
  17575. t['rdotbelow'] = 0x1E5B;
  17576. t['rdotbelowmacron'] = 0x1E5D;
  17577. t['referencemark'] = 0x203B;
  17578. t['reflexsubset'] = 0x2286;
  17579. t['reflexsuperset'] = 0x2287;
  17580. t['registered'] = 0x00AE;
  17581. t['registersans'] = 0xF8E8;
  17582. t['registerserif'] = 0xF6DA;
  17583. t['reharabic'] = 0x0631;
  17584. t['reharmenian'] = 0x0580;
  17585. t['rehfinalarabic'] = 0xFEAE;
  17586. t['rehiragana'] = 0x308C;
  17587. t['rekatakana'] = 0x30EC;
  17588. t['rekatakanahalfwidth'] = 0xFF9A;
  17589. t['resh'] = 0x05E8;
  17590. t['reshdageshhebrew'] = 0xFB48;
  17591. t['reshhebrew'] = 0x05E8;
  17592. t['reversedtilde'] = 0x223D;
  17593. t['reviahebrew'] = 0x0597;
  17594. t['reviamugrashhebrew'] = 0x0597;
  17595. t['revlogicalnot'] = 0x2310;
  17596. t['rfishhook'] = 0x027E;
  17597. t['rfishhookreversed'] = 0x027F;
  17598. t['rhabengali'] = 0x09DD;
  17599. t['rhadeva'] = 0x095D;
  17600. t['rho'] = 0x03C1;
  17601. t['rhook'] = 0x027D;
  17602. t['rhookturned'] = 0x027B;
  17603. t['rhookturnedsuperior'] = 0x02B5;
  17604. t['rhosymbolgreek'] = 0x03F1;
  17605. t['rhotichookmod'] = 0x02DE;
  17606. t['rieulacirclekorean'] = 0x3271;
  17607. t['rieulaparenkorean'] = 0x3211;
  17608. t['rieulcirclekorean'] = 0x3263;
  17609. t['rieulhieuhkorean'] = 0x3140;
  17610. t['rieulkiyeokkorean'] = 0x313A;
  17611. t['rieulkiyeoksioskorean'] = 0x3169;
  17612. t['rieulkorean'] = 0x3139;
  17613. t['rieulmieumkorean'] = 0x313B;
  17614. t['rieulpansioskorean'] = 0x316C;
  17615. t['rieulparenkorean'] = 0x3203;
  17616. t['rieulphieuphkorean'] = 0x313F;
  17617. t['rieulpieupkorean'] = 0x313C;
  17618. t['rieulpieupsioskorean'] = 0x316B;
  17619. t['rieulsioskorean'] = 0x313D;
  17620. t['rieulthieuthkorean'] = 0x313E;
  17621. t['rieultikeutkorean'] = 0x316A;
  17622. t['rieulyeorinhieuhkorean'] = 0x316D;
  17623. t['rightangle'] = 0x221F;
  17624. t['righttackbelowcmb'] = 0x0319;
  17625. t['righttriangle'] = 0x22BF;
  17626. t['rihiragana'] = 0x308A;
  17627. t['rikatakana'] = 0x30EA;
  17628. t['rikatakanahalfwidth'] = 0xFF98;
  17629. t['ring'] = 0x02DA;
  17630. t['ringbelowcmb'] = 0x0325;
  17631. t['ringcmb'] = 0x030A;
  17632. t['ringhalfleft'] = 0x02BF;
  17633. t['ringhalfleftarmenian'] = 0x0559;
  17634. t['ringhalfleftbelowcmb'] = 0x031C;
  17635. t['ringhalfleftcentered'] = 0x02D3;
  17636. t['ringhalfright'] = 0x02BE;
  17637. t['ringhalfrightbelowcmb'] = 0x0339;
  17638. t['ringhalfrightcentered'] = 0x02D2;
  17639. t['rinvertedbreve'] = 0x0213;
  17640. t['rittorusquare'] = 0x3351;
  17641. t['rlinebelow'] = 0x1E5F;
  17642. t['rlongleg'] = 0x027C;
  17643. t['rlonglegturned'] = 0x027A;
  17644. t['rmonospace'] = 0xFF52;
  17645. t['rohiragana'] = 0x308D;
  17646. t['rokatakana'] = 0x30ED;
  17647. t['rokatakanahalfwidth'] = 0xFF9B;
  17648. t['roruathai'] = 0x0E23;
  17649. t['rparen'] = 0x24AD;
  17650. t['rrabengali'] = 0x09DC;
  17651. t['rradeva'] = 0x0931;
  17652. t['rragurmukhi'] = 0x0A5C;
  17653. t['rreharabic'] = 0x0691;
  17654. t['rrehfinalarabic'] = 0xFB8D;
  17655. t['rrvocalicbengali'] = 0x09E0;
  17656. t['rrvocalicdeva'] = 0x0960;
  17657. t['rrvocalicgujarati'] = 0x0AE0;
  17658. t['rrvocalicvowelsignbengali'] = 0x09C4;
  17659. t['rrvocalicvowelsigndeva'] = 0x0944;
  17660. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  17661. t['rsuperior'] = 0xF6F1;
  17662. t['rtblock'] = 0x2590;
  17663. t['rturned'] = 0x0279;
  17664. t['rturnedsuperior'] = 0x02B4;
  17665. t['ruhiragana'] = 0x308B;
  17666. t['rukatakana'] = 0x30EB;
  17667. t['rukatakanahalfwidth'] = 0xFF99;
  17668. t['rupeemarkbengali'] = 0x09F2;
  17669. t['rupeesignbengali'] = 0x09F3;
  17670. t['rupiah'] = 0xF6DD;
  17671. t['ruthai'] = 0x0E24;
  17672. t['rvocalicbengali'] = 0x098B;
  17673. t['rvocalicdeva'] = 0x090B;
  17674. t['rvocalicgujarati'] = 0x0A8B;
  17675. t['rvocalicvowelsignbengali'] = 0x09C3;
  17676. t['rvocalicvowelsigndeva'] = 0x0943;
  17677. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  17678. t['s'] = 0x0073;
  17679. t['sabengali'] = 0x09B8;
  17680. t['sacute'] = 0x015B;
  17681. t['sacutedotaccent'] = 0x1E65;
  17682. t['sadarabic'] = 0x0635;
  17683. t['sadeva'] = 0x0938;
  17684. t['sadfinalarabic'] = 0xFEBA;
  17685. t['sadinitialarabic'] = 0xFEBB;
  17686. t['sadmedialarabic'] = 0xFEBC;
  17687. t['sagujarati'] = 0x0AB8;
  17688. t['sagurmukhi'] = 0x0A38;
  17689. t['sahiragana'] = 0x3055;
  17690. t['sakatakana'] = 0x30B5;
  17691. t['sakatakanahalfwidth'] = 0xFF7B;
  17692. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  17693. t['samekh'] = 0x05E1;
  17694. t['samekhdagesh'] = 0xFB41;
  17695. t['samekhdageshhebrew'] = 0xFB41;
  17696. t['samekhhebrew'] = 0x05E1;
  17697. t['saraaathai'] = 0x0E32;
  17698. t['saraaethai'] = 0x0E41;
  17699. t['saraaimaimalaithai'] = 0x0E44;
  17700. t['saraaimaimuanthai'] = 0x0E43;
  17701. t['saraamthai'] = 0x0E33;
  17702. t['saraathai'] = 0x0E30;
  17703. t['saraethai'] = 0x0E40;
  17704. t['saraiileftthai'] = 0xF886;
  17705. t['saraiithai'] = 0x0E35;
  17706. t['saraileftthai'] = 0xF885;
  17707. t['saraithai'] = 0x0E34;
  17708. t['saraothai'] = 0x0E42;
  17709. t['saraueeleftthai'] = 0xF888;
  17710. t['saraueethai'] = 0x0E37;
  17711. t['saraueleftthai'] = 0xF887;
  17712. t['sarauethai'] = 0x0E36;
  17713. t['sarauthai'] = 0x0E38;
  17714. t['sarauuthai'] = 0x0E39;
  17715. t['sbopomofo'] = 0x3119;
  17716. t['scaron'] = 0x0161;
  17717. t['scarondotaccent'] = 0x1E67;
  17718. t['scedilla'] = 0x015F;
  17719. t['schwa'] = 0x0259;
  17720. t['schwacyrillic'] = 0x04D9;
  17721. t['schwadieresiscyrillic'] = 0x04DB;
  17722. t['schwahook'] = 0x025A;
  17723. t['scircle'] = 0x24E2;
  17724. t['scircumflex'] = 0x015D;
  17725. t['scommaaccent'] = 0x0219;
  17726. t['sdotaccent'] = 0x1E61;
  17727. t['sdotbelow'] = 0x1E63;
  17728. t['sdotbelowdotaccent'] = 0x1E69;
  17729. t['seagullbelowcmb'] = 0x033C;
  17730. t['second'] = 0x2033;
  17731. t['secondtonechinese'] = 0x02CA;
  17732. t['section'] = 0x00A7;
  17733. t['seenarabic'] = 0x0633;
  17734. t['seenfinalarabic'] = 0xFEB2;
  17735. t['seeninitialarabic'] = 0xFEB3;
  17736. t['seenmedialarabic'] = 0xFEB4;
  17737. t['segol'] = 0x05B6;
  17738. t['segol13'] = 0x05B6;
  17739. t['segol1f'] = 0x05B6;
  17740. t['segol2c'] = 0x05B6;
  17741. t['segolhebrew'] = 0x05B6;
  17742. t['segolnarrowhebrew'] = 0x05B6;
  17743. t['segolquarterhebrew'] = 0x05B6;
  17744. t['segoltahebrew'] = 0x0592;
  17745. t['segolwidehebrew'] = 0x05B6;
  17746. t['seharmenian'] = 0x057D;
  17747. t['sehiragana'] = 0x305B;
  17748. t['sekatakana'] = 0x30BB;
  17749. t['sekatakanahalfwidth'] = 0xFF7E;
  17750. t['semicolon'] = 0x003B;
  17751. t['semicolonarabic'] = 0x061B;
  17752. t['semicolonmonospace'] = 0xFF1B;
  17753. t['semicolonsmall'] = 0xFE54;
  17754. t['semivoicedmarkkana'] = 0x309C;
  17755. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  17756. t['sentisquare'] = 0x3322;
  17757. t['sentosquare'] = 0x3323;
  17758. t['seven'] = 0x0037;
  17759. t['sevenarabic'] = 0x0667;
  17760. t['sevenbengali'] = 0x09ED;
  17761. t['sevencircle'] = 0x2466;
  17762. t['sevencircleinversesansserif'] = 0x2790;
  17763. t['sevendeva'] = 0x096D;
  17764. t['seveneighths'] = 0x215E;
  17765. t['sevengujarati'] = 0x0AED;
  17766. t['sevengurmukhi'] = 0x0A6D;
  17767. t['sevenhackarabic'] = 0x0667;
  17768. t['sevenhangzhou'] = 0x3027;
  17769. t['sevenideographicparen'] = 0x3226;
  17770. t['seveninferior'] = 0x2087;
  17771. t['sevenmonospace'] = 0xFF17;
  17772. t['sevenoldstyle'] = 0xF737;
  17773. t['sevenparen'] = 0x247A;
  17774. t['sevenperiod'] = 0x248E;
  17775. t['sevenpersian'] = 0x06F7;
  17776. t['sevenroman'] = 0x2176;
  17777. t['sevensuperior'] = 0x2077;
  17778. t['seventeencircle'] = 0x2470;
  17779. t['seventeenparen'] = 0x2484;
  17780. t['seventeenperiod'] = 0x2498;
  17781. t['seventhai'] = 0x0E57;
  17782. t['sfthyphen'] = 0x00AD;
  17783. t['shaarmenian'] = 0x0577;
  17784. t['shabengali'] = 0x09B6;
  17785. t['shacyrillic'] = 0x0448;
  17786. t['shaddaarabic'] = 0x0651;
  17787. t['shaddadammaarabic'] = 0xFC61;
  17788. t['shaddadammatanarabic'] = 0xFC5E;
  17789. t['shaddafathaarabic'] = 0xFC60;
  17790. t['shaddakasraarabic'] = 0xFC62;
  17791. t['shaddakasratanarabic'] = 0xFC5F;
  17792. t['shade'] = 0x2592;
  17793. t['shadedark'] = 0x2593;
  17794. t['shadelight'] = 0x2591;
  17795. t['shademedium'] = 0x2592;
  17796. t['shadeva'] = 0x0936;
  17797. t['shagujarati'] = 0x0AB6;
  17798. t['shagurmukhi'] = 0x0A36;
  17799. t['shalshelethebrew'] = 0x0593;
  17800. t['shbopomofo'] = 0x3115;
  17801. t['shchacyrillic'] = 0x0449;
  17802. t['sheenarabic'] = 0x0634;
  17803. t['sheenfinalarabic'] = 0xFEB6;
  17804. t['sheeninitialarabic'] = 0xFEB7;
  17805. t['sheenmedialarabic'] = 0xFEB8;
  17806. t['sheicoptic'] = 0x03E3;
  17807. t['sheqel'] = 0x20AA;
  17808. t['sheqelhebrew'] = 0x20AA;
  17809. t['sheva'] = 0x05B0;
  17810. t['sheva115'] = 0x05B0;
  17811. t['sheva15'] = 0x05B0;
  17812. t['sheva22'] = 0x05B0;
  17813. t['sheva2e'] = 0x05B0;
  17814. t['shevahebrew'] = 0x05B0;
  17815. t['shevanarrowhebrew'] = 0x05B0;
  17816. t['shevaquarterhebrew'] = 0x05B0;
  17817. t['shevawidehebrew'] = 0x05B0;
  17818. t['shhacyrillic'] = 0x04BB;
  17819. t['shimacoptic'] = 0x03ED;
  17820. t['shin'] = 0x05E9;
  17821. t['shindagesh'] = 0xFB49;
  17822. t['shindageshhebrew'] = 0xFB49;
  17823. t['shindageshshindot'] = 0xFB2C;
  17824. t['shindageshshindothebrew'] = 0xFB2C;
  17825. t['shindageshsindot'] = 0xFB2D;
  17826. t['shindageshsindothebrew'] = 0xFB2D;
  17827. t['shindothebrew'] = 0x05C1;
  17828. t['shinhebrew'] = 0x05E9;
  17829. t['shinshindot'] = 0xFB2A;
  17830. t['shinshindothebrew'] = 0xFB2A;
  17831. t['shinsindot'] = 0xFB2B;
  17832. t['shinsindothebrew'] = 0xFB2B;
  17833. t['shook'] = 0x0282;
  17834. t['sigma'] = 0x03C3;
  17835. t['sigma1'] = 0x03C2;
  17836. t['sigmafinal'] = 0x03C2;
  17837. t['sigmalunatesymbolgreek'] = 0x03F2;
  17838. t['sihiragana'] = 0x3057;
  17839. t['sikatakana'] = 0x30B7;
  17840. t['sikatakanahalfwidth'] = 0xFF7C;
  17841. t['siluqhebrew'] = 0x05BD;
  17842. t['siluqlefthebrew'] = 0x05BD;
  17843. t['similar'] = 0x223C;
  17844. t['sindothebrew'] = 0x05C2;
  17845. t['siosacirclekorean'] = 0x3274;
  17846. t['siosaparenkorean'] = 0x3214;
  17847. t['sioscieuckorean'] = 0x317E;
  17848. t['sioscirclekorean'] = 0x3266;
  17849. t['sioskiyeokkorean'] = 0x317A;
  17850. t['sioskorean'] = 0x3145;
  17851. t['siosnieunkorean'] = 0x317B;
  17852. t['siosparenkorean'] = 0x3206;
  17853. t['siospieupkorean'] = 0x317D;
  17854. t['siostikeutkorean'] = 0x317C;
  17855. t['six'] = 0x0036;
  17856. t['sixarabic'] = 0x0666;
  17857. t['sixbengali'] = 0x09EC;
  17858. t['sixcircle'] = 0x2465;
  17859. t['sixcircleinversesansserif'] = 0x278F;
  17860. t['sixdeva'] = 0x096C;
  17861. t['sixgujarati'] = 0x0AEC;
  17862. t['sixgurmukhi'] = 0x0A6C;
  17863. t['sixhackarabic'] = 0x0666;
  17864. t['sixhangzhou'] = 0x3026;
  17865. t['sixideographicparen'] = 0x3225;
  17866. t['sixinferior'] = 0x2086;
  17867. t['sixmonospace'] = 0xFF16;
  17868. t['sixoldstyle'] = 0xF736;
  17869. t['sixparen'] = 0x2479;
  17870. t['sixperiod'] = 0x248D;
  17871. t['sixpersian'] = 0x06F6;
  17872. t['sixroman'] = 0x2175;
  17873. t['sixsuperior'] = 0x2076;
  17874. t['sixteencircle'] = 0x246F;
  17875. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17876. t['sixteenparen'] = 0x2483;
  17877. t['sixteenperiod'] = 0x2497;
  17878. t['sixthai'] = 0x0E56;
  17879. t['slash'] = 0x002F;
  17880. t['slashmonospace'] = 0xFF0F;
  17881. t['slong'] = 0x017F;
  17882. t['slongdotaccent'] = 0x1E9B;
  17883. t['smileface'] = 0x263A;
  17884. t['smonospace'] = 0xFF53;
  17885. t['sofpasuqhebrew'] = 0x05C3;
  17886. t['softhyphen'] = 0x00AD;
  17887. t['softsigncyrillic'] = 0x044C;
  17888. t['sohiragana'] = 0x305D;
  17889. t['sokatakana'] = 0x30BD;
  17890. t['sokatakanahalfwidth'] = 0xFF7F;
  17891. t['soliduslongoverlaycmb'] = 0x0338;
  17892. t['solidusshortoverlaycmb'] = 0x0337;
  17893. t['sorusithai'] = 0x0E29;
  17894. t['sosalathai'] = 0x0E28;
  17895. t['sosothai'] = 0x0E0B;
  17896. t['sosuathai'] = 0x0E2A;
  17897. t['space'] = 0x0020;
  17898. t['spacehackarabic'] = 0x0020;
  17899. t['spade'] = 0x2660;
  17900. t['spadesuitblack'] = 0x2660;
  17901. t['spadesuitwhite'] = 0x2664;
  17902. t['sparen'] = 0x24AE;
  17903. t['squarebelowcmb'] = 0x033B;
  17904. t['squarecc'] = 0x33C4;
  17905. t['squarecm'] = 0x339D;
  17906. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17907. t['squarehorizontalfill'] = 0x25A4;
  17908. t['squarekg'] = 0x338F;
  17909. t['squarekm'] = 0x339E;
  17910. t['squarekmcapital'] = 0x33CE;
  17911. t['squareln'] = 0x33D1;
  17912. t['squarelog'] = 0x33D2;
  17913. t['squaremg'] = 0x338E;
  17914. t['squaremil'] = 0x33D5;
  17915. t['squaremm'] = 0x339C;
  17916. t['squaremsquared'] = 0x33A1;
  17917. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17918. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17919. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17920. t['squareverticalfill'] = 0x25A5;
  17921. t['squarewhitewithsmallblack'] = 0x25A3;
  17922. t['srsquare'] = 0x33DB;
  17923. t['ssabengali'] = 0x09B7;
  17924. t['ssadeva'] = 0x0937;
  17925. t['ssagujarati'] = 0x0AB7;
  17926. t['ssangcieuckorean'] = 0x3149;
  17927. t['ssanghieuhkorean'] = 0x3185;
  17928. t['ssangieungkorean'] = 0x3180;
  17929. t['ssangkiyeokkorean'] = 0x3132;
  17930. t['ssangnieunkorean'] = 0x3165;
  17931. t['ssangpieupkorean'] = 0x3143;
  17932. t['ssangsioskorean'] = 0x3146;
  17933. t['ssangtikeutkorean'] = 0x3138;
  17934. t['ssuperior'] = 0xF6F2;
  17935. t['sterling'] = 0x00A3;
  17936. t['sterlingmonospace'] = 0xFFE1;
  17937. t['strokelongoverlaycmb'] = 0x0336;
  17938. t['strokeshortoverlaycmb'] = 0x0335;
  17939. t['subset'] = 0x2282;
  17940. t['subsetnotequal'] = 0x228A;
  17941. t['subsetorequal'] = 0x2286;
  17942. t['succeeds'] = 0x227B;
  17943. t['suchthat'] = 0x220B;
  17944. t['suhiragana'] = 0x3059;
  17945. t['sukatakana'] = 0x30B9;
  17946. t['sukatakanahalfwidth'] = 0xFF7D;
  17947. t['sukunarabic'] = 0x0652;
  17948. t['summation'] = 0x2211;
  17949. t['sun'] = 0x263C;
  17950. t['superset'] = 0x2283;
  17951. t['supersetnotequal'] = 0x228B;
  17952. t['supersetorequal'] = 0x2287;
  17953. t['svsquare'] = 0x33DC;
  17954. t['syouwaerasquare'] = 0x337C;
  17955. t['t'] = 0x0074;
  17956. t['tabengali'] = 0x09A4;
  17957. t['tackdown'] = 0x22A4;
  17958. t['tackleft'] = 0x22A3;
  17959. t['tadeva'] = 0x0924;
  17960. t['tagujarati'] = 0x0AA4;
  17961. t['tagurmukhi'] = 0x0A24;
  17962. t['taharabic'] = 0x0637;
  17963. t['tahfinalarabic'] = 0xFEC2;
  17964. t['tahinitialarabic'] = 0xFEC3;
  17965. t['tahiragana'] = 0x305F;
  17966. t['tahmedialarabic'] = 0xFEC4;
  17967. t['taisyouerasquare'] = 0x337D;
  17968. t['takatakana'] = 0x30BF;
  17969. t['takatakanahalfwidth'] = 0xFF80;
  17970. t['tatweelarabic'] = 0x0640;
  17971. t['tau'] = 0x03C4;
  17972. t['tav'] = 0x05EA;
  17973. t['tavdages'] = 0xFB4A;
  17974. t['tavdagesh'] = 0xFB4A;
  17975. t['tavdageshhebrew'] = 0xFB4A;
  17976. t['tavhebrew'] = 0x05EA;
  17977. t['tbar'] = 0x0167;
  17978. t['tbopomofo'] = 0x310A;
  17979. t['tcaron'] = 0x0165;
  17980. t['tccurl'] = 0x02A8;
  17981. t['tcedilla'] = 0x0163;
  17982. t['tcheharabic'] = 0x0686;
  17983. t['tchehfinalarabic'] = 0xFB7B;
  17984. t['tchehinitialarabic'] = 0xFB7C;
  17985. t['tchehmedialarabic'] = 0xFB7D;
  17986. t['tcircle'] = 0x24E3;
  17987. t['tcircumflexbelow'] = 0x1E71;
  17988. t['tcommaaccent'] = 0x0163;
  17989. t['tdieresis'] = 0x1E97;
  17990. t['tdotaccent'] = 0x1E6B;
  17991. t['tdotbelow'] = 0x1E6D;
  17992. t['tecyrillic'] = 0x0442;
  17993. t['tedescendercyrillic'] = 0x04AD;
  17994. t['teharabic'] = 0x062A;
  17995. t['tehfinalarabic'] = 0xFE96;
  17996. t['tehhahinitialarabic'] = 0xFCA2;
  17997. t['tehhahisolatedarabic'] = 0xFC0C;
  17998. t['tehinitialarabic'] = 0xFE97;
  17999. t['tehiragana'] = 0x3066;
  18000. t['tehjeeminitialarabic'] = 0xFCA1;
  18001. t['tehjeemisolatedarabic'] = 0xFC0B;
  18002. t['tehmarbutaarabic'] = 0x0629;
  18003. t['tehmarbutafinalarabic'] = 0xFE94;
  18004. t['tehmedialarabic'] = 0xFE98;
  18005. t['tehmeeminitialarabic'] = 0xFCA4;
  18006. t['tehmeemisolatedarabic'] = 0xFC0E;
  18007. t['tehnoonfinalarabic'] = 0xFC73;
  18008. t['tekatakana'] = 0x30C6;
  18009. t['tekatakanahalfwidth'] = 0xFF83;
  18010. t['telephone'] = 0x2121;
  18011. t['telephoneblack'] = 0x260E;
  18012. t['telishagedolahebrew'] = 0x05A0;
  18013. t['telishaqetanahebrew'] = 0x05A9;
  18014. t['tencircle'] = 0x2469;
  18015. t['tenideographicparen'] = 0x3229;
  18016. t['tenparen'] = 0x247D;
  18017. t['tenperiod'] = 0x2491;
  18018. t['tenroman'] = 0x2179;
  18019. t['tesh'] = 0x02A7;
  18020. t['tet'] = 0x05D8;
  18021. t['tetdagesh'] = 0xFB38;
  18022. t['tetdageshhebrew'] = 0xFB38;
  18023. t['tethebrew'] = 0x05D8;
  18024. t['tetsecyrillic'] = 0x04B5;
  18025. t['tevirhebrew'] = 0x059B;
  18026. t['tevirlefthebrew'] = 0x059B;
  18027. t['thabengali'] = 0x09A5;
  18028. t['thadeva'] = 0x0925;
  18029. t['thagujarati'] = 0x0AA5;
  18030. t['thagurmukhi'] = 0x0A25;
  18031. t['thalarabic'] = 0x0630;
  18032. t['thalfinalarabic'] = 0xFEAC;
  18033. t['thanthakhatlowleftthai'] = 0xF898;
  18034. t['thanthakhatlowrightthai'] = 0xF897;
  18035. t['thanthakhatthai'] = 0x0E4C;
  18036. t['thanthakhatupperleftthai'] = 0xF896;
  18037. t['theharabic'] = 0x062B;
  18038. t['thehfinalarabic'] = 0xFE9A;
  18039. t['thehinitialarabic'] = 0xFE9B;
  18040. t['thehmedialarabic'] = 0xFE9C;
  18041. t['thereexists'] = 0x2203;
  18042. t['therefore'] = 0x2234;
  18043. t['theta'] = 0x03B8;
  18044. t['theta1'] = 0x03D1;
  18045. t['thetasymbolgreek'] = 0x03D1;
  18046. t['thieuthacirclekorean'] = 0x3279;
  18047. t['thieuthaparenkorean'] = 0x3219;
  18048. t['thieuthcirclekorean'] = 0x326B;
  18049. t['thieuthkorean'] = 0x314C;
  18050. t['thieuthparenkorean'] = 0x320B;
  18051. t['thirteencircle'] = 0x246C;
  18052. t['thirteenparen'] = 0x2480;
  18053. t['thirteenperiod'] = 0x2494;
  18054. t['thonangmonthothai'] = 0x0E11;
  18055. t['thook'] = 0x01AD;
  18056. t['thophuthaothai'] = 0x0E12;
  18057. t['thorn'] = 0x00FE;
  18058. t['thothahanthai'] = 0x0E17;
  18059. t['thothanthai'] = 0x0E10;
  18060. t['thothongthai'] = 0x0E18;
  18061. t['thothungthai'] = 0x0E16;
  18062. t['thousandcyrillic'] = 0x0482;
  18063. t['thousandsseparatorarabic'] = 0x066C;
  18064. t['thousandsseparatorpersian'] = 0x066C;
  18065. t['three'] = 0x0033;
  18066. t['threearabic'] = 0x0663;
  18067. t['threebengali'] = 0x09E9;
  18068. t['threecircle'] = 0x2462;
  18069. t['threecircleinversesansserif'] = 0x278C;
  18070. t['threedeva'] = 0x0969;
  18071. t['threeeighths'] = 0x215C;
  18072. t['threegujarati'] = 0x0AE9;
  18073. t['threegurmukhi'] = 0x0A69;
  18074. t['threehackarabic'] = 0x0663;
  18075. t['threehangzhou'] = 0x3023;
  18076. t['threeideographicparen'] = 0x3222;
  18077. t['threeinferior'] = 0x2083;
  18078. t['threemonospace'] = 0xFF13;
  18079. t['threenumeratorbengali'] = 0x09F6;
  18080. t['threeoldstyle'] = 0xF733;
  18081. t['threeparen'] = 0x2476;
  18082. t['threeperiod'] = 0x248A;
  18083. t['threepersian'] = 0x06F3;
  18084. t['threequarters'] = 0x00BE;
  18085. t['threequartersemdash'] = 0xF6DE;
  18086. t['threeroman'] = 0x2172;
  18087. t['threesuperior'] = 0x00B3;
  18088. t['threethai'] = 0x0E53;
  18089. t['thzsquare'] = 0x3394;
  18090. t['tihiragana'] = 0x3061;
  18091. t['tikatakana'] = 0x30C1;
  18092. t['tikatakanahalfwidth'] = 0xFF81;
  18093. t['tikeutacirclekorean'] = 0x3270;
  18094. t['tikeutaparenkorean'] = 0x3210;
  18095. t['tikeutcirclekorean'] = 0x3262;
  18096. t['tikeutkorean'] = 0x3137;
  18097. t['tikeutparenkorean'] = 0x3202;
  18098. t['tilde'] = 0x02DC;
  18099. t['tildebelowcmb'] = 0x0330;
  18100. t['tildecmb'] = 0x0303;
  18101. t['tildecomb'] = 0x0303;
  18102. t['tildedoublecmb'] = 0x0360;
  18103. t['tildeoperator'] = 0x223C;
  18104. t['tildeoverlaycmb'] = 0x0334;
  18105. t['tildeverticalcmb'] = 0x033E;
  18106. t['timescircle'] = 0x2297;
  18107. t['tipehahebrew'] = 0x0596;
  18108. t['tipehalefthebrew'] = 0x0596;
  18109. t['tippigurmukhi'] = 0x0A70;
  18110. t['titlocyrilliccmb'] = 0x0483;
  18111. t['tiwnarmenian'] = 0x057F;
  18112. t['tlinebelow'] = 0x1E6F;
  18113. t['tmonospace'] = 0xFF54;
  18114. t['toarmenian'] = 0x0569;
  18115. t['tohiragana'] = 0x3068;
  18116. t['tokatakana'] = 0x30C8;
  18117. t['tokatakanahalfwidth'] = 0xFF84;
  18118. t['tonebarextrahighmod'] = 0x02E5;
  18119. t['tonebarextralowmod'] = 0x02E9;
  18120. t['tonebarhighmod'] = 0x02E6;
  18121. t['tonebarlowmod'] = 0x02E8;
  18122. t['tonebarmidmod'] = 0x02E7;
  18123. t['tonefive'] = 0x01BD;
  18124. t['tonesix'] = 0x0185;
  18125. t['tonetwo'] = 0x01A8;
  18126. t['tonos'] = 0x0384;
  18127. t['tonsquare'] = 0x3327;
  18128. t['topatakthai'] = 0x0E0F;
  18129. t['tortoiseshellbracketleft'] = 0x3014;
  18130. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  18131. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  18132. t['tortoiseshellbracketright'] = 0x3015;
  18133. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  18134. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  18135. t['totaothai'] = 0x0E15;
  18136. t['tpalatalhook'] = 0x01AB;
  18137. t['tparen'] = 0x24AF;
  18138. t['trademark'] = 0x2122;
  18139. t['trademarksans'] = 0xF8EA;
  18140. t['trademarkserif'] = 0xF6DB;
  18141. t['tretroflexhook'] = 0x0288;
  18142. t['triagdn'] = 0x25BC;
  18143. t['triaglf'] = 0x25C4;
  18144. t['triagrt'] = 0x25BA;
  18145. t['triagup'] = 0x25B2;
  18146. t['ts'] = 0x02A6;
  18147. t['tsadi'] = 0x05E6;
  18148. t['tsadidagesh'] = 0xFB46;
  18149. t['tsadidageshhebrew'] = 0xFB46;
  18150. t['tsadihebrew'] = 0x05E6;
  18151. t['tsecyrillic'] = 0x0446;
  18152. t['tsere'] = 0x05B5;
  18153. t['tsere12'] = 0x05B5;
  18154. t['tsere1e'] = 0x05B5;
  18155. t['tsere2b'] = 0x05B5;
  18156. t['tserehebrew'] = 0x05B5;
  18157. t['tserenarrowhebrew'] = 0x05B5;
  18158. t['tserequarterhebrew'] = 0x05B5;
  18159. t['tserewidehebrew'] = 0x05B5;
  18160. t['tshecyrillic'] = 0x045B;
  18161. t['tsuperior'] = 0xF6F3;
  18162. t['ttabengali'] = 0x099F;
  18163. t['ttadeva'] = 0x091F;
  18164. t['ttagujarati'] = 0x0A9F;
  18165. t['ttagurmukhi'] = 0x0A1F;
  18166. t['tteharabic'] = 0x0679;
  18167. t['ttehfinalarabic'] = 0xFB67;
  18168. t['ttehinitialarabic'] = 0xFB68;
  18169. t['ttehmedialarabic'] = 0xFB69;
  18170. t['tthabengali'] = 0x09A0;
  18171. t['tthadeva'] = 0x0920;
  18172. t['tthagujarati'] = 0x0AA0;
  18173. t['tthagurmukhi'] = 0x0A20;
  18174. t['tturned'] = 0x0287;
  18175. t['tuhiragana'] = 0x3064;
  18176. t['tukatakana'] = 0x30C4;
  18177. t['tukatakanahalfwidth'] = 0xFF82;
  18178. t['tusmallhiragana'] = 0x3063;
  18179. t['tusmallkatakana'] = 0x30C3;
  18180. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  18181. t['twelvecircle'] = 0x246B;
  18182. t['twelveparen'] = 0x247F;
  18183. t['twelveperiod'] = 0x2493;
  18184. t['twelveroman'] = 0x217B;
  18185. t['twentycircle'] = 0x2473;
  18186. t['twentyhangzhou'] = 0x5344;
  18187. t['twentyparen'] = 0x2487;
  18188. t['twentyperiod'] = 0x249B;
  18189. t['two'] = 0x0032;
  18190. t['twoarabic'] = 0x0662;
  18191. t['twobengali'] = 0x09E8;
  18192. t['twocircle'] = 0x2461;
  18193. t['twocircleinversesansserif'] = 0x278B;
  18194. t['twodeva'] = 0x0968;
  18195. t['twodotenleader'] = 0x2025;
  18196. t['twodotleader'] = 0x2025;
  18197. t['twodotleadervertical'] = 0xFE30;
  18198. t['twogujarati'] = 0x0AE8;
  18199. t['twogurmukhi'] = 0x0A68;
  18200. t['twohackarabic'] = 0x0662;
  18201. t['twohangzhou'] = 0x3022;
  18202. t['twoideographicparen'] = 0x3221;
  18203. t['twoinferior'] = 0x2082;
  18204. t['twomonospace'] = 0xFF12;
  18205. t['twonumeratorbengali'] = 0x09F5;
  18206. t['twooldstyle'] = 0xF732;
  18207. t['twoparen'] = 0x2475;
  18208. t['twoperiod'] = 0x2489;
  18209. t['twopersian'] = 0x06F2;
  18210. t['tworoman'] = 0x2171;
  18211. t['twostroke'] = 0x01BB;
  18212. t['twosuperior'] = 0x00B2;
  18213. t['twothai'] = 0x0E52;
  18214. t['twothirds'] = 0x2154;
  18215. t['u'] = 0x0075;
  18216. t['uacute'] = 0x00FA;
  18217. t['ubar'] = 0x0289;
  18218. t['ubengali'] = 0x0989;
  18219. t['ubopomofo'] = 0x3128;
  18220. t['ubreve'] = 0x016D;
  18221. t['ucaron'] = 0x01D4;
  18222. t['ucircle'] = 0x24E4;
  18223. t['ucircumflex'] = 0x00FB;
  18224. t['ucircumflexbelow'] = 0x1E77;
  18225. t['ucyrillic'] = 0x0443;
  18226. t['udattadeva'] = 0x0951;
  18227. t['udblacute'] = 0x0171;
  18228. t['udblgrave'] = 0x0215;
  18229. t['udeva'] = 0x0909;
  18230. t['udieresis'] = 0x00FC;
  18231. t['udieresisacute'] = 0x01D8;
  18232. t['udieresisbelow'] = 0x1E73;
  18233. t['udieresiscaron'] = 0x01DA;
  18234. t['udieresiscyrillic'] = 0x04F1;
  18235. t['udieresisgrave'] = 0x01DC;
  18236. t['udieresismacron'] = 0x01D6;
  18237. t['udotbelow'] = 0x1EE5;
  18238. t['ugrave'] = 0x00F9;
  18239. t['ugujarati'] = 0x0A89;
  18240. t['ugurmukhi'] = 0x0A09;
  18241. t['uhiragana'] = 0x3046;
  18242. t['uhookabove'] = 0x1EE7;
  18243. t['uhorn'] = 0x01B0;
  18244. t['uhornacute'] = 0x1EE9;
  18245. t['uhorndotbelow'] = 0x1EF1;
  18246. t['uhorngrave'] = 0x1EEB;
  18247. t['uhornhookabove'] = 0x1EED;
  18248. t['uhorntilde'] = 0x1EEF;
  18249. t['uhungarumlaut'] = 0x0171;
  18250. t['uhungarumlautcyrillic'] = 0x04F3;
  18251. t['uinvertedbreve'] = 0x0217;
  18252. t['ukatakana'] = 0x30A6;
  18253. t['ukatakanahalfwidth'] = 0xFF73;
  18254. t['ukcyrillic'] = 0x0479;
  18255. t['ukorean'] = 0x315C;
  18256. t['umacron'] = 0x016B;
  18257. t['umacroncyrillic'] = 0x04EF;
  18258. t['umacrondieresis'] = 0x1E7B;
  18259. t['umatragurmukhi'] = 0x0A41;
  18260. t['umonospace'] = 0xFF55;
  18261. t['underscore'] = 0x005F;
  18262. t['underscoredbl'] = 0x2017;
  18263. t['underscoremonospace'] = 0xFF3F;
  18264. t['underscorevertical'] = 0xFE33;
  18265. t['underscorewavy'] = 0xFE4F;
  18266. t['union'] = 0x222A;
  18267. t['universal'] = 0x2200;
  18268. t['uogonek'] = 0x0173;
  18269. t['uparen'] = 0x24B0;
  18270. t['upblock'] = 0x2580;
  18271. t['upperdothebrew'] = 0x05C4;
  18272. t['upsilon'] = 0x03C5;
  18273. t['upsilondieresis'] = 0x03CB;
  18274. t['upsilondieresistonos'] = 0x03B0;
  18275. t['upsilonlatin'] = 0x028A;
  18276. t['upsilontonos'] = 0x03CD;
  18277. t['uptackbelowcmb'] = 0x031D;
  18278. t['uptackmod'] = 0x02D4;
  18279. t['uragurmukhi'] = 0x0A73;
  18280. t['uring'] = 0x016F;
  18281. t['ushortcyrillic'] = 0x045E;
  18282. t['usmallhiragana'] = 0x3045;
  18283. t['usmallkatakana'] = 0x30A5;
  18284. t['usmallkatakanahalfwidth'] = 0xFF69;
  18285. t['ustraightcyrillic'] = 0x04AF;
  18286. t['ustraightstrokecyrillic'] = 0x04B1;
  18287. t['utilde'] = 0x0169;
  18288. t['utildeacute'] = 0x1E79;
  18289. t['utildebelow'] = 0x1E75;
  18290. t['uubengali'] = 0x098A;
  18291. t['uudeva'] = 0x090A;
  18292. t['uugujarati'] = 0x0A8A;
  18293. t['uugurmukhi'] = 0x0A0A;
  18294. t['uumatragurmukhi'] = 0x0A42;
  18295. t['uuvowelsignbengali'] = 0x09C2;
  18296. t['uuvowelsigndeva'] = 0x0942;
  18297. t['uuvowelsigngujarati'] = 0x0AC2;
  18298. t['uvowelsignbengali'] = 0x09C1;
  18299. t['uvowelsigndeva'] = 0x0941;
  18300. t['uvowelsigngujarati'] = 0x0AC1;
  18301. t['v'] = 0x0076;
  18302. t['vadeva'] = 0x0935;
  18303. t['vagujarati'] = 0x0AB5;
  18304. t['vagurmukhi'] = 0x0A35;
  18305. t['vakatakana'] = 0x30F7;
  18306. t['vav'] = 0x05D5;
  18307. t['vavdagesh'] = 0xFB35;
  18308. t['vavdagesh65'] = 0xFB35;
  18309. t['vavdageshhebrew'] = 0xFB35;
  18310. t['vavhebrew'] = 0x05D5;
  18311. t['vavholam'] = 0xFB4B;
  18312. t['vavholamhebrew'] = 0xFB4B;
  18313. t['vavvavhebrew'] = 0x05F0;
  18314. t['vavyodhebrew'] = 0x05F1;
  18315. t['vcircle'] = 0x24E5;
  18316. t['vdotbelow'] = 0x1E7F;
  18317. t['vecyrillic'] = 0x0432;
  18318. t['veharabic'] = 0x06A4;
  18319. t['vehfinalarabic'] = 0xFB6B;
  18320. t['vehinitialarabic'] = 0xFB6C;
  18321. t['vehmedialarabic'] = 0xFB6D;
  18322. t['vekatakana'] = 0x30F9;
  18323. t['venus'] = 0x2640;
  18324. t['verticalbar'] = 0x007C;
  18325. t['verticallineabovecmb'] = 0x030D;
  18326. t['verticallinebelowcmb'] = 0x0329;
  18327. t['verticallinelowmod'] = 0x02CC;
  18328. t['verticallinemod'] = 0x02C8;
  18329. t['vewarmenian'] = 0x057E;
  18330. t['vhook'] = 0x028B;
  18331. t['vikatakana'] = 0x30F8;
  18332. t['viramabengali'] = 0x09CD;
  18333. t['viramadeva'] = 0x094D;
  18334. t['viramagujarati'] = 0x0ACD;
  18335. t['visargabengali'] = 0x0983;
  18336. t['visargadeva'] = 0x0903;
  18337. t['visargagujarati'] = 0x0A83;
  18338. t['vmonospace'] = 0xFF56;
  18339. t['voarmenian'] = 0x0578;
  18340. t['voicediterationhiragana'] = 0x309E;
  18341. t['voicediterationkatakana'] = 0x30FE;
  18342. t['voicedmarkkana'] = 0x309B;
  18343. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  18344. t['vokatakana'] = 0x30FA;
  18345. t['vparen'] = 0x24B1;
  18346. t['vtilde'] = 0x1E7D;
  18347. t['vturned'] = 0x028C;
  18348. t['vuhiragana'] = 0x3094;
  18349. t['vukatakana'] = 0x30F4;
  18350. t['w'] = 0x0077;
  18351. t['wacute'] = 0x1E83;
  18352. t['waekorean'] = 0x3159;
  18353. t['wahiragana'] = 0x308F;
  18354. t['wakatakana'] = 0x30EF;
  18355. t['wakatakanahalfwidth'] = 0xFF9C;
  18356. t['wakorean'] = 0x3158;
  18357. t['wasmallhiragana'] = 0x308E;
  18358. t['wasmallkatakana'] = 0x30EE;
  18359. t['wattosquare'] = 0x3357;
  18360. t['wavedash'] = 0x301C;
  18361. t['wavyunderscorevertical'] = 0xFE34;
  18362. t['wawarabic'] = 0x0648;
  18363. t['wawfinalarabic'] = 0xFEEE;
  18364. t['wawhamzaabovearabic'] = 0x0624;
  18365. t['wawhamzaabovefinalarabic'] = 0xFE86;
  18366. t['wbsquare'] = 0x33DD;
  18367. t['wcircle'] = 0x24E6;
  18368. t['wcircumflex'] = 0x0175;
  18369. t['wdieresis'] = 0x1E85;
  18370. t['wdotaccent'] = 0x1E87;
  18371. t['wdotbelow'] = 0x1E89;
  18372. t['wehiragana'] = 0x3091;
  18373. t['weierstrass'] = 0x2118;
  18374. t['wekatakana'] = 0x30F1;
  18375. t['wekorean'] = 0x315E;
  18376. t['weokorean'] = 0x315D;
  18377. t['wgrave'] = 0x1E81;
  18378. t['whitebullet'] = 0x25E6;
  18379. t['whitecircle'] = 0x25CB;
  18380. t['whitecircleinverse'] = 0x25D9;
  18381. t['whitecornerbracketleft'] = 0x300E;
  18382. t['whitecornerbracketleftvertical'] = 0xFE43;
  18383. t['whitecornerbracketright'] = 0x300F;
  18384. t['whitecornerbracketrightvertical'] = 0xFE44;
  18385. t['whitediamond'] = 0x25C7;
  18386. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  18387. t['whitedownpointingsmalltriangle'] = 0x25BF;
  18388. t['whitedownpointingtriangle'] = 0x25BD;
  18389. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  18390. t['whiteleftpointingtriangle'] = 0x25C1;
  18391. t['whitelenticularbracketleft'] = 0x3016;
  18392. t['whitelenticularbracketright'] = 0x3017;
  18393. t['whiterightpointingsmalltriangle'] = 0x25B9;
  18394. t['whiterightpointingtriangle'] = 0x25B7;
  18395. t['whitesmallsquare'] = 0x25AB;
  18396. t['whitesmilingface'] = 0x263A;
  18397. t['whitesquare'] = 0x25A1;
  18398. t['whitestar'] = 0x2606;
  18399. t['whitetelephone'] = 0x260F;
  18400. t['whitetortoiseshellbracketleft'] = 0x3018;
  18401. t['whitetortoiseshellbracketright'] = 0x3019;
  18402. t['whiteuppointingsmalltriangle'] = 0x25B5;
  18403. t['whiteuppointingtriangle'] = 0x25B3;
  18404. t['wihiragana'] = 0x3090;
  18405. t['wikatakana'] = 0x30F0;
  18406. t['wikorean'] = 0x315F;
  18407. t['wmonospace'] = 0xFF57;
  18408. t['wohiragana'] = 0x3092;
  18409. t['wokatakana'] = 0x30F2;
  18410. t['wokatakanahalfwidth'] = 0xFF66;
  18411. t['won'] = 0x20A9;
  18412. t['wonmonospace'] = 0xFFE6;
  18413. t['wowaenthai'] = 0x0E27;
  18414. t['wparen'] = 0x24B2;
  18415. t['wring'] = 0x1E98;
  18416. t['wsuperior'] = 0x02B7;
  18417. t['wturned'] = 0x028D;
  18418. t['wynn'] = 0x01BF;
  18419. t['x'] = 0x0078;
  18420. t['xabovecmb'] = 0x033D;
  18421. t['xbopomofo'] = 0x3112;
  18422. t['xcircle'] = 0x24E7;
  18423. t['xdieresis'] = 0x1E8D;
  18424. t['xdotaccent'] = 0x1E8B;
  18425. t['xeharmenian'] = 0x056D;
  18426. t['xi'] = 0x03BE;
  18427. t['xmonospace'] = 0xFF58;
  18428. t['xparen'] = 0x24B3;
  18429. t['xsuperior'] = 0x02E3;
  18430. t['y'] = 0x0079;
  18431. t['yaadosquare'] = 0x334E;
  18432. t['yabengali'] = 0x09AF;
  18433. t['yacute'] = 0x00FD;
  18434. t['yadeva'] = 0x092F;
  18435. t['yaekorean'] = 0x3152;
  18436. t['yagujarati'] = 0x0AAF;
  18437. t['yagurmukhi'] = 0x0A2F;
  18438. t['yahiragana'] = 0x3084;
  18439. t['yakatakana'] = 0x30E4;
  18440. t['yakatakanahalfwidth'] = 0xFF94;
  18441. t['yakorean'] = 0x3151;
  18442. t['yamakkanthai'] = 0x0E4E;
  18443. t['yasmallhiragana'] = 0x3083;
  18444. t['yasmallkatakana'] = 0x30E3;
  18445. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  18446. t['yatcyrillic'] = 0x0463;
  18447. t['ycircle'] = 0x24E8;
  18448. t['ycircumflex'] = 0x0177;
  18449. t['ydieresis'] = 0x00FF;
  18450. t['ydotaccent'] = 0x1E8F;
  18451. t['ydotbelow'] = 0x1EF5;
  18452. t['yeharabic'] = 0x064A;
  18453. t['yehbarreearabic'] = 0x06D2;
  18454. t['yehbarreefinalarabic'] = 0xFBAF;
  18455. t['yehfinalarabic'] = 0xFEF2;
  18456. t['yehhamzaabovearabic'] = 0x0626;
  18457. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  18458. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  18459. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  18460. t['yehinitialarabic'] = 0xFEF3;
  18461. t['yehmedialarabic'] = 0xFEF4;
  18462. t['yehmeeminitialarabic'] = 0xFCDD;
  18463. t['yehmeemisolatedarabic'] = 0xFC58;
  18464. t['yehnoonfinalarabic'] = 0xFC94;
  18465. t['yehthreedotsbelowarabic'] = 0x06D1;
  18466. t['yekorean'] = 0x3156;
  18467. t['yen'] = 0x00A5;
  18468. t['yenmonospace'] = 0xFFE5;
  18469. t['yeokorean'] = 0x3155;
  18470. t['yeorinhieuhkorean'] = 0x3186;
  18471. t['yerahbenyomohebrew'] = 0x05AA;
  18472. t['yerahbenyomolefthebrew'] = 0x05AA;
  18473. t['yericyrillic'] = 0x044B;
  18474. t['yerudieresiscyrillic'] = 0x04F9;
  18475. t['yesieungkorean'] = 0x3181;
  18476. t['yesieungpansioskorean'] = 0x3183;
  18477. t['yesieungsioskorean'] = 0x3182;
  18478. t['yetivhebrew'] = 0x059A;
  18479. t['ygrave'] = 0x1EF3;
  18480. t['yhook'] = 0x01B4;
  18481. t['yhookabove'] = 0x1EF7;
  18482. t['yiarmenian'] = 0x0575;
  18483. t['yicyrillic'] = 0x0457;
  18484. t['yikorean'] = 0x3162;
  18485. t['yinyang'] = 0x262F;
  18486. t['yiwnarmenian'] = 0x0582;
  18487. t['ymonospace'] = 0xFF59;
  18488. t['yod'] = 0x05D9;
  18489. t['yoddagesh'] = 0xFB39;
  18490. t['yoddageshhebrew'] = 0xFB39;
  18491. t['yodhebrew'] = 0x05D9;
  18492. t['yodyodhebrew'] = 0x05F2;
  18493. t['yodyodpatahhebrew'] = 0xFB1F;
  18494. t['yohiragana'] = 0x3088;
  18495. t['yoikorean'] = 0x3189;
  18496. t['yokatakana'] = 0x30E8;
  18497. t['yokatakanahalfwidth'] = 0xFF96;
  18498. t['yokorean'] = 0x315B;
  18499. t['yosmallhiragana'] = 0x3087;
  18500. t['yosmallkatakana'] = 0x30E7;
  18501. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  18502. t['yotgreek'] = 0x03F3;
  18503. t['yoyaekorean'] = 0x3188;
  18504. t['yoyakorean'] = 0x3187;
  18505. t['yoyakthai'] = 0x0E22;
  18506. t['yoyingthai'] = 0x0E0D;
  18507. t['yparen'] = 0x24B4;
  18508. t['ypogegrammeni'] = 0x037A;
  18509. t['ypogegrammenigreekcmb'] = 0x0345;
  18510. t['yr'] = 0x01A6;
  18511. t['yring'] = 0x1E99;
  18512. t['ysuperior'] = 0x02B8;
  18513. t['ytilde'] = 0x1EF9;
  18514. t['yturned'] = 0x028E;
  18515. t['yuhiragana'] = 0x3086;
  18516. t['yuikorean'] = 0x318C;
  18517. t['yukatakana'] = 0x30E6;
  18518. t['yukatakanahalfwidth'] = 0xFF95;
  18519. t['yukorean'] = 0x3160;
  18520. t['yusbigcyrillic'] = 0x046B;
  18521. t['yusbigiotifiedcyrillic'] = 0x046D;
  18522. t['yuslittlecyrillic'] = 0x0467;
  18523. t['yuslittleiotifiedcyrillic'] = 0x0469;
  18524. t['yusmallhiragana'] = 0x3085;
  18525. t['yusmallkatakana'] = 0x30E5;
  18526. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  18527. t['yuyekorean'] = 0x318B;
  18528. t['yuyeokorean'] = 0x318A;
  18529. t['yyabengali'] = 0x09DF;
  18530. t['yyadeva'] = 0x095F;
  18531. t['z'] = 0x007A;
  18532. t['zaarmenian'] = 0x0566;
  18533. t['zacute'] = 0x017A;
  18534. t['zadeva'] = 0x095B;
  18535. t['zagurmukhi'] = 0x0A5B;
  18536. t['zaharabic'] = 0x0638;
  18537. t['zahfinalarabic'] = 0xFEC6;
  18538. t['zahinitialarabic'] = 0xFEC7;
  18539. t['zahiragana'] = 0x3056;
  18540. t['zahmedialarabic'] = 0xFEC8;
  18541. t['zainarabic'] = 0x0632;
  18542. t['zainfinalarabic'] = 0xFEB0;
  18543. t['zakatakana'] = 0x30B6;
  18544. t['zaqefgadolhebrew'] = 0x0595;
  18545. t['zaqefqatanhebrew'] = 0x0594;
  18546. t['zarqahebrew'] = 0x0598;
  18547. t['zayin'] = 0x05D6;
  18548. t['zayindagesh'] = 0xFB36;
  18549. t['zayindageshhebrew'] = 0xFB36;
  18550. t['zayinhebrew'] = 0x05D6;
  18551. t['zbopomofo'] = 0x3117;
  18552. t['zcaron'] = 0x017E;
  18553. t['zcircle'] = 0x24E9;
  18554. t['zcircumflex'] = 0x1E91;
  18555. t['zcurl'] = 0x0291;
  18556. t['zdot'] = 0x017C;
  18557. t['zdotaccent'] = 0x017C;
  18558. t['zdotbelow'] = 0x1E93;
  18559. t['zecyrillic'] = 0x0437;
  18560. t['zedescendercyrillic'] = 0x0499;
  18561. t['zedieresiscyrillic'] = 0x04DF;
  18562. t['zehiragana'] = 0x305C;
  18563. t['zekatakana'] = 0x30BC;
  18564. t['zero'] = 0x0030;
  18565. t['zeroarabic'] = 0x0660;
  18566. t['zerobengali'] = 0x09E6;
  18567. t['zerodeva'] = 0x0966;
  18568. t['zerogujarati'] = 0x0AE6;
  18569. t['zerogurmukhi'] = 0x0A66;
  18570. t['zerohackarabic'] = 0x0660;
  18571. t['zeroinferior'] = 0x2080;
  18572. t['zeromonospace'] = 0xFF10;
  18573. t['zerooldstyle'] = 0xF730;
  18574. t['zeropersian'] = 0x06F0;
  18575. t['zerosuperior'] = 0x2070;
  18576. t['zerothai'] = 0x0E50;
  18577. t['zerowidthjoiner'] = 0xFEFF;
  18578. t['zerowidthnonjoiner'] = 0x200C;
  18579. t['zerowidthspace'] = 0x200B;
  18580. t['zeta'] = 0x03B6;
  18581. t['zhbopomofo'] = 0x3113;
  18582. t['zhearmenian'] = 0x056A;
  18583. t['zhebrevecyrillic'] = 0x04C2;
  18584. t['zhecyrillic'] = 0x0436;
  18585. t['zhedescendercyrillic'] = 0x0497;
  18586. t['zhedieresiscyrillic'] = 0x04DD;
  18587. t['zihiragana'] = 0x3058;
  18588. t['zikatakana'] = 0x30B8;
  18589. t['zinorhebrew'] = 0x05AE;
  18590. t['zlinebelow'] = 0x1E95;
  18591. t['zmonospace'] = 0xFF5A;
  18592. t['zohiragana'] = 0x305E;
  18593. t['zokatakana'] = 0x30BE;
  18594. t['zparen'] = 0x24B5;
  18595. t['zretroflexhook'] = 0x0290;
  18596. t['zstroke'] = 0x01B6;
  18597. t['zuhiragana'] = 0x305A;
  18598. t['zukatakana'] = 0x30BA;
  18599. t['.notdef'] = 0x0000;
  18600. t['angbracketleftbig'] = 0x2329;
  18601. t['angbracketleftBig'] = 0x2329;
  18602. t['angbracketleftbigg'] = 0x2329;
  18603. t['angbracketleftBigg'] = 0x2329;
  18604. t['angbracketrightBig'] = 0x232A;
  18605. t['angbracketrightbig'] = 0x232A;
  18606. t['angbracketrightBigg'] = 0x232A;
  18607. t['angbracketrightbigg'] = 0x232A;
  18608. t['arrowhookleft'] = 0x21AA;
  18609. t['arrowhookright'] = 0x21A9;
  18610. t['arrowlefttophalf'] = 0x21BC;
  18611. t['arrowleftbothalf'] = 0x21BD;
  18612. t['arrownortheast'] = 0x2197;
  18613. t['arrownorthwest'] = 0x2196;
  18614. t['arrowrighttophalf'] = 0x21C0;
  18615. t['arrowrightbothalf'] = 0x21C1;
  18616. t['arrowsoutheast'] = 0x2198;
  18617. t['arrowsouthwest'] = 0x2199;
  18618. t['backslashbig'] = 0x2216;
  18619. t['backslashBig'] = 0x2216;
  18620. t['backslashBigg'] = 0x2216;
  18621. t['backslashbigg'] = 0x2216;
  18622. t['bardbl'] = 0x2016;
  18623. t['bracehtipdownleft'] = 0xFE37;
  18624. t['bracehtipdownright'] = 0xFE37;
  18625. t['bracehtipupleft'] = 0xFE38;
  18626. t['bracehtipupright'] = 0xFE38;
  18627. t['braceleftBig'] = 0x007B;
  18628. t['braceleftbig'] = 0x007B;
  18629. t['braceleftbigg'] = 0x007B;
  18630. t['braceleftBigg'] = 0x007B;
  18631. t['bracerightBig'] = 0x007D;
  18632. t['bracerightbig'] = 0x007D;
  18633. t['bracerightbigg'] = 0x007D;
  18634. t['bracerightBigg'] = 0x007D;
  18635. t['bracketleftbig'] = 0x005B;
  18636. t['bracketleftBig'] = 0x005B;
  18637. t['bracketleftbigg'] = 0x005B;
  18638. t['bracketleftBigg'] = 0x005B;
  18639. t['bracketrightBig'] = 0x005D;
  18640. t['bracketrightbig'] = 0x005D;
  18641. t['bracketrightbigg'] = 0x005D;
  18642. t['bracketrightBigg'] = 0x005D;
  18643. t['ceilingleftbig'] = 0x2308;
  18644. t['ceilingleftBig'] = 0x2308;
  18645. t['ceilingleftBigg'] = 0x2308;
  18646. t['ceilingleftbigg'] = 0x2308;
  18647. t['ceilingrightbig'] = 0x2309;
  18648. t['ceilingrightBig'] = 0x2309;
  18649. t['ceilingrightbigg'] = 0x2309;
  18650. t['ceilingrightBigg'] = 0x2309;
  18651. t['circledotdisplay'] = 0x2299;
  18652. t['circledottext'] = 0x2299;
  18653. t['circlemultiplydisplay'] = 0x2297;
  18654. t['circlemultiplytext'] = 0x2297;
  18655. t['circleplusdisplay'] = 0x2295;
  18656. t['circleplustext'] = 0x2295;
  18657. t['contintegraldisplay'] = 0x222E;
  18658. t['contintegraltext'] = 0x222E;
  18659. t['coproductdisplay'] = 0x2210;
  18660. t['coproducttext'] = 0x2210;
  18661. t['floorleftBig'] = 0x230A;
  18662. t['floorleftbig'] = 0x230A;
  18663. t['floorleftbigg'] = 0x230A;
  18664. t['floorleftBigg'] = 0x230A;
  18665. t['floorrightbig'] = 0x230B;
  18666. t['floorrightBig'] = 0x230B;
  18667. t['floorrightBigg'] = 0x230B;
  18668. t['floorrightbigg'] = 0x230B;
  18669. t['hatwide'] = 0x0302;
  18670. t['hatwider'] = 0x0302;
  18671. t['hatwidest'] = 0x0302;
  18672. t['intercal'] = 0x1D40;
  18673. t['integraldisplay'] = 0x222B;
  18674. t['integraltext'] = 0x222B;
  18675. t['intersectiondisplay'] = 0x22C2;
  18676. t['intersectiontext'] = 0x22C2;
  18677. t['logicalanddisplay'] = 0x2227;
  18678. t['logicalandtext'] = 0x2227;
  18679. t['logicalordisplay'] = 0x2228;
  18680. t['logicalortext'] = 0x2228;
  18681. t['parenleftBig'] = 0x0028;
  18682. t['parenleftbig'] = 0x0028;
  18683. t['parenleftBigg'] = 0x0028;
  18684. t['parenleftbigg'] = 0x0028;
  18685. t['parenrightBig'] = 0x0029;
  18686. t['parenrightbig'] = 0x0029;
  18687. t['parenrightBigg'] = 0x0029;
  18688. t['parenrightbigg'] = 0x0029;
  18689. t['prime'] = 0x2032;
  18690. t['productdisplay'] = 0x220F;
  18691. t['producttext'] = 0x220F;
  18692. t['radicalbig'] = 0x221A;
  18693. t['radicalBig'] = 0x221A;
  18694. t['radicalBigg'] = 0x221A;
  18695. t['radicalbigg'] = 0x221A;
  18696. t['radicalbt'] = 0x221A;
  18697. t['radicaltp'] = 0x221A;
  18698. t['radicalvertex'] = 0x221A;
  18699. t['slashbig'] = 0x002F;
  18700. t['slashBig'] = 0x002F;
  18701. t['slashBigg'] = 0x002F;
  18702. t['slashbigg'] = 0x002F;
  18703. t['summationdisplay'] = 0x2211;
  18704. t['summationtext'] = 0x2211;
  18705. t['tildewide'] = 0x02DC;
  18706. t['tildewider'] = 0x02DC;
  18707. t['tildewidest'] = 0x02DC;
  18708. t['uniondisplay'] = 0x22C3;
  18709. t['unionmultidisplay'] = 0x228E;
  18710. t['unionmultitext'] = 0x228E;
  18711. t['unionsqdisplay'] = 0x2294;
  18712. t['unionsqtext'] = 0x2294;
  18713. t['uniontext'] = 0x22C3;
  18714. t['vextenddouble'] = 0x2225;
  18715. t['vextendsingle'] = 0x2223;
  18716. });
  18717. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  18718. t['space'] = 0x0020;
  18719. t['a1'] = 0x2701;
  18720. t['a2'] = 0x2702;
  18721. t['a202'] = 0x2703;
  18722. t['a3'] = 0x2704;
  18723. t['a4'] = 0x260E;
  18724. t['a5'] = 0x2706;
  18725. t['a119'] = 0x2707;
  18726. t['a118'] = 0x2708;
  18727. t['a117'] = 0x2709;
  18728. t['a11'] = 0x261B;
  18729. t['a12'] = 0x261E;
  18730. t['a13'] = 0x270C;
  18731. t['a14'] = 0x270D;
  18732. t['a15'] = 0x270E;
  18733. t['a16'] = 0x270F;
  18734. t['a105'] = 0x2710;
  18735. t['a17'] = 0x2711;
  18736. t['a18'] = 0x2712;
  18737. t['a19'] = 0x2713;
  18738. t['a20'] = 0x2714;
  18739. t['a21'] = 0x2715;
  18740. t['a22'] = 0x2716;
  18741. t['a23'] = 0x2717;
  18742. t['a24'] = 0x2718;
  18743. t['a25'] = 0x2719;
  18744. t['a26'] = 0x271A;
  18745. t['a27'] = 0x271B;
  18746. t['a28'] = 0x271C;
  18747. t['a6'] = 0x271D;
  18748. t['a7'] = 0x271E;
  18749. t['a8'] = 0x271F;
  18750. t['a9'] = 0x2720;
  18751. t['a10'] = 0x2721;
  18752. t['a29'] = 0x2722;
  18753. t['a30'] = 0x2723;
  18754. t['a31'] = 0x2724;
  18755. t['a32'] = 0x2725;
  18756. t['a33'] = 0x2726;
  18757. t['a34'] = 0x2727;
  18758. t['a35'] = 0x2605;
  18759. t['a36'] = 0x2729;
  18760. t['a37'] = 0x272A;
  18761. t['a38'] = 0x272B;
  18762. t['a39'] = 0x272C;
  18763. t['a40'] = 0x272D;
  18764. t['a41'] = 0x272E;
  18765. t['a42'] = 0x272F;
  18766. t['a43'] = 0x2730;
  18767. t['a44'] = 0x2731;
  18768. t['a45'] = 0x2732;
  18769. t['a46'] = 0x2733;
  18770. t['a47'] = 0x2734;
  18771. t['a48'] = 0x2735;
  18772. t['a49'] = 0x2736;
  18773. t['a50'] = 0x2737;
  18774. t['a51'] = 0x2738;
  18775. t['a52'] = 0x2739;
  18776. t['a53'] = 0x273A;
  18777. t['a54'] = 0x273B;
  18778. t['a55'] = 0x273C;
  18779. t['a56'] = 0x273D;
  18780. t['a57'] = 0x273E;
  18781. t['a58'] = 0x273F;
  18782. t['a59'] = 0x2740;
  18783. t['a60'] = 0x2741;
  18784. t['a61'] = 0x2742;
  18785. t['a62'] = 0x2743;
  18786. t['a63'] = 0x2744;
  18787. t['a64'] = 0x2745;
  18788. t['a65'] = 0x2746;
  18789. t['a66'] = 0x2747;
  18790. t['a67'] = 0x2748;
  18791. t['a68'] = 0x2749;
  18792. t['a69'] = 0x274A;
  18793. t['a70'] = 0x274B;
  18794. t['a71'] = 0x25CF;
  18795. t['a72'] = 0x274D;
  18796. t['a73'] = 0x25A0;
  18797. t['a74'] = 0x274F;
  18798. t['a203'] = 0x2750;
  18799. t['a75'] = 0x2751;
  18800. t['a204'] = 0x2752;
  18801. t['a76'] = 0x25B2;
  18802. t['a77'] = 0x25BC;
  18803. t['a78'] = 0x25C6;
  18804. t['a79'] = 0x2756;
  18805. t['a81'] = 0x25D7;
  18806. t['a82'] = 0x2758;
  18807. t['a83'] = 0x2759;
  18808. t['a84'] = 0x275A;
  18809. t['a97'] = 0x275B;
  18810. t['a98'] = 0x275C;
  18811. t['a99'] = 0x275D;
  18812. t['a100'] = 0x275E;
  18813. t['a101'] = 0x2761;
  18814. t['a102'] = 0x2762;
  18815. t['a103'] = 0x2763;
  18816. t['a104'] = 0x2764;
  18817. t['a106'] = 0x2765;
  18818. t['a107'] = 0x2766;
  18819. t['a108'] = 0x2767;
  18820. t['a112'] = 0x2663;
  18821. t['a111'] = 0x2666;
  18822. t['a110'] = 0x2665;
  18823. t['a109'] = 0x2660;
  18824. t['a120'] = 0x2460;
  18825. t['a121'] = 0x2461;
  18826. t['a122'] = 0x2462;
  18827. t['a123'] = 0x2463;
  18828. t['a124'] = 0x2464;
  18829. t['a125'] = 0x2465;
  18830. t['a126'] = 0x2466;
  18831. t['a127'] = 0x2467;
  18832. t['a128'] = 0x2468;
  18833. t['a129'] = 0x2469;
  18834. t['a130'] = 0x2776;
  18835. t['a131'] = 0x2777;
  18836. t['a132'] = 0x2778;
  18837. t['a133'] = 0x2779;
  18838. t['a134'] = 0x277A;
  18839. t['a135'] = 0x277B;
  18840. t['a136'] = 0x277C;
  18841. t['a137'] = 0x277D;
  18842. t['a138'] = 0x277E;
  18843. t['a139'] = 0x277F;
  18844. t['a140'] = 0x2780;
  18845. t['a141'] = 0x2781;
  18846. t['a142'] = 0x2782;
  18847. t['a143'] = 0x2783;
  18848. t['a144'] = 0x2784;
  18849. t['a145'] = 0x2785;
  18850. t['a146'] = 0x2786;
  18851. t['a147'] = 0x2787;
  18852. t['a148'] = 0x2788;
  18853. t['a149'] = 0x2789;
  18854. t['a150'] = 0x278A;
  18855. t['a151'] = 0x278B;
  18856. t['a152'] = 0x278C;
  18857. t['a153'] = 0x278D;
  18858. t['a154'] = 0x278E;
  18859. t['a155'] = 0x278F;
  18860. t['a156'] = 0x2790;
  18861. t['a157'] = 0x2791;
  18862. t['a158'] = 0x2792;
  18863. t['a159'] = 0x2793;
  18864. t['a160'] = 0x2794;
  18865. t['a161'] = 0x2192;
  18866. t['a163'] = 0x2194;
  18867. t['a164'] = 0x2195;
  18868. t['a196'] = 0x2798;
  18869. t['a165'] = 0x2799;
  18870. t['a192'] = 0x279A;
  18871. t['a166'] = 0x279B;
  18872. t['a167'] = 0x279C;
  18873. t['a168'] = 0x279D;
  18874. t['a169'] = 0x279E;
  18875. t['a170'] = 0x279F;
  18876. t['a171'] = 0x27A0;
  18877. t['a172'] = 0x27A1;
  18878. t['a173'] = 0x27A2;
  18879. t['a162'] = 0x27A3;
  18880. t['a174'] = 0x27A4;
  18881. t['a175'] = 0x27A5;
  18882. t['a176'] = 0x27A6;
  18883. t['a177'] = 0x27A7;
  18884. t['a178'] = 0x27A8;
  18885. t['a179'] = 0x27A9;
  18886. t['a193'] = 0x27AA;
  18887. t['a180'] = 0x27AB;
  18888. t['a199'] = 0x27AC;
  18889. t['a181'] = 0x27AD;
  18890. t['a200'] = 0x27AE;
  18891. t['a182'] = 0x27AF;
  18892. t['a201'] = 0x27B1;
  18893. t['a183'] = 0x27B2;
  18894. t['a184'] = 0x27B3;
  18895. t['a197'] = 0x27B4;
  18896. t['a185'] = 0x27B5;
  18897. t['a194'] = 0x27B6;
  18898. t['a198'] = 0x27B7;
  18899. t['a186'] = 0x27B8;
  18900. t['a195'] = 0x27B9;
  18901. t['a187'] = 0x27BA;
  18902. t['a188'] = 0x27BB;
  18903. t['a189'] = 0x27BC;
  18904. t['a190'] = 0x27BD;
  18905. t['a191'] = 0x27BE;
  18906. t['a89'] = 0x2768;
  18907. t['a90'] = 0x2769;
  18908. t['a93'] = 0x276A;
  18909. t['a94'] = 0x276B;
  18910. t['a91'] = 0x276C;
  18911. t['a92'] = 0x276D;
  18912. t['a205'] = 0x276E;
  18913. t['a85'] = 0x276F;
  18914. t['a206'] = 0x2770;
  18915. t['a86'] = 0x2771;
  18916. t['a87'] = 0x2772;
  18917. t['a88'] = 0x2773;
  18918. t['a95'] = 0x2774;
  18919. t['a96'] = 0x2775;
  18920. t['.notdef'] = 0x0000;
  18921. });
  18922. exports.getGlyphsUnicode = getGlyphsUnicode;
  18923. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18924. /***/ }),
  18925. /* 9 */
  18926. /***/ (function(module, exports, __w_pdfjs_require__) {
  18927. "use strict";
  18928. var sharedUtil = __w_pdfjs_require__(0);
  18929. var displayDOMUtils = __w_pdfjs_require__(3);
  18930. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18931. var AnnotationType = sharedUtil.AnnotationType;
  18932. var stringToPDFString = sharedUtil.stringToPDFString;
  18933. var Util = sharedUtil.Util;
  18934. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18935. var LinkTarget = displayDOMUtils.LinkTarget;
  18936. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18937. var warn = sharedUtil.warn;
  18938. var CustomStyle = displayDOMUtils.CustomStyle;
  18939. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18940. function AnnotationElementFactory() {
  18941. }
  18942. AnnotationElementFactory.prototype = {
  18943. create: function AnnotationElementFactory_create(parameters) {
  18944. var subtype = parameters.data.annotationType;
  18945. switch (subtype) {
  18946. case AnnotationType.LINK:
  18947. return new LinkAnnotationElement(parameters);
  18948. case AnnotationType.TEXT:
  18949. return new TextAnnotationElement(parameters);
  18950. case AnnotationType.WIDGET:
  18951. var fieldType = parameters.data.fieldType;
  18952. switch (fieldType) {
  18953. case 'Tx':
  18954. return new TextWidgetAnnotationElement(parameters);
  18955. case 'Btn':
  18956. if (parameters.data.radioButton) {
  18957. return new RadioButtonWidgetAnnotationElement(parameters);
  18958. } else if (parameters.data.checkBox) {
  18959. return new CheckboxWidgetAnnotationElement(parameters);
  18960. }
  18961. warn('Unimplemented button widget annotation: pushbutton');
  18962. break;
  18963. case 'Ch':
  18964. return new ChoiceWidgetAnnotationElement(parameters);
  18965. }
  18966. return new WidgetAnnotationElement(parameters);
  18967. case AnnotationType.POPUP:
  18968. return new PopupAnnotationElement(parameters);
  18969. case AnnotationType.HIGHLIGHT:
  18970. return new HighlightAnnotationElement(parameters);
  18971. case AnnotationType.UNDERLINE:
  18972. return new UnderlineAnnotationElement(parameters);
  18973. case AnnotationType.SQUIGGLY:
  18974. return new SquigglyAnnotationElement(parameters);
  18975. case AnnotationType.STRIKEOUT:
  18976. return new StrikeOutAnnotationElement(parameters);
  18977. case AnnotationType.FILEATTACHMENT:
  18978. return new FileAttachmentAnnotationElement(parameters);
  18979. default:
  18980. return new AnnotationElement(parameters);
  18981. }
  18982. }
  18983. };
  18984. var AnnotationElement = function AnnotationElementClosure() {
  18985. function AnnotationElement(parameters, isRenderable) {
  18986. this.isRenderable = isRenderable || false;
  18987. this.data = parameters.data;
  18988. this.layer = parameters.layer;
  18989. this.page = parameters.page;
  18990. this.viewport = parameters.viewport;
  18991. this.linkService = parameters.linkService;
  18992. this.downloadManager = parameters.downloadManager;
  18993. this.imageResourcesPath = parameters.imageResourcesPath;
  18994. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18995. if (isRenderable) {
  18996. this.container = this._createContainer();
  18997. }
  18998. }
  18999. AnnotationElement.prototype = {
  19000. _createContainer: function AnnotationElement_createContainer() {
  19001. var data = this.data, page = this.page, viewport = this.viewport;
  19002. var container = document.createElement('section');
  19003. var width = data.rect[2] - data.rect[0];
  19004. var height = data.rect[3] - data.rect[1];
  19005. container.setAttribute('data-annotation-id', data.id);
  19006. var rect = Util.normalizeRect([
  19007. data.rect[0],
  19008. page.view[3] - data.rect[1] + page.view[1],
  19009. data.rect[2],
  19010. page.view[3] - data.rect[3] + page.view[1]
  19011. ]);
  19012. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  19013. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  19014. if (data.borderStyle.width > 0) {
  19015. container.style.borderWidth = data.borderStyle.width + 'px';
  19016. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  19017. width = width - 2 * data.borderStyle.width;
  19018. height = height - 2 * data.borderStyle.width;
  19019. }
  19020. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  19021. var verticalRadius = data.borderStyle.verticalCornerRadius;
  19022. if (horizontalRadius > 0 || verticalRadius > 0) {
  19023. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  19024. CustomStyle.setProp('borderRadius', container, radius);
  19025. }
  19026. switch (data.borderStyle.style) {
  19027. case AnnotationBorderStyleType.SOLID:
  19028. container.style.borderStyle = 'solid';
  19029. break;
  19030. case AnnotationBorderStyleType.DASHED:
  19031. container.style.borderStyle = 'dashed';
  19032. break;
  19033. case AnnotationBorderStyleType.BEVELED:
  19034. warn('Unimplemented border style: beveled');
  19035. break;
  19036. case AnnotationBorderStyleType.INSET:
  19037. warn('Unimplemented border style: inset');
  19038. break;
  19039. case AnnotationBorderStyleType.UNDERLINE:
  19040. container.style.borderBottomStyle = 'solid';
  19041. break;
  19042. default:
  19043. break;
  19044. }
  19045. if (data.color) {
  19046. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  19047. } else {
  19048. container.style.borderWidth = 0;
  19049. }
  19050. }
  19051. container.style.left = rect[0] + 'px';
  19052. container.style.top = rect[1] + 'px';
  19053. container.style.width = width + 'px';
  19054. container.style.height = height + 'px';
  19055. return container;
  19056. },
  19057. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19058. if (!trigger) {
  19059. trigger = document.createElement('div');
  19060. trigger.style.height = container.style.height;
  19061. trigger.style.width = container.style.width;
  19062. container.appendChild(trigger);
  19063. }
  19064. var popupElement = new PopupElement({
  19065. container: container,
  19066. trigger: trigger,
  19067. color: data.color,
  19068. title: data.title,
  19069. contents: data.contents,
  19070. hideWrapper: true
  19071. });
  19072. var popup = popupElement.render();
  19073. popup.style.left = container.style.width;
  19074. container.appendChild(popup);
  19075. },
  19076. render: function AnnotationElement_render() {
  19077. throw new Error('Abstract method AnnotationElement.render called');
  19078. }
  19079. };
  19080. return AnnotationElement;
  19081. }();
  19082. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19083. function LinkAnnotationElement(parameters) {
  19084. AnnotationElement.call(this, parameters, true);
  19085. }
  19086. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19087. render: function LinkAnnotationElement_render() {
  19088. this.container.className = 'linkAnnotation';
  19089. var link = document.createElement('a');
  19090. addLinkAttributes(link, {
  19091. url: this.data.url,
  19092. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19093. });
  19094. if (!this.data.url) {
  19095. if (this.data.action) {
  19096. this._bindNamedAction(link, this.data.action);
  19097. } else {
  19098. this._bindLink(link, this.data.dest);
  19099. }
  19100. }
  19101. this.container.appendChild(link);
  19102. return this.container;
  19103. },
  19104. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19105. var self = this;
  19106. link.href = this.linkService.getDestinationHash(destination);
  19107. link.onclick = function () {
  19108. if (destination) {
  19109. self.linkService.navigateTo(destination);
  19110. }
  19111. return false;
  19112. };
  19113. if (destination) {
  19114. link.className = 'internalLink';
  19115. }
  19116. },
  19117. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19118. var self = this;
  19119. link.href = this.linkService.getAnchorUrl('');
  19120. link.onclick = function () {
  19121. self.linkService.executeNamedAction(action);
  19122. return false;
  19123. };
  19124. link.className = 'internalLink';
  19125. }
  19126. });
  19127. return LinkAnnotationElement;
  19128. }();
  19129. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19130. function TextAnnotationElement(parameters) {
  19131. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19132. AnnotationElement.call(this, parameters, isRenderable);
  19133. }
  19134. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19135. render: function TextAnnotationElement_render() {
  19136. this.container.className = 'textAnnotation';
  19137. var image = document.createElement('img');
  19138. image.style.height = this.container.style.height;
  19139. image.style.width = this.container.style.width;
  19140. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19141. image.alt = '[{{type}} Annotation]';
  19142. image.dataset.l10nId = 'text_annotation_type';
  19143. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19144. if (!this.data.hasPopup) {
  19145. this._createPopup(this.container, image, this.data);
  19146. }
  19147. this.container.appendChild(image);
  19148. return this.container;
  19149. }
  19150. });
  19151. return TextAnnotationElement;
  19152. }();
  19153. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19154. function WidgetAnnotationElement(parameters, isRenderable) {
  19155. AnnotationElement.call(this, parameters, isRenderable);
  19156. }
  19157. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19158. render: function WidgetAnnotationElement_render() {
  19159. return this.container;
  19160. }
  19161. });
  19162. return WidgetAnnotationElement;
  19163. }();
  19164. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19165. var TEXT_ALIGNMENT = [
  19166. 'left',
  19167. 'center',
  19168. 'right'
  19169. ];
  19170. function TextWidgetAnnotationElement(parameters) {
  19171. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19172. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19173. }
  19174. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19175. render: function TextWidgetAnnotationElement_render() {
  19176. this.container.className = 'textWidgetAnnotation';
  19177. var element = null;
  19178. if (this.renderInteractiveForms) {
  19179. if (this.data.multiLine) {
  19180. element = document.createElement('textarea');
  19181. element.textContent = this.data.fieldValue;
  19182. } else {
  19183. element = document.createElement('input');
  19184. element.type = 'text';
  19185. element.setAttribute('value', this.data.fieldValue);
  19186. }
  19187. element.disabled = this.data.readOnly;
  19188. if (this.data.maxLen !== null) {
  19189. element.maxLength = this.data.maxLen;
  19190. }
  19191. if (this.data.comb) {
  19192. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19193. var combWidth = fieldWidth / this.data.maxLen;
  19194. element.classList.add('comb');
  19195. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19196. }
  19197. } else {
  19198. element = document.createElement('div');
  19199. element.textContent = this.data.fieldValue;
  19200. element.style.verticalAlign = 'middle';
  19201. element.style.display = 'table-cell';
  19202. var font = null;
  19203. if (this.data.fontRefName) {
  19204. font = this.page.commonObjs.getData(this.data.fontRefName);
  19205. }
  19206. this._setTextStyle(element, font);
  19207. }
  19208. if (this.data.textAlignment !== null) {
  19209. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19210. }
  19211. this.container.appendChild(element);
  19212. return this.container;
  19213. },
  19214. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19215. var style = element.style;
  19216. style.fontSize = this.data.fontSize + 'px';
  19217. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19218. if (!font) {
  19219. return;
  19220. }
  19221. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19222. style.fontStyle = font.italic ? 'italic' : 'normal';
  19223. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19224. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19225. style.fontFamily = fontFamily + fallbackName;
  19226. }
  19227. });
  19228. return TextWidgetAnnotationElement;
  19229. }();
  19230. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19231. function CheckboxWidgetAnnotationElement(parameters) {
  19232. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19233. }
  19234. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19235. render: function CheckboxWidgetAnnotationElement_render() {
  19236. this.container.className = 'buttonWidgetAnnotation checkBox';
  19237. var element = document.createElement('input');
  19238. element.disabled = this.data.readOnly;
  19239. element.type = 'checkbox';
  19240. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19241. element.setAttribute('checked', true);
  19242. }
  19243. this.container.appendChild(element);
  19244. return this.container;
  19245. }
  19246. });
  19247. return CheckboxWidgetAnnotationElement;
  19248. }();
  19249. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19250. function RadioButtonWidgetAnnotationElement(parameters) {
  19251. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19252. }
  19253. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19254. render: function RadioButtonWidgetAnnotationElement_render() {
  19255. this.container.className = 'buttonWidgetAnnotation radioButton';
  19256. var element = document.createElement('input');
  19257. element.disabled = this.data.readOnly;
  19258. element.type = 'radio';
  19259. element.name = this.data.fieldName;
  19260. if (this.data.fieldValue === this.data.buttonValue) {
  19261. element.setAttribute('checked', true);
  19262. }
  19263. this.container.appendChild(element);
  19264. return this.container;
  19265. }
  19266. });
  19267. return RadioButtonWidgetAnnotationElement;
  19268. }();
  19269. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19270. function ChoiceWidgetAnnotationElement(parameters) {
  19271. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19272. }
  19273. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19274. render: function ChoiceWidgetAnnotationElement_render() {
  19275. this.container.className = 'choiceWidgetAnnotation';
  19276. var selectElement = document.createElement('select');
  19277. selectElement.disabled = this.data.readOnly;
  19278. if (!this.data.combo) {
  19279. selectElement.size = this.data.options.length;
  19280. if (this.data.multiSelect) {
  19281. selectElement.multiple = true;
  19282. }
  19283. }
  19284. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19285. var option = this.data.options[i];
  19286. var optionElement = document.createElement('option');
  19287. optionElement.textContent = option.displayValue;
  19288. optionElement.value = option.exportValue;
  19289. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19290. optionElement.setAttribute('selected', true);
  19291. }
  19292. selectElement.appendChild(optionElement);
  19293. }
  19294. this.container.appendChild(selectElement);
  19295. return this.container;
  19296. }
  19297. });
  19298. return ChoiceWidgetAnnotationElement;
  19299. }();
  19300. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19301. function PopupAnnotationElement(parameters) {
  19302. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19303. AnnotationElement.call(this, parameters, isRenderable);
  19304. }
  19305. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19306. render: function PopupAnnotationElement_render() {
  19307. this.container.className = 'popupAnnotation';
  19308. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19309. var parentElement = this.layer.querySelector(selector);
  19310. if (!parentElement) {
  19311. return this.container;
  19312. }
  19313. var popup = new PopupElement({
  19314. container: this.container,
  19315. trigger: parentElement,
  19316. color: this.data.color,
  19317. title: this.data.title,
  19318. contents: this.data.contents
  19319. });
  19320. var parentLeft = parseFloat(parentElement.style.left);
  19321. var parentWidth = parseFloat(parentElement.style.width);
  19322. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19323. this.container.style.left = parentLeft + parentWidth + 'px';
  19324. this.container.appendChild(popup.render());
  19325. return this.container;
  19326. }
  19327. });
  19328. return PopupAnnotationElement;
  19329. }();
  19330. var PopupElement = function PopupElementClosure() {
  19331. var BACKGROUND_ENLIGHT = 0.7;
  19332. function PopupElement(parameters) {
  19333. this.container = parameters.container;
  19334. this.trigger = parameters.trigger;
  19335. this.color = parameters.color;
  19336. this.title = parameters.title;
  19337. this.contents = parameters.contents;
  19338. this.hideWrapper = parameters.hideWrapper || false;
  19339. this.pinned = false;
  19340. }
  19341. PopupElement.prototype = {
  19342. render: function PopupElement_render() {
  19343. var wrapper = document.createElement('div');
  19344. wrapper.className = 'popupWrapper';
  19345. this.hideElement = this.hideWrapper ? wrapper : this.container;
  19346. this.hideElement.setAttribute('hidden', true);
  19347. var popup = document.createElement('div');
  19348. popup.className = 'popup';
  19349. var color = this.color;
  19350. if (color) {
  19351. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  19352. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  19353. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  19354. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  19355. }
  19356. var contents = this._formatContents(this.contents);
  19357. var title = document.createElement('h1');
  19358. title.textContent = this.title;
  19359. this.trigger.addEventListener('click', this._toggle.bind(this));
  19360. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  19361. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  19362. popup.addEventListener('click', this._hide.bind(this, true));
  19363. popup.appendChild(title);
  19364. popup.appendChild(contents);
  19365. wrapper.appendChild(popup);
  19366. return wrapper;
  19367. },
  19368. _formatContents: function PopupElement_formatContents(contents) {
  19369. var p = document.createElement('p');
  19370. var lines = contents.split(/(?:\r\n?|\n)/);
  19371. for (var i = 0, ii = lines.length; i < ii; ++i) {
  19372. var line = lines[i];
  19373. p.appendChild(document.createTextNode(line));
  19374. if (i < ii - 1) {
  19375. p.appendChild(document.createElement('br'));
  19376. }
  19377. }
  19378. return p;
  19379. },
  19380. _toggle: function PopupElement_toggle() {
  19381. if (this.pinned) {
  19382. this._hide(true);
  19383. } else {
  19384. this._show(true);
  19385. }
  19386. },
  19387. _show: function PopupElement_show(pin) {
  19388. if (pin) {
  19389. this.pinned = true;
  19390. }
  19391. if (this.hideElement.hasAttribute('hidden')) {
  19392. this.hideElement.removeAttribute('hidden');
  19393. this.container.style.zIndex += 1;
  19394. }
  19395. },
  19396. _hide: function PopupElement_hide(unpin) {
  19397. if (unpin) {
  19398. this.pinned = false;
  19399. }
  19400. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  19401. this.hideElement.setAttribute('hidden', true);
  19402. this.container.style.zIndex -= 1;
  19403. }
  19404. }
  19405. };
  19406. return PopupElement;
  19407. }();
  19408. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  19409. function HighlightAnnotationElement(parameters) {
  19410. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19411. AnnotationElement.call(this, parameters, isRenderable);
  19412. }
  19413. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  19414. render: function HighlightAnnotationElement_render() {
  19415. this.container.className = 'highlightAnnotation';
  19416. if (!this.data.hasPopup) {
  19417. this._createPopup(this.container, null, this.data);
  19418. }
  19419. return this.container;
  19420. }
  19421. });
  19422. return HighlightAnnotationElement;
  19423. }();
  19424. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  19425. function UnderlineAnnotationElement(parameters) {
  19426. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19427. AnnotationElement.call(this, parameters, isRenderable);
  19428. }
  19429. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  19430. render: function UnderlineAnnotationElement_render() {
  19431. this.container.className = 'underlineAnnotation';
  19432. if (!this.data.hasPopup) {
  19433. this._createPopup(this.container, null, this.data);
  19434. }
  19435. return this.container;
  19436. }
  19437. });
  19438. return UnderlineAnnotationElement;
  19439. }();
  19440. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  19441. function SquigglyAnnotationElement(parameters) {
  19442. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19443. AnnotationElement.call(this, parameters, isRenderable);
  19444. }
  19445. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  19446. render: function SquigglyAnnotationElement_render() {
  19447. this.container.className = 'squigglyAnnotation';
  19448. if (!this.data.hasPopup) {
  19449. this._createPopup(this.container, null, this.data);
  19450. }
  19451. return this.container;
  19452. }
  19453. });
  19454. return SquigglyAnnotationElement;
  19455. }();
  19456. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  19457. function StrikeOutAnnotationElement(parameters) {
  19458. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19459. AnnotationElement.call(this, parameters, isRenderable);
  19460. }
  19461. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  19462. render: function StrikeOutAnnotationElement_render() {
  19463. this.container.className = 'strikeoutAnnotation';
  19464. if (!this.data.hasPopup) {
  19465. this._createPopup(this.container, null, this.data);
  19466. }
  19467. return this.container;
  19468. }
  19469. });
  19470. return StrikeOutAnnotationElement;
  19471. }();
  19472. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  19473. function FileAttachmentAnnotationElement(parameters) {
  19474. AnnotationElement.call(this, parameters, true);
  19475. var file = this.data.file;
  19476. this.filename = getFilenameFromUrl(file.filename);
  19477. this.content = file.content;
  19478. this.linkService.onFileAttachmentAnnotation({
  19479. id: stringToPDFString(file.filename),
  19480. filename: file.filename,
  19481. content: file.content
  19482. });
  19483. }
  19484. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  19485. render: function FileAttachmentAnnotationElement_render() {
  19486. this.container.className = 'fileAttachmentAnnotation';
  19487. var trigger = document.createElement('div');
  19488. trigger.style.height = this.container.style.height;
  19489. trigger.style.width = this.container.style.width;
  19490. trigger.addEventListener('dblclick', this._download.bind(this));
  19491. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19492. this._createPopup(this.container, trigger, this.data);
  19493. }
  19494. this.container.appendChild(trigger);
  19495. return this.container;
  19496. },
  19497. _download: function FileAttachmentAnnotationElement_download() {
  19498. if (!this.downloadManager) {
  19499. warn('Download cannot be started due to unavailable download manager');
  19500. return;
  19501. }
  19502. this.downloadManager.downloadData(this.content, this.filename, '');
  19503. }
  19504. });
  19505. return FileAttachmentAnnotationElement;
  19506. }();
  19507. var AnnotationLayer = function AnnotationLayerClosure() {
  19508. return {
  19509. render: function AnnotationLayer_render(parameters) {
  19510. var annotationElementFactory = new AnnotationElementFactory();
  19511. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19512. var data = parameters.annotations[i];
  19513. if (!data) {
  19514. continue;
  19515. }
  19516. var element = annotationElementFactory.create({
  19517. data: data,
  19518. layer: parameters.div,
  19519. page: parameters.page,
  19520. viewport: parameters.viewport,
  19521. linkService: parameters.linkService,
  19522. downloadManager: parameters.downloadManager,
  19523. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  19524. renderInteractiveForms: parameters.renderInteractiveForms || false
  19525. });
  19526. if (element.isRenderable) {
  19527. parameters.div.appendChild(element.render());
  19528. }
  19529. }
  19530. },
  19531. update: function AnnotationLayer_update(parameters) {
  19532. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19533. var data = parameters.annotations[i];
  19534. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  19535. if (element) {
  19536. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  19537. }
  19538. }
  19539. parameters.div.removeAttribute('hidden');
  19540. }
  19541. };
  19542. }();
  19543. exports.AnnotationLayer = AnnotationLayer;
  19544. /***/ }),
  19545. /* 10 */
  19546. /***/ (function(module, exports, __w_pdfjs_require__) {
  19547. "use strict";
  19548. var sharedUtil = __w_pdfjs_require__(0);
  19549. var displayFontLoader = __w_pdfjs_require__(45);
  19550. var displayCanvas = __w_pdfjs_require__(44);
  19551. var displayMetadata = __w_pdfjs_require__(23);
  19552. var displayDOMUtils = __w_pdfjs_require__(3);
  19553. var amdRequire;
  19554. var InvalidPDFException = sharedUtil.InvalidPDFException;
  19555. var MessageHandler = sharedUtil.MessageHandler;
  19556. var MissingPDFException = sharedUtil.MissingPDFException;
  19557. var PageViewport = sharedUtil.PageViewport;
  19558. var PasswordException = sharedUtil.PasswordException;
  19559. var StatTimer = sharedUtil.StatTimer;
  19560. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  19561. var UnknownErrorException = sharedUtil.UnknownErrorException;
  19562. var Util = sharedUtil.Util;
  19563. var createPromiseCapability = sharedUtil.createPromiseCapability;
  19564. var error = sharedUtil.error;
  19565. var deprecated = sharedUtil.deprecated;
  19566. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  19567. var info = sharedUtil.info;
  19568. var isInt = sharedUtil.isInt;
  19569. var isArray = sharedUtil.isArray;
  19570. var isArrayBuffer = sharedUtil.isArrayBuffer;
  19571. var isSameOrigin = sharedUtil.isSameOrigin;
  19572. var loadJpegStream = sharedUtil.loadJpegStream;
  19573. var stringToBytes = sharedUtil.stringToBytes;
  19574. var globalScope = sharedUtil.globalScope;
  19575. var warn = sharedUtil.warn;
  19576. var FontFaceObject = displayFontLoader.FontFaceObject;
  19577. var FontLoader = displayFontLoader.FontLoader;
  19578. var CanvasGraphics = displayCanvas.CanvasGraphics;
  19579. var Metadata = displayMetadata.Metadata;
  19580. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19581. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  19582. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  19583. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  19584. var isWorkerDisabled = false;
  19585. var workerSrc;
  19586. var isPostMessageTransfersDisabled = false;
  19587. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  19588. var fakeWorkerFilesLoader = null;
  19589. var useRequireEnsure = false;
  19590. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  19591. var task = new PDFDocumentLoadingTask();
  19592. if (arguments.length > 1) {
  19593. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  19594. }
  19595. if (pdfDataRangeTransport) {
  19596. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  19597. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  19598. pdfDataRangeTransport.length = src.length;
  19599. pdfDataRangeTransport.initialData = src.initialData;
  19600. if (!pdfDataRangeTransport.abort) {
  19601. pdfDataRangeTransport.abort = function () {
  19602. };
  19603. }
  19604. }
  19605. src = Object.create(src);
  19606. src.range = pdfDataRangeTransport;
  19607. }
  19608. task.onPassword = passwordCallback || null;
  19609. task.onProgress = progressCallback || null;
  19610. var source;
  19611. if (typeof src === 'string') {
  19612. source = { url: src };
  19613. } else if (isArrayBuffer(src)) {
  19614. source = { data: src };
  19615. } else if (src instanceof PDFDataRangeTransport) {
  19616. source = { range: src };
  19617. } else {
  19618. if (typeof src !== 'object') {
  19619. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  19620. }
  19621. if (!src.url && !src.data && !src.range) {
  19622. error('Invalid parameter object: need either .data, .range or .url');
  19623. }
  19624. source = src;
  19625. }
  19626. var params = {};
  19627. var rangeTransport = null;
  19628. var worker = null;
  19629. for (var key in source) {
  19630. if (key === 'url' && typeof window !== 'undefined') {
  19631. params[key] = new URL(source[key], window.location).href;
  19632. continue;
  19633. } else if (key === 'range') {
  19634. rangeTransport = source[key];
  19635. continue;
  19636. } else if (key === 'worker') {
  19637. worker = source[key];
  19638. continue;
  19639. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  19640. var pdfBytes = source[key];
  19641. if (typeof pdfBytes === 'string') {
  19642. params[key] = stringToBytes(pdfBytes);
  19643. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  19644. params[key] = new Uint8Array(pdfBytes);
  19645. } else if (isArrayBuffer(pdfBytes)) {
  19646. params[key] = new Uint8Array(pdfBytes);
  19647. } else {
  19648. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  19649. }
  19650. continue;
  19651. }
  19652. params[key] = source[key];
  19653. }
  19654. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  19655. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  19656. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  19657. if (!worker) {
  19658. worker = new PDFWorker();
  19659. task._worker = worker;
  19660. }
  19661. var docId = task.docId;
  19662. worker.promise.then(function () {
  19663. if (task.destroyed) {
  19664. throw new Error('Loading aborted');
  19665. }
  19666. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  19667. if (task.destroyed) {
  19668. throw new Error('Loading aborted');
  19669. }
  19670. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  19671. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  19672. task._transport = transport;
  19673. messageHandler.send('Ready', null);
  19674. });
  19675. }).catch(task._capability.reject);
  19676. return task;
  19677. }
  19678. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  19679. if (worker.destroyed) {
  19680. return Promise.reject(new Error('Worker was destroyed'));
  19681. }
  19682. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  19683. source.disableStream = getDefaultSetting('disableStream');
  19684. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  19685. if (pdfDataRangeTransport) {
  19686. source.length = pdfDataRangeTransport.length;
  19687. source.initialData = pdfDataRangeTransport.initialData;
  19688. }
  19689. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  19690. docId: docId,
  19691. source: source,
  19692. disableRange: getDefaultSetting('disableRange'),
  19693. maxImageSize: getDefaultSetting('maxImageSize'),
  19694. disableFontFace: getDefaultSetting('disableFontFace'),
  19695. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  19696. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  19697. docBaseUrl: source.docBaseUrl,
  19698. disableNativeImageDecoder: source.disableNativeImageDecoder
  19699. }).then(function (workerId) {
  19700. if (worker.destroyed) {
  19701. throw new Error('Worker was destroyed');
  19702. }
  19703. return workerId;
  19704. });
  19705. }
  19706. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  19707. var nextDocumentId = 0;
  19708. function PDFDocumentLoadingTask() {
  19709. this._capability = createPromiseCapability();
  19710. this._transport = null;
  19711. this._worker = null;
  19712. this.docId = 'd' + nextDocumentId++;
  19713. this.destroyed = false;
  19714. this.onPassword = null;
  19715. this.onProgress = null;
  19716. this.onUnsupportedFeature = null;
  19717. }
  19718. PDFDocumentLoadingTask.prototype = {
  19719. get promise() {
  19720. return this._capability.promise;
  19721. },
  19722. destroy: function () {
  19723. this.destroyed = true;
  19724. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  19725. return transportDestroyed.then(function () {
  19726. this._transport = null;
  19727. if (this._worker) {
  19728. this._worker.destroy();
  19729. this._worker = null;
  19730. }
  19731. }.bind(this));
  19732. },
  19733. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  19734. return this.promise.then.apply(this.promise, arguments);
  19735. }
  19736. };
  19737. return PDFDocumentLoadingTask;
  19738. }();
  19739. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  19740. function PDFDataRangeTransport(length, initialData) {
  19741. this.length = length;
  19742. this.initialData = initialData;
  19743. this._rangeListeners = [];
  19744. this._progressListeners = [];
  19745. this._progressiveReadListeners = [];
  19746. this._readyCapability = createPromiseCapability();
  19747. }
  19748. PDFDataRangeTransport.prototype = {
  19749. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  19750. this._rangeListeners.push(listener);
  19751. },
  19752. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  19753. this._progressListeners.push(listener);
  19754. },
  19755. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  19756. this._progressiveReadListeners.push(listener);
  19757. },
  19758. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  19759. var listeners = this._rangeListeners;
  19760. for (var i = 0, n = listeners.length; i < n; ++i) {
  19761. listeners[i](begin, chunk);
  19762. }
  19763. },
  19764. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  19765. this._readyCapability.promise.then(function () {
  19766. var listeners = this._progressListeners;
  19767. for (var i = 0, n = listeners.length; i < n; ++i) {
  19768. listeners[i](loaded);
  19769. }
  19770. }.bind(this));
  19771. },
  19772. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  19773. this._readyCapability.promise.then(function () {
  19774. var listeners = this._progressiveReadListeners;
  19775. for (var i = 0, n = listeners.length; i < n; ++i) {
  19776. listeners[i](chunk);
  19777. }
  19778. }.bind(this));
  19779. },
  19780. transportReady: function PDFDataRangeTransport_transportReady() {
  19781. this._readyCapability.resolve();
  19782. },
  19783. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  19784. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  19785. },
  19786. abort: function PDFDataRangeTransport_abort() {
  19787. }
  19788. };
  19789. return PDFDataRangeTransport;
  19790. }();
  19791. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  19792. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  19793. this.pdfInfo = pdfInfo;
  19794. this.transport = transport;
  19795. this.loadingTask = loadingTask;
  19796. }
  19797. PDFDocumentProxy.prototype = {
  19798. get numPages() {
  19799. return this.pdfInfo.numPages;
  19800. },
  19801. get fingerprint() {
  19802. return this.pdfInfo.fingerprint;
  19803. },
  19804. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  19805. return this.transport.getPage(pageNumber);
  19806. },
  19807. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19808. return this.transport.getPageIndex(ref);
  19809. },
  19810. getDestinations: function PDFDocumentProxy_getDestinations() {
  19811. return this.transport.getDestinations();
  19812. },
  19813. getDestination: function PDFDocumentProxy_getDestination(id) {
  19814. return this.transport.getDestination(id);
  19815. },
  19816. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19817. return this.transport.getPageLabels();
  19818. },
  19819. getAttachments: function PDFDocumentProxy_getAttachments() {
  19820. return this.transport.getAttachments();
  19821. },
  19822. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19823. return this.transport.getJavaScript();
  19824. },
  19825. getOutline: function PDFDocumentProxy_getOutline() {
  19826. return this.transport.getOutline();
  19827. },
  19828. getMetadata: function PDFDocumentProxy_getMetadata() {
  19829. return this.transport.getMetadata();
  19830. },
  19831. getData: function PDFDocumentProxy_getData() {
  19832. return this.transport.getData();
  19833. },
  19834. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19835. return this.transport.downloadInfoCapability.promise;
  19836. },
  19837. getStats: function PDFDocumentProxy_getStats() {
  19838. return this.transport.getStats();
  19839. },
  19840. cleanup: function PDFDocumentProxy_cleanup() {
  19841. this.transport.startCleanup();
  19842. },
  19843. destroy: function PDFDocumentProxy_destroy() {
  19844. return this.loadingTask.destroy();
  19845. }
  19846. };
  19847. return PDFDocumentProxy;
  19848. }();
  19849. var PDFPageProxy = function PDFPageProxyClosure() {
  19850. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19851. this.pageIndex = pageIndex;
  19852. this.pageInfo = pageInfo;
  19853. this.transport = transport;
  19854. this.stats = new StatTimer();
  19855. this.stats.enabled = getDefaultSetting('enableStats');
  19856. this.commonObjs = transport.commonObjs;
  19857. this.objs = new PDFObjects();
  19858. this.cleanupAfterRender = false;
  19859. this.pendingCleanup = false;
  19860. this.intentStates = Object.create(null);
  19861. this.destroyed = false;
  19862. }
  19863. PDFPageProxy.prototype = {
  19864. get pageNumber() {
  19865. return this.pageIndex + 1;
  19866. },
  19867. get rotate() {
  19868. return this.pageInfo.rotate;
  19869. },
  19870. get ref() {
  19871. return this.pageInfo.ref;
  19872. },
  19873. get userUnit() {
  19874. return this.pageInfo.userUnit;
  19875. },
  19876. get view() {
  19877. return this.pageInfo.view;
  19878. },
  19879. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19880. if (arguments.length < 2) {
  19881. rotate = this.rotate;
  19882. }
  19883. return new PageViewport(this.view, scale, rotate, 0, 0);
  19884. },
  19885. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19886. var intent = params && params.intent || null;
  19887. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19888. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19889. this.annotationsIntent = intent;
  19890. }
  19891. return this.annotationsPromise;
  19892. },
  19893. render: function PDFPageProxy_render(params) {
  19894. var stats = this.stats;
  19895. stats.time('Overall');
  19896. this.pendingCleanup = false;
  19897. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19898. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19899. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19900. if (!this.intentStates[renderingIntent]) {
  19901. this.intentStates[renderingIntent] = Object.create(null);
  19902. }
  19903. var intentState = this.intentStates[renderingIntent];
  19904. if (!intentState.displayReadyCapability) {
  19905. intentState.receivingOperatorList = true;
  19906. intentState.displayReadyCapability = createPromiseCapability();
  19907. intentState.operatorList = {
  19908. fnArray: [],
  19909. argsArray: [],
  19910. lastChunk: false
  19911. };
  19912. this.stats.time('Page Request');
  19913. this.transport.messageHandler.send('RenderPageRequest', {
  19914. pageIndex: this.pageNumber - 1,
  19915. intent: renderingIntent,
  19916. renderInteractiveForms: renderInteractiveForms
  19917. });
  19918. }
  19919. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19920. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19921. if (!intentState.renderTasks) {
  19922. intentState.renderTasks = [];
  19923. }
  19924. intentState.renderTasks.push(internalRenderTask);
  19925. var renderTask = internalRenderTask.task;
  19926. if (params.continueCallback) {
  19927. deprecated('render is used with continueCallback parameter');
  19928. renderTask.onContinue = params.continueCallback;
  19929. }
  19930. var self = this;
  19931. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19932. if (self.pendingCleanup) {
  19933. complete();
  19934. return;
  19935. }
  19936. stats.time('Rendering');
  19937. internalRenderTask.initializeGraphics(transparency);
  19938. internalRenderTask.operatorListChanged();
  19939. }, function pageDisplayReadPromiseError(reason) {
  19940. complete(reason);
  19941. });
  19942. function complete(error) {
  19943. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19944. if (i >= 0) {
  19945. intentState.renderTasks.splice(i, 1);
  19946. }
  19947. if (self.cleanupAfterRender) {
  19948. self.pendingCleanup = true;
  19949. }
  19950. self._tryCleanup();
  19951. if (error) {
  19952. internalRenderTask.capability.reject(error);
  19953. } else {
  19954. internalRenderTask.capability.resolve();
  19955. }
  19956. stats.timeEnd('Rendering');
  19957. stats.timeEnd('Overall');
  19958. }
  19959. return renderTask;
  19960. },
  19961. getOperatorList: function PDFPageProxy_getOperatorList() {
  19962. function operatorListChanged() {
  19963. if (intentState.operatorList.lastChunk) {
  19964. intentState.opListReadCapability.resolve(intentState.operatorList);
  19965. var i = intentState.renderTasks.indexOf(opListTask);
  19966. if (i >= 0) {
  19967. intentState.renderTasks.splice(i, 1);
  19968. }
  19969. }
  19970. }
  19971. var renderingIntent = 'oplist';
  19972. if (!this.intentStates[renderingIntent]) {
  19973. this.intentStates[renderingIntent] = Object.create(null);
  19974. }
  19975. var intentState = this.intentStates[renderingIntent];
  19976. var opListTask;
  19977. if (!intentState.opListReadCapability) {
  19978. opListTask = {};
  19979. opListTask.operatorListChanged = operatorListChanged;
  19980. intentState.receivingOperatorList = true;
  19981. intentState.opListReadCapability = createPromiseCapability();
  19982. intentState.renderTasks = [];
  19983. intentState.renderTasks.push(opListTask);
  19984. intentState.operatorList = {
  19985. fnArray: [],
  19986. argsArray: [],
  19987. lastChunk: false
  19988. };
  19989. this.transport.messageHandler.send('RenderPageRequest', {
  19990. pageIndex: this.pageIndex,
  19991. intent: renderingIntent
  19992. });
  19993. }
  19994. return intentState.opListReadCapability.promise;
  19995. },
  19996. getTextContent: function PDFPageProxy_getTextContent(params) {
  19997. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19998. pageIndex: this.pageNumber - 1,
  19999. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  20000. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  20001. });
  20002. },
  20003. _destroy: function PDFPageProxy_destroy() {
  20004. this.destroyed = true;
  20005. this.transport.pageCache[this.pageIndex] = null;
  20006. var waitOn = [];
  20007. Object.keys(this.intentStates).forEach(function (intent) {
  20008. if (intent === 'oplist') {
  20009. return;
  20010. }
  20011. var intentState = this.intentStates[intent];
  20012. intentState.renderTasks.forEach(function (renderTask) {
  20013. var renderCompleted = renderTask.capability.promise.catch(function () {
  20014. });
  20015. waitOn.push(renderCompleted);
  20016. renderTask.cancel();
  20017. });
  20018. }, this);
  20019. this.objs.clear();
  20020. this.annotationsPromise = null;
  20021. this.pendingCleanup = false;
  20022. return Promise.all(waitOn);
  20023. },
  20024. destroy: function () {
  20025. deprecated('page destroy method, use cleanup() instead');
  20026. this.cleanup();
  20027. },
  20028. cleanup: function PDFPageProxy_cleanup() {
  20029. this.pendingCleanup = true;
  20030. this._tryCleanup();
  20031. },
  20032. _tryCleanup: function PDFPageProxy_tryCleanup() {
  20033. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  20034. var intentState = this.intentStates[intent];
  20035. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  20036. }, this)) {
  20037. return;
  20038. }
  20039. Object.keys(this.intentStates).forEach(function (intent) {
  20040. delete this.intentStates[intent];
  20041. }, this);
  20042. this.objs.clear();
  20043. this.annotationsPromise = null;
  20044. this.pendingCleanup = false;
  20045. },
  20046. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  20047. var intentState = this.intentStates[intent];
  20048. if (intentState.displayReadyCapability) {
  20049. intentState.displayReadyCapability.resolve(transparency);
  20050. }
  20051. },
  20052. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20053. var intentState = this.intentStates[intent];
  20054. var i, ii;
  20055. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20056. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20057. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20058. }
  20059. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20060. for (i = 0; i < intentState.renderTasks.length; i++) {
  20061. intentState.renderTasks[i].operatorListChanged();
  20062. }
  20063. if (operatorListChunk.lastChunk) {
  20064. intentState.receivingOperatorList = false;
  20065. this._tryCleanup();
  20066. }
  20067. }
  20068. };
  20069. return PDFPageProxy;
  20070. }();
  20071. var PDFWorker = function PDFWorkerClosure() {
  20072. var nextFakeWorkerId = 0;
  20073. function getWorkerSrc() {
  20074. if (typeof workerSrc !== 'undefined') {
  20075. return workerSrc;
  20076. }
  20077. if (getDefaultSetting('workerSrc')) {
  20078. return getDefaultSetting('workerSrc');
  20079. }
  20080. if (pdfjsFilePath) {
  20081. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20082. }
  20083. error('No PDFJS.workerSrc specified');
  20084. }
  20085. var fakeWorkerFilesLoadedCapability;
  20086. function setupFakeWorkerGlobal() {
  20087. var WorkerMessageHandler;
  20088. if (fakeWorkerFilesLoadedCapability) {
  20089. return fakeWorkerFilesLoadedCapability.promise;
  20090. }
  20091. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20092. var pdfjsCoreWorker = __w_pdfjs_require__(22);
  20093. __w_pdfjs_require__(39);
  20094. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  20095. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20096. return fakeWorkerFilesLoadedCapability.promise;
  20097. }
  20098. function FakeWorkerPort(defer) {
  20099. this._listeners = [];
  20100. this._defer = defer;
  20101. this._deferred = Promise.resolve(undefined);
  20102. }
  20103. FakeWorkerPort.prototype = {
  20104. postMessage: function (obj, transfers) {
  20105. function cloneValue(value) {
  20106. if (typeof value !== 'object' || value === null) {
  20107. return value;
  20108. }
  20109. if (cloned.has(value)) {
  20110. return cloned.get(value);
  20111. }
  20112. var result;
  20113. var buffer;
  20114. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20115. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20116. if (value === buffer) {
  20117. result = value;
  20118. } else if (transferable) {
  20119. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20120. } else {
  20121. result = new value.constructor(value);
  20122. }
  20123. cloned.set(value, result);
  20124. return result;
  20125. }
  20126. result = isArray(value) ? [] : {};
  20127. cloned.set(value, result);
  20128. for (var i in value) {
  20129. var desc, p = value;
  20130. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20131. p = Object.getPrototypeOf(p);
  20132. }
  20133. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20134. continue;
  20135. }
  20136. result[i] = cloneValue(desc.value);
  20137. }
  20138. return result;
  20139. }
  20140. if (!this._defer) {
  20141. this._listeners.forEach(function (listener) {
  20142. listener.call(this, { data: obj });
  20143. }, this);
  20144. return;
  20145. }
  20146. var cloned = new WeakMap();
  20147. var e = { data: cloneValue(obj) };
  20148. this._deferred.then(function () {
  20149. this._listeners.forEach(function (listener) {
  20150. listener.call(this, e);
  20151. }, this);
  20152. }.bind(this));
  20153. },
  20154. addEventListener: function (name, listener) {
  20155. this._listeners.push(listener);
  20156. },
  20157. removeEventListener: function (name, listener) {
  20158. var i = this._listeners.indexOf(listener);
  20159. this._listeners.splice(i, 1);
  20160. },
  20161. terminate: function () {
  20162. this._listeners = [];
  20163. }
  20164. };
  20165. function createCDNWrapper(url) {
  20166. var wrapper = 'importScripts(\'' + url + '\');';
  20167. return URL.createObjectURL(new Blob([wrapper]));
  20168. }
  20169. function PDFWorker(name) {
  20170. this.name = name;
  20171. this.destroyed = false;
  20172. this._readyCapability = createPromiseCapability();
  20173. this._port = null;
  20174. this._webWorker = null;
  20175. this._messageHandler = null;
  20176. this._initialize();
  20177. }
  20178. PDFWorker.prototype = {
  20179. get promise() {
  20180. return this._readyCapability.promise;
  20181. },
  20182. get port() {
  20183. return this._port;
  20184. },
  20185. get messageHandler() {
  20186. return this._messageHandler;
  20187. },
  20188. _initialize: function PDFWorker_initialize() {
  20189. this._setupFakeWorker();
  20190. },
  20191. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20192. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20193. warn('Setting up fake worker.');
  20194. isWorkerDisabled = true;
  20195. }
  20196. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20197. if (this.destroyed) {
  20198. this._readyCapability.reject(new Error('Worker was destroyed'));
  20199. return;
  20200. }
  20201. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20202. var port = new FakeWorkerPort(isTypedArraysPresent);
  20203. this._port = port;
  20204. var id = 'fake' + nextFakeWorkerId++;
  20205. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20206. WorkerMessageHandler.setup(workerHandler, port);
  20207. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20208. this._messageHandler = messageHandler;
  20209. this._readyCapability.resolve();
  20210. }.bind(this));
  20211. },
  20212. destroy: function PDFWorker_destroy() {
  20213. this.destroyed = true;
  20214. if (this._webWorker) {
  20215. this._webWorker.terminate();
  20216. this._webWorker = null;
  20217. }
  20218. this._port = null;
  20219. if (this._messageHandler) {
  20220. this._messageHandler.destroy();
  20221. this._messageHandler = null;
  20222. }
  20223. }
  20224. };
  20225. return PDFWorker;
  20226. }();
  20227. var WorkerTransport = function WorkerTransportClosure() {
  20228. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  20229. this.messageHandler = messageHandler;
  20230. this.loadingTask = loadingTask;
  20231. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20232. this.commonObjs = new PDFObjects();
  20233. this.fontLoader = new FontLoader(loadingTask.docId);
  20234. this.CMapReaderFactory = new CMapReaderFactory({
  20235. baseUrl: getDefaultSetting('cMapUrl'),
  20236. isCompressed: getDefaultSetting('cMapPacked')
  20237. });
  20238. this.destroyed = false;
  20239. this.destroyCapability = null;
  20240. this._passwordCapability = null;
  20241. this.pageCache = [];
  20242. this.pagePromises = [];
  20243. this.downloadInfoCapability = createPromiseCapability();
  20244. this.setupMessageHandler();
  20245. }
  20246. WorkerTransport.prototype = {
  20247. destroy: function WorkerTransport_destroy() {
  20248. if (this.destroyCapability) {
  20249. return this.destroyCapability.promise;
  20250. }
  20251. this.destroyed = true;
  20252. this.destroyCapability = createPromiseCapability();
  20253. if (this._passwordCapability) {
  20254. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20255. }
  20256. var waitOn = [];
  20257. this.pageCache.forEach(function (page) {
  20258. if (page) {
  20259. waitOn.push(page._destroy());
  20260. }
  20261. });
  20262. this.pageCache = [];
  20263. this.pagePromises = [];
  20264. var self = this;
  20265. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20266. waitOn.push(terminated);
  20267. Promise.all(waitOn).then(function () {
  20268. self.fontLoader.clear();
  20269. if (self.pdfDataRangeTransport) {
  20270. self.pdfDataRangeTransport.abort();
  20271. self.pdfDataRangeTransport = null;
  20272. }
  20273. if (self.messageHandler) {
  20274. self.messageHandler.destroy();
  20275. self.messageHandler = null;
  20276. }
  20277. self.destroyCapability.resolve();
  20278. }, this.destroyCapability.reject);
  20279. return this.destroyCapability.promise;
  20280. },
  20281. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20282. var messageHandler = this.messageHandler;
  20283. var loadingTask = this.loadingTask;
  20284. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20285. if (pdfDataRangeTransport) {
  20286. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20287. messageHandler.send('OnDataRange', {
  20288. begin: begin,
  20289. chunk: chunk
  20290. });
  20291. });
  20292. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20293. messageHandler.send('OnDataProgress', { loaded: loaded });
  20294. });
  20295. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20296. messageHandler.send('OnDataRange', { chunk: chunk });
  20297. });
  20298. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20299. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20300. }, this);
  20301. }
  20302. messageHandler.on('GetDoc', function transportDoc(data) {
  20303. var pdfInfo = data.pdfInfo;
  20304. this.numPages = data.pdfInfo.numPages;
  20305. var loadingTask = this.loadingTask;
  20306. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20307. this.pdfDocument = pdfDocument;
  20308. loadingTask._capability.resolve(pdfDocument);
  20309. }, this);
  20310. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20311. this._passwordCapability = createPromiseCapability();
  20312. if (loadingTask.onPassword) {
  20313. var updatePassword = function (password) {
  20314. this._passwordCapability.resolve({ password: password });
  20315. }.bind(this);
  20316. loadingTask.onPassword(updatePassword, exception.code);
  20317. } else {
  20318. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20319. }
  20320. return this._passwordCapability.promise;
  20321. }, this);
  20322. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20323. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20324. }, this);
  20325. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20326. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20327. }, this);
  20328. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20329. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20330. }, this);
  20331. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  20332. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  20333. }, this);
  20334. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  20335. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  20336. }, this);
  20337. messageHandler.on('DataLoaded', function transportPage(data) {
  20338. this.downloadInfoCapability.resolve(data);
  20339. }, this);
  20340. messageHandler.on('PDFManagerReady', function transportPage(data) {
  20341. if (this.pdfDataRangeTransport) {
  20342. this.pdfDataRangeTransport.transportReady();
  20343. }
  20344. }, this);
  20345. messageHandler.on('StartRenderPage', function transportRender(data) {
  20346. if (this.destroyed) {
  20347. return;
  20348. }
  20349. var page = this.pageCache[data.pageIndex];
  20350. page.stats.timeEnd('Page Request');
  20351. page._startRenderPage(data.transparency, data.intent);
  20352. }, this);
  20353. messageHandler.on('RenderPageChunk', function transportRender(data) {
  20354. if (this.destroyed) {
  20355. return;
  20356. }
  20357. var page = this.pageCache[data.pageIndex];
  20358. page._renderPageChunk(data.operatorList, data.intent);
  20359. }, this);
  20360. messageHandler.on('commonobj', function transportObj(data) {
  20361. if (this.destroyed) {
  20362. return;
  20363. }
  20364. var id = data[0];
  20365. var type = data[1];
  20366. if (this.commonObjs.hasData(id)) {
  20367. return;
  20368. }
  20369. switch (type) {
  20370. case 'Font':
  20371. var exportedData = data[2];
  20372. if ('error' in exportedData) {
  20373. var exportedError = exportedData.error;
  20374. warn('Error during font loading: ' + exportedError);
  20375. this.commonObjs.resolve(id, exportedError);
  20376. break;
  20377. }
  20378. var fontRegistry = null;
  20379. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  20380. fontRegistry = {
  20381. registerFont: function (font, url) {
  20382. globalScope['FontInspector'].fontAdded(font, url);
  20383. }
  20384. };
  20385. }
  20386. var font = new FontFaceObject(exportedData, {
  20387. isEvalSuported: getDefaultSetting('isEvalSupported'),
  20388. disableFontFace: getDefaultSetting('disableFontFace'),
  20389. fontRegistry: fontRegistry
  20390. });
  20391. this.fontLoader.bind([font], function fontReady(fontObjs) {
  20392. this.commonObjs.resolve(id, font);
  20393. }.bind(this));
  20394. break;
  20395. case 'FontPath':
  20396. this.commonObjs.resolve(id, data[2]);
  20397. break;
  20398. default:
  20399. error('Got unknown common object type ' + type);
  20400. }
  20401. }, this);
  20402. messageHandler.on('obj', function transportObj(data) {
  20403. if (this.destroyed) {
  20404. return;
  20405. }
  20406. var id = data[0];
  20407. var pageIndex = data[1];
  20408. var type = data[2];
  20409. var pageProxy = this.pageCache[pageIndex];
  20410. var imageData;
  20411. if (pageProxy.objs.hasData(id)) {
  20412. return;
  20413. }
  20414. switch (type) {
  20415. case 'JpegStream':
  20416. imageData = data[3];
  20417. loadJpegStream(id, imageData, pageProxy.objs);
  20418. break;
  20419. case 'Image':
  20420. imageData = data[3];
  20421. pageProxy.objs.resolve(id, imageData);
  20422. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  20423. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  20424. pageProxy.cleanupAfterRender = true;
  20425. }
  20426. break;
  20427. default:
  20428. error('Got unknown object type ' + type);
  20429. }
  20430. }, this);
  20431. messageHandler.on('DocProgress', function transportDocProgress(data) {
  20432. if (this.destroyed) {
  20433. return;
  20434. }
  20435. var loadingTask = this.loadingTask;
  20436. if (loadingTask.onProgress) {
  20437. loadingTask.onProgress({
  20438. loaded: data.loaded,
  20439. total: data.total
  20440. });
  20441. }
  20442. }, this);
  20443. messageHandler.on('PageError', function transportError(data) {
  20444. if (this.destroyed) {
  20445. return;
  20446. }
  20447. var page = this.pageCache[data.pageNum - 1];
  20448. var intentState = page.intentStates[data.intent];
  20449. if (intentState.displayReadyCapability) {
  20450. intentState.displayReadyCapability.reject(data.error);
  20451. } else {
  20452. error(data.error);
  20453. }
  20454. if (intentState.operatorList) {
  20455. intentState.operatorList.lastChunk = true;
  20456. for (var i = 0; i < intentState.renderTasks.length; i++) {
  20457. intentState.renderTasks[i].operatorListChanged();
  20458. }
  20459. }
  20460. }, this);
  20461. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  20462. if (this.destroyed) {
  20463. return;
  20464. }
  20465. var featureId = data.featureId;
  20466. var loadingTask = this.loadingTask;
  20467. if (loadingTask.onUnsupportedFeature) {
  20468. loadingTask.onUnsupportedFeature(featureId);
  20469. }
  20470. _UnsupportedManager.notify(featureId);
  20471. }, this);
  20472. messageHandler.on('JpegDecode', function (data) {
  20473. if (this.destroyed) {
  20474. return Promise.reject(new Error('Worker was destroyed'));
  20475. }
  20476. if (typeof document === 'undefined') {
  20477. return Promise.reject(new Error('"document" is not defined.'));
  20478. }
  20479. var imageUrl = data[0];
  20480. var components = data[1];
  20481. if (components !== 3 && components !== 1) {
  20482. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  20483. }
  20484. return new Promise(function (resolve, reject) {
  20485. var img = new Image();
  20486. img.onload = function () {
  20487. var width = img.width;
  20488. var height = img.height;
  20489. var size = width * height;
  20490. var rgbaLength = size * 4;
  20491. var buf = new Uint8Array(size * components);
  20492. var tmpCanvas = document.createElement('canvas');
  20493. tmpCanvas.width = width;
  20494. tmpCanvas.height = height;
  20495. var tmpCtx = tmpCanvas.getContext('2d');
  20496. tmpCtx.drawImage(img, 0, 0);
  20497. var data = tmpCtx.getImageData(0, 0, width, height).data;
  20498. var i, j;
  20499. if (components === 3) {
  20500. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  20501. buf[j] = data[i];
  20502. buf[j + 1] = data[i + 1];
  20503. buf[j + 2] = data[i + 2];
  20504. }
  20505. } else if (components === 1) {
  20506. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  20507. buf[j] = data[i];
  20508. }
  20509. }
  20510. resolve({
  20511. data: buf,
  20512. width: width,
  20513. height: height
  20514. });
  20515. };
  20516. img.onerror = function () {
  20517. reject(new Error('JpegDecode failed to load image'));
  20518. };
  20519. img.src = imageUrl;
  20520. });
  20521. }, this);
  20522. messageHandler.on('FetchBuiltInCMap', function (data) {
  20523. if (this.destroyed) {
  20524. return Promise.reject(new Error('Worker was destroyed'));
  20525. }
  20526. return this.CMapReaderFactory.fetch({ name: data.name });
  20527. }, this);
  20528. },
  20529. getData: function WorkerTransport_getData() {
  20530. return this.messageHandler.sendWithPromise('GetData', null);
  20531. },
  20532. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  20533. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  20534. return Promise.reject(new Error('Invalid page request'));
  20535. }
  20536. var pageIndex = pageNumber - 1;
  20537. if (pageIndex in this.pagePromises) {
  20538. return this.pagePromises[pageIndex];
  20539. }
  20540. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  20541. if (this.destroyed) {
  20542. throw new Error('Transport destroyed');
  20543. }
  20544. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  20545. this.pageCache[pageIndex] = page;
  20546. return page;
  20547. }.bind(this));
  20548. this.pagePromises[pageIndex] = promise;
  20549. return promise;
  20550. },
  20551. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  20552. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  20553. return Promise.reject(new Error(reason));
  20554. });
  20555. },
  20556. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  20557. return this.messageHandler.sendWithPromise('GetAnnotations', {
  20558. pageIndex: pageIndex,
  20559. intent: intent
  20560. });
  20561. },
  20562. getDestinations: function WorkerTransport_getDestinations() {
  20563. return this.messageHandler.sendWithPromise('GetDestinations', null);
  20564. },
  20565. getDestination: function WorkerTransport_getDestination(id) {
  20566. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  20567. },
  20568. getPageLabels: function WorkerTransport_getPageLabels() {
  20569. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  20570. },
  20571. getAttachments: function WorkerTransport_getAttachments() {
  20572. return this.messageHandler.sendWithPromise('GetAttachments', null);
  20573. },
  20574. getJavaScript: function WorkerTransport_getJavaScript() {
  20575. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  20576. },
  20577. getOutline: function WorkerTransport_getOutline() {
  20578. return this.messageHandler.sendWithPromise('GetOutline', null);
  20579. },
  20580. getMetadata: function WorkerTransport_getMetadata() {
  20581. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  20582. return {
  20583. info: results[0],
  20584. metadata: results[1] ? new Metadata(results[1]) : null
  20585. };
  20586. });
  20587. },
  20588. getStats: function WorkerTransport_getStats() {
  20589. return this.messageHandler.sendWithPromise('GetStats', null);
  20590. },
  20591. startCleanup: function WorkerTransport_startCleanup() {
  20592. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  20593. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  20594. var page = this.pageCache[i];
  20595. if (page) {
  20596. page.cleanup();
  20597. }
  20598. }
  20599. this.commonObjs.clear();
  20600. this.fontLoader.clear();
  20601. }.bind(this));
  20602. }
  20603. };
  20604. return WorkerTransport;
  20605. }();
  20606. var PDFObjects = function PDFObjectsClosure() {
  20607. function PDFObjects() {
  20608. this.objs = Object.create(null);
  20609. }
  20610. PDFObjects.prototype = {
  20611. ensureObj: function PDFObjects_ensureObj(objId) {
  20612. if (this.objs[objId]) {
  20613. return this.objs[objId];
  20614. }
  20615. var obj = {
  20616. capability: createPromiseCapability(),
  20617. data: null,
  20618. resolved: false
  20619. };
  20620. this.objs[objId] = obj;
  20621. return obj;
  20622. },
  20623. get: function PDFObjects_get(objId, callback) {
  20624. if (callback) {
  20625. this.ensureObj(objId).capability.promise.then(callback);
  20626. return null;
  20627. }
  20628. var obj = this.objs[objId];
  20629. if (!obj || !obj.resolved) {
  20630. error('Requesting object that isn\'t resolved yet ' + objId);
  20631. }
  20632. return obj.data;
  20633. },
  20634. resolve: function PDFObjects_resolve(objId, data) {
  20635. var obj = this.ensureObj(objId);
  20636. obj.resolved = true;
  20637. obj.data = data;
  20638. obj.capability.resolve(data);
  20639. },
  20640. isResolved: function PDFObjects_isResolved(objId) {
  20641. var objs = this.objs;
  20642. if (!objs[objId]) {
  20643. return false;
  20644. }
  20645. return objs[objId].resolved;
  20646. },
  20647. hasData: function PDFObjects_hasData(objId) {
  20648. return this.isResolved(objId);
  20649. },
  20650. getData: function PDFObjects_getData(objId) {
  20651. var objs = this.objs;
  20652. if (!objs[objId] || !objs[objId].resolved) {
  20653. return null;
  20654. }
  20655. return objs[objId].data;
  20656. },
  20657. clear: function PDFObjects_clear() {
  20658. this.objs = Object.create(null);
  20659. }
  20660. };
  20661. return PDFObjects;
  20662. }();
  20663. var RenderTask = function RenderTaskClosure() {
  20664. function RenderTask(internalRenderTask) {
  20665. this._internalRenderTask = internalRenderTask;
  20666. this.onContinue = null;
  20667. }
  20668. RenderTask.prototype = {
  20669. get promise() {
  20670. return this._internalRenderTask.capability.promise;
  20671. },
  20672. cancel: function RenderTask_cancel() {
  20673. this._internalRenderTask.cancel();
  20674. },
  20675. then: function RenderTask_then(onFulfilled, onRejected) {
  20676. return this.promise.then.apply(this.promise, arguments);
  20677. }
  20678. };
  20679. return RenderTask;
  20680. }();
  20681. var InternalRenderTask = function InternalRenderTaskClosure() {
  20682. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  20683. this.callback = callback;
  20684. this.params = params;
  20685. this.objs = objs;
  20686. this.commonObjs = commonObjs;
  20687. this.operatorListIdx = null;
  20688. this.operatorList = operatorList;
  20689. this.pageNumber = pageNumber;
  20690. this.canvasFactory = canvasFactory;
  20691. this.running = false;
  20692. this.graphicsReadyCallback = null;
  20693. this.graphicsReady = false;
  20694. this.useRequestAnimationFrame = false;
  20695. this.cancelled = false;
  20696. this.capability = createPromiseCapability();
  20697. this.task = new RenderTask(this);
  20698. this._continueBound = this._continue.bind(this);
  20699. this._scheduleNextBound = this._scheduleNext.bind(this);
  20700. this._nextBound = this._next.bind(this);
  20701. }
  20702. InternalRenderTask.prototype = {
  20703. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  20704. if (this.cancelled) {
  20705. return;
  20706. }
  20707. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  20708. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  20709. this.stepper.init(this.operatorList);
  20710. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  20711. }
  20712. var params = this.params;
  20713. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  20714. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  20715. this.operatorListIdx = 0;
  20716. this.graphicsReady = true;
  20717. if (this.graphicsReadyCallback) {
  20718. this.graphicsReadyCallback();
  20719. }
  20720. },
  20721. cancel: function InternalRenderTask_cancel() {
  20722. this.running = false;
  20723. this.cancelled = true;
  20724. this.callback('cancelled');
  20725. },
  20726. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  20727. if (!this.graphicsReady) {
  20728. if (!this.graphicsReadyCallback) {
  20729. this.graphicsReadyCallback = this._continueBound;
  20730. }
  20731. return;
  20732. }
  20733. if (this.stepper) {
  20734. this.stepper.updateOperatorList(this.operatorList);
  20735. }
  20736. if (this.running) {
  20737. return;
  20738. }
  20739. this._continue();
  20740. },
  20741. _continue: function InternalRenderTask__continue() {
  20742. this.running = true;
  20743. if (this.cancelled) {
  20744. return;
  20745. }
  20746. if (this.task.onContinue) {
  20747. this.task.onContinue(this._scheduleNextBound);
  20748. } else {
  20749. this._scheduleNext();
  20750. }
  20751. },
  20752. _scheduleNext: function InternalRenderTask__scheduleNext() {
  20753. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  20754. window.requestAnimationFrame(this._nextBound);
  20755. } else {
  20756. Promise.resolve(undefined).then(this._nextBound);
  20757. }
  20758. },
  20759. _next: function InternalRenderTask__next() {
  20760. if (this.cancelled) {
  20761. return;
  20762. }
  20763. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  20764. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  20765. this.running = false;
  20766. if (this.operatorList.lastChunk) {
  20767. this.gfx.endDrawing();
  20768. this.callback();
  20769. }
  20770. }
  20771. }
  20772. };
  20773. return InternalRenderTask;
  20774. }();
  20775. var _UnsupportedManager = function UnsupportedManagerClosure() {
  20776. var listeners = [];
  20777. return {
  20778. listen: function (cb) {
  20779. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  20780. listeners.push(cb);
  20781. },
  20782. notify: function (featureId) {
  20783. for (var i = 0, ii = listeners.length; i < ii; i++) {
  20784. listeners[i](featureId);
  20785. }
  20786. }
  20787. };
  20788. }();
  20789. exports.version = '1.7.300';
  20790. exports.build = 'cfaa621a';
  20791. exports.getDocument = getDocument;
  20792. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  20793. exports.PDFWorker = PDFWorker;
  20794. exports.PDFDocumentProxy = PDFDocumentProxy;
  20795. exports.PDFPageProxy = PDFPageProxy;
  20796. exports._UnsupportedManager = _UnsupportedManager;
  20797. /***/ }),
  20798. /* 11 */
  20799. /***/ (function(module, exports, __w_pdfjs_require__) {
  20800. "use strict";
  20801. var sharedUtil = __w_pdfjs_require__(0);
  20802. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20803. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20804. var ImageKind = sharedUtil.ImageKind;
  20805. var OPS = sharedUtil.OPS;
  20806. var Util = sharedUtil.Util;
  20807. var isNum = sharedUtil.isNum;
  20808. var isArray = sharedUtil.isArray;
  20809. var warn = sharedUtil.warn;
  20810. var createObjectURL = sharedUtil.createObjectURL;
  20811. var SVG_DEFAULTS = {
  20812. fontStyle: 'normal',
  20813. fontWeight: 'normal',
  20814. fillColor: '#000000'
  20815. };
  20816. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20817. var PNG_HEADER = new Uint8Array([
  20818. 0x89,
  20819. 0x50,
  20820. 0x4e,
  20821. 0x47,
  20822. 0x0d,
  20823. 0x0a,
  20824. 0x1a,
  20825. 0x0a
  20826. ]);
  20827. var CHUNK_WRAPPER_SIZE = 12;
  20828. var crcTable = new Int32Array(256);
  20829. for (var i = 0; i < 256; i++) {
  20830. var c = i;
  20831. for (var h = 0; h < 8; h++) {
  20832. if (c & 1) {
  20833. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20834. } else {
  20835. c = c >> 1 & 0x7fffffff;
  20836. }
  20837. }
  20838. crcTable[i] = c;
  20839. }
  20840. function crc32(data, start, end) {
  20841. var crc = -1;
  20842. for (var i = start; i < end; i++) {
  20843. var a = (crc ^ data[i]) & 0xff;
  20844. var b = crcTable[a];
  20845. crc = crc >>> 8 ^ b;
  20846. }
  20847. return crc ^ -1;
  20848. }
  20849. function writePngChunk(type, body, data, offset) {
  20850. var p = offset;
  20851. var len = body.length;
  20852. data[p] = len >> 24 & 0xff;
  20853. data[p + 1] = len >> 16 & 0xff;
  20854. data[p + 2] = len >> 8 & 0xff;
  20855. data[p + 3] = len & 0xff;
  20856. p += 4;
  20857. data[p] = type.charCodeAt(0) & 0xff;
  20858. data[p + 1] = type.charCodeAt(1) & 0xff;
  20859. data[p + 2] = type.charCodeAt(2) & 0xff;
  20860. data[p + 3] = type.charCodeAt(3) & 0xff;
  20861. p += 4;
  20862. data.set(body, p);
  20863. p += body.length;
  20864. var crc = crc32(data, offset + 4, p);
  20865. data[p] = crc >> 24 & 0xff;
  20866. data[p + 1] = crc >> 16 & 0xff;
  20867. data[p + 2] = crc >> 8 & 0xff;
  20868. data[p + 3] = crc & 0xff;
  20869. }
  20870. function adler32(data, start, end) {
  20871. var a = 1;
  20872. var b = 0;
  20873. for (var i = start; i < end; ++i) {
  20874. a = (a + (data[i] & 0xff)) % 65521;
  20875. b = (b + a) % 65521;
  20876. }
  20877. return b << 16 | a;
  20878. }
  20879. function encode(imgData, kind, forceDataSchema) {
  20880. var width = imgData.width;
  20881. var height = imgData.height;
  20882. var bitDepth, colorType, lineSize;
  20883. var bytes = imgData.data;
  20884. switch (kind) {
  20885. case ImageKind.GRAYSCALE_1BPP:
  20886. colorType = 0;
  20887. bitDepth = 1;
  20888. lineSize = width + 7 >> 3;
  20889. break;
  20890. case ImageKind.RGB_24BPP:
  20891. colorType = 2;
  20892. bitDepth = 8;
  20893. lineSize = width * 3;
  20894. break;
  20895. case ImageKind.RGBA_32BPP:
  20896. colorType = 6;
  20897. bitDepth = 8;
  20898. lineSize = width * 4;
  20899. break;
  20900. default:
  20901. throw new Error('invalid format');
  20902. }
  20903. var literals = new Uint8Array((1 + lineSize) * height);
  20904. var offsetLiterals = 0, offsetBytes = 0;
  20905. var y, i;
  20906. for (y = 0; y < height; ++y) {
  20907. literals[offsetLiterals++] = 0;
  20908. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20909. offsetBytes += lineSize;
  20910. offsetLiterals += lineSize;
  20911. }
  20912. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20913. offsetLiterals = 0;
  20914. for (y = 0; y < height; y++) {
  20915. offsetLiterals++;
  20916. for (i = 0; i < lineSize; i++) {
  20917. literals[offsetLiterals++] ^= 0xFF;
  20918. }
  20919. }
  20920. }
  20921. var ihdr = new Uint8Array([
  20922. width >> 24 & 0xff,
  20923. width >> 16 & 0xff,
  20924. width >> 8 & 0xff,
  20925. width & 0xff,
  20926. height >> 24 & 0xff,
  20927. height >> 16 & 0xff,
  20928. height >> 8 & 0xff,
  20929. height & 0xff,
  20930. bitDepth,
  20931. colorType,
  20932. 0x00,
  20933. 0x00,
  20934. 0x00
  20935. ]);
  20936. var len = literals.length;
  20937. var maxBlockLength = 0xFFFF;
  20938. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20939. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20940. var pi = 0;
  20941. idat[pi++] = 0x78;
  20942. idat[pi++] = 0x9c;
  20943. var pos = 0;
  20944. while (len > maxBlockLength) {
  20945. idat[pi++] = 0x00;
  20946. idat[pi++] = 0xff;
  20947. idat[pi++] = 0xff;
  20948. idat[pi++] = 0x00;
  20949. idat[pi++] = 0x00;
  20950. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20951. pi += maxBlockLength;
  20952. pos += maxBlockLength;
  20953. len -= maxBlockLength;
  20954. }
  20955. idat[pi++] = 0x01;
  20956. idat[pi++] = len & 0xff;
  20957. idat[pi++] = len >> 8 & 0xff;
  20958. idat[pi++] = ~len & 0xffff & 0xff;
  20959. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20960. idat.set(literals.subarray(pos), pi);
  20961. pi += literals.length - pos;
  20962. var adler = adler32(literals, 0, literals.length);
  20963. idat[pi++] = adler >> 24 & 0xff;
  20964. idat[pi++] = adler >> 16 & 0xff;
  20965. idat[pi++] = adler >> 8 & 0xff;
  20966. idat[pi++] = adler & 0xff;
  20967. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20968. var data = new Uint8Array(pngLength);
  20969. var offset = 0;
  20970. data.set(PNG_HEADER, offset);
  20971. offset += PNG_HEADER.length;
  20972. writePngChunk('IHDR', ihdr, data, offset);
  20973. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20974. writePngChunk('IDATA', idat, data, offset);
  20975. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20976. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20977. return createObjectURL(data, 'image/png', forceDataSchema);
  20978. }
  20979. return function convertImgDataToPng(imgData, forceDataSchema) {
  20980. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20981. return encode(imgData, kind, forceDataSchema);
  20982. };
  20983. }();
  20984. var SVGExtraState = function SVGExtraStateClosure() {
  20985. function SVGExtraState() {
  20986. this.fontSizeScale = 1;
  20987. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20988. this.fontSize = 0;
  20989. this.textMatrix = IDENTITY_MATRIX;
  20990. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20991. this.leading = 0;
  20992. this.x = 0;
  20993. this.y = 0;
  20994. this.lineX = 0;
  20995. this.lineY = 0;
  20996. this.charSpacing = 0;
  20997. this.wordSpacing = 0;
  20998. this.textHScale = 1;
  20999. this.textRise = 0;
  21000. this.fillColor = SVG_DEFAULTS.fillColor;
  21001. this.strokeColor = '#000000';
  21002. this.fillAlpha = 1;
  21003. this.strokeAlpha = 1;
  21004. this.lineWidth = 1;
  21005. this.lineJoin = '';
  21006. this.lineCap = '';
  21007. this.miterLimit = 0;
  21008. this.dashArray = [];
  21009. this.dashPhase = 0;
  21010. this.dependencies = [];
  21011. this.activeClipUrl = null;
  21012. this.clipGroup = null;
  21013. this.maskId = '';
  21014. }
  21015. SVGExtraState.prototype = {
  21016. clone: function SVGExtraState_clone() {
  21017. return Object.create(this);
  21018. },
  21019. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  21020. this.x = x;
  21021. this.y = y;
  21022. }
  21023. };
  21024. return SVGExtraState;
  21025. }();
  21026. var SVGGraphics = function SVGGraphicsClosure() {
  21027. function opListToTree(opList) {
  21028. var opTree = [];
  21029. var tmp = [];
  21030. var opListLen = opList.length;
  21031. for (var x = 0; x < opListLen; x++) {
  21032. if (opList[x].fn === 'save') {
  21033. opTree.push({
  21034. 'fnId': 92,
  21035. 'fn': 'group',
  21036. 'items': []
  21037. });
  21038. tmp.push(opTree);
  21039. opTree = opTree[opTree.length - 1].items;
  21040. continue;
  21041. }
  21042. if (opList[x].fn === 'restore') {
  21043. opTree = tmp.pop();
  21044. } else {
  21045. opTree.push(opList[x]);
  21046. }
  21047. }
  21048. return opTree;
  21049. }
  21050. function pf(value) {
  21051. if (value === (value | 0)) {
  21052. return value.toString();
  21053. }
  21054. var s = value.toFixed(10);
  21055. var i = s.length - 1;
  21056. if (s[i] !== '0') {
  21057. return s;
  21058. }
  21059. do {
  21060. i--;
  21061. } while (s[i] === '0');
  21062. return s.substr(0, s[i] === '.' ? i : i + 1);
  21063. }
  21064. function pm(m) {
  21065. if (m[4] === 0 && m[5] === 0) {
  21066. if (m[1] === 0 && m[2] === 0) {
  21067. if (m[0] === 1 && m[3] === 1) {
  21068. return '';
  21069. }
  21070. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21071. }
  21072. if (m[0] === m[3] && m[1] === -m[2]) {
  21073. var a = Math.acos(m[0]) * 180 / Math.PI;
  21074. return 'rotate(' + pf(a) + ')';
  21075. }
  21076. } else {
  21077. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21078. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21079. }
  21080. }
  21081. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21082. }
  21083. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21084. this.current = new SVGExtraState();
  21085. this.transformMatrix = IDENTITY_MATRIX;
  21086. this.transformStack = [];
  21087. this.extraStack = [];
  21088. this.commonObjs = commonObjs;
  21089. this.objs = objs;
  21090. this.pendingEOFill = false;
  21091. this.embedFonts = false;
  21092. this.embeddedFonts = Object.create(null);
  21093. this.cssStyle = null;
  21094. this.forceDataSchema = !!forceDataSchema;
  21095. }
  21096. var NS = 'http://www.w3.org/2000/svg';
  21097. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21098. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21099. var LINE_CAP_STYLES = [
  21100. 'butt',
  21101. 'round',
  21102. 'square'
  21103. ];
  21104. var LINE_JOIN_STYLES = [
  21105. 'miter',
  21106. 'round',
  21107. 'bevel'
  21108. ];
  21109. var clipCount = 0;
  21110. var maskCount = 0;
  21111. SVGGraphics.prototype = {
  21112. save: function SVGGraphics_save() {
  21113. this.transformStack.push(this.transformMatrix);
  21114. var old = this.current;
  21115. this.extraStack.push(old);
  21116. this.current = old.clone();
  21117. },
  21118. restore: function SVGGraphics_restore() {
  21119. this.transformMatrix = this.transformStack.pop();
  21120. this.current = this.extraStack.pop();
  21121. this.tgrp = null;
  21122. },
  21123. group: function SVGGraphics_group(items) {
  21124. this.save();
  21125. this.executeOpTree(items);
  21126. this.restore();
  21127. },
  21128. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21129. var fnArray = operatorList.fnArray;
  21130. var fnArrayLen = fnArray.length;
  21131. var argsArray = operatorList.argsArray;
  21132. var self = this;
  21133. for (var i = 0; i < fnArrayLen; i++) {
  21134. if (OPS.dependency === fnArray[i]) {
  21135. var deps = argsArray[i];
  21136. for (var n = 0, nn = deps.length; n < nn; n++) {
  21137. var obj = deps[n];
  21138. var common = obj.substring(0, 2) === 'g_';
  21139. var promise;
  21140. if (common) {
  21141. promise = new Promise(function (resolve) {
  21142. self.commonObjs.get(obj, resolve);
  21143. });
  21144. } else {
  21145. promise = new Promise(function (resolve) {
  21146. self.objs.get(obj, resolve);
  21147. });
  21148. }
  21149. this.current.dependencies.push(promise);
  21150. }
  21151. }
  21152. }
  21153. return Promise.all(this.current.dependencies);
  21154. },
  21155. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21156. var transformMatrix = [
  21157. a,
  21158. b,
  21159. c,
  21160. d,
  21161. e,
  21162. f
  21163. ];
  21164. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21165. this.tgrp = null;
  21166. },
  21167. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21168. this.viewport = viewport;
  21169. var svgElement = this._initialize(viewport);
  21170. return this.loadDependencies(operatorList).then(function () {
  21171. this.transformMatrix = IDENTITY_MATRIX;
  21172. var opTree = this.convertOpList(operatorList);
  21173. this.executeOpTree(opTree);
  21174. return svgElement;
  21175. }.bind(this));
  21176. },
  21177. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21178. var argsArray = operatorList.argsArray;
  21179. var fnArray = operatorList.fnArray;
  21180. var fnArrayLen = fnArray.length;
  21181. var REVOPS = [];
  21182. var opList = [];
  21183. for (var op in OPS) {
  21184. REVOPS[OPS[op]] = op;
  21185. }
  21186. for (var x = 0; x < fnArrayLen; x++) {
  21187. var fnId = fnArray[x];
  21188. opList.push({
  21189. 'fnId': fnId,
  21190. 'fn': REVOPS[fnId],
  21191. 'args': argsArray[x]
  21192. });
  21193. }
  21194. return opListToTree(opList);
  21195. },
  21196. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21197. var opTreeLen = opTree.length;
  21198. for (var x = 0; x < opTreeLen; x++) {
  21199. var fn = opTree[x].fn;
  21200. var fnId = opTree[x].fnId;
  21201. var args = opTree[x].args;
  21202. switch (fnId | 0) {
  21203. case OPS.beginText:
  21204. this.beginText();
  21205. break;
  21206. case OPS.setLeading:
  21207. this.setLeading(args);
  21208. break;
  21209. case OPS.setLeadingMoveText:
  21210. this.setLeadingMoveText(args[0], args[1]);
  21211. break;
  21212. case OPS.setFont:
  21213. this.setFont(args);
  21214. break;
  21215. case OPS.showText:
  21216. this.showText(args[0]);
  21217. break;
  21218. case OPS.showSpacedText:
  21219. this.showText(args[0]);
  21220. break;
  21221. case OPS.endText:
  21222. this.endText();
  21223. break;
  21224. case OPS.moveText:
  21225. this.moveText(args[0], args[1]);
  21226. break;
  21227. case OPS.setCharSpacing:
  21228. this.setCharSpacing(args[0]);
  21229. break;
  21230. case OPS.setWordSpacing:
  21231. this.setWordSpacing(args[0]);
  21232. break;
  21233. case OPS.setHScale:
  21234. this.setHScale(args[0]);
  21235. break;
  21236. case OPS.setTextMatrix:
  21237. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21238. break;
  21239. case OPS.setLineWidth:
  21240. this.setLineWidth(args[0]);
  21241. break;
  21242. case OPS.setLineJoin:
  21243. this.setLineJoin(args[0]);
  21244. break;
  21245. case OPS.setLineCap:
  21246. this.setLineCap(args[0]);
  21247. break;
  21248. case OPS.setMiterLimit:
  21249. this.setMiterLimit(args[0]);
  21250. break;
  21251. case OPS.setFillRGBColor:
  21252. this.setFillRGBColor(args[0], args[1], args[2]);
  21253. break;
  21254. case OPS.setStrokeRGBColor:
  21255. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21256. break;
  21257. case OPS.setDash:
  21258. this.setDash(args[0], args[1]);
  21259. break;
  21260. case OPS.setGState:
  21261. this.setGState(args[0]);
  21262. break;
  21263. case OPS.fill:
  21264. this.fill();
  21265. break;
  21266. case OPS.eoFill:
  21267. this.eoFill();
  21268. break;
  21269. case OPS.stroke:
  21270. this.stroke();
  21271. break;
  21272. case OPS.fillStroke:
  21273. this.fillStroke();
  21274. break;
  21275. case OPS.eoFillStroke:
  21276. this.eoFillStroke();
  21277. break;
  21278. case OPS.clip:
  21279. this.clip('nonzero');
  21280. break;
  21281. case OPS.eoClip:
  21282. this.clip('evenodd');
  21283. break;
  21284. case OPS.paintSolidColorImageMask:
  21285. this.paintSolidColorImageMask();
  21286. break;
  21287. case OPS.paintJpegXObject:
  21288. this.paintJpegXObject(args[0], args[1], args[2]);
  21289. break;
  21290. case OPS.paintImageXObject:
  21291. this.paintImageXObject(args[0]);
  21292. break;
  21293. case OPS.paintInlineImageXObject:
  21294. this.paintInlineImageXObject(args[0]);
  21295. break;
  21296. case OPS.paintImageMaskXObject:
  21297. this.paintImageMaskXObject(args[0]);
  21298. break;
  21299. case OPS.paintFormXObjectBegin:
  21300. this.paintFormXObjectBegin(args[0], args[1]);
  21301. break;
  21302. case OPS.paintFormXObjectEnd:
  21303. this.paintFormXObjectEnd();
  21304. break;
  21305. case OPS.closePath:
  21306. this.closePath();
  21307. break;
  21308. case OPS.closeStroke:
  21309. this.closeStroke();
  21310. break;
  21311. case OPS.closeFillStroke:
  21312. this.closeFillStroke();
  21313. break;
  21314. case OPS.nextLine:
  21315. this.nextLine();
  21316. break;
  21317. case OPS.transform:
  21318. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21319. break;
  21320. case OPS.constructPath:
  21321. this.constructPath(args[0], args[1]);
  21322. break;
  21323. case OPS.endPath:
  21324. this.endPath();
  21325. break;
  21326. case 92:
  21327. this.group(opTree[x].items);
  21328. break;
  21329. default:
  21330. warn('Unimplemented operator ' + fn);
  21331. break;
  21332. }
  21333. }
  21334. },
  21335. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21336. this.current.wordSpacing = wordSpacing;
  21337. },
  21338. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  21339. this.current.charSpacing = charSpacing;
  21340. },
  21341. nextLine: function SVGGraphics_nextLine() {
  21342. this.moveText(0, this.current.leading);
  21343. },
  21344. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  21345. var current = this.current;
  21346. this.current.textMatrix = this.current.lineMatrix = [
  21347. a,
  21348. b,
  21349. c,
  21350. d,
  21351. e,
  21352. f
  21353. ];
  21354. this.current.x = this.current.lineX = 0;
  21355. this.current.y = this.current.lineY = 0;
  21356. current.xcoords = [];
  21357. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21358. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21359. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21360. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21361. current.txtElement = document.createElementNS(NS, 'svg:text');
  21362. current.txtElement.appendChild(current.tspan);
  21363. },
  21364. beginText: function SVGGraphics_beginText() {
  21365. this.current.x = this.current.lineX = 0;
  21366. this.current.y = this.current.lineY = 0;
  21367. this.current.textMatrix = IDENTITY_MATRIX;
  21368. this.current.lineMatrix = IDENTITY_MATRIX;
  21369. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21370. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  21371. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  21372. this.current.xcoords = [];
  21373. },
  21374. moveText: function SVGGraphics_moveText(x, y) {
  21375. var current = this.current;
  21376. this.current.x = this.current.lineX += x;
  21377. this.current.y = this.current.lineY += y;
  21378. current.xcoords = [];
  21379. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21380. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21381. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21382. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21383. },
  21384. showText: function SVGGraphics_showText(glyphs) {
  21385. var current = this.current;
  21386. var font = current.font;
  21387. var fontSize = current.fontSize;
  21388. if (fontSize === 0) {
  21389. return;
  21390. }
  21391. var charSpacing = current.charSpacing;
  21392. var wordSpacing = current.wordSpacing;
  21393. var fontDirection = current.fontDirection;
  21394. var textHScale = current.textHScale * fontDirection;
  21395. var glyphsLength = glyphs.length;
  21396. var vertical = font.vertical;
  21397. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  21398. var x = 0, i;
  21399. for (i = 0; i < glyphsLength; ++i) {
  21400. var glyph = glyphs[i];
  21401. if (glyph === null) {
  21402. x += fontDirection * wordSpacing;
  21403. continue;
  21404. } else if (isNum(glyph)) {
  21405. x += -glyph * fontSize * 0.001;
  21406. continue;
  21407. }
  21408. current.xcoords.push(current.x + x * textHScale);
  21409. var width = glyph.width;
  21410. var character = glyph.fontChar;
  21411. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  21412. x += charWidth;
  21413. current.tspan.textContent += character;
  21414. }
  21415. if (vertical) {
  21416. current.y -= x * textHScale;
  21417. } else {
  21418. current.x += x * textHScale;
  21419. }
  21420. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  21421. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21422. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21423. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21424. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  21425. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  21426. }
  21427. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  21428. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  21429. }
  21430. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  21431. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  21432. }
  21433. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  21434. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  21435. current.txtElement.appendChild(current.tspan);
  21436. current.txtgrp.appendChild(current.txtElement);
  21437. this._ensureTransformGroup().appendChild(current.txtElement);
  21438. },
  21439. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  21440. this.setLeading(-y);
  21441. this.moveText(x, y);
  21442. },
  21443. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  21444. if (!this.cssStyle) {
  21445. this.cssStyle = document.createElementNS(NS, 'svg:style');
  21446. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  21447. this.defs.appendChild(this.cssStyle);
  21448. }
  21449. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  21450. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  21451. },
  21452. setFont: function SVGGraphics_setFont(details) {
  21453. var current = this.current;
  21454. var fontObj = this.commonObjs.get(details[0]);
  21455. var size = details[1];
  21456. this.current.font = fontObj;
  21457. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  21458. this.addFontStyle(fontObj);
  21459. this.embeddedFonts[fontObj.loadedName] = fontObj;
  21460. }
  21461. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  21462. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  21463. var italic = fontObj.italic ? 'italic' : 'normal';
  21464. if (size < 0) {
  21465. size = -size;
  21466. current.fontDirection = -1;
  21467. } else {
  21468. current.fontDirection = 1;
  21469. }
  21470. current.fontSize = size;
  21471. current.fontFamily = fontObj.loadedName;
  21472. current.fontWeight = bold;
  21473. current.fontStyle = italic;
  21474. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21475. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21476. current.xcoords = [];
  21477. },
  21478. endText: function SVGGraphics_endText() {
  21479. },
  21480. setLineWidth: function SVGGraphics_setLineWidth(width) {
  21481. this.current.lineWidth = width;
  21482. },
  21483. setLineCap: function SVGGraphics_setLineCap(style) {
  21484. this.current.lineCap = LINE_CAP_STYLES[style];
  21485. },
  21486. setLineJoin: function SVGGraphics_setLineJoin(style) {
  21487. this.current.lineJoin = LINE_JOIN_STYLES[style];
  21488. },
  21489. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  21490. this.current.miterLimit = limit;
  21491. },
  21492. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  21493. var color = Util.makeCssRgb(r, g, b);
  21494. this.current.strokeColor = color;
  21495. },
  21496. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  21497. var color = Util.makeCssRgb(r, g, b);
  21498. this.current.fillColor = color;
  21499. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21500. this.current.xcoords = [];
  21501. },
  21502. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  21503. this.current.dashArray = dashArray;
  21504. this.current.dashPhase = dashPhase;
  21505. },
  21506. constructPath: function SVGGraphics_constructPath(ops, args) {
  21507. var current = this.current;
  21508. var x = current.x, y = current.y;
  21509. current.path = document.createElementNS(NS, 'svg:path');
  21510. var d = [];
  21511. var opLength = ops.length;
  21512. for (var i = 0, j = 0; i < opLength; i++) {
  21513. switch (ops[i] | 0) {
  21514. case OPS.rectangle:
  21515. x = args[j++];
  21516. y = args[j++];
  21517. var width = args[j++];
  21518. var height = args[j++];
  21519. var xw = x + width;
  21520. var yh = y + height;
  21521. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  21522. break;
  21523. case OPS.moveTo:
  21524. x = args[j++];
  21525. y = args[j++];
  21526. d.push('M', pf(x), pf(y));
  21527. break;
  21528. case OPS.lineTo:
  21529. x = args[j++];
  21530. y = args[j++];
  21531. d.push('L', pf(x), pf(y));
  21532. break;
  21533. case OPS.curveTo:
  21534. x = args[j + 4];
  21535. y = args[j + 5];
  21536. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21537. j += 6;
  21538. break;
  21539. case OPS.curveTo2:
  21540. x = args[j + 2];
  21541. y = args[j + 3];
  21542. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21543. j += 4;
  21544. break;
  21545. case OPS.curveTo3:
  21546. x = args[j + 2];
  21547. y = args[j + 3];
  21548. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21549. j += 4;
  21550. break;
  21551. case OPS.closePath:
  21552. d.push('Z');
  21553. break;
  21554. }
  21555. }
  21556. current.path.setAttributeNS(null, 'd', d.join(' '));
  21557. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  21558. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  21559. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  21560. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  21561. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  21562. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  21563. current.path.setAttributeNS(null, 'fill', 'none');
  21564. this._ensureTransformGroup().appendChild(current.path);
  21565. current.element = current.path;
  21566. current.setCurrentPoint(x, y);
  21567. },
  21568. endPath: function SVGGraphics_endPath() {
  21569. },
  21570. clip: function SVGGraphics_clip(type) {
  21571. var current = this.current;
  21572. var clipId = 'clippath' + clipCount;
  21573. clipCount++;
  21574. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  21575. clipPath.setAttributeNS(null, 'id', clipId);
  21576. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21577. var clipElement = current.element.cloneNode();
  21578. if (type === 'evenodd') {
  21579. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  21580. } else {
  21581. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  21582. }
  21583. clipPath.appendChild(clipElement);
  21584. this.defs.appendChild(clipPath);
  21585. if (current.activeClipUrl) {
  21586. current.clipGroup = null;
  21587. this.extraStack.forEach(function (prev) {
  21588. prev.clipGroup = null;
  21589. });
  21590. }
  21591. current.activeClipUrl = 'url(#' + clipId + ')';
  21592. this.tgrp = null;
  21593. },
  21594. closePath: function SVGGraphics_closePath() {
  21595. var current = this.current;
  21596. var d = current.path.getAttributeNS(null, 'd');
  21597. d += 'Z';
  21598. current.path.setAttributeNS(null, 'd', d);
  21599. },
  21600. setLeading: function SVGGraphics_setLeading(leading) {
  21601. this.current.leading = -leading;
  21602. },
  21603. setTextRise: function SVGGraphics_setTextRise(textRise) {
  21604. this.current.textRise = textRise;
  21605. },
  21606. setHScale: function SVGGraphics_setHScale(scale) {
  21607. this.current.textHScale = scale / 100;
  21608. },
  21609. setGState: function SVGGraphics_setGState(states) {
  21610. for (var i = 0, ii = states.length; i < ii; i++) {
  21611. var state = states[i];
  21612. var key = state[0];
  21613. var value = state[1];
  21614. switch (key) {
  21615. case 'LW':
  21616. this.setLineWidth(value);
  21617. break;
  21618. case 'LC':
  21619. this.setLineCap(value);
  21620. break;
  21621. case 'LJ':
  21622. this.setLineJoin(value);
  21623. break;
  21624. case 'ML':
  21625. this.setMiterLimit(value);
  21626. break;
  21627. case 'D':
  21628. this.setDash(value[0], value[1]);
  21629. break;
  21630. case 'Font':
  21631. this.setFont(value);
  21632. break;
  21633. default:
  21634. warn('Unimplemented graphic state ' + key);
  21635. break;
  21636. }
  21637. }
  21638. },
  21639. fill: function SVGGraphics_fill() {
  21640. var current = this.current;
  21641. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21642. },
  21643. stroke: function SVGGraphics_stroke() {
  21644. var current = this.current;
  21645. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  21646. current.element.setAttributeNS(null, 'fill', 'none');
  21647. },
  21648. eoFill: function SVGGraphics_eoFill() {
  21649. var current = this.current;
  21650. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21651. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21652. },
  21653. fillStroke: function SVGGraphics_fillStroke() {
  21654. this.stroke();
  21655. this.fill();
  21656. },
  21657. eoFillStroke: function SVGGraphics_eoFillStroke() {
  21658. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21659. this.fillStroke();
  21660. },
  21661. closeStroke: function SVGGraphics_closeStroke() {
  21662. this.closePath();
  21663. this.stroke();
  21664. },
  21665. closeFillStroke: function SVGGraphics_closeFillStroke() {
  21666. this.closePath();
  21667. this.fillStroke();
  21668. },
  21669. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  21670. var current = this.current;
  21671. var rect = document.createElementNS(NS, 'svg:rect');
  21672. rect.setAttributeNS(null, 'x', '0');
  21673. rect.setAttributeNS(null, 'y', '0');
  21674. rect.setAttributeNS(null, 'width', '1px');
  21675. rect.setAttributeNS(null, 'height', '1px');
  21676. rect.setAttributeNS(null, 'fill', current.fillColor);
  21677. this._ensureTransformGroup().appendChild(rect);
  21678. },
  21679. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  21680. var imgObj = this.objs.get(objId);
  21681. var imgEl = document.createElementNS(NS, 'svg:image');
  21682. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  21683. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  21684. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  21685. imgEl.setAttributeNS(null, 'x', '0');
  21686. imgEl.setAttributeNS(null, 'y', pf(-h));
  21687. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  21688. this._ensureTransformGroup().appendChild(imgEl);
  21689. },
  21690. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  21691. var imgData = this.objs.get(objId);
  21692. if (!imgData) {
  21693. warn('Dependent image isn\'t ready yet');
  21694. return;
  21695. }
  21696. this.paintInlineImageXObject(imgData);
  21697. },
  21698. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  21699. var width = imgData.width;
  21700. var height = imgData.height;
  21701. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  21702. var cliprect = document.createElementNS(NS, 'svg:rect');
  21703. cliprect.setAttributeNS(null, 'x', '0');
  21704. cliprect.setAttributeNS(null, 'y', '0');
  21705. cliprect.setAttributeNS(null, 'width', pf(width));
  21706. cliprect.setAttributeNS(null, 'height', pf(height));
  21707. this.current.element = cliprect;
  21708. this.clip('nonzero');
  21709. var imgEl = document.createElementNS(NS, 'svg:image');
  21710. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  21711. imgEl.setAttributeNS(null, 'x', '0');
  21712. imgEl.setAttributeNS(null, 'y', pf(-height));
  21713. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  21714. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  21715. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  21716. if (mask) {
  21717. mask.appendChild(imgEl);
  21718. } else {
  21719. this._ensureTransformGroup().appendChild(imgEl);
  21720. }
  21721. },
  21722. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  21723. var current = this.current;
  21724. var width = imgData.width;
  21725. var height = imgData.height;
  21726. var fillColor = current.fillColor;
  21727. current.maskId = 'mask' + maskCount++;
  21728. var mask = document.createElementNS(NS, 'svg:mask');
  21729. mask.setAttributeNS(null, 'id', current.maskId);
  21730. var rect = document.createElementNS(NS, 'svg:rect');
  21731. rect.setAttributeNS(null, 'x', '0');
  21732. rect.setAttributeNS(null, 'y', '0');
  21733. rect.setAttributeNS(null, 'width', pf(width));
  21734. rect.setAttributeNS(null, 'height', pf(height));
  21735. rect.setAttributeNS(null, 'fill', fillColor);
  21736. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  21737. this.defs.appendChild(mask);
  21738. this._ensureTransformGroup().appendChild(rect);
  21739. this.paintInlineImageXObject(imgData, mask);
  21740. },
  21741. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  21742. if (isArray(matrix) && matrix.length === 6) {
  21743. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21744. }
  21745. if (isArray(bbox) && bbox.length === 4) {
  21746. var width = bbox[2] - bbox[0];
  21747. var height = bbox[3] - bbox[1];
  21748. var cliprect = document.createElementNS(NS, 'svg:rect');
  21749. cliprect.setAttributeNS(null, 'x', bbox[0]);
  21750. cliprect.setAttributeNS(null, 'y', bbox[1]);
  21751. cliprect.setAttributeNS(null, 'width', pf(width));
  21752. cliprect.setAttributeNS(null, 'height', pf(height));
  21753. this.current.element = cliprect;
  21754. this.clip('nonzero');
  21755. this.endPath();
  21756. }
  21757. },
  21758. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  21759. },
  21760. _initialize: function SVGGraphics_initialize(viewport) {
  21761. var svg = document.createElementNS(NS, 'svg:svg');
  21762. svg.setAttributeNS(null, 'version', '1.1');
  21763. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  21764. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  21765. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  21766. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  21767. var definitions = document.createElementNS(NS, 'svg:defs');
  21768. svg.appendChild(definitions);
  21769. this.defs = definitions;
  21770. var rootGroup = document.createElementNS(NS, 'svg:g');
  21771. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  21772. svg.appendChild(rootGroup);
  21773. this.svg = rootGroup;
  21774. return svg;
  21775. },
  21776. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  21777. if (!this.current.clipGroup) {
  21778. var clipGroup = document.createElementNS(NS, 'svg:g');
  21779. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  21780. this.svg.appendChild(clipGroup);
  21781. this.current.clipGroup = clipGroup;
  21782. }
  21783. return this.current.clipGroup;
  21784. },
  21785. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  21786. if (!this.tgrp) {
  21787. this.tgrp = document.createElementNS(NS, 'svg:g');
  21788. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21789. if (this.current.activeClipUrl) {
  21790. this._ensureClipGroup().appendChild(this.tgrp);
  21791. } else {
  21792. this.svg.appendChild(this.tgrp);
  21793. }
  21794. }
  21795. return this.tgrp;
  21796. }
  21797. };
  21798. return SVGGraphics;
  21799. }();
  21800. exports.SVGGraphics = SVGGraphics;
  21801. /***/ }),
  21802. /* 12 */
  21803. /***/ (function(module, exports, __w_pdfjs_require__) {
  21804. "use strict";
  21805. var sharedUtil = __w_pdfjs_require__(0);
  21806. var displayDOMUtils = __w_pdfjs_require__(3);
  21807. var Util = sharedUtil.Util;
  21808. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21809. var CustomStyle = displayDOMUtils.CustomStyle;
  21810. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21811. var renderTextLayer = function renderTextLayerClosure() {
  21812. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21813. var NonWhitespaceRegexp = /\S/;
  21814. function isAllWhitespace(str) {
  21815. return !NonWhitespaceRegexp.test(str);
  21816. }
  21817. var styleBuf = [
  21818. 'left: ',
  21819. 0,
  21820. 'px; top: ',
  21821. 0,
  21822. 'px; font-size: ',
  21823. 0,
  21824. 'px; font-family: ',
  21825. '',
  21826. ';'
  21827. ];
  21828. function appendText(task, geom, styles) {
  21829. var textDiv = document.createElement('div');
  21830. var textDivProperties = {
  21831. style: null,
  21832. angle: 0,
  21833. canvasWidth: 0,
  21834. isWhitespace: false,
  21835. originalTransform: null,
  21836. paddingBottom: 0,
  21837. paddingLeft: 0,
  21838. paddingRight: 0,
  21839. paddingTop: 0,
  21840. scale: 1
  21841. };
  21842. task._textDivs.push(textDiv);
  21843. if (isAllWhitespace(geom.str)) {
  21844. textDivProperties.isWhitespace = true;
  21845. task._textDivProperties.set(textDiv, textDivProperties);
  21846. return;
  21847. }
  21848. var tx = Util.transform(task._viewport.transform, geom.transform);
  21849. var angle = Math.atan2(tx[1], tx[0]);
  21850. var style = styles[geom.fontName];
  21851. if (style.vertical) {
  21852. angle += Math.PI / 2;
  21853. }
  21854. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21855. var fontAscent = fontHeight;
  21856. if (style.ascent) {
  21857. fontAscent = style.ascent * fontAscent;
  21858. } else if (style.descent) {
  21859. fontAscent = (1 + style.descent) * fontAscent;
  21860. }
  21861. var left;
  21862. var top;
  21863. if (angle === 0) {
  21864. left = tx[4];
  21865. top = tx[5] - fontAscent;
  21866. } else {
  21867. left = tx[4] + fontAscent * Math.sin(angle);
  21868. top = tx[5] - fontAscent * Math.cos(angle);
  21869. }
  21870. styleBuf[1] = left;
  21871. styleBuf[3] = top;
  21872. styleBuf[5] = fontHeight;
  21873. styleBuf[7] = style.fontFamily;
  21874. textDivProperties.style = styleBuf.join('');
  21875. textDiv.setAttribute('style', textDivProperties.style);
  21876. textDiv.textContent = geom.str;
  21877. if (getDefaultSetting('pdfBug')) {
  21878. textDiv.dataset.fontName = geom.fontName;
  21879. }
  21880. if (angle !== 0) {
  21881. textDivProperties.angle = angle * (180 / Math.PI);
  21882. }
  21883. if (geom.str.length > 1) {
  21884. if (style.vertical) {
  21885. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21886. } else {
  21887. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21888. }
  21889. }
  21890. task._textDivProperties.set(textDiv, textDivProperties);
  21891. if (task._enhanceTextSelection) {
  21892. var angleCos = 1, angleSin = 0;
  21893. if (angle !== 0) {
  21894. angleCos = Math.cos(angle);
  21895. angleSin = Math.sin(angle);
  21896. }
  21897. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21898. var divHeight = fontHeight;
  21899. var m, b;
  21900. if (angle !== 0) {
  21901. m = [
  21902. angleCos,
  21903. angleSin,
  21904. -angleSin,
  21905. angleCos,
  21906. left,
  21907. top
  21908. ];
  21909. b = Util.getAxialAlignedBoundingBox([
  21910. 0,
  21911. 0,
  21912. divWidth,
  21913. divHeight
  21914. ], m);
  21915. } else {
  21916. b = [
  21917. left,
  21918. top,
  21919. left + divWidth,
  21920. top + divHeight
  21921. ];
  21922. }
  21923. task._bounds.push({
  21924. left: b[0],
  21925. top: b[1],
  21926. right: b[2],
  21927. bottom: b[3],
  21928. div: textDiv,
  21929. size: [
  21930. divWidth,
  21931. divHeight
  21932. ],
  21933. m: m
  21934. });
  21935. }
  21936. }
  21937. function render(task) {
  21938. if (task._canceled) {
  21939. return;
  21940. }
  21941. var textLayerFrag = task._container;
  21942. var textDivs = task._textDivs;
  21943. var capability = task._capability;
  21944. var textDivsLength = textDivs.length;
  21945. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21946. task._renderingDone = true;
  21947. capability.resolve();
  21948. return;
  21949. }
  21950. var canvas = document.createElement('canvas');
  21951. var ctx = canvas.getContext('2d', { alpha: false });
  21952. var lastFontSize;
  21953. var lastFontFamily;
  21954. for (var i = 0; i < textDivsLength; i++) {
  21955. var textDiv = textDivs[i];
  21956. var textDivProperties = task._textDivProperties.get(textDiv);
  21957. if (textDivProperties.isWhitespace) {
  21958. continue;
  21959. }
  21960. var fontSize = textDiv.style.fontSize;
  21961. var fontFamily = textDiv.style.fontFamily;
  21962. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21963. ctx.font = fontSize + ' ' + fontFamily;
  21964. lastFontSize = fontSize;
  21965. lastFontFamily = fontFamily;
  21966. }
  21967. var width = ctx.measureText(textDiv.textContent).width;
  21968. textLayerFrag.appendChild(textDiv);
  21969. var transform = '';
  21970. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21971. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21972. transform = 'scaleX(' + textDivProperties.scale + ')';
  21973. }
  21974. if (textDivProperties.angle !== 0) {
  21975. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21976. }
  21977. if (transform !== '') {
  21978. textDivProperties.originalTransform = transform;
  21979. CustomStyle.setProp('transform', textDiv, transform);
  21980. }
  21981. task._textDivProperties.set(textDiv, textDivProperties);
  21982. }
  21983. task._renderingDone = true;
  21984. capability.resolve();
  21985. }
  21986. function expand(task) {
  21987. var bounds = task._bounds;
  21988. var viewport = task._viewport;
  21989. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21990. for (var i = 0; i < expanded.length; i++) {
  21991. var div = bounds[i].div;
  21992. var divProperties = task._textDivProperties.get(div);
  21993. if (divProperties.angle === 0) {
  21994. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21995. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21996. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21997. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21998. task._textDivProperties.set(div, divProperties);
  21999. continue;
  22000. }
  22001. var e = expanded[i], b = bounds[i];
  22002. var m = b.m, c = m[0], s = m[1];
  22003. var points = [
  22004. [
  22005. 0,
  22006. 0
  22007. ],
  22008. [
  22009. 0,
  22010. b.size[1]
  22011. ],
  22012. [
  22013. b.size[0],
  22014. 0
  22015. ],
  22016. b.size
  22017. ];
  22018. var ts = new Float64Array(64);
  22019. points.forEach(function (p, i) {
  22020. var t = Util.applyTransform(p, m);
  22021. ts[i + 0] = c && (e.left - t[0]) / c;
  22022. ts[i + 4] = s && (e.top - t[1]) / s;
  22023. ts[i + 8] = c && (e.right - t[0]) / c;
  22024. ts[i + 12] = s && (e.bottom - t[1]) / s;
  22025. ts[i + 16] = s && (e.left - t[0]) / -s;
  22026. ts[i + 20] = c && (e.top - t[1]) / c;
  22027. ts[i + 24] = s && (e.right - t[0]) / -s;
  22028. ts[i + 28] = c && (e.bottom - t[1]) / c;
  22029. ts[i + 32] = c && (e.left - t[0]) / -c;
  22030. ts[i + 36] = s && (e.top - t[1]) / -s;
  22031. ts[i + 40] = c && (e.right - t[0]) / -c;
  22032. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  22033. ts[i + 48] = s && (e.left - t[0]) / s;
  22034. ts[i + 52] = c && (e.top - t[1]) / -c;
  22035. ts[i + 56] = s && (e.right - t[0]) / s;
  22036. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  22037. });
  22038. var findPositiveMin = function (ts, offset, count) {
  22039. var result = 0;
  22040. for (var i = 0; i < count; i++) {
  22041. var t = ts[offset++];
  22042. if (t > 0) {
  22043. result = result ? Math.min(t, result) : t;
  22044. }
  22045. }
  22046. return result;
  22047. };
  22048. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  22049. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  22050. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  22051. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  22052. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  22053. task._textDivProperties.set(div, divProperties);
  22054. }
  22055. }
  22056. function expandBounds(width, height, boxes) {
  22057. var bounds = boxes.map(function (box, i) {
  22058. return {
  22059. x1: box.left,
  22060. y1: box.top,
  22061. x2: box.right,
  22062. y2: box.bottom,
  22063. index: i,
  22064. x1New: undefined,
  22065. x2New: undefined
  22066. };
  22067. });
  22068. expandBoundsLTR(width, bounds);
  22069. var expanded = new Array(boxes.length);
  22070. bounds.forEach(function (b) {
  22071. var i = b.index;
  22072. expanded[i] = {
  22073. left: b.x1New,
  22074. top: 0,
  22075. right: b.x2New,
  22076. bottom: 0
  22077. };
  22078. });
  22079. boxes.map(function (box, i) {
  22080. var e = expanded[i], b = bounds[i];
  22081. b.x1 = box.top;
  22082. b.y1 = width - e.right;
  22083. b.x2 = box.bottom;
  22084. b.y2 = width - e.left;
  22085. b.index = i;
  22086. b.x1New = undefined;
  22087. b.x2New = undefined;
  22088. });
  22089. expandBoundsLTR(height, bounds);
  22090. bounds.forEach(function (b) {
  22091. var i = b.index;
  22092. expanded[i].top = b.x1New;
  22093. expanded[i].bottom = b.x2New;
  22094. });
  22095. return expanded;
  22096. }
  22097. function expandBoundsLTR(width, bounds) {
  22098. bounds.sort(function (a, b) {
  22099. return a.x1 - b.x1 || a.index - b.index;
  22100. });
  22101. var fakeBoundary = {
  22102. x1: -Infinity,
  22103. y1: -Infinity,
  22104. x2: 0,
  22105. y2: Infinity,
  22106. index: -1,
  22107. x1New: 0,
  22108. x2New: 0
  22109. };
  22110. var horizon = [{
  22111. start: -Infinity,
  22112. end: Infinity,
  22113. boundary: fakeBoundary
  22114. }];
  22115. bounds.forEach(function (boundary) {
  22116. var i = 0;
  22117. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22118. i++;
  22119. }
  22120. var j = horizon.length - 1;
  22121. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22122. j--;
  22123. }
  22124. var horizonPart, affectedBoundary;
  22125. var q, k, maxXNew = -Infinity;
  22126. for (q = i; q <= j; q++) {
  22127. horizonPart = horizon[q];
  22128. affectedBoundary = horizonPart.boundary;
  22129. var xNew;
  22130. if (affectedBoundary.x2 > boundary.x1) {
  22131. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22132. } else if (affectedBoundary.x2New === undefined) {
  22133. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22134. } else {
  22135. xNew = affectedBoundary.x2New;
  22136. }
  22137. if (xNew > maxXNew) {
  22138. maxXNew = xNew;
  22139. }
  22140. }
  22141. boundary.x1New = maxXNew;
  22142. for (q = i; q <= j; q++) {
  22143. horizonPart = horizon[q];
  22144. affectedBoundary = horizonPart.boundary;
  22145. if (affectedBoundary.x2New === undefined) {
  22146. if (affectedBoundary.x2 > boundary.x1) {
  22147. if (affectedBoundary.index > boundary.index) {
  22148. affectedBoundary.x2New = affectedBoundary.x2;
  22149. }
  22150. } else {
  22151. affectedBoundary.x2New = maxXNew;
  22152. }
  22153. } else if (affectedBoundary.x2New > maxXNew) {
  22154. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22155. }
  22156. }
  22157. var changedHorizon = [], lastBoundary = null;
  22158. for (q = i; q <= j; q++) {
  22159. horizonPart = horizon[q];
  22160. affectedBoundary = horizonPart.boundary;
  22161. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22162. if (lastBoundary === useBoundary) {
  22163. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22164. } else {
  22165. changedHorizon.push({
  22166. start: horizonPart.start,
  22167. end: horizonPart.end,
  22168. boundary: useBoundary
  22169. });
  22170. lastBoundary = useBoundary;
  22171. }
  22172. }
  22173. if (horizon[i].start < boundary.y1) {
  22174. changedHorizon[0].start = boundary.y1;
  22175. changedHorizon.unshift({
  22176. start: horizon[i].start,
  22177. end: boundary.y1,
  22178. boundary: horizon[i].boundary
  22179. });
  22180. }
  22181. if (boundary.y2 < horizon[j].end) {
  22182. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22183. changedHorizon.push({
  22184. start: boundary.y2,
  22185. end: horizon[j].end,
  22186. boundary: horizon[j].boundary
  22187. });
  22188. }
  22189. for (q = i; q <= j; q++) {
  22190. horizonPart = horizon[q];
  22191. affectedBoundary = horizonPart.boundary;
  22192. if (affectedBoundary.x2New !== undefined) {
  22193. continue;
  22194. }
  22195. var used = false;
  22196. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22197. used = horizon[k].boundary === affectedBoundary;
  22198. }
  22199. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22200. used = horizon[k].boundary === affectedBoundary;
  22201. }
  22202. for (k = 0; !used && k < changedHorizon.length; k++) {
  22203. used = changedHorizon[k].boundary === affectedBoundary;
  22204. }
  22205. if (!used) {
  22206. affectedBoundary.x2New = maxXNew;
  22207. }
  22208. }
  22209. Array.prototype.splice.apply(horizon, [
  22210. i,
  22211. j - i + 1
  22212. ].concat(changedHorizon));
  22213. });
  22214. horizon.forEach(function (horizonPart) {
  22215. var affectedBoundary = horizonPart.boundary;
  22216. if (affectedBoundary.x2New === undefined) {
  22217. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22218. }
  22219. });
  22220. }
  22221. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22222. this._textContent = textContent;
  22223. this._container = container;
  22224. this._viewport = viewport;
  22225. this._textDivs = textDivs || [];
  22226. this._textDivProperties = new WeakMap();
  22227. this._renderingDone = false;
  22228. this._canceled = false;
  22229. this._capability = createPromiseCapability();
  22230. this._renderTimer = null;
  22231. this._bounds = [];
  22232. this._enhanceTextSelection = !!enhanceTextSelection;
  22233. }
  22234. TextLayerRenderTask.prototype = {
  22235. get promise() {
  22236. return this._capability.promise;
  22237. },
  22238. cancel: function TextLayer_cancel() {
  22239. this._canceled = true;
  22240. if (this._renderTimer !== null) {
  22241. clearTimeout(this._renderTimer);
  22242. this._renderTimer = null;
  22243. }
  22244. this._capability.reject('canceled');
  22245. },
  22246. _render: function TextLayer_render(timeout) {
  22247. var textItems = this._textContent.items;
  22248. var textStyles = this._textContent.styles;
  22249. for (var i = 0, len = textItems.length; i < len; i++) {
  22250. appendText(this, textItems[i], textStyles);
  22251. }
  22252. if (!timeout) {
  22253. render(this);
  22254. } else {
  22255. var self = this;
  22256. this._renderTimer = setTimeout(function () {
  22257. render(self);
  22258. self._renderTimer = null;
  22259. }, timeout);
  22260. }
  22261. },
  22262. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22263. if (!this._enhanceTextSelection || !this._renderingDone) {
  22264. return;
  22265. }
  22266. if (this._bounds !== null) {
  22267. expand(this);
  22268. this._bounds = null;
  22269. }
  22270. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22271. var div = this._textDivs[i];
  22272. var divProperties = this._textDivProperties.get(div);
  22273. if (divProperties.isWhitespace) {
  22274. continue;
  22275. }
  22276. if (expandDivs) {
  22277. var transform = '', padding = '';
  22278. if (divProperties.scale !== 1) {
  22279. transform = 'scaleX(' + divProperties.scale + ')';
  22280. }
  22281. if (divProperties.angle !== 0) {
  22282. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22283. }
  22284. if (divProperties.paddingLeft !== 0) {
  22285. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22286. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22287. }
  22288. if (divProperties.paddingTop !== 0) {
  22289. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22290. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22291. }
  22292. if (divProperties.paddingRight !== 0) {
  22293. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22294. }
  22295. if (divProperties.paddingBottom !== 0) {
  22296. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22297. }
  22298. if (padding !== '') {
  22299. div.setAttribute('style', divProperties.style + padding);
  22300. }
  22301. if (transform !== '') {
  22302. CustomStyle.setProp('transform', div, transform);
  22303. }
  22304. } else {
  22305. div.style.padding = 0;
  22306. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22307. }
  22308. }
  22309. }
  22310. };
  22311. function renderTextLayer(renderParameters) {
  22312. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22313. task._render(renderParameters.timeout);
  22314. return task;
  22315. }
  22316. return renderTextLayer;
  22317. }();
  22318. exports.renderTextLayer = renderTextLayer;
  22319. /***/ }),
  22320. /* 13 */
  22321. /***/ (function(module, exports, __w_pdfjs_require__) {
  22322. "use strict";
  22323. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22324. var QeTable = [
  22325. {
  22326. qe: 0x5601,
  22327. nmps: 1,
  22328. nlps: 1,
  22329. switchFlag: 1
  22330. },
  22331. {
  22332. qe: 0x3401,
  22333. nmps: 2,
  22334. nlps: 6,
  22335. switchFlag: 0
  22336. },
  22337. {
  22338. qe: 0x1801,
  22339. nmps: 3,
  22340. nlps: 9,
  22341. switchFlag: 0
  22342. },
  22343. {
  22344. qe: 0x0AC1,
  22345. nmps: 4,
  22346. nlps: 12,
  22347. switchFlag: 0
  22348. },
  22349. {
  22350. qe: 0x0521,
  22351. nmps: 5,
  22352. nlps: 29,
  22353. switchFlag: 0
  22354. },
  22355. {
  22356. qe: 0x0221,
  22357. nmps: 38,
  22358. nlps: 33,
  22359. switchFlag: 0
  22360. },
  22361. {
  22362. qe: 0x5601,
  22363. nmps: 7,
  22364. nlps: 6,
  22365. switchFlag: 1
  22366. },
  22367. {
  22368. qe: 0x5401,
  22369. nmps: 8,
  22370. nlps: 14,
  22371. switchFlag: 0
  22372. },
  22373. {
  22374. qe: 0x4801,
  22375. nmps: 9,
  22376. nlps: 14,
  22377. switchFlag: 0
  22378. },
  22379. {
  22380. qe: 0x3801,
  22381. nmps: 10,
  22382. nlps: 14,
  22383. switchFlag: 0
  22384. },
  22385. {
  22386. qe: 0x3001,
  22387. nmps: 11,
  22388. nlps: 17,
  22389. switchFlag: 0
  22390. },
  22391. {
  22392. qe: 0x2401,
  22393. nmps: 12,
  22394. nlps: 18,
  22395. switchFlag: 0
  22396. },
  22397. {
  22398. qe: 0x1C01,
  22399. nmps: 13,
  22400. nlps: 20,
  22401. switchFlag: 0
  22402. },
  22403. {
  22404. qe: 0x1601,
  22405. nmps: 29,
  22406. nlps: 21,
  22407. switchFlag: 0
  22408. },
  22409. {
  22410. qe: 0x5601,
  22411. nmps: 15,
  22412. nlps: 14,
  22413. switchFlag: 1
  22414. },
  22415. {
  22416. qe: 0x5401,
  22417. nmps: 16,
  22418. nlps: 14,
  22419. switchFlag: 0
  22420. },
  22421. {
  22422. qe: 0x5101,
  22423. nmps: 17,
  22424. nlps: 15,
  22425. switchFlag: 0
  22426. },
  22427. {
  22428. qe: 0x4801,
  22429. nmps: 18,
  22430. nlps: 16,
  22431. switchFlag: 0
  22432. },
  22433. {
  22434. qe: 0x3801,
  22435. nmps: 19,
  22436. nlps: 17,
  22437. switchFlag: 0
  22438. },
  22439. {
  22440. qe: 0x3401,
  22441. nmps: 20,
  22442. nlps: 18,
  22443. switchFlag: 0
  22444. },
  22445. {
  22446. qe: 0x3001,
  22447. nmps: 21,
  22448. nlps: 19,
  22449. switchFlag: 0
  22450. },
  22451. {
  22452. qe: 0x2801,
  22453. nmps: 22,
  22454. nlps: 19,
  22455. switchFlag: 0
  22456. },
  22457. {
  22458. qe: 0x2401,
  22459. nmps: 23,
  22460. nlps: 20,
  22461. switchFlag: 0
  22462. },
  22463. {
  22464. qe: 0x2201,
  22465. nmps: 24,
  22466. nlps: 21,
  22467. switchFlag: 0
  22468. },
  22469. {
  22470. qe: 0x1C01,
  22471. nmps: 25,
  22472. nlps: 22,
  22473. switchFlag: 0
  22474. },
  22475. {
  22476. qe: 0x1801,
  22477. nmps: 26,
  22478. nlps: 23,
  22479. switchFlag: 0
  22480. },
  22481. {
  22482. qe: 0x1601,
  22483. nmps: 27,
  22484. nlps: 24,
  22485. switchFlag: 0
  22486. },
  22487. {
  22488. qe: 0x1401,
  22489. nmps: 28,
  22490. nlps: 25,
  22491. switchFlag: 0
  22492. },
  22493. {
  22494. qe: 0x1201,
  22495. nmps: 29,
  22496. nlps: 26,
  22497. switchFlag: 0
  22498. },
  22499. {
  22500. qe: 0x1101,
  22501. nmps: 30,
  22502. nlps: 27,
  22503. switchFlag: 0
  22504. },
  22505. {
  22506. qe: 0x0AC1,
  22507. nmps: 31,
  22508. nlps: 28,
  22509. switchFlag: 0
  22510. },
  22511. {
  22512. qe: 0x09C1,
  22513. nmps: 32,
  22514. nlps: 29,
  22515. switchFlag: 0
  22516. },
  22517. {
  22518. qe: 0x08A1,
  22519. nmps: 33,
  22520. nlps: 30,
  22521. switchFlag: 0
  22522. },
  22523. {
  22524. qe: 0x0521,
  22525. nmps: 34,
  22526. nlps: 31,
  22527. switchFlag: 0
  22528. },
  22529. {
  22530. qe: 0x0441,
  22531. nmps: 35,
  22532. nlps: 32,
  22533. switchFlag: 0
  22534. },
  22535. {
  22536. qe: 0x02A1,
  22537. nmps: 36,
  22538. nlps: 33,
  22539. switchFlag: 0
  22540. },
  22541. {
  22542. qe: 0x0221,
  22543. nmps: 37,
  22544. nlps: 34,
  22545. switchFlag: 0
  22546. },
  22547. {
  22548. qe: 0x0141,
  22549. nmps: 38,
  22550. nlps: 35,
  22551. switchFlag: 0
  22552. },
  22553. {
  22554. qe: 0x0111,
  22555. nmps: 39,
  22556. nlps: 36,
  22557. switchFlag: 0
  22558. },
  22559. {
  22560. qe: 0x0085,
  22561. nmps: 40,
  22562. nlps: 37,
  22563. switchFlag: 0
  22564. },
  22565. {
  22566. qe: 0x0049,
  22567. nmps: 41,
  22568. nlps: 38,
  22569. switchFlag: 0
  22570. },
  22571. {
  22572. qe: 0x0025,
  22573. nmps: 42,
  22574. nlps: 39,
  22575. switchFlag: 0
  22576. },
  22577. {
  22578. qe: 0x0015,
  22579. nmps: 43,
  22580. nlps: 40,
  22581. switchFlag: 0
  22582. },
  22583. {
  22584. qe: 0x0009,
  22585. nmps: 44,
  22586. nlps: 41,
  22587. switchFlag: 0
  22588. },
  22589. {
  22590. qe: 0x0005,
  22591. nmps: 45,
  22592. nlps: 42,
  22593. switchFlag: 0
  22594. },
  22595. {
  22596. qe: 0x0001,
  22597. nmps: 45,
  22598. nlps: 43,
  22599. switchFlag: 0
  22600. },
  22601. {
  22602. qe: 0x5601,
  22603. nmps: 46,
  22604. nlps: 46,
  22605. switchFlag: 0
  22606. }
  22607. ];
  22608. function ArithmeticDecoder(data, start, end) {
  22609. this.data = data;
  22610. this.bp = start;
  22611. this.dataEnd = end;
  22612. this.chigh = data[start];
  22613. this.clow = 0;
  22614. this.byteIn();
  22615. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  22616. this.clow = this.clow << 7 & 0xFFFF;
  22617. this.ct -= 7;
  22618. this.a = 0x8000;
  22619. }
  22620. ArithmeticDecoder.prototype = {
  22621. byteIn: function ArithmeticDecoder_byteIn() {
  22622. var data = this.data;
  22623. var bp = this.bp;
  22624. if (data[bp] === 0xFF) {
  22625. var b1 = data[bp + 1];
  22626. if (b1 > 0x8F) {
  22627. this.clow += 0xFF00;
  22628. this.ct = 8;
  22629. } else {
  22630. bp++;
  22631. this.clow += data[bp] << 9;
  22632. this.ct = 7;
  22633. this.bp = bp;
  22634. }
  22635. } else {
  22636. bp++;
  22637. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  22638. this.ct = 8;
  22639. this.bp = bp;
  22640. }
  22641. if (this.clow > 0xFFFF) {
  22642. this.chigh += this.clow >> 16;
  22643. this.clow &= 0xFFFF;
  22644. }
  22645. },
  22646. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  22647. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  22648. var qeTableIcx = QeTable[cx_index];
  22649. var qeIcx = qeTableIcx.qe;
  22650. var d;
  22651. var a = this.a - qeIcx;
  22652. if (this.chigh < qeIcx) {
  22653. if (a < qeIcx) {
  22654. a = qeIcx;
  22655. d = cx_mps;
  22656. cx_index = qeTableIcx.nmps;
  22657. } else {
  22658. a = qeIcx;
  22659. d = 1 ^ cx_mps;
  22660. if (qeTableIcx.switchFlag === 1) {
  22661. cx_mps = d;
  22662. }
  22663. cx_index = qeTableIcx.nlps;
  22664. }
  22665. } else {
  22666. this.chigh -= qeIcx;
  22667. if ((a & 0x8000) !== 0) {
  22668. this.a = a;
  22669. return cx_mps;
  22670. }
  22671. if (a < qeIcx) {
  22672. d = 1 ^ cx_mps;
  22673. if (qeTableIcx.switchFlag === 1) {
  22674. cx_mps = d;
  22675. }
  22676. cx_index = qeTableIcx.nlps;
  22677. } else {
  22678. d = cx_mps;
  22679. cx_index = qeTableIcx.nmps;
  22680. }
  22681. }
  22682. do {
  22683. if (this.ct === 0) {
  22684. this.byteIn();
  22685. }
  22686. a <<= 1;
  22687. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  22688. this.clow = this.clow << 1 & 0xFFFF;
  22689. this.ct--;
  22690. } while ((a & 0x8000) === 0);
  22691. this.a = a;
  22692. contexts[pos] = cx_index << 1 | cx_mps;
  22693. return d;
  22694. }
  22695. };
  22696. return ArithmeticDecoder;
  22697. }();
  22698. exports.ArithmeticDecoder = ArithmeticDecoder;
  22699. /***/ }),
  22700. /* 14 */
  22701. /***/ (function(module, exports, __w_pdfjs_require__) {
  22702. "use strict";
  22703. var sharedUtil = __w_pdfjs_require__(0);
  22704. var coreCharsets = __w_pdfjs_require__(29);
  22705. var coreEncodings = __w_pdfjs_require__(5);
  22706. var error = sharedUtil.error;
  22707. var info = sharedUtil.info;
  22708. var bytesToString = sharedUtil.bytesToString;
  22709. var warn = sharedUtil.warn;
  22710. var isArray = sharedUtil.isArray;
  22711. var Util = sharedUtil.Util;
  22712. var stringToBytes = sharedUtil.stringToBytes;
  22713. var assert = sharedUtil.assert;
  22714. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  22715. var ExpertCharset = coreCharsets.ExpertCharset;
  22716. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  22717. var StandardEncoding = coreEncodings.StandardEncoding;
  22718. var ExpertEncoding = coreEncodings.ExpertEncoding;
  22719. var MAX_SUBR_NESTING = 10;
  22720. var CFFStandardStrings = [
  22721. '.notdef',
  22722. 'space',
  22723. 'exclam',
  22724. 'quotedbl',
  22725. 'numbersign',
  22726. 'dollar',
  22727. 'percent',
  22728. 'ampersand',
  22729. 'quoteright',
  22730. 'parenleft',
  22731. 'parenright',
  22732. 'asterisk',
  22733. 'plus',
  22734. 'comma',
  22735. 'hyphen',
  22736. 'period',
  22737. 'slash',
  22738. 'zero',
  22739. 'one',
  22740. 'two',
  22741. 'three',
  22742. 'four',
  22743. 'five',
  22744. 'six',
  22745. 'seven',
  22746. 'eight',
  22747. 'nine',
  22748. 'colon',
  22749. 'semicolon',
  22750. 'less',
  22751. 'equal',
  22752. 'greater',
  22753. 'question',
  22754. 'at',
  22755. 'A',
  22756. 'B',
  22757. 'C',
  22758. 'D',
  22759. 'E',
  22760. 'F',
  22761. 'G',
  22762. 'H',
  22763. 'I',
  22764. 'J',
  22765. 'K',
  22766. 'L',
  22767. 'M',
  22768. 'N',
  22769. 'O',
  22770. 'P',
  22771. 'Q',
  22772. 'R',
  22773. 'S',
  22774. 'T',
  22775. 'U',
  22776. 'V',
  22777. 'W',
  22778. 'X',
  22779. 'Y',
  22780. 'Z',
  22781. 'bracketleft',
  22782. 'backslash',
  22783. 'bracketright',
  22784. 'asciicircum',
  22785. 'underscore',
  22786. 'quoteleft',
  22787. 'a',
  22788. 'b',
  22789. 'c',
  22790. 'd',
  22791. 'e',
  22792. 'f',
  22793. 'g',
  22794. 'h',
  22795. 'i',
  22796. 'j',
  22797. 'k',
  22798. 'l',
  22799. 'm',
  22800. 'n',
  22801. 'o',
  22802. 'p',
  22803. 'q',
  22804. 'r',
  22805. 's',
  22806. 't',
  22807. 'u',
  22808. 'v',
  22809. 'w',
  22810. 'x',
  22811. 'y',
  22812. 'z',
  22813. 'braceleft',
  22814. 'bar',
  22815. 'braceright',
  22816. 'asciitilde',
  22817. 'exclamdown',
  22818. 'cent',
  22819. 'sterling',
  22820. 'fraction',
  22821. 'yen',
  22822. 'florin',
  22823. 'section',
  22824. 'currency',
  22825. 'quotesingle',
  22826. 'quotedblleft',
  22827. 'guillemotleft',
  22828. 'guilsinglleft',
  22829. 'guilsinglright',
  22830. 'fi',
  22831. 'fl',
  22832. 'endash',
  22833. 'dagger',
  22834. 'daggerdbl',
  22835. 'periodcentered',
  22836. 'paragraph',
  22837. 'bullet',
  22838. 'quotesinglbase',
  22839. 'quotedblbase',
  22840. 'quotedblright',
  22841. 'guillemotright',
  22842. 'ellipsis',
  22843. 'perthousand',
  22844. 'questiondown',
  22845. 'grave',
  22846. 'acute',
  22847. 'circumflex',
  22848. 'tilde',
  22849. 'macron',
  22850. 'breve',
  22851. 'dotaccent',
  22852. 'dieresis',
  22853. 'ring',
  22854. 'cedilla',
  22855. 'hungarumlaut',
  22856. 'ogonek',
  22857. 'caron',
  22858. 'emdash',
  22859. 'AE',
  22860. 'ordfeminine',
  22861. 'Lslash',
  22862. 'Oslash',
  22863. 'OE',
  22864. 'ordmasculine',
  22865. 'ae',
  22866. 'dotlessi',
  22867. 'lslash',
  22868. 'oslash',
  22869. 'oe',
  22870. 'germandbls',
  22871. 'onesuperior',
  22872. 'logicalnot',
  22873. 'mu',
  22874. 'trademark',
  22875. 'Eth',
  22876. 'onehalf',
  22877. 'plusminus',
  22878. 'Thorn',
  22879. 'onequarter',
  22880. 'divide',
  22881. 'brokenbar',
  22882. 'degree',
  22883. 'thorn',
  22884. 'threequarters',
  22885. 'twosuperior',
  22886. 'registered',
  22887. 'minus',
  22888. 'eth',
  22889. 'multiply',
  22890. 'threesuperior',
  22891. 'copyright',
  22892. 'Aacute',
  22893. 'Acircumflex',
  22894. 'Adieresis',
  22895. 'Agrave',
  22896. 'Aring',
  22897. 'Atilde',
  22898. 'Ccedilla',
  22899. 'Eacute',
  22900. 'Ecircumflex',
  22901. 'Edieresis',
  22902. 'Egrave',
  22903. 'Iacute',
  22904. 'Icircumflex',
  22905. 'Idieresis',
  22906. 'Igrave',
  22907. 'Ntilde',
  22908. 'Oacute',
  22909. 'Ocircumflex',
  22910. 'Odieresis',
  22911. 'Ograve',
  22912. 'Otilde',
  22913. 'Scaron',
  22914. 'Uacute',
  22915. 'Ucircumflex',
  22916. 'Udieresis',
  22917. 'Ugrave',
  22918. 'Yacute',
  22919. 'Ydieresis',
  22920. 'Zcaron',
  22921. 'aacute',
  22922. 'acircumflex',
  22923. 'adieresis',
  22924. 'agrave',
  22925. 'aring',
  22926. 'atilde',
  22927. 'ccedilla',
  22928. 'eacute',
  22929. 'ecircumflex',
  22930. 'edieresis',
  22931. 'egrave',
  22932. 'iacute',
  22933. 'icircumflex',
  22934. 'idieresis',
  22935. 'igrave',
  22936. 'ntilde',
  22937. 'oacute',
  22938. 'ocircumflex',
  22939. 'odieresis',
  22940. 'ograve',
  22941. 'otilde',
  22942. 'scaron',
  22943. 'uacute',
  22944. 'ucircumflex',
  22945. 'udieresis',
  22946. 'ugrave',
  22947. 'yacute',
  22948. 'ydieresis',
  22949. 'zcaron',
  22950. 'exclamsmall',
  22951. 'Hungarumlautsmall',
  22952. 'dollaroldstyle',
  22953. 'dollarsuperior',
  22954. 'ampersandsmall',
  22955. 'Acutesmall',
  22956. 'parenleftsuperior',
  22957. 'parenrightsuperior',
  22958. 'twodotenleader',
  22959. 'onedotenleader',
  22960. 'zerooldstyle',
  22961. 'oneoldstyle',
  22962. 'twooldstyle',
  22963. 'threeoldstyle',
  22964. 'fouroldstyle',
  22965. 'fiveoldstyle',
  22966. 'sixoldstyle',
  22967. 'sevenoldstyle',
  22968. 'eightoldstyle',
  22969. 'nineoldstyle',
  22970. 'commasuperior',
  22971. 'threequartersemdash',
  22972. 'periodsuperior',
  22973. 'questionsmall',
  22974. 'asuperior',
  22975. 'bsuperior',
  22976. 'centsuperior',
  22977. 'dsuperior',
  22978. 'esuperior',
  22979. 'isuperior',
  22980. 'lsuperior',
  22981. 'msuperior',
  22982. 'nsuperior',
  22983. 'osuperior',
  22984. 'rsuperior',
  22985. 'ssuperior',
  22986. 'tsuperior',
  22987. 'ff',
  22988. 'ffi',
  22989. 'ffl',
  22990. 'parenleftinferior',
  22991. 'parenrightinferior',
  22992. 'Circumflexsmall',
  22993. 'hyphensuperior',
  22994. 'Gravesmall',
  22995. 'Asmall',
  22996. 'Bsmall',
  22997. 'Csmall',
  22998. 'Dsmall',
  22999. 'Esmall',
  23000. 'Fsmall',
  23001. 'Gsmall',
  23002. 'Hsmall',
  23003. 'Ismall',
  23004. 'Jsmall',
  23005. 'Ksmall',
  23006. 'Lsmall',
  23007. 'Msmall',
  23008. 'Nsmall',
  23009. 'Osmall',
  23010. 'Psmall',
  23011. 'Qsmall',
  23012. 'Rsmall',
  23013. 'Ssmall',
  23014. 'Tsmall',
  23015. 'Usmall',
  23016. 'Vsmall',
  23017. 'Wsmall',
  23018. 'Xsmall',
  23019. 'Ysmall',
  23020. 'Zsmall',
  23021. 'colonmonetary',
  23022. 'onefitted',
  23023. 'rupiah',
  23024. 'Tildesmall',
  23025. 'exclamdownsmall',
  23026. 'centoldstyle',
  23027. 'Lslashsmall',
  23028. 'Scaronsmall',
  23029. 'Zcaronsmall',
  23030. 'Dieresissmall',
  23031. 'Brevesmall',
  23032. 'Caronsmall',
  23033. 'Dotaccentsmall',
  23034. 'Macronsmall',
  23035. 'figuredash',
  23036. 'hypheninferior',
  23037. 'Ogoneksmall',
  23038. 'Ringsmall',
  23039. 'Cedillasmall',
  23040. 'questiondownsmall',
  23041. 'oneeighth',
  23042. 'threeeighths',
  23043. 'fiveeighths',
  23044. 'seveneighths',
  23045. 'onethird',
  23046. 'twothirds',
  23047. 'zerosuperior',
  23048. 'foursuperior',
  23049. 'fivesuperior',
  23050. 'sixsuperior',
  23051. 'sevensuperior',
  23052. 'eightsuperior',
  23053. 'ninesuperior',
  23054. 'zeroinferior',
  23055. 'oneinferior',
  23056. 'twoinferior',
  23057. 'threeinferior',
  23058. 'fourinferior',
  23059. 'fiveinferior',
  23060. 'sixinferior',
  23061. 'seveninferior',
  23062. 'eightinferior',
  23063. 'nineinferior',
  23064. 'centinferior',
  23065. 'dollarinferior',
  23066. 'periodinferior',
  23067. 'commainferior',
  23068. 'Agravesmall',
  23069. 'Aacutesmall',
  23070. 'Acircumflexsmall',
  23071. 'Atildesmall',
  23072. 'Adieresissmall',
  23073. 'Aringsmall',
  23074. 'AEsmall',
  23075. 'Ccedillasmall',
  23076. 'Egravesmall',
  23077. 'Eacutesmall',
  23078. 'Ecircumflexsmall',
  23079. 'Edieresissmall',
  23080. 'Igravesmall',
  23081. 'Iacutesmall',
  23082. 'Icircumflexsmall',
  23083. 'Idieresissmall',
  23084. 'Ethsmall',
  23085. 'Ntildesmall',
  23086. 'Ogravesmall',
  23087. 'Oacutesmall',
  23088. 'Ocircumflexsmall',
  23089. 'Otildesmall',
  23090. 'Odieresissmall',
  23091. 'OEsmall',
  23092. 'Oslashsmall',
  23093. 'Ugravesmall',
  23094. 'Uacutesmall',
  23095. 'Ucircumflexsmall',
  23096. 'Udieresissmall',
  23097. 'Yacutesmall',
  23098. 'Thornsmall',
  23099. 'Ydieresissmall',
  23100. '001.000',
  23101. '001.001',
  23102. '001.002',
  23103. '001.003',
  23104. 'Black',
  23105. 'Bold',
  23106. 'Book',
  23107. 'Light',
  23108. 'Medium',
  23109. 'Regular',
  23110. 'Roman',
  23111. 'Semibold'
  23112. ];
  23113. var CFFParser = function CFFParserClosure() {
  23114. var CharstringValidationData = [
  23115. null,
  23116. {
  23117. id: 'hstem',
  23118. min: 2,
  23119. stackClearing: true,
  23120. stem: true
  23121. },
  23122. null,
  23123. {
  23124. id: 'vstem',
  23125. min: 2,
  23126. stackClearing: true,
  23127. stem: true
  23128. },
  23129. {
  23130. id: 'vmoveto',
  23131. min: 1,
  23132. stackClearing: true
  23133. },
  23134. {
  23135. id: 'rlineto',
  23136. min: 2,
  23137. resetStack: true
  23138. },
  23139. {
  23140. id: 'hlineto',
  23141. min: 1,
  23142. resetStack: true
  23143. },
  23144. {
  23145. id: 'vlineto',
  23146. min: 1,
  23147. resetStack: true
  23148. },
  23149. {
  23150. id: 'rrcurveto',
  23151. min: 6,
  23152. resetStack: true
  23153. },
  23154. null,
  23155. {
  23156. id: 'callsubr',
  23157. min: 1,
  23158. undefStack: true
  23159. },
  23160. {
  23161. id: 'return',
  23162. min: 0,
  23163. undefStack: true
  23164. },
  23165. null,
  23166. null,
  23167. {
  23168. id: 'endchar',
  23169. min: 0,
  23170. stackClearing: true
  23171. },
  23172. null,
  23173. null,
  23174. null,
  23175. {
  23176. id: 'hstemhm',
  23177. min: 2,
  23178. stackClearing: true,
  23179. stem: true
  23180. },
  23181. {
  23182. id: 'hintmask',
  23183. min: 0,
  23184. stackClearing: true
  23185. },
  23186. {
  23187. id: 'cntrmask',
  23188. min: 0,
  23189. stackClearing: true
  23190. },
  23191. {
  23192. id: 'rmoveto',
  23193. min: 2,
  23194. stackClearing: true
  23195. },
  23196. {
  23197. id: 'hmoveto',
  23198. min: 1,
  23199. stackClearing: true
  23200. },
  23201. {
  23202. id: 'vstemhm',
  23203. min: 2,
  23204. stackClearing: true,
  23205. stem: true
  23206. },
  23207. {
  23208. id: 'rcurveline',
  23209. min: 8,
  23210. resetStack: true
  23211. },
  23212. {
  23213. id: 'rlinecurve',
  23214. min: 8,
  23215. resetStack: true
  23216. },
  23217. {
  23218. id: 'vvcurveto',
  23219. min: 4,
  23220. resetStack: true
  23221. },
  23222. {
  23223. id: 'hhcurveto',
  23224. min: 4,
  23225. resetStack: true
  23226. },
  23227. null,
  23228. {
  23229. id: 'callgsubr',
  23230. min: 1,
  23231. undefStack: true
  23232. },
  23233. {
  23234. id: 'vhcurveto',
  23235. min: 4,
  23236. resetStack: true
  23237. },
  23238. {
  23239. id: 'hvcurveto',
  23240. min: 4,
  23241. resetStack: true
  23242. }
  23243. ];
  23244. var CharstringValidationData12 = [
  23245. null,
  23246. null,
  23247. null,
  23248. {
  23249. id: 'and',
  23250. min: 2,
  23251. stackDelta: -1
  23252. },
  23253. {
  23254. id: 'or',
  23255. min: 2,
  23256. stackDelta: -1
  23257. },
  23258. {
  23259. id: 'not',
  23260. min: 1,
  23261. stackDelta: 0
  23262. },
  23263. null,
  23264. null,
  23265. null,
  23266. {
  23267. id: 'abs',
  23268. min: 1,
  23269. stackDelta: 0
  23270. },
  23271. {
  23272. id: 'add',
  23273. min: 2,
  23274. stackDelta: -1,
  23275. stackFn: function stack_div(stack, index) {
  23276. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23277. }
  23278. },
  23279. {
  23280. id: 'sub',
  23281. min: 2,
  23282. stackDelta: -1,
  23283. stackFn: function stack_div(stack, index) {
  23284. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23285. }
  23286. },
  23287. {
  23288. id: 'div',
  23289. min: 2,
  23290. stackDelta: -1,
  23291. stackFn: function stack_div(stack, index) {
  23292. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23293. }
  23294. },
  23295. null,
  23296. {
  23297. id: 'neg',
  23298. min: 1,
  23299. stackDelta: 0,
  23300. stackFn: function stack_div(stack, index) {
  23301. stack[index - 1] = -stack[index - 1];
  23302. }
  23303. },
  23304. {
  23305. id: 'eq',
  23306. min: 2,
  23307. stackDelta: -1
  23308. },
  23309. null,
  23310. null,
  23311. {
  23312. id: 'drop',
  23313. min: 1,
  23314. stackDelta: -1
  23315. },
  23316. null,
  23317. {
  23318. id: 'put',
  23319. min: 2,
  23320. stackDelta: -2
  23321. },
  23322. {
  23323. id: 'get',
  23324. min: 1,
  23325. stackDelta: 0
  23326. },
  23327. {
  23328. id: 'ifelse',
  23329. min: 4,
  23330. stackDelta: -3
  23331. },
  23332. {
  23333. id: 'random',
  23334. min: 0,
  23335. stackDelta: 1
  23336. },
  23337. {
  23338. id: 'mul',
  23339. min: 2,
  23340. stackDelta: -1,
  23341. stackFn: function stack_div(stack, index) {
  23342. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23343. }
  23344. },
  23345. null,
  23346. {
  23347. id: 'sqrt',
  23348. min: 1,
  23349. stackDelta: 0
  23350. },
  23351. {
  23352. id: 'dup',
  23353. min: 1,
  23354. stackDelta: 1
  23355. },
  23356. {
  23357. id: 'exch',
  23358. min: 2,
  23359. stackDelta: 0
  23360. },
  23361. {
  23362. id: 'index',
  23363. min: 2,
  23364. stackDelta: 0
  23365. },
  23366. {
  23367. id: 'roll',
  23368. min: 3,
  23369. stackDelta: -2
  23370. },
  23371. null,
  23372. null,
  23373. null,
  23374. {
  23375. id: 'hflex',
  23376. min: 7,
  23377. resetStack: true
  23378. },
  23379. {
  23380. id: 'flex',
  23381. min: 13,
  23382. resetStack: true
  23383. },
  23384. {
  23385. id: 'hflex1',
  23386. min: 9,
  23387. resetStack: true
  23388. },
  23389. {
  23390. id: 'flex1',
  23391. min: 11,
  23392. resetStack: true
  23393. }
  23394. ];
  23395. function CFFParser(file, properties, seacAnalysisEnabled) {
  23396. this.bytes = file.getBytes();
  23397. this.properties = properties;
  23398. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23399. }
  23400. CFFParser.prototype = {
  23401. parse: function CFFParser_parse() {
  23402. var properties = this.properties;
  23403. var cff = new CFF();
  23404. this.cff = cff;
  23405. var header = this.parseHeader();
  23406. var nameIndex = this.parseIndex(header.endPos);
  23407. var topDictIndex = this.parseIndex(nameIndex.endPos);
  23408. var stringIndex = this.parseIndex(topDictIndex.endPos);
  23409. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23410. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23411. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23412. cff.header = header.obj;
  23413. cff.names = this.parseNameIndex(nameIndex.obj);
  23414. cff.strings = this.parseStringIndex(stringIndex.obj);
  23415. cff.topDict = topDict;
  23416. cff.globalSubrIndex = globalSubrIndex.obj;
  23417. this.parsePrivateDict(cff.topDict);
  23418. cff.isCIDFont = topDict.hasName('ROS');
  23419. var charStringOffset = topDict.getByName('CharStrings');
  23420. var charStringIndex = this.parseIndex(charStringOffset).obj;
  23421. var fontMatrix = topDict.getByName('FontMatrix');
  23422. if (fontMatrix) {
  23423. properties.fontMatrix = fontMatrix;
  23424. }
  23425. var fontBBox = topDict.getByName('FontBBox');
  23426. if (fontBBox) {
  23427. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  23428. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  23429. properties.ascentScaled = true;
  23430. }
  23431. var charset, encoding;
  23432. if (cff.isCIDFont) {
  23433. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  23434. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23435. var dictRaw = fdArrayIndex.get(i);
  23436. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23437. this.parsePrivateDict(fontDict);
  23438. cff.fdArray.push(fontDict);
  23439. }
  23440. encoding = null;
  23441. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  23442. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  23443. } else {
  23444. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  23445. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  23446. }
  23447. cff.charset = charset;
  23448. cff.encoding = encoding;
  23449. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  23450. cff.charStrings = charStringsAndSeacs.charStrings;
  23451. cff.seacs = charStringsAndSeacs.seacs;
  23452. cff.widths = charStringsAndSeacs.widths;
  23453. return cff;
  23454. },
  23455. parseHeader: function CFFParser_parseHeader() {
  23456. var bytes = this.bytes;
  23457. var bytesLength = bytes.length;
  23458. var offset = 0;
  23459. while (offset < bytesLength && bytes[offset] !== 1) {
  23460. ++offset;
  23461. }
  23462. if (offset >= bytesLength) {
  23463. error('Invalid CFF header');
  23464. } else if (offset !== 0) {
  23465. info('cff data is shifted');
  23466. bytes = bytes.subarray(offset);
  23467. this.bytes = bytes;
  23468. }
  23469. var major = bytes[0];
  23470. var minor = bytes[1];
  23471. var hdrSize = bytes[2];
  23472. var offSize = bytes[3];
  23473. var header = new CFFHeader(major, minor, hdrSize, offSize);
  23474. return {
  23475. obj: header,
  23476. endPos: hdrSize
  23477. };
  23478. },
  23479. parseDict: function CFFParser_parseDict(dict) {
  23480. var pos = 0;
  23481. function parseOperand() {
  23482. var value = dict[pos++];
  23483. if (value === 30) {
  23484. return parseFloatOperand();
  23485. } else if (value === 28) {
  23486. value = dict[pos++];
  23487. value = (value << 24 | dict[pos++] << 16) >> 16;
  23488. return value;
  23489. } else if (value === 29) {
  23490. value = dict[pos++];
  23491. value = value << 8 | dict[pos++];
  23492. value = value << 8 | dict[pos++];
  23493. value = value << 8 | dict[pos++];
  23494. return value;
  23495. } else if (value >= 32 && value <= 246) {
  23496. return value - 139;
  23497. } else if (value >= 247 && value <= 250) {
  23498. return (value - 247) * 256 + dict[pos++] + 108;
  23499. } else if (value >= 251 && value <= 254) {
  23500. return -((value - 251) * 256) - dict[pos++] - 108;
  23501. }
  23502. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23503. return NaN;
  23504. }
  23505. function parseFloatOperand() {
  23506. var str = '';
  23507. var eof = 15;
  23508. var lookup = [
  23509. '0',
  23510. '1',
  23511. '2',
  23512. '3',
  23513. '4',
  23514. '5',
  23515. '6',
  23516. '7',
  23517. '8',
  23518. '9',
  23519. '.',
  23520. 'E',
  23521. 'E-',
  23522. null,
  23523. '-'
  23524. ];
  23525. var length = dict.length;
  23526. while (pos < length) {
  23527. var b = dict[pos++];
  23528. var b1 = b >> 4;
  23529. var b2 = b & 15;
  23530. if (b1 === eof) {
  23531. break;
  23532. }
  23533. str += lookup[b1];
  23534. if (b2 === eof) {
  23535. break;
  23536. }
  23537. str += lookup[b2];
  23538. }
  23539. return parseFloat(str);
  23540. }
  23541. var operands = [];
  23542. var entries = [];
  23543. pos = 0;
  23544. var end = dict.length;
  23545. while (pos < end) {
  23546. var b = dict[pos];
  23547. if (b <= 21) {
  23548. if (b === 12) {
  23549. b = b << 8 | dict[++pos];
  23550. }
  23551. entries.push([
  23552. b,
  23553. operands
  23554. ]);
  23555. operands = [];
  23556. ++pos;
  23557. } else {
  23558. operands.push(parseOperand());
  23559. }
  23560. }
  23561. return entries;
  23562. },
  23563. parseIndex: function CFFParser_parseIndex(pos) {
  23564. var cffIndex = new CFFIndex();
  23565. var bytes = this.bytes;
  23566. var count = bytes[pos++] << 8 | bytes[pos++];
  23567. var offsets = [];
  23568. var end = pos;
  23569. var i, ii;
  23570. if (count !== 0) {
  23571. var offsetSize = bytes[pos++];
  23572. var startPos = pos + (count + 1) * offsetSize - 1;
  23573. for (i = 0, ii = count + 1; i < ii; ++i) {
  23574. var offset = 0;
  23575. for (var j = 0; j < offsetSize; ++j) {
  23576. offset <<= 8;
  23577. offset += bytes[pos++];
  23578. }
  23579. offsets.push(startPos + offset);
  23580. }
  23581. end = offsets[count];
  23582. }
  23583. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23584. var offsetStart = offsets[i];
  23585. var offsetEnd = offsets[i + 1];
  23586. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23587. }
  23588. return {
  23589. obj: cffIndex,
  23590. endPos: end
  23591. };
  23592. },
  23593. parseNameIndex: function CFFParser_parseNameIndex(index) {
  23594. var names = [];
  23595. for (var i = 0, ii = index.count; i < ii; ++i) {
  23596. var name = index.get(i);
  23597. var length = Math.min(name.length, 127);
  23598. var data = [];
  23599. for (var j = 0; j < length; ++j) {
  23600. var c = name[j];
  23601. if (j === 0 && c === 0) {
  23602. data[j] = c;
  23603. continue;
  23604. }
  23605. 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) {
  23606. data[j] = 95;
  23607. continue;
  23608. }
  23609. data[j] = c;
  23610. }
  23611. names.push(bytesToString(data));
  23612. }
  23613. return names;
  23614. },
  23615. parseStringIndex: function CFFParser_parseStringIndex(index) {
  23616. var strings = new CFFStrings();
  23617. for (var i = 0, ii = index.count; i < ii; ++i) {
  23618. var data = index.get(i);
  23619. strings.add(bytesToString(data));
  23620. }
  23621. return strings;
  23622. },
  23623. createDict: function CFFParser_createDict(Type, dict, strings) {
  23624. var cffDict = new Type(strings);
  23625. for (var i = 0, ii = dict.length; i < ii; ++i) {
  23626. var pair = dict[i];
  23627. var key = pair[0];
  23628. var value = pair[1];
  23629. cffDict.setByKey(key, value);
  23630. }
  23631. return cffDict;
  23632. },
  23633. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23634. if (state.callDepth > MAX_SUBR_NESTING) {
  23635. return false;
  23636. }
  23637. var stackSize = state.stackSize;
  23638. var stack = state.stack;
  23639. var length = data.length;
  23640. for (var j = 0; j < length;) {
  23641. var value = data[j++];
  23642. var validationCommand = null;
  23643. if (value === 12) {
  23644. var q = data[j++];
  23645. if (q === 0) {
  23646. data[j - 2] = 139;
  23647. data[j - 1] = 22;
  23648. stackSize = 0;
  23649. } else {
  23650. validationCommand = CharstringValidationData12[q];
  23651. }
  23652. } else if (value === 28) {
  23653. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23654. j += 2;
  23655. stackSize++;
  23656. } else if (value === 14) {
  23657. if (stackSize >= 4) {
  23658. stackSize -= 4;
  23659. if (this.seacAnalysisEnabled) {
  23660. state.seac = stack.slice(stackSize, stackSize + 4);
  23661. return false;
  23662. }
  23663. }
  23664. validationCommand = CharstringValidationData[value];
  23665. } else if (value >= 32 && value <= 246) {
  23666. stack[stackSize] = value - 139;
  23667. stackSize++;
  23668. } else if (value >= 247 && value <= 254) {
  23669. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  23670. j++;
  23671. stackSize++;
  23672. } else if (value === 255) {
  23673. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  23674. j += 4;
  23675. stackSize++;
  23676. } else if (value === 19 || value === 20) {
  23677. state.hints += stackSize >> 1;
  23678. j += state.hints + 7 >> 3;
  23679. stackSize %= 2;
  23680. validationCommand = CharstringValidationData[value];
  23681. } else if (value === 10 || value === 29) {
  23682. var subrsIndex;
  23683. if (value === 10) {
  23684. subrsIndex = localSubrIndex;
  23685. } else {
  23686. subrsIndex = globalSubrIndex;
  23687. }
  23688. if (!subrsIndex) {
  23689. validationCommand = CharstringValidationData[value];
  23690. warn('Missing subrsIndex for ' + validationCommand.id);
  23691. return false;
  23692. }
  23693. var bias = 32768;
  23694. if (subrsIndex.count < 1240) {
  23695. bias = 107;
  23696. } else if (subrsIndex.count < 33900) {
  23697. bias = 1131;
  23698. }
  23699. var subrNumber = stack[--stackSize] + bias;
  23700. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  23701. validationCommand = CharstringValidationData[value];
  23702. warn('Out of bounds subrIndex for ' + validationCommand.id);
  23703. return false;
  23704. }
  23705. state.stackSize = stackSize;
  23706. state.callDepth++;
  23707. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  23708. if (!valid) {
  23709. return false;
  23710. }
  23711. state.callDepth--;
  23712. stackSize = state.stackSize;
  23713. continue;
  23714. } else if (value === 11) {
  23715. state.stackSize = stackSize;
  23716. return true;
  23717. } else {
  23718. validationCommand = CharstringValidationData[value];
  23719. }
  23720. if (validationCommand) {
  23721. if (validationCommand.stem) {
  23722. state.hints += stackSize >> 1;
  23723. }
  23724. if ('min' in validationCommand) {
  23725. if (!state.undefStack && stackSize < validationCommand.min) {
  23726. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  23727. return false;
  23728. }
  23729. }
  23730. if (state.firstStackClearing && validationCommand.stackClearing) {
  23731. state.firstStackClearing = false;
  23732. stackSize -= validationCommand.min;
  23733. if (stackSize >= 2 && validationCommand.stem) {
  23734. stackSize %= 2;
  23735. } else if (stackSize > 1) {
  23736. warn('Found too many parameters for stack-clearing command');
  23737. }
  23738. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  23739. state.width = stack[stackSize - 1];
  23740. }
  23741. }
  23742. if ('stackDelta' in validationCommand) {
  23743. if ('stackFn' in validationCommand) {
  23744. validationCommand.stackFn(stack, stackSize);
  23745. }
  23746. stackSize += validationCommand.stackDelta;
  23747. } else if (validationCommand.stackClearing) {
  23748. stackSize = 0;
  23749. } else if (validationCommand.resetStack) {
  23750. stackSize = 0;
  23751. state.undefStack = false;
  23752. } else if (validationCommand.undefStack) {
  23753. stackSize = 0;
  23754. state.undefStack = true;
  23755. state.firstStackClearing = false;
  23756. }
  23757. }
  23758. }
  23759. state.stackSize = stackSize;
  23760. return true;
  23761. },
  23762. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  23763. var seacs = [];
  23764. var widths = [];
  23765. var count = charStrings.count;
  23766. for (var i = 0; i < count; i++) {
  23767. var charstring = charStrings.get(i);
  23768. var state = {
  23769. callDepth: 0,
  23770. stackSize: 0,
  23771. stack: [],
  23772. undefStack: true,
  23773. hints: 0,
  23774. firstStackClearing: true,
  23775. seac: null,
  23776. width: null
  23777. };
  23778. var valid = true;
  23779. var localSubrToUse = null;
  23780. if (fdSelect && fdArray.length) {
  23781. var fdIndex = fdSelect.getFDIndex(i);
  23782. if (fdIndex === -1) {
  23783. warn('Glyph index is not in fd select.');
  23784. valid = false;
  23785. }
  23786. if (fdIndex >= fdArray.length) {
  23787. warn('Invalid fd index for glyph index.');
  23788. valid = false;
  23789. }
  23790. if (valid) {
  23791. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23792. }
  23793. } else if (localSubrIndex) {
  23794. localSubrToUse = localSubrIndex;
  23795. }
  23796. if (valid) {
  23797. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23798. }
  23799. if (state.width !== null) {
  23800. widths[i] = state.width;
  23801. }
  23802. if (state.seac !== null) {
  23803. seacs[i] = state.seac;
  23804. }
  23805. if (!valid) {
  23806. charStrings.set(i, new Uint8Array([14]));
  23807. }
  23808. }
  23809. return {
  23810. charStrings: charStrings,
  23811. seacs: seacs,
  23812. widths: widths
  23813. };
  23814. },
  23815. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23816. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23817. parentDict.setByKey(18, [
  23818. 0,
  23819. 0
  23820. ]);
  23821. parentDict.privateDict = privateDict;
  23822. },
  23823. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23824. if (!parentDict.hasName('Private')) {
  23825. this.emptyPrivateDictionary(parentDict);
  23826. return;
  23827. }
  23828. var privateOffset = parentDict.getByName('Private');
  23829. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23830. parentDict.removeByName('Private');
  23831. return;
  23832. }
  23833. var size = privateOffset[0];
  23834. var offset = privateOffset[1];
  23835. if (size === 0 || offset >= this.bytes.length) {
  23836. this.emptyPrivateDictionary(parentDict);
  23837. return;
  23838. }
  23839. var privateDictEnd = offset + size;
  23840. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23841. var dict = this.parseDict(dictData);
  23842. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23843. parentDict.privateDict = privateDict;
  23844. if (!privateDict.getByName('Subrs')) {
  23845. return;
  23846. }
  23847. var subrsOffset = privateDict.getByName('Subrs');
  23848. var relativeOffset = offset + subrsOffset;
  23849. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23850. this.emptyPrivateDictionary(parentDict);
  23851. return;
  23852. }
  23853. var subrsIndex = this.parseIndex(relativeOffset);
  23854. privateDict.subrsIndex = subrsIndex.obj;
  23855. },
  23856. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23857. if (pos === 0) {
  23858. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23859. } else if (pos === 1) {
  23860. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23861. } else if (pos === 2) {
  23862. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23863. }
  23864. var bytes = this.bytes;
  23865. var start = pos;
  23866. var format = bytes[pos++];
  23867. var charset = ['.notdef'];
  23868. var id, count, i;
  23869. length -= 1;
  23870. switch (format) {
  23871. case 0:
  23872. for (i = 0; i < length; i++) {
  23873. id = bytes[pos++] << 8 | bytes[pos++];
  23874. charset.push(cid ? id : strings.get(id));
  23875. }
  23876. break;
  23877. case 1:
  23878. while (charset.length <= length) {
  23879. id = bytes[pos++] << 8 | bytes[pos++];
  23880. count = bytes[pos++];
  23881. for (i = 0; i <= count; i++) {
  23882. charset.push(cid ? id++ : strings.get(id++));
  23883. }
  23884. }
  23885. break;
  23886. case 2:
  23887. while (charset.length <= length) {
  23888. id = bytes[pos++] << 8 | bytes[pos++];
  23889. count = bytes[pos++] << 8 | bytes[pos++];
  23890. for (i = 0; i <= count; i++) {
  23891. charset.push(cid ? id++ : strings.get(id++));
  23892. }
  23893. }
  23894. break;
  23895. default:
  23896. error('Unknown charset format');
  23897. }
  23898. var end = pos;
  23899. var raw = bytes.subarray(start, end);
  23900. return new CFFCharset(false, format, charset, raw);
  23901. },
  23902. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23903. var encoding = Object.create(null);
  23904. var bytes = this.bytes;
  23905. var predefined = false;
  23906. var format, i, ii;
  23907. var raw = null;
  23908. function readSupplement() {
  23909. var supplementsCount = bytes[pos++];
  23910. for (i = 0; i < supplementsCount; i++) {
  23911. var code = bytes[pos++];
  23912. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23913. encoding[code] = charset.indexOf(strings.get(sid));
  23914. }
  23915. }
  23916. if (pos === 0 || pos === 1) {
  23917. predefined = true;
  23918. format = pos;
  23919. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23920. for (i = 0, ii = charset.length; i < ii; i++) {
  23921. var index = baseEncoding.indexOf(charset[i]);
  23922. if (index !== -1) {
  23923. encoding[index] = i;
  23924. }
  23925. }
  23926. } else {
  23927. var dataStart = pos;
  23928. format = bytes[pos++];
  23929. switch (format & 0x7f) {
  23930. case 0:
  23931. var glyphsCount = bytes[pos++];
  23932. for (i = 1; i <= glyphsCount; i++) {
  23933. encoding[bytes[pos++]] = i;
  23934. }
  23935. break;
  23936. case 1:
  23937. var rangesCount = bytes[pos++];
  23938. var gid = 1;
  23939. for (i = 0; i < rangesCount; i++) {
  23940. var start = bytes[pos++];
  23941. var left = bytes[pos++];
  23942. for (var j = start; j <= start + left; j++) {
  23943. encoding[j] = gid++;
  23944. }
  23945. }
  23946. break;
  23947. default:
  23948. error('Unknown encoding format: ' + format + ' in CFF');
  23949. break;
  23950. }
  23951. var dataEnd = pos;
  23952. if (format & 0x80) {
  23953. bytes[dataStart] &= 0x7f;
  23954. readSupplement();
  23955. }
  23956. raw = bytes.subarray(dataStart, dataEnd);
  23957. }
  23958. format = format & 0x7f;
  23959. return new CFFEncoding(predefined, format, encoding, raw);
  23960. },
  23961. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23962. var start = pos;
  23963. var bytes = this.bytes;
  23964. var format = bytes[pos++];
  23965. var fdSelect = [], rawBytes;
  23966. var i, invalidFirstGID = false;
  23967. switch (format) {
  23968. case 0:
  23969. for (i = 0; i < length; ++i) {
  23970. var id = bytes[pos++];
  23971. fdSelect.push(id);
  23972. }
  23973. rawBytes = bytes.subarray(start, pos);
  23974. break;
  23975. case 3:
  23976. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23977. for (i = 0; i < rangesCount; ++i) {
  23978. var first = bytes[pos++] << 8 | bytes[pos++];
  23979. if (i === 0 && first !== 0) {
  23980. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23981. invalidFirstGID = true;
  23982. first = 0;
  23983. }
  23984. var fdIndex = bytes[pos++];
  23985. var next = bytes[pos] << 8 | bytes[pos + 1];
  23986. for (var j = first; j < next; ++j) {
  23987. fdSelect.push(fdIndex);
  23988. }
  23989. }
  23990. pos += 2;
  23991. rawBytes = bytes.subarray(start, pos);
  23992. if (invalidFirstGID) {
  23993. rawBytes[3] = rawBytes[4] = 0;
  23994. }
  23995. break;
  23996. default:
  23997. error('parseFDSelect: Unknown format "' + format + '".');
  23998. break;
  23999. }
  24000. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  24001. return new CFFFDSelect(fdSelect, rawBytes);
  24002. }
  24003. };
  24004. return CFFParser;
  24005. }();
  24006. var CFF = function CFFClosure() {
  24007. function CFF() {
  24008. this.header = null;
  24009. this.names = [];
  24010. this.topDict = null;
  24011. this.strings = new CFFStrings();
  24012. this.globalSubrIndex = null;
  24013. this.encoding = null;
  24014. this.charset = null;
  24015. this.charStrings = null;
  24016. this.fdArray = [];
  24017. this.fdSelect = null;
  24018. this.isCIDFont = false;
  24019. }
  24020. return CFF;
  24021. }();
  24022. var CFFHeader = function CFFHeaderClosure() {
  24023. function CFFHeader(major, minor, hdrSize, offSize) {
  24024. this.major = major;
  24025. this.minor = minor;
  24026. this.hdrSize = hdrSize;
  24027. this.offSize = offSize;
  24028. }
  24029. return CFFHeader;
  24030. }();
  24031. var CFFStrings = function CFFStringsClosure() {
  24032. function CFFStrings() {
  24033. this.strings = [];
  24034. }
  24035. CFFStrings.prototype = {
  24036. get: function CFFStrings_get(index) {
  24037. if (index >= 0 && index <= 390) {
  24038. return CFFStandardStrings[index];
  24039. }
  24040. if (index - 391 <= this.strings.length) {
  24041. return this.strings[index - 391];
  24042. }
  24043. return CFFStandardStrings[0];
  24044. },
  24045. add: function CFFStrings_add(value) {
  24046. this.strings.push(value);
  24047. },
  24048. get count() {
  24049. return this.strings.length;
  24050. }
  24051. };
  24052. return CFFStrings;
  24053. }();
  24054. var CFFIndex = function CFFIndexClosure() {
  24055. function CFFIndex() {
  24056. this.objects = [];
  24057. this.length = 0;
  24058. }
  24059. CFFIndex.prototype = {
  24060. add: function CFFIndex_add(data) {
  24061. this.length += data.length;
  24062. this.objects.push(data);
  24063. },
  24064. set: function CFFIndex_set(index, data) {
  24065. this.length += data.length - this.objects[index].length;
  24066. this.objects[index] = data;
  24067. },
  24068. get: function CFFIndex_get(index) {
  24069. return this.objects[index];
  24070. },
  24071. get count() {
  24072. return this.objects.length;
  24073. }
  24074. };
  24075. return CFFIndex;
  24076. }();
  24077. var CFFDict = function CFFDictClosure() {
  24078. function CFFDict(tables, strings) {
  24079. this.keyToNameMap = tables.keyToNameMap;
  24080. this.nameToKeyMap = tables.nameToKeyMap;
  24081. this.defaults = tables.defaults;
  24082. this.types = tables.types;
  24083. this.opcodes = tables.opcodes;
  24084. this.order = tables.order;
  24085. this.strings = strings;
  24086. this.values = Object.create(null);
  24087. }
  24088. CFFDict.prototype = {
  24089. setByKey: function CFFDict_setByKey(key, value) {
  24090. if (!(key in this.keyToNameMap)) {
  24091. return false;
  24092. }
  24093. var valueLength = value.length;
  24094. if (valueLength === 0) {
  24095. return true;
  24096. }
  24097. for (var i = 0; i < valueLength; i++) {
  24098. if (isNaN(value[i])) {
  24099. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24100. return true;
  24101. }
  24102. }
  24103. var type = this.types[key];
  24104. if (type === 'num' || type === 'sid' || type === 'offset') {
  24105. value = value[0];
  24106. }
  24107. this.values[key] = value;
  24108. return true;
  24109. },
  24110. setByName: function CFFDict_setByName(name, value) {
  24111. if (!(name in this.nameToKeyMap)) {
  24112. error('Invalid dictionary name "' + name + '"');
  24113. }
  24114. this.values[this.nameToKeyMap[name]] = value;
  24115. },
  24116. hasName: function CFFDict_hasName(name) {
  24117. return this.nameToKeyMap[name] in this.values;
  24118. },
  24119. getByName: function CFFDict_getByName(name) {
  24120. if (!(name in this.nameToKeyMap)) {
  24121. error('Invalid dictionary name "' + name + '"');
  24122. }
  24123. var key = this.nameToKeyMap[name];
  24124. if (!(key in this.values)) {
  24125. return this.defaults[key];
  24126. }
  24127. return this.values[key];
  24128. },
  24129. removeByName: function CFFDict_removeByName(name) {
  24130. delete this.values[this.nameToKeyMap[name]];
  24131. }
  24132. };
  24133. CFFDict.createTables = function CFFDict_createTables(layout) {
  24134. var tables = {
  24135. keyToNameMap: {},
  24136. nameToKeyMap: {},
  24137. defaults: {},
  24138. types: {},
  24139. opcodes: {},
  24140. order: []
  24141. };
  24142. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24143. var entry = layout[i];
  24144. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24145. tables.keyToNameMap[key] = entry[1];
  24146. tables.nameToKeyMap[entry[1]] = key;
  24147. tables.types[key] = entry[2];
  24148. tables.defaults[key] = entry[3];
  24149. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24150. tables.order.push(key);
  24151. }
  24152. return tables;
  24153. };
  24154. return CFFDict;
  24155. }();
  24156. var CFFTopDict = function CFFTopDictClosure() {
  24157. var layout = [
  24158. [
  24159. [
  24160. 12,
  24161. 30
  24162. ],
  24163. 'ROS',
  24164. [
  24165. 'sid',
  24166. 'sid',
  24167. 'num'
  24168. ],
  24169. null
  24170. ],
  24171. [
  24172. [
  24173. 12,
  24174. 20
  24175. ],
  24176. 'SyntheticBase',
  24177. 'num',
  24178. null
  24179. ],
  24180. [
  24181. 0,
  24182. 'version',
  24183. 'sid',
  24184. null
  24185. ],
  24186. [
  24187. 1,
  24188. 'Notice',
  24189. 'sid',
  24190. null
  24191. ],
  24192. [
  24193. [
  24194. 12,
  24195. 0
  24196. ],
  24197. 'Copyright',
  24198. 'sid',
  24199. null
  24200. ],
  24201. [
  24202. 2,
  24203. 'FullName',
  24204. 'sid',
  24205. null
  24206. ],
  24207. [
  24208. 3,
  24209. 'FamilyName',
  24210. 'sid',
  24211. null
  24212. ],
  24213. [
  24214. 4,
  24215. 'Weight',
  24216. 'sid',
  24217. null
  24218. ],
  24219. [
  24220. [
  24221. 12,
  24222. 1
  24223. ],
  24224. 'isFixedPitch',
  24225. 'num',
  24226. 0
  24227. ],
  24228. [
  24229. [
  24230. 12,
  24231. 2
  24232. ],
  24233. 'ItalicAngle',
  24234. 'num',
  24235. 0
  24236. ],
  24237. [
  24238. [
  24239. 12,
  24240. 3
  24241. ],
  24242. 'UnderlinePosition',
  24243. 'num',
  24244. -100
  24245. ],
  24246. [
  24247. [
  24248. 12,
  24249. 4
  24250. ],
  24251. 'UnderlineThickness',
  24252. 'num',
  24253. 50
  24254. ],
  24255. [
  24256. [
  24257. 12,
  24258. 5
  24259. ],
  24260. 'PaintType',
  24261. 'num',
  24262. 0
  24263. ],
  24264. [
  24265. [
  24266. 12,
  24267. 6
  24268. ],
  24269. 'CharstringType',
  24270. 'num',
  24271. 2
  24272. ],
  24273. [
  24274. [
  24275. 12,
  24276. 7
  24277. ],
  24278. 'FontMatrix',
  24279. [
  24280. 'num',
  24281. 'num',
  24282. 'num',
  24283. 'num',
  24284. 'num',
  24285. 'num'
  24286. ],
  24287. [
  24288. 0.001,
  24289. 0,
  24290. 0,
  24291. 0.001,
  24292. 0,
  24293. 0
  24294. ]
  24295. ],
  24296. [
  24297. 13,
  24298. 'UniqueID',
  24299. 'num',
  24300. null
  24301. ],
  24302. [
  24303. 5,
  24304. 'FontBBox',
  24305. [
  24306. 'num',
  24307. 'num',
  24308. 'num',
  24309. 'num'
  24310. ],
  24311. [
  24312. 0,
  24313. 0,
  24314. 0,
  24315. 0
  24316. ]
  24317. ],
  24318. [
  24319. [
  24320. 12,
  24321. 8
  24322. ],
  24323. 'StrokeWidth',
  24324. 'num',
  24325. 0
  24326. ],
  24327. [
  24328. 14,
  24329. 'XUID',
  24330. 'array',
  24331. null
  24332. ],
  24333. [
  24334. 15,
  24335. 'charset',
  24336. 'offset',
  24337. 0
  24338. ],
  24339. [
  24340. 16,
  24341. 'Encoding',
  24342. 'offset',
  24343. 0
  24344. ],
  24345. [
  24346. 17,
  24347. 'CharStrings',
  24348. 'offset',
  24349. 0
  24350. ],
  24351. [
  24352. 18,
  24353. 'Private',
  24354. [
  24355. 'offset',
  24356. 'offset'
  24357. ],
  24358. null
  24359. ],
  24360. [
  24361. [
  24362. 12,
  24363. 21
  24364. ],
  24365. 'PostScript',
  24366. 'sid',
  24367. null
  24368. ],
  24369. [
  24370. [
  24371. 12,
  24372. 22
  24373. ],
  24374. 'BaseFontName',
  24375. 'sid',
  24376. null
  24377. ],
  24378. [
  24379. [
  24380. 12,
  24381. 23
  24382. ],
  24383. 'BaseFontBlend',
  24384. 'delta',
  24385. null
  24386. ],
  24387. [
  24388. [
  24389. 12,
  24390. 31
  24391. ],
  24392. 'CIDFontVersion',
  24393. 'num',
  24394. 0
  24395. ],
  24396. [
  24397. [
  24398. 12,
  24399. 32
  24400. ],
  24401. 'CIDFontRevision',
  24402. 'num',
  24403. 0
  24404. ],
  24405. [
  24406. [
  24407. 12,
  24408. 33
  24409. ],
  24410. 'CIDFontType',
  24411. 'num',
  24412. 0
  24413. ],
  24414. [
  24415. [
  24416. 12,
  24417. 34
  24418. ],
  24419. 'CIDCount',
  24420. 'num',
  24421. 8720
  24422. ],
  24423. [
  24424. [
  24425. 12,
  24426. 35
  24427. ],
  24428. 'UIDBase',
  24429. 'num',
  24430. null
  24431. ],
  24432. [
  24433. [
  24434. 12,
  24435. 37
  24436. ],
  24437. 'FDSelect',
  24438. 'offset',
  24439. null
  24440. ],
  24441. [
  24442. [
  24443. 12,
  24444. 36
  24445. ],
  24446. 'FDArray',
  24447. 'offset',
  24448. null
  24449. ],
  24450. [
  24451. [
  24452. 12,
  24453. 38
  24454. ],
  24455. 'FontName',
  24456. 'sid',
  24457. null
  24458. ]
  24459. ];
  24460. var tables = null;
  24461. function CFFTopDict(strings) {
  24462. if (tables === null) {
  24463. tables = CFFDict.createTables(layout);
  24464. }
  24465. CFFDict.call(this, tables, strings);
  24466. this.privateDict = null;
  24467. }
  24468. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  24469. return CFFTopDict;
  24470. }();
  24471. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24472. var layout = [
  24473. [
  24474. 6,
  24475. 'BlueValues',
  24476. 'delta',
  24477. null
  24478. ],
  24479. [
  24480. 7,
  24481. 'OtherBlues',
  24482. 'delta',
  24483. null
  24484. ],
  24485. [
  24486. 8,
  24487. 'FamilyBlues',
  24488. 'delta',
  24489. null
  24490. ],
  24491. [
  24492. 9,
  24493. 'FamilyOtherBlues',
  24494. 'delta',
  24495. null
  24496. ],
  24497. [
  24498. [
  24499. 12,
  24500. 9
  24501. ],
  24502. 'BlueScale',
  24503. 'num',
  24504. 0.039625
  24505. ],
  24506. [
  24507. [
  24508. 12,
  24509. 10
  24510. ],
  24511. 'BlueShift',
  24512. 'num',
  24513. 7
  24514. ],
  24515. [
  24516. [
  24517. 12,
  24518. 11
  24519. ],
  24520. 'BlueFuzz',
  24521. 'num',
  24522. 1
  24523. ],
  24524. [
  24525. 10,
  24526. 'StdHW',
  24527. 'num',
  24528. null
  24529. ],
  24530. [
  24531. 11,
  24532. 'StdVW',
  24533. 'num',
  24534. null
  24535. ],
  24536. [
  24537. [
  24538. 12,
  24539. 12
  24540. ],
  24541. 'StemSnapH',
  24542. 'delta',
  24543. null
  24544. ],
  24545. [
  24546. [
  24547. 12,
  24548. 13
  24549. ],
  24550. 'StemSnapV',
  24551. 'delta',
  24552. null
  24553. ],
  24554. [
  24555. [
  24556. 12,
  24557. 14
  24558. ],
  24559. 'ForceBold',
  24560. 'num',
  24561. 0
  24562. ],
  24563. [
  24564. [
  24565. 12,
  24566. 17
  24567. ],
  24568. 'LanguageGroup',
  24569. 'num',
  24570. 0
  24571. ],
  24572. [
  24573. [
  24574. 12,
  24575. 18
  24576. ],
  24577. 'ExpansionFactor',
  24578. 'num',
  24579. 0.06
  24580. ],
  24581. [
  24582. [
  24583. 12,
  24584. 19
  24585. ],
  24586. 'initialRandomSeed',
  24587. 'num',
  24588. 0
  24589. ],
  24590. [
  24591. 20,
  24592. 'defaultWidthX',
  24593. 'num',
  24594. 0
  24595. ],
  24596. [
  24597. 21,
  24598. 'nominalWidthX',
  24599. 'num',
  24600. 0
  24601. ],
  24602. [
  24603. 19,
  24604. 'Subrs',
  24605. 'offset',
  24606. null
  24607. ]
  24608. ];
  24609. var tables = null;
  24610. function CFFPrivateDict(strings) {
  24611. if (tables === null) {
  24612. tables = CFFDict.createTables(layout);
  24613. }
  24614. CFFDict.call(this, tables, strings);
  24615. this.subrsIndex = null;
  24616. }
  24617. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  24618. return CFFPrivateDict;
  24619. }();
  24620. var CFFCharsetPredefinedTypes = {
  24621. ISO_ADOBE: 0,
  24622. EXPERT: 1,
  24623. EXPERT_SUBSET: 2
  24624. };
  24625. var CFFCharset = function CFFCharsetClosure() {
  24626. function CFFCharset(predefined, format, charset, raw) {
  24627. this.predefined = predefined;
  24628. this.format = format;
  24629. this.charset = charset;
  24630. this.raw = raw;
  24631. }
  24632. return CFFCharset;
  24633. }();
  24634. var CFFEncoding = function CFFEncodingClosure() {
  24635. function CFFEncoding(predefined, format, encoding, raw) {
  24636. this.predefined = predefined;
  24637. this.format = format;
  24638. this.encoding = encoding;
  24639. this.raw = raw;
  24640. }
  24641. return CFFEncoding;
  24642. }();
  24643. var CFFFDSelect = function CFFFDSelectClosure() {
  24644. function CFFFDSelect(fdSelect, raw) {
  24645. this.fdSelect = fdSelect;
  24646. this.raw = raw;
  24647. }
  24648. CFFFDSelect.prototype = {
  24649. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  24650. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24651. return -1;
  24652. }
  24653. return this.fdSelect[glyphIndex];
  24654. }
  24655. };
  24656. return CFFFDSelect;
  24657. }();
  24658. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  24659. function CFFOffsetTracker() {
  24660. this.offsets = Object.create(null);
  24661. }
  24662. CFFOffsetTracker.prototype = {
  24663. isTracking: function CFFOffsetTracker_isTracking(key) {
  24664. return key in this.offsets;
  24665. },
  24666. track: function CFFOffsetTracker_track(key, location) {
  24667. if (key in this.offsets) {
  24668. error('Already tracking location of ' + key);
  24669. }
  24670. this.offsets[key] = location;
  24671. },
  24672. offset: function CFFOffsetTracker_offset(value) {
  24673. for (var key in this.offsets) {
  24674. this.offsets[key] += value;
  24675. }
  24676. },
  24677. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  24678. if (!(key in this.offsets)) {
  24679. error('Not tracking location of ' + key);
  24680. }
  24681. var data = output.data;
  24682. var dataOffset = this.offsets[key];
  24683. var size = 5;
  24684. for (var i = 0, ii = values.length; i < ii; ++i) {
  24685. var offset0 = i * size + dataOffset;
  24686. var offset1 = offset0 + 1;
  24687. var offset2 = offset0 + 2;
  24688. var offset3 = offset0 + 3;
  24689. var offset4 = offset0 + 4;
  24690. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24691. error('writing to an offset that is not empty');
  24692. }
  24693. var value = values[i];
  24694. data[offset0] = 0x1d;
  24695. data[offset1] = value >> 24 & 0xFF;
  24696. data[offset2] = value >> 16 & 0xFF;
  24697. data[offset3] = value >> 8 & 0xFF;
  24698. data[offset4] = value & 0xFF;
  24699. }
  24700. }
  24701. };
  24702. return CFFOffsetTracker;
  24703. }();
  24704. var CFFCompiler = function CFFCompilerClosure() {
  24705. function CFFCompiler(cff) {
  24706. this.cff = cff;
  24707. }
  24708. CFFCompiler.prototype = {
  24709. compile: function CFFCompiler_compile() {
  24710. var cff = this.cff;
  24711. var output = {
  24712. data: [],
  24713. length: 0,
  24714. add: function CFFCompiler_add(data) {
  24715. this.data = this.data.concat(data);
  24716. this.length = this.data.length;
  24717. }
  24718. };
  24719. var header = this.compileHeader(cff.header);
  24720. output.add(header);
  24721. var nameIndex = this.compileNameIndex(cff.names);
  24722. output.add(nameIndex);
  24723. if (cff.isCIDFont) {
  24724. if (cff.topDict.hasName('FontMatrix')) {
  24725. var base = cff.topDict.getByName('FontMatrix');
  24726. cff.topDict.removeByName('FontMatrix');
  24727. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24728. var subDict = cff.fdArray[i];
  24729. var matrix = base.slice(0);
  24730. if (subDict.hasName('FontMatrix')) {
  24731. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  24732. }
  24733. subDict.setByName('FontMatrix', matrix);
  24734. }
  24735. }
  24736. }
  24737. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24738. output.add(compiled.output);
  24739. var topDictTracker = compiled.trackers[0];
  24740. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24741. output.add(stringIndex);
  24742. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24743. output.add(globalSubrIndex);
  24744. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  24745. if (cff.encoding.predefined) {
  24746. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  24747. } else {
  24748. var encoding = this.compileEncoding(cff.encoding);
  24749. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  24750. output.add(encoding);
  24751. }
  24752. }
  24753. if (cff.charset && cff.topDict.hasName('charset')) {
  24754. if (cff.charset.predefined) {
  24755. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  24756. } else {
  24757. var charset = this.compileCharset(cff.charset);
  24758. topDictTracker.setEntryLocation('charset', [output.length], output);
  24759. output.add(charset);
  24760. }
  24761. }
  24762. var charStrings = this.compileCharStrings(cff.charStrings);
  24763. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  24764. output.add(charStrings);
  24765. if (cff.isCIDFont) {
  24766. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  24767. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  24768. output.add(fdSelect);
  24769. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24770. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  24771. output.add(compiled.output);
  24772. var fontDictTrackers = compiled.trackers;
  24773. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24774. }
  24775. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24776. output.add([0]);
  24777. return output.data;
  24778. },
  24779. encodeNumber: function CFFCompiler_encodeNumber(value) {
  24780. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  24781. return this.encodeInteger(value);
  24782. }
  24783. return this.encodeFloat(value);
  24784. },
  24785. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24786. var value = num.toString();
  24787. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24788. if (m) {
  24789. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24790. value = (Math.round(num * epsilon) / epsilon).toString();
  24791. }
  24792. var nibbles = '';
  24793. var i, ii;
  24794. for (i = 0, ii = value.length; i < ii; ++i) {
  24795. var a = value[i];
  24796. if (a === 'e') {
  24797. nibbles += value[++i] === '-' ? 'c' : 'b';
  24798. } else if (a === '.') {
  24799. nibbles += 'a';
  24800. } else if (a === '-') {
  24801. nibbles += 'e';
  24802. } else {
  24803. nibbles += a;
  24804. }
  24805. }
  24806. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24807. var out = [30];
  24808. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24809. out.push(parseInt(nibbles.substr(i, 2), 16));
  24810. }
  24811. return out;
  24812. },
  24813. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24814. var code;
  24815. if (value >= -107 && value <= 107) {
  24816. code = [value + 139];
  24817. } else if (value >= 108 && value <= 1131) {
  24818. value = value - 108;
  24819. code = [
  24820. (value >> 8) + 247,
  24821. value & 0xFF
  24822. ];
  24823. } else if (value >= -1131 && value <= -108) {
  24824. value = -value - 108;
  24825. code = [
  24826. (value >> 8) + 251,
  24827. value & 0xFF
  24828. ];
  24829. } else if (value >= -32768 && value <= 32767) {
  24830. code = [
  24831. 0x1c,
  24832. value >> 8 & 0xFF,
  24833. value & 0xFF
  24834. ];
  24835. } else {
  24836. code = [
  24837. 0x1d,
  24838. value >> 24 & 0xFF,
  24839. value >> 16 & 0xFF,
  24840. value >> 8 & 0xFF,
  24841. value & 0xFF
  24842. ];
  24843. }
  24844. return code;
  24845. },
  24846. compileHeader: function CFFCompiler_compileHeader(header) {
  24847. return [
  24848. header.major,
  24849. header.minor,
  24850. header.hdrSize,
  24851. header.offSize
  24852. ];
  24853. },
  24854. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24855. var nameIndex = new CFFIndex();
  24856. for (var i = 0, ii = names.length; i < ii; ++i) {
  24857. nameIndex.add(stringToBytes(names[i]));
  24858. }
  24859. return this.compileIndex(nameIndex);
  24860. },
  24861. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24862. var fontDictTrackers = [];
  24863. var fdArrayIndex = new CFFIndex();
  24864. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24865. var fontDict = dicts[i];
  24866. if (removeCidKeys) {
  24867. fontDict.removeByName('CIDFontVersion');
  24868. fontDict.removeByName('CIDFontRevision');
  24869. fontDict.removeByName('CIDFontType');
  24870. fontDict.removeByName('CIDCount');
  24871. fontDict.removeByName('UIDBase');
  24872. }
  24873. var fontDictTracker = new CFFOffsetTracker();
  24874. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24875. fontDictTrackers.push(fontDictTracker);
  24876. fdArrayIndex.add(fontDictData);
  24877. fontDictTracker.offset(length);
  24878. }
  24879. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24880. return {
  24881. trackers: fontDictTrackers,
  24882. output: fdArrayIndex
  24883. };
  24884. },
  24885. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24886. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24887. var fontDict = dicts[i];
  24888. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24889. var privateDict = fontDict.privateDict;
  24890. var privateDictTracker = new CFFOffsetTracker();
  24891. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24892. var outputLength = output.length;
  24893. privateDictTracker.offset(outputLength);
  24894. if (!privateDictData.length) {
  24895. outputLength = 0;
  24896. }
  24897. trackers[i].setEntryLocation('Private', [
  24898. privateDictData.length,
  24899. outputLength
  24900. ], output);
  24901. output.add(privateDictData);
  24902. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24903. var subrs = this.compileIndex(privateDict.subrsIndex);
  24904. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24905. output.add(subrs);
  24906. }
  24907. }
  24908. },
  24909. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24910. var out = [];
  24911. var order = dict.order;
  24912. for (var i = 0; i < order.length; ++i) {
  24913. var key = order[i];
  24914. if (!(key in dict.values)) {
  24915. continue;
  24916. }
  24917. var values = dict.values[key];
  24918. var types = dict.types[key];
  24919. if (!isArray(types)) {
  24920. types = [types];
  24921. }
  24922. if (!isArray(values)) {
  24923. values = [values];
  24924. }
  24925. if (values.length === 0) {
  24926. continue;
  24927. }
  24928. for (var j = 0, jj = types.length; j < jj; ++j) {
  24929. var type = types[j];
  24930. var value = values[j];
  24931. switch (type) {
  24932. case 'num':
  24933. case 'sid':
  24934. out = out.concat(this.encodeNumber(value));
  24935. break;
  24936. case 'offset':
  24937. var name = dict.keyToNameMap[key];
  24938. if (!offsetTracker.isTracking(name)) {
  24939. offsetTracker.track(name, out.length);
  24940. }
  24941. out = out.concat([
  24942. 0x1d,
  24943. 0,
  24944. 0,
  24945. 0,
  24946. 0
  24947. ]);
  24948. break;
  24949. case 'array':
  24950. case 'delta':
  24951. out = out.concat(this.encodeNumber(value));
  24952. for (var k = 1, kk = values.length; k < kk; ++k) {
  24953. out = out.concat(this.encodeNumber(values[k]));
  24954. }
  24955. break;
  24956. default:
  24957. error('Unknown data type of ' + type);
  24958. break;
  24959. }
  24960. }
  24961. out = out.concat(dict.opcodes[key]);
  24962. }
  24963. return out;
  24964. },
  24965. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24966. var stringIndex = new CFFIndex();
  24967. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24968. stringIndex.add(stringToBytes(strings[i]));
  24969. }
  24970. return this.compileIndex(stringIndex);
  24971. },
  24972. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24973. var globalSubrIndex = this.cff.globalSubrIndex;
  24974. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24975. },
  24976. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24977. return this.compileIndex(charStrings);
  24978. },
  24979. compileCharset: function CFFCompiler_compileCharset(charset) {
  24980. return this.compileTypedArray(charset.raw);
  24981. },
  24982. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24983. return this.compileTypedArray(encoding.raw);
  24984. },
  24985. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24986. return this.compileTypedArray(fdSelect);
  24987. },
  24988. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24989. var out = [];
  24990. for (var i = 0, ii = data.length; i < ii; ++i) {
  24991. out[i] = data[i];
  24992. }
  24993. return out;
  24994. },
  24995. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24996. trackers = trackers || [];
  24997. var objects = index.objects;
  24998. var count = objects.length;
  24999. if (count === 0) {
  25000. return [
  25001. 0,
  25002. 0,
  25003. 0
  25004. ];
  25005. }
  25006. var data = [
  25007. count >> 8 & 0xFF,
  25008. count & 0xff
  25009. ];
  25010. var lastOffset = 1, i;
  25011. for (i = 0; i < count; ++i) {
  25012. lastOffset += objects[i].length;
  25013. }
  25014. var offsetSize;
  25015. if (lastOffset < 0x100) {
  25016. offsetSize = 1;
  25017. } else if (lastOffset < 0x10000) {
  25018. offsetSize = 2;
  25019. } else if (lastOffset < 0x1000000) {
  25020. offsetSize = 3;
  25021. } else {
  25022. offsetSize = 4;
  25023. }
  25024. data.push(offsetSize);
  25025. var relativeOffset = 1;
  25026. for (i = 0; i < count + 1; i++) {
  25027. if (offsetSize === 1) {
  25028. data.push(relativeOffset & 0xFF);
  25029. } else if (offsetSize === 2) {
  25030. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25031. } else if (offsetSize === 3) {
  25032. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25033. } else {
  25034. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25035. }
  25036. if (objects[i]) {
  25037. relativeOffset += objects[i].length;
  25038. }
  25039. }
  25040. for (i = 0; i < count; i++) {
  25041. if (trackers[i]) {
  25042. trackers[i].offset(data.length);
  25043. }
  25044. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  25045. data.push(objects[i][j]);
  25046. }
  25047. }
  25048. return data;
  25049. }
  25050. };
  25051. return CFFCompiler;
  25052. }();
  25053. exports.CFFStandardStrings = CFFStandardStrings;
  25054. exports.CFFParser = CFFParser;
  25055. exports.CFF = CFF;
  25056. exports.CFFHeader = CFFHeader;
  25057. exports.CFFStrings = CFFStrings;
  25058. exports.CFFIndex = CFFIndex;
  25059. exports.CFFCharset = CFFCharset;
  25060. exports.CFFTopDict = CFFTopDict;
  25061. exports.CFFPrivateDict = CFFPrivateDict;
  25062. exports.CFFCompiler = CFFCompiler;
  25063. /***/ }),
  25064. /* 15 */
  25065. /***/ (function(module, exports, __w_pdfjs_require__) {
  25066. "use strict";
  25067. var sharedUtil = __w_pdfjs_require__(0);
  25068. var MissingDataException = sharedUtil.MissingDataException;
  25069. var arrayByteLength = sharedUtil.arrayByteLength;
  25070. var arraysToBytes = sharedUtil.arraysToBytes;
  25071. var assert = sharedUtil.assert;
  25072. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25073. var isInt = sharedUtil.isInt;
  25074. var isEmptyObj = sharedUtil.isEmptyObj;
  25075. var ChunkedStream = function ChunkedStreamClosure() {
  25076. function ChunkedStream(length, chunkSize, manager) {
  25077. this.bytes = new Uint8Array(length);
  25078. this.start = 0;
  25079. this.pos = 0;
  25080. this.end = length;
  25081. this.chunkSize = chunkSize;
  25082. this.loadedChunks = [];
  25083. this.numChunksLoaded = 0;
  25084. this.numChunks = Math.ceil(length / chunkSize);
  25085. this.manager = manager;
  25086. this.progressiveDataLength = 0;
  25087. this.lastSuccessfulEnsureByteChunk = -1;
  25088. }
  25089. ChunkedStream.prototype = {
  25090. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25091. var chunks = [];
  25092. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25093. if (!this.loadedChunks[chunk]) {
  25094. chunks.push(chunk);
  25095. }
  25096. }
  25097. return chunks;
  25098. },
  25099. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25100. return [this];
  25101. },
  25102. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25103. return this.numChunksLoaded === this.numChunks;
  25104. },
  25105. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25106. var end = begin + chunk.byteLength;
  25107. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25108. var length = this.bytes.length;
  25109. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25110. this.bytes.set(new Uint8Array(chunk), begin);
  25111. var chunkSize = this.chunkSize;
  25112. var beginChunk = Math.floor(begin / chunkSize);
  25113. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25114. var curChunk;
  25115. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25116. if (!this.loadedChunks[curChunk]) {
  25117. this.loadedChunks[curChunk] = true;
  25118. ++this.numChunksLoaded;
  25119. }
  25120. }
  25121. },
  25122. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25123. var position = this.progressiveDataLength;
  25124. var beginChunk = Math.floor(position / this.chunkSize);
  25125. this.bytes.set(new Uint8Array(data), position);
  25126. position += data.byteLength;
  25127. this.progressiveDataLength = position;
  25128. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25129. var curChunk;
  25130. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25131. if (!this.loadedChunks[curChunk]) {
  25132. this.loadedChunks[curChunk] = true;
  25133. ++this.numChunksLoaded;
  25134. }
  25135. }
  25136. },
  25137. ensureByte: function ChunkedStream_ensureByte(pos) {
  25138. var chunk = Math.floor(pos / this.chunkSize);
  25139. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25140. return;
  25141. }
  25142. if (!this.loadedChunks[chunk]) {
  25143. throw new MissingDataException(pos, pos + 1);
  25144. }
  25145. this.lastSuccessfulEnsureByteChunk = chunk;
  25146. },
  25147. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25148. if (begin >= end) {
  25149. return;
  25150. }
  25151. if (end <= this.progressiveDataLength) {
  25152. return;
  25153. }
  25154. var chunkSize = this.chunkSize;
  25155. var beginChunk = Math.floor(begin / chunkSize);
  25156. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25157. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25158. if (!this.loadedChunks[chunk]) {
  25159. throw new MissingDataException(begin, end);
  25160. }
  25161. }
  25162. },
  25163. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25164. var chunk, numChunks = this.numChunks;
  25165. for (var i = 0; i < numChunks; ++i) {
  25166. chunk = (beginChunk + i) % numChunks;
  25167. if (!this.loadedChunks[chunk]) {
  25168. return chunk;
  25169. }
  25170. }
  25171. return null;
  25172. },
  25173. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25174. return !!this.loadedChunks[chunk];
  25175. },
  25176. get length() {
  25177. return this.end - this.start;
  25178. },
  25179. get isEmpty() {
  25180. return this.length === 0;
  25181. },
  25182. getByte: function ChunkedStream_getByte() {
  25183. var pos = this.pos;
  25184. if (pos >= this.end) {
  25185. return -1;
  25186. }
  25187. this.ensureByte(pos);
  25188. return this.bytes[this.pos++];
  25189. },
  25190. getUint16: function ChunkedStream_getUint16() {
  25191. var b0 = this.getByte();
  25192. var b1 = this.getByte();
  25193. if (b0 === -1 || b1 === -1) {
  25194. return -1;
  25195. }
  25196. return (b0 << 8) + b1;
  25197. },
  25198. getInt32: function ChunkedStream_getInt32() {
  25199. var b0 = this.getByte();
  25200. var b1 = this.getByte();
  25201. var b2 = this.getByte();
  25202. var b3 = this.getByte();
  25203. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25204. },
  25205. getBytes: function ChunkedStream_getBytes(length) {
  25206. var bytes = this.bytes;
  25207. var pos = this.pos;
  25208. var strEnd = this.end;
  25209. if (!length) {
  25210. this.ensureRange(pos, strEnd);
  25211. return bytes.subarray(pos, strEnd);
  25212. }
  25213. var end = pos + length;
  25214. if (end > strEnd) {
  25215. end = strEnd;
  25216. }
  25217. this.ensureRange(pos, end);
  25218. this.pos = end;
  25219. return bytes.subarray(pos, end);
  25220. },
  25221. peekByte: function ChunkedStream_peekByte() {
  25222. var peekedByte = this.getByte();
  25223. this.pos--;
  25224. return peekedByte;
  25225. },
  25226. peekBytes: function ChunkedStream_peekBytes(length) {
  25227. var bytes = this.getBytes(length);
  25228. this.pos -= bytes.length;
  25229. return bytes;
  25230. },
  25231. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25232. this.ensureRange(begin, end);
  25233. return this.bytes.subarray(begin, end);
  25234. },
  25235. skip: function ChunkedStream_skip(n) {
  25236. if (!n) {
  25237. n = 1;
  25238. }
  25239. this.pos += n;
  25240. },
  25241. reset: function ChunkedStream_reset() {
  25242. this.pos = this.start;
  25243. },
  25244. moveStart: function ChunkedStream_moveStart() {
  25245. this.start = this.pos;
  25246. },
  25247. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25248. this.ensureRange(start, start + length);
  25249. function ChunkedStreamSubstream() {
  25250. }
  25251. ChunkedStreamSubstream.prototype = Object.create(this);
  25252. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25253. var chunkSize = this.chunkSize;
  25254. var beginChunk = Math.floor(this.start / chunkSize);
  25255. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25256. var missingChunks = [];
  25257. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25258. if (!this.loadedChunks[chunk]) {
  25259. missingChunks.push(chunk);
  25260. }
  25261. }
  25262. return missingChunks;
  25263. };
  25264. var subStream = new ChunkedStreamSubstream();
  25265. subStream.pos = subStream.start = start;
  25266. subStream.end = start + length || this.end;
  25267. subStream.dict = dict;
  25268. return subStream;
  25269. }
  25270. };
  25271. return ChunkedStream;
  25272. }();
  25273. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25274. function ChunkedStreamManager(pdfNetworkStream, args) {
  25275. var chunkSize = args.rangeChunkSize;
  25276. var length = args.length;
  25277. this.stream = new ChunkedStream(length, chunkSize, this);
  25278. this.length = length;
  25279. this.chunkSize = chunkSize;
  25280. this.pdfNetworkStream = pdfNetworkStream;
  25281. this.url = args.url;
  25282. this.disableAutoFetch = args.disableAutoFetch;
  25283. this.msgHandler = args.msgHandler;
  25284. this.currRequestId = 0;
  25285. this.chunksNeededByRequest = Object.create(null);
  25286. this.requestsByChunk = Object.create(null);
  25287. this.promisesByRequest = Object.create(null);
  25288. this.progressiveDataLength = 0;
  25289. this.aborted = false;
  25290. this._loadedStreamCapability = createPromiseCapability();
  25291. }
  25292. ChunkedStreamManager.prototype = {
  25293. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25294. return this._loadedStreamCapability.promise;
  25295. },
  25296. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25297. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25298. if (!rangeReader.isStreamingSupported) {
  25299. rangeReader.onProgress = this.onProgress.bind(this);
  25300. }
  25301. var chunks = [], loaded = 0;
  25302. var manager = this;
  25303. var promise = new Promise(function (resolve, reject) {
  25304. var readChunk = function (chunk) {
  25305. try {
  25306. if (!chunk.done) {
  25307. var data = chunk.value;
  25308. chunks.push(data);
  25309. loaded += arrayByteLength(data);
  25310. if (rangeReader.isStreamingSupported) {
  25311. manager.onProgress({ loaded: loaded });
  25312. }
  25313. rangeReader.read().then(readChunk, reject);
  25314. return;
  25315. }
  25316. var chunkData = arraysToBytes(chunks);
  25317. chunks = null;
  25318. resolve(chunkData);
  25319. } catch (e) {
  25320. reject(e);
  25321. }
  25322. };
  25323. rangeReader.read().then(readChunk, reject);
  25324. });
  25325. promise.then(function (data) {
  25326. if (this.aborted) {
  25327. return;
  25328. }
  25329. this.onReceiveData({
  25330. chunk: data,
  25331. begin: begin
  25332. });
  25333. }.bind(this));
  25334. },
  25335. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25336. var missingChunks = this.stream.getMissingChunks();
  25337. this._requestChunks(missingChunks);
  25338. return this._loadedStreamCapability.promise;
  25339. },
  25340. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  25341. var requestId = this.currRequestId++;
  25342. var i, ii;
  25343. var chunksNeeded = Object.create(null);
  25344. this.chunksNeededByRequest[requestId] = chunksNeeded;
  25345. for (i = 0, ii = chunks.length; i < ii; i++) {
  25346. if (!this.stream.hasChunk(chunks[i])) {
  25347. chunksNeeded[chunks[i]] = true;
  25348. }
  25349. }
  25350. if (isEmptyObj(chunksNeeded)) {
  25351. return Promise.resolve();
  25352. }
  25353. var capability = createPromiseCapability();
  25354. this.promisesByRequest[requestId] = capability;
  25355. var chunksToRequest = [];
  25356. for (var chunk in chunksNeeded) {
  25357. chunk = chunk | 0;
  25358. if (!(chunk in this.requestsByChunk)) {
  25359. this.requestsByChunk[chunk] = [];
  25360. chunksToRequest.push(chunk);
  25361. }
  25362. this.requestsByChunk[chunk].push(requestId);
  25363. }
  25364. if (!chunksToRequest.length) {
  25365. return capability.promise;
  25366. }
  25367. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  25368. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  25369. var groupedChunk = groupedChunksToRequest[i];
  25370. var begin = groupedChunk.beginChunk * this.chunkSize;
  25371. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  25372. this.sendRequest(begin, end);
  25373. }
  25374. return capability.promise;
  25375. },
  25376. getStream: function ChunkedStreamManager_getStream() {
  25377. return this.stream;
  25378. },
  25379. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  25380. end = Math.min(end, this.length);
  25381. var beginChunk = this.getBeginChunk(begin);
  25382. var endChunk = this.getEndChunk(end);
  25383. var chunks = [];
  25384. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25385. chunks.push(chunk);
  25386. }
  25387. return this._requestChunks(chunks);
  25388. },
  25389. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  25390. ranges = ranges || [];
  25391. var chunksToRequest = [];
  25392. for (var i = 0; i < ranges.length; i++) {
  25393. var beginChunk = this.getBeginChunk(ranges[i].begin);
  25394. var endChunk = this.getEndChunk(ranges[i].end);
  25395. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25396. if (chunksToRequest.indexOf(chunk) < 0) {
  25397. chunksToRequest.push(chunk);
  25398. }
  25399. }
  25400. }
  25401. chunksToRequest.sort(function (a, b) {
  25402. return a - b;
  25403. });
  25404. return this._requestChunks(chunksToRequest);
  25405. },
  25406. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  25407. var groupedChunks = [];
  25408. var beginChunk = -1;
  25409. var prevChunk = -1;
  25410. for (var i = 0; i < chunks.length; ++i) {
  25411. var chunk = chunks[i];
  25412. if (beginChunk < 0) {
  25413. beginChunk = chunk;
  25414. }
  25415. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  25416. groupedChunks.push({
  25417. beginChunk: beginChunk,
  25418. endChunk: prevChunk + 1
  25419. });
  25420. beginChunk = chunk;
  25421. }
  25422. if (i + 1 === chunks.length) {
  25423. groupedChunks.push({
  25424. beginChunk: beginChunk,
  25425. endChunk: chunk + 1
  25426. });
  25427. }
  25428. prevChunk = chunk;
  25429. }
  25430. return groupedChunks;
  25431. },
  25432. onProgress: function ChunkedStreamManager_onProgress(args) {
  25433. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  25434. this.msgHandler.send('DocProgress', {
  25435. loaded: bytesLoaded,
  25436. total: this.length
  25437. });
  25438. },
  25439. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  25440. var chunk = args.chunk;
  25441. var isProgressive = args.begin === undefined;
  25442. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  25443. var end = begin + chunk.byteLength;
  25444. var beginChunk = Math.floor(begin / this.chunkSize);
  25445. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  25446. if (isProgressive) {
  25447. this.stream.onReceiveProgressiveData(chunk);
  25448. this.progressiveDataLength = end;
  25449. } else {
  25450. this.stream.onReceiveData(begin, chunk);
  25451. }
  25452. if (this.stream.allChunksLoaded()) {
  25453. this._loadedStreamCapability.resolve(this.stream);
  25454. }
  25455. var loadedRequests = [];
  25456. var i, requestId;
  25457. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  25458. var requestIds = this.requestsByChunk[chunk] || [];
  25459. delete this.requestsByChunk[chunk];
  25460. for (i = 0; i < requestIds.length; ++i) {
  25461. requestId = requestIds[i];
  25462. var chunksNeeded = this.chunksNeededByRequest[requestId];
  25463. if (chunk in chunksNeeded) {
  25464. delete chunksNeeded[chunk];
  25465. }
  25466. if (!isEmptyObj(chunksNeeded)) {
  25467. continue;
  25468. }
  25469. loadedRequests.push(requestId);
  25470. }
  25471. }
  25472. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  25473. var nextEmptyChunk;
  25474. if (this.stream.numChunksLoaded === 1) {
  25475. var lastChunk = this.stream.numChunks - 1;
  25476. if (!this.stream.hasChunk(lastChunk)) {
  25477. nextEmptyChunk = lastChunk;
  25478. }
  25479. } else {
  25480. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  25481. }
  25482. if (isInt(nextEmptyChunk)) {
  25483. this._requestChunks([nextEmptyChunk]);
  25484. }
  25485. }
  25486. for (i = 0; i < loadedRequests.length; ++i) {
  25487. requestId = loadedRequests[i];
  25488. var capability = this.promisesByRequest[requestId];
  25489. delete this.promisesByRequest[requestId];
  25490. capability.resolve();
  25491. }
  25492. this.msgHandler.send('DocProgress', {
  25493. loaded: this.stream.numChunksLoaded * this.chunkSize,
  25494. total: this.length
  25495. });
  25496. },
  25497. onError: function ChunkedStreamManager_onError(err) {
  25498. this._loadedStreamCapability.reject(err);
  25499. },
  25500. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  25501. var chunk = Math.floor(begin / this.chunkSize);
  25502. return chunk;
  25503. },
  25504. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  25505. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  25506. return chunk;
  25507. },
  25508. abort: function ChunkedStreamManager_abort() {
  25509. this.aborted = true;
  25510. if (this.pdfNetworkStream) {
  25511. this.pdfNetworkStream.cancelAllRequests('abort');
  25512. }
  25513. for (var requestId in this.promisesByRequest) {
  25514. var capability = this.promisesByRequest[requestId];
  25515. capability.reject(new Error('Request was aborted'));
  25516. }
  25517. }
  25518. };
  25519. return ChunkedStreamManager;
  25520. }();
  25521. exports.ChunkedStream = ChunkedStream;
  25522. exports.ChunkedStreamManager = ChunkedStreamManager;
  25523. /***/ }),
  25524. /* 16 */
  25525. /***/ (function(module, exports, __w_pdfjs_require__) {
  25526. "use strict";
  25527. var sharedUtil = __w_pdfjs_require__(0);
  25528. var corePrimitives = __w_pdfjs_require__(1);
  25529. var coreStream = __w_pdfjs_require__(2);
  25530. var PasswordException = sharedUtil.PasswordException;
  25531. var PasswordResponses = sharedUtil.PasswordResponses;
  25532. var bytesToString = sharedUtil.bytesToString;
  25533. var warn = sharedUtil.warn;
  25534. var error = sharedUtil.error;
  25535. var assert = sharedUtil.assert;
  25536. var isInt = sharedUtil.isInt;
  25537. var stringToBytes = sharedUtil.stringToBytes;
  25538. var utf8StringToString = sharedUtil.utf8StringToString;
  25539. var Name = corePrimitives.Name;
  25540. var isName = corePrimitives.isName;
  25541. var isDict = corePrimitives.isDict;
  25542. var DecryptStream = coreStream.DecryptStream;
  25543. var ARCFourCipher = function ARCFourCipherClosure() {
  25544. function ARCFourCipher(key) {
  25545. this.a = 0;
  25546. this.b = 0;
  25547. var s = new Uint8Array(256);
  25548. var i, j = 0, tmp, keyLength = key.length;
  25549. for (i = 0; i < 256; ++i) {
  25550. s[i] = i;
  25551. }
  25552. for (i = 0; i < 256; ++i) {
  25553. tmp = s[i];
  25554. j = j + tmp + key[i % keyLength] & 0xFF;
  25555. s[i] = s[j];
  25556. s[j] = tmp;
  25557. }
  25558. this.s = s;
  25559. }
  25560. ARCFourCipher.prototype = {
  25561. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  25562. var i, n = data.length, tmp, tmp2;
  25563. var a = this.a, b = this.b, s = this.s;
  25564. var output = new Uint8Array(n);
  25565. for (i = 0; i < n; ++i) {
  25566. a = a + 1 & 0xFF;
  25567. tmp = s[a];
  25568. b = b + tmp & 0xFF;
  25569. tmp2 = s[b];
  25570. s[a] = tmp2;
  25571. s[b] = tmp;
  25572. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  25573. }
  25574. this.a = a;
  25575. this.b = b;
  25576. return output;
  25577. }
  25578. };
  25579. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  25580. return ARCFourCipher;
  25581. }();
  25582. var calculateMD5 = function calculateMD5Closure() {
  25583. var r = new Uint8Array([
  25584. 7,
  25585. 12,
  25586. 17,
  25587. 22,
  25588. 7,
  25589. 12,
  25590. 17,
  25591. 22,
  25592. 7,
  25593. 12,
  25594. 17,
  25595. 22,
  25596. 7,
  25597. 12,
  25598. 17,
  25599. 22,
  25600. 5,
  25601. 9,
  25602. 14,
  25603. 20,
  25604. 5,
  25605. 9,
  25606. 14,
  25607. 20,
  25608. 5,
  25609. 9,
  25610. 14,
  25611. 20,
  25612. 5,
  25613. 9,
  25614. 14,
  25615. 20,
  25616. 4,
  25617. 11,
  25618. 16,
  25619. 23,
  25620. 4,
  25621. 11,
  25622. 16,
  25623. 23,
  25624. 4,
  25625. 11,
  25626. 16,
  25627. 23,
  25628. 4,
  25629. 11,
  25630. 16,
  25631. 23,
  25632. 6,
  25633. 10,
  25634. 15,
  25635. 21,
  25636. 6,
  25637. 10,
  25638. 15,
  25639. 21,
  25640. 6,
  25641. 10,
  25642. 15,
  25643. 21,
  25644. 6,
  25645. 10,
  25646. 15,
  25647. 21
  25648. ]);
  25649. var k = new Int32Array([
  25650. -680876936,
  25651. -389564586,
  25652. 606105819,
  25653. -1044525330,
  25654. -176418897,
  25655. 1200080426,
  25656. -1473231341,
  25657. -45705983,
  25658. 1770035416,
  25659. -1958414417,
  25660. -42063,
  25661. -1990404162,
  25662. 1804603682,
  25663. -40341101,
  25664. -1502002290,
  25665. 1236535329,
  25666. -165796510,
  25667. -1069501632,
  25668. 643717713,
  25669. -373897302,
  25670. -701558691,
  25671. 38016083,
  25672. -660478335,
  25673. -405537848,
  25674. 568446438,
  25675. -1019803690,
  25676. -187363961,
  25677. 1163531501,
  25678. -1444681467,
  25679. -51403784,
  25680. 1735328473,
  25681. -1926607734,
  25682. -378558,
  25683. -2022574463,
  25684. 1839030562,
  25685. -35309556,
  25686. -1530992060,
  25687. 1272893353,
  25688. -155497632,
  25689. -1094730640,
  25690. 681279174,
  25691. -358537222,
  25692. -722521979,
  25693. 76029189,
  25694. -640364487,
  25695. -421815835,
  25696. 530742520,
  25697. -995338651,
  25698. -198630844,
  25699. 1126891415,
  25700. -1416354905,
  25701. -57434055,
  25702. 1700485571,
  25703. -1894986606,
  25704. -1051523,
  25705. -2054922799,
  25706. 1873313359,
  25707. -30611744,
  25708. -1560198380,
  25709. 1309151649,
  25710. -145523070,
  25711. -1120210379,
  25712. 718787259,
  25713. -343485551
  25714. ]);
  25715. function hash(data, offset, length) {
  25716. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  25717. var paddedLength = length + 72 & ~63;
  25718. var padded = new Uint8Array(paddedLength);
  25719. var i, j, n;
  25720. for (i = 0; i < length; ++i) {
  25721. padded[i] = data[offset++];
  25722. }
  25723. padded[i++] = 0x80;
  25724. n = paddedLength - 8;
  25725. while (i < n) {
  25726. padded[i++] = 0;
  25727. }
  25728. padded[i++] = length << 3 & 0xFF;
  25729. padded[i++] = length >> 5 & 0xFF;
  25730. padded[i++] = length >> 13 & 0xFF;
  25731. padded[i++] = length >> 21 & 0xFF;
  25732. padded[i++] = length >>> 29 & 0xFF;
  25733. padded[i++] = 0;
  25734. padded[i++] = 0;
  25735. padded[i++] = 0;
  25736. var w = new Int32Array(16);
  25737. for (i = 0; i < paddedLength;) {
  25738. for (j = 0; j < 16; ++j, i += 4) {
  25739. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  25740. }
  25741. var a = h0, b = h1, c = h2, d = h3, f, g;
  25742. for (j = 0; j < 64; ++j) {
  25743. if (j < 16) {
  25744. f = b & c | ~b & d;
  25745. g = j;
  25746. } else if (j < 32) {
  25747. f = d & b | ~d & c;
  25748. g = 5 * j + 1 & 15;
  25749. } else if (j < 48) {
  25750. f = b ^ c ^ d;
  25751. g = 3 * j + 5 & 15;
  25752. } else {
  25753. f = c ^ (b | ~d);
  25754. g = 7 * j & 15;
  25755. }
  25756. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  25757. d = c;
  25758. c = b;
  25759. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  25760. a = tmp;
  25761. }
  25762. h0 = h0 + a | 0;
  25763. h1 = h1 + b | 0;
  25764. h2 = h2 + c | 0;
  25765. h3 = h3 + d | 0;
  25766. }
  25767. return new Uint8Array([
  25768. h0 & 0xFF,
  25769. h0 >> 8 & 0xFF,
  25770. h0 >> 16 & 0xFF,
  25771. h0 >>> 24 & 0xFF,
  25772. h1 & 0xFF,
  25773. h1 >> 8 & 0xFF,
  25774. h1 >> 16 & 0xFF,
  25775. h1 >>> 24 & 0xFF,
  25776. h2 & 0xFF,
  25777. h2 >> 8 & 0xFF,
  25778. h2 >> 16 & 0xFF,
  25779. h2 >>> 24 & 0xFF,
  25780. h3 & 0xFF,
  25781. h3 >> 8 & 0xFF,
  25782. h3 >> 16 & 0xFF,
  25783. h3 >>> 24 & 0xFF
  25784. ]);
  25785. }
  25786. return hash;
  25787. }();
  25788. var Word64 = function Word64Closure() {
  25789. function Word64(highInteger, lowInteger) {
  25790. this.high = highInteger | 0;
  25791. this.low = lowInteger | 0;
  25792. }
  25793. Word64.prototype = {
  25794. and: function Word64_and(word) {
  25795. this.high &= word.high;
  25796. this.low &= word.low;
  25797. },
  25798. xor: function Word64_xor(word) {
  25799. this.high ^= word.high;
  25800. this.low ^= word.low;
  25801. },
  25802. or: function Word64_or(word) {
  25803. this.high |= word.high;
  25804. this.low |= word.low;
  25805. },
  25806. shiftRight: function Word64_shiftRight(places) {
  25807. if (places >= 32) {
  25808. this.low = this.high >>> places - 32 | 0;
  25809. this.high = 0;
  25810. } else {
  25811. this.low = this.low >>> places | this.high << 32 - places;
  25812. this.high = this.high >>> places | 0;
  25813. }
  25814. },
  25815. shiftLeft: function Word64_shiftLeft(places) {
  25816. if (places >= 32) {
  25817. this.high = this.low << places - 32;
  25818. this.low = 0;
  25819. } else {
  25820. this.high = this.high << places | this.low >>> 32 - places;
  25821. this.low = this.low << places;
  25822. }
  25823. },
  25824. rotateRight: function Word64_rotateRight(places) {
  25825. var low, high;
  25826. if (places & 32) {
  25827. high = this.low;
  25828. low = this.high;
  25829. } else {
  25830. low = this.low;
  25831. high = this.high;
  25832. }
  25833. places &= 31;
  25834. this.low = low >>> places | high << 32 - places;
  25835. this.high = high >>> places | low << 32 - places;
  25836. },
  25837. not: function Word64_not() {
  25838. this.high = ~this.high;
  25839. this.low = ~this.low;
  25840. },
  25841. add: function Word64_add(word) {
  25842. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25843. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25844. if (lowAdd > 0xFFFFFFFF) {
  25845. highAdd += 1;
  25846. }
  25847. this.low = lowAdd | 0;
  25848. this.high = highAdd | 0;
  25849. },
  25850. copyTo: function Word64_copyTo(bytes, offset) {
  25851. bytes[offset] = this.high >>> 24 & 0xFF;
  25852. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25853. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25854. bytes[offset + 3] = this.high & 0xFF;
  25855. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25856. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25857. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25858. bytes[offset + 7] = this.low & 0xFF;
  25859. },
  25860. assign: function Word64_assign(word) {
  25861. this.high = word.high;
  25862. this.low = word.low;
  25863. }
  25864. };
  25865. return Word64;
  25866. }();
  25867. var calculateSHA256 = function calculateSHA256Closure() {
  25868. function rotr(x, n) {
  25869. return x >>> n | x << 32 - n;
  25870. }
  25871. function ch(x, y, z) {
  25872. return x & y ^ ~x & z;
  25873. }
  25874. function maj(x, y, z) {
  25875. return x & y ^ x & z ^ y & z;
  25876. }
  25877. function sigma(x) {
  25878. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25879. }
  25880. function sigmaPrime(x) {
  25881. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25882. }
  25883. function littleSigma(x) {
  25884. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25885. }
  25886. function littleSigmaPrime(x) {
  25887. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25888. }
  25889. var k = [
  25890. 0x428a2f98,
  25891. 0x71374491,
  25892. 0xb5c0fbcf,
  25893. 0xe9b5dba5,
  25894. 0x3956c25b,
  25895. 0x59f111f1,
  25896. 0x923f82a4,
  25897. 0xab1c5ed5,
  25898. 0xd807aa98,
  25899. 0x12835b01,
  25900. 0x243185be,
  25901. 0x550c7dc3,
  25902. 0x72be5d74,
  25903. 0x80deb1fe,
  25904. 0x9bdc06a7,
  25905. 0xc19bf174,
  25906. 0xe49b69c1,
  25907. 0xefbe4786,
  25908. 0x0fc19dc6,
  25909. 0x240ca1cc,
  25910. 0x2de92c6f,
  25911. 0x4a7484aa,
  25912. 0x5cb0a9dc,
  25913. 0x76f988da,
  25914. 0x983e5152,
  25915. 0xa831c66d,
  25916. 0xb00327c8,
  25917. 0xbf597fc7,
  25918. 0xc6e00bf3,
  25919. 0xd5a79147,
  25920. 0x06ca6351,
  25921. 0x14292967,
  25922. 0x27b70a85,
  25923. 0x2e1b2138,
  25924. 0x4d2c6dfc,
  25925. 0x53380d13,
  25926. 0x650a7354,
  25927. 0x766a0abb,
  25928. 0x81c2c92e,
  25929. 0x92722c85,
  25930. 0xa2bfe8a1,
  25931. 0xa81a664b,
  25932. 0xc24b8b70,
  25933. 0xc76c51a3,
  25934. 0xd192e819,
  25935. 0xd6990624,
  25936. 0xf40e3585,
  25937. 0x106aa070,
  25938. 0x19a4c116,
  25939. 0x1e376c08,
  25940. 0x2748774c,
  25941. 0x34b0bcb5,
  25942. 0x391c0cb3,
  25943. 0x4ed8aa4a,
  25944. 0x5b9cca4f,
  25945. 0x682e6ff3,
  25946. 0x748f82ee,
  25947. 0x78a5636f,
  25948. 0x84c87814,
  25949. 0x8cc70208,
  25950. 0x90befffa,
  25951. 0xa4506ceb,
  25952. 0xbef9a3f7,
  25953. 0xc67178f2
  25954. ];
  25955. function hash(data, offset, length) {
  25956. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25957. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25958. var padded = new Uint8Array(paddedLength);
  25959. var i, j, n;
  25960. for (i = 0; i < length; ++i) {
  25961. padded[i] = data[offset++];
  25962. }
  25963. padded[i++] = 0x80;
  25964. n = paddedLength - 8;
  25965. while (i < n) {
  25966. padded[i++] = 0;
  25967. }
  25968. padded[i++] = 0;
  25969. padded[i++] = 0;
  25970. padded[i++] = 0;
  25971. padded[i++] = length >>> 29 & 0xFF;
  25972. padded[i++] = length >> 21 & 0xFF;
  25973. padded[i++] = length >> 13 & 0xFF;
  25974. padded[i++] = length >> 5 & 0xFF;
  25975. padded[i++] = length << 3 & 0xFF;
  25976. var w = new Uint32Array(64);
  25977. for (i = 0; i < paddedLength;) {
  25978. for (j = 0; j < 16; ++j) {
  25979. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25980. i += 4;
  25981. }
  25982. for (j = 16; j < 64; ++j) {
  25983. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25984. }
  25985. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25986. for (j = 0; j < 64; ++j) {
  25987. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25988. t2 = sigma(a) + maj(a, b, c);
  25989. h = g;
  25990. g = f;
  25991. f = e;
  25992. e = d + t1 | 0;
  25993. d = c;
  25994. c = b;
  25995. b = a;
  25996. a = t1 + t2 | 0;
  25997. }
  25998. h0 = h0 + a | 0;
  25999. h1 = h1 + b | 0;
  26000. h2 = h2 + c | 0;
  26001. h3 = h3 + d | 0;
  26002. h4 = h4 + e | 0;
  26003. h5 = h5 + f | 0;
  26004. h6 = h6 + g | 0;
  26005. h7 = h7 + h | 0;
  26006. }
  26007. return new Uint8Array([
  26008. h0 >> 24 & 0xFF,
  26009. h0 >> 16 & 0xFF,
  26010. h0 >> 8 & 0xFF,
  26011. h0 & 0xFF,
  26012. h1 >> 24 & 0xFF,
  26013. h1 >> 16 & 0xFF,
  26014. h1 >> 8 & 0xFF,
  26015. h1 & 0xFF,
  26016. h2 >> 24 & 0xFF,
  26017. h2 >> 16 & 0xFF,
  26018. h2 >> 8 & 0xFF,
  26019. h2 & 0xFF,
  26020. h3 >> 24 & 0xFF,
  26021. h3 >> 16 & 0xFF,
  26022. h3 >> 8 & 0xFF,
  26023. h3 & 0xFF,
  26024. h4 >> 24 & 0xFF,
  26025. h4 >> 16 & 0xFF,
  26026. h4 >> 8 & 0xFF,
  26027. h4 & 0xFF,
  26028. h5 >> 24 & 0xFF,
  26029. h5 >> 16 & 0xFF,
  26030. h5 >> 8 & 0xFF,
  26031. h5 & 0xFF,
  26032. h6 >> 24 & 0xFF,
  26033. h6 >> 16 & 0xFF,
  26034. h6 >> 8 & 0xFF,
  26035. h6 & 0xFF,
  26036. h7 >> 24 & 0xFF,
  26037. h7 >> 16 & 0xFF,
  26038. h7 >> 8 & 0xFF,
  26039. h7 & 0xFF
  26040. ]);
  26041. }
  26042. return hash;
  26043. }();
  26044. var calculateSHA512 = function calculateSHA512Closure() {
  26045. function ch(result, x, y, z, tmp) {
  26046. result.assign(x);
  26047. result.and(y);
  26048. tmp.assign(x);
  26049. tmp.not();
  26050. tmp.and(z);
  26051. result.xor(tmp);
  26052. }
  26053. function maj(result, x, y, z, tmp) {
  26054. result.assign(x);
  26055. result.and(y);
  26056. tmp.assign(x);
  26057. tmp.and(z);
  26058. result.xor(tmp);
  26059. tmp.assign(y);
  26060. tmp.and(z);
  26061. result.xor(tmp);
  26062. }
  26063. function sigma(result, x, tmp) {
  26064. result.assign(x);
  26065. result.rotateRight(28);
  26066. tmp.assign(x);
  26067. tmp.rotateRight(34);
  26068. result.xor(tmp);
  26069. tmp.assign(x);
  26070. tmp.rotateRight(39);
  26071. result.xor(tmp);
  26072. }
  26073. function sigmaPrime(result, x, tmp) {
  26074. result.assign(x);
  26075. result.rotateRight(14);
  26076. tmp.assign(x);
  26077. tmp.rotateRight(18);
  26078. result.xor(tmp);
  26079. tmp.assign(x);
  26080. tmp.rotateRight(41);
  26081. result.xor(tmp);
  26082. }
  26083. function littleSigma(result, x, tmp) {
  26084. result.assign(x);
  26085. result.rotateRight(1);
  26086. tmp.assign(x);
  26087. tmp.rotateRight(8);
  26088. result.xor(tmp);
  26089. tmp.assign(x);
  26090. tmp.shiftRight(7);
  26091. result.xor(tmp);
  26092. }
  26093. function littleSigmaPrime(result, x, tmp) {
  26094. result.assign(x);
  26095. result.rotateRight(19);
  26096. tmp.assign(x);
  26097. tmp.rotateRight(61);
  26098. result.xor(tmp);
  26099. tmp.assign(x);
  26100. tmp.shiftRight(6);
  26101. result.xor(tmp);
  26102. }
  26103. var k = [
  26104. new Word64(0x428a2f98, 0xd728ae22),
  26105. new Word64(0x71374491, 0x23ef65cd),
  26106. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26107. new Word64(0xe9b5dba5, 0x8189dbbc),
  26108. new Word64(0x3956c25b, 0xf348b538),
  26109. new Word64(0x59f111f1, 0xb605d019),
  26110. new Word64(0x923f82a4, 0xaf194f9b),
  26111. new Word64(0xab1c5ed5, 0xda6d8118),
  26112. new Word64(0xd807aa98, 0xa3030242),
  26113. new Word64(0x12835b01, 0x45706fbe),
  26114. new Word64(0x243185be, 0x4ee4b28c),
  26115. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26116. new Word64(0x72be5d74, 0xf27b896f),
  26117. new Word64(0x80deb1fe, 0x3b1696b1),
  26118. new Word64(0x9bdc06a7, 0x25c71235),
  26119. new Word64(0xc19bf174, 0xcf692694),
  26120. new Word64(0xe49b69c1, 0x9ef14ad2),
  26121. new Word64(0xefbe4786, 0x384f25e3),
  26122. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26123. new Word64(0x240ca1cc, 0x77ac9c65),
  26124. new Word64(0x2de92c6f, 0x592b0275),
  26125. new Word64(0x4a7484aa, 0x6ea6e483),
  26126. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26127. new Word64(0x76f988da, 0x831153b5),
  26128. new Word64(0x983e5152, 0xee66dfab),
  26129. new Word64(0xa831c66d, 0x2db43210),
  26130. new Word64(0xb00327c8, 0x98fb213f),
  26131. new Word64(0xbf597fc7, 0xbeef0ee4),
  26132. new Word64(0xc6e00bf3, 0x3da88fc2),
  26133. new Word64(0xd5a79147, 0x930aa725),
  26134. new Word64(0x06ca6351, 0xe003826f),
  26135. new Word64(0x14292967, 0x0a0e6e70),
  26136. new Word64(0x27b70a85, 0x46d22ffc),
  26137. new Word64(0x2e1b2138, 0x5c26c926),
  26138. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26139. new Word64(0x53380d13, 0x9d95b3df),
  26140. new Word64(0x650a7354, 0x8baf63de),
  26141. new Word64(0x766a0abb, 0x3c77b2a8),
  26142. new Word64(0x81c2c92e, 0x47edaee6),
  26143. new Word64(0x92722c85, 0x1482353b),
  26144. new Word64(0xa2bfe8a1, 0x4cf10364),
  26145. new Word64(0xa81a664b, 0xbc423001),
  26146. new Word64(0xc24b8b70, 0xd0f89791),
  26147. new Word64(0xc76c51a3, 0x0654be30),
  26148. new Word64(0xd192e819, 0xd6ef5218),
  26149. new Word64(0xd6990624, 0x5565a910),
  26150. new Word64(0xf40e3585, 0x5771202a),
  26151. new Word64(0x106aa070, 0x32bbd1b8),
  26152. new Word64(0x19a4c116, 0xb8d2d0c8),
  26153. new Word64(0x1e376c08, 0x5141ab53),
  26154. new Word64(0x2748774c, 0xdf8eeb99),
  26155. new Word64(0x34b0bcb5, 0xe19b48a8),
  26156. new Word64(0x391c0cb3, 0xc5c95a63),
  26157. new Word64(0x4ed8aa4a, 0xe3418acb),
  26158. new Word64(0x5b9cca4f, 0x7763e373),
  26159. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26160. new Word64(0x748f82ee, 0x5defb2fc),
  26161. new Word64(0x78a5636f, 0x43172f60),
  26162. new Word64(0x84c87814, 0xa1f0ab72),
  26163. new Word64(0x8cc70208, 0x1a6439ec),
  26164. new Word64(0x90befffa, 0x23631e28),
  26165. new Word64(0xa4506ceb, 0xde82bde9),
  26166. new Word64(0xbef9a3f7, 0xb2c67915),
  26167. new Word64(0xc67178f2, 0xe372532b),
  26168. new Word64(0xca273ece, 0xea26619c),
  26169. new Word64(0xd186b8c7, 0x21c0c207),
  26170. new Word64(0xeada7dd6, 0xcde0eb1e),
  26171. new Word64(0xf57d4f7f, 0xee6ed178),
  26172. new Word64(0x06f067aa, 0x72176fba),
  26173. new Word64(0x0a637dc5, 0xa2c898a6),
  26174. new Word64(0x113f9804, 0xbef90dae),
  26175. new Word64(0x1b710b35, 0x131c471b),
  26176. new Word64(0x28db77f5, 0x23047d84),
  26177. new Word64(0x32caab7b, 0x40c72493),
  26178. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26179. new Word64(0x431d67c4, 0x9c100d4c),
  26180. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26181. new Word64(0x597f299c, 0xfc657e2a),
  26182. new Word64(0x5fcb6fab, 0x3ad6faec),
  26183. new Word64(0x6c44198c, 0x4a475817)
  26184. ];
  26185. function hash(data, offset, length, mode384) {
  26186. mode384 = !!mode384;
  26187. var h0, h1, h2, h3, h4, h5, h6, h7;
  26188. if (!mode384) {
  26189. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26190. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26191. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26192. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26193. h4 = new Word64(0x510e527f, 0xade682d1);
  26194. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26195. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26196. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26197. } else {
  26198. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26199. h1 = new Word64(0x629a292a, 0x367cd507);
  26200. h2 = new Word64(0x9159015a, 0x3070dd17);
  26201. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26202. h4 = new Word64(0x67332667, 0xffc00b31);
  26203. h5 = new Word64(0x8eb44a87, 0x68581511);
  26204. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26205. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26206. }
  26207. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26208. var padded = new Uint8Array(paddedLength);
  26209. var i, j, n;
  26210. for (i = 0; i < length; ++i) {
  26211. padded[i] = data[offset++];
  26212. }
  26213. padded[i++] = 0x80;
  26214. n = paddedLength - 16;
  26215. while (i < n) {
  26216. padded[i++] = 0;
  26217. }
  26218. padded[i++] = 0;
  26219. padded[i++] = 0;
  26220. padded[i++] = 0;
  26221. padded[i++] = 0;
  26222. padded[i++] = 0;
  26223. padded[i++] = 0;
  26224. padded[i++] = 0;
  26225. padded[i++] = 0;
  26226. padded[i++] = 0;
  26227. padded[i++] = 0;
  26228. padded[i++] = 0;
  26229. padded[i++] = length >>> 29 & 0xFF;
  26230. padded[i++] = length >> 21 & 0xFF;
  26231. padded[i++] = length >> 13 & 0xFF;
  26232. padded[i++] = length >> 5 & 0xFF;
  26233. padded[i++] = length << 3 & 0xFF;
  26234. var w = new Array(80);
  26235. for (i = 0; i < 80; i++) {
  26236. w[i] = new Word64(0, 0);
  26237. }
  26238. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26239. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26240. var g = new Word64(0, 0), h = new Word64(0, 0);
  26241. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26242. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26243. for (i = 0; i < paddedLength;) {
  26244. for (j = 0; j < 16; ++j) {
  26245. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26246. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26247. i += 8;
  26248. }
  26249. for (j = 16; j < 80; ++j) {
  26250. tmp3 = w[j];
  26251. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26252. tmp3.add(w[j - 7]);
  26253. littleSigma(tmp1, w[j - 15], tmp2);
  26254. tmp3.add(tmp1);
  26255. tmp3.add(w[j - 16]);
  26256. }
  26257. a.assign(h0);
  26258. b.assign(h1);
  26259. c.assign(h2);
  26260. d.assign(h3);
  26261. e.assign(h4);
  26262. f.assign(h5);
  26263. g.assign(h6);
  26264. h.assign(h7);
  26265. for (j = 0; j < 80; ++j) {
  26266. t1.assign(h);
  26267. sigmaPrime(tmp1, e, tmp2);
  26268. t1.add(tmp1);
  26269. ch(tmp1, e, f, g, tmp2);
  26270. t1.add(tmp1);
  26271. t1.add(k[j]);
  26272. t1.add(w[j]);
  26273. sigma(t2, a, tmp2);
  26274. maj(tmp1, a, b, c, tmp2);
  26275. t2.add(tmp1);
  26276. tmp3 = h;
  26277. h = g;
  26278. g = f;
  26279. f = e;
  26280. d.add(t1);
  26281. e = d;
  26282. d = c;
  26283. c = b;
  26284. b = a;
  26285. tmp3.assign(t1);
  26286. tmp3.add(t2);
  26287. a = tmp3;
  26288. }
  26289. h0.add(a);
  26290. h1.add(b);
  26291. h2.add(c);
  26292. h3.add(d);
  26293. h4.add(e);
  26294. h5.add(f);
  26295. h6.add(g);
  26296. h7.add(h);
  26297. }
  26298. var result;
  26299. if (!mode384) {
  26300. result = new Uint8Array(64);
  26301. h0.copyTo(result, 0);
  26302. h1.copyTo(result, 8);
  26303. h2.copyTo(result, 16);
  26304. h3.copyTo(result, 24);
  26305. h4.copyTo(result, 32);
  26306. h5.copyTo(result, 40);
  26307. h6.copyTo(result, 48);
  26308. h7.copyTo(result, 56);
  26309. } else {
  26310. result = new Uint8Array(48);
  26311. h0.copyTo(result, 0);
  26312. h1.copyTo(result, 8);
  26313. h2.copyTo(result, 16);
  26314. h3.copyTo(result, 24);
  26315. h4.copyTo(result, 32);
  26316. h5.copyTo(result, 40);
  26317. }
  26318. return result;
  26319. }
  26320. return hash;
  26321. }();
  26322. var calculateSHA384 = function calculateSHA384Closure() {
  26323. function hash(data, offset, length) {
  26324. return calculateSHA512(data, offset, length, true);
  26325. }
  26326. return hash;
  26327. }();
  26328. var NullCipher = function NullCipherClosure() {
  26329. function NullCipher() {
  26330. }
  26331. NullCipher.prototype = {
  26332. decryptBlock: function NullCipher_decryptBlock(data) {
  26333. return data;
  26334. }
  26335. };
  26336. return NullCipher;
  26337. }();
  26338. var AES128Cipher = function AES128CipherClosure() {
  26339. var rcon = new Uint8Array([
  26340. 0x8d,
  26341. 0x01,
  26342. 0x02,
  26343. 0x04,
  26344. 0x08,
  26345. 0x10,
  26346. 0x20,
  26347. 0x40,
  26348. 0x80,
  26349. 0x1b,
  26350. 0x36,
  26351. 0x6c,
  26352. 0xd8,
  26353. 0xab,
  26354. 0x4d,
  26355. 0x9a,
  26356. 0x2f,
  26357. 0x5e,
  26358. 0xbc,
  26359. 0x63,
  26360. 0xc6,
  26361. 0x97,
  26362. 0x35,
  26363. 0x6a,
  26364. 0xd4,
  26365. 0xb3,
  26366. 0x7d,
  26367. 0xfa,
  26368. 0xef,
  26369. 0xc5,
  26370. 0x91,
  26371. 0x39,
  26372. 0x72,
  26373. 0xe4,
  26374. 0xd3,
  26375. 0xbd,
  26376. 0x61,
  26377. 0xc2,
  26378. 0x9f,
  26379. 0x25,
  26380. 0x4a,
  26381. 0x94,
  26382. 0x33,
  26383. 0x66,
  26384. 0xcc,
  26385. 0x83,
  26386. 0x1d,
  26387. 0x3a,
  26388. 0x74,
  26389. 0xe8,
  26390. 0xcb,
  26391. 0x8d,
  26392. 0x01,
  26393. 0x02,
  26394. 0x04,
  26395. 0x08,
  26396. 0x10,
  26397. 0x20,
  26398. 0x40,
  26399. 0x80,
  26400. 0x1b,
  26401. 0x36,
  26402. 0x6c,
  26403. 0xd8,
  26404. 0xab,
  26405. 0x4d,
  26406. 0x9a,
  26407. 0x2f,
  26408. 0x5e,
  26409. 0xbc,
  26410. 0x63,
  26411. 0xc6,
  26412. 0x97,
  26413. 0x35,
  26414. 0x6a,
  26415. 0xd4,
  26416. 0xb3,
  26417. 0x7d,
  26418. 0xfa,
  26419. 0xef,
  26420. 0xc5,
  26421. 0x91,
  26422. 0x39,
  26423. 0x72,
  26424. 0xe4,
  26425. 0xd3,
  26426. 0xbd,
  26427. 0x61,
  26428. 0xc2,
  26429. 0x9f,
  26430. 0x25,
  26431. 0x4a,
  26432. 0x94,
  26433. 0x33,
  26434. 0x66,
  26435. 0xcc,
  26436. 0x83,
  26437. 0x1d,
  26438. 0x3a,
  26439. 0x74,
  26440. 0xe8,
  26441. 0xcb,
  26442. 0x8d,
  26443. 0x01,
  26444. 0x02,
  26445. 0x04,
  26446. 0x08,
  26447. 0x10,
  26448. 0x20,
  26449. 0x40,
  26450. 0x80,
  26451. 0x1b,
  26452. 0x36,
  26453. 0x6c,
  26454. 0xd8,
  26455. 0xab,
  26456. 0x4d,
  26457. 0x9a,
  26458. 0x2f,
  26459. 0x5e,
  26460. 0xbc,
  26461. 0x63,
  26462. 0xc6,
  26463. 0x97,
  26464. 0x35,
  26465. 0x6a,
  26466. 0xd4,
  26467. 0xb3,
  26468. 0x7d,
  26469. 0xfa,
  26470. 0xef,
  26471. 0xc5,
  26472. 0x91,
  26473. 0x39,
  26474. 0x72,
  26475. 0xe4,
  26476. 0xd3,
  26477. 0xbd,
  26478. 0x61,
  26479. 0xc2,
  26480. 0x9f,
  26481. 0x25,
  26482. 0x4a,
  26483. 0x94,
  26484. 0x33,
  26485. 0x66,
  26486. 0xcc,
  26487. 0x83,
  26488. 0x1d,
  26489. 0x3a,
  26490. 0x74,
  26491. 0xe8,
  26492. 0xcb,
  26493. 0x8d,
  26494. 0x01,
  26495. 0x02,
  26496. 0x04,
  26497. 0x08,
  26498. 0x10,
  26499. 0x20,
  26500. 0x40,
  26501. 0x80,
  26502. 0x1b,
  26503. 0x36,
  26504. 0x6c,
  26505. 0xd8,
  26506. 0xab,
  26507. 0x4d,
  26508. 0x9a,
  26509. 0x2f,
  26510. 0x5e,
  26511. 0xbc,
  26512. 0x63,
  26513. 0xc6,
  26514. 0x97,
  26515. 0x35,
  26516. 0x6a,
  26517. 0xd4,
  26518. 0xb3,
  26519. 0x7d,
  26520. 0xfa,
  26521. 0xef,
  26522. 0xc5,
  26523. 0x91,
  26524. 0x39,
  26525. 0x72,
  26526. 0xe4,
  26527. 0xd3,
  26528. 0xbd,
  26529. 0x61,
  26530. 0xc2,
  26531. 0x9f,
  26532. 0x25,
  26533. 0x4a,
  26534. 0x94,
  26535. 0x33,
  26536. 0x66,
  26537. 0xcc,
  26538. 0x83,
  26539. 0x1d,
  26540. 0x3a,
  26541. 0x74,
  26542. 0xe8,
  26543. 0xcb,
  26544. 0x8d,
  26545. 0x01,
  26546. 0x02,
  26547. 0x04,
  26548. 0x08,
  26549. 0x10,
  26550. 0x20,
  26551. 0x40,
  26552. 0x80,
  26553. 0x1b,
  26554. 0x36,
  26555. 0x6c,
  26556. 0xd8,
  26557. 0xab,
  26558. 0x4d,
  26559. 0x9a,
  26560. 0x2f,
  26561. 0x5e,
  26562. 0xbc,
  26563. 0x63,
  26564. 0xc6,
  26565. 0x97,
  26566. 0x35,
  26567. 0x6a,
  26568. 0xd4,
  26569. 0xb3,
  26570. 0x7d,
  26571. 0xfa,
  26572. 0xef,
  26573. 0xc5,
  26574. 0x91,
  26575. 0x39,
  26576. 0x72,
  26577. 0xe4,
  26578. 0xd3,
  26579. 0xbd,
  26580. 0x61,
  26581. 0xc2,
  26582. 0x9f,
  26583. 0x25,
  26584. 0x4a,
  26585. 0x94,
  26586. 0x33,
  26587. 0x66,
  26588. 0xcc,
  26589. 0x83,
  26590. 0x1d,
  26591. 0x3a,
  26592. 0x74,
  26593. 0xe8,
  26594. 0xcb,
  26595. 0x8d
  26596. ]);
  26597. var s = new Uint8Array([
  26598. 0x63,
  26599. 0x7c,
  26600. 0x77,
  26601. 0x7b,
  26602. 0xf2,
  26603. 0x6b,
  26604. 0x6f,
  26605. 0xc5,
  26606. 0x30,
  26607. 0x01,
  26608. 0x67,
  26609. 0x2b,
  26610. 0xfe,
  26611. 0xd7,
  26612. 0xab,
  26613. 0x76,
  26614. 0xca,
  26615. 0x82,
  26616. 0xc9,
  26617. 0x7d,
  26618. 0xfa,
  26619. 0x59,
  26620. 0x47,
  26621. 0xf0,
  26622. 0xad,
  26623. 0xd4,
  26624. 0xa2,
  26625. 0xaf,
  26626. 0x9c,
  26627. 0xa4,
  26628. 0x72,
  26629. 0xc0,
  26630. 0xb7,
  26631. 0xfd,
  26632. 0x93,
  26633. 0x26,
  26634. 0x36,
  26635. 0x3f,
  26636. 0xf7,
  26637. 0xcc,
  26638. 0x34,
  26639. 0xa5,
  26640. 0xe5,
  26641. 0xf1,
  26642. 0x71,
  26643. 0xd8,
  26644. 0x31,
  26645. 0x15,
  26646. 0x04,
  26647. 0xc7,
  26648. 0x23,
  26649. 0xc3,
  26650. 0x18,
  26651. 0x96,
  26652. 0x05,
  26653. 0x9a,
  26654. 0x07,
  26655. 0x12,
  26656. 0x80,
  26657. 0xe2,
  26658. 0xeb,
  26659. 0x27,
  26660. 0xb2,
  26661. 0x75,
  26662. 0x09,
  26663. 0x83,
  26664. 0x2c,
  26665. 0x1a,
  26666. 0x1b,
  26667. 0x6e,
  26668. 0x5a,
  26669. 0xa0,
  26670. 0x52,
  26671. 0x3b,
  26672. 0xd6,
  26673. 0xb3,
  26674. 0x29,
  26675. 0xe3,
  26676. 0x2f,
  26677. 0x84,
  26678. 0x53,
  26679. 0xd1,
  26680. 0x00,
  26681. 0xed,
  26682. 0x20,
  26683. 0xfc,
  26684. 0xb1,
  26685. 0x5b,
  26686. 0x6a,
  26687. 0xcb,
  26688. 0xbe,
  26689. 0x39,
  26690. 0x4a,
  26691. 0x4c,
  26692. 0x58,
  26693. 0xcf,
  26694. 0xd0,
  26695. 0xef,
  26696. 0xaa,
  26697. 0xfb,
  26698. 0x43,
  26699. 0x4d,
  26700. 0x33,
  26701. 0x85,
  26702. 0x45,
  26703. 0xf9,
  26704. 0x02,
  26705. 0x7f,
  26706. 0x50,
  26707. 0x3c,
  26708. 0x9f,
  26709. 0xa8,
  26710. 0x51,
  26711. 0xa3,
  26712. 0x40,
  26713. 0x8f,
  26714. 0x92,
  26715. 0x9d,
  26716. 0x38,
  26717. 0xf5,
  26718. 0xbc,
  26719. 0xb6,
  26720. 0xda,
  26721. 0x21,
  26722. 0x10,
  26723. 0xff,
  26724. 0xf3,
  26725. 0xd2,
  26726. 0xcd,
  26727. 0x0c,
  26728. 0x13,
  26729. 0xec,
  26730. 0x5f,
  26731. 0x97,
  26732. 0x44,
  26733. 0x17,
  26734. 0xc4,
  26735. 0xa7,
  26736. 0x7e,
  26737. 0x3d,
  26738. 0x64,
  26739. 0x5d,
  26740. 0x19,
  26741. 0x73,
  26742. 0x60,
  26743. 0x81,
  26744. 0x4f,
  26745. 0xdc,
  26746. 0x22,
  26747. 0x2a,
  26748. 0x90,
  26749. 0x88,
  26750. 0x46,
  26751. 0xee,
  26752. 0xb8,
  26753. 0x14,
  26754. 0xde,
  26755. 0x5e,
  26756. 0x0b,
  26757. 0xdb,
  26758. 0xe0,
  26759. 0x32,
  26760. 0x3a,
  26761. 0x0a,
  26762. 0x49,
  26763. 0x06,
  26764. 0x24,
  26765. 0x5c,
  26766. 0xc2,
  26767. 0xd3,
  26768. 0xac,
  26769. 0x62,
  26770. 0x91,
  26771. 0x95,
  26772. 0xe4,
  26773. 0x79,
  26774. 0xe7,
  26775. 0xc8,
  26776. 0x37,
  26777. 0x6d,
  26778. 0x8d,
  26779. 0xd5,
  26780. 0x4e,
  26781. 0xa9,
  26782. 0x6c,
  26783. 0x56,
  26784. 0xf4,
  26785. 0xea,
  26786. 0x65,
  26787. 0x7a,
  26788. 0xae,
  26789. 0x08,
  26790. 0xba,
  26791. 0x78,
  26792. 0x25,
  26793. 0x2e,
  26794. 0x1c,
  26795. 0xa6,
  26796. 0xb4,
  26797. 0xc6,
  26798. 0xe8,
  26799. 0xdd,
  26800. 0x74,
  26801. 0x1f,
  26802. 0x4b,
  26803. 0xbd,
  26804. 0x8b,
  26805. 0x8a,
  26806. 0x70,
  26807. 0x3e,
  26808. 0xb5,
  26809. 0x66,
  26810. 0x48,
  26811. 0x03,
  26812. 0xf6,
  26813. 0x0e,
  26814. 0x61,
  26815. 0x35,
  26816. 0x57,
  26817. 0xb9,
  26818. 0x86,
  26819. 0xc1,
  26820. 0x1d,
  26821. 0x9e,
  26822. 0xe1,
  26823. 0xf8,
  26824. 0x98,
  26825. 0x11,
  26826. 0x69,
  26827. 0xd9,
  26828. 0x8e,
  26829. 0x94,
  26830. 0x9b,
  26831. 0x1e,
  26832. 0x87,
  26833. 0xe9,
  26834. 0xce,
  26835. 0x55,
  26836. 0x28,
  26837. 0xdf,
  26838. 0x8c,
  26839. 0xa1,
  26840. 0x89,
  26841. 0x0d,
  26842. 0xbf,
  26843. 0xe6,
  26844. 0x42,
  26845. 0x68,
  26846. 0x41,
  26847. 0x99,
  26848. 0x2d,
  26849. 0x0f,
  26850. 0xb0,
  26851. 0x54,
  26852. 0xbb,
  26853. 0x16
  26854. ]);
  26855. var inv_s = new Uint8Array([
  26856. 0x52,
  26857. 0x09,
  26858. 0x6a,
  26859. 0xd5,
  26860. 0x30,
  26861. 0x36,
  26862. 0xa5,
  26863. 0x38,
  26864. 0xbf,
  26865. 0x40,
  26866. 0xa3,
  26867. 0x9e,
  26868. 0x81,
  26869. 0xf3,
  26870. 0xd7,
  26871. 0xfb,
  26872. 0x7c,
  26873. 0xe3,
  26874. 0x39,
  26875. 0x82,
  26876. 0x9b,
  26877. 0x2f,
  26878. 0xff,
  26879. 0x87,
  26880. 0x34,
  26881. 0x8e,
  26882. 0x43,
  26883. 0x44,
  26884. 0xc4,
  26885. 0xde,
  26886. 0xe9,
  26887. 0xcb,
  26888. 0x54,
  26889. 0x7b,
  26890. 0x94,
  26891. 0x32,
  26892. 0xa6,
  26893. 0xc2,
  26894. 0x23,
  26895. 0x3d,
  26896. 0xee,
  26897. 0x4c,
  26898. 0x95,
  26899. 0x0b,
  26900. 0x42,
  26901. 0xfa,
  26902. 0xc3,
  26903. 0x4e,
  26904. 0x08,
  26905. 0x2e,
  26906. 0xa1,
  26907. 0x66,
  26908. 0x28,
  26909. 0xd9,
  26910. 0x24,
  26911. 0xb2,
  26912. 0x76,
  26913. 0x5b,
  26914. 0xa2,
  26915. 0x49,
  26916. 0x6d,
  26917. 0x8b,
  26918. 0xd1,
  26919. 0x25,
  26920. 0x72,
  26921. 0xf8,
  26922. 0xf6,
  26923. 0x64,
  26924. 0x86,
  26925. 0x68,
  26926. 0x98,
  26927. 0x16,
  26928. 0xd4,
  26929. 0xa4,
  26930. 0x5c,
  26931. 0xcc,
  26932. 0x5d,
  26933. 0x65,
  26934. 0xb6,
  26935. 0x92,
  26936. 0x6c,
  26937. 0x70,
  26938. 0x48,
  26939. 0x50,
  26940. 0xfd,
  26941. 0xed,
  26942. 0xb9,
  26943. 0xda,
  26944. 0x5e,
  26945. 0x15,
  26946. 0x46,
  26947. 0x57,
  26948. 0xa7,
  26949. 0x8d,
  26950. 0x9d,
  26951. 0x84,
  26952. 0x90,
  26953. 0xd8,
  26954. 0xab,
  26955. 0x00,
  26956. 0x8c,
  26957. 0xbc,
  26958. 0xd3,
  26959. 0x0a,
  26960. 0xf7,
  26961. 0xe4,
  26962. 0x58,
  26963. 0x05,
  26964. 0xb8,
  26965. 0xb3,
  26966. 0x45,
  26967. 0x06,
  26968. 0xd0,
  26969. 0x2c,
  26970. 0x1e,
  26971. 0x8f,
  26972. 0xca,
  26973. 0x3f,
  26974. 0x0f,
  26975. 0x02,
  26976. 0xc1,
  26977. 0xaf,
  26978. 0xbd,
  26979. 0x03,
  26980. 0x01,
  26981. 0x13,
  26982. 0x8a,
  26983. 0x6b,
  26984. 0x3a,
  26985. 0x91,
  26986. 0x11,
  26987. 0x41,
  26988. 0x4f,
  26989. 0x67,
  26990. 0xdc,
  26991. 0xea,
  26992. 0x97,
  26993. 0xf2,
  26994. 0xcf,
  26995. 0xce,
  26996. 0xf0,
  26997. 0xb4,
  26998. 0xe6,
  26999. 0x73,
  27000. 0x96,
  27001. 0xac,
  27002. 0x74,
  27003. 0x22,
  27004. 0xe7,
  27005. 0xad,
  27006. 0x35,
  27007. 0x85,
  27008. 0xe2,
  27009. 0xf9,
  27010. 0x37,
  27011. 0xe8,
  27012. 0x1c,
  27013. 0x75,
  27014. 0xdf,
  27015. 0x6e,
  27016. 0x47,
  27017. 0xf1,
  27018. 0x1a,
  27019. 0x71,
  27020. 0x1d,
  27021. 0x29,
  27022. 0xc5,
  27023. 0x89,
  27024. 0x6f,
  27025. 0xb7,
  27026. 0x62,
  27027. 0x0e,
  27028. 0xaa,
  27029. 0x18,
  27030. 0xbe,
  27031. 0x1b,
  27032. 0xfc,
  27033. 0x56,
  27034. 0x3e,
  27035. 0x4b,
  27036. 0xc6,
  27037. 0xd2,
  27038. 0x79,
  27039. 0x20,
  27040. 0x9a,
  27041. 0xdb,
  27042. 0xc0,
  27043. 0xfe,
  27044. 0x78,
  27045. 0xcd,
  27046. 0x5a,
  27047. 0xf4,
  27048. 0x1f,
  27049. 0xdd,
  27050. 0xa8,
  27051. 0x33,
  27052. 0x88,
  27053. 0x07,
  27054. 0xc7,
  27055. 0x31,
  27056. 0xb1,
  27057. 0x12,
  27058. 0x10,
  27059. 0x59,
  27060. 0x27,
  27061. 0x80,
  27062. 0xec,
  27063. 0x5f,
  27064. 0x60,
  27065. 0x51,
  27066. 0x7f,
  27067. 0xa9,
  27068. 0x19,
  27069. 0xb5,
  27070. 0x4a,
  27071. 0x0d,
  27072. 0x2d,
  27073. 0xe5,
  27074. 0x7a,
  27075. 0x9f,
  27076. 0x93,
  27077. 0xc9,
  27078. 0x9c,
  27079. 0xef,
  27080. 0xa0,
  27081. 0xe0,
  27082. 0x3b,
  27083. 0x4d,
  27084. 0xae,
  27085. 0x2a,
  27086. 0xf5,
  27087. 0xb0,
  27088. 0xc8,
  27089. 0xeb,
  27090. 0xbb,
  27091. 0x3c,
  27092. 0x83,
  27093. 0x53,
  27094. 0x99,
  27095. 0x61,
  27096. 0x17,
  27097. 0x2b,
  27098. 0x04,
  27099. 0x7e,
  27100. 0xba,
  27101. 0x77,
  27102. 0xd6,
  27103. 0x26,
  27104. 0xe1,
  27105. 0x69,
  27106. 0x14,
  27107. 0x63,
  27108. 0x55,
  27109. 0x21,
  27110. 0x0c,
  27111. 0x7d
  27112. ]);
  27113. var mixCol = new Uint8Array(256);
  27114. for (var i = 0; i < 256; i++) {
  27115. if (i < 128) {
  27116. mixCol[i] = i << 1;
  27117. } else {
  27118. mixCol[i] = i << 1 ^ 0x1b;
  27119. }
  27120. }
  27121. var mix = new Uint32Array([
  27122. 0x00000000,
  27123. 0x0e090d0b,
  27124. 0x1c121a16,
  27125. 0x121b171d,
  27126. 0x3824342c,
  27127. 0x362d3927,
  27128. 0x24362e3a,
  27129. 0x2a3f2331,
  27130. 0x70486858,
  27131. 0x7e416553,
  27132. 0x6c5a724e,
  27133. 0x62537f45,
  27134. 0x486c5c74,
  27135. 0x4665517f,
  27136. 0x547e4662,
  27137. 0x5a774b69,
  27138. 0xe090d0b0,
  27139. 0xee99ddbb,
  27140. 0xfc82caa6,
  27141. 0xf28bc7ad,
  27142. 0xd8b4e49c,
  27143. 0xd6bde997,
  27144. 0xc4a6fe8a,
  27145. 0xcaaff381,
  27146. 0x90d8b8e8,
  27147. 0x9ed1b5e3,
  27148. 0x8ccaa2fe,
  27149. 0x82c3aff5,
  27150. 0xa8fc8cc4,
  27151. 0xa6f581cf,
  27152. 0xb4ee96d2,
  27153. 0xbae79bd9,
  27154. 0xdb3bbb7b,
  27155. 0xd532b670,
  27156. 0xc729a16d,
  27157. 0xc920ac66,
  27158. 0xe31f8f57,
  27159. 0xed16825c,
  27160. 0xff0d9541,
  27161. 0xf104984a,
  27162. 0xab73d323,
  27163. 0xa57ade28,
  27164. 0xb761c935,
  27165. 0xb968c43e,
  27166. 0x9357e70f,
  27167. 0x9d5eea04,
  27168. 0x8f45fd19,
  27169. 0x814cf012,
  27170. 0x3bab6bcb,
  27171. 0x35a266c0,
  27172. 0x27b971dd,
  27173. 0x29b07cd6,
  27174. 0x038f5fe7,
  27175. 0x0d8652ec,
  27176. 0x1f9d45f1,
  27177. 0x119448fa,
  27178. 0x4be30393,
  27179. 0x45ea0e98,
  27180. 0x57f11985,
  27181. 0x59f8148e,
  27182. 0x73c737bf,
  27183. 0x7dce3ab4,
  27184. 0x6fd52da9,
  27185. 0x61dc20a2,
  27186. 0xad766df6,
  27187. 0xa37f60fd,
  27188. 0xb16477e0,
  27189. 0xbf6d7aeb,
  27190. 0x955259da,
  27191. 0x9b5b54d1,
  27192. 0x894043cc,
  27193. 0x87494ec7,
  27194. 0xdd3e05ae,
  27195. 0xd33708a5,
  27196. 0xc12c1fb8,
  27197. 0xcf2512b3,
  27198. 0xe51a3182,
  27199. 0xeb133c89,
  27200. 0xf9082b94,
  27201. 0xf701269f,
  27202. 0x4de6bd46,
  27203. 0x43efb04d,
  27204. 0x51f4a750,
  27205. 0x5ffdaa5b,
  27206. 0x75c2896a,
  27207. 0x7bcb8461,
  27208. 0x69d0937c,
  27209. 0x67d99e77,
  27210. 0x3daed51e,
  27211. 0x33a7d815,
  27212. 0x21bccf08,
  27213. 0x2fb5c203,
  27214. 0x058ae132,
  27215. 0x0b83ec39,
  27216. 0x1998fb24,
  27217. 0x1791f62f,
  27218. 0x764dd68d,
  27219. 0x7844db86,
  27220. 0x6a5fcc9b,
  27221. 0x6456c190,
  27222. 0x4e69e2a1,
  27223. 0x4060efaa,
  27224. 0x527bf8b7,
  27225. 0x5c72f5bc,
  27226. 0x0605bed5,
  27227. 0x080cb3de,
  27228. 0x1a17a4c3,
  27229. 0x141ea9c8,
  27230. 0x3e218af9,
  27231. 0x302887f2,
  27232. 0x223390ef,
  27233. 0x2c3a9de4,
  27234. 0x96dd063d,
  27235. 0x98d40b36,
  27236. 0x8acf1c2b,
  27237. 0x84c61120,
  27238. 0xaef93211,
  27239. 0xa0f03f1a,
  27240. 0xb2eb2807,
  27241. 0xbce2250c,
  27242. 0xe6956e65,
  27243. 0xe89c636e,
  27244. 0xfa877473,
  27245. 0xf48e7978,
  27246. 0xdeb15a49,
  27247. 0xd0b85742,
  27248. 0xc2a3405f,
  27249. 0xccaa4d54,
  27250. 0x41ecdaf7,
  27251. 0x4fe5d7fc,
  27252. 0x5dfec0e1,
  27253. 0x53f7cdea,
  27254. 0x79c8eedb,
  27255. 0x77c1e3d0,
  27256. 0x65daf4cd,
  27257. 0x6bd3f9c6,
  27258. 0x31a4b2af,
  27259. 0x3fadbfa4,
  27260. 0x2db6a8b9,
  27261. 0x23bfa5b2,
  27262. 0x09808683,
  27263. 0x07898b88,
  27264. 0x15929c95,
  27265. 0x1b9b919e,
  27266. 0xa17c0a47,
  27267. 0xaf75074c,
  27268. 0xbd6e1051,
  27269. 0xb3671d5a,
  27270. 0x99583e6b,
  27271. 0x97513360,
  27272. 0x854a247d,
  27273. 0x8b432976,
  27274. 0xd134621f,
  27275. 0xdf3d6f14,
  27276. 0xcd267809,
  27277. 0xc32f7502,
  27278. 0xe9105633,
  27279. 0xe7195b38,
  27280. 0xf5024c25,
  27281. 0xfb0b412e,
  27282. 0x9ad7618c,
  27283. 0x94de6c87,
  27284. 0x86c57b9a,
  27285. 0x88cc7691,
  27286. 0xa2f355a0,
  27287. 0xacfa58ab,
  27288. 0xbee14fb6,
  27289. 0xb0e842bd,
  27290. 0xea9f09d4,
  27291. 0xe49604df,
  27292. 0xf68d13c2,
  27293. 0xf8841ec9,
  27294. 0xd2bb3df8,
  27295. 0xdcb230f3,
  27296. 0xcea927ee,
  27297. 0xc0a02ae5,
  27298. 0x7a47b13c,
  27299. 0x744ebc37,
  27300. 0x6655ab2a,
  27301. 0x685ca621,
  27302. 0x42638510,
  27303. 0x4c6a881b,
  27304. 0x5e719f06,
  27305. 0x5078920d,
  27306. 0x0a0fd964,
  27307. 0x0406d46f,
  27308. 0x161dc372,
  27309. 0x1814ce79,
  27310. 0x322bed48,
  27311. 0x3c22e043,
  27312. 0x2e39f75e,
  27313. 0x2030fa55,
  27314. 0xec9ab701,
  27315. 0xe293ba0a,
  27316. 0xf088ad17,
  27317. 0xfe81a01c,
  27318. 0xd4be832d,
  27319. 0xdab78e26,
  27320. 0xc8ac993b,
  27321. 0xc6a59430,
  27322. 0x9cd2df59,
  27323. 0x92dbd252,
  27324. 0x80c0c54f,
  27325. 0x8ec9c844,
  27326. 0xa4f6eb75,
  27327. 0xaaffe67e,
  27328. 0xb8e4f163,
  27329. 0xb6edfc68,
  27330. 0x0c0a67b1,
  27331. 0x02036aba,
  27332. 0x10187da7,
  27333. 0x1e1170ac,
  27334. 0x342e539d,
  27335. 0x3a275e96,
  27336. 0x283c498b,
  27337. 0x26354480,
  27338. 0x7c420fe9,
  27339. 0x724b02e2,
  27340. 0x605015ff,
  27341. 0x6e5918f4,
  27342. 0x44663bc5,
  27343. 0x4a6f36ce,
  27344. 0x587421d3,
  27345. 0x567d2cd8,
  27346. 0x37a10c7a,
  27347. 0x39a80171,
  27348. 0x2bb3166c,
  27349. 0x25ba1b67,
  27350. 0x0f853856,
  27351. 0x018c355d,
  27352. 0x13972240,
  27353. 0x1d9e2f4b,
  27354. 0x47e96422,
  27355. 0x49e06929,
  27356. 0x5bfb7e34,
  27357. 0x55f2733f,
  27358. 0x7fcd500e,
  27359. 0x71c45d05,
  27360. 0x63df4a18,
  27361. 0x6dd64713,
  27362. 0xd731dcca,
  27363. 0xd938d1c1,
  27364. 0xcb23c6dc,
  27365. 0xc52acbd7,
  27366. 0xef15e8e6,
  27367. 0xe11ce5ed,
  27368. 0xf307f2f0,
  27369. 0xfd0efffb,
  27370. 0xa779b492,
  27371. 0xa970b999,
  27372. 0xbb6bae84,
  27373. 0xb562a38f,
  27374. 0x9f5d80be,
  27375. 0x91548db5,
  27376. 0x834f9aa8,
  27377. 0x8d4697a3
  27378. ]);
  27379. function expandKey128(cipherKey) {
  27380. var b = 176, result = new Uint8Array(b);
  27381. result.set(cipherKey);
  27382. for (var j = 16, i = 1; j < b; ++i) {
  27383. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27384. t1 = s[t1];
  27385. t2 = s[t2];
  27386. t3 = s[t3];
  27387. t4 = s[t4];
  27388. t1 = t1 ^ rcon[i];
  27389. for (var n = 0; n < 4; ++n) {
  27390. result[j] = t1 ^= result[j - 16];
  27391. j++;
  27392. result[j] = t2 ^= result[j - 16];
  27393. j++;
  27394. result[j] = t3 ^= result[j - 16];
  27395. j++;
  27396. result[j] = t4 ^= result[j - 16];
  27397. j++;
  27398. }
  27399. }
  27400. return result;
  27401. }
  27402. function decrypt128(input, key) {
  27403. var state = new Uint8Array(16);
  27404. state.set(input);
  27405. var i, j, k;
  27406. var t, u, v;
  27407. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27408. state[j] ^= key[k];
  27409. }
  27410. for (i = 9; i >= 1; --i) {
  27411. t = state[13];
  27412. state[13] = state[9];
  27413. state[9] = state[5];
  27414. state[5] = state[1];
  27415. state[1] = t;
  27416. t = state[14];
  27417. u = state[10];
  27418. state[14] = state[6];
  27419. state[10] = state[2];
  27420. state[6] = t;
  27421. state[2] = u;
  27422. t = state[15];
  27423. u = state[11];
  27424. v = state[7];
  27425. state[15] = state[3];
  27426. state[11] = t;
  27427. state[7] = u;
  27428. state[3] = v;
  27429. for (j = 0; j < 16; ++j) {
  27430. state[j] = inv_s[state[j]];
  27431. }
  27432. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27433. state[j] ^= key[k];
  27434. }
  27435. for (j = 0; j < 16; j += 4) {
  27436. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27437. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27438. state[j] = t >>> 24 & 0xFF;
  27439. state[j + 1] = t >> 16 & 0xFF;
  27440. state[j + 2] = t >> 8 & 0xFF;
  27441. state[j + 3] = t & 0xFF;
  27442. }
  27443. }
  27444. t = state[13];
  27445. state[13] = state[9];
  27446. state[9] = state[5];
  27447. state[5] = state[1];
  27448. state[1] = t;
  27449. t = state[14];
  27450. u = state[10];
  27451. state[14] = state[6];
  27452. state[10] = state[2];
  27453. state[6] = t;
  27454. state[2] = u;
  27455. t = state[15];
  27456. u = state[11];
  27457. v = state[7];
  27458. state[15] = state[3];
  27459. state[11] = t;
  27460. state[7] = u;
  27461. state[3] = v;
  27462. for (j = 0; j < 16; ++j) {
  27463. state[j] = inv_s[state[j]];
  27464. state[j] ^= key[j];
  27465. }
  27466. return state;
  27467. }
  27468. function encrypt128(input, key) {
  27469. var t, u, v, k;
  27470. var state = new Uint8Array(16);
  27471. state.set(input);
  27472. for (j = 0; j < 16; ++j) {
  27473. state[j] ^= key[j];
  27474. }
  27475. for (i = 1; i < 10; i++) {
  27476. for (j = 0; j < 16; ++j) {
  27477. state[j] = s[state[j]];
  27478. }
  27479. v = state[1];
  27480. state[1] = state[5];
  27481. state[5] = state[9];
  27482. state[9] = state[13];
  27483. state[13] = v;
  27484. v = state[2];
  27485. u = state[6];
  27486. state[2] = state[10];
  27487. state[6] = state[14];
  27488. state[10] = v;
  27489. state[14] = u;
  27490. v = state[3];
  27491. u = state[7];
  27492. t = state[11];
  27493. state[3] = state[15];
  27494. state[7] = v;
  27495. state[11] = u;
  27496. state[15] = t;
  27497. for (var j = 0; j < 16; j += 4) {
  27498. var s0 = state[j + 0], s1 = state[j + 1];
  27499. var s2 = state[j + 2], s3 = state[j + 3];
  27500. t = s0 ^ s1 ^ s2 ^ s3;
  27501. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27502. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27503. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27504. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27505. }
  27506. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27507. state[j] ^= key[k];
  27508. }
  27509. }
  27510. for (j = 0; j < 16; ++j) {
  27511. state[j] = s[state[j]];
  27512. }
  27513. v = state[1];
  27514. state[1] = state[5];
  27515. state[5] = state[9];
  27516. state[9] = state[13];
  27517. state[13] = v;
  27518. v = state[2];
  27519. u = state[6];
  27520. state[2] = state[10];
  27521. state[6] = state[14];
  27522. state[10] = v;
  27523. state[14] = u;
  27524. v = state[3];
  27525. u = state[7];
  27526. t = state[11];
  27527. state[3] = state[15];
  27528. state[7] = v;
  27529. state[11] = u;
  27530. state[15] = t;
  27531. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27532. state[j] ^= key[k];
  27533. }
  27534. return state;
  27535. }
  27536. function AES128Cipher(key) {
  27537. this.key = expandKey128(key);
  27538. this.buffer = new Uint8Array(16);
  27539. this.bufferPosition = 0;
  27540. }
  27541. function decryptBlock2(data, finalize) {
  27542. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27543. for (i = 0; i < sourceLength; ++i) {
  27544. buffer[bufferLength] = data[i];
  27545. ++bufferLength;
  27546. if (bufferLength < 16) {
  27547. continue;
  27548. }
  27549. var plain = decrypt128(buffer, this.key);
  27550. for (j = 0; j < 16; ++j) {
  27551. plain[j] ^= iv[j];
  27552. }
  27553. iv = buffer;
  27554. result.push(plain);
  27555. buffer = new Uint8Array(16);
  27556. bufferLength = 0;
  27557. }
  27558. this.buffer = buffer;
  27559. this.bufferLength = bufferLength;
  27560. this.iv = iv;
  27561. if (result.length === 0) {
  27562. return new Uint8Array([]);
  27563. }
  27564. var outputLength = 16 * result.length;
  27565. if (finalize) {
  27566. var lastBlock = result[result.length - 1];
  27567. var psLen = lastBlock[15];
  27568. if (psLen <= 16) {
  27569. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27570. if (lastBlock[i] !== psLen) {
  27571. psLen = 0;
  27572. break;
  27573. }
  27574. }
  27575. outputLength -= psLen;
  27576. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27577. }
  27578. }
  27579. var output = new Uint8Array(outputLength);
  27580. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27581. output.set(result[i], j);
  27582. }
  27583. return output;
  27584. }
  27585. AES128Cipher.prototype = {
  27586. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  27587. var i, sourceLength = data.length;
  27588. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27589. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27590. buffer[bufferLength] = data[i];
  27591. }
  27592. if (bufferLength < 16) {
  27593. this.bufferLength = bufferLength;
  27594. return new Uint8Array([]);
  27595. }
  27596. this.iv = buffer;
  27597. this.buffer = new Uint8Array(16);
  27598. this.bufferLength = 0;
  27599. this.decryptBlock = decryptBlock2;
  27600. return this.decryptBlock(data.subarray(16), finalize);
  27601. },
  27602. encrypt: function AES128Cipher_encrypt(data, iv) {
  27603. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27604. if (!iv) {
  27605. iv = new Uint8Array(16);
  27606. }
  27607. for (i = 0; i < sourceLength; ++i) {
  27608. buffer[bufferLength] = data[i];
  27609. ++bufferLength;
  27610. if (bufferLength < 16) {
  27611. continue;
  27612. }
  27613. for (j = 0; j < 16; ++j) {
  27614. buffer[j] ^= iv[j];
  27615. }
  27616. var cipher = encrypt128(buffer, this.key);
  27617. iv = cipher;
  27618. result.push(cipher);
  27619. buffer = new Uint8Array(16);
  27620. bufferLength = 0;
  27621. }
  27622. this.buffer = buffer;
  27623. this.bufferLength = bufferLength;
  27624. this.iv = iv;
  27625. if (result.length === 0) {
  27626. return new Uint8Array([]);
  27627. }
  27628. var outputLength = 16 * result.length;
  27629. var output = new Uint8Array(outputLength);
  27630. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27631. output.set(result[i], j);
  27632. }
  27633. return output;
  27634. }
  27635. };
  27636. return AES128Cipher;
  27637. }();
  27638. var AES256Cipher = function AES256CipherClosure() {
  27639. var s = new Uint8Array([
  27640. 0x63,
  27641. 0x7c,
  27642. 0x77,
  27643. 0x7b,
  27644. 0xf2,
  27645. 0x6b,
  27646. 0x6f,
  27647. 0xc5,
  27648. 0x30,
  27649. 0x01,
  27650. 0x67,
  27651. 0x2b,
  27652. 0xfe,
  27653. 0xd7,
  27654. 0xab,
  27655. 0x76,
  27656. 0xca,
  27657. 0x82,
  27658. 0xc9,
  27659. 0x7d,
  27660. 0xfa,
  27661. 0x59,
  27662. 0x47,
  27663. 0xf0,
  27664. 0xad,
  27665. 0xd4,
  27666. 0xa2,
  27667. 0xaf,
  27668. 0x9c,
  27669. 0xa4,
  27670. 0x72,
  27671. 0xc0,
  27672. 0xb7,
  27673. 0xfd,
  27674. 0x93,
  27675. 0x26,
  27676. 0x36,
  27677. 0x3f,
  27678. 0xf7,
  27679. 0xcc,
  27680. 0x34,
  27681. 0xa5,
  27682. 0xe5,
  27683. 0xf1,
  27684. 0x71,
  27685. 0xd8,
  27686. 0x31,
  27687. 0x15,
  27688. 0x04,
  27689. 0xc7,
  27690. 0x23,
  27691. 0xc3,
  27692. 0x18,
  27693. 0x96,
  27694. 0x05,
  27695. 0x9a,
  27696. 0x07,
  27697. 0x12,
  27698. 0x80,
  27699. 0xe2,
  27700. 0xeb,
  27701. 0x27,
  27702. 0xb2,
  27703. 0x75,
  27704. 0x09,
  27705. 0x83,
  27706. 0x2c,
  27707. 0x1a,
  27708. 0x1b,
  27709. 0x6e,
  27710. 0x5a,
  27711. 0xa0,
  27712. 0x52,
  27713. 0x3b,
  27714. 0xd6,
  27715. 0xb3,
  27716. 0x29,
  27717. 0xe3,
  27718. 0x2f,
  27719. 0x84,
  27720. 0x53,
  27721. 0xd1,
  27722. 0x00,
  27723. 0xed,
  27724. 0x20,
  27725. 0xfc,
  27726. 0xb1,
  27727. 0x5b,
  27728. 0x6a,
  27729. 0xcb,
  27730. 0xbe,
  27731. 0x39,
  27732. 0x4a,
  27733. 0x4c,
  27734. 0x58,
  27735. 0xcf,
  27736. 0xd0,
  27737. 0xef,
  27738. 0xaa,
  27739. 0xfb,
  27740. 0x43,
  27741. 0x4d,
  27742. 0x33,
  27743. 0x85,
  27744. 0x45,
  27745. 0xf9,
  27746. 0x02,
  27747. 0x7f,
  27748. 0x50,
  27749. 0x3c,
  27750. 0x9f,
  27751. 0xa8,
  27752. 0x51,
  27753. 0xa3,
  27754. 0x40,
  27755. 0x8f,
  27756. 0x92,
  27757. 0x9d,
  27758. 0x38,
  27759. 0xf5,
  27760. 0xbc,
  27761. 0xb6,
  27762. 0xda,
  27763. 0x21,
  27764. 0x10,
  27765. 0xff,
  27766. 0xf3,
  27767. 0xd2,
  27768. 0xcd,
  27769. 0x0c,
  27770. 0x13,
  27771. 0xec,
  27772. 0x5f,
  27773. 0x97,
  27774. 0x44,
  27775. 0x17,
  27776. 0xc4,
  27777. 0xa7,
  27778. 0x7e,
  27779. 0x3d,
  27780. 0x64,
  27781. 0x5d,
  27782. 0x19,
  27783. 0x73,
  27784. 0x60,
  27785. 0x81,
  27786. 0x4f,
  27787. 0xdc,
  27788. 0x22,
  27789. 0x2a,
  27790. 0x90,
  27791. 0x88,
  27792. 0x46,
  27793. 0xee,
  27794. 0xb8,
  27795. 0x14,
  27796. 0xde,
  27797. 0x5e,
  27798. 0x0b,
  27799. 0xdb,
  27800. 0xe0,
  27801. 0x32,
  27802. 0x3a,
  27803. 0x0a,
  27804. 0x49,
  27805. 0x06,
  27806. 0x24,
  27807. 0x5c,
  27808. 0xc2,
  27809. 0xd3,
  27810. 0xac,
  27811. 0x62,
  27812. 0x91,
  27813. 0x95,
  27814. 0xe4,
  27815. 0x79,
  27816. 0xe7,
  27817. 0xc8,
  27818. 0x37,
  27819. 0x6d,
  27820. 0x8d,
  27821. 0xd5,
  27822. 0x4e,
  27823. 0xa9,
  27824. 0x6c,
  27825. 0x56,
  27826. 0xf4,
  27827. 0xea,
  27828. 0x65,
  27829. 0x7a,
  27830. 0xae,
  27831. 0x08,
  27832. 0xba,
  27833. 0x78,
  27834. 0x25,
  27835. 0x2e,
  27836. 0x1c,
  27837. 0xa6,
  27838. 0xb4,
  27839. 0xc6,
  27840. 0xe8,
  27841. 0xdd,
  27842. 0x74,
  27843. 0x1f,
  27844. 0x4b,
  27845. 0xbd,
  27846. 0x8b,
  27847. 0x8a,
  27848. 0x70,
  27849. 0x3e,
  27850. 0xb5,
  27851. 0x66,
  27852. 0x48,
  27853. 0x03,
  27854. 0xf6,
  27855. 0x0e,
  27856. 0x61,
  27857. 0x35,
  27858. 0x57,
  27859. 0xb9,
  27860. 0x86,
  27861. 0xc1,
  27862. 0x1d,
  27863. 0x9e,
  27864. 0xe1,
  27865. 0xf8,
  27866. 0x98,
  27867. 0x11,
  27868. 0x69,
  27869. 0xd9,
  27870. 0x8e,
  27871. 0x94,
  27872. 0x9b,
  27873. 0x1e,
  27874. 0x87,
  27875. 0xe9,
  27876. 0xce,
  27877. 0x55,
  27878. 0x28,
  27879. 0xdf,
  27880. 0x8c,
  27881. 0xa1,
  27882. 0x89,
  27883. 0x0d,
  27884. 0xbf,
  27885. 0xe6,
  27886. 0x42,
  27887. 0x68,
  27888. 0x41,
  27889. 0x99,
  27890. 0x2d,
  27891. 0x0f,
  27892. 0xb0,
  27893. 0x54,
  27894. 0xbb,
  27895. 0x16
  27896. ]);
  27897. var inv_s = new Uint8Array([
  27898. 0x52,
  27899. 0x09,
  27900. 0x6a,
  27901. 0xd5,
  27902. 0x30,
  27903. 0x36,
  27904. 0xa5,
  27905. 0x38,
  27906. 0xbf,
  27907. 0x40,
  27908. 0xa3,
  27909. 0x9e,
  27910. 0x81,
  27911. 0xf3,
  27912. 0xd7,
  27913. 0xfb,
  27914. 0x7c,
  27915. 0xe3,
  27916. 0x39,
  27917. 0x82,
  27918. 0x9b,
  27919. 0x2f,
  27920. 0xff,
  27921. 0x87,
  27922. 0x34,
  27923. 0x8e,
  27924. 0x43,
  27925. 0x44,
  27926. 0xc4,
  27927. 0xde,
  27928. 0xe9,
  27929. 0xcb,
  27930. 0x54,
  27931. 0x7b,
  27932. 0x94,
  27933. 0x32,
  27934. 0xa6,
  27935. 0xc2,
  27936. 0x23,
  27937. 0x3d,
  27938. 0xee,
  27939. 0x4c,
  27940. 0x95,
  27941. 0x0b,
  27942. 0x42,
  27943. 0xfa,
  27944. 0xc3,
  27945. 0x4e,
  27946. 0x08,
  27947. 0x2e,
  27948. 0xa1,
  27949. 0x66,
  27950. 0x28,
  27951. 0xd9,
  27952. 0x24,
  27953. 0xb2,
  27954. 0x76,
  27955. 0x5b,
  27956. 0xa2,
  27957. 0x49,
  27958. 0x6d,
  27959. 0x8b,
  27960. 0xd1,
  27961. 0x25,
  27962. 0x72,
  27963. 0xf8,
  27964. 0xf6,
  27965. 0x64,
  27966. 0x86,
  27967. 0x68,
  27968. 0x98,
  27969. 0x16,
  27970. 0xd4,
  27971. 0xa4,
  27972. 0x5c,
  27973. 0xcc,
  27974. 0x5d,
  27975. 0x65,
  27976. 0xb6,
  27977. 0x92,
  27978. 0x6c,
  27979. 0x70,
  27980. 0x48,
  27981. 0x50,
  27982. 0xfd,
  27983. 0xed,
  27984. 0xb9,
  27985. 0xda,
  27986. 0x5e,
  27987. 0x15,
  27988. 0x46,
  27989. 0x57,
  27990. 0xa7,
  27991. 0x8d,
  27992. 0x9d,
  27993. 0x84,
  27994. 0x90,
  27995. 0xd8,
  27996. 0xab,
  27997. 0x00,
  27998. 0x8c,
  27999. 0xbc,
  28000. 0xd3,
  28001. 0x0a,
  28002. 0xf7,
  28003. 0xe4,
  28004. 0x58,
  28005. 0x05,
  28006. 0xb8,
  28007. 0xb3,
  28008. 0x45,
  28009. 0x06,
  28010. 0xd0,
  28011. 0x2c,
  28012. 0x1e,
  28013. 0x8f,
  28014. 0xca,
  28015. 0x3f,
  28016. 0x0f,
  28017. 0x02,
  28018. 0xc1,
  28019. 0xaf,
  28020. 0xbd,
  28021. 0x03,
  28022. 0x01,
  28023. 0x13,
  28024. 0x8a,
  28025. 0x6b,
  28026. 0x3a,
  28027. 0x91,
  28028. 0x11,
  28029. 0x41,
  28030. 0x4f,
  28031. 0x67,
  28032. 0xdc,
  28033. 0xea,
  28034. 0x97,
  28035. 0xf2,
  28036. 0xcf,
  28037. 0xce,
  28038. 0xf0,
  28039. 0xb4,
  28040. 0xe6,
  28041. 0x73,
  28042. 0x96,
  28043. 0xac,
  28044. 0x74,
  28045. 0x22,
  28046. 0xe7,
  28047. 0xad,
  28048. 0x35,
  28049. 0x85,
  28050. 0xe2,
  28051. 0xf9,
  28052. 0x37,
  28053. 0xe8,
  28054. 0x1c,
  28055. 0x75,
  28056. 0xdf,
  28057. 0x6e,
  28058. 0x47,
  28059. 0xf1,
  28060. 0x1a,
  28061. 0x71,
  28062. 0x1d,
  28063. 0x29,
  28064. 0xc5,
  28065. 0x89,
  28066. 0x6f,
  28067. 0xb7,
  28068. 0x62,
  28069. 0x0e,
  28070. 0xaa,
  28071. 0x18,
  28072. 0xbe,
  28073. 0x1b,
  28074. 0xfc,
  28075. 0x56,
  28076. 0x3e,
  28077. 0x4b,
  28078. 0xc6,
  28079. 0xd2,
  28080. 0x79,
  28081. 0x20,
  28082. 0x9a,
  28083. 0xdb,
  28084. 0xc0,
  28085. 0xfe,
  28086. 0x78,
  28087. 0xcd,
  28088. 0x5a,
  28089. 0xf4,
  28090. 0x1f,
  28091. 0xdd,
  28092. 0xa8,
  28093. 0x33,
  28094. 0x88,
  28095. 0x07,
  28096. 0xc7,
  28097. 0x31,
  28098. 0xb1,
  28099. 0x12,
  28100. 0x10,
  28101. 0x59,
  28102. 0x27,
  28103. 0x80,
  28104. 0xec,
  28105. 0x5f,
  28106. 0x60,
  28107. 0x51,
  28108. 0x7f,
  28109. 0xa9,
  28110. 0x19,
  28111. 0xb5,
  28112. 0x4a,
  28113. 0x0d,
  28114. 0x2d,
  28115. 0xe5,
  28116. 0x7a,
  28117. 0x9f,
  28118. 0x93,
  28119. 0xc9,
  28120. 0x9c,
  28121. 0xef,
  28122. 0xa0,
  28123. 0xe0,
  28124. 0x3b,
  28125. 0x4d,
  28126. 0xae,
  28127. 0x2a,
  28128. 0xf5,
  28129. 0xb0,
  28130. 0xc8,
  28131. 0xeb,
  28132. 0xbb,
  28133. 0x3c,
  28134. 0x83,
  28135. 0x53,
  28136. 0x99,
  28137. 0x61,
  28138. 0x17,
  28139. 0x2b,
  28140. 0x04,
  28141. 0x7e,
  28142. 0xba,
  28143. 0x77,
  28144. 0xd6,
  28145. 0x26,
  28146. 0xe1,
  28147. 0x69,
  28148. 0x14,
  28149. 0x63,
  28150. 0x55,
  28151. 0x21,
  28152. 0x0c,
  28153. 0x7d
  28154. ]);
  28155. var mixCol = new Uint8Array(256);
  28156. for (var i = 0; i < 256; i++) {
  28157. if (i < 128) {
  28158. mixCol[i] = i << 1;
  28159. } else {
  28160. mixCol[i] = i << 1 ^ 0x1b;
  28161. }
  28162. }
  28163. var mix = new Uint32Array([
  28164. 0x00000000,
  28165. 0x0e090d0b,
  28166. 0x1c121a16,
  28167. 0x121b171d,
  28168. 0x3824342c,
  28169. 0x362d3927,
  28170. 0x24362e3a,
  28171. 0x2a3f2331,
  28172. 0x70486858,
  28173. 0x7e416553,
  28174. 0x6c5a724e,
  28175. 0x62537f45,
  28176. 0x486c5c74,
  28177. 0x4665517f,
  28178. 0x547e4662,
  28179. 0x5a774b69,
  28180. 0xe090d0b0,
  28181. 0xee99ddbb,
  28182. 0xfc82caa6,
  28183. 0xf28bc7ad,
  28184. 0xd8b4e49c,
  28185. 0xd6bde997,
  28186. 0xc4a6fe8a,
  28187. 0xcaaff381,
  28188. 0x90d8b8e8,
  28189. 0x9ed1b5e3,
  28190. 0x8ccaa2fe,
  28191. 0x82c3aff5,
  28192. 0xa8fc8cc4,
  28193. 0xa6f581cf,
  28194. 0xb4ee96d2,
  28195. 0xbae79bd9,
  28196. 0xdb3bbb7b,
  28197. 0xd532b670,
  28198. 0xc729a16d,
  28199. 0xc920ac66,
  28200. 0xe31f8f57,
  28201. 0xed16825c,
  28202. 0xff0d9541,
  28203. 0xf104984a,
  28204. 0xab73d323,
  28205. 0xa57ade28,
  28206. 0xb761c935,
  28207. 0xb968c43e,
  28208. 0x9357e70f,
  28209. 0x9d5eea04,
  28210. 0x8f45fd19,
  28211. 0x814cf012,
  28212. 0x3bab6bcb,
  28213. 0x35a266c0,
  28214. 0x27b971dd,
  28215. 0x29b07cd6,
  28216. 0x038f5fe7,
  28217. 0x0d8652ec,
  28218. 0x1f9d45f1,
  28219. 0x119448fa,
  28220. 0x4be30393,
  28221. 0x45ea0e98,
  28222. 0x57f11985,
  28223. 0x59f8148e,
  28224. 0x73c737bf,
  28225. 0x7dce3ab4,
  28226. 0x6fd52da9,
  28227. 0x61dc20a2,
  28228. 0xad766df6,
  28229. 0xa37f60fd,
  28230. 0xb16477e0,
  28231. 0xbf6d7aeb,
  28232. 0x955259da,
  28233. 0x9b5b54d1,
  28234. 0x894043cc,
  28235. 0x87494ec7,
  28236. 0xdd3e05ae,
  28237. 0xd33708a5,
  28238. 0xc12c1fb8,
  28239. 0xcf2512b3,
  28240. 0xe51a3182,
  28241. 0xeb133c89,
  28242. 0xf9082b94,
  28243. 0xf701269f,
  28244. 0x4de6bd46,
  28245. 0x43efb04d,
  28246. 0x51f4a750,
  28247. 0x5ffdaa5b,
  28248. 0x75c2896a,
  28249. 0x7bcb8461,
  28250. 0x69d0937c,
  28251. 0x67d99e77,
  28252. 0x3daed51e,
  28253. 0x33a7d815,
  28254. 0x21bccf08,
  28255. 0x2fb5c203,
  28256. 0x058ae132,
  28257. 0x0b83ec39,
  28258. 0x1998fb24,
  28259. 0x1791f62f,
  28260. 0x764dd68d,
  28261. 0x7844db86,
  28262. 0x6a5fcc9b,
  28263. 0x6456c190,
  28264. 0x4e69e2a1,
  28265. 0x4060efaa,
  28266. 0x527bf8b7,
  28267. 0x5c72f5bc,
  28268. 0x0605bed5,
  28269. 0x080cb3de,
  28270. 0x1a17a4c3,
  28271. 0x141ea9c8,
  28272. 0x3e218af9,
  28273. 0x302887f2,
  28274. 0x223390ef,
  28275. 0x2c3a9de4,
  28276. 0x96dd063d,
  28277. 0x98d40b36,
  28278. 0x8acf1c2b,
  28279. 0x84c61120,
  28280. 0xaef93211,
  28281. 0xa0f03f1a,
  28282. 0xb2eb2807,
  28283. 0xbce2250c,
  28284. 0xe6956e65,
  28285. 0xe89c636e,
  28286. 0xfa877473,
  28287. 0xf48e7978,
  28288. 0xdeb15a49,
  28289. 0xd0b85742,
  28290. 0xc2a3405f,
  28291. 0xccaa4d54,
  28292. 0x41ecdaf7,
  28293. 0x4fe5d7fc,
  28294. 0x5dfec0e1,
  28295. 0x53f7cdea,
  28296. 0x79c8eedb,
  28297. 0x77c1e3d0,
  28298. 0x65daf4cd,
  28299. 0x6bd3f9c6,
  28300. 0x31a4b2af,
  28301. 0x3fadbfa4,
  28302. 0x2db6a8b9,
  28303. 0x23bfa5b2,
  28304. 0x09808683,
  28305. 0x07898b88,
  28306. 0x15929c95,
  28307. 0x1b9b919e,
  28308. 0xa17c0a47,
  28309. 0xaf75074c,
  28310. 0xbd6e1051,
  28311. 0xb3671d5a,
  28312. 0x99583e6b,
  28313. 0x97513360,
  28314. 0x854a247d,
  28315. 0x8b432976,
  28316. 0xd134621f,
  28317. 0xdf3d6f14,
  28318. 0xcd267809,
  28319. 0xc32f7502,
  28320. 0xe9105633,
  28321. 0xe7195b38,
  28322. 0xf5024c25,
  28323. 0xfb0b412e,
  28324. 0x9ad7618c,
  28325. 0x94de6c87,
  28326. 0x86c57b9a,
  28327. 0x88cc7691,
  28328. 0xa2f355a0,
  28329. 0xacfa58ab,
  28330. 0xbee14fb6,
  28331. 0xb0e842bd,
  28332. 0xea9f09d4,
  28333. 0xe49604df,
  28334. 0xf68d13c2,
  28335. 0xf8841ec9,
  28336. 0xd2bb3df8,
  28337. 0xdcb230f3,
  28338. 0xcea927ee,
  28339. 0xc0a02ae5,
  28340. 0x7a47b13c,
  28341. 0x744ebc37,
  28342. 0x6655ab2a,
  28343. 0x685ca621,
  28344. 0x42638510,
  28345. 0x4c6a881b,
  28346. 0x5e719f06,
  28347. 0x5078920d,
  28348. 0x0a0fd964,
  28349. 0x0406d46f,
  28350. 0x161dc372,
  28351. 0x1814ce79,
  28352. 0x322bed48,
  28353. 0x3c22e043,
  28354. 0x2e39f75e,
  28355. 0x2030fa55,
  28356. 0xec9ab701,
  28357. 0xe293ba0a,
  28358. 0xf088ad17,
  28359. 0xfe81a01c,
  28360. 0xd4be832d,
  28361. 0xdab78e26,
  28362. 0xc8ac993b,
  28363. 0xc6a59430,
  28364. 0x9cd2df59,
  28365. 0x92dbd252,
  28366. 0x80c0c54f,
  28367. 0x8ec9c844,
  28368. 0xa4f6eb75,
  28369. 0xaaffe67e,
  28370. 0xb8e4f163,
  28371. 0xb6edfc68,
  28372. 0x0c0a67b1,
  28373. 0x02036aba,
  28374. 0x10187da7,
  28375. 0x1e1170ac,
  28376. 0x342e539d,
  28377. 0x3a275e96,
  28378. 0x283c498b,
  28379. 0x26354480,
  28380. 0x7c420fe9,
  28381. 0x724b02e2,
  28382. 0x605015ff,
  28383. 0x6e5918f4,
  28384. 0x44663bc5,
  28385. 0x4a6f36ce,
  28386. 0x587421d3,
  28387. 0x567d2cd8,
  28388. 0x37a10c7a,
  28389. 0x39a80171,
  28390. 0x2bb3166c,
  28391. 0x25ba1b67,
  28392. 0x0f853856,
  28393. 0x018c355d,
  28394. 0x13972240,
  28395. 0x1d9e2f4b,
  28396. 0x47e96422,
  28397. 0x49e06929,
  28398. 0x5bfb7e34,
  28399. 0x55f2733f,
  28400. 0x7fcd500e,
  28401. 0x71c45d05,
  28402. 0x63df4a18,
  28403. 0x6dd64713,
  28404. 0xd731dcca,
  28405. 0xd938d1c1,
  28406. 0xcb23c6dc,
  28407. 0xc52acbd7,
  28408. 0xef15e8e6,
  28409. 0xe11ce5ed,
  28410. 0xf307f2f0,
  28411. 0xfd0efffb,
  28412. 0xa779b492,
  28413. 0xa970b999,
  28414. 0xbb6bae84,
  28415. 0xb562a38f,
  28416. 0x9f5d80be,
  28417. 0x91548db5,
  28418. 0x834f9aa8,
  28419. 0x8d4697a3
  28420. ]);
  28421. function expandKey256(cipherKey) {
  28422. var b = 240, result = new Uint8Array(b);
  28423. var r = 1;
  28424. result.set(cipherKey);
  28425. for (var j = 32, i = 1; j < b; ++i) {
  28426. if (j % 32 === 16) {
  28427. t1 = s[t1];
  28428. t2 = s[t2];
  28429. t3 = s[t3];
  28430. t4 = s[t4];
  28431. } else if (j % 32 === 0) {
  28432. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28433. t1 = s[t1];
  28434. t2 = s[t2];
  28435. t3 = s[t3];
  28436. t4 = s[t4];
  28437. t1 = t1 ^ r;
  28438. if ((r <<= 1) >= 256) {
  28439. r = (r ^ 0x1b) & 0xFF;
  28440. }
  28441. }
  28442. for (var n = 0; n < 4; ++n) {
  28443. result[j] = t1 ^= result[j - 32];
  28444. j++;
  28445. result[j] = t2 ^= result[j - 32];
  28446. j++;
  28447. result[j] = t3 ^= result[j - 32];
  28448. j++;
  28449. result[j] = t4 ^= result[j - 32];
  28450. j++;
  28451. }
  28452. }
  28453. return result;
  28454. }
  28455. function decrypt256(input, key) {
  28456. var state = new Uint8Array(16);
  28457. state.set(input);
  28458. var i, j, k;
  28459. var t, u, v;
  28460. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28461. state[j] ^= key[k];
  28462. }
  28463. for (i = 13; i >= 1; --i) {
  28464. t = state[13];
  28465. state[13] = state[9];
  28466. state[9] = state[5];
  28467. state[5] = state[1];
  28468. state[1] = t;
  28469. t = state[14];
  28470. u = state[10];
  28471. state[14] = state[6];
  28472. state[10] = state[2];
  28473. state[6] = t;
  28474. state[2] = u;
  28475. t = state[15];
  28476. u = state[11];
  28477. v = state[7];
  28478. state[15] = state[3];
  28479. state[11] = t;
  28480. state[7] = u;
  28481. state[3] = v;
  28482. for (j = 0; j < 16; ++j) {
  28483. state[j] = inv_s[state[j]];
  28484. }
  28485. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28486. state[j] ^= key[k];
  28487. }
  28488. for (j = 0; j < 16; j += 4) {
  28489. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28490. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28491. state[j] = t >>> 24 & 0xFF;
  28492. state[j + 1] = t >> 16 & 0xFF;
  28493. state[j + 2] = t >> 8 & 0xFF;
  28494. state[j + 3] = t & 0xFF;
  28495. }
  28496. }
  28497. t = state[13];
  28498. state[13] = state[9];
  28499. state[9] = state[5];
  28500. state[5] = state[1];
  28501. state[1] = t;
  28502. t = state[14];
  28503. u = state[10];
  28504. state[14] = state[6];
  28505. state[10] = state[2];
  28506. state[6] = t;
  28507. state[2] = u;
  28508. t = state[15];
  28509. u = state[11];
  28510. v = state[7];
  28511. state[15] = state[3];
  28512. state[11] = t;
  28513. state[7] = u;
  28514. state[3] = v;
  28515. for (j = 0; j < 16; ++j) {
  28516. state[j] = inv_s[state[j]];
  28517. state[j] ^= key[j];
  28518. }
  28519. return state;
  28520. }
  28521. function encrypt256(input, key) {
  28522. var t, u, v, k;
  28523. var state = new Uint8Array(16);
  28524. state.set(input);
  28525. for (j = 0; j < 16; ++j) {
  28526. state[j] ^= key[j];
  28527. }
  28528. for (i = 1; i < 14; i++) {
  28529. for (j = 0; j < 16; ++j) {
  28530. state[j] = s[state[j]];
  28531. }
  28532. v = state[1];
  28533. state[1] = state[5];
  28534. state[5] = state[9];
  28535. state[9] = state[13];
  28536. state[13] = v;
  28537. v = state[2];
  28538. u = state[6];
  28539. state[2] = state[10];
  28540. state[6] = state[14];
  28541. state[10] = v;
  28542. state[14] = u;
  28543. v = state[3];
  28544. u = state[7];
  28545. t = state[11];
  28546. state[3] = state[15];
  28547. state[7] = v;
  28548. state[11] = u;
  28549. state[15] = t;
  28550. for (var j = 0; j < 16; j += 4) {
  28551. var s0 = state[j + 0], s1 = state[j + 1];
  28552. var s2 = state[j + 2], s3 = state[j + 3];
  28553. t = s0 ^ s1 ^ s2 ^ s3;
  28554. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28555. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28556. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28557. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28558. }
  28559. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28560. state[j] ^= key[k];
  28561. }
  28562. }
  28563. for (j = 0; j < 16; ++j) {
  28564. state[j] = s[state[j]];
  28565. }
  28566. v = state[1];
  28567. state[1] = state[5];
  28568. state[5] = state[9];
  28569. state[9] = state[13];
  28570. state[13] = v;
  28571. v = state[2];
  28572. u = state[6];
  28573. state[2] = state[10];
  28574. state[6] = state[14];
  28575. state[10] = v;
  28576. state[14] = u;
  28577. v = state[3];
  28578. u = state[7];
  28579. t = state[11];
  28580. state[3] = state[15];
  28581. state[7] = v;
  28582. state[11] = u;
  28583. state[15] = t;
  28584. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28585. state[j] ^= key[k];
  28586. }
  28587. return state;
  28588. }
  28589. function AES256Cipher(key) {
  28590. this.key = expandKey256(key);
  28591. this.buffer = new Uint8Array(16);
  28592. this.bufferPosition = 0;
  28593. }
  28594. function decryptBlock2(data, finalize) {
  28595. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28596. for (i = 0; i < sourceLength; ++i) {
  28597. buffer[bufferLength] = data[i];
  28598. ++bufferLength;
  28599. if (bufferLength < 16) {
  28600. continue;
  28601. }
  28602. var plain = decrypt256(buffer, this.key);
  28603. for (j = 0; j < 16; ++j) {
  28604. plain[j] ^= iv[j];
  28605. }
  28606. iv = buffer;
  28607. result.push(plain);
  28608. buffer = new Uint8Array(16);
  28609. bufferLength = 0;
  28610. }
  28611. this.buffer = buffer;
  28612. this.bufferLength = bufferLength;
  28613. this.iv = iv;
  28614. if (result.length === 0) {
  28615. return new Uint8Array([]);
  28616. }
  28617. var outputLength = 16 * result.length;
  28618. if (finalize) {
  28619. var lastBlock = result[result.length - 1];
  28620. var psLen = lastBlock[15];
  28621. if (psLen <= 16) {
  28622. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28623. if (lastBlock[i] !== psLen) {
  28624. psLen = 0;
  28625. break;
  28626. }
  28627. }
  28628. outputLength -= psLen;
  28629. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28630. }
  28631. }
  28632. var output = new Uint8Array(outputLength);
  28633. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28634. output.set(result[i], j);
  28635. }
  28636. return output;
  28637. }
  28638. AES256Cipher.prototype = {
  28639. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  28640. var i, sourceLength = data.length;
  28641. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28642. if (iv) {
  28643. this.iv = iv;
  28644. } else {
  28645. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28646. buffer[bufferLength] = data[i];
  28647. }
  28648. if (bufferLength < 16) {
  28649. this.bufferLength = bufferLength;
  28650. return new Uint8Array([]);
  28651. }
  28652. this.iv = buffer;
  28653. data = data.subarray(16);
  28654. }
  28655. this.buffer = new Uint8Array(16);
  28656. this.bufferLength = 0;
  28657. this.decryptBlock = decryptBlock2;
  28658. return this.decryptBlock(data, finalize);
  28659. },
  28660. encrypt: function AES256Cipher_encrypt(data, iv) {
  28661. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28662. if (!iv) {
  28663. iv = new Uint8Array(16);
  28664. }
  28665. for (i = 0; i < sourceLength; ++i) {
  28666. buffer[bufferLength] = data[i];
  28667. ++bufferLength;
  28668. if (bufferLength < 16) {
  28669. continue;
  28670. }
  28671. for (j = 0; j < 16; ++j) {
  28672. buffer[j] ^= iv[j];
  28673. }
  28674. var cipher = encrypt256(buffer, this.key);
  28675. this.iv = cipher;
  28676. result.push(cipher);
  28677. buffer = new Uint8Array(16);
  28678. bufferLength = 0;
  28679. }
  28680. this.buffer = buffer;
  28681. this.bufferLength = bufferLength;
  28682. this.iv = iv;
  28683. if (result.length === 0) {
  28684. return new Uint8Array([]);
  28685. }
  28686. var outputLength = 16 * result.length;
  28687. var output = new Uint8Array(outputLength);
  28688. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28689. output.set(result[i], j);
  28690. }
  28691. return output;
  28692. }
  28693. };
  28694. return AES256Cipher;
  28695. }();
  28696. var PDF17 = function PDF17Closure() {
  28697. function compareByteArrays(array1, array2) {
  28698. if (array1.length !== array2.length) {
  28699. return false;
  28700. }
  28701. for (var i = 0; i < array1.length; i++) {
  28702. if (array1[i] !== array2[i]) {
  28703. return false;
  28704. }
  28705. }
  28706. return true;
  28707. }
  28708. function PDF17() {
  28709. }
  28710. PDF17.prototype = {
  28711. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28712. var hashData = new Uint8Array(password.length + 56);
  28713. hashData.set(password, 0);
  28714. hashData.set(ownerValidationSalt, password.length);
  28715. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28716. var result = calculateSHA256(hashData, 0, hashData.length);
  28717. return compareByteArrays(result, ownerPassword);
  28718. },
  28719. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  28720. var hashData = new Uint8Array(password.length + 8);
  28721. hashData.set(password, 0);
  28722. hashData.set(userValidationSalt, password.length);
  28723. var result = calculateSHA256(hashData, 0, hashData.length);
  28724. return compareByteArrays(result, userPassword);
  28725. },
  28726. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28727. var hashData = new Uint8Array(password.length + 56);
  28728. hashData.set(password, 0);
  28729. hashData.set(ownerKeySalt, password.length);
  28730. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28731. var key = calculateSHA256(hashData, 0, hashData.length);
  28732. var cipher = new AES256Cipher(key);
  28733. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28734. },
  28735. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  28736. var hashData = new Uint8Array(password.length + 8);
  28737. hashData.set(password, 0);
  28738. hashData.set(userKeySalt, password.length);
  28739. var key = calculateSHA256(hashData, 0, hashData.length);
  28740. var cipher = new AES256Cipher(key);
  28741. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28742. }
  28743. };
  28744. return PDF17;
  28745. }();
  28746. var PDF20 = function PDF20Closure() {
  28747. function concatArrays(array1, array2) {
  28748. var t = new Uint8Array(array1.length + array2.length);
  28749. t.set(array1, 0);
  28750. t.set(array2, array1.length);
  28751. return t;
  28752. }
  28753. function calculatePDF20Hash(password, input, userBytes) {
  28754. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  28755. var e = [0];
  28756. var i = 0;
  28757. while (i < 64 || e[e.length - 1] > i - 32) {
  28758. var arrayLength = password.length + k.length + userBytes.length;
  28759. var k1 = new Uint8Array(arrayLength * 64);
  28760. var array = concatArrays(password, k);
  28761. array = concatArrays(array, userBytes);
  28762. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  28763. k1.set(array, pos);
  28764. }
  28765. var cipher = new AES128Cipher(k.subarray(0, 16));
  28766. e = cipher.encrypt(k1, k.subarray(16, 32));
  28767. var remainder = 0;
  28768. for (var z = 0; z < 16; z++) {
  28769. remainder *= 256 % 3;
  28770. remainder %= 3;
  28771. remainder += (e[z] >>> 0) % 3;
  28772. remainder %= 3;
  28773. }
  28774. if (remainder === 0) {
  28775. k = calculateSHA256(e, 0, e.length);
  28776. } else if (remainder === 1) {
  28777. k = calculateSHA384(e, 0, e.length);
  28778. } else if (remainder === 2) {
  28779. k = calculateSHA512(e, 0, e.length);
  28780. }
  28781. i++;
  28782. }
  28783. return k.subarray(0, 32);
  28784. }
  28785. function PDF20() {
  28786. }
  28787. function compareByteArrays(array1, array2) {
  28788. if (array1.length !== array2.length) {
  28789. return false;
  28790. }
  28791. for (var i = 0; i < array1.length; i++) {
  28792. if (array1[i] !== array2[i]) {
  28793. return false;
  28794. }
  28795. }
  28796. return true;
  28797. }
  28798. PDF20.prototype = {
  28799. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28800. return calculatePDF20Hash(password, concatBytes, userBytes);
  28801. },
  28802. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28803. var hashData = new Uint8Array(password.length + 56);
  28804. hashData.set(password, 0);
  28805. hashData.set(ownerValidationSalt, password.length);
  28806. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28807. var result = calculatePDF20Hash(password, hashData, userBytes);
  28808. return compareByteArrays(result, ownerPassword);
  28809. },
  28810. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28811. var hashData = new Uint8Array(password.length + 8);
  28812. hashData.set(password, 0);
  28813. hashData.set(userValidationSalt, password.length);
  28814. var result = calculatePDF20Hash(password, hashData, []);
  28815. return compareByteArrays(result, userPassword);
  28816. },
  28817. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28818. var hashData = new Uint8Array(password.length + 56);
  28819. hashData.set(password, 0);
  28820. hashData.set(ownerKeySalt, password.length);
  28821. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28822. var key = calculatePDF20Hash(password, hashData, userBytes);
  28823. var cipher = new AES256Cipher(key);
  28824. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28825. },
  28826. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28827. var hashData = new Uint8Array(password.length + 8);
  28828. hashData.set(password, 0);
  28829. hashData.set(userKeySalt, password.length);
  28830. var key = calculatePDF20Hash(password, hashData, []);
  28831. var cipher = new AES256Cipher(key);
  28832. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28833. }
  28834. };
  28835. return PDF20;
  28836. }();
  28837. var CipherTransform = function CipherTransformClosure() {
  28838. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28839. this.StringCipherConstructor = stringCipherConstructor;
  28840. this.StreamCipherConstructor = streamCipherConstructor;
  28841. }
  28842. CipherTransform.prototype = {
  28843. createStream: function CipherTransform_createStream(stream, length) {
  28844. var cipher = new this.StreamCipherConstructor();
  28845. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28846. return cipher.decryptBlock(data, finalize);
  28847. });
  28848. },
  28849. decryptString: function CipherTransform_decryptString(s) {
  28850. var cipher = new this.StringCipherConstructor();
  28851. var data = stringToBytes(s);
  28852. data = cipher.decryptBlock(data, true);
  28853. return bytesToString(data);
  28854. }
  28855. };
  28856. return CipherTransform;
  28857. }();
  28858. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28859. var defaultPasswordBytes = new Uint8Array([
  28860. 0x28,
  28861. 0xBF,
  28862. 0x4E,
  28863. 0x5E,
  28864. 0x4E,
  28865. 0x75,
  28866. 0x8A,
  28867. 0x41,
  28868. 0x64,
  28869. 0x00,
  28870. 0x4E,
  28871. 0x56,
  28872. 0xFF,
  28873. 0xFA,
  28874. 0x01,
  28875. 0x08,
  28876. 0x2E,
  28877. 0x2E,
  28878. 0x00,
  28879. 0xB6,
  28880. 0xD0,
  28881. 0x68,
  28882. 0x3E,
  28883. 0x80,
  28884. 0x2F,
  28885. 0x0C,
  28886. 0xA9,
  28887. 0xFE,
  28888. 0x64,
  28889. 0x53,
  28890. 0x69,
  28891. 0x7A
  28892. ]);
  28893. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28894. if (password) {
  28895. var passwordLength = Math.min(127, password.length);
  28896. password = password.subarray(0, passwordLength);
  28897. } else {
  28898. password = [];
  28899. }
  28900. var pdfAlgorithm;
  28901. if (revision === 6) {
  28902. pdfAlgorithm = new PDF20();
  28903. } else {
  28904. pdfAlgorithm = new PDF17();
  28905. }
  28906. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28907. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28908. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28909. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28910. }
  28911. return null;
  28912. }
  28913. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28914. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28915. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28916. if (password) {
  28917. n = Math.min(32, password.length);
  28918. for (; i < n; ++i) {
  28919. hashData[i] = password[i];
  28920. }
  28921. }
  28922. j = 0;
  28923. while (i < 32) {
  28924. hashData[i++] = defaultPasswordBytes[j++];
  28925. }
  28926. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28927. hashData[i++] = ownerPassword[j];
  28928. }
  28929. hashData[i++] = flags & 0xFF;
  28930. hashData[i++] = flags >> 8 & 0xFF;
  28931. hashData[i++] = flags >> 16 & 0xFF;
  28932. hashData[i++] = flags >>> 24 & 0xFF;
  28933. for (j = 0, n = fileId.length; j < n; ++j) {
  28934. hashData[i++] = fileId[j];
  28935. }
  28936. if (revision >= 4 && !encryptMetadata) {
  28937. hashData[i++] = 0xFF;
  28938. hashData[i++] = 0xFF;
  28939. hashData[i++] = 0xFF;
  28940. hashData[i++] = 0xFF;
  28941. }
  28942. var hash = calculateMD5(hashData, 0, i);
  28943. var keyLengthInBytes = keyLength >> 3;
  28944. if (revision >= 3) {
  28945. for (j = 0; j < 50; ++j) {
  28946. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28947. }
  28948. }
  28949. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28950. var cipher, checkData;
  28951. if (revision >= 3) {
  28952. for (i = 0; i < 32; ++i) {
  28953. hashData[i] = defaultPasswordBytes[i];
  28954. }
  28955. for (j = 0, n = fileId.length; j < n; ++j) {
  28956. hashData[i++] = fileId[j];
  28957. }
  28958. cipher = new ARCFourCipher(encryptionKey);
  28959. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28960. n = encryptionKey.length;
  28961. var derivedKey = new Uint8Array(n), k;
  28962. for (j = 1; j <= 19; ++j) {
  28963. for (k = 0; k < n; ++k) {
  28964. derivedKey[k] = encryptionKey[k] ^ j;
  28965. }
  28966. cipher = new ARCFourCipher(derivedKey);
  28967. checkData = cipher.encryptBlock(checkData);
  28968. }
  28969. for (j = 0, n = checkData.length; j < n; ++j) {
  28970. if (userPassword[j] !== checkData[j]) {
  28971. return null;
  28972. }
  28973. }
  28974. } else {
  28975. cipher = new ARCFourCipher(encryptionKey);
  28976. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28977. for (j = 0, n = checkData.length; j < n; ++j) {
  28978. if (userPassword[j] !== checkData[j]) {
  28979. return null;
  28980. }
  28981. }
  28982. }
  28983. return encryptionKey;
  28984. }
  28985. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28986. var hashData = new Uint8Array(32), i = 0, j, n;
  28987. n = Math.min(32, password.length);
  28988. for (; i < n; ++i) {
  28989. hashData[i] = password[i];
  28990. }
  28991. j = 0;
  28992. while (i < 32) {
  28993. hashData[i++] = defaultPasswordBytes[j++];
  28994. }
  28995. var hash = calculateMD5(hashData, 0, i);
  28996. var keyLengthInBytes = keyLength >> 3;
  28997. if (revision >= 3) {
  28998. for (j = 0; j < 50; ++j) {
  28999. hash = calculateMD5(hash, 0, hash.length);
  29000. }
  29001. }
  29002. var cipher, userPassword;
  29003. if (revision >= 3) {
  29004. userPassword = ownerPassword;
  29005. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  29006. for (j = 19; j >= 0; j--) {
  29007. for (k = 0; k < keyLengthInBytes; ++k) {
  29008. derivedKey[k] = hash[k] ^ j;
  29009. }
  29010. cipher = new ARCFourCipher(derivedKey);
  29011. userPassword = cipher.encryptBlock(userPassword);
  29012. }
  29013. } else {
  29014. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  29015. userPassword = cipher.encryptBlock(ownerPassword);
  29016. }
  29017. return userPassword;
  29018. }
  29019. var identityName = Name.get('Identity');
  29020. function CipherTransformFactory(dict, fileId, password) {
  29021. var filter = dict.get('Filter');
  29022. if (!isName(filter, 'Standard')) {
  29023. error('unknown encryption method');
  29024. }
  29025. this.dict = dict;
  29026. var algorithm = dict.get('V');
  29027. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  29028. error('unsupported encryption algorithm');
  29029. }
  29030. this.algorithm = algorithm;
  29031. var keyLength = dict.get('Length');
  29032. if (!keyLength) {
  29033. if (algorithm <= 3) {
  29034. keyLength = 40;
  29035. } else {
  29036. var cfDict = dict.get('CF');
  29037. var streamCryptoName = dict.get('StmF');
  29038. if (isDict(cfDict) && isName(streamCryptoName)) {
  29039. cfDict.suppressEncryption = true;
  29040. var handlerDict = cfDict.get(streamCryptoName.name);
  29041. keyLength = handlerDict && handlerDict.get('Length') || 128;
  29042. if (keyLength < 40) {
  29043. keyLength <<= 3;
  29044. }
  29045. }
  29046. }
  29047. }
  29048. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  29049. error('invalid key length');
  29050. }
  29051. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  29052. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  29053. var flags = dict.get('P');
  29054. var revision = dict.get('R');
  29055. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  29056. this.encryptMetadata = encryptMetadata;
  29057. var fileIdBytes = stringToBytes(fileId);
  29058. var passwordBytes;
  29059. if (password) {
  29060. if (revision === 6) {
  29061. try {
  29062. password = utf8StringToString(password);
  29063. } catch (ex) {
  29064. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29065. }
  29066. }
  29067. passwordBytes = stringToBytes(password);
  29068. }
  29069. var encryptionKey;
  29070. if (algorithm !== 5) {
  29071. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29072. } else {
  29073. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29074. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29075. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29076. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29077. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29078. var ownerEncryption = stringToBytes(dict.get('OE'));
  29079. var userEncryption = stringToBytes(dict.get('UE'));
  29080. var perms = stringToBytes(dict.get('Perms'));
  29081. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29082. }
  29083. if (!encryptionKey && !password) {
  29084. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29085. } else if (!encryptionKey && password) {
  29086. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29087. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29088. }
  29089. if (!encryptionKey) {
  29090. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29091. }
  29092. this.encryptionKey = encryptionKey;
  29093. if (algorithm >= 4) {
  29094. var cf = dict.get('CF');
  29095. if (isDict(cf)) {
  29096. cf.suppressEncryption = true;
  29097. }
  29098. this.cf = cf;
  29099. this.stmf = dict.get('StmF') || identityName;
  29100. this.strf = dict.get('StrF') || identityName;
  29101. this.eff = dict.get('EFF') || this.stmf;
  29102. }
  29103. }
  29104. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29105. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29106. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29107. key[i] = encryptionKey[i];
  29108. }
  29109. key[i++] = num & 0xFF;
  29110. key[i++] = num >> 8 & 0xFF;
  29111. key[i++] = num >> 16 & 0xFF;
  29112. key[i++] = gen & 0xFF;
  29113. key[i++] = gen >> 8 & 0xFF;
  29114. if (isAes) {
  29115. key[i++] = 0x73;
  29116. key[i++] = 0x41;
  29117. key[i++] = 0x6C;
  29118. key[i++] = 0x54;
  29119. }
  29120. var hash = calculateMD5(key, 0, i);
  29121. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29122. }
  29123. function buildCipherConstructor(cf, name, num, gen, key) {
  29124. assert(isName(name), 'Invalid crypt filter name.');
  29125. var cryptFilter = cf.get(name.name);
  29126. var cfm;
  29127. if (cryptFilter !== null && cryptFilter !== undefined) {
  29128. cfm = cryptFilter.get('CFM');
  29129. }
  29130. if (!cfm || cfm.name === 'None') {
  29131. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29132. return new NullCipher();
  29133. };
  29134. }
  29135. if (cfm.name === 'V2') {
  29136. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29137. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29138. };
  29139. }
  29140. if (cfm.name === 'AESV2') {
  29141. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29142. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29143. };
  29144. }
  29145. if (cfm.name === 'AESV3') {
  29146. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29147. return new AES256Cipher(key);
  29148. };
  29149. }
  29150. error('Unknown crypto method');
  29151. }
  29152. CipherTransformFactory.prototype = {
  29153. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29154. if (this.algorithm === 4 || this.algorithm === 5) {
  29155. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29156. }
  29157. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29158. var cipherConstructor = function buildCipherCipherConstructor() {
  29159. return new ARCFourCipher(key);
  29160. };
  29161. return new CipherTransform(cipherConstructor, cipherConstructor);
  29162. }
  29163. };
  29164. return CipherTransformFactory;
  29165. }();
  29166. exports.AES128Cipher = AES128Cipher;
  29167. exports.AES256Cipher = AES256Cipher;
  29168. exports.ARCFourCipher = ARCFourCipher;
  29169. exports.CipherTransformFactory = CipherTransformFactory;
  29170. exports.PDF17 = PDF17;
  29171. exports.PDF20 = PDF20;
  29172. exports.calculateMD5 = calculateMD5;
  29173. exports.calculateSHA256 = calculateSHA256;
  29174. exports.calculateSHA384 = calculateSHA384;
  29175. exports.calculateSHA512 = calculateSHA512;
  29176. /***/ }),
  29177. /* 17 */
  29178. /***/ (function(module, exports, __w_pdfjs_require__) {
  29179. "use strict";
  29180. var sharedUtil = __w_pdfjs_require__(0);
  29181. var corePrimitives = __w_pdfjs_require__(1);
  29182. var coreStream = __w_pdfjs_require__(2);
  29183. var coreParser = __w_pdfjs_require__(6);
  29184. var coreImage = __w_pdfjs_require__(34);
  29185. var coreColorSpace = __w_pdfjs_require__(4);
  29186. var coreMurmurHash3 = __w_pdfjs_require__(38);
  29187. var coreFonts = __w_pdfjs_require__(33);
  29188. var coreFunction = __w_pdfjs_require__(7);
  29189. var corePattern = __w_pdfjs_require__(40);
  29190. var coreCMap = __w_pdfjs_require__(30);
  29191. var coreMetrics = __w_pdfjs_require__(37);
  29192. var coreBidi = __w_pdfjs_require__(28);
  29193. var coreEncodings = __w_pdfjs_require__(5);
  29194. var coreStandardFonts = __w_pdfjs_require__(20);
  29195. var coreUnicode = __w_pdfjs_require__(21);
  29196. var coreGlyphList = __w_pdfjs_require__(8);
  29197. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29198. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29199. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29200. var ImageKind = sharedUtil.ImageKind;
  29201. var OPS = sharedUtil.OPS;
  29202. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29203. var CMapCompressionType = sharedUtil.CMapCompressionType;
  29204. var Util = sharedUtil.Util;
  29205. var assert = sharedUtil.assert;
  29206. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29207. var error = sharedUtil.error;
  29208. var info = sharedUtil.info;
  29209. var isArray = sharedUtil.isArray;
  29210. var isNum = sharedUtil.isNum;
  29211. var isString = sharedUtil.isString;
  29212. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29213. var warn = sharedUtil.warn;
  29214. var Dict = corePrimitives.Dict;
  29215. var Name = corePrimitives.Name;
  29216. var isEOF = corePrimitives.isEOF;
  29217. var isCmd = corePrimitives.isCmd;
  29218. var isDict = corePrimitives.isDict;
  29219. var isName = corePrimitives.isName;
  29220. var isRef = corePrimitives.isRef;
  29221. var isStream = corePrimitives.isStream;
  29222. var DecodeStream = coreStream.DecodeStream;
  29223. var JpegStream = coreStream.JpegStream;
  29224. var Stream = coreStream.Stream;
  29225. var Lexer = coreParser.Lexer;
  29226. var Parser = coreParser.Parser;
  29227. var PDFImage = coreImage.PDFImage;
  29228. var ColorSpace = coreColorSpace.ColorSpace;
  29229. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29230. var ErrorFont = coreFonts.ErrorFont;
  29231. var FontFlags = coreFonts.FontFlags;
  29232. var Font = coreFonts.Font;
  29233. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29234. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29235. var getFontType = coreFonts.getFontType;
  29236. var isPDFFunction = coreFunction.isPDFFunction;
  29237. var PDFFunction = coreFunction.PDFFunction;
  29238. var Pattern = corePattern.Pattern;
  29239. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29240. var CMapFactory = coreCMap.CMapFactory;
  29241. var IdentityCMap = coreCMap.IdentityCMap;
  29242. var getMetrics = coreMetrics.getMetrics;
  29243. var bidi = coreBidi.bidi;
  29244. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29245. var StandardEncoding = coreEncodings.StandardEncoding;
  29246. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29247. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29248. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29249. var getEncoding = coreEncodings.getEncoding;
  29250. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29251. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29252. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29253. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29254. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29255. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29256. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29257. var PartialEvaluator = function PartialEvaluatorClosure() {
  29258. var DefaultPartialEvaluatorOptions = {
  29259. forceDataSchema: false,
  29260. maxImageSize: -1,
  29261. disableFontFace: false,
  29262. disableNativeImageDecoder: false
  29263. };
  29264. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29265. this.xref = xref;
  29266. this.resources = resources;
  29267. this.handler = handler;
  29268. this.forceDataSchema = forceDataSchema;
  29269. }
  29270. NativeImageDecoder.prototype = {
  29271. canDecode: function (image) {
  29272. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29273. },
  29274. decode: function (image) {
  29275. var dict = image.dict;
  29276. var colorSpace = dict.get('ColorSpace', 'CS');
  29277. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29278. var numComps = colorSpace.numComps;
  29279. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29280. image.getIR(this.forceDataSchema),
  29281. numComps
  29282. ]);
  29283. return decodePromise.then(function (message) {
  29284. var data = message.data;
  29285. return new Stream(data, 0, data.length, image.dict);
  29286. });
  29287. }
  29288. };
  29289. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29290. var dict = image.dict;
  29291. if (dict.has('DecodeParms') || dict.has('DP')) {
  29292. return false;
  29293. }
  29294. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29295. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29296. };
  29297. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29298. var dict = image.dict;
  29299. if (dict.has('DecodeParms') || dict.has('DP')) {
  29300. return false;
  29301. }
  29302. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29303. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29304. };
  29305. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  29306. this.pdfManager = pdfManager;
  29307. this.xref = xref;
  29308. this.handler = handler;
  29309. this.pageIndex = pageIndex;
  29310. this.idFactory = idFactory;
  29311. this.fontCache = fontCache;
  29312. this.builtInCMapCache = builtInCMapCache;
  29313. this.options = options || DefaultPartialEvaluatorOptions;
  29314. this.fetchBuiltInCMap = function (name) {
  29315. var cachedCMap = builtInCMapCache[name];
  29316. if (cachedCMap) {
  29317. return Promise.resolve(cachedCMap);
  29318. }
  29319. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  29320. if (data.compressionType !== CMapCompressionType.NONE) {
  29321. builtInCMapCache[name] = data;
  29322. }
  29323. return data;
  29324. });
  29325. };
  29326. }
  29327. var TIME_SLOT_DURATION_MS = 20;
  29328. var CHECK_TIME_EVERY = 100;
  29329. function TimeSlotManager() {
  29330. this.reset();
  29331. }
  29332. TimeSlotManager.prototype = {
  29333. check: function TimeSlotManager_check() {
  29334. if (++this.checked < CHECK_TIME_EVERY) {
  29335. return false;
  29336. }
  29337. this.checked = 0;
  29338. return this.endTime <= Date.now();
  29339. },
  29340. reset: function TimeSlotManager_reset() {
  29341. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29342. this.checked = 0;
  29343. }
  29344. };
  29345. var deferred = Promise.resolve();
  29346. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29347. PartialEvaluator.prototype = {
  29348. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  29349. if (!isDict(resources)) {
  29350. return false;
  29351. }
  29352. var processed = Object.create(null);
  29353. if (resources.objId) {
  29354. processed[resources.objId] = true;
  29355. }
  29356. var nodes = [resources], xref = this.xref;
  29357. while (nodes.length) {
  29358. var key, i, ii;
  29359. var node = nodes.shift();
  29360. var graphicStates = node.get('ExtGState');
  29361. if (isDict(graphicStates)) {
  29362. var graphicStatesKeys = graphicStates.getKeys();
  29363. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  29364. key = graphicStatesKeys[i];
  29365. var graphicState = graphicStates.get(key);
  29366. var bm = graphicState.get('BM');
  29367. if (isName(bm) && bm.name !== 'Normal') {
  29368. return true;
  29369. }
  29370. }
  29371. }
  29372. var xObjects = node.get('XObject');
  29373. if (!isDict(xObjects)) {
  29374. continue;
  29375. }
  29376. var xObjectsKeys = xObjects.getKeys();
  29377. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  29378. key = xObjectsKeys[i];
  29379. var xObject = xObjects.getRaw(key);
  29380. if (isRef(xObject)) {
  29381. if (processed[xObject.toString()]) {
  29382. continue;
  29383. }
  29384. xObject = xref.fetch(xObject);
  29385. }
  29386. if (!isStream(xObject)) {
  29387. continue;
  29388. }
  29389. if (xObject.dict.objId) {
  29390. if (processed[xObject.dict.objId]) {
  29391. continue;
  29392. }
  29393. processed[xObject.dict.objId] = true;
  29394. }
  29395. var xResources = xObject.dict.get('Resources');
  29396. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  29397. nodes.push(xResources);
  29398. if (xResources.objId) {
  29399. processed[xResources.objId] = true;
  29400. }
  29401. }
  29402. }
  29403. }
  29404. return false;
  29405. },
  29406. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  29407. var matrix = xobj.dict.getArray('Matrix');
  29408. var bbox = xobj.dict.getArray('BBox');
  29409. var group = xobj.dict.get('Group');
  29410. if (group) {
  29411. var groupOptions = {
  29412. matrix: matrix,
  29413. bbox: bbox,
  29414. smask: smask,
  29415. isolated: false,
  29416. knockout: false
  29417. };
  29418. var groupSubtype = group.get('S');
  29419. var colorSpace;
  29420. if (isName(groupSubtype, 'Transparency')) {
  29421. groupOptions.isolated = group.get('I') || false;
  29422. groupOptions.knockout = group.get('K') || false;
  29423. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  29424. }
  29425. if (smask && smask.backdrop) {
  29426. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  29427. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  29428. }
  29429. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  29430. }
  29431. operatorList.addOp(OPS.paintFormXObjectBegin, [
  29432. matrix,
  29433. bbox
  29434. ]);
  29435. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  29436. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  29437. if (group) {
  29438. operatorList.addOp(OPS.endGroup, [groupOptions]);
  29439. }
  29440. });
  29441. },
  29442. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  29443. var self = this;
  29444. var dict = image.dict;
  29445. var w = dict.get('Width', 'W');
  29446. var h = dict.get('Height', 'H');
  29447. if (!(w && isNum(w)) || !(h && isNum(h))) {
  29448. warn('Image dimensions are missing, or not numbers.');
  29449. return;
  29450. }
  29451. var maxImageSize = this.options.maxImageSize;
  29452. if (maxImageSize !== -1 && w * h > maxImageSize) {
  29453. warn('Image exceeded maximum allowed size and was removed.');
  29454. return;
  29455. }
  29456. var imageMask = dict.get('ImageMask', 'IM') || false;
  29457. var imgData, args;
  29458. if (imageMask) {
  29459. var width = dict.get('Width', 'W');
  29460. var height = dict.get('Height', 'H');
  29461. var bitStrideLength = width + 7 >> 3;
  29462. var imgArray = image.getBytes(bitStrideLength * height);
  29463. var decode = dict.getArray('Decode', 'D');
  29464. var inverseDecode = !!decode && decode[0] > 0;
  29465. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  29466. imgData.cached = true;
  29467. args = [imgData];
  29468. operatorList.addOp(OPS.paintImageMaskXObject, args);
  29469. if (cacheKey) {
  29470. imageCache[cacheKey] = {
  29471. fn: OPS.paintImageMaskXObject,
  29472. args: args
  29473. };
  29474. }
  29475. return;
  29476. }
  29477. var softMask = dict.get('SMask', 'SM') || false;
  29478. var mask = dict.get('Mask') || false;
  29479. var SMALL_IMAGE_DIMENSIONS = 200;
  29480. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  29481. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  29482. imgData = imageObj.createImageData(true);
  29483. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  29484. return;
  29485. }
  29486. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  29487. var objId = 'img_' + this.idFactory.createObjId();
  29488. operatorList.addDependency(objId);
  29489. args = [
  29490. objId,
  29491. w,
  29492. h
  29493. ];
  29494. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  29495. operatorList.addOp(OPS.paintJpegXObject, args);
  29496. this.handler.send('obj', [
  29497. objId,
  29498. this.pageIndex,
  29499. 'JpegStream',
  29500. image.getIR(this.options.forceDataSchema)
  29501. ]);
  29502. return;
  29503. }
  29504. var nativeImageDecoder = null;
  29505. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  29506. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  29507. }
  29508. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  29509. var imgData = imageObj.createImageData(false);
  29510. self.handler.send('obj', [
  29511. objId,
  29512. self.pageIndex,
  29513. 'Image',
  29514. imgData
  29515. ], [imgData.data.buffer]);
  29516. }).then(undefined, function (reason) {
  29517. warn('Unable to decode image: ' + reason);
  29518. self.handler.send('obj', [
  29519. objId,
  29520. self.pageIndex,
  29521. 'Image',
  29522. null
  29523. ]);
  29524. });
  29525. operatorList.addOp(OPS.paintImageXObject, args);
  29526. if (cacheKey) {
  29527. imageCache[cacheKey] = {
  29528. fn: OPS.paintImageXObject,
  29529. args: args
  29530. };
  29531. }
  29532. },
  29533. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  29534. var smaskContent = smask.get('G');
  29535. var smaskOptions = {
  29536. subtype: smask.get('S').name,
  29537. backdrop: smask.get('BC')
  29538. };
  29539. var transferObj = smask.get('TR');
  29540. if (isPDFFunction(transferObj)) {
  29541. var transferFn = PDFFunction.parse(this.xref, transferObj);
  29542. var transferMap = new Uint8Array(256);
  29543. var tmp = new Float32Array(1);
  29544. for (var i = 0; i < 256; i++) {
  29545. tmp[0] = i / 255;
  29546. transferFn(tmp, 0, tmp, 0);
  29547. transferMap[i] = tmp[0] * 255 | 0;
  29548. }
  29549. smaskOptions.transferMap = transferMap;
  29550. }
  29551. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  29552. },
  29553. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  29554. var tilingOpList = new OperatorList();
  29555. var resourcesArray = [
  29556. patternDict.get('Resources'),
  29557. resources
  29558. ];
  29559. var patternResources = Dict.merge(this.xref, resourcesArray);
  29560. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  29561. operatorList.addDependencies(tilingOpList.dependencies);
  29562. operatorList.addOp(fn, getTilingPatternIR({
  29563. fnArray: tilingOpList.fnArray,
  29564. argsArray: tilingOpList.argsArray
  29565. }, patternDict, args));
  29566. });
  29567. },
  29568. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  29569. var fontName;
  29570. if (fontArgs) {
  29571. fontArgs = fontArgs.slice();
  29572. fontName = fontArgs[0].name;
  29573. }
  29574. var self = this;
  29575. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  29576. if (!translated.font.isType3Font) {
  29577. return translated;
  29578. }
  29579. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  29580. return translated;
  29581. }, function (reason) {
  29582. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29583. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  29584. });
  29585. }).then(function (translated) {
  29586. state.font = translated.font;
  29587. translated.send(self.handler);
  29588. return translated.loadedName;
  29589. });
  29590. },
  29591. handleText: function PartialEvaluator_handleText(chars, state) {
  29592. var font = state.font;
  29593. var glyphs = font.charsToGlyphs(chars);
  29594. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  29595. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  29596. var buildPath = function (fontChar) {
  29597. if (!font.renderer.hasBuiltPath(fontChar)) {
  29598. var path = font.renderer.getPathJs(fontChar);
  29599. this.handler.send('commonobj', [
  29600. font.loadedName + '_path_' + fontChar,
  29601. 'FontPath',
  29602. path
  29603. ]);
  29604. }
  29605. }.bind(this);
  29606. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  29607. var glyph = glyphs[i];
  29608. buildPath(glyph.fontChar);
  29609. var accent = glyph.accent;
  29610. if (accent && accent.fontChar) {
  29611. buildPath(accent.fontChar);
  29612. }
  29613. }
  29614. }
  29615. return glyphs;
  29616. },
  29617. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  29618. var gStateObj = [];
  29619. var gStateKeys = gState.getKeys();
  29620. var self = this;
  29621. var promise = Promise.resolve();
  29622. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  29623. var key = gStateKeys[i];
  29624. var value = gState.get(key);
  29625. switch (key) {
  29626. case 'Type':
  29627. break;
  29628. case 'LW':
  29629. case 'LC':
  29630. case 'LJ':
  29631. case 'ML':
  29632. case 'D':
  29633. case 'RI':
  29634. case 'FL':
  29635. case 'CA':
  29636. case 'ca':
  29637. gStateObj.push([
  29638. key,
  29639. value
  29640. ]);
  29641. break;
  29642. case 'Font':
  29643. promise = promise.then(function () {
  29644. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  29645. operatorList.addDependency(loadedName);
  29646. gStateObj.push([
  29647. key,
  29648. [
  29649. loadedName,
  29650. value[1]
  29651. ]
  29652. ]);
  29653. });
  29654. });
  29655. break;
  29656. case 'BM':
  29657. gStateObj.push([
  29658. key,
  29659. value
  29660. ]);
  29661. break;
  29662. case 'SMask':
  29663. if (isName(value, 'None')) {
  29664. gStateObj.push([
  29665. key,
  29666. false
  29667. ]);
  29668. break;
  29669. }
  29670. if (isDict(value)) {
  29671. promise = promise.then(function (dict) {
  29672. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  29673. }.bind(this, value));
  29674. gStateObj.push([
  29675. key,
  29676. true
  29677. ]);
  29678. } else {
  29679. warn('Unsupported SMask type');
  29680. }
  29681. break;
  29682. case 'OP':
  29683. case 'op':
  29684. case 'OPM':
  29685. case 'BG':
  29686. case 'BG2':
  29687. case 'UCR':
  29688. case 'UCR2':
  29689. case 'TR':
  29690. case 'TR2':
  29691. case 'HT':
  29692. case 'SM':
  29693. case 'SA':
  29694. case 'AIS':
  29695. case 'TK':
  29696. info('graphic state operator ' + key);
  29697. break;
  29698. default:
  29699. info('Unknown graphic state operator ' + key);
  29700. break;
  29701. }
  29702. }
  29703. return promise.then(function () {
  29704. if (gStateObj.length > 0) {
  29705. operatorList.addOp(OPS.setGState, [gStateObj]);
  29706. }
  29707. });
  29708. },
  29709. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  29710. function errorFont() {
  29711. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  29712. }
  29713. var fontRef;
  29714. if (font) {
  29715. assert(isRef(font));
  29716. fontRef = font;
  29717. } else {
  29718. var fontRes = resources.get('Font');
  29719. if (fontRes) {
  29720. fontRef = fontRes.getRaw(fontName);
  29721. } else {
  29722. warn('fontRes not available');
  29723. return errorFont();
  29724. }
  29725. }
  29726. if (!fontRef) {
  29727. warn('fontRef not available');
  29728. return errorFont();
  29729. }
  29730. if (this.fontCache.has(fontRef)) {
  29731. return this.fontCache.get(fontRef);
  29732. }
  29733. font = xref.fetchIfRef(fontRef);
  29734. if (!isDict(font)) {
  29735. return errorFont();
  29736. }
  29737. if (font.translated) {
  29738. return font.translated;
  29739. }
  29740. var fontCapability = createPromiseCapability();
  29741. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  29742. var descriptor = preEvaluatedFont.descriptor;
  29743. var fontRefIsRef = isRef(fontRef), fontID;
  29744. if (fontRefIsRef) {
  29745. fontID = fontRef.toString();
  29746. }
  29747. if (isDict(descriptor)) {
  29748. if (!descriptor.fontAliases) {
  29749. descriptor.fontAliases = Object.create(null);
  29750. }
  29751. var fontAliases = descriptor.fontAliases;
  29752. var hash = preEvaluatedFont.hash;
  29753. if (fontAliases[hash]) {
  29754. var aliasFontRef = fontAliases[hash].aliasRef;
  29755. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  29756. this.fontCache.putAlias(fontRef, aliasFontRef);
  29757. return this.fontCache.get(fontRef);
  29758. }
  29759. } else {
  29760. fontAliases[hash] = { fontID: Font.getFontID() };
  29761. }
  29762. if (fontRefIsRef) {
  29763. fontAliases[hash].aliasRef = fontRef;
  29764. }
  29765. fontID = fontAliases[hash].fontID;
  29766. }
  29767. if (fontRefIsRef) {
  29768. this.fontCache.put(fontRef, fontCapability.promise);
  29769. } else {
  29770. if (!fontID) {
  29771. fontID = this.idFactory.createObjId();
  29772. }
  29773. this.fontCache.put('id_' + fontID, fontCapability.promise);
  29774. }
  29775. assert(fontID, 'The "fontID" must be defined.');
  29776. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  29777. font.translated = fontCapability.promise;
  29778. var translatedPromise;
  29779. try {
  29780. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  29781. } catch (e) {
  29782. translatedPromise = Promise.reject(e);
  29783. }
  29784. var self = this;
  29785. translatedPromise.then(function (translatedFont) {
  29786. if (translatedFont.fontType !== undefined) {
  29787. var xrefFontStats = xref.stats.fontTypes;
  29788. xrefFontStats[translatedFont.fontType] = true;
  29789. }
  29790. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29791. }, function (reason) {
  29792. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29793. try {
  29794. var descriptor = preEvaluatedFont.descriptor;
  29795. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29796. var subtype = fontFile3 && fontFile3.get('Subtype');
  29797. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29798. var xrefFontStats = xref.stats.fontTypes;
  29799. xrefFontStats[fontType] = true;
  29800. } catch (ex) {
  29801. }
  29802. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29803. });
  29804. return fontCapability.promise;
  29805. },
  29806. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29807. var lastIndex = operatorList.length - 1;
  29808. if (!args) {
  29809. args = [];
  29810. }
  29811. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29812. operatorList.addOp(OPS.constructPath, [
  29813. [fn],
  29814. args
  29815. ]);
  29816. } else {
  29817. var opArgs = operatorList.argsArray[lastIndex];
  29818. opArgs[0].push(fn);
  29819. Array.prototype.push.apply(opArgs[1], args);
  29820. }
  29821. },
  29822. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29823. var patternName = args[args.length - 1];
  29824. var pattern;
  29825. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29826. var dict = isStream(pattern) ? pattern.dict : pattern;
  29827. var typeNum = dict.get('PatternType');
  29828. if (typeNum === TILING_PATTERN) {
  29829. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29830. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29831. } else if (typeNum === SHADING_PATTERN) {
  29832. var shading = dict.get('Shading');
  29833. var matrix = dict.getArray('Matrix');
  29834. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29835. operatorList.addOp(fn, pattern.getIR());
  29836. return Promise.resolve();
  29837. }
  29838. return Promise.reject('Unknown PatternType: ' + typeNum);
  29839. }
  29840. operatorList.addOp(fn, args);
  29841. return Promise.resolve();
  29842. },
  29843. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29844. var self = this;
  29845. var xref = this.xref;
  29846. var imageCache = Object.create(null);
  29847. assert(operatorList);
  29848. resources = resources || Dict.empty;
  29849. var xobjs = resources.get('XObject') || Dict.empty;
  29850. var patterns = resources.get('Pattern') || Dict.empty;
  29851. var stateManager = new StateManager(initialState || new EvalState());
  29852. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29853. var timeSlotManager = new TimeSlotManager();
  29854. return new Promise(function promiseBody(resolve, reject) {
  29855. var next = function (promise) {
  29856. promise.then(function () {
  29857. try {
  29858. promiseBody(resolve, reject);
  29859. } catch (ex) {
  29860. reject(ex);
  29861. }
  29862. }, reject);
  29863. };
  29864. task.ensureNotTerminated();
  29865. timeSlotManager.reset();
  29866. var stop, operation = {}, i, ii, cs;
  29867. while (!(stop = timeSlotManager.check())) {
  29868. operation.args = null;
  29869. if (!preprocessor.read(operation)) {
  29870. break;
  29871. }
  29872. var args = operation.args;
  29873. var fn = operation.fn;
  29874. switch (fn | 0) {
  29875. case OPS.paintXObject:
  29876. if (args[0].code) {
  29877. break;
  29878. }
  29879. var name = args[0].name;
  29880. if (!name) {
  29881. warn('XObject must be referred to by name.');
  29882. continue;
  29883. }
  29884. if (imageCache[name] !== undefined) {
  29885. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29886. args = null;
  29887. continue;
  29888. }
  29889. var xobj = xobjs.get(name);
  29890. if (xobj) {
  29891. assert(isStream(xobj), 'XObject should be a stream');
  29892. var type = xobj.dict.get('Subtype');
  29893. assert(isName(type), 'XObject should have a Name subtype');
  29894. if (type.name === 'Form') {
  29895. stateManager.save();
  29896. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29897. stateManager.restore();
  29898. }));
  29899. return;
  29900. } else if (type.name === 'Image') {
  29901. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29902. args = null;
  29903. continue;
  29904. } else if (type.name === 'PS') {
  29905. info('Ignored XObject subtype PS');
  29906. continue;
  29907. } else {
  29908. error('Unhandled XObject subtype ' + type.name);
  29909. }
  29910. }
  29911. break;
  29912. case OPS.setFont:
  29913. var fontSize = args[1];
  29914. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29915. operatorList.addDependency(loadedName);
  29916. operatorList.addOp(OPS.setFont, [
  29917. loadedName,
  29918. fontSize
  29919. ]);
  29920. }));
  29921. return;
  29922. case OPS.endInlineImage:
  29923. var cacheKey = args[0].cacheKey;
  29924. if (cacheKey) {
  29925. var cacheEntry = imageCache[cacheKey];
  29926. if (cacheEntry !== undefined) {
  29927. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29928. args = null;
  29929. continue;
  29930. }
  29931. }
  29932. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29933. args = null;
  29934. continue;
  29935. case OPS.showText:
  29936. args[0] = self.handleText(args[0], stateManager.state);
  29937. break;
  29938. case OPS.showSpacedText:
  29939. var arr = args[0];
  29940. var combinedGlyphs = [];
  29941. var arrLength = arr.length;
  29942. var state = stateManager.state;
  29943. for (i = 0; i < arrLength; ++i) {
  29944. var arrItem = arr[i];
  29945. if (isString(arrItem)) {
  29946. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29947. } else if (isNum(arrItem)) {
  29948. combinedGlyphs.push(arrItem);
  29949. }
  29950. }
  29951. args[0] = combinedGlyphs;
  29952. fn = OPS.showText;
  29953. break;
  29954. case OPS.nextLineShowText:
  29955. operatorList.addOp(OPS.nextLine);
  29956. args[0] = self.handleText(args[0], stateManager.state);
  29957. fn = OPS.showText;
  29958. break;
  29959. case OPS.nextLineSetSpacingShowText:
  29960. operatorList.addOp(OPS.nextLine);
  29961. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29962. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29963. args[0] = self.handleText(args[0], stateManager.state);
  29964. fn = OPS.showText;
  29965. break;
  29966. case OPS.setTextRenderingMode:
  29967. stateManager.state.textRenderingMode = args[0];
  29968. break;
  29969. case OPS.setFillColorSpace:
  29970. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29971. continue;
  29972. case OPS.setStrokeColorSpace:
  29973. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29974. continue;
  29975. case OPS.setFillColor:
  29976. cs = stateManager.state.fillColorSpace;
  29977. args = cs.getRgb(args, 0);
  29978. fn = OPS.setFillRGBColor;
  29979. break;
  29980. case OPS.setStrokeColor:
  29981. cs = stateManager.state.strokeColorSpace;
  29982. args = cs.getRgb(args, 0);
  29983. fn = OPS.setStrokeRGBColor;
  29984. break;
  29985. case OPS.setFillGray:
  29986. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29987. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29988. fn = OPS.setFillRGBColor;
  29989. break;
  29990. case OPS.setStrokeGray:
  29991. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29992. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29993. fn = OPS.setStrokeRGBColor;
  29994. break;
  29995. case OPS.setFillCMYKColor:
  29996. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29997. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29998. fn = OPS.setFillRGBColor;
  29999. break;
  30000. case OPS.setStrokeCMYKColor:
  30001. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  30002. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30003. fn = OPS.setStrokeRGBColor;
  30004. break;
  30005. case OPS.setFillRGBColor:
  30006. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  30007. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30008. break;
  30009. case OPS.setStrokeRGBColor:
  30010. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  30011. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30012. break;
  30013. case OPS.setFillColorN:
  30014. cs = stateManager.state.fillColorSpace;
  30015. if (cs.name === 'Pattern') {
  30016. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  30017. return;
  30018. }
  30019. args = cs.getRgb(args, 0);
  30020. fn = OPS.setFillRGBColor;
  30021. break;
  30022. case OPS.setStrokeColorN:
  30023. cs = stateManager.state.strokeColorSpace;
  30024. if (cs.name === 'Pattern') {
  30025. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  30026. return;
  30027. }
  30028. args = cs.getRgb(args, 0);
  30029. fn = OPS.setStrokeRGBColor;
  30030. break;
  30031. case OPS.shadingFill:
  30032. var shadingRes = resources.get('Shading');
  30033. if (!shadingRes) {
  30034. error('No shading resource found');
  30035. }
  30036. var shading = shadingRes.get(args[0].name);
  30037. if (!shading) {
  30038. error('No shading object found');
  30039. }
  30040. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  30041. var patternIR = shadingFill.getIR();
  30042. args = [patternIR];
  30043. fn = OPS.shadingFill;
  30044. break;
  30045. case OPS.setGState:
  30046. var dictName = args[0];
  30047. var extGState = resources.get('ExtGState');
  30048. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  30049. break;
  30050. }
  30051. var gState = extGState.get(dictName.name);
  30052. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  30053. return;
  30054. case OPS.moveTo:
  30055. case OPS.lineTo:
  30056. case OPS.curveTo:
  30057. case OPS.curveTo2:
  30058. case OPS.curveTo3:
  30059. case OPS.closePath:
  30060. self.buildPath(operatorList, fn, args);
  30061. continue;
  30062. case OPS.rectangle:
  30063. self.buildPath(operatorList, fn, args);
  30064. continue;
  30065. case OPS.markPoint:
  30066. case OPS.markPointProps:
  30067. case OPS.beginMarkedContent:
  30068. case OPS.beginMarkedContentProps:
  30069. case OPS.endMarkedContent:
  30070. case OPS.beginCompat:
  30071. case OPS.endCompat:
  30072. continue;
  30073. default:
  30074. if (args !== null) {
  30075. for (i = 0, ii = args.length; i < ii; i++) {
  30076. if (args[i] instanceof Dict) {
  30077. break;
  30078. }
  30079. }
  30080. if (i < ii) {
  30081. warn('getOperatorList - ignoring operator: ' + fn);
  30082. continue;
  30083. }
  30084. }
  30085. }
  30086. operatorList.addOp(fn, args);
  30087. }
  30088. if (stop) {
  30089. next(deferred);
  30090. return;
  30091. }
  30092. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30093. operatorList.addOp(OPS.restore, []);
  30094. }
  30095. resolve();
  30096. });
  30097. },
  30098. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30099. stateManager = stateManager || new StateManager(new TextState());
  30100. var WhitespaceRegexp = /\s/g;
  30101. var textContent = {
  30102. items: [],
  30103. styles: Object.create(null)
  30104. };
  30105. var textContentItem = {
  30106. initialized: false,
  30107. str: [],
  30108. width: 0,
  30109. height: 0,
  30110. vertical: false,
  30111. lastAdvanceWidth: 0,
  30112. lastAdvanceHeight: 0,
  30113. textAdvanceScale: 0,
  30114. spaceWidth: 0,
  30115. fakeSpaceMin: Infinity,
  30116. fakeMultiSpaceMin: Infinity,
  30117. fakeMultiSpaceMax: -0,
  30118. textRunBreakAllowed: false,
  30119. transform: null,
  30120. fontName: null
  30121. };
  30122. var SPACE_FACTOR = 0.3;
  30123. var MULTI_SPACE_FACTOR = 1.5;
  30124. var MULTI_SPACE_FACTOR_MAX = 4;
  30125. var self = this;
  30126. var xref = this.xref;
  30127. resources = xref.fetchIfRef(resources) || Dict.empty;
  30128. var xobjs = null;
  30129. var xobjsCache = Object.create(null);
  30130. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30131. var textState;
  30132. function ensureTextContentItem() {
  30133. if (textContentItem.initialized) {
  30134. return textContentItem;
  30135. }
  30136. var font = textState.font;
  30137. if (!(font.loadedName in textContent.styles)) {
  30138. textContent.styles[font.loadedName] = {
  30139. fontFamily: font.fallbackName,
  30140. ascent: font.ascent,
  30141. descent: font.descent,
  30142. vertical: font.vertical
  30143. };
  30144. }
  30145. textContentItem.fontName = font.loadedName;
  30146. var tsm = [
  30147. textState.fontSize * textState.textHScale,
  30148. 0,
  30149. 0,
  30150. textState.fontSize,
  30151. 0,
  30152. textState.textRise
  30153. ];
  30154. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30155. var glyphHeight = font.bbox[3] - font.bbox[1];
  30156. if (glyphHeight > 0) {
  30157. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30158. tsm[3] *= glyphHeight;
  30159. }
  30160. }
  30161. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30162. textContentItem.transform = trm;
  30163. if (!font.vertical) {
  30164. textContentItem.width = 0;
  30165. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30166. textContentItem.vertical = false;
  30167. } else {
  30168. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30169. textContentItem.height = 0;
  30170. textContentItem.vertical = true;
  30171. }
  30172. var a = textState.textLineMatrix[0];
  30173. var b = textState.textLineMatrix[1];
  30174. var scaleLineX = Math.sqrt(a * a + b * b);
  30175. a = textState.ctm[0];
  30176. b = textState.ctm[1];
  30177. var scaleCtmX = Math.sqrt(a * a + b * b);
  30178. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30179. textContentItem.lastAdvanceWidth = 0;
  30180. textContentItem.lastAdvanceHeight = 0;
  30181. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30182. if (spaceWidth) {
  30183. textContentItem.spaceWidth = spaceWidth;
  30184. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30185. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30186. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30187. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30188. } else {
  30189. textContentItem.spaceWidth = 0;
  30190. textContentItem.fakeSpaceMin = Infinity;
  30191. textContentItem.fakeMultiSpaceMin = Infinity;
  30192. textContentItem.fakeMultiSpaceMax = 0;
  30193. textContentItem.textRunBreakAllowed = false;
  30194. }
  30195. textContentItem.initialized = true;
  30196. return textContentItem;
  30197. }
  30198. function replaceWhitespace(str) {
  30199. var i = 0, ii = str.length, code;
  30200. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30201. i++;
  30202. }
  30203. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30204. }
  30205. function runBidiTransform(textChunk) {
  30206. var str = textChunk.str.join('');
  30207. var bidiResult = bidi(str, -1, textChunk.vertical);
  30208. return {
  30209. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30210. dir: bidiResult.dir,
  30211. width: textChunk.width,
  30212. height: textChunk.height,
  30213. transform: textChunk.transform,
  30214. fontName: textChunk.fontName
  30215. };
  30216. }
  30217. function handleSetFont(fontName, fontRef) {
  30218. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30219. textState.font = translated.font;
  30220. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30221. });
  30222. }
  30223. function buildTextContentItem(chars) {
  30224. var font = textState.font;
  30225. var textChunk = ensureTextContentItem();
  30226. var width = 0;
  30227. var height = 0;
  30228. var glyphs = font.charsToGlyphs(chars);
  30229. for (var i = 0; i < glyphs.length; i++) {
  30230. var glyph = glyphs[i];
  30231. var glyphWidth = null;
  30232. if (font.vertical && glyph.vmetric) {
  30233. glyphWidth = glyph.vmetric[0];
  30234. } else {
  30235. glyphWidth = glyph.width;
  30236. }
  30237. var glyphUnicode = glyph.unicode;
  30238. var NormalizedUnicodes = getNormalizedUnicodes();
  30239. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30240. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30241. }
  30242. glyphUnicode = reverseIfRtl(glyphUnicode);
  30243. var charSpacing = textState.charSpacing;
  30244. if (glyph.isSpace) {
  30245. var wordSpacing = textState.wordSpacing;
  30246. charSpacing += wordSpacing;
  30247. if (wordSpacing > 0) {
  30248. addFakeSpaces(wordSpacing, textChunk.str);
  30249. }
  30250. }
  30251. var tx = 0;
  30252. var ty = 0;
  30253. if (!font.vertical) {
  30254. var w0 = glyphWidth * textState.fontMatrix[0];
  30255. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30256. width += tx;
  30257. } else {
  30258. var w1 = glyphWidth * textState.fontMatrix[0];
  30259. ty = w1 * textState.fontSize + charSpacing;
  30260. height += ty;
  30261. }
  30262. textState.translateTextMatrix(tx, ty);
  30263. textChunk.str.push(glyphUnicode);
  30264. }
  30265. if (!font.vertical) {
  30266. textChunk.lastAdvanceWidth = width;
  30267. textChunk.width += width;
  30268. } else {
  30269. textChunk.lastAdvanceHeight = height;
  30270. textChunk.height += Math.abs(height);
  30271. }
  30272. return textChunk;
  30273. }
  30274. function addFakeSpaces(width, strBuf) {
  30275. if (width < textContentItem.fakeSpaceMin) {
  30276. return;
  30277. }
  30278. if (width < textContentItem.fakeMultiSpaceMin) {
  30279. strBuf.push(' ');
  30280. return;
  30281. }
  30282. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30283. while (fakeSpaces-- > 0) {
  30284. strBuf.push(' ');
  30285. }
  30286. }
  30287. function flushTextContentItem() {
  30288. if (!textContentItem.initialized) {
  30289. return;
  30290. }
  30291. textContentItem.width *= textContentItem.textAdvanceScale;
  30292. textContentItem.height *= textContentItem.textAdvanceScale;
  30293. textContent.items.push(runBidiTransform(textContentItem));
  30294. textContentItem.initialized = false;
  30295. textContentItem.str.length = 0;
  30296. }
  30297. var timeSlotManager = new TimeSlotManager();
  30298. return new Promise(function promiseBody(resolve, reject) {
  30299. var next = function (promise) {
  30300. promise.then(function () {
  30301. try {
  30302. promiseBody(resolve, reject);
  30303. } catch (ex) {
  30304. reject(ex);
  30305. }
  30306. }, reject);
  30307. };
  30308. task.ensureNotTerminated();
  30309. timeSlotManager.reset();
  30310. var stop, operation = {}, args = [];
  30311. while (!(stop = timeSlotManager.check())) {
  30312. args.length = 0;
  30313. operation.args = args;
  30314. if (!preprocessor.read(operation)) {
  30315. break;
  30316. }
  30317. textState = stateManager.state;
  30318. var fn = operation.fn;
  30319. args = operation.args;
  30320. var advance, diff;
  30321. switch (fn | 0) {
  30322. case OPS.setFont:
  30323. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30324. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30325. break;
  30326. }
  30327. flushTextContentItem();
  30328. textState.fontName = fontNameArg;
  30329. textState.fontSize = fontSizeArg;
  30330. next(handleSetFont(fontNameArg, null));
  30331. return;
  30332. case OPS.setTextRise:
  30333. flushTextContentItem();
  30334. textState.textRise = args[0];
  30335. break;
  30336. case OPS.setHScale:
  30337. flushTextContentItem();
  30338. textState.textHScale = args[0] / 100;
  30339. break;
  30340. case OPS.setLeading:
  30341. flushTextContentItem();
  30342. textState.leading = args[0];
  30343. break;
  30344. case OPS.moveText:
  30345. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30346. advance = args[0] - args[1];
  30347. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  30348. textState.translateTextLineMatrix(args[0], args[1]);
  30349. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  30350. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  30351. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  30352. addFakeSpaces(diff, textContentItem.str);
  30353. break;
  30354. }
  30355. flushTextContentItem();
  30356. textState.translateTextLineMatrix(args[0], args[1]);
  30357. textState.textMatrix = textState.textLineMatrix.slice();
  30358. break;
  30359. case OPS.setLeadingMoveText:
  30360. flushTextContentItem();
  30361. textState.leading = -args[1];
  30362. textState.translateTextLineMatrix(args[0], args[1]);
  30363. textState.textMatrix = textState.textLineMatrix.slice();
  30364. break;
  30365. case OPS.nextLine:
  30366. flushTextContentItem();
  30367. textState.carriageReturn();
  30368. break;
  30369. case OPS.setTextMatrix:
  30370. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  30371. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  30372. textState.translateTextLineMatrix(advance.width, advance.height);
  30373. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  30374. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  30375. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  30376. addFakeSpaces(diff, textContentItem.str);
  30377. break;
  30378. }
  30379. flushTextContentItem();
  30380. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30381. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30382. break;
  30383. case OPS.setCharSpacing:
  30384. textState.charSpacing = args[0];
  30385. break;
  30386. case OPS.setWordSpacing:
  30387. textState.wordSpacing = args[0];
  30388. break;
  30389. case OPS.beginText:
  30390. flushTextContentItem();
  30391. textState.textMatrix = IDENTITY_MATRIX.slice();
  30392. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  30393. break;
  30394. case OPS.showSpacedText:
  30395. var items = args[0];
  30396. var offset;
  30397. for (var j = 0, jj = items.length; j < jj; j++) {
  30398. if (typeof items[j] === 'string') {
  30399. buildTextContentItem(items[j]);
  30400. } else if (isNum(items[j])) {
  30401. ensureTextContentItem();
  30402. advance = items[j] * textState.fontSize / 1000;
  30403. var breakTextRun = false;
  30404. if (textState.font.vertical) {
  30405. offset = advance;
  30406. textState.translateTextMatrix(0, offset);
  30407. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30408. if (!breakTextRun) {
  30409. textContentItem.height += offset;
  30410. }
  30411. } else {
  30412. advance = -advance;
  30413. offset = advance * textState.textHScale;
  30414. textState.translateTextMatrix(offset, 0);
  30415. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30416. if (!breakTextRun) {
  30417. textContentItem.width += offset;
  30418. }
  30419. }
  30420. if (breakTextRun) {
  30421. flushTextContentItem();
  30422. } else if (advance > 0) {
  30423. addFakeSpaces(advance, textContentItem.str);
  30424. }
  30425. }
  30426. }
  30427. break;
  30428. case OPS.showText:
  30429. buildTextContentItem(args[0]);
  30430. break;
  30431. case OPS.nextLineShowText:
  30432. flushTextContentItem();
  30433. textState.carriageReturn();
  30434. buildTextContentItem(args[0]);
  30435. break;
  30436. case OPS.nextLineSetSpacingShowText:
  30437. flushTextContentItem();
  30438. textState.wordSpacing = args[0];
  30439. textState.charSpacing = args[1];
  30440. textState.carriageReturn();
  30441. buildTextContentItem(args[2]);
  30442. break;
  30443. case OPS.paintXObject:
  30444. flushTextContentItem();
  30445. if (args[0].code) {
  30446. break;
  30447. }
  30448. if (!xobjs) {
  30449. xobjs = resources.get('XObject') || Dict.empty;
  30450. }
  30451. var name = args[0].name;
  30452. if (xobjsCache.key === name) {
  30453. if (xobjsCache.texts) {
  30454. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  30455. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  30456. }
  30457. break;
  30458. }
  30459. var xobj = xobjs.get(name);
  30460. if (!xobj) {
  30461. break;
  30462. }
  30463. assert(isStream(xobj), 'XObject should be a stream');
  30464. var type = xobj.dict.get('Subtype');
  30465. assert(isName(type), 'XObject should have a Name subtype');
  30466. if ('Form' !== type.name) {
  30467. xobjsCache.key = name;
  30468. xobjsCache.texts = null;
  30469. break;
  30470. }
  30471. stateManager.save();
  30472. var matrix = xobj.dict.getArray('Matrix');
  30473. if (isArray(matrix) && matrix.length === 6) {
  30474. stateManager.transform(matrix);
  30475. }
  30476. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  30477. Util.appendToArray(textContent.items, formTextContent.items);
  30478. Util.extendObj(textContent.styles, formTextContent.styles);
  30479. stateManager.restore();
  30480. xobjsCache.key = name;
  30481. xobjsCache.texts = formTextContent;
  30482. }));
  30483. return;
  30484. case OPS.setGState:
  30485. flushTextContentItem();
  30486. var dictName = args[0];
  30487. var extGState = resources.get('ExtGState');
  30488. if (!isDict(extGState) || !isName(dictName)) {
  30489. break;
  30490. }
  30491. var gState = extGState.get(dictName.name);
  30492. if (!isDict(gState)) {
  30493. break;
  30494. }
  30495. var gStateFont = gState.get('Font');
  30496. if (gStateFont) {
  30497. textState.fontName = null;
  30498. textState.fontSize = gStateFont[1];
  30499. next(handleSetFont(null, gStateFont[0]));
  30500. return;
  30501. }
  30502. break;
  30503. }
  30504. }
  30505. if (stop) {
  30506. next(deferred);
  30507. return;
  30508. }
  30509. flushTextContentItem();
  30510. resolve(textContent);
  30511. });
  30512. },
  30513. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  30514. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30515. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  30516. if (properties.composite) {
  30517. var cidSystemInfo = dict.get('CIDSystemInfo');
  30518. if (isDict(cidSystemInfo)) {
  30519. properties.cidSystemInfo = {
  30520. registry: cidSystemInfo.get('Registry'),
  30521. ordering: cidSystemInfo.get('Ordering'),
  30522. supplement: cidSystemInfo.get('Supplement')
  30523. };
  30524. }
  30525. var cidToGidMap = dict.get('CIDToGIDMap');
  30526. if (isStream(cidToGidMap)) {
  30527. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  30528. }
  30529. }
  30530. var differences = [];
  30531. var baseEncodingName = null;
  30532. var encoding;
  30533. if (dict.has('Encoding')) {
  30534. encoding = dict.get('Encoding');
  30535. if (isDict(encoding)) {
  30536. baseEncodingName = encoding.get('BaseEncoding');
  30537. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  30538. if (encoding.has('Differences')) {
  30539. var diffEncoding = encoding.get('Differences');
  30540. var index = 0;
  30541. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  30542. var data = xref.fetchIfRef(diffEncoding[j]);
  30543. if (isNum(data)) {
  30544. index = data;
  30545. } else if (isName(data)) {
  30546. differences[index++] = data.name;
  30547. } else {
  30548. error('Invalid entry in \'Differences\' array: ' + data);
  30549. }
  30550. }
  30551. }
  30552. } else if (isName(encoding)) {
  30553. baseEncodingName = encoding.name;
  30554. } else {
  30555. error('Encoding is not a Name nor a Dict');
  30556. }
  30557. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  30558. baseEncodingName = null;
  30559. }
  30560. }
  30561. if (baseEncodingName) {
  30562. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  30563. } else {
  30564. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  30565. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  30566. encoding = StandardEncoding;
  30567. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  30568. encoding = WinAnsiEncoding;
  30569. }
  30570. if (isSymbolicFont) {
  30571. encoding = MacRomanEncoding;
  30572. if (!properties.file) {
  30573. if (/Symbol/i.test(properties.name)) {
  30574. encoding = SymbolSetEncoding;
  30575. } else if (/Dingbats/i.test(properties.name)) {
  30576. encoding = ZapfDingbatsEncoding;
  30577. }
  30578. }
  30579. }
  30580. properties.defaultEncoding = encoding;
  30581. }
  30582. properties.differences = differences;
  30583. properties.baseEncodingName = baseEncodingName;
  30584. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  30585. properties.dict = dict;
  30586. return toUnicodePromise.then(function (toUnicode) {
  30587. properties.toUnicode = toUnicode;
  30588. return this.buildToUnicode(properties);
  30589. }.bind(this)).then(function (toUnicode) {
  30590. properties.toUnicode = toUnicode;
  30591. return properties;
  30592. });
  30593. },
  30594. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  30595. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  30596. if (properties.hasIncludedToUnicodeMap) {
  30597. return Promise.resolve(properties.toUnicode);
  30598. }
  30599. var toUnicode, charcode, glyphName;
  30600. if (!properties.composite) {
  30601. toUnicode = [];
  30602. var encoding = properties.defaultEncoding.slice();
  30603. var baseEncodingName = properties.baseEncodingName;
  30604. var differences = properties.differences;
  30605. for (charcode in differences) {
  30606. glyphName = differences[charcode];
  30607. if (glyphName === '.notdef') {
  30608. continue;
  30609. }
  30610. encoding[charcode] = glyphName;
  30611. }
  30612. var glyphsUnicodeMap = getGlyphsUnicode();
  30613. for (charcode in encoding) {
  30614. glyphName = encoding[charcode];
  30615. if (glyphName === '') {
  30616. continue;
  30617. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  30618. var code = 0;
  30619. switch (glyphName[0]) {
  30620. case 'G':
  30621. if (glyphName.length === 3) {
  30622. code = parseInt(glyphName.substr(1), 16);
  30623. }
  30624. break;
  30625. case 'g':
  30626. if (glyphName.length === 5) {
  30627. code = parseInt(glyphName.substr(1), 16);
  30628. }
  30629. break;
  30630. case 'C':
  30631. case 'c':
  30632. if (glyphName.length >= 3) {
  30633. code = +glyphName.substr(1);
  30634. }
  30635. break;
  30636. default:
  30637. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  30638. if (unicode !== -1) {
  30639. code = unicode;
  30640. }
  30641. }
  30642. if (code) {
  30643. if (baseEncodingName && code === +charcode) {
  30644. var baseEncoding = getEncoding(baseEncodingName);
  30645. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  30646. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30647. continue;
  30648. }
  30649. }
  30650. toUnicode[charcode] = String.fromCharCode(code);
  30651. }
  30652. continue;
  30653. }
  30654. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30655. }
  30656. return Promise.resolve(new ToUnicodeMap(toUnicode));
  30657. }
  30658. 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'))) {
  30659. var registry = properties.cidSystemInfo.registry;
  30660. var ordering = properties.cidSystemInfo.ordering;
  30661. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  30662. return CMapFactory.create({
  30663. encoding: ucs2CMapName,
  30664. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30665. useCMap: null
  30666. }).then(function (ucs2CMap) {
  30667. var cMap = properties.cMap;
  30668. toUnicode = [];
  30669. cMap.forEach(function (charcode, cid) {
  30670. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  30671. var ucs2 = ucs2CMap.lookup(cid);
  30672. if (ucs2) {
  30673. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  30674. }
  30675. });
  30676. return new ToUnicodeMap(toUnicode);
  30677. });
  30678. }
  30679. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  30680. },
  30681. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  30682. var cmapObj = toUnicode;
  30683. if (isName(cmapObj)) {
  30684. return CMapFactory.create({
  30685. encoding: cmapObj,
  30686. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30687. useCMap: null
  30688. }).then(function (cmap) {
  30689. if (cmap instanceof IdentityCMap) {
  30690. return new IdentityToUnicodeMap(0, 0xFFFF);
  30691. }
  30692. return new ToUnicodeMap(cmap.getMap());
  30693. });
  30694. } else if (isStream(cmapObj)) {
  30695. return CMapFactory.create({
  30696. encoding: cmapObj,
  30697. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30698. useCMap: null
  30699. }).then(function (cmap) {
  30700. if (cmap instanceof IdentityCMap) {
  30701. return new IdentityToUnicodeMap(0, 0xFFFF);
  30702. }
  30703. var map = new Array(cmap.length);
  30704. cmap.forEach(function (charCode, token) {
  30705. var str = [];
  30706. for (var k = 0; k < token.length; k += 2) {
  30707. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30708. if ((w1 & 0xF800) !== 0xD800) {
  30709. str.push(w1);
  30710. continue;
  30711. }
  30712. k += 2;
  30713. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30714. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  30715. }
  30716. map[charCode] = String.fromCharCode.apply(String, str);
  30717. });
  30718. return new ToUnicodeMap(map);
  30719. });
  30720. }
  30721. return Promise.resolve(null);
  30722. },
  30723. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  30724. var glyphsData = cidToGidStream.getBytes();
  30725. var result = [];
  30726. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  30727. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  30728. if (glyphID === 0) {
  30729. continue;
  30730. }
  30731. var code = j >> 1;
  30732. result[code] = glyphID;
  30733. }
  30734. return result;
  30735. },
  30736. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  30737. var glyphsWidths = [];
  30738. var defaultWidth = 0;
  30739. var glyphsVMetrics = [];
  30740. var defaultVMetrics;
  30741. var i, ii, j, jj, start, code, widths;
  30742. if (properties.composite) {
  30743. defaultWidth = dict.get('DW') || 1000;
  30744. widths = dict.get('W');
  30745. if (widths) {
  30746. for (i = 0, ii = widths.length; i < ii; i++) {
  30747. start = xref.fetchIfRef(widths[i++]);
  30748. code = xref.fetchIfRef(widths[i]);
  30749. if (isArray(code)) {
  30750. for (j = 0, jj = code.length; j < jj; j++) {
  30751. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  30752. }
  30753. } else {
  30754. var width = xref.fetchIfRef(widths[++i]);
  30755. for (j = start; j <= code; j++) {
  30756. glyphsWidths[j] = width;
  30757. }
  30758. }
  30759. }
  30760. }
  30761. if (properties.vertical) {
  30762. var vmetrics = dict.getArray('DW2') || [
  30763. 880,
  30764. -1000
  30765. ];
  30766. defaultVMetrics = [
  30767. vmetrics[1],
  30768. defaultWidth * 0.5,
  30769. vmetrics[0]
  30770. ];
  30771. vmetrics = dict.get('W2');
  30772. if (vmetrics) {
  30773. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  30774. start = xref.fetchIfRef(vmetrics[i++]);
  30775. code = xref.fetchIfRef(vmetrics[i]);
  30776. if (isArray(code)) {
  30777. for (j = 0, jj = code.length; j < jj; j++) {
  30778. glyphsVMetrics[start++] = [
  30779. xref.fetchIfRef(code[j++]),
  30780. xref.fetchIfRef(code[j++]),
  30781. xref.fetchIfRef(code[j])
  30782. ];
  30783. }
  30784. } else {
  30785. var vmetric = [
  30786. xref.fetchIfRef(vmetrics[++i]),
  30787. xref.fetchIfRef(vmetrics[++i]),
  30788. xref.fetchIfRef(vmetrics[++i])
  30789. ];
  30790. for (j = start; j <= code; j++) {
  30791. glyphsVMetrics[j] = vmetric;
  30792. }
  30793. }
  30794. }
  30795. }
  30796. }
  30797. } else {
  30798. var firstChar = properties.firstChar;
  30799. widths = dict.get('Widths');
  30800. if (widths) {
  30801. j = firstChar;
  30802. for (i = 0, ii = widths.length; i < ii; i++) {
  30803. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30804. }
  30805. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30806. } else {
  30807. var baseFontName = dict.get('BaseFont');
  30808. if (isName(baseFontName)) {
  30809. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30810. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30811. defaultWidth = metrics.defaultWidth;
  30812. }
  30813. }
  30814. }
  30815. var isMonospace = true;
  30816. var firstWidth = defaultWidth;
  30817. for (var glyph in glyphsWidths) {
  30818. var glyphWidth = glyphsWidths[glyph];
  30819. if (!glyphWidth) {
  30820. continue;
  30821. }
  30822. if (!firstWidth) {
  30823. firstWidth = glyphWidth;
  30824. continue;
  30825. }
  30826. if (firstWidth !== glyphWidth) {
  30827. isMonospace = false;
  30828. break;
  30829. }
  30830. }
  30831. if (isMonospace) {
  30832. properties.flags |= FontFlags.FixedPitch;
  30833. }
  30834. properties.defaultWidth = defaultWidth;
  30835. properties.widths = glyphsWidths;
  30836. properties.defaultVMetrics = defaultVMetrics;
  30837. properties.vmetrics = glyphsVMetrics;
  30838. },
  30839. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30840. var fontNameWoStyle = baseFontName.split('-')[0];
  30841. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30842. },
  30843. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30844. var defaultWidth = 0;
  30845. var widths = [];
  30846. var monospace = false;
  30847. var stdFontMap = getStdFontMap();
  30848. var lookupName = stdFontMap[name] || name;
  30849. var Metrics = getMetrics();
  30850. if (!(lookupName in Metrics)) {
  30851. if (this.isSerifFont(name)) {
  30852. lookupName = 'Times-Roman';
  30853. } else {
  30854. lookupName = 'Helvetica';
  30855. }
  30856. }
  30857. var glyphWidths = Metrics[lookupName];
  30858. if (isNum(glyphWidths)) {
  30859. defaultWidth = glyphWidths;
  30860. monospace = true;
  30861. } else {
  30862. widths = glyphWidths();
  30863. }
  30864. return {
  30865. defaultWidth: defaultWidth,
  30866. monospace: monospace,
  30867. widths: widths
  30868. };
  30869. },
  30870. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30871. var widths = Object.create(null);
  30872. var differences = properties.differences;
  30873. var encoding = properties.defaultEncoding;
  30874. for (var charCode = 0; charCode < 256; charCode++) {
  30875. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30876. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30877. continue;
  30878. }
  30879. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30880. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30881. continue;
  30882. }
  30883. }
  30884. return widths;
  30885. },
  30886. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30887. var baseDict = dict;
  30888. var type = dict.get('Subtype');
  30889. assert(isName(type), 'invalid font Subtype');
  30890. var composite = false;
  30891. var uint8array;
  30892. if (type.name === 'Type0') {
  30893. var df = dict.get('DescendantFonts');
  30894. if (!df) {
  30895. error('Descendant fonts are not specified');
  30896. }
  30897. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30898. type = dict.get('Subtype');
  30899. assert(isName(type), 'invalid font Subtype');
  30900. composite = true;
  30901. }
  30902. var descriptor = dict.get('FontDescriptor');
  30903. if (descriptor) {
  30904. var hash = new MurmurHash3_64();
  30905. var encoding = baseDict.getRaw('Encoding');
  30906. if (isName(encoding)) {
  30907. hash.update(encoding.name);
  30908. } else if (isRef(encoding)) {
  30909. hash.update(encoding.toString());
  30910. } else if (isDict(encoding)) {
  30911. var keys = encoding.getKeys();
  30912. for (var i = 0, ii = keys.length; i < ii; i++) {
  30913. var entry = encoding.getRaw(keys[i]);
  30914. if (isName(entry)) {
  30915. hash.update(entry.name);
  30916. } else if (isRef(entry)) {
  30917. hash.update(entry.toString());
  30918. } else if (isArray(entry)) {
  30919. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30920. for (var j = 0; j < diffLength; j++) {
  30921. var diffEntry = entry[j];
  30922. if (isName(diffEntry)) {
  30923. diffBuf[j] = diffEntry.name;
  30924. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30925. diffBuf[j] = diffEntry.toString();
  30926. }
  30927. }
  30928. hash.update(diffBuf.join());
  30929. }
  30930. }
  30931. }
  30932. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30933. if (isStream(toUnicode)) {
  30934. var stream = toUnicode.str || toUnicode;
  30935. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30936. hash.update(uint8array);
  30937. } else if (isName(toUnicode)) {
  30938. hash.update(toUnicode.name);
  30939. }
  30940. var widths = dict.get('Widths') || baseDict.get('Widths');
  30941. if (widths) {
  30942. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30943. hash.update(uint8array);
  30944. }
  30945. }
  30946. return {
  30947. descriptor: descriptor,
  30948. dict: dict,
  30949. baseDict: baseDict,
  30950. composite: composite,
  30951. type: type.name,
  30952. hash: hash ? hash.hexdigest() : ''
  30953. };
  30954. },
  30955. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30956. var baseDict = preEvaluatedFont.baseDict;
  30957. var dict = preEvaluatedFont.dict;
  30958. var composite = preEvaluatedFont.composite;
  30959. var descriptor = preEvaluatedFont.descriptor;
  30960. var type = preEvaluatedFont.type;
  30961. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30962. var properties;
  30963. if (!descriptor) {
  30964. if (type === 'Type3') {
  30965. descriptor = new Dict(null);
  30966. descriptor.set('FontName', Name.get(type));
  30967. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30968. } else {
  30969. var baseFontName = dict.get('BaseFont');
  30970. if (!isName(baseFontName)) {
  30971. error('Base font is not specified');
  30972. }
  30973. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30974. var metrics = this.getBaseFontMetrics(baseFontName);
  30975. var fontNameWoStyle = baseFontName.split('-')[0];
  30976. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30977. properties = {
  30978. type: type,
  30979. name: baseFontName,
  30980. widths: metrics.widths,
  30981. defaultWidth: metrics.defaultWidth,
  30982. flags: flags,
  30983. firstChar: 0,
  30984. lastChar: maxCharIndex
  30985. };
  30986. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30987. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30988. return new Font(baseFontName, null, properties);
  30989. }.bind(this));
  30990. }
  30991. }
  30992. var firstChar = dict.get('FirstChar') || 0;
  30993. var lastChar = dict.get('LastChar') || maxCharIndex;
  30994. var fontName = descriptor.get('FontName');
  30995. var baseFont = dict.get('BaseFont');
  30996. if (isString(fontName)) {
  30997. fontName = Name.get(fontName);
  30998. }
  30999. if (isString(baseFont)) {
  31000. baseFont = Name.get(baseFont);
  31001. }
  31002. if (type !== 'Type3') {
  31003. var fontNameStr = fontName && fontName.name;
  31004. var baseFontStr = baseFont && baseFont.name;
  31005. if (fontNameStr !== baseFontStr) {
  31006. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  31007. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  31008. fontName = baseFont;
  31009. }
  31010. }
  31011. }
  31012. fontName = fontName || baseFont;
  31013. assert(isName(fontName), 'invalid font name');
  31014. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  31015. if (fontFile) {
  31016. if (fontFile.dict) {
  31017. var subtype = fontFile.dict.get('Subtype');
  31018. if (subtype) {
  31019. subtype = subtype.name;
  31020. }
  31021. var length1 = fontFile.dict.get('Length1');
  31022. var length2 = fontFile.dict.get('Length2');
  31023. var length3 = fontFile.dict.get('Length3');
  31024. }
  31025. }
  31026. properties = {
  31027. type: type,
  31028. name: fontName.name,
  31029. subtype: subtype,
  31030. file: fontFile,
  31031. length1: length1,
  31032. length2: length2,
  31033. length3: length3,
  31034. loadedName: baseDict.loadedName,
  31035. composite: composite,
  31036. wideChars: composite,
  31037. fixedPitch: false,
  31038. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  31039. firstChar: firstChar || 0,
  31040. lastChar: lastChar || maxCharIndex,
  31041. bbox: descriptor.getArray('FontBBox'),
  31042. ascent: descriptor.get('Ascent'),
  31043. descent: descriptor.get('Descent'),
  31044. xHeight: descriptor.get('XHeight'),
  31045. capHeight: descriptor.get('CapHeight'),
  31046. flags: descriptor.get('Flags'),
  31047. italicAngle: descriptor.get('ItalicAngle'),
  31048. coded: false
  31049. };
  31050. var cMapPromise;
  31051. if (composite) {
  31052. var cidEncoding = baseDict.get('Encoding');
  31053. if (isName(cidEncoding)) {
  31054. properties.cidEncoding = cidEncoding.name;
  31055. }
  31056. cMapPromise = CMapFactory.create({
  31057. encoding: cidEncoding,
  31058. fetchBuiltInCMap: this.fetchBuiltInCMap,
  31059. useCMap: null
  31060. }).then(function (cMap) {
  31061. properties.cMap = cMap;
  31062. properties.vertical = properties.cMap.vertical;
  31063. });
  31064. } else {
  31065. cMapPromise = Promise.resolve(undefined);
  31066. }
  31067. return cMapPromise.then(function () {
  31068. return this.extractDataStructures(dict, baseDict, xref, properties);
  31069. }.bind(this)).then(function (properties) {
  31070. this.extractWidths(dict, xref, descriptor, properties);
  31071. if (type === 'Type3') {
  31072. properties.isType3Font = true;
  31073. }
  31074. return new Font(fontName.name, fontFile, properties);
  31075. }.bind(this));
  31076. }
  31077. };
  31078. return PartialEvaluator;
  31079. }();
  31080. var TranslatedFont = function TranslatedFontClosure() {
  31081. function TranslatedFont(loadedName, font, dict) {
  31082. this.loadedName = loadedName;
  31083. this.font = font;
  31084. this.dict = dict;
  31085. this.type3Loaded = null;
  31086. this.sent = false;
  31087. }
  31088. TranslatedFont.prototype = {
  31089. send: function (handler) {
  31090. if (this.sent) {
  31091. return;
  31092. }
  31093. var fontData = this.font.exportData();
  31094. handler.send('commonobj', [
  31095. this.loadedName,
  31096. 'Font',
  31097. fontData
  31098. ]);
  31099. this.sent = true;
  31100. },
  31101. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31102. assert(this.font.isType3Font);
  31103. if (this.type3Loaded) {
  31104. return this.type3Loaded;
  31105. }
  31106. var translatedFont = this.font;
  31107. var loadCharProcsPromise = Promise.resolve();
  31108. var charProcs = this.dict.get('CharProcs');
  31109. var fontResources = this.dict.get('Resources') || resources;
  31110. var charProcKeys = charProcs.getKeys();
  31111. var charProcOperatorList = Object.create(null);
  31112. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31113. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31114. var glyphStream = charProcs.get(key);
  31115. var operatorList = new OperatorList();
  31116. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31117. charProcOperatorList[key] = operatorList.getIR();
  31118. parentOperatorList.addDependencies(operatorList.dependencies);
  31119. }, function (reason) {
  31120. warn('Type3 font resource \"' + key + '\" is not available');
  31121. var operatorList = new OperatorList();
  31122. charProcOperatorList[key] = operatorList.getIR();
  31123. });
  31124. }.bind(this, charProcKeys[i]));
  31125. }
  31126. this.type3Loaded = loadCharProcsPromise.then(function () {
  31127. translatedFont.charProcOperatorList = charProcOperatorList;
  31128. });
  31129. return this.type3Loaded;
  31130. }
  31131. };
  31132. return TranslatedFont;
  31133. }();
  31134. var OperatorList = function OperatorListClosure() {
  31135. var CHUNK_SIZE = 1000;
  31136. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31137. function getTransfers(queue) {
  31138. var transfers = [];
  31139. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31140. for (var i = 0, ii = queue.length; i < ii; i++) {
  31141. switch (fnArray[i]) {
  31142. case OPS.paintInlineImageXObject:
  31143. case OPS.paintInlineImageXObjectGroup:
  31144. case OPS.paintImageMaskXObject:
  31145. var arg = argsArray[i][0];
  31146. if (!arg.cached) {
  31147. transfers.push(arg.data.buffer);
  31148. }
  31149. break;
  31150. }
  31151. }
  31152. return transfers;
  31153. }
  31154. function OperatorList(intent, messageHandler, pageIndex) {
  31155. this.messageHandler = messageHandler;
  31156. this.fnArray = [];
  31157. this.argsArray = [];
  31158. this.dependencies = Object.create(null);
  31159. this._totalLength = 0;
  31160. this.pageIndex = pageIndex;
  31161. this.intent = intent;
  31162. }
  31163. OperatorList.prototype = {
  31164. get length() {
  31165. return this.argsArray.length;
  31166. },
  31167. get totalLength() {
  31168. return this._totalLength + this.length;
  31169. },
  31170. addOp: function (fn, args) {
  31171. this.fnArray.push(fn);
  31172. this.argsArray.push(args);
  31173. if (this.messageHandler) {
  31174. if (this.fnArray.length >= CHUNK_SIZE) {
  31175. this.flush();
  31176. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31177. this.flush();
  31178. }
  31179. }
  31180. },
  31181. addDependency: function (dependency) {
  31182. if (dependency in this.dependencies) {
  31183. return;
  31184. }
  31185. this.dependencies[dependency] = true;
  31186. this.addOp(OPS.dependency, [dependency]);
  31187. },
  31188. addDependencies: function (dependencies) {
  31189. for (var key in dependencies) {
  31190. this.addDependency(key);
  31191. }
  31192. },
  31193. addOpList: function (opList) {
  31194. Util.extendObj(this.dependencies, opList.dependencies);
  31195. for (var i = 0, ii = opList.length; i < ii; i++) {
  31196. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31197. }
  31198. },
  31199. getIR: function () {
  31200. return {
  31201. fnArray: this.fnArray,
  31202. argsArray: this.argsArray,
  31203. length: this.length
  31204. };
  31205. },
  31206. flush: function (lastChunk) {
  31207. if (this.intent !== 'oplist') {
  31208. new QueueOptimizer().optimize(this);
  31209. }
  31210. var transfers = getTransfers(this);
  31211. var length = this.length;
  31212. this._totalLength += length;
  31213. this.messageHandler.send('RenderPageChunk', {
  31214. operatorList: {
  31215. fnArray: this.fnArray,
  31216. argsArray: this.argsArray,
  31217. lastChunk: lastChunk,
  31218. length: length
  31219. },
  31220. pageIndex: this.pageIndex,
  31221. intent: this.intent
  31222. }, transfers);
  31223. this.dependencies = Object.create(null);
  31224. this.fnArray.length = 0;
  31225. this.argsArray.length = 0;
  31226. }
  31227. };
  31228. return OperatorList;
  31229. }();
  31230. var StateManager = function StateManagerClosure() {
  31231. function StateManager(initialState) {
  31232. this.state = initialState;
  31233. this.stateStack = [];
  31234. }
  31235. StateManager.prototype = {
  31236. save: function () {
  31237. var old = this.state;
  31238. this.stateStack.push(this.state);
  31239. this.state = old.clone();
  31240. },
  31241. restore: function () {
  31242. var prev = this.stateStack.pop();
  31243. if (prev) {
  31244. this.state = prev;
  31245. }
  31246. },
  31247. transform: function (args) {
  31248. this.state.ctm = Util.transform(this.state.ctm, args);
  31249. }
  31250. };
  31251. return StateManager;
  31252. }();
  31253. var TextState = function TextStateClosure() {
  31254. function TextState() {
  31255. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31256. this.fontName = null;
  31257. this.fontSize = 0;
  31258. this.font = null;
  31259. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31260. this.textMatrix = IDENTITY_MATRIX.slice();
  31261. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31262. this.charSpacing = 0;
  31263. this.wordSpacing = 0;
  31264. this.leading = 0;
  31265. this.textHScale = 1;
  31266. this.textRise = 0;
  31267. }
  31268. TextState.prototype = {
  31269. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31270. var m = this.textMatrix;
  31271. m[0] = a;
  31272. m[1] = b;
  31273. m[2] = c;
  31274. m[3] = d;
  31275. m[4] = e;
  31276. m[5] = f;
  31277. },
  31278. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31279. var m = this.textLineMatrix;
  31280. m[0] = a;
  31281. m[1] = b;
  31282. m[2] = c;
  31283. m[3] = d;
  31284. m[4] = e;
  31285. m[5] = f;
  31286. },
  31287. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31288. var m = this.textMatrix;
  31289. m[4] = m[0] * x + m[2] * y + m[4];
  31290. m[5] = m[1] * x + m[3] * y + m[5];
  31291. },
  31292. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31293. var m = this.textLineMatrix;
  31294. m[4] = m[0] * x + m[2] * y + m[4];
  31295. m[5] = m[1] * x + m[3] * y + m[5];
  31296. },
  31297. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31298. var font = this.font;
  31299. if (!font) {
  31300. return null;
  31301. }
  31302. var m = this.textLineMatrix;
  31303. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31304. return null;
  31305. }
  31306. var txDiff = e - m[4], tyDiff = f - m[5];
  31307. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31308. return null;
  31309. }
  31310. var tx, ty, denominator = a * d - b * c;
  31311. if (font.vertical) {
  31312. tx = -tyDiff * c / denominator;
  31313. ty = tyDiff * a / denominator;
  31314. } else {
  31315. tx = txDiff * d / denominator;
  31316. ty = -txDiff * b / denominator;
  31317. }
  31318. return {
  31319. width: tx,
  31320. height: ty,
  31321. value: font.vertical ? ty : tx
  31322. };
  31323. },
  31324. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31325. var tsm = [
  31326. this.fontSize * this.textHScale,
  31327. 0,
  31328. 0,
  31329. this.fontSize,
  31330. 0,
  31331. this.textRise
  31332. ];
  31333. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31334. },
  31335. carriageReturn: function TextState_carriageReturn() {
  31336. this.translateTextLineMatrix(0, -this.leading);
  31337. this.textMatrix = this.textLineMatrix.slice();
  31338. },
  31339. clone: function TextState_clone() {
  31340. var clone = Object.create(this);
  31341. clone.textMatrix = this.textMatrix.slice();
  31342. clone.textLineMatrix = this.textLineMatrix.slice();
  31343. clone.fontMatrix = this.fontMatrix.slice();
  31344. return clone;
  31345. }
  31346. };
  31347. return TextState;
  31348. }();
  31349. var EvalState = function EvalStateClosure() {
  31350. function EvalState() {
  31351. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31352. this.font = null;
  31353. this.textRenderingMode = TextRenderingMode.FILL;
  31354. this.fillColorSpace = ColorSpace.singletons.gray;
  31355. this.strokeColorSpace = ColorSpace.singletons.gray;
  31356. }
  31357. EvalState.prototype = {
  31358. clone: function CanvasExtraState_clone() {
  31359. return Object.create(this);
  31360. }
  31361. };
  31362. return EvalState;
  31363. }();
  31364. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  31365. var getOPMap = getLookupTableFactory(function (t) {
  31366. t['w'] = {
  31367. id: OPS.setLineWidth,
  31368. numArgs: 1,
  31369. variableArgs: false
  31370. };
  31371. t['J'] = {
  31372. id: OPS.setLineCap,
  31373. numArgs: 1,
  31374. variableArgs: false
  31375. };
  31376. t['j'] = {
  31377. id: OPS.setLineJoin,
  31378. numArgs: 1,
  31379. variableArgs: false
  31380. };
  31381. t['M'] = {
  31382. id: OPS.setMiterLimit,
  31383. numArgs: 1,
  31384. variableArgs: false
  31385. };
  31386. t['d'] = {
  31387. id: OPS.setDash,
  31388. numArgs: 2,
  31389. variableArgs: false
  31390. };
  31391. t['ri'] = {
  31392. id: OPS.setRenderingIntent,
  31393. numArgs: 1,
  31394. variableArgs: false
  31395. };
  31396. t['i'] = {
  31397. id: OPS.setFlatness,
  31398. numArgs: 1,
  31399. variableArgs: false
  31400. };
  31401. t['gs'] = {
  31402. id: OPS.setGState,
  31403. numArgs: 1,
  31404. variableArgs: false
  31405. };
  31406. t['q'] = {
  31407. id: OPS.save,
  31408. numArgs: 0,
  31409. variableArgs: false
  31410. };
  31411. t['Q'] = {
  31412. id: OPS.restore,
  31413. numArgs: 0,
  31414. variableArgs: false
  31415. };
  31416. t['cm'] = {
  31417. id: OPS.transform,
  31418. numArgs: 6,
  31419. variableArgs: false
  31420. };
  31421. t['m'] = {
  31422. id: OPS.moveTo,
  31423. numArgs: 2,
  31424. variableArgs: false
  31425. };
  31426. t['l'] = {
  31427. id: OPS.lineTo,
  31428. numArgs: 2,
  31429. variableArgs: false
  31430. };
  31431. t['c'] = {
  31432. id: OPS.curveTo,
  31433. numArgs: 6,
  31434. variableArgs: false
  31435. };
  31436. t['v'] = {
  31437. id: OPS.curveTo2,
  31438. numArgs: 4,
  31439. variableArgs: false
  31440. };
  31441. t['y'] = {
  31442. id: OPS.curveTo3,
  31443. numArgs: 4,
  31444. variableArgs: false
  31445. };
  31446. t['h'] = {
  31447. id: OPS.closePath,
  31448. numArgs: 0,
  31449. variableArgs: false
  31450. };
  31451. t['re'] = {
  31452. id: OPS.rectangle,
  31453. numArgs: 4,
  31454. variableArgs: false
  31455. };
  31456. t['S'] = {
  31457. id: OPS.stroke,
  31458. numArgs: 0,
  31459. variableArgs: false
  31460. };
  31461. t['s'] = {
  31462. id: OPS.closeStroke,
  31463. numArgs: 0,
  31464. variableArgs: false
  31465. };
  31466. t['f'] = {
  31467. id: OPS.fill,
  31468. numArgs: 0,
  31469. variableArgs: false
  31470. };
  31471. t['F'] = {
  31472. id: OPS.fill,
  31473. numArgs: 0,
  31474. variableArgs: false
  31475. };
  31476. t['f*'] = {
  31477. id: OPS.eoFill,
  31478. numArgs: 0,
  31479. variableArgs: false
  31480. };
  31481. t['B'] = {
  31482. id: OPS.fillStroke,
  31483. numArgs: 0,
  31484. variableArgs: false
  31485. };
  31486. t['B*'] = {
  31487. id: OPS.eoFillStroke,
  31488. numArgs: 0,
  31489. variableArgs: false
  31490. };
  31491. t['b'] = {
  31492. id: OPS.closeFillStroke,
  31493. numArgs: 0,
  31494. variableArgs: false
  31495. };
  31496. t['b*'] = {
  31497. id: OPS.closeEOFillStroke,
  31498. numArgs: 0,
  31499. variableArgs: false
  31500. };
  31501. t['n'] = {
  31502. id: OPS.endPath,
  31503. numArgs: 0,
  31504. variableArgs: false
  31505. };
  31506. t['W'] = {
  31507. id: OPS.clip,
  31508. numArgs: 0,
  31509. variableArgs: false
  31510. };
  31511. t['W*'] = {
  31512. id: OPS.eoClip,
  31513. numArgs: 0,
  31514. variableArgs: false
  31515. };
  31516. t['BT'] = {
  31517. id: OPS.beginText,
  31518. numArgs: 0,
  31519. variableArgs: false
  31520. };
  31521. t['ET'] = {
  31522. id: OPS.endText,
  31523. numArgs: 0,
  31524. variableArgs: false
  31525. };
  31526. t['Tc'] = {
  31527. id: OPS.setCharSpacing,
  31528. numArgs: 1,
  31529. variableArgs: false
  31530. };
  31531. t['Tw'] = {
  31532. id: OPS.setWordSpacing,
  31533. numArgs: 1,
  31534. variableArgs: false
  31535. };
  31536. t['Tz'] = {
  31537. id: OPS.setHScale,
  31538. numArgs: 1,
  31539. variableArgs: false
  31540. };
  31541. t['TL'] = {
  31542. id: OPS.setLeading,
  31543. numArgs: 1,
  31544. variableArgs: false
  31545. };
  31546. t['Tf'] = {
  31547. id: OPS.setFont,
  31548. numArgs: 2,
  31549. variableArgs: false
  31550. };
  31551. t['Tr'] = {
  31552. id: OPS.setTextRenderingMode,
  31553. numArgs: 1,
  31554. variableArgs: false
  31555. };
  31556. t['Ts'] = {
  31557. id: OPS.setTextRise,
  31558. numArgs: 1,
  31559. variableArgs: false
  31560. };
  31561. t['Td'] = {
  31562. id: OPS.moveText,
  31563. numArgs: 2,
  31564. variableArgs: false
  31565. };
  31566. t['TD'] = {
  31567. id: OPS.setLeadingMoveText,
  31568. numArgs: 2,
  31569. variableArgs: false
  31570. };
  31571. t['Tm'] = {
  31572. id: OPS.setTextMatrix,
  31573. numArgs: 6,
  31574. variableArgs: false
  31575. };
  31576. t['T*'] = {
  31577. id: OPS.nextLine,
  31578. numArgs: 0,
  31579. variableArgs: false
  31580. };
  31581. t['Tj'] = {
  31582. id: OPS.showText,
  31583. numArgs: 1,
  31584. variableArgs: false
  31585. };
  31586. t['TJ'] = {
  31587. id: OPS.showSpacedText,
  31588. numArgs: 1,
  31589. variableArgs: false
  31590. };
  31591. t['\''] = {
  31592. id: OPS.nextLineShowText,
  31593. numArgs: 1,
  31594. variableArgs: false
  31595. };
  31596. t['"'] = {
  31597. id: OPS.nextLineSetSpacingShowText,
  31598. numArgs: 3,
  31599. variableArgs: false
  31600. };
  31601. t['d0'] = {
  31602. id: OPS.setCharWidth,
  31603. numArgs: 2,
  31604. variableArgs: false
  31605. };
  31606. t['d1'] = {
  31607. id: OPS.setCharWidthAndBounds,
  31608. numArgs: 6,
  31609. variableArgs: false
  31610. };
  31611. t['CS'] = {
  31612. id: OPS.setStrokeColorSpace,
  31613. numArgs: 1,
  31614. variableArgs: false
  31615. };
  31616. t['cs'] = {
  31617. id: OPS.setFillColorSpace,
  31618. numArgs: 1,
  31619. variableArgs: false
  31620. };
  31621. t['SC'] = {
  31622. id: OPS.setStrokeColor,
  31623. numArgs: 4,
  31624. variableArgs: true
  31625. };
  31626. t['SCN'] = {
  31627. id: OPS.setStrokeColorN,
  31628. numArgs: 33,
  31629. variableArgs: true
  31630. };
  31631. t['sc'] = {
  31632. id: OPS.setFillColor,
  31633. numArgs: 4,
  31634. variableArgs: true
  31635. };
  31636. t['scn'] = {
  31637. id: OPS.setFillColorN,
  31638. numArgs: 33,
  31639. variableArgs: true
  31640. };
  31641. t['G'] = {
  31642. id: OPS.setStrokeGray,
  31643. numArgs: 1,
  31644. variableArgs: false
  31645. };
  31646. t['g'] = {
  31647. id: OPS.setFillGray,
  31648. numArgs: 1,
  31649. variableArgs: false
  31650. };
  31651. t['RG'] = {
  31652. id: OPS.setStrokeRGBColor,
  31653. numArgs: 3,
  31654. variableArgs: false
  31655. };
  31656. t['rg'] = {
  31657. id: OPS.setFillRGBColor,
  31658. numArgs: 3,
  31659. variableArgs: false
  31660. };
  31661. t['K'] = {
  31662. id: OPS.setStrokeCMYKColor,
  31663. numArgs: 4,
  31664. variableArgs: false
  31665. };
  31666. t['k'] = {
  31667. id: OPS.setFillCMYKColor,
  31668. numArgs: 4,
  31669. variableArgs: false
  31670. };
  31671. t['sh'] = {
  31672. id: OPS.shadingFill,
  31673. numArgs: 1,
  31674. variableArgs: false
  31675. };
  31676. t['BI'] = {
  31677. id: OPS.beginInlineImage,
  31678. numArgs: 0,
  31679. variableArgs: false
  31680. };
  31681. t['ID'] = {
  31682. id: OPS.beginImageData,
  31683. numArgs: 0,
  31684. variableArgs: false
  31685. };
  31686. t['EI'] = {
  31687. id: OPS.endInlineImage,
  31688. numArgs: 1,
  31689. variableArgs: false
  31690. };
  31691. t['Do'] = {
  31692. id: OPS.paintXObject,
  31693. numArgs: 1,
  31694. variableArgs: false
  31695. };
  31696. t['MP'] = {
  31697. id: OPS.markPoint,
  31698. numArgs: 1,
  31699. variableArgs: false
  31700. };
  31701. t['DP'] = {
  31702. id: OPS.markPointProps,
  31703. numArgs: 2,
  31704. variableArgs: false
  31705. };
  31706. t['BMC'] = {
  31707. id: OPS.beginMarkedContent,
  31708. numArgs: 1,
  31709. variableArgs: false
  31710. };
  31711. t['BDC'] = {
  31712. id: OPS.beginMarkedContentProps,
  31713. numArgs: 2,
  31714. variableArgs: false
  31715. };
  31716. t['EMC'] = {
  31717. id: OPS.endMarkedContent,
  31718. numArgs: 0,
  31719. variableArgs: false
  31720. };
  31721. t['BX'] = {
  31722. id: OPS.beginCompat,
  31723. numArgs: 0,
  31724. variableArgs: false
  31725. };
  31726. t['EX'] = {
  31727. id: OPS.endCompat,
  31728. numArgs: 0,
  31729. variableArgs: false
  31730. };
  31731. t['BM'] = null;
  31732. t['BD'] = null;
  31733. t['true'] = null;
  31734. t['fa'] = null;
  31735. t['fal'] = null;
  31736. t['fals'] = null;
  31737. t['false'] = null;
  31738. t['nu'] = null;
  31739. t['nul'] = null;
  31740. t['null'] = null;
  31741. });
  31742. function EvaluatorPreprocessor(stream, xref, stateManager) {
  31743. this.opMap = getOPMap();
  31744. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  31745. this.stateManager = stateManager;
  31746. this.nonProcessedArgs = [];
  31747. }
  31748. EvaluatorPreprocessor.prototype = {
  31749. get savedStatesDepth() {
  31750. return this.stateManager.stateStack.length;
  31751. },
  31752. read: function EvaluatorPreprocessor_read(operation) {
  31753. var args = operation.args;
  31754. while (true) {
  31755. var obj = this.parser.getObj();
  31756. if (isCmd(obj)) {
  31757. var cmd = obj.cmd;
  31758. var opSpec = this.opMap[cmd];
  31759. if (!opSpec) {
  31760. warn('Unknown command "' + cmd + '"');
  31761. continue;
  31762. }
  31763. var fn = opSpec.id;
  31764. var numArgs = opSpec.numArgs;
  31765. var argsLength = args !== null ? args.length : 0;
  31766. if (!opSpec.variableArgs) {
  31767. if (argsLength !== numArgs) {
  31768. var nonProcessedArgs = this.nonProcessedArgs;
  31769. while (argsLength > numArgs) {
  31770. nonProcessedArgs.push(args.shift());
  31771. argsLength--;
  31772. }
  31773. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  31774. if (args === null) {
  31775. args = [];
  31776. }
  31777. args.unshift(nonProcessedArgs.pop());
  31778. argsLength++;
  31779. }
  31780. }
  31781. if (argsLength < numArgs) {
  31782. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31783. if (args !== null) {
  31784. args.length = 0;
  31785. }
  31786. continue;
  31787. }
  31788. } else if (argsLength > numArgs) {
  31789. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31790. }
  31791. this.preprocessCommand(fn, args);
  31792. operation.fn = fn;
  31793. operation.args = args;
  31794. return true;
  31795. }
  31796. if (isEOF(obj)) {
  31797. return false;
  31798. }
  31799. if (obj !== null) {
  31800. if (args === null) {
  31801. args = [];
  31802. }
  31803. args.push(obj);
  31804. assert(args.length <= 33, 'Too many arguments');
  31805. }
  31806. }
  31807. },
  31808. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31809. switch (fn | 0) {
  31810. case OPS.save:
  31811. this.stateManager.save();
  31812. break;
  31813. case OPS.restore:
  31814. this.stateManager.restore();
  31815. break;
  31816. case OPS.transform:
  31817. this.stateManager.transform(args);
  31818. break;
  31819. }
  31820. }
  31821. };
  31822. return EvaluatorPreprocessor;
  31823. }();
  31824. var QueueOptimizer = function QueueOptimizerClosure() {
  31825. function addState(parentState, pattern, fn) {
  31826. var state = parentState;
  31827. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31828. var item = pattern[i];
  31829. state = state[item] || (state[item] = []);
  31830. }
  31831. state[pattern[pattern.length - 1]] = fn;
  31832. }
  31833. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31834. var iFirstPIMXO = iFirstSave + 2;
  31835. for (var i = 0; i < count; i++) {
  31836. var arg = argsArray[iFirstPIMXO + 4 * i];
  31837. var imageMask = arg.length === 1 && arg[0];
  31838. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31839. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31840. continue;
  31841. }
  31842. break;
  31843. }
  31844. return count - i;
  31845. }
  31846. var InitialState = [];
  31847. addState(InitialState, [
  31848. OPS.save,
  31849. OPS.transform,
  31850. OPS.paintInlineImageXObject,
  31851. OPS.restore
  31852. ], function foundInlineImageGroup(context) {
  31853. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31854. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31855. var MAX_WIDTH = 1000;
  31856. var IMAGE_PADDING = 1;
  31857. var fnArray = context.fnArray, argsArray = context.argsArray;
  31858. var curr = context.iCurr;
  31859. var iFirstSave = curr - 3;
  31860. var iFirstTransform = curr - 2;
  31861. var iFirstPIIXO = curr - 1;
  31862. var i = iFirstSave + 4;
  31863. var ii = fnArray.length;
  31864. while (i + 3 < ii) {
  31865. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31866. break;
  31867. }
  31868. i += 4;
  31869. }
  31870. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31871. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31872. return i;
  31873. }
  31874. var maxX = 0;
  31875. var map = [], maxLineHeight = 0;
  31876. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31877. var q;
  31878. for (q = 0; q < count; q++) {
  31879. var transform = argsArray[iFirstTransform + (q << 2)];
  31880. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31881. if (currentX + img.width > MAX_WIDTH) {
  31882. maxX = Math.max(maxX, currentX);
  31883. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31884. currentX = 0;
  31885. maxLineHeight = 0;
  31886. }
  31887. map.push({
  31888. transform: transform,
  31889. x: currentX,
  31890. y: currentY,
  31891. w: img.width,
  31892. h: img.height
  31893. });
  31894. currentX += img.width + 2 * IMAGE_PADDING;
  31895. maxLineHeight = Math.max(maxLineHeight, img.height);
  31896. }
  31897. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31898. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31899. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31900. var imgRowSize = imgWidth << 2;
  31901. for (q = 0; q < count; q++) {
  31902. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31903. var rowSize = map[q].w << 2;
  31904. var dataOffset = 0;
  31905. var offset = map[q].x + map[q].y * imgWidth << 2;
  31906. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31907. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31908. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31909. dataOffset += rowSize;
  31910. offset += imgRowSize;
  31911. }
  31912. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31913. while (offset >= 0) {
  31914. data[offset - 4] = data[offset];
  31915. data[offset - 3] = data[offset + 1];
  31916. data[offset - 2] = data[offset + 2];
  31917. data[offset - 1] = data[offset + 3];
  31918. data[offset + rowSize] = data[offset + rowSize - 4];
  31919. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31920. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31921. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31922. offset -= imgRowSize;
  31923. }
  31924. }
  31925. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31926. argsArray.splice(iFirstSave, count * 4, [
  31927. {
  31928. width: imgWidth,
  31929. height: imgHeight,
  31930. kind: ImageKind.RGBA_32BPP,
  31931. data: imgData
  31932. },
  31933. map
  31934. ]);
  31935. return iFirstSave + 1;
  31936. });
  31937. addState(InitialState, [
  31938. OPS.save,
  31939. OPS.transform,
  31940. OPS.paintImageMaskXObject,
  31941. OPS.restore
  31942. ], function foundImageMaskGroup(context) {
  31943. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31944. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31945. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31946. var fnArray = context.fnArray, argsArray = context.argsArray;
  31947. var curr = context.iCurr;
  31948. var iFirstSave = curr - 3;
  31949. var iFirstTransform = curr - 2;
  31950. var iFirstPIMXO = curr - 1;
  31951. var i = iFirstSave + 4;
  31952. var ii = fnArray.length;
  31953. while (i + 3 < ii) {
  31954. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31955. break;
  31956. }
  31957. i += 4;
  31958. }
  31959. var count = (i - iFirstSave) / 4;
  31960. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31961. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31962. return i;
  31963. }
  31964. var q;
  31965. var isSameImage = false;
  31966. var iTransform, transformArgs;
  31967. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31968. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31969. isSameImage = true;
  31970. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31971. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31972. iTransform = iFirstTransform + 4;
  31973. var iPIMXO = iFirstPIMXO + 4;
  31974. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31975. transformArgs = argsArray[iTransform];
  31976. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31977. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31978. isSameImage = false;
  31979. } else {
  31980. count = q;
  31981. }
  31982. break;
  31983. }
  31984. }
  31985. }
  31986. if (isSameImage) {
  31987. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31988. var positions = new Float32Array(count * 2);
  31989. iTransform = iFirstTransform;
  31990. for (q = 0; q < count; q++, iTransform += 4) {
  31991. transformArgs = argsArray[iTransform];
  31992. positions[q << 1] = transformArgs[4];
  31993. positions[(q << 1) + 1] = transformArgs[5];
  31994. }
  31995. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31996. argsArray.splice(iFirstSave, count * 4, [
  31997. firstPIMXOArg0,
  31998. firstTransformArg0,
  31999. firstTransformArg3,
  32000. positions
  32001. ]);
  32002. } else {
  32003. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  32004. var images = [];
  32005. for (q = 0; q < count; q++) {
  32006. transformArgs = argsArray[iFirstTransform + (q << 2)];
  32007. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  32008. images.push({
  32009. data: maskParams.data,
  32010. width: maskParams.width,
  32011. height: maskParams.height,
  32012. transform: transformArgs
  32013. });
  32014. }
  32015. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  32016. argsArray.splice(iFirstSave, count * 4, [images]);
  32017. }
  32018. return iFirstSave + 1;
  32019. });
  32020. addState(InitialState, [
  32021. OPS.save,
  32022. OPS.transform,
  32023. OPS.paintImageXObject,
  32024. OPS.restore
  32025. ], function (context) {
  32026. var MIN_IMAGES_IN_BLOCK = 3;
  32027. var MAX_IMAGES_IN_BLOCK = 1000;
  32028. var fnArray = context.fnArray, argsArray = context.argsArray;
  32029. var curr = context.iCurr;
  32030. var iFirstSave = curr - 3;
  32031. var iFirstTransform = curr - 2;
  32032. var iFirstPIXO = curr - 1;
  32033. var iFirstRestore = curr;
  32034. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  32035. return iFirstRestore + 1;
  32036. }
  32037. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  32038. var firstTransformArg0 = argsArray[iFirstTransform][0];
  32039. var firstTransformArg3 = argsArray[iFirstTransform][3];
  32040. var i = iFirstSave + 4;
  32041. var ii = fnArray.length;
  32042. while (i + 3 < ii) {
  32043. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  32044. break;
  32045. }
  32046. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  32047. break;
  32048. }
  32049. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  32050. break;
  32051. }
  32052. i += 4;
  32053. }
  32054. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  32055. if (count < MIN_IMAGES_IN_BLOCK) {
  32056. return i;
  32057. }
  32058. var positions = new Float32Array(count * 2);
  32059. var iTransform = iFirstTransform;
  32060. for (var q = 0; q < count; q++, iTransform += 4) {
  32061. var transformArgs = argsArray[iTransform];
  32062. positions[q << 1] = transformArgs[4];
  32063. positions[(q << 1) + 1] = transformArgs[5];
  32064. }
  32065. var args = [
  32066. firstPIXOArg0,
  32067. firstTransformArg0,
  32068. firstTransformArg3,
  32069. positions
  32070. ];
  32071. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  32072. argsArray.splice(iFirstSave, count * 4, args);
  32073. return iFirstSave + 1;
  32074. });
  32075. addState(InitialState, [
  32076. OPS.beginText,
  32077. OPS.setFont,
  32078. OPS.setTextMatrix,
  32079. OPS.showText,
  32080. OPS.endText
  32081. ], function (context) {
  32082. var MIN_CHARS_IN_BLOCK = 3;
  32083. var MAX_CHARS_IN_BLOCK = 1000;
  32084. var fnArray = context.fnArray, argsArray = context.argsArray;
  32085. var curr = context.iCurr;
  32086. var iFirstBeginText = curr - 4;
  32087. var iFirstSetFont = curr - 3;
  32088. var iFirstSetTextMatrix = curr - 2;
  32089. var iFirstShowText = curr - 1;
  32090. var iFirstEndText = curr;
  32091. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32092. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32093. var i = iFirstBeginText + 5;
  32094. var ii = fnArray.length;
  32095. while (i + 4 < ii) {
  32096. 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) {
  32097. break;
  32098. }
  32099. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32100. break;
  32101. }
  32102. i += 5;
  32103. }
  32104. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32105. if (count < MIN_CHARS_IN_BLOCK) {
  32106. return i;
  32107. }
  32108. var iFirst = iFirstBeginText;
  32109. 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) {
  32110. count++;
  32111. iFirst -= 5;
  32112. }
  32113. var iEndText = iFirst + 4;
  32114. for (var q = 1; q < count; q++) {
  32115. fnArray.splice(iEndText, 3);
  32116. argsArray.splice(iEndText, 3);
  32117. iEndText += 2;
  32118. }
  32119. return iEndText + 1;
  32120. });
  32121. function QueueOptimizer() {
  32122. }
  32123. QueueOptimizer.prototype = {
  32124. optimize: function QueueOptimizer_optimize(queue) {
  32125. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32126. var context = {
  32127. iCurr: 0,
  32128. fnArray: fnArray,
  32129. argsArray: argsArray
  32130. };
  32131. var state;
  32132. var i = 0, ii = fnArray.length;
  32133. while (i < ii) {
  32134. state = (state || InitialState)[fnArray[i]];
  32135. if (typeof state === 'function') {
  32136. context.iCurr = i;
  32137. i = state(context);
  32138. state = undefined;
  32139. ii = context.fnArray.length;
  32140. } else {
  32141. i++;
  32142. }
  32143. }
  32144. }
  32145. };
  32146. return QueueOptimizer;
  32147. }();
  32148. exports.OperatorList = OperatorList;
  32149. exports.PartialEvaluator = PartialEvaluator;
  32150. /***/ }),
  32151. /* 18 */
  32152. /***/ (function(module, exports, __w_pdfjs_require__) {
  32153. "use strict";
  32154. var sharedUtil = __w_pdfjs_require__(0);
  32155. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  32156. var info = sharedUtil.info;
  32157. var warn = sharedUtil.warn;
  32158. var error = sharedUtil.error;
  32159. var log2 = sharedUtil.log2;
  32160. var readUint16 = sharedUtil.readUint16;
  32161. var readUint32 = sharedUtil.readUint32;
  32162. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32163. var JpxImage = function JpxImageClosure() {
  32164. var SubbandsGainLog2 = {
  32165. 'LL': 0,
  32166. 'LH': 1,
  32167. 'HL': 1,
  32168. 'HH': 2
  32169. };
  32170. function JpxImage() {
  32171. this.failOnCorruptedImage = false;
  32172. }
  32173. JpxImage.prototype = {
  32174. parse: function JpxImage_parse(data) {
  32175. var head = readUint16(data, 0);
  32176. if (head === 0xFF4F) {
  32177. this.parseCodestream(data, 0, data.length);
  32178. return;
  32179. }
  32180. var position = 0, length = data.length;
  32181. while (position < length) {
  32182. var headerSize = 8;
  32183. var lbox = readUint32(data, position);
  32184. var tbox = readUint32(data, position + 4);
  32185. position += headerSize;
  32186. if (lbox === 1) {
  32187. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32188. position += 8;
  32189. headerSize += 8;
  32190. }
  32191. if (lbox === 0) {
  32192. lbox = length - position + headerSize;
  32193. }
  32194. if (lbox < headerSize) {
  32195. error('JPX Error: Invalid box field size');
  32196. }
  32197. var dataLength = lbox - headerSize;
  32198. var jumpDataLength = true;
  32199. switch (tbox) {
  32200. case 0x6A703268:
  32201. jumpDataLength = false;
  32202. break;
  32203. case 0x636F6C72:
  32204. var method = data[position];
  32205. if (method === 1) {
  32206. var colorspace = readUint32(data, position + 3);
  32207. switch (colorspace) {
  32208. case 16:
  32209. case 17:
  32210. case 18:
  32211. break;
  32212. default:
  32213. warn('Unknown colorspace ' + colorspace);
  32214. break;
  32215. }
  32216. } else if (method === 2) {
  32217. info('ICC profile not supported');
  32218. }
  32219. break;
  32220. case 0x6A703263:
  32221. this.parseCodestream(data, position, position + dataLength);
  32222. break;
  32223. case 0x6A502020:
  32224. if (0x0d0a870a !== readUint32(data, position)) {
  32225. warn('Invalid JP2 signature');
  32226. }
  32227. break;
  32228. case 0x6A501A1A:
  32229. case 0x66747970:
  32230. case 0x72726571:
  32231. case 0x72657320:
  32232. case 0x69686472:
  32233. break;
  32234. default:
  32235. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32236. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32237. break;
  32238. }
  32239. if (jumpDataLength) {
  32240. position += dataLength;
  32241. }
  32242. }
  32243. },
  32244. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32245. var newByte = stream.getByte();
  32246. while (newByte >= 0) {
  32247. var oldByte = newByte;
  32248. newByte = stream.getByte();
  32249. var code = oldByte << 8 | newByte;
  32250. if (code === 0xFF51) {
  32251. stream.skip(4);
  32252. var Xsiz = stream.getInt32() >>> 0;
  32253. var Ysiz = stream.getInt32() >>> 0;
  32254. var XOsiz = stream.getInt32() >>> 0;
  32255. var YOsiz = stream.getInt32() >>> 0;
  32256. stream.skip(16);
  32257. var Csiz = stream.getUint16();
  32258. this.width = Xsiz - XOsiz;
  32259. this.height = Ysiz - YOsiz;
  32260. this.componentsCount = Csiz;
  32261. this.bitsPerComponent = 8;
  32262. return;
  32263. }
  32264. }
  32265. error('JPX Error: No size marker found in JPX stream');
  32266. },
  32267. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32268. var context = {};
  32269. var doNotRecover = false;
  32270. try {
  32271. var position = start;
  32272. while (position + 1 < end) {
  32273. var code = readUint16(data, position);
  32274. position += 2;
  32275. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32276. switch (code) {
  32277. case 0xFF4F:
  32278. context.mainHeader = true;
  32279. break;
  32280. case 0xFFD9:
  32281. break;
  32282. case 0xFF51:
  32283. length = readUint16(data, position);
  32284. var siz = {};
  32285. siz.Xsiz = readUint32(data, position + 4);
  32286. siz.Ysiz = readUint32(data, position + 8);
  32287. siz.XOsiz = readUint32(data, position + 12);
  32288. siz.YOsiz = readUint32(data, position + 16);
  32289. siz.XTsiz = readUint32(data, position + 20);
  32290. siz.YTsiz = readUint32(data, position + 24);
  32291. siz.XTOsiz = readUint32(data, position + 28);
  32292. siz.YTOsiz = readUint32(data, position + 32);
  32293. var componentsCount = readUint16(data, position + 36);
  32294. siz.Csiz = componentsCount;
  32295. var components = [];
  32296. j = position + 38;
  32297. for (var i = 0; i < componentsCount; i++) {
  32298. var component = {
  32299. precision: (data[j] & 0x7F) + 1,
  32300. isSigned: !!(data[j] & 0x80),
  32301. XRsiz: data[j + 1],
  32302. YRsiz: data[j + 1]
  32303. };
  32304. calculateComponentDimensions(component, siz);
  32305. components.push(component);
  32306. }
  32307. context.SIZ = siz;
  32308. context.components = components;
  32309. calculateTileGrids(context, components);
  32310. context.QCC = [];
  32311. context.COC = [];
  32312. break;
  32313. case 0xFF5C:
  32314. length = readUint16(data, position);
  32315. var qcd = {};
  32316. j = position + 2;
  32317. sqcd = data[j++];
  32318. switch (sqcd & 0x1F) {
  32319. case 0:
  32320. spqcdSize = 8;
  32321. scalarExpounded = true;
  32322. break;
  32323. case 1:
  32324. spqcdSize = 16;
  32325. scalarExpounded = false;
  32326. break;
  32327. case 2:
  32328. spqcdSize = 16;
  32329. scalarExpounded = true;
  32330. break;
  32331. default:
  32332. throw new Error('Invalid SQcd value ' + sqcd);
  32333. }
  32334. qcd.noQuantization = spqcdSize === 8;
  32335. qcd.scalarExpounded = scalarExpounded;
  32336. qcd.guardBits = sqcd >> 5;
  32337. spqcds = [];
  32338. while (j < length + position) {
  32339. var spqcd = {};
  32340. if (spqcdSize === 8) {
  32341. spqcd.epsilon = data[j++] >> 3;
  32342. spqcd.mu = 0;
  32343. } else {
  32344. spqcd.epsilon = data[j] >> 3;
  32345. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32346. j += 2;
  32347. }
  32348. spqcds.push(spqcd);
  32349. }
  32350. qcd.SPqcds = spqcds;
  32351. if (context.mainHeader) {
  32352. context.QCD = qcd;
  32353. } else {
  32354. context.currentTile.QCD = qcd;
  32355. context.currentTile.QCC = [];
  32356. }
  32357. break;
  32358. case 0xFF5D:
  32359. length = readUint16(data, position);
  32360. var qcc = {};
  32361. j = position + 2;
  32362. var cqcc;
  32363. if (context.SIZ.Csiz < 257) {
  32364. cqcc = data[j++];
  32365. } else {
  32366. cqcc = readUint16(data, j);
  32367. j += 2;
  32368. }
  32369. sqcd = data[j++];
  32370. switch (sqcd & 0x1F) {
  32371. case 0:
  32372. spqcdSize = 8;
  32373. scalarExpounded = true;
  32374. break;
  32375. case 1:
  32376. spqcdSize = 16;
  32377. scalarExpounded = false;
  32378. break;
  32379. case 2:
  32380. spqcdSize = 16;
  32381. scalarExpounded = true;
  32382. break;
  32383. default:
  32384. throw new Error('Invalid SQcd value ' + sqcd);
  32385. }
  32386. qcc.noQuantization = spqcdSize === 8;
  32387. qcc.scalarExpounded = scalarExpounded;
  32388. qcc.guardBits = sqcd >> 5;
  32389. spqcds = [];
  32390. while (j < length + position) {
  32391. spqcd = {};
  32392. if (spqcdSize === 8) {
  32393. spqcd.epsilon = data[j++] >> 3;
  32394. spqcd.mu = 0;
  32395. } else {
  32396. spqcd.epsilon = data[j] >> 3;
  32397. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32398. j += 2;
  32399. }
  32400. spqcds.push(spqcd);
  32401. }
  32402. qcc.SPqcds = spqcds;
  32403. if (context.mainHeader) {
  32404. context.QCC[cqcc] = qcc;
  32405. } else {
  32406. context.currentTile.QCC[cqcc] = qcc;
  32407. }
  32408. break;
  32409. case 0xFF52:
  32410. length = readUint16(data, position);
  32411. var cod = {};
  32412. j = position + 2;
  32413. var scod = data[j++];
  32414. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  32415. cod.sopMarkerUsed = !!(scod & 2);
  32416. cod.ephMarkerUsed = !!(scod & 4);
  32417. cod.progressionOrder = data[j++];
  32418. cod.layersCount = readUint16(data, j);
  32419. j += 2;
  32420. cod.multipleComponentTransform = data[j++];
  32421. cod.decompositionLevelsCount = data[j++];
  32422. cod.xcb = (data[j++] & 0xF) + 2;
  32423. cod.ycb = (data[j++] & 0xF) + 2;
  32424. var blockStyle = data[j++];
  32425. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  32426. cod.resetContextProbabilities = !!(blockStyle & 2);
  32427. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  32428. cod.verticalyStripe = !!(blockStyle & 8);
  32429. cod.predictableTermination = !!(blockStyle & 16);
  32430. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  32431. cod.reversibleTransformation = data[j++];
  32432. if (cod.entropyCoderWithCustomPrecincts) {
  32433. var precinctsSizes = [];
  32434. while (j < length + position) {
  32435. var precinctsSize = data[j++];
  32436. precinctsSizes.push({
  32437. PPx: precinctsSize & 0xF,
  32438. PPy: precinctsSize >> 4
  32439. });
  32440. }
  32441. cod.precinctsSizes = precinctsSizes;
  32442. }
  32443. var unsupported = [];
  32444. if (cod.selectiveArithmeticCodingBypass) {
  32445. unsupported.push('selectiveArithmeticCodingBypass');
  32446. }
  32447. if (cod.resetContextProbabilities) {
  32448. unsupported.push('resetContextProbabilities');
  32449. }
  32450. if (cod.terminationOnEachCodingPass) {
  32451. unsupported.push('terminationOnEachCodingPass');
  32452. }
  32453. if (cod.verticalyStripe) {
  32454. unsupported.push('verticalyStripe');
  32455. }
  32456. if (cod.predictableTermination) {
  32457. unsupported.push('predictableTermination');
  32458. }
  32459. if (unsupported.length > 0) {
  32460. doNotRecover = true;
  32461. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  32462. }
  32463. if (context.mainHeader) {
  32464. context.COD = cod;
  32465. } else {
  32466. context.currentTile.COD = cod;
  32467. context.currentTile.COC = [];
  32468. }
  32469. break;
  32470. case 0xFF90:
  32471. length = readUint16(data, position);
  32472. tile = {};
  32473. tile.index = readUint16(data, position + 2);
  32474. tile.length = readUint32(data, position + 4);
  32475. tile.dataEnd = tile.length + position - 2;
  32476. tile.partIndex = data[position + 8];
  32477. tile.partsCount = data[position + 9];
  32478. context.mainHeader = false;
  32479. if (tile.partIndex === 0) {
  32480. tile.COD = context.COD;
  32481. tile.COC = context.COC.slice(0);
  32482. tile.QCD = context.QCD;
  32483. tile.QCC = context.QCC.slice(0);
  32484. }
  32485. context.currentTile = tile;
  32486. break;
  32487. case 0xFF93:
  32488. tile = context.currentTile;
  32489. if (tile.partIndex === 0) {
  32490. initializeTile(context, tile.index);
  32491. buildPackets(context);
  32492. }
  32493. length = tile.dataEnd - position;
  32494. parseTilePackets(context, data, position, length);
  32495. break;
  32496. case 0xFF55:
  32497. case 0xFF57:
  32498. case 0xFF58:
  32499. case 0xFF64:
  32500. length = readUint16(data, position);
  32501. break;
  32502. case 0xFF53:
  32503. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  32504. default:
  32505. throw new Error('Unknown codestream code: ' + code.toString(16));
  32506. }
  32507. position += length;
  32508. }
  32509. } catch (e) {
  32510. if (doNotRecover || this.failOnCorruptedImage) {
  32511. error('JPX Error: ' + e.message);
  32512. } else {
  32513. warn('JPX: Trying to recover from: ' + e.message);
  32514. }
  32515. }
  32516. this.tiles = transformComponents(context);
  32517. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  32518. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  32519. this.componentsCount = context.SIZ.Csiz;
  32520. }
  32521. };
  32522. function calculateComponentDimensions(component, siz) {
  32523. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  32524. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  32525. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  32526. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  32527. component.width = component.x1 - component.x0;
  32528. component.height = component.y1 - component.y0;
  32529. }
  32530. function calculateTileGrids(context, components) {
  32531. var siz = context.SIZ;
  32532. var tile, tiles = [];
  32533. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  32534. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  32535. for (var q = 0; q < numYtiles; q++) {
  32536. for (var p = 0; p < numXtiles; p++) {
  32537. tile = {};
  32538. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  32539. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  32540. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  32541. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  32542. tile.width = tile.tx1 - tile.tx0;
  32543. tile.height = tile.ty1 - tile.ty0;
  32544. tile.components = [];
  32545. tiles.push(tile);
  32546. }
  32547. }
  32548. context.tiles = tiles;
  32549. var componentsCount = siz.Csiz;
  32550. for (var i = 0, ii = componentsCount; i < ii; i++) {
  32551. var component = components[i];
  32552. for (var j = 0, jj = tiles.length; j < jj; j++) {
  32553. var tileComponent = {};
  32554. tile = tiles[j];
  32555. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  32556. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  32557. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  32558. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  32559. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  32560. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  32561. tile.components[i] = tileComponent;
  32562. }
  32563. }
  32564. }
  32565. function getBlocksDimensions(context, component, r) {
  32566. var codOrCoc = component.codingStyleParameters;
  32567. var result = {};
  32568. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  32569. result.PPx = 15;
  32570. result.PPy = 15;
  32571. } else {
  32572. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  32573. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  32574. }
  32575. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  32576. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  32577. return result;
  32578. }
  32579. function buildPrecincts(context, resolution, dimensions) {
  32580. var precinctWidth = 1 << dimensions.PPx;
  32581. var precinctHeight = 1 << dimensions.PPy;
  32582. var isZeroRes = resolution.resLevel === 0;
  32583. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  32584. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  32585. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  32586. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  32587. var numprecincts = numprecinctswide * numprecinctshigh;
  32588. resolution.precinctParameters = {
  32589. precinctWidth: precinctWidth,
  32590. precinctHeight: precinctHeight,
  32591. numprecinctswide: numprecinctswide,
  32592. numprecinctshigh: numprecinctshigh,
  32593. numprecincts: numprecincts,
  32594. precinctWidthInSubband: precinctWidthInSubband,
  32595. precinctHeightInSubband: precinctHeightInSubband
  32596. };
  32597. }
  32598. function buildCodeblocks(context, subband, dimensions) {
  32599. var xcb_ = dimensions.xcb_;
  32600. var ycb_ = dimensions.ycb_;
  32601. var codeblockWidth = 1 << xcb_;
  32602. var codeblockHeight = 1 << ycb_;
  32603. var cbx0 = subband.tbx0 >> xcb_;
  32604. var cby0 = subband.tby0 >> ycb_;
  32605. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  32606. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  32607. var precinctParameters = subband.resolution.precinctParameters;
  32608. var codeblocks = [];
  32609. var precincts = [];
  32610. var i, j, codeblock, precinctNumber;
  32611. for (j = cby0; j < cby1; j++) {
  32612. for (i = cbx0; i < cbx1; i++) {
  32613. codeblock = {
  32614. cbx: i,
  32615. cby: j,
  32616. tbx0: codeblockWidth * i,
  32617. tby0: codeblockHeight * j,
  32618. tbx1: codeblockWidth * (i + 1),
  32619. tby1: codeblockHeight * (j + 1)
  32620. };
  32621. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  32622. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  32623. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  32624. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  32625. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  32626. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  32627. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  32628. codeblock.precinctNumber = precinctNumber;
  32629. codeblock.subbandType = subband.type;
  32630. codeblock.Lblock = 3;
  32631. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  32632. continue;
  32633. }
  32634. codeblocks.push(codeblock);
  32635. var precinct = precincts[precinctNumber];
  32636. if (precinct !== undefined) {
  32637. if (i < precinct.cbxMin) {
  32638. precinct.cbxMin = i;
  32639. } else if (i > precinct.cbxMax) {
  32640. precinct.cbxMax = i;
  32641. }
  32642. if (j < precinct.cbyMin) {
  32643. precinct.cbxMin = j;
  32644. } else if (j > precinct.cbyMax) {
  32645. precinct.cbyMax = j;
  32646. }
  32647. } else {
  32648. precincts[precinctNumber] = precinct = {
  32649. cbxMin: i,
  32650. cbyMin: j,
  32651. cbxMax: i,
  32652. cbyMax: j
  32653. };
  32654. }
  32655. codeblock.precinct = precinct;
  32656. }
  32657. }
  32658. subband.codeblockParameters = {
  32659. codeblockWidth: xcb_,
  32660. codeblockHeight: ycb_,
  32661. numcodeblockwide: cbx1 - cbx0 + 1,
  32662. numcodeblockhigh: cby1 - cby0 + 1
  32663. };
  32664. subband.codeblocks = codeblocks;
  32665. subband.precincts = precincts;
  32666. }
  32667. function createPacket(resolution, precinctNumber, layerNumber) {
  32668. var precinctCodeblocks = [];
  32669. var subbands = resolution.subbands;
  32670. for (var i = 0, ii = subbands.length; i < ii; i++) {
  32671. var subband = subbands[i];
  32672. var codeblocks = subband.codeblocks;
  32673. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  32674. var codeblock = codeblocks[j];
  32675. if (codeblock.precinctNumber !== precinctNumber) {
  32676. continue;
  32677. }
  32678. precinctCodeblocks.push(codeblock);
  32679. }
  32680. }
  32681. return {
  32682. layerNumber: layerNumber,
  32683. codeblocks: precinctCodeblocks
  32684. };
  32685. }
  32686. function LayerResolutionComponentPositionIterator(context) {
  32687. var siz = context.SIZ;
  32688. var tileIndex = context.currentTile.index;
  32689. var tile = context.tiles[tileIndex];
  32690. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32691. var componentsCount = siz.Csiz;
  32692. var maxDecompositionLevelsCount = 0;
  32693. for (var q = 0; q < componentsCount; q++) {
  32694. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32695. }
  32696. var l = 0, r = 0, i = 0, k = 0;
  32697. this.nextPacket = function JpxImage_nextPacket() {
  32698. for (; l < layersCount; l++) {
  32699. for (; r <= maxDecompositionLevelsCount; r++) {
  32700. for (; i < componentsCount; i++) {
  32701. var component = tile.components[i];
  32702. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32703. continue;
  32704. }
  32705. var resolution = component.resolutions[r];
  32706. var numprecincts = resolution.precinctParameters.numprecincts;
  32707. for (; k < numprecincts;) {
  32708. var packet = createPacket(resolution, k, l);
  32709. k++;
  32710. return packet;
  32711. }
  32712. k = 0;
  32713. }
  32714. i = 0;
  32715. }
  32716. r = 0;
  32717. }
  32718. error('JPX Error: Out of packets');
  32719. };
  32720. }
  32721. function ResolutionLayerComponentPositionIterator(context) {
  32722. var siz = context.SIZ;
  32723. var tileIndex = context.currentTile.index;
  32724. var tile = context.tiles[tileIndex];
  32725. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32726. var componentsCount = siz.Csiz;
  32727. var maxDecompositionLevelsCount = 0;
  32728. for (var q = 0; q < componentsCount; q++) {
  32729. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32730. }
  32731. var r = 0, l = 0, i = 0, k = 0;
  32732. this.nextPacket = function JpxImage_nextPacket() {
  32733. for (; r <= maxDecompositionLevelsCount; r++) {
  32734. for (; l < layersCount; l++) {
  32735. for (; i < componentsCount; i++) {
  32736. var component = tile.components[i];
  32737. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32738. continue;
  32739. }
  32740. var resolution = component.resolutions[r];
  32741. var numprecincts = resolution.precinctParameters.numprecincts;
  32742. for (; k < numprecincts;) {
  32743. var packet = createPacket(resolution, k, l);
  32744. k++;
  32745. return packet;
  32746. }
  32747. k = 0;
  32748. }
  32749. i = 0;
  32750. }
  32751. l = 0;
  32752. }
  32753. error('JPX Error: Out of packets');
  32754. };
  32755. }
  32756. function ResolutionPositionComponentLayerIterator(context) {
  32757. var siz = context.SIZ;
  32758. var tileIndex = context.currentTile.index;
  32759. var tile = context.tiles[tileIndex];
  32760. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32761. var componentsCount = siz.Csiz;
  32762. var l, r, c, p;
  32763. var maxDecompositionLevelsCount = 0;
  32764. for (c = 0; c < componentsCount; c++) {
  32765. var component = tile.components[c];
  32766. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  32767. }
  32768. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  32769. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  32770. var maxNumPrecincts = 0;
  32771. for (c = 0; c < componentsCount; ++c) {
  32772. var resolutions = tile.components[c].resolutions;
  32773. if (r < resolutions.length) {
  32774. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  32775. }
  32776. }
  32777. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  32778. }
  32779. l = 0;
  32780. r = 0;
  32781. c = 0;
  32782. p = 0;
  32783. this.nextPacket = function JpxImage_nextPacket() {
  32784. for (; r <= maxDecompositionLevelsCount; r++) {
  32785. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32786. for (; c < componentsCount; c++) {
  32787. var component = tile.components[c];
  32788. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32789. continue;
  32790. }
  32791. var resolution = component.resolutions[r];
  32792. var numprecincts = resolution.precinctParameters.numprecincts;
  32793. if (p >= numprecincts) {
  32794. continue;
  32795. }
  32796. for (; l < layersCount;) {
  32797. var packet = createPacket(resolution, p, l);
  32798. l++;
  32799. return packet;
  32800. }
  32801. l = 0;
  32802. }
  32803. c = 0;
  32804. }
  32805. p = 0;
  32806. }
  32807. error('JPX Error: Out of packets');
  32808. };
  32809. }
  32810. function PositionComponentResolutionLayerIterator(context) {
  32811. var siz = context.SIZ;
  32812. var tileIndex = context.currentTile.index;
  32813. var tile = context.tiles[tileIndex];
  32814. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32815. var componentsCount = siz.Csiz;
  32816. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32817. var precinctsIterationSizes = precinctsSizes;
  32818. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32819. this.nextPacket = function JpxImage_nextPacket() {
  32820. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32821. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32822. for (; c < componentsCount; c++) {
  32823. var component = tile.components[c];
  32824. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32825. for (; r <= decompositionLevelsCount; r++) {
  32826. var resolution = component.resolutions[r];
  32827. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32828. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32829. if (k === null) {
  32830. continue;
  32831. }
  32832. for (; l < layersCount;) {
  32833. var packet = createPacket(resolution, k, l);
  32834. l++;
  32835. return packet;
  32836. }
  32837. l = 0;
  32838. }
  32839. r = 0;
  32840. }
  32841. c = 0;
  32842. }
  32843. px = 0;
  32844. }
  32845. error('JPX Error: Out of packets');
  32846. };
  32847. }
  32848. function ComponentPositionResolutionLayerIterator(context) {
  32849. var siz = context.SIZ;
  32850. var tileIndex = context.currentTile.index;
  32851. var tile = context.tiles[tileIndex];
  32852. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32853. var componentsCount = siz.Csiz;
  32854. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32855. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32856. this.nextPacket = function JpxImage_nextPacket() {
  32857. for (; c < componentsCount; ++c) {
  32858. var component = tile.components[c];
  32859. var precinctsIterationSizes = precinctsSizes.components[c];
  32860. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32861. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32862. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32863. for (; r <= decompositionLevelsCount; r++) {
  32864. var resolution = component.resolutions[r];
  32865. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32866. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32867. if (k === null) {
  32868. continue;
  32869. }
  32870. for (; l < layersCount;) {
  32871. var packet = createPacket(resolution, k, l);
  32872. l++;
  32873. return packet;
  32874. }
  32875. l = 0;
  32876. }
  32877. r = 0;
  32878. }
  32879. px = 0;
  32880. }
  32881. py = 0;
  32882. }
  32883. error('JPX Error: Out of packets');
  32884. };
  32885. }
  32886. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32887. var posX = pxIndex * precinctIterationSizes.minWidth;
  32888. var posY = pyIndex * precinctIterationSizes.minHeight;
  32889. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32890. return null;
  32891. }
  32892. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32893. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32894. }
  32895. function getPrecinctSizesInImageScale(tile) {
  32896. var componentsCount = tile.components.length;
  32897. var minWidth = Number.MAX_VALUE;
  32898. var minHeight = Number.MAX_VALUE;
  32899. var maxNumWide = 0;
  32900. var maxNumHigh = 0;
  32901. var sizePerComponent = new Array(componentsCount);
  32902. for (var c = 0; c < componentsCount; c++) {
  32903. var component = tile.components[c];
  32904. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32905. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32906. var minWidthCurrentComponent = Number.MAX_VALUE;
  32907. var minHeightCurrentComponent = Number.MAX_VALUE;
  32908. var maxNumWideCurrentComponent = 0;
  32909. var maxNumHighCurrentComponent = 0;
  32910. var scale = 1;
  32911. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32912. var resolution = component.resolutions[r];
  32913. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32914. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32915. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32916. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32917. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32918. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32919. sizePerResolution[r] = {
  32920. width: widthCurrentResolution,
  32921. height: heightCurrentResolution
  32922. };
  32923. scale <<= 1;
  32924. }
  32925. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32926. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32927. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32928. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32929. sizePerComponent[c] = {
  32930. resolutions: sizePerResolution,
  32931. minWidth: minWidthCurrentComponent,
  32932. minHeight: minHeightCurrentComponent,
  32933. maxNumWide: maxNumWideCurrentComponent,
  32934. maxNumHigh: maxNumHighCurrentComponent
  32935. };
  32936. }
  32937. return {
  32938. components: sizePerComponent,
  32939. minWidth: minWidth,
  32940. minHeight: minHeight,
  32941. maxNumWide: maxNumWide,
  32942. maxNumHigh: maxNumHigh
  32943. };
  32944. }
  32945. function buildPackets(context) {
  32946. var siz = context.SIZ;
  32947. var tileIndex = context.currentTile.index;
  32948. var tile = context.tiles[tileIndex];
  32949. var componentsCount = siz.Csiz;
  32950. for (var c = 0; c < componentsCount; c++) {
  32951. var component = tile.components[c];
  32952. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32953. var resolutions = [];
  32954. var subbands = [];
  32955. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32956. var blocksDimensions = getBlocksDimensions(context, component, r);
  32957. var resolution = {};
  32958. var scale = 1 << decompositionLevelsCount - r;
  32959. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32960. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32961. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32962. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32963. resolution.resLevel = r;
  32964. buildPrecincts(context, resolution, blocksDimensions);
  32965. resolutions.push(resolution);
  32966. var subband;
  32967. if (r === 0) {
  32968. subband = {};
  32969. subband.type = 'LL';
  32970. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32971. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32972. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32973. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32974. subband.resolution = resolution;
  32975. buildCodeblocks(context, subband, blocksDimensions);
  32976. subbands.push(subband);
  32977. resolution.subbands = [subband];
  32978. } else {
  32979. var bscale = 1 << decompositionLevelsCount - r + 1;
  32980. var resolutionSubbands = [];
  32981. subband = {};
  32982. subband.type = 'HL';
  32983. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32984. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32985. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32986. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32987. subband.resolution = resolution;
  32988. buildCodeblocks(context, subband, blocksDimensions);
  32989. subbands.push(subband);
  32990. resolutionSubbands.push(subband);
  32991. subband = {};
  32992. subband.type = 'LH';
  32993. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32994. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32995. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32996. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32997. subband.resolution = resolution;
  32998. buildCodeblocks(context, subband, blocksDimensions);
  32999. subbands.push(subband);
  33000. resolutionSubbands.push(subband);
  33001. subband = {};
  33002. subband.type = 'HH';
  33003. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  33004. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33005. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  33006. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33007. subband.resolution = resolution;
  33008. buildCodeblocks(context, subband, blocksDimensions);
  33009. subbands.push(subband);
  33010. resolutionSubbands.push(subband);
  33011. resolution.subbands = resolutionSubbands;
  33012. }
  33013. }
  33014. component.resolutions = resolutions;
  33015. component.subbands = subbands;
  33016. }
  33017. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  33018. switch (progressionOrder) {
  33019. case 0:
  33020. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  33021. break;
  33022. case 1:
  33023. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  33024. break;
  33025. case 2:
  33026. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  33027. break;
  33028. case 3:
  33029. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  33030. break;
  33031. case 4:
  33032. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  33033. break;
  33034. default:
  33035. error('JPX Error: Unsupported progression order ' + progressionOrder);
  33036. }
  33037. }
  33038. function parseTilePackets(context, data, offset, dataLength) {
  33039. var position = 0;
  33040. var buffer, bufferSize = 0, skipNextBit = false;
  33041. function readBits(count) {
  33042. while (bufferSize < count) {
  33043. var b = data[offset + position];
  33044. position++;
  33045. if (skipNextBit) {
  33046. buffer = buffer << 7 | b;
  33047. bufferSize += 7;
  33048. skipNextBit = false;
  33049. } else {
  33050. buffer = buffer << 8 | b;
  33051. bufferSize += 8;
  33052. }
  33053. if (b === 0xFF) {
  33054. skipNextBit = true;
  33055. }
  33056. }
  33057. bufferSize -= count;
  33058. return buffer >>> bufferSize & (1 << count) - 1;
  33059. }
  33060. function skipMarkerIfEqual(value) {
  33061. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  33062. skipBytes(1);
  33063. return true;
  33064. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  33065. skipBytes(2);
  33066. return true;
  33067. }
  33068. return false;
  33069. }
  33070. function skipBytes(count) {
  33071. position += count;
  33072. }
  33073. function alignToByte() {
  33074. bufferSize = 0;
  33075. if (skipNextBit) {
  33076. position++;
  33077. skipNextBit = false;
  33078. }
  33079. }
  33080. function readCodingpasses() {
  33081. if (readBits(1) === 0) {
  33082. return 1;
  33083. }
  33084. if (readBits(1) === 0) {
  33085. return 2;
  33086. }
  33087. var value = readBits(2);
  33088. if (value < 3) {
  33089. return value + 3;
  33090. }
  33091. value = readBits(5);
  33092. if (value < 31) {
  33093. return value + 6;
  33094. }
  33095. value = readBits(7);
  33096. return value + 37;
  33097. }
  33098. var tileIndex = context.currentTile.index;
  33099. var tile = context.tiles[tileIndex];
  33100. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33101. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33102. var packetsIterator = tile.packetsIterator;
  33103. while (position < dataLength) {
  33104. alignToByte();
  33105. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33106. skipBytes(4);
  33107. }
  33108. var packet = packetsIterator.nextPacket();
  33109. if (!readBits(1)) {
  33110. continue;
  33111. }
  33112. var layerNumber = packet.layerNumber;
  33113. var queue = [], codeblock;
  33114. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33115. codeblock = packet.codeblocks[i];
  33116. var precinct = codeblock.precinct;
  33117. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33118. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33119. var codeblockIncluded = false;
  33120. var firstTimeInclusion = false;
  33121. var valueReady;
  33122. if (codeblock['included'] !== undefined) {
  33123. codeblockIncluded = !!readBits(1);
  33124. } else {
  33125. precinct = codeblock.precinct;
  33126. var inclusionTree, zeroBitPlanesTree;
  33127. if (precinct['inclusionTree'] !== undefined) {
  33128. inclusionTree = precinct.inclusionTree;
  33129. } else {
  33130. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33131. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33132. inclusionTree = new InclusionTree(width, height, layerNumber);
  33133. zeroBitPlanesTree = new TagTree(width, height);
  33134. precinct.inclusionTree = inclusionTree;
  33135. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33136. }
  33137. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33138. while (true) {
  33139. if (readBits(1)) {
  33140. valueReady = !inclusionTree.nextLevel();
  33141. if (valueReady) {
  33142. codeblock.included = true;
  33143. codeblockIncluded = firstTimeInclusion = true;
  33144. break;
  33145. }
  33146. } else {
  33147. inclusionTree.incrementValue(layerNumber);
  33148. break;
  33149. }
  33150. }
  33151. }
  33152. }
  33153. if (!codeblockIncluded) {
  33154. continue;
  33155. }
  33156. if (firstTimeInclusion) {
  33157. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33158. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33159. while (true) {
  33160. if (readBits(1)) {
  33161. valueReady = !zeroBitPlanesTree.nextLevel();
  33162. if (valueReady) {
  33163. break;
  33164. }
  33165. } else {
  33166. zeroBitPlanesTree.incrementValue();
  33167. }
  33168. }
  33169. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33170. }
  33171. var codingpasses = readCodingpasses();
  33172. while (readBits(1)) {
  33173. codeblock.Lblock++;
  33174. }
  33175. var codingpassesLog2 = log2(codingpasses);
  33176. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33177. var codedDataLength = readBits(bits);
  33178. queue.push({
  33179. codeblock: codeblock,
  33180. codingpasses: codingpasses,
  33181. dataLength: codedDataLength
  33182. });
  33183. }
  33184. alignToByte();
  33185. if (ephMarkerUsed) {
  33186. skipMarkerIfEqual(0x92);
  33187. }
  33188. while (queue.length > 0) {
  33189. var packetItem = queue.shift();
  33190. codeblock = packetItem.codeblock;
  33191. if (codeblock['data'] === undefined) {
  33192. codeblock.data = [];
  33193. }
  33194. codeblock.data.push({
  33195. data: data,
  33196. start: offset + position,
  33197. end: offset + position + packetItem.dataLength,
  33198. codingpasses: packetItem.codingpasses
  33199. });
  33200. position += packetItem.dataLength;
  33201. }
  33202. }
  33203. return position;
  33204. }
  33205. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33206. var x0 = subband.tbx0;
  33207. var y0 = subband.tby0;
  33208. var width = subband.tbx1 - subband.tbx0;
  33209. var codeblocks = subband.codeblocks;
  33210. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33211. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33212. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33213. var codeblock = codeblocks[i];
  33214. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33215. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33216. if (blockWidth === 0 || blockHeight === 0) {
  33217. continue;
  33218. }
  33219. if (codeblock['data'] === undefined) {
  33220. continue;
  33221. }
  33222. var bitModel, currentCodingpassType;
  33223. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33224. currentCodingpassType = 2;
  33225. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33226. var j, jj, dataItem;
  33227. for (j = 0, jj = data.length; j < jj; j++) {
  33228. dataItem = data[j];
  33229. totalLength += dataItem.end - dataItem.start;
  33230. codingpasses += dataItem.codingpasses;
  33231. }
  33232. var encodedData = new Uint8Array(totalLength);
  33233. var position = 0;
  33234. for (j = 0, jj = data.length; j < jj; j++) {
  33235. dataItem = data[j];
  33236. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33237. encodedData.set(chunk, position);
  33238. position += chunk.length;
  33239. }
  33240. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33241. bitModel.setDecoder(decoder);
  33242. for (j = 0; j < codingpasses; j++) {
  33243. switch (currentCodingpassType) {
  33244. case 0:
  33245. bitModel.runSignificancePropagationPass();
  33246. break;
  33247. case 1:
  33248. bitModel.runMagnitudeRefinementPass();
  33249. break;
  33250. case 2:
  33251. bitModel.runCleanupPass();
  33252. if (segmentationSymbolUsed) {
  33253. bitModel.checkSegmentationSymbol();
  33254. }
  33255. break;
  33256. }
  33257. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33258. }
  33259. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33260. var sign = bitModel.coefficentsSign;
  33261. var magnitude = bitModel.coefficentsMagnitude;
  33262. var bitsDecoded = bitModel.bitsDecoded;
  33263. var magnitudeCorrection = reversible ? 0 : 0.5;
  33264. var k, n, nb;
  33265. position = 0;
  33266. var interleave = subband.type !== 'LL';
  33267. for (j = 0; j < blockHeight; j++) {
  33268. var row = offset / width | 0;
  33269. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33270. for (k = 0; k < blockWidth; k++) {
  33271. n = magnitude[position];
  33272. if (n !== 0) {
  33273. n = (n + magnitudeCorrection) * delta;
  33274. if (sign[position] !== 0) {
  33275. n = -n;
  33276. }
  33277. nb = bitsDecoded[position];
  33278. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33279. if (reversible && nb >= mb) {
  33280. coefficients[pos] = n;
  33281. } else {
  33282. coefficients[pos] = n * (1 << mb - nb);
  33283. }
  33284. }
  33285. offset++;
  33286. position++;
  33287. }
  33288. offset += width - blockWidth;
  33289. }
  33290. }
  33291. }
  33292. function transformTile(context, tile, c) {
  33293. var component = tile.components[c];
  33294. var codingStyleParameters = component.codingStyleParameters;
  33295. var quantizationParameters = component.quantizationParameters;
  33296. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33297. var spqcds = quantizationParameters.SPqcds;
  33298. var scalarExpounded = quantizationParameters.scalarExpounded;
  33299. var guardBits = quantizationParameters.guardBits;
  33300. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33301. var precision = context.components[c].precision;
  33302. var reversible = codingStyleParameters.reversibleTransformation;
  33303. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33304. var subbandCoefficients = [];
  33305. var b = 0;
  33306. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33307. var resolution = component.resolutions[i];
  33308. var width = resolution.trx1 - resolution.trx0;
  33309. var height = resolution.try1 - resolution.try0;
  33310. var coefficients = new Float32Array(width * height);
  33311. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33312. var mu, epsilon;
  33313. if (!scalarExpounded) {
  33314. mu = spqcds[0].mu;
  33315. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33316. } else {
  33317. mu = spqcds[b].mu;
  33318. epsilon = spqcds[b].epsilon;
  33319. b++;
  33320. }
  33321. var subband = resolution.subbands[j];
  33322. var gainLog2 = SubbandsGainLog2[subband.type];
  33323. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33324. var mb = guardBits + epsilon - 1;
  33325. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33326. }
  33327. subbandCoefficients.push({
  33328. width: width,
  33329. height: height,
  33330. items: coefficients
  33331. });
  33332. }
  33333. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33334. return {
  33335. left: component.tcx0,
  33336. top: component.tcy0,
  33337. width: result.width,
  33338. height: result.height,
  33339. items: result.items
  33340. };
  33341. }
  33342. function transformComponents(context) {
  33343. var siz = context.SIZ;
  33344. var components = context.components;
  33345. var componentsCount = siz.Csiz;
  33346. var resultImages = [];
  33347. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33348. var tile = context.tiles[i];
  33349. var transformedTiles = [];
  33350. var c;
  33351. for (c = 0; c < componentsCount; c++) {
  33352. transformedTiles[c] = transformTile(context, tile, c);
  33353. }
  33354. var tile0 = transformedTiles[0];
  33355. var out = new Uint8Array(tile0.items.length * componentsCount);
  33356. var result = {
  33357. left: tile0.left,
  33358. top: tile0.top,
  33359. width: tile0.width,
  33360. height: tile0.height,
  33361. items: out
  33362. };
  33363. var shift, offset, max, min, maxK;
  33364. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  33365. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  33366. var fourComponents = componentsCount === 4;
  33367. var y0items = transformedTiles[0].items;
  33368. var y1items = transformedTiles[1].items;
  33369. var y2items = transformedTiles[2].items;
  33370. var y3items = fourComponents ? transformedTiles[3].items : null;
  33371. shift = components[0].precision - 8;
  33372. offset = (128 << shift) + 0.5;
  33373. max = 255 * (1 << shift);
  33374. maxK = max * 0.5;
  33375. min = -maxK;
  33376. var component0 = tile.components[0];
  33377. var alpha01 = componentsCount - 3;
  33378. jj = y0items.length;
  33379. if (!component0.codingStyleParameters.reversibleTransformation) {
  33380. for (j = 0; j < jj; j++, pos += alpha01) {
  33381. y0 = y0items[j] + offset;
  33382. y1 = y1items[j];
  33383. y2 = y2items[j];
  33384. r = y0 + 1.402 * y2;
  33385. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  33386. b = y0 + 1.772 * y1;
  33387. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33388. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33389. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33390. }
  33391. } else {
  33392. for (j = 0; j < jj; j++, pos += alpha01) {
  33393. y0 = y0items[j] + offset;
  33394. y1 = y1items[j];
  33395. y2 = y2items[j];
  33396. g = y0 - (y2 + y1 >> 2);
  33397. r = g + y2;
  33398. b = g + y1;
  33399. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33400. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33401. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33402. }
  33403. }
  33404. if (fourComponents) {
  33405. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  33406. k = y3items[j];
  33407. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  33408. }
  33409. }
  33410. } else {
  33411. for (c = 0; c < componentsCount; c++) {
  33412. var items = transformedTiles[c].items;
  33413. shift = components[c].precision - 8;
  33414. offset = (128 << shift) + 0.5;
  33415. max = 127.5 * (1 << shift);
  33416. min = -max;
  33417. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  33418. val = items[j];
  33419. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  33420. pos += componentsCount;
  33421. }
  33422. }
  33423. }
  33424. resultImages.push(result);
  33425. }
  33426. return resultImages;
  33427. }
  33428. function initializeTile(context, tileIndex) {
  33429. var siz = context.SIZ;
  33430. var componentsCount = siz.Csiz;
  33431. var tile = context.tiles[tileIndex];
  33432. for (var c = 0; c < componentsCount; c++) {
  33433. var component = tile.components[c];
  33434. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  33435. component.quantizationParameters = qcdOrQcc;
  33436. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  33437. component.codingStyleParameters = codOrCoc;
  33438. }
  33439. tile.codingStyleDefaultParameters = context.currentTile.COD;
  33440. }
  33441. var TagTree = function TagTreeClosure() {
  33442. function TagTree(width, height) {
  33443. var levelsLength = log2(Math.max(width, height)) + 1;
  33444. this.levels = [];
  33445. for (var i = 0; i < levelsLength; i++) {
  33446. var level = {
  33447. width: width,
  33448. height: height,
  33449. items: []
  33450. };
  33451. this.levels.push(level);
  33452. width = Math.ceil(width / 2);
  33453. height = Math.ceil(height / 2);
  33454. }
  33455. }
  33456. TagTree.prototype = {
  33457. reset: function TagTree_reset(i, j) {
  33458. var currentLevel = 0, value = 0, level;
  33459. while (currentLevel < this.levels.length) {
  33460. level = this.levels[currentLevel];
  33461. var index = i + j * level.width;
  33462. if (level.items[index] !== undefined) {
  33463. value = level.items[index];
  33464. break;
  33465. }
  33466. level.index = index;
  33467. i >>= 1;
  33468. j >>= 1;
  33469. currentLevel++;
  33470. }
  33471. currentLevel--;
  33472. level = this.levels[currentLevel];
  33473. level.items[level.index] = value;
  33474. this.currentLevel = currentLevel;
  33475. delete this.value;
  33476. },
  33477. incrementValue: function TagTree_incrementValue() {
  33478. var level = this.levels[this.currentLevel];
  33479. level.items[level.index]++;
  33480. },
  33481. nextLevel: function TagTree_nextLevel() {
  33482. var currentLevel = this.currentLevel;
  33483. var level = this.levels[currentLevel];
  33484. var value = level.items[level.index];
  33485. currentLevel--;
  33486. if (currentLevel < 0) {
  33487. this.value = value;
  33488. return false;
  33489. }
  33490. this.currentLevel = currentLevel;
  33491. level = this.levels[currentLevel];
  33492. level.items[level.index] = value;
  33493. return true;
  33494. }
  33495. };
  33496. return TagTree;
  33497. }();
  33498. var InclusionTree = function InclusionTreeClosure() {
  33499. function InclusionTree(width, height, defaultValue) {
  33500. var levelsLength = log2(Math.max(width, height)) + 1;
  33501. this.levels = [];
  33502. for (var i = 0; i < levelsLength; i++) {
  33503. var items = new Uint8Array(width * height);
  33504. for (var j = 0, jj = items.length; j < jj; j++) {
  33505. items[j] = defaultValue;
  33506. }
  33507. var level = {
  33508. width: width,
  33509. height: height,
  33510. items: items
  33511. };
  33512. this.levels.push(level);
  33513. width = Math.ceil(width / 2);
  33514. height = Math.ceil(height / 2);
  33515. }
  33516. }
  33517. InclusionTree.prototype = {
  33518. reset: function InclusionTree_reset(i, j, stopValue) {
  33519. var currentLevel = 0;
  33520. while (currentLevel < this.levels.length) {
  33521. var level = this.levels[currentLevel];
  33522. var index = i + j * level.width;
  33523. level.index = index;
  33524. var value = level.items[index];
  33525. if (value === 0xFF) {
  33526. break;
  33527. }
  33528. if (value > stopValue) {
  33529. this.currentLevel = currentLevel;
  33530. this.propagateValues();
  33531. return false;
  33532. }
  33533. i >>= 1;
  33534. j >>= 1;
  33535. currentLevel++;
  33536. }
  33537. this.currentLevel = currentLevel - 1;
  33538. return true;
  33539. },
  33540. incrementValue: function InclusionTree_incrementValue(stopValue) {
  33541. var level = this.levels[this.currentLevel];
  33542. level.items[level.index] = stopValue + 1;
  33543. this.propagateValues();
  33544. },
  33545. propagateValues: function InclusionTree_propagateValues() {
  33546. var levelIndex = this.currentLevel;
  33547. var level = this.levels[levelIndex];
  33548. var currentValue = level.items[level.index];
  33549. while (--levelIndex >= 0) {
  33550. level = this.levels[levelIndex];
  33551. level.items[level.index] = currentValue;
  33552. }
  33553. },
  33554. nextLevel: function InclusionTree_nextLevel() {
  33555. var currentLevel = this.currentLevel;
  33556. var level = this.levels[currentLevel];
  33557. var value = level.items[level.index];
  33558. level.items[level.index] = 0xFF;
  33559. currentLevel--;
  33560. if (currentLevel < 0) {
  33561. return false;
  33562. }
  33563. this.currentLevel = currentLevel;
  33564. level = this.levels[currentLevel];
  33565. level.items[level.index] = value;
  33566. return true;
  33567. }
  33568. };
  33569. return InclusionTree;
  33570. }();
  33571. var BitModel = function BitModelClosure() {
  33572. var UNIFORM_CONTEXT = 17;
  33573. var RUNLENGTH_CONTEXT = 18;
  33574. var LLAndLHContextsLabel = new Uint8Array([
  33575. 0,
  33576. 5,
  33577. 8,
  33578. 0,
  33579. 3,
  33580. 7,
  33581. 8,
  33582. 0,
  33583. 4,
  33584. 7,
  33585. 8,
  33586. 0,
  33587. 0,
  33588. 0,
  33589. 0,
  33590. 0,
  33591. 1,
  33592. 6,
  33593. 8,
  33594. 0,
  33595. 3,
  33596. 7,
  33597. 8,
  33598. 0,
  33599. 4,
  33600. 7,
  33601. 8,
  33602. 0,
  33603. 0,
  33604. 0,
  33605. 0,
  33606. 0,
  33607. 2,
  33608. 6,
  33609. 8,
  33610. 0,
  33611. 3,
  33612. 7,
  33613. 8,
  33614. 0,
  33615. 4,
  33616. 7,
  33617. 8,
  33618. 0,
  33619. 0,
  33620. 0,
  33621. 0,
  33622. 0,
  33623. 2,
  33624. 6,
  33625. 8,
  33626. 0,
  33627. 3,
  33628. 7,
  33629. 8,
  33630. 0,
  33631. 4,
  33632. 7,
  33633. 8,
  33634. 0,
  33635. 0,
  33636. 0,
  33637. 0,
  33638. 0,
  33639. 2,
  33640. 6,
  33641. 8,
  33642. 0,
  33643. 3,
  33644. 7,
  33645. 8,
  33646. 0,
  33647. 4,
  33648. 7,
  33649. 8
  33650. ]);
  33651. var HLContextLabel = new Uint8Array([
  33652. 0,
  33653. 3,
  33654. 4,
  33655. 0,
  33656. 5,
  33657. 7,
  33658. 7,
  33659. 0,
  33660. 8,
  33661. 8,
  33662. 8,
  33663. 0,
  33664. 0,
  33665. 0,
  33666. 0,
  33667. 0,
  33668. 1,
  33669. 3,
  33670. 4,
  33671. 0,
  33672. 6,
  33673. 7,
  33674. 7,
  33675. 0,
  33676. 8,
  33677. 8,
  33678. 8,
  33679. 0,
  33680. 0,
  33681. 0,
  33682. 0,
  33683. 0,
  33684. 2,
  33685. 3,
  33686. 4,
  33687. 0,
  33688. 6,
  33689. 7,
  33690. 7,
  33691. 0,
  33692. 8,
  33693. 8,
  33694. 8,
  33695. 0,
  33696. 0,
  33697. 0,
  33698. 0,
  33699. 0,
  33700. 2,
  33701. 3,
  33702. 4,
  33703. 0,
  33704. 6,
  33705. 7,
  33706. 7,
  33707. 0,
  33708. 8,
  33709. 8,
  33710. 8,
  33711. 0,
  33712. 0,
  33713. 0,
  33714. 0,
  33715. 0,
  33716. 2,
  33717. 3,
  33718. 4,
  33719. 0,
  33720. 6,
  33721. 7,
  33722. 7,
  33723. 0,
  33724. 8,
  33725. 8,
  33726. 8
  33727. ]);
  33728. var HHContextLabel = new Uint8Array([
  33729. 0,
  33730. 1,
  33731. 2,
  33732. 0,
  33733. 1,
  33734. 2,
  33735. 2,
  33736. 0,
  33737. 2,
  33738. 2,
  33739. 2,
  33740. 0,
  33741. 0,
  33742. 0,
  33743. 0,
  33744. 0,
  33745. 3,
  33746. 4,
  33747. 5,
  33748. 0,
  33749. 4,
  33750. 5,
  33751. 5,
  33752. 0,
  33753. 5,
  33754. 5,
  33755. 5,
  33756. 0,
  33757. 0,
  33758. 0,
  33759. 0,
  33760. 0,
  33761. 6,
  33762. 7,
  33763. 7,
  33764. 0,
  33765. 7,
  33766. 7,
  33767. 7,
  33768. 0,
  33769. 7,
  33770. 7,
  33771. 7,
  33772. 0,
  33773. 0,
  33774. 0,
  33775. 0,
  33776. 0,
  33777. 8,
  33778. 8,
  33779. 8,
  33780. 0,
  33781. 8,
  33782. 8,
  33783. 8,
  33784. 0,
  33785. 8,
  33786. 8,
  33787. 8,
  33788. 0,
  33789. 0,
  33790. 0,
  33791. 0,
  33792. 0,
  33793. 8,
  33794. 8,
  33795. 8,
  33796. 0,
  33797. 8,
  33798. 8,
  33799. 8,
  33800. 0,
  33801. 8,
  33802. 8,
  33803. 8
  33804. ]);
  33805. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33806. this.width = width;
  33807. this.height = height;
  33808. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33809. var coefficientCount = width * height;
  33810. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33811. this.coefficentsSign = new Uint8Array(coefficientCount);
  33812. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33813. this.processingFlags = new Uint8Array(coefficientCount);
  33814. var bitsDecoded = new Uint8Array(coefficientCount);
  33815. if (zeroBitPlanes !== 0) {
  33816. for (var i = 0; i < coefficientCount; i++) {
  33817. bitsDecoded[i] = zeroBitPlanes;
  33818. }
  33819. }
  33820. this.bitsDecoded = bitsDecoded;
  33821. this.reset();
  33822. }
  33823. BitModel.prototype = {
  33824. setDecoder: function BitModel_setDecoder(decoder) {
  33825. this.decoder = decoder;
  33826. },
  33827. reset: function BitModel_reset() {
  33828. this.contexts = new Int8Array(19);
  33829. this.contexts[0] = 4 << 1 | 0;
  33830. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33831. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33832. },
  33833. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33834. var neighborsSignificance = this.neighborsSignificance;
  33835. var width = this.width, height = this.height;
  33836. var left = column > 0;
  33837. var right = column + 1 < width;
  33838. var i;
  33839. if (row > 0) {
  33840. i = index - width;
  33841. if (left) {
  33842. neighborsSignificance[i - 1] += 0x10;
  33843. }
  33844. if (right) {
  33845. neighborsSignificance[i + 1] += 0x10;
  33846. }
  33847. neighborsSignificance[i] += 0x04;
  33848. }
  33849. if (row + 1 < height) {
  33850. i = index + width;
  33851. if (left) {
  33852. neighborsSignificance[i - 1] += 0x10;
  33853. }
  33854. if (right) {
  33855. neighborsSignificance[i + 1] += 0x10;
  33856. }
  33857. neighborsSignificance[i] += 0x04;
  33858. }
  33859. if (left) {
  33860. neighborsSignificance[index - 1] += 0x01;
  33861. }
  33862. if (right) {
  33863. neighborsSignificance[index + 1] += 0x01;
  33864. }
  33865. neighborsSignificance[index] |= 0x80;
  33866. },
  33867. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33868. var decoder = this.decoder;
  33869. var width = this.width, height = this.height;
  33870. var coefficentsMagnitude = this.coefficentsMagnitude;
  33871. var coefficentsSign = this.coefficentsSign;
  33872. var neighborsSignificance = this.neighborsSignificance;
  33873. var processingFlags = this.processingFlags;
  33874. var contexts = this.contexts;
  33875. var labels = this.contextLabelTable;
  33876. var bitsDecoded = this.bitsDecoded;
  33877. var processedInverseMask = ~1;
  33878. var processedMask = 1;
  33879. var firstMagnitudeBitMask = 2;
  33880. for (var i0 = 0; i0 < height; i0 += 4) {
  33881. for (var j = 0; j < width; j++) {
  33882. var index = i0 * width + j;
  33883. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33884. var i = i0 + i1;
  33885. if (i >= height) {
  33886. break;
  33887. }
  33888. processingFlags[index] &= processedInverseMask;
  33889. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33890. continue;
  33891. }
  33892. var contextLabel = labels[neighborsSignificance[index]];
  33893. var decision = decoder.readBit(contexts, contextLabel);
  33894. if (decision) {
  33895. var sign = this.decodeSignBit(i, j, index);
  33896. coefficentsSign[index] = sign;
  33897. coefficentsMagnitude[index] = 1;
  33898. this.setNeighborsSignificance(i, j, index);
  33899. processingFlags[index] |= firstMagnitudeBitMask;
  33900. }
  33901. bitsDecoded[index]++;
  33902. processingFlags[index] |= processedMask;
  33903. }
  33904. }
  33905. }
  33906. },
  33907. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33908. var width = this.width, height = this.height;
  33909. var coefficentsMagnitude = this.coefficentsMagnitude;
  33910. var coefficentsSign = this.coefficentsSign;
  33911. var contribution, sign0, sign1, significance1;
  33912. var contextLabel, decoded;
  33913. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33914. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33915. sign1 = coefficentsSign[index + 1];
  33916. if (significance1) {
  33917. sign0 = coefficentsSign[index - 1];
  33918. contribution = 1 - sign1 - sign0;
  33919. } else {
  33920. contribution = 1 - sign1 - sign1;
  33921. }
  33922. } else if (significance1) {
  33923. sign0 = coefficentsSign[index - 1];
  33924. contribution = 1 - sign0 - sign0;
  33925. } else {
  33926. contribution = 0;
  33927. }
  33928. var horizontalContribution = 3 * contribution;
  33929. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33930. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33931. sign1 = coefficentsSign[index + width];
  33932. if (significance1) {
  33933. sign0 = coefficentsSign[index - width];
  33934. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33935. } else {
  33936. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33937. }
  33938. } else if (significance1) {
  33939. sign0 = coefficentsSign[index - width];
  33940. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33941. } else {
  33942. contribution = horizontalContribution;
  33943. }
  33944. if (contribution >= 0) {
  33945. contextLabel = 9 + contribution;
  33946. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33947. } else {
  33948. contextLabel = 9 - contribution;
  33949. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33950. }
  33951. return decoded;
  33952. },
  33953. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33954. var decoder = this.decoder;
  33955. var width = this.width, height = this.height;
  33956. var coefficentsMagnitude = this.coefficentsMagnitude;
  33957. var neighborsSignificance = this.neighborsSignificance;
  33958. var contexts = this.contexts;
  33959. var bitsDecoded = this.bitsDecoded;
  33960. var processingFlags = this.processingFlags;
  33961. var processedMask = 1;
  33962. var firstMagnitudeBitMask = 2;
  33963. var length = width * height;
  33964. var width4 = width * 4;
  33965. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33966. indexNext = Math.min(length, index0 + width4);
  33967. for (var j = 0; j < width; j++) {
  33968. for (var index = index0 + j; index < indexNext; index += width) {
  33969. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33970. continue;
  33971. }
  33972. var contextLabel = 16;
  33973. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33974. processingFlags[index] ^= firstMagnitudeBitMask;
  33975. var significance = neighborsSignificance[index] & 127;
  33976. contextLabel = significance === 0 ? 15 : 14;
  33977. }
  33978. var bit = decoder.readBit(contexts, contextLabel);
  33979. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33980. bitsDecoded[index]++;
  33981. processingFlags[index] |= processedMask;
  33982. }
  33983. }
  33984. }
  33985. },
  33986. runCleanupPass: function BitModel_runCleanupPass() {
  33987. var decoder = this.decoder;
  33988. var width = this.width, height = this.height;
  33989. var neighborsSignificance = this.neighborsSignificance;
  33990. var coefficentsMagnitude = this.coefficentsMagnitude;
  33991. var coefficentsSign = this.coefficentsSign;
  33992. var contexts = this.contexts;
  33993. var labels = this.contextLabelTable;
  33994. var bitsDecoded = this.bitsDecoded;
  33995. var processingFlags = this.processingFlags;
  33996. var processedMask = 1;
  33997. var firstMagnitudeBitMask = 2;
  33998. var oneRowDown = width;
  33999. var twoRowsDown = width * 2;
  34000. var threeRowsDown = width * 3;
  34001. var iNext;
  34002. for (var i0 = 0; i0 < height; i0 = iNext) {
  34003. iNext = Math.min(i0 + 4, height);
  34004. var indexBase = i0 * width;
  34005. var checkAllEmpty = i0 + 3 < height;
  34006. for (var j = 0; j < width; j++) {
  34007. var index0 = indexBase + j;
  34008. 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;
  34009. var i1 = 0, index = index0;
  34010. var i = i0, sign;
  34011. if (allEmpty) {
  34012. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  34013. if (!hasSignificantCoefficent) {
  34014. bitsDecoded[index0]++;
  34015. bitsDecoded[index0 + oneRowDown]++;
  34016. bitsDecoded[index0 + twoRowsDown]++;
  34017. bitsDecoded[index0 + threeRowsDown]++;
  34018. continue;
  34019. }
  34020. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  34021. if (i1 !== 0) {
  34022. i = i0 + i1;
  34023. index += i1 * width;
  34024. }
  34025. sign = this.decodeSignBit(i, j, index);
  34026. coefficentsSign[index] = sign;
  34027. coefficentsMagnitude[index] = 1;
  34028. this.setNeighborsSignificance(i, j, index);
  34029. processingFlags[index] |= firstMagnitudeBitMask;
  34030. index = index0;
  34031. for (var i2 = i0; i2 <= i; i2++, index += width) {
  34032. bitsDecoded[index]++;
  34033. }
  34034. i1++;
  34035. }
  34036. for (i = i0 + i1; i < iNext; i++, index += width) {
  34037. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  34038. continue;
  34039. }
  34040. var contextLabel = labels[neighborsSignificance[index]];
  34041. var decision = decoder.readBit(contexts, contextLabel);
  34042. if (decision === 1) {
  34043. sign = this.decodeSignBit(i, j, index);
  34044. coefficentsSign[index] = sign;
  34045. coefficentsMagnitude[index] = 1;
  34046. this.setNeighborsSignificance(i, j, index);
  34047. processingFlags[index] |= firstMagnitudeBitMask;
  34048. }
  34049. bitsDecoded[index]++;
  34050. }
  34051. }
  34052. }
  34053. },
  34054. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  34055. var decoder = this.decoder;
  34056. var contexts = this.contexts;
  34057. 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);
  34058. if (symbol !== 0xA) {
  34059. error('JPX Error: Invalid segmentation symbol');
  34060. }
  34061. }
  34062. };
  34063. return BitModel;
  34064. }();
  34065. var Transform = function TransformClosure() {
  34066. function Transform() {
  34067. }
  34068. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  34069. var ll = subbands[0];
  34070. for (var i = 1, ii = subbands.length; i < ii; i++) {
  34071. ll = this.iterate(ll, subbands[i], u0, v0);
  34072. }
  34073. return ll;
  34074. };
  34075. Transform.prototype.extend = function extend(buffer, offset, size) {
  34076. var i1 = offset - 1, j1 = offset + 1;
  34077. var i2 = offset + size - 2, j2 = offset + size;
  34078. buffer[i1--] = buffer[j1++];
  34079. buffer[j2++] = buffer[i2--];
  34080. buffer[i1--] = buffer[j1++];
  34081. buffer[j2++] = buffer[i2--];
  34082. buffer[i1--] = buffer[j1++];
  34083. buffer[j2++] = buffer[i2--];
  34084. buffer[i1] = buffer[j1];
  34085. buffer[j2] = buffer[i2];
  34086. };
  34087. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34088. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34089. var width = hl_lh_hh.width;
  34090. var height = hl_lh_hh.height;
  34091. var items = hl_lh_hh.items;
  34092. var i, j, k, l, u, v;
  34093. for (k = 0, i = 0; i < llHeight; i++) {
  34094. l = i * 2 * width;
  34095. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34096. items[l] = llItems[k];
  34097. }
  34098. }
  34099. llItems = ll.items = null;
  34100. var bufferPadding = 4;
  34101. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34102. if (width === 1) {
  34103. if ((u0 & 1) !== 0) {
  34104. for (v = 0, k = 0; v < height; v++, k += width) {
  34105. items[k] *= 0.5;
  34106. }
  34107. }
  34108. } else {
  34109. for (v = 0, k = 0; v < height; v++, k += width) {
  34110. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34111. this.extend(rowBuffer, bufferPadding, width);
  34112. this.filter(rowBuffer, bufferPadding, width);
  34113. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34114. }
  34115. }
  34116. var numBuffers = 16;
  34117. var colBuffers = [];
  34118. for (i = 0; i < numBuffers; i++) {
  34119. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34120. }
  34121. var b, currentBuffer = 0;
  34122. ll = bufferPadding + height;
  34123. if (height === 1) {
  34124. if ((v0 & 1) !== 0) {
  34125. for (u = 0; u < width; u++) {
  34126. items[u] *= 0.5;
  34127. }
  34128. }
  34129. } else {
  34130. for (u = 0; u < width; u++) {
  34131. if (currentBuffer === 0) {
  34132. numBuffers = Math.min(width - u, numBuffers);
  34133. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34134. for (b = 0; b < numBuffers; b++) {
  34135. colBuffers[b][l] = items[k + b];
  34136. }
  34137. }
  34138. currentBuffer = numBuffers;
  34139. }
  34140. currentBuffer--;
  34141. var buffer = colBuffers[currentBuffer];
  34142. this.extend(buffer, bufferPadding, height);
  34143. this.filter(buffer, bufferPadding, height);
  34144. if (currentBuffer === 0) {
  34145. k = u - numBuffers + 1;
  34146. for (l = bufferPadding; l < ll; k += width, l++) {
  34147. for (b = 0; b < numBuffers; b++) {
  34148. items[k + b] = colBuffers[b][l];
  34149. }
  34150. }
  34151. }
  34152. }
  34153. }
  34154. return {
  34155. width: width,
  34156. height: height,
  34157. items: items
  34158. };
  34159. };
  34160. return Transform;
  34161. }();
  34162. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34163. function IrreversibleTransform() {
  34164. Transform.call(this);
  34165. }
  34166. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34167. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34168. var len = length >> 1;
  34169. offset = offset | 0;
  34170. var j, n, current, next;
  34171. var alpha = -1.586134342059924;
  34172. var beta = -0.052980118572961;
  34173. var gamma = 0.882911075530934;
  34174. var delta = 0.443506852043971;
  34175. var K = 1.230174104914001;
  34176. var K_ = 1 / K;
  34177. j = offset - 3;
  34178. for (n = len + 4; n--; j += 2) {
  34179. x[j] *= K_;
  34180. }
  34181. j = offset - 2;
  34182. current = delta * x[j - 1];
  34183. for (n = len + 3; n--; j += 2) {
  34184. next = delta * x[j + 1];
  34185. x[j] = K * x[j] - current - next;
  34186. if (n--) {
  34187. j += 2;
  34188. current = delta * x[j + 1];
  34189. x[j] = K * x[j] - current - next;
  34190. } else {
  34191. break;
  34192. }
  34193. }
  34194. j = offset - 1;
  34195. current = gamma * x[j - 1];
  34196. for (n = len + 2; n--; j += 2) {
  34197. next = gamma * x[j + 1];
  34198. x[j] -= current + next;
  34199. if (n--) {
  34200. j += 2;
  34201. current = gamma * x[j + 1];
  34202. x[j] -= current + next;
  34203. } else {
  34204. break;
  34205. }
  34206. }
  34207. j = offset;
  34208. current = beta * x[j - 1];
  34209. for (n = len + 1; n--; j += 2) {
  34210. next = beta * x[j + 1];
  34211. x[j] -= current + next;
  34212. if (n--) {
  34213. j += 2;
  34214. current = beta * x[j + 1];
  34215. x[j] -= current + next;
  34216. } else {
  34217. break;
  34218. }
  34219. }
  34220. if (len !== 0) {
  34221. j = offset + 1;
  34222. current = alpha * x[j - 1];
  34223. for (n = len; n--; j += 2) {
  34224. next = alpha * x[j + 1];
  34225. x[j] -= current + next;
  34226. if (n--) {
  34227. j += 2;
  34228. current = alpha * x[j + 1];
  34229. x[j] -= current + next;
  34230. } else {
  34231. break;
  34232. }
  34233. }
  34234. }
  34235. };
  34236. return IrreversibleTransform;
  34237. }();
  34238. var ReversibleTransform = function ReversibleTransformClosure() {
  34239. function ReversibleTransform() {
  34240. Transform.call(this);
  34241. }
  34242. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34243. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34244. var len = length >> 1;
  34245. offset = offset | 0;
  34246. var j, n;
  34247. for (j = offset, n = len + 1; n--; j += 2) {
  34248. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34249. }
  34250. for (j = offset + 1, n = len; n--; j += 2) {
  34251. x[j] += x[j - 1] + x[j + 1] >> 1;
  34252. }
  34253. };
  34254. return ReversibleTransform;
  34255. }();
  34256. return JpxImage;
  34257. }();
  34258. exports.JpxImage = JpxImage;
  34259. /***/ }),
  34260. /* 19 */
  34261. /***/ (function(module, exports, __w_pdfjs_require__) {
  34262. "use strict";
  34263. var sharedUtil = __w_pdfjs_require__(0);
  34264. var corePrimitives = __w_pdfjs_require__(1);
  34265. var coreCrypto = __w_pdfjs_require__(16);
  34266. var coreParser = __w_pdfjs_require__(6);
  34267. var coreChunkedStream = __w_pdfjs_require__(15);
  34268. var coreColorSpace = __w_pdfjs_require__(4);
  34269. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34270. var MissingDataException = sharedUtil.MissingDataException;
  34271. var XRefParseException = sharedUtil.XRefParseException;
  34272. var assert = sharedUtil.assert;
  34273. var bytesToString = sharedUtil.bytesToString;
  34274. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34275. var error = sharedUtil.error;
  34276. var info = sharedUtil.info;
  34277. var isArray = sharedUtil.isArray;
  34278. var isBool = sharedUtil.isBool;
  34279. var isInt = sharedUtil.isInt;
  34280. var isString = sharedUtil.isString;
  34281. var shadow = sharedUtil.shadow;
  34282. var stringToPDFString = sharedUtil.stringToPDFString;
  34283. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34284. var warn = sharedUtil.warn;
  34285. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34286. var Util = sharedUtil.Util;
  34287. var Ref = corePrimitives.Ref;
  34288. var RefSet = corePrimitives.RefSet;
  34289. var RefSetCache = corePrimitives.RefSetCache;
  34290. var isName = corePrimitives.isName;
  34291. var isCmd = corePrimitives.isCmd;
  34292. var isDict = corePrimitives.isDict;
  34293. var isRef = corePrimitives.isRef;
  34294. var isRefsEqual = corePrimitives.isRefsEqual;
  34295. var isStream = corePrimitives.isStream;
  34296. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34297. var Lexer = coreParser.Lexer;
  34298. var Parser = coreParser.Parser;
  34299. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34300. var ColorSpace = coreColorSpace.ColorSpace;
  34301. var Catalog = function CatalogClosure() {
  34302. function Catalog(pdfManager, xref, pageFactory) {
  34303. this.pdfManager = pdfManager;
  34304. this.xref = xref;
  34305. this.catDict = xref.getCatalogObj();
  34306. this.fontCache = new RefSetCache();
  34307. this.builtInCMapCache = Object.create(null);
  34308. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34309. this.pageFactory = pageFactory;
  34310. this.pagePromises = [];
  34311. }
  34312. Catalog.prototype = {
  34313. get metadata() {
  34314. var streamRef = this.catDict.getRaw('Metadata');
  34315. if (!isRef(streamRef)) {
  34316. return shadow(this, 'metadata', null);
  34317. }
  34318. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34319. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34320. var metadata;
  34321. if (stream && isDict(stream.dict)) {
  34322. var type = stream.dict.get('Type');
  34323. var subtype = stream.dict.get('Subtype');
  34324. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34325. try {
  34326. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34327. } catch (e) {
  34328. info('Skipping invalid metadata.');
  34329. }
  34330. }
  34331. }
  34332. return shadow(this, 'metadata', metadata);
  34333. },
  34334. get toplevelPagesDict() {
  34335. var pagesObj = this.catDict.get('Pages');
  34336. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34337. return shadow(this, 'toplevelPagesDict', pagesObj);
  34338. },
  34339. get documentOutline() {
  34340. var obj = null;
  34341. try {
  34342. obj = this.readDocumentOutline();
  34343. } catch (ex) {
  34344. if (ex instanceof MissingDataException) {
  34345. throw ex;
  34346. }
  34347. warn('Unable to read document outline');
  34348. }
  34349. return shadow(this, 'documentOutline', obj);
  34350. },
  34351. readDocumentOutline: function Catalog_readDocumentOutline() {
  34352. var obj = this.catDict.get('Outlines');
  34353. if (!isDict(obj)) {
  34354. return null;
  34355. }
  34356. obj = obj.getRaw('First');
  34357. if (!isRef(obj)) {
  34358. return null;
  34359. }
  34360. var root = { items: [] };
  34361. var queue = [{
  34362. obj: obj,
  34363. parent: root
  34364. }];
  34365. var processed = new RefSet();
  34366. processed.put(obj);
  34367. var xref = this.xref, blackColor = new Uint8Array(3);
  34368. while (queue.length > 0) {
  34369. var i = queue.shift();
  34370. var outlineDict = xref.fetchIfRef(i.obj);
  34371. if (outlineDict === null) {
  34372. continue;
  34373. }
  34374. assert(outlineDict.has('Title'), 'Invalid outline item');
  34375. var data = {
  34376. url: null,
  34377. dest: null
  34378. };
  34379. Catalog.parseDestDictionary({
  34380. destDict: outlineDict,
  34381. resultObj: data,
  34382. docBaseUrl: this.pdfManager.docBaseUrl
  34383. });
  34384. var title = outlineDict.get('Title');
  34385. var flags = outlineDict.get('F') || 0;
  34386. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  34387. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  34388. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  34389. }
  34390. var outlineItem = {
  34391. dest: data.dest,
  34392. url: data.url,
  34393. unsafeUrl: data.unsafeUrl,
  34394. newWindow: data.newWindow,
  34395. title: stringToPDFString(title),
  34396. color: rgbColor,
  34397. count: outlineDict.get('Count'),
  34398. bold: !!(flags & 2),
  34399. italic: !!(flags & 1),
  34400. items: []
  34401. };
  34402. i.parent.items.push(outlineItem);
  34403. obj = outlineDict.getRaw('First');
  34404. if (isRef(obj) && !processed.has(obj)) {
  34405. queue.push({
  34406. obj: obj,
  34407. parent: outlineItem
  34408. });
  34409. processed.put(obj);
  34410. }
  34411. obj = outlineDict.getRaw('Next');
  34412. if (isRef(obj) && !processed.has(obj)) {
  34413. queue.push({
  34414. obj: obj,
  34415. parent: i.parent
  34416. });
  34417. processed.put(obj);
  34418. }
  34419. }
  34420. return root.items.length > 0 ? root.items : null;
  34421. },
  34422. get numPages() {
  34423. var obj = this.toplevelPagesDict.get('Count');
  34424. assert(isInt(obj), 'page count in top level pages object is not an integer');
  34425. return shadow(this, 'num', obj);
  34426. },
  34427. get destinations() {
  34428. function fetchDestination(dest) {
  34429. return isDict(dest) ? dest.get('D') : dest;
  34430. }
  34431. var xref = this.xref;
  34432. var dests = {}, nameTreeRef, nameDictionaryRef;
  34433. var obj = this.catDict.get('Names');
  34434. if (obj && obj.has('Dests')) {
  34435. nameTreeRef = obj.getRaw('Dests');
  34436. } else if (this.catDict.has('Dests')) {
  34437. nameDictionaryRef = this.catDict.get('Dests');
  34438. }
  34439. if (nameDictionaryRef) {
  34440. obj = nameDictionaryRef;
  34441. obj.forEach(function catalogForEach(key, value) {
  34442. if (!value) {
  34443. return;
  34444. }
  34445. dests[key] = fetchDestination(value);
  34446. });
  34447. }
  34448. if (nameTreeRef) {
  34449. var nameTree = new NameTree(nameTreeRef, xref);
  34450. var names = nameTree.getAll();
  34451. for (var name in names) {
  34452. dests[name] = fetchDestination(names[name]);
  34453. }
  34454. }
  34455. return shadow(this, 'destinations', dests);
  34456. },
  34457. getDestination: function Catalog_getDestination(destinationId) {
  34458. function fetchDestination(dest) {
  34459. return isDict(dest) ? dest.get('D') : dest;
  34460. }
  34461. var xref = this.xref;
  34462. var dest = null, nameTreeRef, nameDictionaryRef;
  34463. var obj = this.catDict.get('Names');
  34464. if (obj && obj.has('Dests')) {
  34465. nameTreeRef = obj.getRaw('Dests');
  34466. } else if (this.catDict.has('Dests')) {
  34467. nameDictionaryRef = this.catDict.get('Dests');
  34468. }
  34469. if (nameDictionaryRef) {
  34470. var value = nameDictionaryRef.get(destinationId);
  34471. if (value) {
  34472. dest = fetchDestination(value);
  34473. }
  34474. }
  34475. if (nameTreeRef) {
  34476. var nameTree = new NameTree(nameTreeRef, xref);
  34477. dest = fetchDestination(nameTree.get(destinationId));
  34478. }
  34479. return dest;
  34480. },
  34481. get pageLabels() {
  34482. var obj = null;
  34483. try {
  34484. obj = this.readPageLabels();
  34485. } catch (ex) {
  34486. if (ex instanceof MissingDataException) {
  34487. throw ex;
  34488. }
  34489. warn('Unable to read page labels.');
  34490. }
  34491. return shadow(this, 'pageLabels', obj);
  34492. },
  34493. readPageLabels: function Catalog_readPageLabels() {
  34494. var obj = this.catDict.getRaw('PageLabels');
  34495. if (!obj) {
  34496. return null;
  34497. }
  34498. var pageLabels = new Array(this.numPages);
  34499. var style = null;
  34500. var prefix = '';
  34501. var numberTree = new NumberTree(obj, this.xref);
  34502. var nums = numberTree.getAll();
  34503. var currentLabel = '', currentIndex = 1;
  34504. for (var i = 0, ii = this.numPages; i < ii; i++) {
  34505. if (i in nums) {
  34506. var labelDict = nums[i];
  34507. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  34508. var type = labelDict.get('Type');
  34509. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  34510. var s = labelDict.get('S');
  34511. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  34512. style = s ? s.name : null;
  34513. var p = labelDict.get('P');
  34514. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  34515. prefix = p ? stringToPDFString(p) : '';
  34516. var st = labelDict.get('St');
  34517. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  34518. currentIndex = st || 1;
  34519. }
  34520. switch (style) {
  34521. case 'D':
  34522. currentLabel = currentIndex;
  34523. break;
  34524. case 'R':
  34525. case 'r':
  34526. currentLabel = Util.toRoman(currentIndex, style === 'r');
  34527. break;
  34528. case 'A':
  34529. case 'a':
  34530. var LIMIT = 26;
  34531. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  34532. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  34533. var letterIndex = currentIndex - 1;
  34534. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  34535. var charBuf = [];
  34536. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  34537. charBuf.push(character);
  34538. }
  34539. currentLabel = charBuf.join('');
  34540. break;
  34541. default:
  34542. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  34543. }
  34544. pageLabels[i] = prefix + currentLabel;
  34545. currentLabel = '';
  34546. currentIndex++;
  34547. }
  34548. return pageLabels;
  34549. },
  34550. get attachments() {
  34551. var xref = this.xref;
  34552. var attachments = null, nameTreeRef;
  34553. var obj = this.catDict.get('Names');
  34554. if (obj) {
  34555. nameTreeRef = obj.getRaw('EmbeddedFiles');
  34556. }
  34557. if (nameTreeRef) {
  34558. var nameTree = new NameTree(nameTreeRef, xref);
  34559. var names = nameTree.getAll();
  34560. for (var name in names) {
  34561. var fs = new FileSpec(names[name], xref);
  34562. if (!attachments) {
  34563. attachments = Object.create(null);
  34564. }
  34565. attachments[stringToPDFString(name)] = fs.serializable;
  34566. }
  34567. }
  34568. return shadow(this, 'attachments', attachments);
  34569. },
  34570. get javaScript() {
  34571. var xref = this.xref;
  34572. var obj = this.catDict.get('Names');
  34573. var javaScript = [];
  34574. function appendIfJavaScriptDict(jsDict) {
  34575. var type = jsDict.get('S');
  34576. if (!isName(type, 'JavaScript')) {
  34577. return;
  34578. }
  34579. var js = jsDict.get('JS');
  34580. if (isStream(js)) {
  34581. js = bytesToString(js.getBytes());
  34582. } else if (!isString(js)) {
  34583. return;
  34584. }
  34585. javaScript.push(stringToPDFString(js));
  34586. }
  34587. if (obj && obj.has('JavaScript')) {
  34588. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  34589. var names = nameTree.getAll();
  34590. for (var name in names) {
  34591. var jsDict = names[name];
  34592. if (isDict(jsDict)) {
  34593. appendIfJavaScriptDict(jsDict);
  34594. }
  34595. }
  34596. }
  34597. var openactionDict = this.catDict.get('OpenAction');
  34598. if (isDict(openactionDict, 'Action')) {
  34599. var actionType = openactionDict.get('S');
  34600. if (isName(actionType, 'Named')) {
  34601. var action = openactionDict.get('N');
  34602. if (isName(action, 'Print')) {
  34603. javaScript.push('print({});');
  34604. }
  34605. } else {
  34606. appendIfJavaScriptDict(openactionDict);
  34607. }
  34608. }
  34609. return shadow(this, 'javaScript', javaScript);
  34610. },
  34611. cleanup: function Catalog_cleanup() {
  34612. var promises = [];
  34613. this.fontCache.forEach(function (promise) {
  34614. promises.push(promise);
  34615. });
  34616. return Promise.all(promises).then(function (translatedFonts) {
  34617. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  34618. var font = translatedFonts[i].dict;
  34619. delete font.translated;
  34620. }
  34621. this.fontCache.clear();
  34622. this.builtInCMapCache = Object.create(null);
  34623. }.bind(this));
  34624. },
  34625. getPage: function Catalog_getPage(pageIndex) {
  34626. if (!(pageIndex in this.pagePromises)) {
  34627. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  34628. var dict = a[0];
  34629. var ref = a[1];
  34630. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  34631. }.bind(this));
  34632. }
  34633. return this.pagePromises[pageIndex];
  34634. },
  34635. getPageDict: function Catalog_getPageDict(pageIndex) {
  34636. var capability = createPromiseCapability();
  34637. var nodesToVisit = [this.catDict.getRaw('Pages')];
  34638. var currentPageIndex = 0;
  34639. var xref = this.xref;
  34640. var checkAllKids = false;
  34641. function next() {
  34642. while (nodesToVisit.length) {
  34643. var currentNode = nodesToVisit.pop();
  34644. if (isRef(currentNode)) {
  34645. xref.fetchAsync(currentNode).then(function (obj) {
  34646. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  34647. if (pageIndex === currentPageIndex) {
  34648. capability.resolve([
  34649. obj,
  34650. currentNode
  34651. ]);
  34652. } else {
  34653. currentPageIndex++;
  34654. next();
  34655. }
  34656. return;
  34657. }
  34658. nodesToVisit.push(obj);
  34659. next();
  34660. }, capability.reject);
  34661. return;
  34662. }
  34663. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  34664. var count = currentNode.get('Count');
  34665. if (count === 0) {
  34666. checkAllKids = true;
  34667. }
  34668. if (currentPageIndex + count <= pageIndex) {
  34669. currentPageIndex += count;
  34670. continue;
  34671. }
  34672. var kids = currentNode.get('Kids');
  34673. assert(isArray(kids), 'page dictionary kids object is not an array');
  34674. if (!checkAllKids && count === kids.length) {
  34675. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  34676. currentPageIndex = pageIndex;
  34677. continue;
  34678. } else {
  34679. for (var last = kids.length - 1; last >= 0; last--) {
  34680. nodesToVisit.push(kids[last]);
  34681. }
  34682. }
  34683. }
  34684. capability.reject('Page index ' + pageIndex + ' not found.');
  34685. }
  34686. next();
  34687. return capability.promise;
  34688. },
  34689. getPageIndex: function Catalog_getPageIndex(pageRef) {
  34690. var xref = this.xref;
  34691. function pagesBeforeRef(kidRef) {
  34692. var total = 0;
  34693. var parentRef;
  34694. return xref.fetchAsync(kidRef).then(function (node) {
  34695. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  34696. throw new Error('The reference does not point to a /Page Dict.');
  34697. }
  34698. if (!node) {
  34699. return null;
  34700. }
  34701. assert(isDict(node), 'node must be a Dict.');
  34702. parentRef = node.getRaw('Parent');
  34703. return node.getAsync('Parent');
  34704. }).then(function (parent) {
  34705. if (!parent) {
  34706. return null;
  34707. }
  34708. assert(isDict(parent), 'parent must be a Dict.');
  34709. return parent.getAsync('Kids');
  34710. }).then(function (kids) {
  34711. if (!kids) {
  34712. return null;
  34713. }
  34714. var kidPromises = [];
  34715. var found = false;
  34716. for (var i = 0; i < kids.length; i++) {
  34717. var kid = kids[i];
  34718. assert(isRef(kid), 'kid must be a Ref.');
  34719. if (kid.num === kidRef.num) {
  34720. found = true;
  34721. break;
  34722. }
  34723. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  34724. if (kid.has('Count')) {
  34725. var count = kid.get('Count');
  34726. total += count;
  34727. } else {
  34728. total++;
  34729. }
  34730. }));
  34731. }
  34732. if (!found) {
  34733. error('kid ref not found in parents kids');
  34734. }
  34735. return Promise.all(kidPromises).then(function () {
  34736. return [
  34737. total,
  34738. parentRef
  34739. ];
  34740. });
  34741. });
  34742. }
  34743. var total = 0;
  34744. function next(ref) {
  34745. return pagesBeforeRef(ref).then(function (args) {
  34746. if (!args) {
  34747. return total;
  34748. }
  34749. var count = args[0];
  34750. var parentRef = args[1];
  34751. total += count;
  34752. return next(parentRef);
  34753. });
  34754. }
  34755. return next(pageRef);
  34756. }
  34757. };
  34758. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  34759. function addDefaultProtocolToUrl(url) {
  34760. if (url.indexOf('www.') === 0) {
  34761. return 'http://' + url;
  34762. }
  34763. return url;
  34764. }
  34765. function tryConvertUrlEncoding(url) {
  34766. try {
  34767. return stringToUTF8String(url);
  34768. } catch (e) {
  34769. return url;
  34770. }
  34771. }
  34772. var destDict = params.destDict;
  34773. if (!isDict(destDict)) {
  34774. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  34775. return;
  34776. }
  34777. var resultObj = params.resultObj;
  34778. if (typeof resultObj !== 'object') {
  34779. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  34780. return;
  34781. }
  34782. var docBaseUrl = params.docBaseUrl || null;
  34783. var action = destDict.get('A'), url, dest;
  34784. if (isDict(action)) {
  34785. var linkType = action.get('S').name;
  34786. switch (linkType) {
  34787. case 'URI':
  34788. url = action.get('URI');
  34789. if (isName(url)) {
  34790. url = '/' + url.name;
  34791. } else if (isString(url)) {
  34792. url = addDefaultProtocolToUrl(url);
  34793. }
  34794. break;
  34795. case 'GoTo':
  34796. dest = action.get('D');
  34797. break;
  34798. case 'Launch':
  34799. case 'GoToR':
  34800. var urlDict = action.get('F');
  34801. if (isDict(urlDict)) {
  34802. url = urlDict.get('F') || null;
  34803. } else if (isString(urlDict)) {
  34804. url = urlDict;
  34805. }
  34806. var remoteDest = action.get('D');
  34807. if (remoteDest) {
  34808. if (isName(remoteDest)) {
  34809. remoteDest = remoteDest.name;
  34810. }
  34811. if (isString(url)) {
  34812. var baseUrl = url.split('#')[0];
  34813. if (isString(remoteDest)) {
  34814. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34815. } else if (isArray(remoteDest)) {
  34816. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34817. }
  34818. }
  34819. }
  34820. var newWindow = action.get('NewWindow');
  34821. if (isBool(newWindow)) {
  34822. resultObj.newWindow = newWindow;
  34823. }
  34824. break;
  34825. case 'Named':
  34826. var namedAction = action.get('N');
  34827. if (isName(namedAction)) {
  34828. resultObj.action = namedAction.name;
  34829. }
  34830. break;
  34831. case 'JavaScript':
  34832. var jsAction = action.get('JS'), js;
  34833. if (isStream(jsAction)) {
  34834. js = bytesToString(jsAction.getBytes());
  34835. } else if (isString(jsAction)) {
  34836. js = jsAction;
  34837. }
  34838. if (js) {
  34839. var URL_OPEN_METHODS = [
  34840. 'app.launchURL',
  34841. 'window.open'
  34842. ];
  34843. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34844. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34845. if (jsUrl && jsUrl[1]) {
  34846. url = jsUrl[1];
  34847. break;
  34848. }
  34849. }
  34850. default:
  34851. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34852. break;
  34853. }
  34854. } else if (destDict.has('Dest')) {
  34855. dest = destDict.get('Dest');
  34856. }
  34857. if (isString(url)) {
  34858. url = tryConvertUrlEncoding(url);
  34859. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34860. if (absoluteUrl) {
  34861. resultObj.url = absoluteUrl.href;
  34862. }
  34863. resultObj.unsafeUrl = url;
  34864. }
  34865. if (dest) {
  34866. if (isName(dest)) {
  34867. dest = dest.name;
  34868. }
  34869. if (isString(dest) || isArray(dest)) {
  34870. resultObj.dest = dest;
  34871. }
  34872. }
  34873. };
  34874. return Catalog;
  34875. }();
  34876. var XRef = function XRefClosure() {
  34877. function XRef(stream, pdfManager) {
  34878. this.stream = stream;
  34879. this.pdfManager = pdfManager;
  34880. this.entries = [];
  34881. this.xrefstms = Object.create(null);
  34882. this.cache = [];
  34883. this.stats = {
  34884. streamTypes: [],
  34885. fontTypes: []
  34886. };
  34887. }
  34888. XRef.prototype = {
  34889. setStartXRef: function XRef_setStartXRef(startXRef) {
  34890. this.startXRefQueue = [startXRef];
  34891. },
  34892. parse: function XRef_parse(recoveryMode) {
  34893. var trailerDict;
  34894. if (!recoveryMode) {
  34895. trailerDict = this.readXRef();
  34896. } else {
  34897. warn('Indexing all PDF objects');
  34898. trailerDict = this.indexObjects();
  34899. }
  34900. trailerDict.assignXref(this);
  34901. this.trailer = trailerDict;
  34902. var encrypt = trailerDict.get('Encrypt');
  34903. if (isDict(encrypt)) {
  34904. var ids = trailerDict.get('ID');
  34905. var fileId = ids && ids.length ? ids[0] : '';
  34906. encrypt.suppressEncryption = true;
  34907. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34908. }
  34909. if (!(this.root = trailerDict.get('Root'))) {
  34910. error('Invalid root reference');
  34911. }
  34912. },
  34913. processXRefTable: function XRef_processXRefTable(parser) {
  34914. if (!('tableState' in this)) {
  34915. this.tableState = {
  34916. entryNum: 0,
  34917. streamPos: parser.lexer.stream.pos,
  34918. parserBuf1: parser.buf1,
  34919. parserBuf2: parser.buf2
  34920. };
  34921. }
  34922. var obj = this.readXRefTable(parser);
  34923. if (!isCmd(obj, 'trailer')) {
  34924. error('Invalid XRef table: could not find trailer dictionary');
  34925. }
  34926. var dict = parser.getObj();
  34927. if (!isDict(dict) && dict.dict) {
  34928. dict = dict.dict;
  34929. }
  34930. if (!isDict(dict)) {
  34931. error('Invalid XRef table: could not parse trailer dictionary');
  34932. }
  34933. delete this.tableState;
  34934. return dict;
  34935. },
  34936. readXRefTable: function XRef_readXRefTable(parser) {
  34937. var stream = parser.lexer.stream;
  34938. var tableState = this.tableState;
  34939. stream.pos = tableState.streamPos;
  34940. parser.buf1 = tableState.parserBuf1;
  34941. parser.buf2 = tableState.parserBuf2;
  34942. var obj;
  34943. while (true) {
  34944. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34945. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34946. break;
  34947. }
  34948. tableState.firstEntryNum = obj;
  34949. tableState.entryCount = parser.getObj();
  34950. }
  34951. var first = tableState.firstEntryNum;
  34952. var count = tableState.entryCount;
  34953. if (!isInt(first) || !isInt(count)) {
  34954. error('Invalid XRef table: wrong types in subsection header');
  34955. }
  34956. for (var i = tableState.entryNum; i < count; i++) {
  34957. tableState.streamPos = stream.pos;
  34958. tableState.entryNum = i;
  34959. tableState.parserBuf1 = parser.buf1;
  34960. tableState.parserBuf2 = parser.buf2;
  34961. var entry = {};
  34962. entry.offset = parser.getObj();
  34963. entry.gen = parser.getObj();
  34964. var type = parser.getObj();
  34965. if (isCmd(type, 'f')) {
  34966. entry.free = true;
  34967. } else if (isCmd(type, 'n')) {
  34968. entry.uncompressed = true;
  34969. }
  34970. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34971. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34972. }
  34973. if (i === 0 && entry.free && first === 1) {
  34974. first = 0;
  34975. }
  34976. if (!this.entries[i + first]) {
  34977. this.entries[i + first] = entry;
  34978. }
  34979. }
  34980. tableState.entryNum = 0;
  34981. tableState.streamPos = stream.pos;
  34982. tableState.parserBuf1 = parser.buf1;
  34983. tableState.parserBuf2 = parser.buf2;
  34984. delete tableState.firstEntryNum;
  34985. delete tableState.entryCount;
  34986. }
  34987. if (this.entries[0] && !this.entries[0].free) {
  34988. error('Invalid XRef table: unexpected first object');
  34989. }
  34990. return obj;
  34991. },
  34992. processXRefStream: function XRef_processXRefStream(stream) {
  34993. if (!('streamState' in this)) {
  34994. var streamParameters = stream.dict;
  34995. var byteWidths = streamParameters.get('W');
  34996. var range = streamParameters.get('Index');
  34997. if (!range) {
  34998. range = [
  34999. 0,
  35000. streamParameters.get('Size')
  35001. ];
  35002. }
  35003. this.streamState = {
  35004. entryRanges: range,
  35005. byteWidths: byteWidths,
  35006. entryNum: 0,
  35007. streamPos: stream.pos
  35008. };
  35009. }
  35010. this.readXRefStream(stream);
  35011. delete this.streamState;
  35012. return stream.dict;
  35013. },
  35014. readXRefStream: function XRef_readXRefStream(stream) {
  35015. var i, j;
  35016. var streamState = this.streamState;
  35017. stream.pos = streamState.streamPos;
  35018. var byteWidths = streamState.byteWidths;
  35019. var typeFieldWidth = byteWidths[0];
  35020. var offsetFieldWidth = byteWidths[1];
  35021. var generationFieldWidth = byteWidths[2];
  35022. var entryRanges = streamState.entryRanges;
  35023. while (entryRanges.length > 0) {
  35024. var first = entryRanges[0];
  35025. var n = entryRanges[1];
  35026. if (!isInt(first) || !isInt(n)) {
  35027. error('Invalid XRef range fields: ' + first + ', ' + n);
  35028. }
  35029. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  35030. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  35031. }
  35032. for (i = streamState.entryNum; i < n; ++i) {
  35033. streamState.entryNum = i;
  35034. streamState.streamPos = stream.pos;
  35035. var type = 0, offset = 0, generation = 0;
  35036. for (j = 0; j < typeFieldWidth; ++j) {
  35037. type = type << 8 | stream.getByte();
  35038. }
  35039. if (typeFieldWidth === 0) {
  35040. type = 1;
  35041. }
  35042. for (j = 0; j < offsetFieldWidth; ++j) {
  35043. offset = offset << 8 | stream.getByte();
  35044. }
  35045. for (j = 0; j < generationFieldWidth; ++j) {
  35046. generation = generation << 8 | stream.getByte();
  35047. }
  35048. var entry = {};
  35049. entry.offset = offset;
  35050. entry.gen = generation;
  35051. switch (type) {
  35052. case 0:
  35053. entry.free = true;
  35054. break;
  35055. case 1:
  35056. entry.uncompressed = true;
  35057. break;
  35058. case 2:
  35059. break;
  35060. default:
  35061. error('Invalid XRef entry type: ' + type);
  35062. }
  35063. if (!this.entries[first + i]) {
  35064. this.entries[first + i] = entry;
  35065. }
  35066. }
  35067. streamState.entryNum = 0;
  35068. streamState.streamPos = stream.pos;
  35069. entryRanges.splice(0, 2);
  35070. }
  35071. },
  35072. indexObjects: function XRef_indexObjects() {
  35073. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  35074. var PERCENT = 0x25, LT = 0x3C;
  35075. function readToken(data, offset) {
  35076. var token = '', ch = data[offset];
  35077. while (ch !== LF && ch !== CR && ch !== LT) {
  35078. if (++offset >= data.length) {
  35079. break;
  35080. }
  35081. token += String.fromCharCode(ch);
  35082. ch = data[offset];
  35083. }
  35084. return token;
  35085. }
  35086. function skipUntil(data, offset, what) {
  35087. var length = what.length, dataLength = data.length;
  35088. var skipped = 0;
  35089. while (offset < dataLength) {
  35090. var i = 0;
  35091. while (i < length && data[offset + i] === what[i]) {
  35092. ++i;
  35093. }
  35094. if (i >= length) {
  35095. break;
  35096. }
  35097. offset++;
  35098. skipped++;
  35099. }
  35100. return skipped;
  35101. }
  35102. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35103. var trailerBytes = new Uint8Array([
  35104. 116,
  35105. 114,
  35106. 97,
  35107. 105,
  35108. 108,
  35109. 101,
  35110. 114
  35111. ]);
  35112. var startxrefBytes = new Uint8Array([
  35113. 115,
  35114. 116,
  35115. 97,
  35116. 114,
  35117. 116,
  35118. 120,
  35119. 114,
  35120. 101,
  35121. 102
  35122. ]);
  35123. var endobjBytes = new Uint8Array([
  35124. 101,
  35125. 110,
  35126. 100,
  35127. 111,
  35128. 98,
  35129. 106
  35130. ]);
  35131. var xrefBytes = new Uint8Array([
  35132. 47,
  35133. 88,
  35134. 82,
  35135. 101,
  35136. 102
  35137. ]);
  35138. this.entries.length = 0;
  35139. var stream = this.stream;
  35140. stream.pos = 0;
  35141. var buffer = stream.getBytes();
  35142. var position = stream.start, length = buffer.length;
  35143. var trailers = [], xrefStms = [];
  35144. while (position < length) {
  35145. var ch = buffer[position];
  35146. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35147. ++position;
  35148. continue;
  35149. }
  35150. if (ch === PERCENT) {
  35151. do {
  35152. ++position;
  35153. if (position >= length) {
  35154. break;
  35155. }
  35156. ch = buffer[position];
  35157. } while (ch !== LF && ch !== CR);
  35158. continue;
  35159. }
  35160. var token = readToken(buffer, position);
  35161. var m;
  35162. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35163. position += skipUntil(buffer, position, trailerBytes);
  35164. trailers.push(position);
  35165. position += skipUntil(buffer, position, startxrefBytes);
  35166. } else if (m = objRegExp.exec(token)) {
  35167. if (typeof this.entries[m[1]] === 'undefined') {
  35168. this.entries[m[1]] = {
  35169. offset: position - stream.start,
  35170. gen: m[2] | 0,
  35171. uncompressed: true
  35172. };
  35173. }
  35174. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35175. var content = buffer.subarray(position, position + contentLength);
  35176. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35177. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35178. xrefStms.push(position - stream.start);
  35179. this.xrefstms[position - stream.start] = 1;
  35180. }
  35181. position += contentLength;
  35182. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35183. trailers.push(position);
  35184. position += skipUntil(buffer, position, startxrefBytes);
  35185. } else {
  35186. position += token.length + 1;
  35187. }
  35188. }
  35189. var i, ii;
  35190. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35191. this.startXRefQueue.push(xrefStms[i]);
  35192. this.readXRef(true);
  35193. }
  35194. var dict;
  35195. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35196. stream.pos = trailers[i];
  35197. var parser = new Parser(new Lexer(stream), true, this, true);
  35198. var obj = parser.getObj();
  35199. if (!isCmd(obj, 'trailer')) {
  35200. continue;
  35201. }
  35202. dict = parser.getObj();
  35203. if (!isDict(dict)) {
  35204. continue;
  35205. }
  35206. if (dict.has('ID')) {
  35207. return dict;
  35208. }
  35209. }
  35210. if (dict) {
  35211. return dict;
  35212. }
  35213. throw new InvalidPDFException('Invalid PDF structure');
  35214. },
  35215. readXRef: function XRef_readXRef(recoveryMode) {
  35216. var stream = this.stream;
  35217. try {
  35218. while (this.startXRefQueue.length) {
  35219. var startXRef = this.startXRefQueue[0];
  35220. stream.pos = startXRef + stream.start;
  35221. var parser = new Parser(new Lexer(stream), true, this);
  35222. var obj = parser.getObj();
  35223. var dict;
  35224. if (isCmd(obj, 'xref')) {
  35225. dict = this.processXRefTable(parser);
  35226. if (!this.topDict) {
  35227. this.topDict = dict;
  35228. }
  35229. obj = dict.get('XRefStm');
  35230. if (isInt(obj)) {
  35231. var pos = obj;
  35232. if (!(pos in this.xrefstms)) {
  35233. this.xrefstms[pos] = 1;
  35234. this.startXRefQueue.push(pos);
  35235. }
  35236. }
  35237. } else if (isInt(obj)) {
  35238. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35239. error('Invalid XRef stream');
  35240. }
  35241. dict = this.processXRefStream(obj);
  35242. if (!this.topDict) {
  35243. this.topDict = dict;
  35244. }
  35245. if (!dict) {
  35246. error('Failed to read XRef stream');
  35247. }
  35248. } else {
  35249. error('Invalid XRef stream header');
  35250. }
  35251. obj = dict.get('Prev');
  35252. if (isInt(obj)) {
  35253. this.startXRefQueue.push(obj);
  35254. } else if (isRef(obj)) {
  35255. this.startXRefQueue.push(obj.num);
  35256. }
  35257. this.startXRefQueue.shift();
  35258. }
  35259. return this.topDict;
  35260. } catch (e) {
  35261. if (e instanceof MissingDataException) {
  35262. throw e;
  35263. }
  35264. info('(while reading XRef): ' + e);
  35265. }
  35266. if (recoveryMode) {
  35267. return;
  35268. }
  35269. throw new XRefParseException();
  35270. },
  35271. getEntry: function XRef_getEntry(i) {
  35272. var xrefEntry = this.entries[i];
  35273. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35274. return xrefEntry;
  35275. }
  35276. return null;
  35277. },
  35278. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35279. if (!isRef(obj)) {
  35280. return obj;
  35281. }
  35282. return this.fetch(obj, suppressEncryption);
  35283. },
  35284. fetch: function XRef_fetch(ref, suppressEncryption) {
  35285. assert(isRef(ref), 'ref object is not a reference');
  35286. var num = ref.num;
  35287. if (num in this.cache) {
  35288. var cacheEntry = this.cache[num];
  35289. return cacheEntry;
  35290. }
  35291. var xrefEntry = this.getEntry(num);
  35292. if (xrefEntry === null) {
  35293. return this.cache[num] = null;
  35294. }
  35295. if (xrefEntry.uncompressed) {
  35296. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35297. } else {
  35298. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35299. }
  35300. if (isDict(xrefEntry)) {
  35301. xrefEntry.objId = ref.toString();
  35302. } else if (isStream(xrefEntry)) {
  35303. xrefEntry.dict.objId = ref.toString();
  35304. }
  35305. return xrefEntry;
  35306. },
  35307. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35308. var gen = ref.gen;
  35309. var num = ref.num;
  35310. if (xrefEntry.gen !== gen) {
  35311. error('inconsistent generation in XRef');
  35312. }
  35313. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35314. var parser = new Parser(new Lexer(stream), true, this);
  35315. var obj1 = parser.getObj();
  35316. var obj2 = parser.getObj();
  35317. var obj3 = parser.getObj();
  35318. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35319. error('bad XRef entry');
  35320. }
  35321. if (!isCmd(obj3, 'obj')) {
  35322. if (obj3.cmd.indexOf('obj') === 0) {
  35323. num = parseInt(obj3.cmd.substring(3), 10);
  35324. if (!isNaN(num)) {
  35325. return num;
  35326. }
  35327. }
  35328. error('bad XRef entry');
  35329. }
  35330. if (this.encrypt && !suppressEncryption) {
  35331. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35332. } else {
  35333. xrefEntry = parser.getObj();
  35334. }
  35335. if (!isStream(xrefEntry)) {
  35336. this.cache[num] = xrefEntry;
  35337. }
  35338. return xrefEntry;
  35339. },
  35340. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35341. var tableOffset = xrefEntry.offset;
  35342. var stream = this.fetch(new Ref(tableOffset, 0));
  35343. if (!isStream(stream)) {
  35344. error('bad ObjStm stream');
  35345. }
  35346. var first = stream.dict.get('First');
  35347. var n = stream.dict.get('N');
  35348. if (!isInt(first) || !isInt(n)) {
  35349. error('invalid first and n parameters for ObjStm stream');
  35350. }
  35351. var parser = new Parser(new Lexer(stream), false, this);
  35352. parser.allowStreams = true;
  35353. var i, entries = [], num, nums = [];
  35354. for (i = 0; i < n; ++i) {
  35355. num = parser.getObj();
  35356. if (!isInt(num)) {
  35357. error('invalid object number in the ObjStm stream: ' + num);
  35358. }
  35359. nums.push(num);
  35360. var offset = parser.getObj();
  35361. if (!isInt(offset)) {
  35362. error('invalid object offset in the ObjStm stream: ' + offset);
  35363. }
  35364. }
  35365. for (i = 0; i < n; ++i) {
  35366. entries.push(parser.getObj());
  35367. if (isCmd(parser.buf1, 'endobj')) {
  35368. parser.shift();
  35369. }
  35370. num = nums[i];
  35371. var entry = this.entries[num];
  35372. if (entry && entry.offset === tableOffset && entry.gen === i) {
  35373. this.cache[num] = entries[i];
  35374. }
  35375. }
  35376. xrefEntry = entries[xrefEntry.gen];
  35377. if (xrefEntry === undefined) {
  35378. error('bad XRef entry for compressed object');
  35379. }
  35380. return xrefEntry;
  35381. },
  35382. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  35383. if (!isRef(obj)) {
  35384. return Promise.resolve(obj);
  35385. }
  35386. return this.fetchAsync(obj, suppressEncryption);
  35387. },
  35388. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  35389. var streamManager = this.stream.manager;
  35390. var xref = this;
  35391. return new Promise(function tryFetch(resolve, reject) {
  35392. try {
  35393. resolve(xref.fetch(ref, suppressEncryption));
  35394. } catch (e) {
  35395. if (e instanceof MissingDataException) {
  35396. streamManager.requestRange(e.begin, e.end).then(function () {
  35397. tryFetch(resolve, reject);
  35398. }, reject);
  35399. return;
  35400. }
  35401. reject(e);
  35402. }
  35403. });
  35404. },
  35405. getCatalogObj: function XRef_getCatalogObj() {
  35406. return this.root;
  35407. }
  35408. };
  35409. return XRef;
  35410. }();
  35411. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  35412. function NameOrNumberTree(root, xref) {
  35413. throw new Error('Cannot initialize NameOrNumberTree.');
  35414. }
  35415. NameOrNumberTree.prototype = {
  35416. getAll: function NameOrNumberTree_getAll() {
  35417. var dict = Object.create(null);
  35418. if (!this.root) {
  35419. return dict;
  35420. }
  35421. var xref = this.xref;
  35422. var processed = new RefSet();
  35423. processed.put(this.root);
  35424. var queue = [this.root];
  35425. while (queue.length > 0) {
  35426. var i, n;
  35427. var obj = xref.fetchIfRef(queue.shift());
  35428. if (!isDict(obj)) {
  35429. continue;
  35430. }
  35431. if (obj.has('Kids')) {
  35432. var kids = obj.get('Kids');
  35433. for (i = 0, n = kids.length; i < n; i++) {
  35434. var kid = kids[i];
  35435. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  35436. queue.push(kid);
  35437. processed.put(kid);
  35438. }
  35439. continue;
  35440. }
  35441. var entries = obj.get(this._type);
  35442. if (isArray(entries)) {
  35443. for (i = 0, n = entries.length; i < n; i += 2) {
  35444. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  35445. }
  35446. }
  35447. }
  35448. return dict;
  35449. },
  35450. get: function NameOrNumberTree_get(key) {
  35451. if (!this.root) {
  35452. return null;
  35453. }
  35454. var xref = this.xref;
  35455. var kidsOrEntries = xref.fetchIfRef(this.root);
  35456. var loopCount = 0;
  35457. var MAX_LEVELS = 10;
  35458. var l, r, m;
  35459. while (kidsOrEntries.has('Kids')) {
  35460. if (++loopCount > MAX_LEVELS) {
  35461. warn('Search depth limit reached for "' + this._type + '" tree.');
  35462. return null;
  35463. }
  35464. var kids = kidsOrEntries.get('Kids');
  35465. if (!isArray(kids)) {
  35466. return null;
  35467. }
  35468. l = 0;
  35469. r = kids.length - 1;
  35470. while (l <= r) {
  35471. m = l + r >> 1;
  35472. var kid = xref.fetchIfRef(kids[m]);
  35473. var limits = kid.get('Limits');
  35474. if (key < xref.fetchIfRef(limits[0])) {
  35475. r = m - 1;
  35476. } else if (key > xref.fetchIfRef(limits[1])) {
  35477. l = m + 1;
  35478. } else {
  35479. kidsOrEntries = xref.fetchIfRef(kids[m]);
  35480. break;
  35481. }
  35482. }
  35483. if (l > r) {
  35484. return null;
  35485. }
  35486. }
  35487. var entries = kidsOrEntries.get(this._type);
  35488. if (isArray(entries)) {
  35489. l = 0;
  35490. r = entries.length - 2;
  35491. while (l <= r) {
  35492. m = l + r & ~1;
  35493. var currentKey = xref.fetchIfRef(entries[m]);
  35494. if (key < currentKey) {
  35495. r = m - 2;
  35496. } else if (key > currentKey) {
  35497. l = m + 2;
  35498. } else {
  35499. return xref.fetchIfRef(entries[m + 1]);
  35500. }
  35501. }
  35502. }
  35503. return null;
  35504. }
  35505. };
  35506. return NameOrNumberTree;
  35507. }();
  35508. var NameTree = function NameTreeClosure() {
  35509. function NameTree(root, xref) {
  35510. this.root = root;
  35511. this.xref = xref;
  35512. this._type = 'Names';
  35513. }
  35514. Util.inherit(NameTree, NameOrNumberTree, {});
  35515. return NameTree;
  35516. }();
  35517. var NumberTree = function NumberTreeClosure() {
  35518. function NumberTree(root, xref) {
  35519. this.root = root;
  35520. this.xref = xref;
  35521. this._type = 'Nums';
  35522. }
  35523. Util.inherit(NumberTree, NameOrNumberTree, {});
  35524. return NumberTree;
  35525. }();
  35526. var FileSpec = function FileSpecClosure() {
  35527. function FileSpec(root, xref) {
  35528. if (!root || !isDict(root)) {
  35529. return;
  35530. }
  35531. this.xref = xref;
  35532. this.root = root;
  35533. if (root.has('FS')) {
  35534. this.fs = root.get('FS');
  35535. }
  35536. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  35537. if (root.has('RF')) {
  35538. warn('Related file specifications are not supported');
  35539. }
  35540. this.contentAvailable = true;
  35541. if (!root.has('EF')) {
  35542. this.contentAvailable = false;
  35543. warn('Non-embedded file specifications are not supported');
  35544. }
  35545. }
  35546. function pickPlatformItem(dict) {
  35547. if (dict.has('UF')) {
  35548. return dict.get('UF');
  35549. } else if (dict.has('F')) {
  35550. return dict.get('F');
  35551. } else if (dict.has('Unix')) {
  35552. return dict.get('Unix');
  35553. } else if (dict.has('Mac')) {
  35554. return dict.get('Mac');
  35555. } else if (dict.has('DOS')) {
  35556. return dict.get('DOS');
  35557. }
  35558. return null;
  35559. }
  35560. FileSpec.prototype = {
  35561. get filename() {
  35562. if (!this._filename && this.root) {
  35563. var filename = pickPlatformItem(this.root) || 'unnamed';
  35564. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  35565. }
  35566. return this._filename;
  35567. },
  35568. get content() {
  35569. if (!this.contentAvailable) {
  35570. return null;
  35571. }
  35572. if (!this.contentRef && this.root) {
  35573. this.contentRef = pickPlatformItem(this.root.get('EF'));
  35574. }
  35575. var content = null;
  35576. if (this.contentRef) {
  35577. var xref = this.xref;
  35578. var fileObj = xref.fetchIfRef(this.contentRef);
  35579. if (fileObj && isStream(fileObj)) {
  35580. content = fileObj.getBytes();
  35581. } else {
  35582. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  35583. }
  35584. } else {
  35585. warn('Embedded file specification does not have a content');
  35586. }
  35587. return content;
  35588. },
  35589. get serializable() {
  35590. return {
  35591. filename: this.filename,
  35592. content: this.content
  35593. };
  35594. }
  35595. };
  35596. return FileSpec;
  35597. }();
  35598. var ObjectLoader = function () {
  35599. function mayHaveChildren(value) {
  35600. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  35601. }
  35602. function addChildren(node, nodesToVisit) {
  35603. var value;
  35604. if (isDict(node) || isStream(node)) {
  35605. var map;
  35606. if (isDict(node)) {
  35607. map = node.map;
  35608. } else {
  35609. map = node.dict.map;
  35610. }
  35611. for (var key in map) {
  35612. value = map[key];
  35613. if (mayHaveChildren(value)) {
  35614. nodesToVisit.push(value);
  35615. }
  35616. }
  35617. } else if (isArray(node)) {
  35618. for (var i = 0, ii = node.length; i < ii; i++) {
  35619. value = node[i];
  35620. if (mayHaveChildren(value)) {
  35621. nodesToVisit.push(value);
  35622. }
  35623. }
  35624. }
  35625. }
  35626. function ObjectLoader(obj, keys, xref) {
  35627. this.obj = obj;
  35628. this.keys = keys;
  35629. this.xref = xref;
  35630. this.refSet = null;
  35631. this.capability = null;
  35632. }
  35633. ObjectLoader.prototype = {
  35634. load: function ObjectLoader_load() {
  35635. var keys = this.keys;
  35636. this.capability = createPromiseCapability();
  35637. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  35638. this.capability.resolve();
  35639. return this.capability.promise;
  35640. }
  35641. this.refSet = new RefSet();
  35642. var nodesToVisit = [];
  35643. for (var i = 0; i < keys.length; i++) {
  35644. nodesToVisit.push(this.obj[keys[i]]);
  35645. }
  35646. this._walk(nodesToVisit);
  35647. return this.capability.promise;
  35648. },
  35649. _walk: function ObjectLoader_walk(nodesToVisit) {
  35650. var nodesToRevisit = [];
  35651. var pendingRequests = [];
  35652. while (nodesToVisit.length) {
  35653. var currentNode = nodesToVisit.pop();
  35654. if (isRef(currentNode)) {
  35655. if (this.refSet.has(currentNode)) {
  35656. continue;
  35657. }
  35658. try {
  35659. var ref = currentNode;
  35660. this.refSet.put(ref);
  35661. currentNode = this.xref.fetch(currentNode);
  35662. } catch (e) {
  35663. if (!(e instanceof MissingDataException)) {
  35664. throw e;
  35665. }
  35666. nodesToRevisit.push(currentNode);
  35667. pendingRequests.push({
  35668. begin: e.begin,
  35669. end: e.end
  35670. });
  35671. }
  35672. }
  35673. if (currentNode && currentNode.getBaseStreams) {
  35674. var baseStreams = currentNode.getBaseStreams();
  35675. var foundMissingData = false;
  35676. for (var i = 0; i < baseStreams.length; i++) {
  35677. var stream = baseStreams[i];
  35678. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  35679. foundMissingData = true;
  35680. pendingRequests.push({
  35681. begin: stream.start,
  35682. end: stream.end
  35683. });
  35684. }
  35685. }
  35686. if (foundMissingData) {
  35687. nodesToRevisit.push(currentNode);
  35688. }
  35689. }
  35690. addChildren(currentNode, nodesToVisit);
  35691. }
  35692. if (pendingRequests.length) {
  35693. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  35694. nodesToVisit = nodesToRevisit;
  35695. for (var i = 0; i < nodesToRevisit.length; i++) {
  35696. var node = nodesToRevisit[i];
  35697. if (isRef(node)) {
  35698. this.refSet.remove(node);
  35699. }
  35700. }
  35701. this._walk(nodesToVisit);
  35702. }.bind(this), this.capability.reject);
  35703. return;
  35704. }
  35705. this.refSet = null;
  35706. this.capability.resolve();
  35707. }
  35708. };
  35709. return ObjectLoader;
  35710. }();
  35711. exports.Catalog = Catalog;
  35712. exports.ObjectLoader = ObjectLoader;
  35713. exports.XRef = XRef;
  35714. exports.FileSpec = FileSpec;
  35715. /***/ }),
  35716. /* 20 */
  35717. /***/ (function(module, exports, __w_pdfjs_require__) {
  35718. "use strict";
  35719. var sharedUtil = __w_pdfjs_require__(0);
  35720. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35721. var getStdFontMap = getLookupTableFactory(function (t) {
  35722. t['ArialNarrow'] = 'Helvetica';
  35723. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  35724. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  35725. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  35726. t['ArialBlack'] = 'Helvetica';
  35727. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  35728. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  35729. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  35730. t['Arial-Black'] = 'Helvetica';
  35731. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  35732. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  35733. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  35734. t['Arial'] = 'Helvetica';
  35735. t['Arial-Bold'] = 'Helvetica-Bold';
  35736. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  35737. t['Arial-Italic'] = 'Helvetica-Oblique';
  35738. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  35739. t['Arial-BoldMT'] = 'Helvetica-Bold';
  35740. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  35741. t['ArialMT'] = 'Helvetica';
  35742. t['Courier-Bold'] = 'Courier-Bold';
  35743. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  35744. t['Courier-Italic'] = 'Courier-Oblique';
  35745. t['CourierNew'] = 'Courier';
  35746. t['CourierNew-Bold'] = 'Courier-Bold';
  35747. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  35748. t['CourierNew-Italic'] = 'Courier-Oblique';
  35749. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  35750. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  35751. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  35752. t['CourierNewPSMT'] = 'Courier';
  35753. t['Helvetica'] = 'Helvetica';
  35754. t['Helvetica-Bold'] = 'Helvetica-Bold';
  35755. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  35756. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  35757. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  35758. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  35759. t['Symbol-Bold'] = 'Symbol';
  35760. t['Symbol-BoldItalic'] = 'Symbol';
  35761. t['Symbol-Italic'] = 'Symbol';
  35762. t['TimesNewRoman'] = 'Times-Roman';
  35763. t['TimesNewRoman-Bold'] = 'Times-Bold';
  35764. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  35765. t['TimesNewRoman-Italic'] = 'Times-Italic';
  35766. t['TimesNewRomanPS'] = 'Times-Roman';
  35767. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  35768. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  35769. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  35770. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  35771. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  35772. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  35773. t['TimesNewRomanPSMT'] = 'Times-Roman';
  35774. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  35775. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  35776. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  35777. });
  35778. var getNonStdFontMap = getLookupTableFactory(function (t) {
  35779. t['CenturyGothic'] = 'Helvetica';
  35780. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  35781. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  35782. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  35783. t['ComicSansMS'] = 'Comic Sans MS';
  35784. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  35785. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35786. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35787. t['LucidaConsole'] = 'Courier';
  35788. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35789. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35790. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35791. t['MS-Gothic'] = 'MS Gothic';
  35792. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35793. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35794. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35795. t['MS-Mincho'] = 'MS Mincho';
  35796. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35797. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35798. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35799. t['MS-PGothic'] = 'MS PGothic';
  35800. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35801. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35802. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35803. t['MS-PMincho'] = 'MS PMincho';
  35804. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35805. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35806. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35807. t['NuptialScript'] = 'Times-Italic';
  35808. t['Wingdings'] = 'ZapfDingbats';
  35809. });
  35810. var getSerifFonts = getLookupTableFactory(function (t) {
  35811. t['Adobe Jenson'] = true;
  35812. t['Adobe Text'] = true;
  35813. t['Albertus'] = true;
  35814. t['Aldus'] = true;
  35815. t['Alexandria'] = true;
  35816. t['Algerian'] = true;
  35817. t['American Typewriter'] = true;
  35818. t['Antiqua'] = true;
  35819. t['Apex'] = true;
  35820. t['Arno'] = true;
  35821. t['Aster'] = true;
  35822. t['Aurora'] = true;
  35823. t['Baskerville'] = true;
  35824. t['Bell'] = true;
  35825. t['Bembo'] = true;
  35826. t['Bembo Schoolbook'] = true;
  35827. t['Benguiat'] = true;
  35828. t['Berkeley Old Style'] = true;
  35829. t['Bernhard Modern'] = true;
  35830. t['Berthold City'] = true;
  35831. t['Bodoni'] = true;
  35832. t['Bauer Bodoni'] = true;
  35833. t['Book Antiqua'] = true;
  35834. t['Bookman'] = true;
  35835. t['Bordeaux Roman'] = true;
  35836. t['Californian FB'] = true;
  35837. t['Calisto'] = true;
  35838. t['Calvert'] = true;
  35839. t['Capitals'] = true;
  35840. t['Cambria'] = true;
  35841. t['Cartier'] = true;
  35842. t['Caslon'] = true;
  35843. t['Catull'] = true;
  35844. t['Centaur'] = true;
  35845. t['Century Old Style'] = true;
  35846. t['Century Schoolbook'] = true;
  35847. t['Chaparral'] = true;
  35848. t['Charis SIL'] = true;
  35849. t['Cheltenham'] = true;
  35850. t['Cholla Slab'] = true;
  35851. t['Clarendon'] = true;
  35852. t['Clearface'] = true;
  35853. t['Cochin'] = true;
  35854. t['Colonna'] = true;
  35855. t['Computer Modern'] = true;
  35856. t['Concrete Roman'] = true;
  35857. t['Constantia'] = true;
  35858. t['Cooper Black'] = true;
  35859. t['Corona'] = true;
  35860. t['Ecotype'] = true;
  35861. t['Egyptienne'] = true;
  35862. t['Elephant'] = true;
  35863. t['Excelsior'] = true;
  35864. t['Fairfield'] = true;
  35865. t['FF Scala'] = true;
  35866. t['Folkard'] = true;
  35867. t['Footlight'] = true;
  35868. t['FreeSerif'] = true;
  35869. t['Friz Quadrata'] = true;
  35870. t['Garamond'] = true;
  35871. t['Gentium'] = true;
  35872. t['Georgia'] = true;
  35873. t['Gloucester'] = true;
  35874. t['Goudy Old Style'] = true;
  35875. t['Goudy Schoolbook'] = true;
  35876. t['Goudy Pro Font'] = true;
  35877. t['Granjon'] = true;
  35878. t['Guardian Egyptian'] = true;
  35879. t['Heather'] = true;
  35880. t['Hercules'] = true;
  35881. t['High Tower Text'] = true;
  35882. t['Hiroshige'] = true;
  35883. t['Hoefler Text'] = true;
  35884. t['Humana Serif'] = true;
  35885. t['Imprint'] = true;
  35886. t['Ionic No. 5'] = true;
  35887. t['Janson'] = true;
  35888. t['Joanna'] = true;
  35889. t['Korinna'] = true;
  35890. t['Lexicon'] = true;
  35891. t['Liberation Serif'] = true;
  35892. t['Linux Libertine'] = true;
  35893. t['Literaturnaya'] = true;
  35894. t['Lucida'] = true;
  35895. t['Lucida Bright'] = true;
  35896. t['Melior'] = true;
  35897. t['Memphis'] = true;
  35898. t['Miller'] = true;
  35899. t['Minion'] = true;
  35900. t['Modern'] = true;
  35901. t['Mona Lisa'] = true;
  35902. t['Mrs Eaves'] = true;
  35903. t['MS Serif'] = true;
  35904. t['Museo Slab'] = true;
  35905. t['New York'] = true;
  35906. t['Nimbus Roman'] = true;
  35907. t['NPS Rawlinson Roadway'] = true;
  35908. t['NuptialScript'] = true;
  35909. t['Palatino'] = true;
  35910. t['Perpetua'] = true;
  35911. t['Plantin'] = true;
  35912. t['Plantin Schoolbook'] = true;
  35913. t['Playbill'] = true;
  35914. t['Poor Richard'] = true;
  35915. t['Rawlinson Roadway'] = true;
  35916. t['Renault'] = true;
  35917. t['Requiem'] = true;
  35918. t['Rockwell'] = true;
  35919. t['Roman'] = true;
  35920. t['Rotis Serif'] = true;
  35921. t['Sabon'] = true;
  35922. t['Scala'] = true;
  35923. t['Seagull'] = true;
  35924. t['Sistina'] = true;
  35925. t['Souvenir'] = true;
  35926. t['STIX'] = true;
  35927. t['Stone Informal'] = true;
  35928. t['Stone Serif'] = true;
  35929. t['Sylfaen'] = true;
  35930. t['Times'] = true;
  35931. t['Trajan'] = true;
  35932. t['Trinité'] = true;
  35933. t['Trump Mediaeval'] = true;
  35934. t['Utopia'] = true;
  35935. t['Vale Type'] = true;
  35936. t['Bitstream Vera'] = true;
  35937. t['Vera Serif'] = true;
  35938. t['Versailles'] = true;
  35939. t['Wanted'] = true;
  35940. t['Weiss'] = true;
  35941. t['Wide Latin'] = true;
  35942. t['Windsor'] = true;
  35943. t['XITS'] = true;
  35944. });
  35945. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35946. t['Dingbats'] = true;
  35947. t['Symbol'] = true;
  35948. t['ZapfDingbats'] = true;
  35949. });
  35950. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35951. t[2] = 10;
  35952. t[3] = 32;
  35953. t[4] = 33;
  35954. t[5] = 34;
  35955. t[6] = 35;
  35956. t[7] = 36;
  35957. t[8] = 37;
  35958. t[9] = 38;
  35959. t[10] = 39;
  35960. t[11] = 40;
  35961. t[12] = 41;
  35962. t[13] = 42;
  35963. t[14] = 43;
  35964. t[15] = 44;
  35965. t[16] = 45;
  35966. t[17] = 46;
  35967. t[18] = 47;
  35968. t[19] = 48;
  35969. t[20] = 49;
  35970. t[21] = 50;
  35971. t[22] = 51;
  35972. t[23] = 52;
  35973. t[24] = 53;
  35974. t[25] = 54;
  35975. t[26] = 55;
  35976. t[27] = 56;
  35977. t[28] = 57;
  35978. t[29] = 58;
  35979. t[30] = 894;
  35980. t[31] = 60;
  35981. t[32] = 61;
  35982. t[33] = 62;
  35983. t[34] = 63;
  35984. t[35] = 64;
  35985. t[36] = 65;
  35986. t[37] = 66;
  35987. t[38] = 67;
  35988. t[39] = 68;
  35989. t[40] = 69;
  35990. t[41] = 70;
  35991. t[42] = 71;
  35992. t[43] = 72;
  35993. t[44] = 73;
  35994. t[45] = 74;
  35995. t[46] = 75;
  35996. t[47] = 76;
  35997. t[48] = 77;
  35998. t[49] = 78;
  35999. t[50] = 79;
  36000. t[51] = 80;
  36001. t[52] = 81;
  36002. t[53] = 82;
  36003. t[54] = 83;
  36004. t[55] = 84;
  36005. t[56] = 85;
  36006. t[57] = 86;
  36007. t[58] = 87;
  36008. t[59] = 88;
  36009. t[60] = 89;
  36010. t[61] = 90;
  36011. t[62] = 91;
  36012. t[63] = 92;
  36013. t[64] = 93;
  36014. t[65] = 94;
  36015. t[66] = 95;
  36016. t[67] = 96;
  36017. t[68] = 97;
  36018. t[69] = 98;
  36019. t[70] = 99;
  36020. t[71] = 100;
  36021. t[72] = 101;
  36022. t[73] = 102;
  36023. t[74] = 103;
  36024. t[75] = 104;
  36025. t[76] = 105;
  36026. t[77] = 106;
  36027. t[78] = 107;
  36028. t[79] = 108;
  36029. t[80] = 109;
  36030. t[81] = 110;
  36031. t[82] = 111;
  36032. t[83] = 112;
  36033. t[84] = 113;
  36034. t[85] = 114;
  36035. t[86] = 115;
  36036. t[87] = 116;
  36037. t[88] = 117;
  36038. t[89] = 118;
  36039. t[90] = 119;
  36040. t[91] = 120;
  36041. t[92] = 121;
  36042. t[93] = 122;
  36043. t[94] = 123;
  36044. t[95] = 124;
  36045. t[96] = 125;
  36046. t[97] = 126;
  36047. t[98] = 196;
  36048. t[99] = 197;
  36049. t[100] = 199;
  36050. t[101] = 201;
  36051. t[102] = 209;
  36052. t[103] = 214;
  36053. t[104] = 220;
  36054. t[105] = 225;
  36055. t[106] = 224;
  36056. t[107] = 226;
  36057. t[108] = 228;
  36058. t[109] = 227;
  36059. t[110] = 229;
  36060. t[111] = 231;
  36061. t[112] = 233;
  36062. t[113] = 232;
  36063. t[114] = 234;
  36064. t[115] = 235;
  36065. t[116] = 237;
  36066. t[117] = 236;
  36067. t[118] = 238;
  36068. t[119] = 239;
  36069. t[120] = 241;
  36070. t[121] = 243;
  36071. t[122] = 242;
  36072. t[123] = 244;
  36073. t[124] = 246;
  36074. t[125] = 245;
  36075. t[126] = 250;
  36076. t[127] = 249;
  36077. t[128] = 251;
  36078. t[129] = 252;
  36079. t[130] = 8224;
  36080. t[131] = 176;
  36081. t[132] = 162;
  36082. t[133] = 163;
  36083. t[134] = 167;
  36084. t[135] = 8226;
  36085. t[136] = 182;
  36086. t[137] = 223;
  36087. t[138] = 174;
  36088. t[139] = 169;
  36089. t[140] = 8482;
  36090. t[141] = 180;
  36091. t[142] = 168;
  36092. t[143] = 8800;
  36093. t[144] = 198;
  36094. t[145] = 216;
  36095. t[146] = 8734;
  36096. t[147] = 177;
  36097. t[148] = 8804;
  36098. t[149] = 8805;
  36099. t[150] = 165;
  36100. t[151] = 181;
  36101. t[152] = 8706;
  36102. t[153] = 8721;
  36103. t[154] = 8719;
  36104. t[156] = 8747;
  36105. t[157] = 170;
  36106. t[158] = 186;
  36107. t[159] = 8486;
  36108. t[160] = 230;
  36109. t[161] = 248;
  36110. t[162] = 191;
  36111. t[163] = 161;
  36112. t[164] = 172;
  36113. t[165] = 8730;
  36114. t[166] = 402;
  36115. t[167] = 8776;
  36116. t[168] = 8710;
  36117. t[169] = 171;
  36118. t[170] = 187;
  36119. t[171] = 8230;
  36120. t[210] = 218;
  36121. t[223] = 711;
  36122. t[224] = 321;
  36123. t[225] = 322;
  36124. t[227] = 353;
  36125. t[229] = 382;
  36126. t[234] = 253;
  36127. t[252] = 263;
  36128. t[253] = 268;
  36129. t[254] = 269;
  36130. t[258] = 258;
  36131. t[260] = 260;
  36132. t[261] = 261;
  36133. t[265] = 280;
  36134. t[266] = 281;
  36135. t[268] = 283;
  36136. t[269] = 313;
  36137. t[275] = 323;
  36138. t[276] = 324;
  36139. t[278] = 328;
  36140. t[284] = 345;
  36141. t[285] = 346;
  36142. t[286] = 347;
  36143. t[292] = 367;
  36144. t[295] = 377;
  36145. t[296] = 378;
  36146. t[298] = 380;
  36147. t[305] = 963;
  36148. t[306] = 964;
  36149. t[307] = 966;
  36150. t[308] = 8215;
  36151. t[309] = 8252;
  36152. t[310] = 8319;
  36153. t[311] = 8359;
  36154. t[312] = 8592;
  36155. t[313] = 8593;
  36156. t[337] = 9552;
  36157. t[493] = 1039;
  36158. t[494] = 1040;
  36159. t[705] = 1524;
  36160. t[706] = 8362;
  36161. t[710] = 64288;
  36162. t[711] = 64298;
  36163. t[759] = 1617;
  36164. t[761] = 1776;
  36165. t[763] = 1778;
  36166. t[775] = 1652;
  36167. t[777] = 1764;
  36168. t[778] = 1780;
  36169. t[779] = 1781;
  36170. t[780] = 1782;
  36171. t[782] = 771;
  36172. t[783] = 64726;
  36173. t[786] = 8363;
  36174. t[788] = 8532;
  36175. t[790] = 768;
  36176. t[791] = 769;
  36177. t[792] = 768;
  36178. t[795] = 803;
  36179. t[797] = 64336;
  36180. t[798] = 64337;
  36181. t[799] = 64342;
  36182. t[800] = 64343;
  36183. t[801] = 64344;
  36184. t[802] = 64345;
  36185. t[803] = 64362;
  36186. t[804] = 64363;
  36187. t[805] = 64364;
  36188. t[2424] = 7821;
  36189. t[2425] = 7822;
  36190. t[2426] = 7823;
  36191. t[2427] = 7824;
  36192. t[2428] = 7825;
  36193. t[2429] = 7826;
  36194. t[2430] = 7827;
  36195. t[2433] = 7682;
  36196. t[2678] = 8045;
  36197. t[2679] = 8046;
  36198. t[2830] = 1552;
  36199. t[2838] = 686;
  36200. t[2840] = 751;
  36201. t[2842] = 753;
  36202. t[2843] = 754;
  36203. t[2844] = 755;
  36204. t[2846] = 757;
  36205. t[2856] = 767;
  36206. t[2857] = 848;
  36207. t[2858] = 849;
  36208. t[2862] = 853;
  36209. t[2863] = 854;
  36210. t[2864] = 855;
  36211. t[2865] = 861;
  36212. t[2866] = 862;
  36213. t[2906] = 7460;
  36214. t[2908] = 7462;
  36215. t[2909] = 7463;
  36216. t[2910] = 7464;
  36217. t[2912] = 7466;
  36218. t[2913] = 7467;
  36219. t[2914] = 7468;
  36220. t[2916] = 7470;
  36221. t[2917] = 7471;
  36222. t[2918] = 7472;
  36223. t[2920] = 7474;
  36224. t[2921] = 7475;
  36225. t[2922] = 7476;
  36226. t[2924] = 7478;
  36227. t[2925] = 7479;
  36228. t[2926] = 7480;
  36229. t[2928] = 7482;
  36230. t[2929] = 7483;
  36231. t[2930] = 7484;
  36232. t[2932] = 7486;
  36233. t[2933] = 7487;
  36234. t[2934] = 7488;
  36235. t[2936] = 7490;
  36236. t[2937] = 7491;
  36237. t[2938] = 7492;
  36238. t[2940] = 7494;
  36239. t[2941] = 7495;
  36240. t[2942] = 7496;
  36241. t[2944] = 7498;
  36242. t[2946] = 7500;
  36243. t[2948] = 7502;
  36244. t[2950] = 7504;
  36245. t[2951] = 7505;
  36246. t[2952] = 7506;
  36247. t[2954] = 7508;
  36248. t[2955] = 7509;
  36249. t[2956] = 7510;
  36250. t[2958] = 7512;
  36251. t[2959] = 7513;
  36252. t[2960] = 7514;
  36253. t[2962] = 7516;
  36254. t[2963] = 7517;
  36255. t[2964] = 7518;
  36256. t[2966] = 7520;
  36257. t[2967] = 7521;
  36258. t[2968] = 7522;
  36259. t[2970] = 7524;
  36260. t[2971] = 7525;
  36261. t[2972] = 7526;
  36262. t[2974] = 7528;
  36263. t[2975] = 7529;
  36264. t[2976] = 7530;
  36265. t[2978] = 1537;
  36266. t[2979] = 1538;
  36267. t[2980] = 1539;
  36268. t[2982] = 1549;
  36269. t[2983] = 1551;
  36270. t[2984] = 1552;
  36271. t[2986] = 1554;
  36272. t[2987] = 1555;
  36273. t[2988] = 1556;
  36274. t[2990] = 1623;
  36275. t[2991] = 1624;
  36276. t[2995] = 1775;
  36277. t[2999] = 1791;
  36278. t[3002] = 64290;
  36279. t[3003] = 64291;
  36280. t[3004] = 64292;
  36281. t[3006] = 64294;
  36282. t[3007] = 64295;
  36283. t[3008] = 64296;
  36284. t[3011] = 1900;
  36285. t[3014] = 8223;
  36286. t[3015] = 8244;
  36287. t[3017] = 7532;
  36288. t[3018] = 7533;
  36289. t[3019] = 7534;
  36290. t[3075] = 7590;
  36291. t[3076] = 7591;
  36292. t[3079] = 7594;
  36293. t[3080] = 7595;
  36294. t[3083] = 7598;
  36295. t[3084] = 7599;
  36296. t[3087] = 7602;
  36297. t[3088] = 7603;
  36298. t[3091] = 7606;
  36299. t[3092] = 7607;
  36300. t[3095] = 7610;
  36301. t[3096] = 7611;
  36302. t[3099] = 7614;
  36303. t[3100] = 7615;
  36304. t[3103] = 7618;
  36305. t[3104] = 7619;
  36306. t[3107] = 8337;
  36307. t[3108] = 8338;
  36308. t[3116] = 1884;
  36309. t[3119] = 1885;
  36310. t[3120] = 1885;
  36311. t[3123] = 1886;
  36312. t[3124] = 1886;
  36313. t[3127] = 1887;
  36314. t[3128] = 1887;
  36315. t[3131] = 1888;
  36316. t[3132] = 1888;
  36317. t[3135] = 1889;
  36318. t[3136] = 1889;
  36319. t[3139] = 1890;
  36320. t[3140] = 1890;
  36321. t[3143] = 1891;
  36322. t[3144] = 1891;
  36323. t[3147] = 1892;
  36324. t[3148] = 1892;
  36325. t[3153] = 580;
  36326. t[3154] = 581;
  36327. t[3157] = 584;
  36328. t[3158] = 585;
  36329. t[3161] = 588;
  36330. t[3162] = 589;
  36331. t[3165] = 891;
  36332. t[3166] = 892;
  36333. t[3169] = 1274;
  36334. t[3170] = 1275;
  36335. t[3173] = 1278;
  36336. t[3174] = 1279;
  36337. t[3181] = 7622;
  36338. t[3182] = 7623;
  36339. t[3282] = 11799;
  36340. t[3316] = 578;
  36341. t[3379] = 42785;
  36342. t[3393] = 1159;
  36343. t[3416] = 8377;
  36344. });
  36345. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36346. t[227] = 322;
  36347. t[264] = 261;
  36348. t[291] = 346;
  36349. });
  36350. exports.getStdFontMap = getStdFontMap;
  36351. exports.getNonStdFontMap = getNonStdFontMap;
  36352. exports.getSerifFonts = getSerifFonts;
  36353. exports.getSymbolsFonts = getSymbolsFonts;
  36354. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36355. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36356. /***/ }),
  36357. /* 21 */
  36358. /***/ (function(module, exports, __w_pdfjs_require__) {
  36359. "use strict";
  36360. var sharedUtil = __w_pdfjs_require__(0);
  36361. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36362. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36363. t[63721] = 0x00A9;
  36364. t[63193] = 0x00A9;
  36365. t[63720] = 0x00AE;
  36366. t[63194] = 0x00AE;
  36367. t[63722] = 0x2122;
  36368. t[63195] = 0x2122;
  36369. t[63729] = 0x23A7;
  36370. t[63730] = 0x23A8;
  36371. t[63731] = 0x23A9;
  36372. t[63740] = 0x23AB;
  36373. t[63741] = 0x23AC;
  36374. t[63742] = 0x23AD;
  36375. t[63726] = 0x23A1;
  36376. t[63727] = 0x23A2;
  36377. t[63728] = 0x23A3;
  36378. t[63737] = 0x23A4;
  36379. t[63738] = 0x23A5;
  36380. t[63739] = 0x23A6;
  36381. t[63723] = 0x239B;
  36382. t[63724] = 0x239C;
  36383. t[63725] = 0x239D;
  36384. t[63734] = 0x239E;
  36385. t[63735] = 0x239F;
  36386. t[63736] = 0x23A0;
  36387. });
  36388. function mapSpecialUnicodeValues(code) {
  36389. if (code >= 0xFFF0 && code <= 0xFFFF) {
  36390. return 0;
  36391. } else if (code >= 0xF600 && code <= 0xF8FF) {
  36392. return getSpecialPUASymbols()[code] || code;
  36393. }
  36394. return code;
  36395. }
  36396. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  36397. var unicode = glyphsUnicodeMap[name];
  36398. if (unicode !== undefined) {
  36399. return unicode;
  36400. }
  36401. if (!name) {
  36402. return -1;
  36403. }
  36404. if (name[0] === 'u') {
  36405. var nameLen = name.length, hexStr;
  36406. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  36407. hexStr = name.substr(3);
  36408. } else if (nameLen >= 5 && nameLen <= 7) {
  36409. hexStr = name.substr(1);
  36410. } else {
  36411. return -1;
  36412. }
  36413. if (hexStr === hexStr.toUpperCase()) {
  36414. unicode = parseInt(hexStr, 16);
  36415. if (unicode >= 0) {
  36416. return unicode;
  36417. }
  36418. }
  36419. }
  36420. return -1;
  36421. }
  36422. var UnicodeRanges = [
  36423. {
  36424. 'begin': 0x0000,
  36425. 'end': 0x007F
  36426. },
  36427. {
  36428. 'begin': 0x0080,
  36429. 'end': 0x00FF
  36430. },
  36431. {
  36432. 'begin': 0x0100,
  36433. 'end': 0x017F
  36434. },
  36435. {
  36436. 'begin': 0x0180,
  36437. 'end': 0x024F
  36438. },
  36439. {
  36440. 'begin': 0x0250,
  36441. 'end': 0x02AF
  36442. },
  36443. {
  36444. 'begin': 0x02B0,
  36445. 'end': 0x02FF
  36446. },
  36447. {
  36448. 'begin': 0x0300,
  36449. 'end': 0x036F
  36450. },
  36451. {
  36452. 'begin': 0x0370,
  36453. 'end': 0x03FF
  36454. },
  36455. {
  36456. 'begin': 0x2C80,
  36457. 'end': 0x2CFF
  36458. },
  36459. {
  36460. 'begin': 0x0400,
  36461. 'end': 0x04FF
  36462. },
  36463. {
  36464. 'begin': 0x0530,
  36465. 'end': 0x058F
  36466. },
  36467. {
  36468. 'begin': 0x0590,
  36469. 'end': 0x05FF
  36470. },
  36471. {
  36472. 'begin': 0xA500,
  36473. 'end': 0xA63F
  36474. },
  36475. {
  36476. 'begin': 0x0600,
  36477. 'end': 0x06FF
  36478. },
  36479. {
  36480. 'begin': 0x07C0,
  36481. 'end': 0x07FF
  36482. },
  36483. {
  36484. 'begin': 0x0900,
  36485. 'end': 0x097F
  36486. },
  36487. {
  36488. 'begin': 0x0980,
  36489. 'end': 0x09FF
  36490. },
  36491. {
  36492. 'begin': 0x0A00,
  36493. 'end': 0x0A7F
  36494. },
  36495. {
  36496. 'begin': 0x0A80,
  36497. 'end': 0x0AFF
  36498. },
  36499. {
  36500. 'begin': 0x0B00,
  36501. 'end': 0x0B7F
  36502. },
  36503. {
  36504. 'begin': 0x0B80,
  36505. 'end': 0x0BFF
  36506. },
  36507. {
  36508. 'begin': 0x0C00,
  36509. 'end': 0x0C7F
  36510. },
  36511. {
  36512. 'begin': 0x0C80,
  36513. 'end': 0x0CFF
  36514. },
  36515. {
  36516. 'begin': 0x0D00,
  36517. 'end': 0x0D7F
  36518. },
  36519. {
  36520. 'begin': 0x0E00,
  36521. 'end': 0x0E7F
  36522. },
  36523. {
  36524. 'begin': 0x0E80,
  36525. 'end': 0x0EFF
  36526. },
  36527. {
  36528. 'begin': 0x10A0,
  36529. 'end': 0x10FF
  36530. },
  36531. {
  36532. 'begin': 0x1B00,
  36533. 'end': 0x1B7F
  36534. },
  36535. {
  36536. 'begin': 0x1100,
  36537. 'end': 0x11FF
  36538. },
  36539. {
  36540. 'begin': 0x1E00,
  36541. 'end': 0x1EFF
  36542. },
  36543. {
  36544. 'begin': 0x1F00,
  36545. 'end': 0x1FFF
  36546. },
  36547. {
  36548. 'begin': 0x2000,
  36549. 'end': 0x206F
  36550. },
  36551. {
  36552. 'begin': 0x2070,
  36553. 'end': 0x209F
  36554. },
  36555. {
  36556. 'begin': 0x20A0,
  36557. 'end': 0x20CF
  36558. },
  36559. {
  36560. 'begin': 0x20D0,
  36561. 'end': 0x20FF
  36562. },
  36563. {
  36564. 'begin': 0x2100,
  36565. 'end': 0x214F
  36566. },
  36567. {
  36568. 'begin': 0x2150,
  36569. 'end': 0x218F
  36570. },
  36571. {
  36572. 'begin': 0x2190,
  36573. 'end': 0x21FF
  36574. },
  36575. {
  36576. 'begin': 0x2200,
  36577. 'end': 0x22FF
  36578. },
  36579. {
  36580. 'begin': 0x2300,
  36581. 'end': 0x23FF
  36582. },
  36583. {
  36584. 'begin': 0x2400,
  36585. 'end': 0x243F
  36586. },
  36587. {
  36588. 'begin': 0x2440,
  36589. 'end': 0x245F
  36590. },
  36591. {
  36592. 'begin': 0x2460,
  36593. 'end': 0x24FF
  36594. },
  36595. {
  36596. 'begin': 0x2500,
  36597. 'end': 0x257F
  36598. },
  36599. {
  36600. 'begin': 0x2580,
  36601. 'end': 0x259F
  36602. },
  36603. {
  36604. 'begin': 0x25A0,
  36605. 'end': 0x25FF
  36606. },
  36607. {
  36608. 'begin': 0x2600,
  36609. 'end': 0x26FF
  36610. },
  36611. {
  36612. 'begin': 0x2700,
  36613. 'end': 0x27BF
  36614. },
  36615. {
  36616. 'begin': 0x3000,
  36617. 'end': 0x303F
  36618. },
  36619. {
  36620. 'begin': 0x3040,
  36621. 'end': 0x309F
  36622. },
  36623. {
  36624. 'begin': 0x30A0,
  36625. 'end': 0x30FF
  36626. },
  36627. {
  36628. 'begin': 0x3100,
  36629. 'end': 0x312F
  36630. },
  36631. {
  36632. 'begin': 0x3130,
  36633. 'end': 0x318F
  36634. },
  36635. {
  36636. 'begin': 0xA840,
  36637. 'end': 0xA87F
  36638. },
  36639. {
  36640. 'begin': 0x3200,
  36641. 'end': 0x32FF
  36642. },
  36643. {
  36644. 'begin': 0x3300,
  36645. 'end': 0x33FF
  36646. },
  36647. {
  36648. 'begin': 0xAC00,
  36649. 'end': 0xD7AF
  36650. },
  36651. {
  36652. 'begin': 0xD800,
  36653. 'end': 0xDFFF
  36654. },
  36655. {
  36656. 'begin': 0x10900,
  36657. 'end': 0x1091F
  36658. },
  36659. {
  36660. 'begin': 0x4E00,
  36661. 'end': 0x9FFF
  36662. },
  36663. {
  36664. 'begin': 0xE000,
  36665. 'end': 0xF8FF
  36666. },
  36667. {
  36668. 'begin': 0x31C0,
  36669. 'end': 0x31EF
  36670. },
  36671. {
  36672. 'begin': 0xFB00,
  36673. 'end': 0xFB4F
  36674. },
  36675. {
  36676. 'begin': 0xFB50,
  36677. 'end': 0xFDFF
  36678. },
  36679. {
  36680. 'begin': 0xFE20,
  36681. 'end': 0xFE2F
  36682. },
  36683. {
  36684. 'begin': 0xFE10,
  36685. 'end': 0xFE1F
  36686. },
  36687. {
  36688. 'begin': 0xFE50,
  36689. 'end': 0xFE6F
  36690. },
  36691. {
  36692. 'begin': 0xFE70,
  36693. 'end': 0xFEFF
  36694. },
  36695. {
  36696. 'begin': 0xFF00,
  36697. 'end': 0xFFEF
  36698. },
  36699. {
  36700. 'begin': 0xFFF0,
  36701. 'end': 0xFFFF
  36702. },
  36703. {
  36704. 'begin': 0x0F00,
  36705. 'end': 0x0FFF
  36706. },
  36707. {
  36708. 'begin': 0x0700,
  36709. 'end': 0x074F
  36710. },
  36711. {
  36712. 'begin': 0x0780,
  36713. 'end': 0x07BF
  36714. },
  36715. {
  36716. 'begin': 0x0D80,
  36717. 'end': 0x0DFF
  36718. },
  36719. {
  36720. 'begin': 0x1000,
  36721. 'end': 0x109F
  36722. },
  36723. {
  36724. 'begin': 0x1200,
  36725. 'end': 0x137F
  36726. },
  36727. {
  36728. 'begin': 0x13A0,
  36729. 'end': 0x13FF
  36730. },
  36731. {
  36732. 'begin': 0x1400,
  36733. 'end': 0x167F
  36734. },
  36735. {
  36736. 'begin': 0x1680,
  36737. 'end': 0x169F
  36738. },
  36739. {
  36740. 'begin': 0x16A0,
  36741. 'end': 0x16FF
  36742. },
  36743. {
  36744. 'begin': 0x1780,
  36745. 'end': 0x17FF
  36746. },
  36747. {
  36748. 'begin': 0x1800,
  36749. 'end': 0x18AF
  36750. },
  36751. {
  36752. 'begin': 0x2800,
  36753. 'end': 0x28FF
  36754. },
  36755. {
  36756. 'begin': 0xA000,
  36757. 'end': 0xA48F
  36758. },
  36759. {
  36760. 'begin': 0x1700,
  36761. 'end': 0x171F
  36762. },
  36763. {
  36764. 'begin': 0x10300,
  36765. 'end': 0x1032F
  36766. },
  36767. {
  36768. 'begin': 0x10330,
  36769. 'end': 0x1034F
  36770. },
  36771. {
  36772. 'begin': 0x10400,
  36773. 'end': 0x1044F
  36774. },
  36775. {
  36776. 'begin': 0x1D000,
  36777. 'end': 0x1D0FF
  36778. },
  36779. {
  36780. 'begin': 0x1D400,
  36781. 'end': 0x1D7FF
  36782. },
  36783. {
  36784. 'begin': 0xFF000,
  36785. 'end': 0xFFFFD
  36786. },
  36787. {
  36788. 'begin': 0xFE00,
  36789. 'end': 0xFE0F
  36790. },
  36791. {
  36792. 'begin': 0xE0000,
  36793. 'end': 0xE007F
  36794. },
  36795. {
  36796. 'begin': 0x1900,
  36797. 'end': 0x194F
  36798. },
  36799. {
  36800. 'begin': 0x1950,
  36801. 'end': 0x197F
  36802. },
  36803. {
  36804. 'begin': 0x1980,
  36805. 'end': 0x19DF
  36806. },
  36807. {
  36808. 'begin': 0x1A00,
  36809. 'end': 0x1A1F
  36810. },
  36811. {
  36812. 'begin': 0x2C00,
  36813. 'end': 0x2C5F
  36814. },
  36815. {
  36816. 'begin': 0x2D30,
  36817. 'end': 0x2D7F
  36818. },
  36819. {
  36820. 'begin': 0x4DC0,
  36821. 'end': 0x4DFF
  36822. },
  36823. {
  36824. 'begin': 0xA800,
  36825. 'end': 0xA82F
  36826. },
  36827. {
  36828. 'begin': 0x10000,
  36829. 'end': 0x1007F
  36830. },
  36831. {
  36832. 'begin': 0x10140,
  36833. 'end': 0x1018F
  36834. },
  36835. {
  36836. 'begin': 0x10380,
  36837. 'end': 0x1039F
  36838. },
  36839. {
  36840. 'begin': 0x103A0,
  36841. 'end': 0x103DF
  36842. },
  36843. {
  36844. 'begin': 0x10450,
  36845. 'end': 0x1047F
  36846. },
  36847. {
  36848. 'begin': 0x10480,
  36849. 'end': 0x104AF
  36850. },
  36851. {
  36852. 'begin': 0x10800,
  36853. 'end': 0x1083F
  36854. },
  36855. {
  36856. 'begin': 0x10A00,
  36857. 'end': 0x10A5F
  36858. },
  36859. {
  36860. 'begin': 0x1D300,
  36861. 'end': 0x1D35F
  36862. },
  36863. {
  36864. 'begin': 0x12000,
  36865. 'end': 0x123FF
  36866. },
  36867. {
  36868. 'begin': 0x1D360,
  36869. 'end': 0x1D37F
  36870. },
  36871. {
  36872. 'begin': 0x1B80,
  36873. 'end': 0x1BBF
  36874. },
  36875. {
  36876. 'begin': 0x1C00,
  36877. 'end': 0x1C4F
  36878. },
  36879. {
  36880. 'begin': 0x1C50,
  36881. 'end': 0x1C7F
  36882. },
  36883. {
  36884. 'begin': 0xA880,
  36885. 'end': 0xA8DF
  36886. },
  36887. {
  36888. 'begin': 0xA900,
  36889. 'end': 0xA92F
  36890. },
  36891. {
  36892. 'begin': 0xA930,
  36893. 'end': 0xA95F
  36894. },
  36895. {
  36896. 'begin': 0xAA00,
  36897. 'end': 0xAA5F
  36898. },
  36899. {
  36900. 'begin': 0x10190,
  36901. 'end': 0x101CF
  36902. },
  36903. {
  36904. 'begin': 0x101D0,
  36905. 'end': 0x101FF
  36906. },
  36907. {
  36908. 'begin': 0x102A0,
  36909. 'end': 0x102DF
  36910. },
  36911. {
  36912. 'begin': 0x1F030,
  36913. 'end': 0x1F09F
  36914. }
  36915. ];
  36916. function getUnicodeRangeFor(value) {
  36917. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36918. var range = UnicodeRanges[i];
  36919. if (value >= range.begin && value < range.end) {
  36920. return i;
  36921. }
  36922. }
  36923. return -1;
  36924. }
  36925. function isRTLRangeFor(value) {
  36926. var range = UnicodeRanges[13];
  36927. if (value >= range.begin && value < range.end) {
  36928. return true;
  36929. }
  36930. range = UnicodeRanges[11];
  36931. if (value >= range.begin && value < range.end) {
  36932. return true;
  36933. }
  36934. return false;
  36935. }
  36936. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36937. t['\u00A8'] = '\u0020\u0308';
  36938. t['\u00AF'] = '\u0020\u0304';
  36939. t['\u00B4'] = '\u0020\u0301';
  36940. t['\u00B5'] = '\u03BC';
  36941. t['\u00B8'] = '\u0020\u0327';
  36942. t['\u0132'] = '\u0049\u004A';
  36943. t['\u0133'] = '\u0069\u006A';
  36944. t['\u013F'] = '\u004C\u00B7';
  36945. t['\u0140'] = '\u006C\u00B7';
  36946. t['\u0149'] = '\u02BC\u006E';
  36947. t['\u017F'] = '\u0073';
  36948. t['\u01C4'] = '\u0044\u017D';
  36949. t['\u01C5'] = '\u0044\u017E';
  36950. t['\u01C6'] = '\u0064\u017E';
  36951. t['\u01C7'] = '\u004C\u004A';
  36952. t['\u01C8'] = '\u004C\u006A';
  36953. t['\u01C9'] = '\u006C\u006A';
  36954. t['\u01CA'] = '\u004E\u004A';
  36955. t['\u01CB'] = '\u004E\u006A';
  36956. t['\u01CC'] = '\u006E\u006A';
  36957. t['\u01F1'] = '\u0044\u005A';
  36958. t['\u01F2'] = '\u0044\u007A';
  36959. t['\u01F3'] = '\u0064\u007A';
  36960. t['\u02D8'] = '\u0020\u0306';
  36961. t['\u02D9'] = '\u0020\u0307';
  36962. t['\u02DA'] = '\u0020\u030A';
  36963. t['\u02DB'] = '\u0020\u0328';
  36964. t['\u02DC'] = '\u0020\u0303';
  36965. t['\u02DD'] = '\u0020\u030B';
  36966. t['\u037A'] = '\u0020\u0345';
  36967. t['\u0384'] = '\u0020\u0301';
  36968. t['\u03D0'] = '\u03B2';
  36969. t['\u03D1'] = '\u03B8';
  36970. t['\u03D2'] = '\u03A5';
  36971. t['\u03D5'] = '\u03C6';
  36972. t['\u03D6'] = '\u03C0';
  36973. t['\u03F0'] = '\u03BA';
  36974. t['\u03F1'] = '\u03C1';
  36975. t['\u03F2'] = '\u03C2';
  36976. t['\u03F4'] = '\u0398';
  36977. t['\u03F5'] = '\u03B5';
  36978. t['\u03F9'] = '\u03A3';
  36979. t['\u0587'] = '\u0565\u0582';
  36980. t['\u0675'] = '\u0627\u0674';
  36981. t['\u0676'] = '\u0648\u0674';
  36982. t['\u0677'] = '\u06C7\u0674';
  36983. t['\u0678'] = '\u064A\u0674';
  36984. t['\u0E33'] = '\u0E4D\u0E32';
  36985. t['\u0EB3'] = '\u0ECD\u0EB2';
  36986. t['\u0EDC'] = '\u0EAB\u0E99';
  36987. t['\u0EDD'] = '\u0EAB\u0EA1';
  36988. t['\u0F77'] = '\u0FB2\u0F81';
  36989. t['\u0F79'] = '\u0FB3\u0F81';
  36990. t['\u1E9A'] = '\u0061\u02BE';
  36991. t['\u1FBD'] = '\u0020\u0313';
  36992. t['\u1FBF'] = '\u0020\u0313';
  36993. t['\u1FC0'] = '\u0020\u0342';
  36994. t['\u1FFE'] = '\u0020\u0314';
  36995. t['\u2002'] = '\u0020';
  36996. t['\u2003'] = '\u0020';
  36997. t['\u2004'] = '\u0020';
  36998. t['\u2005'] = '\u0020';
  36999. t['\u2006'] = '\u0020';
  37000. t['\u2008'] = '\u0020';
  37001. t['\u2009'] = '\u0020';
  37002. t['\u200A'] = '\u0020';
  37003. t['\u2017'] = '\u0020\u0333';
  37004. t['\u2024'] = '\u002E';
  37005. t['\u2025'] = '\u002E\u002E';
  37006. t['\u2026'] = '\u002E\u002E\u002E';
  37007. t['\u2033'] = '\u2032\u2032';
  37008. t['\u2034'] = '\u2032\u2032\u2032';
  37009. t['\u2036'] = '\u2035\u2035';
  37010. t['\u2037'] = '\u2035\u2035\u2035';
  37011. t['\u203C'] = '\u0021\u0021';
  37012. t['\u203E'] = '\u0020\u0305';
  37013. t['\u2047'] = '\u003F\u003F';
  37014. t['\u2048'] = '\u003F\u0021';
  37015. t['\u2049'] = '\u0021\u003F';
  37016. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  37017. t['\u205F'] = '\u0020';
  37018. t['\u20A8'] = '\u0052\u0073';
  37019. t['\u2100'] = '\u0061\u002F\u0063';
  37020. t['\u2101'] = '\u0061\u002F\u0073';
  37021. t['\u2103'] = '\u00B0\u0043';
  37022. t['\u2105'] = '\u0063\u002F\u006F';
  37023. t['\u2106'] = '\u0063\u002F\u0075';
  37024. t['\u2107'] = '\u0190';
  37025. t['\u2109'] = '\u00B0\u0046';
  37026. t['\u2116'] = '\u004E\u006F';
  37027. t['\u2121'] = '\u0054\u0045\u004C';
  37028. t['\u2135'] = '\u05D0';
  37029. t['\u2136'] = '\u05D1';
  37030. t['\u2137'] = '\u05D2';
  37031. t['\u2138'] = '\u05D3';
  37032. t['\u213B'] = '\u0046\u0041\u0058';
  37033. t['\u2160'] = '\u0049';
  37034. t['\u2161'] = '\u0049\u0049';
  37035. t['\u2162'] = '\u0049\u0049\u0049';
  37036. t['\u2163'] = '\u0049\u0056';
  37037. t['\u2164'] = '\u0056';
  37038. t['\u2165'] = '\u0056\u0049';
  37039. t['\u2166'] = '\u0056\u0049\u0049';
  37040. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  37041. t['\u2168'] = '\u0049\u0058';
  37042. t['\u2169'] = '\u0058';
  37043. t['\u216A'] = '\u0058\u0049';
  37044. t['\u216B'] = '\u0058\u0049\u0049';
  37045. t['\u216C'] = '\u004C';
  37046. t['\u216D'] = '\u0043';
  37047. t['\u216E'] = '\u0044';
  37048. t['\u216F'] = '\u004D';
  37049. t['\u2170'] = '\u0069';
  37050. t['\u2171'] = '\u0069\u0069';
  37051. t['\u2172'] = '\u0069\u0069\u0069';
  37052. t['\u2173'] = '\u0069\u0076';
  37053. t['\u2174'] = '\u0076';
  37054. t['\u2175'] = '\u0076\u0069';
  37055. t['\u2176'] = '\u0076\u0069\u0069';
  37056. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  37057. t['\u2178'] = '\u0069\u0078';
  37058. t['\u2179'] = '\u0078';
  37059. t['\u217A'] = '\u0078\u0069';
  37060. t['\u217B'] = '\u0078\u0069\u0069';
  37061. t['\u217C'] = '\u006C';
  37062. t['\u217D'] = '\u0063';
  37063. t['\u217E'] = '\u0064';
  37064. t['\u217F'] = '\u006D';
  37065. t['\u222C'] = '\u222B\u222B';
  37066. t['\u222D'] = '\u222B\u222B\u222B';
  37067. t['\u222F'] = '\u222E\u222E';
  37068. t['\u2230'] = '\u222E\u222E\u222E';
  37069. t['\u2474'] = '\u0028\u0031\u0029';
  37070. t['\u2475'] = '\u0028\u0032\u0029';
  37071. t['\u2476'] = '\u0028\u0033\u0029';
  37072. t['\u2477'] = '\u0028\u0034\u0029';
  37073. t['\u2478'] = '\u0028\u0035\u0029';
  37074. t['\u2479'] = '\u0028\u0036\u0029';
  37075. t['\u247A'] = '\u0028\u0037\u0029';
  37076. t['\u247B'] = '\u0028\u0038\u0029';
  37077. t['\u247C'] = '\u0028\u0039\u0029';
  37078. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  37079. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  37080. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  37081. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  37082. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  37083. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  37084. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  37085. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  37086. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  37087. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  37088. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37089. t['\u2488'] = '\u0031\u002E';
  37090. t['\u2489'] = '\u0032\u002E';
  37091. t['\u248A'] = '\u0033\u002E';
  37092. t['\u248B'] = '\u0034\u002E';
  37093. t['\u248C'] = '\u0035\u002E';
  37094. t['\u248D'] = '\u0036\u002E';
  37095. t['\u248E'] = '\u0037\u002E';
  37096. t['\u248F'] = '\u0038\u002E';
  37097. t['\u2490'] = '\u0039\u002E';
  37098. t['\u2491'] = '\u0031\u0030\u002E';
  37099. t['\u2492'] = '\u0031\u0031\u002E';
  37100. t['\u2493'] = '\u0031\u0032\u002E';
  37101. t['\u2494'] = '\u0031\u0033\u002E';
  37102. t['\u2495'] = '\u0031\u0034\u002E';
  37103. t['\u2496'] = '\u0031\u0035\u002E';
  37104. t['\u2497'] = '\u0031\u0036\u002E';
  37105. t['\u2498'] = '\u0031\u0037\u002E';
  37106. t['\u2499'] = '\u0031\u0038\u002E';
  37107. t['\u249A'] = '\u0031\u0039\u002E';
  37108. t['\u249B'] = '\u0032\u0030\u002E';
  37109. t['\u249C'] = '\u0028\u0061\u0029';
  37110. t['\u249D'] = '\u0028\u0062\u0029';
  37111. t['\u249E'] = '\u0028\u0063\u0029';
  37112. t['\u249F'] = '\u0028\u0064\u0029';
  37113. t['\u24A0'] = '\u0028\u0065\u0029';
  37114. t['\u24A1'] = '\u0028\u0066\u0029';
  37115. t['\u24A2'] = '\u0028\u0067\u0029';
  37116. t['\u24A3'] = '\u0028\u0068\u0029';
  37117. t['\u24A4'] = '\u0028\u0069\u0029';
  37118. t['\u24A5'] = '\u0028\u006A\u0029';
  37119. t['\u24A6'] = '\u0028\u006B\u0029';
  37120. t['\u24A7'] = '\u0028\u006C\u0029';
  37121. t['\u24A8'] = '\u0028\u006D\u0029';
  37122. t['\u24A9'] = '\u0028\u006E\u0029';
  37123. t['\u24AA'] = '\u0028\u006F\u0029';
  37124. t['\u24AB'] = '\u0028\u0070\u0029';
  37125. t['\u24AC'] = '\u0028\u0071\u0029';
  37126. t['\u24AD'] = '\u0028\u0072\u0029';
  37127. t['\u24AE'] = '\u0028\u0073\u0029';
  37128. t['\u24AF'] = '\u0028\u0074\u0029';
  37129. t['\u24B0'] = '\u0028\u0075\u0029';
  37130. t['\u24B1'] = '\u0028\u0076\u0029';
  37131. t['\u24B2'] = '\u0028\u0077\u0029';
  37132. t['\u24B3'] = '\u0028\u0078\u0029';
  37133. t['\u24B4'] = '\u0028\u0079\u0029';
  37134. t['\u24B5'] = '\u0028\u007A\u0029';
  37135. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37136. t['\u2A74'] = '\u003A\u003A\u003D';
  37137. t['\u2A75'] = '\u003D\u003D';
  37138. t['\u2A76'] = '\u003D\u003D\u003D';
  37139. t['\u2E9F'] = '\u6BCD';
  37140. t['\u2EF3'] = '\u9F9F';
  37141. t['\u2F00'] = '\u4E00';
  37142. t['\u2F01'] = '\u4E28';
  37143. t['\u2F02'] = '\u4E36';
  37144. t['\u2F03'] = '\u4E3F';
  37145. t['\u2F04'] = '\u4E59';
  37146. t['\u2F05'] = '\u4E85';
  37147. t['\u2F06'] = '\u4E8C';
  37148. t['\u2F07'] = '\u4EA0';
  37149. t['\u2F08'] = '\u4EBA';
  37150. t['\u2F09'] = '\u513F';
  37151. t['\u2F0A'] = '\u5165';
  37152. t['\u2F0B'] = '\u516B';
  37153. t['\u2F0C'] = '\u5182';
  37154. t['\u2F0D'] = '\u5196';
  37155. t['\u2F0E'] = '\u51AB';
  37156. t['\u2F0F'] = '\u51E0';
  37157. t['\u2F10'] = '\u51F5';
  37158. t['\u2F11'] = '\u5200';
  37159. t['\u2F12'] = '\u529B';
  37160. t['\u2F13'] = '\u52F9';
  37161. t['\u2F14'] = '\u5315';
  37162. t['\u2F15'] = '\u531A';
  37163. t['\u2F16'] = '\u5338';
  37164. t['\u2F17'] = '\u5341';
  37165. t['\u2F18'] = '\u535C';
  37166. t['\u2F19'] = '\u5369';
  37167. t['\u2F1A'] = '\u5382';
  37168. t['\u2F1B'] = '\u53B6';
  37169. t['\u2F1C'] = '\u53C8';
  37170. t['\u2F1D'] = '\u53E3';
  37171. t['\u2F1E'] = '\u56D7';
  37172. t['\u2F1F'] = '\u571F';
  37173. t['\u2F20'] = '\u58EB';
  37174. t['\u2F21'] = '\u5902';
  37175. t['\u2F22'] = '\u590A';
  37176. t['\u2F23'] = '\u5915';
  37177. t['\u2F24'] = '\u5927';
  37178. t['\u2F25'] = '\u5973';
  37179. t['\u2F26'] = '\u5B50';
  37180. t['\u2F27'] = '\u5B80';
  37181. t['\u2F28'] = '\u5BF8';
  37182. t['\u2F29'] = '\u5C0F';
  37183. t['\u2F2A'] = '\u5C22';
  37184. t['\u2F2B'] = '\u5C38';
  37185. t['\u2F2C'] = '\u5C6E';
  37186. t['\u2F2D'] = '\u5C71';
  37187. t['\u2F2E'] = '\u5DDB';
  37188. t['\u2F2F'] = '\u5DE5';
  37189. t['\u2F30'] = '\u5DF1';
  37190. t['\u2F31'] = '\u5DFE';
  37191. t['\u2F32'] = '\u5E72';
  37192. t['\u2F33'] = '\u5E7A';
  37193. t['\u2F34'] = '\u5E7F';
  37194. t['\u2F35'] = '\u5EF4';
  37195. t['\u2F36'] = '\u5EFE';
  37196. t['\u2F37'] = '\u5F0B';
  37197. t['\u2F38'] = '\u5F13';
  37198. t['\u2F39'] = '\u5F50';
  37199. t['\u2F3A'] = '\u5F61';
  37200. t['\u2F3B'] = '\u5F73';
  37201. t['\u2F3C'] = '\u5FC3';
  37202. t['\u2F3D'] = '\u6208';
  37203. t['\u2F3E'] = '\u6236';
  37204. t['\u2F3F'] = '\u624B';
  37205. t['\u2F40'] = '\u652F';
  37206. t['\u2F41'] = '\u6534';
  37207. t['\u2F42'] = '\u6587';
  37208. t['\u2F43'] = '\u6597';
  37209. t['\u2F44'] = '\u65A4';
  37210. t['\u2F45'] = '\u65B9';
  37211. t['\u2F46'] = '\u65E0';
  37212. t['\u2F47'] = '\u65E5';
  37213. t['\u2F48'] = '\u66F0';
  37214. t['\u2F49'] = '\u6708';
  37215. t['\u2F4A'] = '\u6728';
  37216. t['\u2F4B'] = '\u6B20';
  37217. t['\u2F4C'] = '\u6B62';
  37218. t['\u2F4D'] = '\u6B79';
  37219. t['\u2F4E'] = '\u6BB3';
  37220. t['\u2F4F'] = '\u6BCB';
  37221. t['\u2F50'] = '\u6BD4';
  37222. t['\u2F51'] = '\u6BDB';
  37223. t['\u2F52'] = '\u6C0F';
  37224. t['\u2F53'] = '\u6C14';
  37225. t['\u2F54'] = '\u6C34';
  37226. t['\u2F55'] = '\u706B';
  37227. t['\u2F56'] = '\u722A';
  37228. t['\u2F57'] = '\u7236';
  37229. t['\u2F58'] = '\u723B';
  37230. t['\u2F59'] = '\u723F';
  37231. t['\u2F5A'] = '\u7247';
  37232. t['\u2F5B'] = '\u7259';
  37233. t['\u2F5C'] = '\u725B';
  37234. t['\u2F5D'] = '\u72AC';
  37235. t['\u2F5E'] = '\u7384';
  37236. t['\u2F5F'] = '\u7389';
  37237. t['\u2F60'] = '\u74DC';
  37238. t['\u2F61'] = '\u74E6';
  37239. t['\u2F62'] = '\u7518';
  37240. t['\u2F63'] = '\u751F';
  37241. t['\u2F64'] = '\u7528';
  37242. t['\u2F65'] = '\u7530';
  37243. t['\u2F66'] = '\u758B';
  37244. t['\u2F67'] = '\u7592';
  37245. t['\u2F68'] = '\u7676';
  37246. t['\u2F69'] = '\u767D';
  37247. t['\u2F6A'] = '\u76AE';
  37248. t['\u2F6B'] = '\u76BF';
  37249. t['\u2F6C'] = '\u76EE';
  37250. t['\u2F6D'] = '\u77DB';
  37251. t['\u2F6E'] = '\u77E2';
  37252. t['\u2F6F'] = '\u77F3';
  37253. t['\u2F70'] = '\u793A';
  37254. t['\u2F71'] = '\u79B8';
  37255. t['\u2F72'] = '\u79BE';
  37256. t['\u2F73'] = '\u7A74';
  37257. t['\u2F74'] = '\u7ACB';
  37258. t['\u2F75'] = '\u7AF9';
  37259. t['\u2F76'] = '\u7C73';
  37260. t['\u2F77'] = '\u7CF8';
  37261. t['\u2F78'] = '\u7F36';
  37262. t['\u2F79'] = '\u7F51';
  37263. t['\u2F7A'] = '\u7F8A';
  37264. t['\u2F7B'] = '\u7FBD';
  37265. t['\u2F7C'] = '\u8001';
  37266. t['\u2F7D'] = '\u800C';
  37267. t['\u2F7E'] = '\u8012';
  37268. t['\u2F7F'] = '\u8033';
  37269. t['\u2F80'] = '\u807F';
  37270. t['\u2F81'] = '\u8089';
  37271. t['\u2F82'] = '\u81E3';
  37272. t['\u2F83'] = '\u81EA';
  37273. t['\u2F84'] = '\u81F3';
  37274. t['\u2F85'] = '\u81FC';
  37275. t['\u2F86'] = '\u820C';
  37276. t['\u2F87'] = '\u821B';
  37277. t['\u2F88'] = '\u821F';
  37278. t['\u2F89'] = '\u826E';
  37279. t['\u2F8A'] = '\u8272';
  37280. t['\u2F8B'] = '\u8278';
  37281. t['\u2F8C'] = '\u864D';
  37282. t['\u2F8D'] = '\u866B';
  37283. t['\u2F8E'] = '\u8840';
  37284. t['\u2F8F'] = '\u884C';
  37285. t['\u2F90'] = '\u8863';
  37286. t['\u2F91'] = '\u897E';
  37287. t['\u2F92'] = '\u898B';
  37288. t['\u2F93'] = '\u89D2';
  37289. t['\u2F94'] = '\u8A00';
  37290. t['\u2F95'] = '\u8C37';
  37291. t['\u2F96'] = '\u8C46';
  37292. t['\u2F97'] = '\u8C55';
  37293. t['\u2F98'] = '\u8C78';
  37294. t['\u2F99'] = '\u8C9D';
  37295. t['\u2F9A'] = '\u8D64';
  37296. t['\u2F9B'] = '\u8D70';
  37297. t['\u2F9C'] = '\u8DB3';
  37298. t['\u2F9D'] = '\u8EAB';
  37299. t['\u2F9E'] = '\u8ECA';
  37300. t['\u2F9F'] = '\u8F9B';
  37301. t['\u2FA0'] = '\u8FB0';
  37302. t['\u2FA1'] = '\u8FB5';
  37303. t['\u2FA2'] = '\u9091';
  37304. t['\u2FA3'] = '\u9149';
  37305. t['\u2FA4'] = '\u91C6';
  37306. t['\u2FA5'] = '\u91CC';
  37307. t['\u2FA6'] = '\u91D1';
  37308. t['\u2FA7'] = '\u9577';
  37309. t['\u2FA8'] = '\u9580';
  37310. t['\u2FA9'] = '\u961C';
  37311. t['\u2FAA'] = '\u96B6';
  37312. t['\u2FAB'] = '\u96B9';
  37313. t['\u2FAC'] = '\u96E8';
  37314. t['\u2FAD'] = '\u9751';
  37315. t['\u2FAE'] = '\u975E';
  37316. t['\u2FAF'] = '\u9762';
  37317. t['\u2FB0'] = '\u9769';
  37318. t['\u2FB1'] = '\u97CB';
  37319. t['\u2FB2'] = '\u97ED';
  37320. t['\u2FB3'] = '\u97F3';
  37321. t['\u2FB4'] = '\u9801';
  37322. t['\u2FB5'] = '\u98A8';
  37323. t['\u2FB6'] = '\u98DB';
  37324. t['\u2FB7'] = '\u98DF';
  37325. t['\u2FB8'] = '\u9996';
  37326. t['\u2FB9'] = '\u9999';
  37327. t['\u2FBA'] = '\u99AC';
  37328. t['\u2FBB'] = '\u9AA8';
  37329. t['\u2FBC'] = '\u9AD8';
  37330. t['\u2FBD'] = '\u9ADF';
  37331. t['\u2FBE'] = '\u9B25';
  37332. t['\u2FBF'] = '\u9B2F';
  37333. t['\u2FC0'] = '\u9B32';
  37334. t['\u2FC1'] = '\u9B3C';
  37335. t['\u2FC2'] = '\u9B5A';
  37336. t['\u2FC3'] = '\u9CE5';
  37337. t['\u2FC4'] = '\u9E75';
  37338. t['\u2FC5'] = '\u9E7F';
  37339. t['\u2FC6'] = '\u9EA5';
  37340. t['\u2FC7'] = '\u9EBB';
  37341. t['\u2FC8'] = '\u9EC3';
  37342. t['\u2FC9'] = '\u9ECD';
  37343. t['\u2FCA'] = '\u9ED1';
  37344. t['\u2FCB'] = '\u9EF9';
  37345. t['\u2FCC'] = '\u9EFD';
  37346. t['\u2FCD'] = '\u9F0E';
  37347. t['\u2FCE'] = '\u9F13';
  37348. t['\u2FCF'] = '\u9F20';
  37349. t['\u2FD0'] = '\u9F3B';
  37350. t['\u2FD1'] = '\u9F4A';
  37351. t['\u2FD2'] = '\u9F52';
  37352. t['\u2FD3'] = '\u9F8D';
  37353. t['\u2FD4'] = '\u9F9C';
  37354. t['\u2FD5'] = '\u9FA0';
  37355. t['\u3036'] = '\u3012';
  37356. t['\u3038'] = '\u5341';
  37357. t['\u3039'] = '\u5344';
  37358. t['\u303A'] = '\u5345';
  37359. t['\u309B'] = '\u0020\u3099';
  37360. t['\u309C'] = '\u0020\u309A';
  37361. t['\u3131'] = '\u1100';
  37362. t['\u3132'] = '\u1101';
  37363. t['\u3133'] = '\u11AA';
  37364. t['\u3134'] = '\u1102';
  37365. t['\u3135'] = '\u11AC';
  37366. t['\u3136'] = '\u11AD';
  37367. t['\u3137'] = '\u1103';
  37368. t['\u3138'] = '\u1104';
  37369. t['\u3139'] = '\u1105';
  37370. t['\u313A'] = '\u11B0';
  37371. t['\u313B'] = '\u11B1';
  37372. t['\u313C'] = '\u11B2';
  37373. t['\u313D'] = '\u11B3';
  37374. t['\u313E'] = '\u11B4';
  37375. t['\u313F'] = '\u11B5';
  37376. t['\u3140'] = '\u111A';
  37377. t['\u3141'] = '\u1106';
  37378. t['\u3142'] = '\u1107';
  37379. t['\u3143'] = '\u1108';
  37380. t['\u3144'] = '\u1121';
  37381. t['\u3145'] = '\u1109';
  37382. t['\u3146'] = '\u110A';
  37383. t['\u3147'] = '\u110B';
  37384. t['\u3148'] = '\u110C';
  37385. t['\u3149'] = '\u110D';
  37386. t['\u314A'] = '\u110E';
  37387. t['\u314B'] = '\u110F';
  37388. t['\u314C'] = '\u1110';
  37389. t['\u314D'] = '\u1111';
  37390. t['\u314E'] = '\u1112';
  37391. t['\u314F'] = '\u1161';
  37392. t['\u3150'] = '\u1162';
  37393. t['\u3151'] = '\u1163';
  37394. t['\u3152'] = '\u1164';
  37395. t['\u3153'] = '\u1165';
  37396. t['\u3154'] = '\u1166';
  37397. t['\u3155'] = '\u1167';
  37398. t['\u3156'] = '\u1168';
  37399. t['\u3157'] = '\u1169';
  37400. t['\u3158'] = '\u116A';
  37401. t['\u3159'] = '\u116B';
  37402. t['\u315A'] = '\u116C';
  37403. t['\u315B'] = '\u116D';
  37404. t['\u315C'] = '\u116E';
  37405. t['\u315D'] = '\u116F';
  37406. t['\u315E'] = '\u1170';
  37407. t['\u315F'] = '\u1171';
  37408. t['\u3160'] = '\u1172';
  37409. t['\u3161'] = '\u1173';
  37410. t['\u3162'] = '\u1174';
  37411. t['\u3163'] = '\u1175';
  37412. t['\u3164'] = '\u1160';
  37413. t['\u3165'] = '\u1114';
  37414. t['\u3166'] = '\u1115';
  37415. t['\u3167'] = '\u11C7';
  37416. t['\u3168'] = '\u11C8';
  37417. t['\u3169'] = '\u11CC';
  37418. t['\u316A'] = '\u11CE';
  37419. t['\u316B'] = '\u11D3';
  37420. t['\u316C'] = '\u11D7';
  37421. t['\u316D'] = '\u11D9';
  37422. t['\u316E'] = '\u111C';
  37423. t['\u316F'] = '\u11DD';
  37424. t['\u3170'] = '\u11DF';
  37425. t['\u3171'] = '\u111D';
  37426. t['\u3172'] = '\u111E';
  37427. t['\u3173'] = '\u1120';
  37428. t['\u3174'] = '\u1122';
  37429. t['\u3175'] = '\u1123';
  37430. t['\u3176'] = '\u1127';
  37431. t['\u3177'] = '\u1129';
  37432. t['\u3178'] = '\u112B';
  37433. t['\u3179'] = '\u112C';
  37434. t['\u317A'] = '\u112D';
  37435. t['\u317B'] = '\u112E';
  37436. t['\u317C'] = '\u112F';
  37437. t['\u317D'] = '\u1132';
  37438. t['\u317E'] = '\u1136';
  37439. t['\u317F'] = '\u1140';
  37440. t['\u3180'] = '\u1147';
  37441. t['\u3181'] = '\u114C';
  37442. t['\u3182'] = '\u11F1';
  37443. t['\u3183'] = '\u11F2';
  37444. t['\u3184'] = '\u1157';
  37445. t['\u3185'] = '\u1158';
  37446. t['\u3186'] = '\u1159';
  37447. t['\u3187'] = '\u1184';
  37448. t['\u3188'] = '\u1185';
  37449. t['\u3189'] = '\u1188';
  37450. t['\u318A'] = '\u1191';
  37451. t['\u318B'] = '\u1192';
  37452. t['\u318C'] = '\u1194';
  37453. t['\u318D'] = '\u119E';
  37454. t['\u318E'] = '\u11A1';
  37455. t['\u3200'] = '\u0028\u1100\u0029';
  37456. t['\u3201'] = '\u0028\u1102\u0029';
  37457. t['\u3202'] = '\u0028\u1103\u0029';
  37458. t['\u3203'] = '\u0028\u1105\u0029';
  37459. t['\u3204'] = '\u0028\u1106\u0029';
  37460. t['\u3205'] = '\u0028\u1107\u0029';
  37461. t['\u3206'] = '\u0028\u1109\u0029';
  37462. t['\u3207'] = '\u0028\u110B\u0029';
  37463. t['\u3208'] = '\u0028\u110C\u0029';
  37464. t['\u3209'] = '\u0028\u110E\u0029';
  37465. t['\u320A'] = '\u0028\u110F\u0029';
  37466. t['\u320B'] = '\u0028\u1110\u0029';
  37467. t['\u320C'] = '\u0028\u1111\u0029';
  37468. t['\u320D'] = '\u0028\u1112\u0029';
  37469. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  37470. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  37471. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  37472. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  37473. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  37474. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  37475. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  37476. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  37477. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  37478. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  37479. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  37480. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  37481. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  37482. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  37483. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  37484. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  37485. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  37486. t['\u3220'] = '\u0028\u4E00\u0029';
  37487. t['\u3221'] = '\u0028\u4E8C\u0029';
  37488. t['\u3222'] = '\u0028\u4E09\u0029';
  37489. t['\u3223'] = '\u0028\u56DB\u0029';
  37490. t['\u3224'] = '\u0028\u4E94\u0029';
  37491. t['\u3225'] = '\u0028\u516D\u0029';
  37492. t['\u3226'] = '\u0028\u4E03\u0029';
  37493. t['\u3227'] = '\u0028\u516B\u0029';
  37494. t['\u3228'] = '\u0028\u4E5D\u0029';
  37495. t['\u3229'] = '\u0028\u5341\u0029';
  37496. t['\u322A'] = '\u0028\u6708\u0029';
  37497. t['\u322B'] = '\u0028\u706B\u0029';
  37498. t['\u322C'] = '\u0028\u6C34\u0029';
  37499. t['\u322D'] = '\u0028\u6728\u0029';
  37500. t['\u322E'] = '\u0028\u91D1\u0029';
  37501. t['\u322F'] = '\u0028\u571F\u0029';
  37502. t['\u3230'] = '\u0028\u65E5\u0029';
  37503. t['\u3231'] = '\u0028\u682A\u0029';
  37504. t['\u3232'] = '\u0028\u6709\u0029';
  37505. t['\u3233'] = '\u0028\u793E\u0029';
  37506. t['\u3234'] = '\u0028\u540D\u0029';
  37507. t['\u3235'] = '\u0028\u7279\u0029';
  37508. t['\u3236'] = '\u0028\u8CA1\u0029';
  37509. t['\u3237'] = '\u0028\u795D\u0029';
  37510. t['\u3238'] = '\u0028\u52B4\u0029';
  37511. t['\u3239'] = '\u0028\u4EE3\u0029';
  37512. t['\u323A'] = '\u0028\u547C\u0029';
  37513. t['\u323B'] = '\u0028\u5B66\u0029';
  37514. t['\u323C'] = '\u0028\u76E3\u0029';
  37515. t['\u323D'] = '\u0028\u4F01\u0029';
  37516. t['\u323E'] = '\u0028\u8CC7\u0029';
  37517. t['\u323F'] = '\u0028\u5354\u0029';
  37518. t['\u3240'] = '\u0028\u796D\u0029';
  37519. t['\u3241'] = '\u0028\u4F11\u0029';
  37520. t['\u3242'] = '\u0028\u81EA\u0029';
  37521. t['\u3243'] = '\u0028\u81F3\u0029';
  37522. t['\u32C0'] = '\u0031\u6708';
  37523. t['\u32C1'] = '\u0032\u6708';
  37524. t['\u32C2'] = '\u0033\u6708';
  37525. t['\u32C3'] = '\u0034\u6708';
  37526. t['\u32C4'] = '\u0035\u6708';
  37527. t['\u32C5'] = '\u0036\u6708';
  37528. t['\u32C6'] = '\u0037\u6708';
  37529. t['\u32C7'] = '\u0038\u6708';
  37530. t['\u32C8'] = '\u0039\u6708';
  37531. t['\u32C9'] = '\u0031\u0030\u6708';
  37532. t['\u32CA'] = '\u0031\u0031\u6708';
  37533. t['\u32CB'] = '\u0031\u0032\u6708';
  37534. t['\u3358'] = '\u0030\u70B9';
  37535. t['\u3359'] = '\u0031\u70B9';
  37536. t['\u335A'] = '\u0032\u70B9';
  37537. t['\u335B'] = '\u0033\u70B9';
  37538. t['\u335C'] = '\u0034\u70B9';
  37539. t['\u335D'] = '\u0035\u70B9';
  37540. t['\u335E'] = '\u0036\u70B9';
  37541. t['\u335F'] = '\u0037\u70B9';
  37542. t['\u3360'] = '\u0038\u70B9';
  37543. t['\u3361'] = '\u0039\u70B9';
  37544. t['\u3362'] = '\u0031\u0030\u70B9';
  37545. t['\u3363'] = '\u0031\u0031\u70B9';
  37546. t['\u3364'] = '\u0031\u0032\u70B9';
  37547. t['\u3365'] = '\u0031\u0033\u70B9';
  37548. t['\u3366'] = '\u0031\u0034\u70B9';
  37549. t['\u3367'] = '\u0031\u0035\u70B9';
  37550. t['\u3368'] = '\u0031\u0036\u70B9';
  37551. t['\u3369'] = '\u0031\u0037\u70B9';
  37552. t['\u336A'] = '\u0031\u0038\u70B9';
  37553. t['\u336B'] = '\u0031\u0039\u70B9';
  37554. t['\u336C'] = '\u0032\u0030\u70B9';
  37555. t['\u336D'] = '\u0032\u0031\u70B9';
  37556. t['\u336E'] = '\u0032\u0032\u70B9';
  37557. t['\u336F'] = '\u0032\u0033\u70B9';
  37558. t['\u3370'] = '\u0032\u0034\u70B9';
  37559. t['\u33E0'] = '\u0031\u65E5';
  37560. t['\u33E1'] = '\u0032\u65E5';
  37561. t['\u33E2'] = '\u0033\u65E5';
  37562. t['\u33E3'] = '\u0034\u65E5';
  37563. t['\u33E4'] = '\u0035\u65E5';
  37564. t['\u33E5'] = '\u0036\u65E5';
  37565. t['\u33E6'] = '\u0037\u65E5';
  37566. t['\u33E7'] = '\u0038\u65E5';
  37567. t['\u33E8'] = '\u0039\u65E5';
  37568. t['\u33E9'] = '\u0031\u0030\u65E5';
  37569. t['\u33EA'] = '\u0031\u0031\u65E5';
  37570. t['\u33EB'] = '\u0031\u0032\u65E5';
  37571. t['\u33EC'] = '\u0031\u0033\u65E5';
  37572. t['\u33ED'] = '\u0031\u0034\u65E5';
  37573. t['\u33EE'] = '\u0031\u0035\u65E5';
  37574. t['\u33EF'] = '\u0031\u0036\u65E5';
  37575. t['\u33F0'] = '\u0031\u0037\u65E5';
  37576. t['\u33F1'] = '\u0031\u0038\u65E5';
  37577. t['\u33F2'] = '\u0031\u0039\u65E5';
  37578. t['\u33F3'] = '\u0032\u0030\u65E5';
  37579. t['\u33F4'] = '\u0032\u0031\u65E5';
  37580. t['\u33F5'] = '\u0032\u0032\u65E5';
  37581. t['\u33F6'] = '\u0032\u0033\u65E5';
  37582. t['\u33F7'] = '\u0032\u0034\u65E5';
  37583. t['\u33F8'] = '\u0032\u0035\u65E5';
  37584. t['\u33F9'] = '\u0032\u0036\u65E5';
  37585. t['\u33FA'] = '\u0032\u0037\u65E5';
  37586. t['\u33FB'] = '\u0032\u0038\u65E5';
  37587. t['\u33FC'] = '\u0032\u0039\u65E5';
  37588. t['\u33FD'] = '\u0033\u0030\u65E5';
  37589. t['\u33FE'] = '\u0033\u0031\u65E5';
  37590. t['\uFB00'] = '\u0066\u0066';
  37591. t['\uFB01'] = '\u0066\u0069';
  37592. t['\uFB02'] = '\u0066\u006C';
  37593. t['\uFB03'] = '\u0066\u0066\u0069';
  37594. t['\uFB04'] = '\u0066\u0066\u006C';
  37595. t['\uFB05'] = '\u017F\u0074';
  37596. t['\uFB06'] = '\u0073\u0074';
  37597. t['\uFB13'] = '\u0574\u0576';
  37598. t['\uFB14'] = '\u0574\u0565';
  37599. t['\uFB15'] = '\u0574\u056B';
  37600. t['\uFB16'] = '\u057E\u0576';
  37601. t['\uFB17'] = '\u0574\u056D';
  37602. t['\uFB4F'] = '\u05D0\u05DC';
  37603. t['\uFB50'] = '\u0671';
  37604. t['\uFB51'] = '\u0671';
  37605. t['\uFB52'] = '\u067B';
  37606. t['\uFB53'] = '\u067B';
  37607. t['\uFB54'] = '\u067B';
  37608. t['\uFB55'] = '\u067B';
  37609. t['\uFB56'] = '\u067E';
  37610. t['\uFB57'] = '\u067E';
  37611. t['\uFB58'] = '\u067E';
  37612. t['\uFB59'] = '\u067E';
  37613. t['\uFB5A'] = '\u0680';
  37614. t['\uFB5B'] = '\u0680';
  37615. t['\uFB5C'] = '\u0680';
  37616. t['\uFB5D'] = '\u0680';
  37617. t['\uFB5E'] = '\u067A';
  37618. t['\uFB5F'] = '\u067A';
  37619. t['\uFB60'] = '\u067A';
  37620. t['\uFB61'] = '\u067A';
  37621. t['\uFB62'] = '\u067F';
  37622. t['\uFB63'] = '\u067F';
  37623. t['\uFB64'] = '\u067F';
  37624. t['\uFB65'] = '\u067F';
  37625. t['\uFB66'] = '\u0679';
  37626. t['\uFB67'] = '\u0679';
  37627. t['\uFB68'] = '\u0679';
  37628. t['\uFB69'] = '\u0679';
  37629. t['\uFB6A'] = '\u06A4';
  37630. t['\uFB6B'] = '\u06A4';
  37631. t['\uFB6C'] = '\u06A4';
  37632. t['\uFB6D'] = '\u06A4';
  37633. t['\uFB6E'] = '\u06A6';
  37634. t['\uFB6F'] = '\u06A6';
  37635. t['\uFB70'] = '\u06A6';
  37636. t['\uFB71'] = '\u06A6';
  37637. t['\uFB72'] = '\u0684';
  37638. t['\uFB73'] = '\u0684';
  37639. t['\uFB74'] = '\u0684';
  37640. t['\uFB75'] = '\u0684';
  37641. t['\uFB76'] = '\u0683';
  37642. t['\uFB77'] = '\u0683';
  37643. t['\uFB78'] = '\u0683';
  37644. t['\uFB79'] = '\u0683';
  37645. t['\uFB7A'] = '\u0686';
  37646. t['\uFB7B'] = '\u0686';
  37647. t['\uFB7C'] = '\u0686';
  37648. t['\uFB7D'] = '\u0686';
  37649. t['\uFB7E'] = '\u0687';
  37650. t['\uFB7F'] = '\u0687';
  37651. t['\uFB80'] = '\u0687';
  37652. t['\uFB81'] = '\u0687';
  37653. t['\uFB82'] = '\u068D';
  37654. t['\uFB83'] = '\u068D';
  37655. t['\uFB84'] = '\u068C';
  37656. t['\uFB85'] = '\u068C';
  37657. t['\uFB86'] = '\u068E';
  37658. t['\uFB87'] = '\u068E';
  37659. t['\uFB88'] = '\u0688';
  37660. t['\uFB89'] = '\u0688';
  37661. t['\uFB8A'] = '\u0698';
  37662. t['\uFB8B'] = '\u0698';
  37663. t['\uFB8C'] = '\u0691';
  37664. t['\uFB8D'] = '\u0691';
  37665. t['\uFB8E'] = '\u06A9';
  37666. t['\uFB8F'] = '\u06A9';
  37667. t['\uFB90'] = '\u06A9';
  37668. t['\uFB91'] = '\u06A9';
  37669. t['\uFB92'] = '\u06AF';
  37670. t['\uFB93'] = '\u06AF';
  37671. t['\uFB94'] = '\u06AF';
  37672. t['\uFB95'] = '\u06AF';
  37673. t['\uFB96'] = '\u06B3';
  37674. t['\uFB97'] = '\u06B3';
  37675. t['\uFB98'] = '\u06B3';
  37676. t['\uFB99'] = '\u06B3';
  37677. t['\uFB9A'] = '\u06B1';
  37678. t['\uFB9B'] = '\u06B1';
  37679. t['\uFB9C'] = '\u06B1';
  37680. t['\uFB9D'] = '\u06B1';
  37681. t['\uFB9E'] = '\u06BA';
  37682. t['\uFB9F'] = '\u06BA';
  37683. t['\uFBA0'] = '\u06BB';
  37684. t['\uFBA1'] = '\u06BB';
  37685. t['\uFBA2'] = '\u06BB';
  37686. t['\uFBA3'] = '\u06BB';
  37687. t['\uFBA4'] = '\u06C0';
  37688. t['\uFBA5'] = '\u06C0';
  37689. t['\uFBA6'] = '\u06C1';
  37690. t['\uFBA7'] = '\u06C1';
  37691. t['\uFBA8'] = '\u06C1';
  37692. t['\uFBA9'] = '\u06C1';
  37693. t['\uFBAA'] = '\u06BE';
  37694. t['\uFBAB'] = '\u06BE';
  37695. t['\uFBAC'] = '\u06BE';
  37696. t['\uFBAD'] = '\u06BE';
  37697. t['\uFBAE'] = '\u06D2';
  37698. t['\uFBAF'] = '\u06D2';
  37699. t['\uFBB0'] = '\u06D3';
  37700. t['\uFBB1'] = '\u06D3';
  37701. t['\uFBD3'] = '\u06AD';
  37702. t['\uFBD4'] = '\u06AD';
  37703. t['\uFBD5'] = '\u06AD';
  37704. t['\uFBD6'] = '\u06AD';
  37705. t['\uFBD7'] = '\u06C7';
  37706. t['\uFBD8'] = '\u06C7';
  37707. t['\uFBD9'] = '\u06C6';
  37708. t['\uFBDA'] = '\u06C6';
  37709. t['\uFBDB'] = '\u06C8';
  37710. t['\uFBDC'] = '\u06C8';
  37711. t['\uFBDD'] = '\u0677';
  37712. t['\uFBDE'] = '\u06CB';
  37713. t['\uFBDF'] = '\u06CB';
  37714. t['\uFBE0'] = '\u06C5';
  37715. t['\uFBE1'] = '\u06C5';
  37716. t['\uFBE2'] = '\u06C9';
  37717. t['\uFBE3'] = '\u06C9';
  37718. t['\uFBE4'] = '\u06D0';
  37719. t['\uFBE5'] = '\u06D0';
  37720. t['\uFBE6'] = '\u06D0';
  37721. t['\uFBE7'] = '\u06D0';
  37722. t['\uFBE8'] = '\u0649';
  37723. t['\uFBE9'] = '\u0649';
  37724. t['\uFBEA'] = '\u0626\u0627';
  37725. t['\uFBEB'] = '\u0626\u0627';
  37726. t['\uFBEC'] = '\u0626\u06D5';
  37727. t['\uFBED'] = '\u0626\u06D5';
  37728. t['\uFBEE'] = '\u0626\u0648';
  37729. t['\uFBEF'] = '\u0626\u0648';
  37730. t['\uFBF0'] = '\u0626\u06C7';
  37731. t['\uFBF1'] = '\u0626\u06C7';
  37732. t['\uFBF2'] = '\u0626\u06C6';
  37733. t['\uFBF3'] = '\u0626\u06C6';
  37734. t['\uFBF4'] = '\u0626\u06C8';
  37735. t['\uFBF5'] = '\u0626\u06C8';
  37736. t['\uFBF6'] = '\u0626\u06D0';
  37737. t['\uFBF7'] = '\u0626\u06D0';
  37738. t['\uFBF8'] = '\u0626\u06D0';
  37739. t['\uFBF9'] = '\u0626\u0649';
  37740. t['\uFBFA'] = '\u0626\u0649';
  37741. t['\uFBFB'] = '\u0626\u0649';
  37742. t['\uFBFC'] = '\u06CC';
  37743. t['\uFBFD'] = '\u06CC';
  37744. t['\uFBFE'] = '\u06CC';
  37745. t['\uFBFF'] = '\u06CC';
  37746. t['\uFC00'] = '\u0626\u062C';
  37747. t['\uFC01'] = '\u0626\u062D';
  37748. t['\uFC02'] = '\u0626\u0645';
  37749. t['\uFC03'] = '\u0626\u0649';
  37750. t['\uFC04'] = '\u0626\u064A';
  37751. t['\uFC05'] = '\u0628\u062C';
  37752. t['\uFC06'] = '\u0628\u062D';
  37753. t['\uFC07'] = '\u0628\u062E';
  37754. t['\uFC08'] = '\u0628\u0645';
  37755. t['\uFC09'] = '\u0628\u0649';
  37756. t['\uFC0A'] = '\u0628\u064A';
  37757. t['\uFC0B'] = '\u062A\u062C';
  37758. t['\uFC0C'] = '\u062A\u062D';
  37759. t['\uFC0D'] = '\u062A\u062E';
  37760. t['\uFC0E'] = '\u062A\u0645';
  37761. t['\uFC0F'] = '\u062A\u0649';
  37762. t['\uFC10'] = '\u062A\u064A';
  37763. t['\uFC11'] = '\u062B\u062C';
  37764. t['\uFC12'] = '\u062B\u0645';
  37765. t['\uFC13'] = '\u062B\u0649';
  37766. t['\uFC14'] = '\u062B\u064A';
  37767. t['\uFC15'] = '\u062C\u062D';
  37768. t['\uFC16'] = '\u062C\u0645';
  37769. t['\uFC17'] = '\u062D\u062C';
  37770. t['\uFC18'] = '\u062D\u0645';
  37771. t['\uFC19'] = '\u062E\u062C';
  37772. t['\uFC1A'] = '\u062E\u062D';
  37773. t['\uFC1B'] = '\u062E\u0645';
  37774. t['\uFC1C'] = '\u0633\u062C';
  37775. t['\uFC1D'] = '\u0633\u062D';
  37776. t['\uFC1E'] = '\u0633\u062E';
  37777. t['\uFC1F'] = '\u0633\u0645';
  37778. t['\uFC20'] = '\u0635\u062D';
  37779. t['\uFC21'] = '\u0635\u0645';
  37780. t['\uFC22'] = '\u0636\u062C';
  37781. t['\uFC23'] = '\u0636\u062D';
  37782. t['\uFC24'] = '\u0636\u062E';
  37783. t['\uFC25'] = '\u0636\u0645';
  37784. t['\uFC26'] = '\u0637\u062D';
  37785. t['\uFC27'] = '\u0637\u0645';
  37786. t['\uFC28'] = '\u0638\u0645';
  37787. t['\uFC29'] = '\u0639\u062C';
  37788. t['\uFC2A'] = '\u0639\u0645';
  37789. t['\uFC2B'] = '\u063A\u062C';
  37790. t['\uFC2C'] = '\u063A\u0645';
  37791. t['\uFC2D'] = '\u0641\u062C';
  37792. t['\uFC2E'] = '\u0641\u062D';
  37793. t['\uFC2F'] = '\u0641\u062E';
  37794. t['\uFC30'] = '\u0641\u0645';
  37795. t['\uFC31'] = '\u0641\u0649';
  37796. t['\uFC32'] = '\u0641\u064A';
  37797. t['\uFC33'] = '\u0642\u062D';
  37798. t['\uFC34'] = '\u0642\u0645';
  37799. t['\uFC35'] = '\u0642\u0649';
  37800. t['\uFC36'] = '\u0642\u064A';
  37801. t['\uFC37'] = '\u0643\u0627';
  37802. t['\uFC38'] = '\u0643\u062C';
  37803. t['\uFC39'] = '\u0643\u062D';
  37804. t['\uFC3A'] = '\u0643\u062E';
  37805. t['\uFC3B'] = '\u0643\u0644';
  37806. t['\uFC3C'] = '\u0643\u0645';
  37807. t['\uFC3D'] = '\u0643\u0649';
  37808. t['\uFC3E'] = '\u0643\u064A';
  37809. t['\uFC3F'] = '\u0644\u062C';
  37810. t['\uFC40'] = '\u0644\u062D';
  37811. t['\uFC41'] = '\u0644\u062E';
  37812. t['\uFC42'] = '\u0644\u0645';
  37813. t['\uFC43'] = '\u0644\u0649';
  37814. t['\uFC44'] = '\u0644\u064A';
  37815. t['\uFC45'] = '\u0645\u062C';
  37816. t['\uFC46'] = '\u0645\u062D';
  37817. t['\uFC47'] = '\u0645\u062E';
  37818. t['\uFC48'] = '\u0645\u0645';
  37819. t['\uFC49'] = '\u0645\u0649';
  37820. t['\uFC4A'] = '\u0645\u064A';
  37821. t['\uFC4B'] = '\u0646\u062C';
  37822. t['\uFC4C'] = '\u0646\u062D';
  37823. t['\uFC4D'] = '\u0646\u062E';
  37824. t['\uFC4E'] = '\u0646\u0645';
  37825. t['\uFC4F'] = '\u0646\u0649';
  37826. t['\uFC50'] = '\u0646\u064A';
  37827. t['\uFC51'] = '\u0647\u062C';
  37828. t['\uFC52'] = '\u0647\u0645';
  37829. t['\uFC53'] = '\u0647\u0649';
  37830. t['\uFC54'] = '\u0647\u064A';
  37831. t['\uFC55'] = '\u064A\u062C';
  37832. t['\uFC56'] = '\u064A\u062D';
  37833. t['\uFC57'] = '\u064A\u062E';
  37834. t['\uFC58'] = '\u064A\u0645';
  37835. t['\uFC59'] = '\u064A\u0649';
  37836. t['\uFC5A'] = '\u064A\u064A';
  37837. t['\uFC5B'] = '\u0630\u0670';
  37838. t['\uFC5C'] = '\u0631\u0670';
  37839. t['\uFC5D'] = '\u0649\u0670';
  37840. t['\uFC5E'] = '\u0020\u064C\u0651';
  37841. t['\uFC5F'] = '\u0020\u064D\u0651';
  37842. t['\uFC60'] = '\u0020\u064E\u0651';
  37843. t['\uFC61'] = '\u0020\u064F\u0651';
  37844. t['\uFC62'] = '\u0020\u0650\u0651';
  37845. t['\uFC63'] = '\u0020\u0651\u0670';
  37846. t['\uFC64'] = '\u0626\u0631';
  37847. t['\uFC65'] = '\u0626\u0632';
  37848. t['\uFC66'] = '\u0626\u0645';
  37849. t['\uFC67'] = '\u0626\u0646';
  37850. t['\uFC68'] = '\u0626\u0649';
  37851. t['\uFC69'] = '\u0626\u064A';
  37852. t['\uFC6A'] = '\u0628\u0631';
  37853. t['\uFC6B'] = '\u0628\u0632';
  37854. t['\uFC6C'] = '\u0628\u0645';
  37855. t['\uFC6D'] = '\u0628\u0646';
  37856. t['\uFC6E'] = '\u0628\u0649';
  37857. t['\uFC6F'] = '\u0628\u064A';
  37858. t['\uFC70'] = '\u062A\u0631';
  37859. t['\uFC71'] = '\u062A\u0632';
  37860. t['\uFC72'] = '\u062A\u0645';
  37861. t['\uFC73'] = '\u062A\u0646';
  37862. t['\uFC74'] = '\u062A\u0649';
  37863. t['\uFC75'] = '\u062A\u064A';
  37864. t['\uFC76'] = '\u062B\u0631';
  37865. t['\uFC77'] = '\u062B\u0632';
  37866. t['\uFC78'] = '\u062B\u0645';
  37867. t['\uFC79'] = '\u062B\u0646';
  37868. t['\uFC7A'] = '\u062B\u0649';
  37869. t['\uFC7B'] = '\u062B\u064A';
  37870. t['\uFC7C'] = '\u0641\u0649';
  37871. t['\uFC7D'] = '\u0641\u064A';
  37872. t['\uFC7E'] = '\u0642\u0649';
  37873. t['\uFC7F'] = '\u0642\u064A';
  37874. t['\uFC80'] = '\u0643\u0627';
  37875. t['\uFC81'] = '\u0643\u0644';
  37876. t['\uFC82'] = '\u0643\u0645';
  37877. t['\uFC83'] = '\u0643\u0649';
  37878. t['\uFC84'] = '\u0643\u064A';
  37879. t['\uFC85'] = '\u0644\u0645';
  37880. t['\uFC86'] = '\u0644\u0649';
  37881. t['\uFC87'] = '\u0644\u064A';
  37882. t['\uFC88'] = '\u0645\u0627';
  37883. t['\uFC89'] = '\u0645\u0645';
  37884. t['\uFC8A'] = '\u0646\u0631';
  37885. t['\uFC8B'] = '\u0646\u0632';
  37886. t['\uFC8C'] = '\u0646\u0645';
  37887. t['\uFC8D'] = '\u0646\u0646';
  37888. t['\uFC8E'] = '\u0646\u0649';
  37889. t['\uFC8F'] = '\u0646\u064A';
  37890. t['\uFC90'] = '\u0649\u0670';
  37891. t['\uFC91'] = '\u064A\u0631';
  37892. t['\uFC92'] = '\u064A\u0632';
  37893. t['\uFC93'] = '\u064A\u0645';
  37894. t['\uFC94'] = '\u064A\u0646';
  37895. t['\uFC95'] = '\u064A\u0649';
  37896. t['\uFC96'] = '\u064A\u064A';
  37897. t['\uFC97'] = '\u0626\u062C';
  37898. t['\uFC98'] = '\u0626\u062D';
  37899. t['\uFC99'] = '\u0626\u062E';
  37900. t['\uFC9A'] = '\u0626\u0645';
  37901. t['\uFC9B'] = '\u0626\u0647';
  37902. t['\uFC9C'] = '\u0628\u062C';
  37903. t['\uFC9D'] = '\u0628\u062D';
  37904. t['\uFC9E'] = '\u0628\u062E';
  37905. t['\uFC9F'] = '\u0628\u0645';
  37906. t['\uFCA0'] = '\u0628\u0647';
  37907. t['\uFCA1'] = '\u062A\u062C';
  37908. t['\uFCA2'] = '\u062A\u062D';
  37909. t['\uFCA3'] = '\u062A\u062E';
  37910. t['\uFCA4'] = '\u062A\u0645';
  37911. t['\uFCA5'] = '\u062A\u0647';
  37912. t['\uFCA6'] = '\u062B\u0645';
  37913. t['\uFCA7'] = '\u062C\u062D';
  37914. t['\uFCA8'] = '\u062C\u0645';
  37915. t['\uFCA9'] = '\u062D\u062C';
  37916. t['\uFCAA'] = '\u062D\u0645';
  37917. t['\uFCAB'] = '\u062E\u062C';
  37918. t['\uFCAC'] = '\u062E\u0645';
  37919. t['\uFCAD'] = '\u0633\u062C';
  37920. t['\uFCAE'] = '\u0633\u062D';
  37921. t['\uFCAF'] = '\u0633\u062E';
  37922. t['\uFCB0'] = '\u0633\u0645';
  37923. t['\uFCB1'] = '\u0635\u062D';
  37924. t['\uFCB2'] = '\u0635\u062E';
  37925. t['\uFCB3'] = '\u0635\u0645';
  37926. t['\uFCB4'] = '\u0636\u062C';
  37927. t['\uFCB5'] = '\u0636\u062D';
  37928. t['\uFCB6'] = '\u0636\u062E';
  37929. t['\uFCB7'] = '\u0636\u0645';
  37930. t['\uFCB8'] = '\u0637\u062D';
  37931. t['\uFCB9'] = '\u0638\u0645';
  37932. t['\uFCBA'] = '\u0639\u062C';
  37933. t['\uFCBB'] = '\u0639\u0645';
  37934. t['\uFCBC'] = '\u063A\u062C';
  37935. t['\uFCBD'] = '\u063A\u0645';
  37936. t['\uFCBE'] = '\u0641\u062C';
  37937. t['\uFCBF'] = '\u0641\u062D';
  37938. t['\uFCC0'] = '\u0641\u062E';
  37939. t['\uFCC1'] = '\u0641\u0645';
  37940. t['\uFCC2'] = '\u0642\u062D';
  37941. t['\uFCC3'] = '\u0642\u0645';
  37942. t['\uFCC4'] = '\u0643\u062C';
  37943. t['\uFCC5'] = '\u0643\u062D';
  37944. t['\uFCC6'] = '\u0643\u062E';
  37945. t['\uFCC7'] = '\u0643\u0644';
  37946. t['\uFCC8'] = '\u0643\u0645';
  37947. t['\uFCC9'] = '\u0644\u062C';
  37948. t['\uFCCA'] = '\u0644\u062D';
  37949. t['\uFCCB'] = '\u0644\u062E';
  37950. t['\uFCCC'] = '\u0644\u0645';
  37951. t['\uFCCD'] = '\u0644\u0647';
  37952. t['\uFCCE'] = '\u0645\u062C';
  37953. t['\uFCCF'] = '\u0645\u062D';
  37954. t['\uFCD0'] = '\u0645\u062E';
  37955. t['\uFCD1'] = '\u0645\u0645';
  37956. t['\uFCD2'] = '\u0646\u062C';
  37957. t['\uFCD3'] = '\u0646\u062D';
  37958. t['\uFCD4'] = '\u0646\u062E';
  37959. t['\uFCD5'] = '\u0646\u0645';
  37960. t['\uFCD6'] = '\u0646\u0647';
  37961. t['\uFCD7'] = '\u0647\u062C';
  37962. t['\uFCD8'] = '\u0647\u0645';
  37963. t['\uFCD9'] = '\u0647\u0670';
  37964. t['\uFCDA'] = '\u064A\u062C';
  37965. t['\uFCDB'] = '\u064A\u062D';
  37966. t['\uFCDC'] = '\u064A\u062E';
  37967. t['\uFCDD'] = '\u064A\u0645';
  37968. t['\uFCDE'] = '\u064A\u0647';
  37969. t['\uFCDF'] = '\u0626\u0645';
  37970. t['\uFCE0'] = '\u0626\u0647';
  37971. t['\uFCE1'] = '\u0628\u0645';
  37972. t['\uFCE2'] = '\u0628\u0647';
  37973. t['\uFCE3'] = '\u062A\u0645';
  37974. t['\uFCE4'] = '\u062A\u0647';
  37975. t['\uFCE5'] = '\u062B\u0645';
  37976. t['\uFCE6'] = '\u062B\u0647';
  37977. t['\uFCE7'] = '\u0633\u0645';
  37978. t['\uFCE8'] = '\u0633\u0647';
  37979. t['\uFCE9'] = '\u0634\u0645';
  37980. t['\uFCEA'] = '\u0634\u0647';
  37981. t['\uFCEB'] = '\u0643\u0644';
  37982. t['\uFCEC'] = '\u0643\u0645';
  37983. t['\uFCED'] = '\u0644\u0645';
  37984. t['\uFCEE'] = '\u0646\u0645';
  37985. t['\uFCEF'] = '\u0646\u0647';
  37986. t['\uFCF0'] = '\u064A\u0645';
  37987. t['\uFCF1'] = '\u064A\u0647';
  37988. t['\uFCF2'] = '\u0640\u064E\u0651';
  37989. t['\uFCF3'] = '\u0640\u064F\u0651';
  37990. t['\uFCF4'] = '\u0640\u0650\u0651';
  37991. t['\uFCF5'] = '\u0637\u0649';
  37992. t['\uFCF6'] = '\u0637\u064A';
  37993. t['\uFCF7'] = '\u0639\u0649';
  37994. t['\uFCF8'] = '\u0639\u064A';
  37995. t['\uFCF9'] = '\u063A\u0649';
  37996. t['\uFCFA'] = '\u063A\u064A';
  37997. t['\uFCFB'] = '\u0633\u0649';
  37998. t['\uFCFC'] = '\u0633\u064A';
  37999. t['\uFCFD'] = '\u0634\u0649';
  38000. t['\uFCFE'] = '\u0634\u064A';
  38001. t['\uFCFF'] = '\u062D\u0649';
  38002. t['\uFD00'] = '\u062D\u064A';
  38003. t['\uFD01'] = '\u062C\u0649';
  38004. t['\uFD02'] = '\u062C\u064A';
  38005. t['\uFD03'] = '\u062E\u0649';
  38006. t['\uFD04'] = '\u062E\u064A';
  38007. t['\uFD05'] = '\u0635\u0649';
  38008. t['\uFD06'] = '\u0635\u064A';
  38009. t['\uFD07'] = '\u0636\u0649';
  38010. t['\uFD08'] = '\u0636\u064A';
  38011. t['\uFD09'] = '\u0634\u062C';
  38012. t['\uFD0A'] = '\u0634\u062D';
  38013. t['\uFD0B'] = '\u0634\u062E';
  38014. t['\uFD0C'] = '\u0634\u0645';
  38015. t['\uFD0D'] = '\u0634\u0631';
  38016. t['\uFD0E'] = '\u0633\u0631';
  38017. t['\uFD0F'] = '\u0635\u0631';
  38018. t['\uFD10'] = '\u0636\u0631';
  38019. t['\uFD11'] = '\u0637\u0649';
  38020. t['\uFD12'] = '\u0637\u064A';
  38021. t['\uFD13'] = '\u0639\u0649';
  38022. t['\uFD14'] = '\u0639\u064A';
  38023. t['\uFD15'] = '\u063A\u0649';
  38024. t['\uFD16'] = '\u063A\u064A';
  38025. t['\uFD17'] = '\u0633\u0649';
  38026. t['\uFD18'] = '\u0633\u064A';
  38027. t['\uFD19'] = '\u0634\u0649';
  38028. t['\uFD1A'] = '\u0634\u064A';
  38029. t['\uFD1B'] = '\u062D\u0649';
  38030. t['\uFD1C'] = '\u062D\u064A';
  38031. t['\uFD1D'] = '\u062C\u0649';
  38032. t['\uFD1E'] = '\u062C\u064A';
  38033. t['\uFD1F'] = '\u062E\u0649';
  38034. t['\uFD20'] = '\u062E\u064A';
  38035. t['\uFD21'] = '\u0635\u0649';
  38036. t['\uFD22'] = '\u0635\u064A';
  38037. t['\uFD23'] = '\u0636\u0649';
  38038. t['\uFD24'] = '\u0636\u064A';
  38039. t['\uFD25'] = '\u0634\u062C';
  38040. t['\uFD26'] = '\u0634\u062D';
  38041. t['\uFD27'] = '\u0634\u062E';
  38042. t['\uFD28'] = '\u0634\u0645';
  38043. t['\uFD29'] = '\u0634\u0631';
  38044. t['\uFD2A'] = '\u0633\u0631';
  38045. t['\uFD2B'] = '\u0635\u0631';
  38046. t['\uFD2C'] = '\u0636\u0631';
  38047. t['\uFD2D'] = '\u0634\u062C';
  38048. t['\uFD2E'] = '\u0634\u062D';
  38049. t['\uFD2F'] = '\u0634\u062E';
  38050. t['\uFD30'] = '\u0634\u0645';
  38051. t['\uFD31'] = '\u0633\u0647';
  38052. t['\uFD32'] = '\u0634\u0647';
  38053. t['\uFD33'] = '\u0637\u0645';
  38054. t['\uFD34'] = '\u0633\u062C';
  38055. t['\uFD35'] = '\u0633\u062D';
  38056. t['\uFD36'] = '\u0633\u062E';
  38057. t['\uFD37'] = '\u0634\u062C';
  38058. t['\uFD38'] = '\u0634\u062D';
  38059. t['\uFD39'] = '\u0634\u062E';
  38060. t['\uFD3A'] = '\u0637\u0645';
  38061. t['\uFD3B'] = '\u0638\u0645';
  38062. t['\uFD3C'] = '\u0627\u064B';
  38063. t['\uFD3D'] = '\u0627\u064B';
  38064. t['\uFD50'] = '\u062A\u062C\u0645';
  38065. t['\uFD51'] = '\u062A\u062D\u062C';
  38066. t['\uFD52'] = '\u062A\u062D\u062C';
  38067. t['\uFD53'] = '\u062A\u062D\u0645';
  38068. t['\uFD54'] = '\u062A\u062E\u0645';
  38069. t['\uFD55'] = '\u062A\u0645\u062C';
  38070. t['\uFD56'] = '\u062A\u0645\u062D';
  38071. t['\uFD57'] = '\u062A\u0645\u062E';
  38072. t['\uFD58'] = '\u062C\u0645\u062D';
  38073. t['\uFD59'] = '\u062C\u0645\u062D';
  38074. t['\uFD5A'] = '\u062D\u0645\u064A';
  38075. t['\uFD5B'] = '\u062D\u0645\u0649';
  38076. t['\uFD5C'] = '\u0633\u062D\u062C';
  38077. t['\uFD5D'] = '\u0633\u062C\u062D';
  38078. t['\uFD5E'] = '\u0633\u062C\u0649';
  38079. t['\uFD5F'] = '\u0633\u0645\u062D';
  38080. t['\uFD60'] = '\u0633\u0645\u062D';
  38081. t['\uFD61'] = '\u0633\u0645\u062C';
  38082. t['\uFD62'] = '\u0633\u0645\u0645';
  38083. t['\uFD63'] = '\u0633\u0645\u0645';
  38084. t['\uFD64'] = '\u0635\u062D\u062D';
  38085. t['\uFD65'] = '\u0635\u062D\u062D';
  38086. t['\uFD66'] = '\u0635\u0645\u0645';
  38087. t['\uFD67'] = '\u0634\u062D\u0645';
  38088. t['\uFD68'] = '\u0634\u062D\u0645';
  38089. t['\uFD69'] = '\u0634\u062C\u064A';
  38090. t['\uFD6A'] = '\u0634\u0645\u062E';
  38091. t['\uFD6B'] = '\u0634\u0645\u062E';
  38092. t['\uFD6C'] = '\u0634\u0645\u0645';
  38093. t['\uFD6D'] = '\u0634\u0645\u0645';
  38094. t['\uFD6E'] = '\u0636\u062D\u0649';
  38095. t['\uFD6F'] = '\u0636\u062E\u0645';
  38096. t['\uFD70'] = '\u0636\u062E\u0645';
  38097. t['\uFD71'] = '\u0637\u0645\u062D';
  38098. t['\uFD72'] = '\u0637\u0645\u062D';
  38099. t['\uFD73'] = '\u0637\u0645\u0645';
  38100. t['\uFD74'] = '\u0637\u0645\u064A';
  38101. t['\uFD75'] = '\u0639\u062C\u0645';
  38102. t['\uFD76'] = '\u0639\u0645\u0645';
  38103. t['\uFD77'] = '\u0639\u0645\u0645';
  38104. t['\uFD78'] = '\u0639\u0645\u0649';
  38105. t['\uFD79'] = '\u063A\u0645\u0645';
  38106. t['\uFD7A'] = '\u063A\u0645\u064A';
  38107. t['\uFD7B'] = '\u063A\u0645\u0649';
  38108. t['\uFD7C'] = '\u0641\u062E\u0645';
  38109. t['\uFD7D'] = '\u0641\u062E\u0645';
  38110. t['\uFD7E'] = '\u0642\u0645\u062D';
  38111. t['\uFD7F'] = '\u0642\u0645\u0645';
  38112. t['\uFD80'] = '\u0644\u062D\u0645';
  38113. t['\uFD81'] = '\u0644\u062D\u064A';
  38114. t['\uFD82'] = '\u0644\u062D\u0649';
  38115. t['\uFD83'] = '\u0644\u062C\u062C';
  38116. t['\uFD84'] = '\u0644\u062C\u062C';
  38117. t['\uFD85'] = '\u0644\u062E\u0645';
  38118. t['\uFD86'] = '\u0644\u062E\u0645';
  38119. t['\uFD87'] = '\u0644\u0645\u062D';
  38120. t['\uFD88'] = '\u0644\u0645\u062D';
  38121. t['\uFD89'] = '\u0645\u062D\u062C';
  38122. t['\uFD8A'] = '\u0645\u062D\u0645';
  38123. t['\uFD8B'] = '\u0645\u062D\u064A';
  38124. t['\uFD8C'] = '\u0645\u062C\u062D';
  38125. t['\uFD8D'] = '\u0645\u062C\u0645';
  38126. t['\uFD8E'] = '\u0645\u062E\u062C';
  38127. t['\uFD8F'] = '\u0645\u062E\u0645';
  38128. t['\uFD92'] = '\u0645\u062C\u062E';
  38129. t['\uFD93'] = '\u0647\u0645\u062C';
  38130. t['\uFD94'] = '\u0647\u0645\u0645';
  38131. t['\uFD95'] = '\u0646\u062D\u0645';
  38132. t['\uFD96'] = '\u0646\u062D\u0649';
  38133. t['\uFD97'] = '\u0646\u062C\u0645';
  38134. t['\uFD98'] = '\u0646\u062C\u0645';
  38135. t['\uFD99'] = '\u0646\u062C\u0649';
  38136. t['\uFD9A'] = '\u0646\u0645\u064A';
  38137. t['\uFD9B'] = '\u0646\u0645\u0649';
  38138. t['\uFD9C'] = '\u064A\u0645\u0645';
  38139. t['\uFD9D'] = '\u064A\u0645\u0645';
  38140. t['\uFD9E'] = '\u0628\u062E\u064A';
  38141. t['\uFD9F'] = '\u062A\u062C\u064A';
  38142. t['\uFDA0'] = '\u062A\u062C\u0649';
  38143. t['\uFDA1'] = '\u062A\u062E\u064A';
  38144. t['\uFDA2'] = '\u062A\u062E\u0649';
  38145. t['\uFDA3'] = '\u062A\u0645\u064A';
  38146. t['\uFDA4'] = '\u062A\u0645\u0649';
  38147. t['\uFDA5'] = '\u062C\u0645\u064A';
  38148. t['\uFDA6'] = '\u062C\u062D\u0649';
  38149. t['\uFDA7'] = '\u062C\u0645\u0649';
  38150. t['\uFDA8'] = '\u0633\u062E\u0649';
  38151. t['\uFDA9'] = '\u0635\u062D\u064A';
  38152. t['\uFDAA'] = '\u0634\u062D\u064A';
  38153. t['\uFDAB'] = '\u0636\u062D\u064A';
  38154. t['\uFDAC'] = '\u0644\u062C\u064A';
  38155. t['\uFDAD'] = '\u0644\u0645\u064A';
  38156. t['\uFDAE'] = '\u064A\u062D\u064A';
  38157. t['\uFDAF'] = '\u064A\u062C\u064A';
  38158. t['\uFDB0'] = '\u064A\u0645\u064A';
  38159. t['\uFDB1'] = '\u0645\u0645\u064A';
  38160. t['\uFDB2'] = '\u0642\u0645\u064A';
  38161. t['\uFDB3'] = '\u0646\u062D\u064A';
  38162. t['\uFDB4'] = '\u0642\u0645\u062D';
  38163. t['\uFDB5'] = '\u0644\u062D\u0645';
  38164. t['\uFDB6'] = '\u0639\u0645\u064A';
  38165. t['\uFDB7'] = '\u0643\u0645\u064A';
  38166. t['\uFDB8'] = '\u0646\u062C\u062D';
  38167. t['\uFDB9'] = '\u0645\u062E\u064A';
  38168. t['\uFDBA'] = '\u0644\u062C\u0645';
  38169. t['\uFDBB'] = '\u0643\u0645\u0645';
  38170. t['\uFDBC'] = '\u0644\u062C\u0645';
  38171. t['\uFDBD'] = '\u0646\u062C\u062D';
  38172. t['\uFDBE'] = '\u062C\u062D\u064A';
  38173. t['\uFDBF'] = '\u062D\u062C\u064A';
  38174. t['\uFDC0'] = '\u0645\u062C\u064A';
  38175. t['\uFDC1'] = '\u0641\u0645\u064A';
  38176. t['\uFDC2'] = '\u0628\u062D\u064A';
  38177. t['\uFDC3'] = '\u0643\u0645\u0645';
  38178. t['\uFDC4'] = '\u0639\u062C\u0645';
  38179. t['\uFDC5'] = '\u0635\u0645\u0645';
  38180. t['\uFDC6'] = '\u0633\u062E\u064A';
  38181. t['\uFDC7'] = '\u0646\u062C\u064A';
  38182. t['\uFE49'] = '\u203E';
  38183. t['\uFE4A'] = '\u203E';
  38184. t['\uFE4B'] = '\u203E';
  38185. t['\uFE4C'] = '\u203E';
  38186. t['\uFE4D'] = '\u005F';
  38187. t['\uFE4E'] = '\u005F';
  38188. t['\uFE4F'] = '\u005F';
  38189. t['\uFE80'] = '\u0621';
  38190. t['\uFE81'] = '\u0622';
  38191. t['\uFE82'] = '\u0622';
  38192. t['\uFE83'] = '\u0623';
  38193. t['\uFE84'] = '\u0623';
  38194. t['\uFE85'] = '\u0624';
  38195. t['\uFE86'] = '\u0624';
  38196. t['\uFE87'] = '\u0625';
  38197. t['\uFE88'] = '\u0625';
  38198. t['\uFE89'] = '\u0626';
  38199. t['\uFE8A'] = '\u0626';
  38200. t['\uFE8B'] = '\u0626';
  38201. t['\uFE8C'] = '\u0626';
  38202. t['\uFE8D'] = '\u0627';
  38203. t['\uFE8E'] = '\u0627';
  38204. t['\uFE8F'] = '\u0628';
  38205. t['\uFE90'] = '\u0628';
  38206. t['\uFE91'] = '\u0628';
  38207. t['\uFE92'] = '\u0628';
  38208. t['\uFE93'] = '\u0629';
  38209. t['\uFE94'] = '\u0629';
  38210. t['\uFE95'] = '\u062A';
  38211. t['\uFE96'] = '\u062A';
  38212. t['\uFE97'] = '\u062A';
  38213. t['\uFE98'] = '\u062A';
  38214. t['\uFE99'] = '\u062B';
  38215. t['\uFE9A'] = '\u062B';
  38216. t['\uFE9B'] = '\u062B';
  38217. t['\uFE9C'] = '\u062B';
  38218. t['\uFE9D'] = '\u062C';
  38219. t['\uFE9E'] = '\u062C';
  38220. t['\uFE9F'] = '\u062C';
  38221. t['\uFEA0'] = '\u062C';
  38222. t['\uFEA1'] = '\u062D';
  38223. t['\uFEA2'] = '\u062D';
  38224. t['\uFEA3'] = '\u062D';
  38225. t['\uFEA4'] = '\u062D';
  38226. t['\uFEA5'] = '\u062E';
  38227. t['\uFEA6'] = '\u062E';
  38228. t['\uFEA7'] = '\u062E';
  38229. t['\uFEA8'] = '\u062E';
  38230. t['\uFEA9'] = '\u062F';
  38231. t['\uFEAA'] = '\u062F';
  38232. t['\uFEAB'] = '\u0630';
  38233. t['\uFEAC'] = '\u0630';
  38234. t['\uFEAD'] = '\u0631';
  38235. t['\uFEAE'] = '\u0631';
  38236. t['\uFEAF'] = '\u0632';
  38237. t['\uFEB0'] = '\u0632';
  38238. t['\uFEB1'] = '\u0633';
  38239. t['\uFEB2'] = '\u0633';
  38240. t['\uFEB3'] = '\u0633';
  38241. t['\uFEB4'] = '\u0633';
  38242. t['\uFEB5'] = '\u0634';
  38243. t['\uFEB6'] = '\u0634';
  38244. t['\uFEB7'] = '\u0634';
  38245. t['\uFEB8'] = '\u0634';
  38246. t['\uFEB9'] = '\u0635';
  38247. t['\uFEBA'] = '\u0635';
  38248. t['\uFEBB'] = '\u0635';
  38249. t['\uFEBC'] = '\u0635';
  38250. t['\uFEBD'] = '\u0636';
  38251. t['\uFEBE'] = '\u0636';
  38252. t['\uFEBF'] = '\u0636';
  38253. t['\uFEC0'] = '\u0636';
  38254. t['\uFEC1'] = '\u0637';
  38255. t['\uFEC2'] = '\u0637';
  38256. t['\uFEC3'] = '\u0637';
  38257. t['\uFEC4'] = '\u0637';
  38258. t['\uFEC5'] = '\u0638';
  38259. t['\uFEC6'] = '\u0638';
  38260. t['\uFEC7'] = '\u0638';
  38261. t['\uFEC8'] = '\u0638';
  38262. t['\uFEC9'] = '\u0639';
  38263. t['\uFECA'] = '\u0639';
  38264. t['\uFECB'] = '\u0639';
  38265. t['\uFECC'] = '\u0639';
  38266. t['\uFECD'] = '\u063A';
  38267. t['\uFECE'] = '\u063A';
  38268. t['\uFECF'] = '\u063A';
  38269. t['\uFED0'] = '\u063A';
  38270. t['\uFED1'] = '\u0641';
  38271. t['\uFED2'] = '\u0641';
  38272. t['\uFED3'] = '\u0641';
  38273. t['\uFED4'] = '\u0641';
  38274. t['\uFED5'] = '\u0642';
  38275. t['\uFED6'] = '\u0642';
  38276. t['\uFED7'] = '\u0642';
  38277. t['\uFED8'] = '\u0642';
  38278. t['\uFED9'] = '\u0643';
  38279. t['\uFEDA'] = '\u0643';
  38280. t['\uFEDB'] = '\u0643';
  38281. t['\uFEDC'] = '\u0643';
  38282. t['\uFEDD'] = '\u0644';
  38283. t['\uFEDE'] = '\u0644';
  38284. t['\uFEDF'] = '\u0644';
  38285. t['\uFEE0'] = '\u0644';
  38286. t['\uFEE1'] = '\u0645';
  38287. t['\uFEE2'] = '\u0645';
  38288. t['\uFEE3'] = '\u0645';
  38289. t['\uFEE4'] = '\u0645';
  38290. t['\uFEE5'] = '\u0646';
  38291. t['\uFEE6'] = '\u0646';
  38292. t['\uFEE7'] = '\u0646';
  38293. t['\uFEE8'] = '\u0646';
  38294. t['\uFEE9'] = '\u0647';
  38295. t['\uFEEA'] = '\u0647';
  38296. t['\uFEEB'] = '\u0647';
  38297. t['\uFEEC'] = '\u0647';
  38298. t['\uFEED'] = '\u0648';
  38299. t['\uFEEE'] = '\u0648';
  38300. t['\uFEEF'] = '\u0649';
  38301. t['\uFEF0'] = '\u0649';
  38302. t['\uFEF1'] = '\u064A';
  38303. t['\uFEF2'] = '\u064A';
  38304. t['\uFEF3'] = '\u064A';
  38305. t['\uFEF4'] = '\u064A';
  38306. t['\uFEF5'] = '\u0644\u0622';
  38307. t['\uFEF6'] = '\u0644\u0622';
  38308. t['\uFEF7'] = '\u0644\u0623';
  38309. t['\uFEF8'] = '\u0644\u0623';
  38310. t['\uFEF9'] = '\u0644\u0625';
  38311. t['\uFEFA'] = '\u0644\u0625';
  38312. t['\uFEFB'] = '\u0644\u0627';
  38313. t['\uFEFC'] = '\u0644\u0627';
  38314. });
  38315. function reverseIfRtl(chars) {
  38316. var charsLength = chars.length;
  38317. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38318. return chars;
  38319. }
  38320. var s = '';
  38321. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38322. s += chars[ii];
  38323. }
  38324. return s;
  38325. }
  38326. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38327. exports.reverseIfRtl = reverseIfRtl;
  38328. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38329. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38330. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38331. /***/ }),
  38332. /* 22 */
  38333. /***/ (function(module, exports, __w_pdfjs_require__) {
  38334. "use strict";
  38335. var sharedUtil = __w_pdfjs_require__(0);
  38336. var corePrimitives = __w_pdfjs_require__(1);
  38337. var corePdfManager = __w_pdfjs_require__(41);
  38338. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38339. var InvalidPDFException = sharedUtil.InvalidPDFException;
  38340. var MessageHandler = sharedUtil.MessageHandler;
  38341. var MissingPDFException = sharedUtil.MissingPDFException;
  38342. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38343. var PasswordException = sharedUtil.PasswordException;
  38344. var UnknownErrorException = sharedUtil.UnknownErrorException;
  38345. var XRefParseException = sharedUtil.XRefParseException;
  38346. var arrayByteLength = sharedUtil.arrayByteLength;
  38347. var arraysToBytes = sharedUtil.arraysToBytes;
  38348. var assert = sharedUtil.assert;
  38349. var createPromiseCapability = sharedUtil.createPromiseCapability;
  38350. var error = sharedUtil.error;
  38351. var info = sharedUtil.info;
  38352. var warn = sharedUtil.warn;
  38353. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  38354. var Ref = corePrimitives.Ref;
  38355. var LocalPdfManager = corePdfManager.LocalPdfManager;
  38356. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  38357. var globalScope = sharedUtil.globalScope;
  38358. var WorkerTask = function WorkerTaskClosure() {
  38359. function WorkerTask(name) {
  38360. this.name = name;
  38361. this.terminated = false;
  38362. this._capability = createPromiseCapability();
  38363. }
  38364. WorkerTask.prototype = {
  38365. get finished() {
  38366. return this._capability.promise;
  38367. },
  38368. finish: function () {
  38369. this._capability.resolve();
  38370. },
  38371. terminate: function () {
  38372. this.terminated = true;
  38373. },
  38374. ensureNotTerminated: function () {
  38375. if (this.terminated) {
  38376. throw new Error('Worker task was terminated');
  38377. }
  38378. }
  38379. };
  38380. return WorkerTask;
  38381. }();
  38382. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  38383. function PDFWorkerStream(params, msgHandler) {
  38384. this._queuedChunks = [];
  38385. var initialData = params.initialData;
  38386. if (initialData && initialData.length > 0) {
  38387. this._queuedChunks.push(initialData);
  38388. }
  38389. this._msgHandler = msgHandler;
  38390. this._isRangeSupported = !params.disableRange;
  38391. this._isStreamingSupported = !params.disableStream;
  38392. this._contentLength = params.length;
  38393. this._fullRequestReader = null;
  38394. this._rangeReaders = [];
  38395. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  38396. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  38397. }
  38398. PDFWorkerStream.prototype = {
  38399. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  38400. if (args.begin === undefined) {
  38401. if (this._fullRequestReader) {
  38402. this._fullRequestReader._enqueue(args.chunk);
  38403. } else {
  38404. this._queuedChunks.push(args.chunk);
  38405. }
  38406. } else {
  38407. var found = this._rangeReaders.some(function (rangeReader) {
  38408. if (rangeReader._begin !== args.begin) {
  38409. return false;
  38410. }
  38411. rangeReader._enqueue(args.chunk);
  38412. return true;
  38413. });
  38414. assert(found);
  38415. }
  38416. },
  38417. _onProgress: function PDFWorkerStream_onProgress(evt) {
  38418. if (this._rangeReaders.length > 0) {
  38419. var firstReader = this._rangeReaders[0];
  38420. if (firstReader.onProgress) {
  38421. firstReader.onProgress({ loaded: evt.loaded });
  38422. }
  38423. }
  38424. },
  38425. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  38426. var i = this._rangeReaders.indexOf(reader);
  38427. if (i >= 0) {
  38428. this._rangeReaders.splice(i, 1);
  38429. }
  38430. },
  38431. getFullReader: function PDFWorkerStream_getFullReader() {
  38432. assert(!this._fullRequestReader);
  38433. var queuedChunks = this._queuedChunks;
  38434. this._queuedChunks = null;
  38435. return new PDFWorkerStreamReader(this, queuedChunks);
  38436. },
  38437. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  38438. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  38439. this._msgHandler.send('RequestDataRange', {
  38440. begin: begin,
  38441. end: end
  38442. });
  38443. this._rangeReaders.push(reader);
  38444. return reader;
  38445. },
  38446. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  38447. if (this._fullRequestReader) {
  38448. this._fullRequestReader.cancel(reason);
  38449. }
  38450. var readers = this._rangeReaders.slice(0);
  38451. readers.forEach(function (rangeReader) {
  38452. rangeReader.cancel(reason);
  38453. });
  38454. }
  38455. };
  38456. function PDFWorkerStreamReader(stream, queuedChunks) {
  38457. this._stream = stream;
  38458. this._done = false;
  38459. this._queuedChunks = queuedChunks || [];
  38460. this._requests = [];
  38461. this._headersReady = Promise.resolve();
  38462. stream._fullRequestReader = this;
  38463. this.onProgress = null;
  38464. }
  38465. PDFWorkerStreamReader.prototype = {
  38466. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  38467. if (this._done) {
  38468. return;
  38469. }
  38470. if (this._requests.length > 0) {
  38471. var requestCapability = this._requests.shift();
  38472. requestCapability.resolve({
  38473. value: chunk,
  38474. done: false
  38475. });
  38476. return;
  38477. }
  38478. this._queuedChunks.push(chunk);
  38479. },
  38480. get headersReady() {
  38481. return this._headersReady;
  38482. },
  38483. get isRangeSupported() {
  38484. return this._stream._isRangeSupported;
  38485. },
  38486. get isStreamingSupported() {
  38487. return this._stream._isStreamingSupported;
  38488. },
  38489. get contentLength() {
  38490. return this._stream._contentLength;
  38491. },
  38492. read: function PDFWorkerStreamReader_read() {
  38493. if (this._queuedChunks.length > 0) {
  38494. var chunk = this._queuedChunks.shift();
  38495. return Promise.resolve({
  38496. value: chunk,
  38497. done: false
  38498. });
  38499. }
  38500. if (this._done) {
  38501. return Promise.resolve({
  38502. value: undefined,
  38503. done: true
  38504. });
  38505. }
  38506. var requestCapability = createPromiseCapability();
  38507. this._requests.push(requestCapability);
  38508. return requestCapability.promise;
  38509. },
  38510. cancel: function PDFWorkerStreamReader_cancel(reason) {
  38511. this._done = true;
  38512. this._requests.forEach(function (requestCapability) {
  38513. requestCapability.resolve({
  38514. value: undefined,
  38515. done: true
  38516. });
  38517. });
  38518. this._requests = [];
  38519. }
  38520. };
  38521. function PDFWorkerStreamRangeReader(stream, begin, end) {
  38522. this._stream = stream;
  38523. this._begin = begin;
  38524. this._end = end;
  38525. this._queuedChunk = null;
  38526. this._requests = [];
  38527. this._done = false;
  38528. this.onProgress = null;
  38529. }
  38530. PDFWorkerStreamRangeReader.prototype = {
  38531. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  38532. if (this._done) {
  38533. return;
  38534. }
  38535. if (this._requests.length === 0) {
  38536. this._queuedChunk = chunk;
  38537. } else {
  38538. var requestsCapability = this._requests.shift();
  38539. requestsCapability.resolve({
  38540. value: chunk,
  38541. done: false
  38542. });
  38543. this._requests.forEach(function (requestCapability) {
  38544. requestCapability.resolve({
  38545. value: undefined,
  38546. done: true
  38547. });
  38548. });
  38549. this._requests = [];
  38550. }
  38551. this._done = true;
  38552. this._stream._removeRangeReader(this);
  38553. },
  38554. get isStreamingSupported() {
  38555. return false;
  38556. },
  38557. read: function PDFWorkerStreamRangeReader_read() {
  38558. if (this._queuedChunk) {
  38559. return Promise.resolve({
  38560. value: this._queuedChunk,
  38561. done: false
  38562. });
  38563. }
  38564. if (this._done) {
  38565. return Promise.resolve({
  38566. value: undefined,
  38567. done: true
  38568. });
  38569. }
  38570. var requestCapability = createPromiseCapability();
  38571. this._requests.push(requestCapability);
  38572. return requestCapability.promise;
  38573. },
  38574. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  38575. this._done = true;
  38576. this._requests.forEach(function (requestCapability) {
  38577. requestCapability.resolve({
  38578. value: undefined,
  38579. done: true
  38580. });
  38581. });
  38582. this._requests = [];
  38583. this._stream._removeRangeReader(this);
  38584. }
  38585. };
  38586. return PDFWorkerStream;
  38587. }();
  38588. var PDFNetworkStream;
  38589. function setPDFNetworkStreamClass(cls) {
  38590. PDFNetworkStream = cls;
  38591. }
  38592. var WorkerMessageHandler = {
  38593. setup: function wphSetup(handler, port) {
  38594. var testMessageProcessed = false;
  38595. handler.on('test', function wphSetupTest(data) {
  38596. if (testMessageProcessed) {
  38597. return;
  38598. }
  38599. testMessageProcessed = true;
  38600. if (!(data instanceof Uint8Array)) {
  38601. handler.send('test', 'main', false);
  38602. return;
  38603. }
  38604. var supportTransfers = data[0] === 255;
  38605. handler.postMessageTransfers = supportTransfers;
  38606. var xhr = new XMLHttpRequest();
  38607. var responseExists = 'response' in xhr;
  38608. try {
  38609. xhr.responseType;
  38610. } catch (e) {
  38611. responseExists = false;
  38612. }
  38613. if (!responseExists) {
  38614. handler.send('test', false);
  38615. return;
  38616. }
  38617. handler.send('test', {
  38618. supportTypedArray: true,
  38619. supportTransfers: supportTransfers
  38620. });
  38621. });
  38622. handler.on('configure', function wphConfigure(data) {
  38623. setVerbosityLevel(data.verbosity);
  38624. });
  38625. handler.on('GetDocRequest', function wphSetupDoc(data) {
  38626. return WorkerMessageHandler.createDocumentHandler(data, port);
  38627. });
  38628. },
  38629. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  38630. var pdfManager;
  38631. var terminated = false;
  38632. var cancelXHRs = null;
  38633. var WorkerTasks = [];
  38634. var docId = docParams.docId;
  38635. var docBaseUrl = docParams.docBaseUrl;
  38636. var workerHandlerName = docParams.docId + '_worker';
  38637. var handler = new MessageHandler(workerHandlerName, docId, port);
  38638. handler.postMessageTransfers = docParams.postMessageTransfers;
  38639. function ensureNotTerminated() {
  38640. if (terminated) {
  38641. throw new Error('Worker was terminated');
  38642. }
  38643. }
  38644. function startWorkerTask(task) {
  38645. WorkerTasks.push(task);
  38646. }
  38647. function finishWorkerTask(task) {
  38648. task.finish();
  38649. var i = WorkerTasks.indexOf(task);
  38650. WorkerTasks.splice(i, 1);
  38651. }
  38652. function loadDocument(recoveryMode) {
  38653. var loadDocumentCapability = createPromiseCapability();
  38654. var parseSuccess = function parseSuccess() {
  38655. var numPagesPromise = pdfManager.ensureDoc('numPages');
  38656. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  38657. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  38658. Promise.all([
  38659. numPagesPromise,
  38660. fingerprintPromise,
  38661. encryptedPromise
  38662. ]).then(function onDocReady(results) {
  38663. var doc = {
  38664. numPages: results[0],
  38665. fingerprint: results[1],
  38666. encrypted: !!results[2]
  38667. };
  38668. loadDocumentCapability.resolve(doc);
  38669. }, parseFailure);
  38670. };
  38671. var parseFailure = function parseFailure(e) {
  38672. loadDocumentCapability.reject(e);
  38673. };
  38674. pdfManager.ensureDoc('checkHeader', []).then(function () {
  38675. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  38676. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  38677. }, parseFailure);
  38678. }, parseFailure);
  38679. return loadDocumentCapability.promise;
  38680. }
  38681. function getPdfManager(data, evaluatorOptions) {
  38682. var pdfManagerCapability = createPromiseCapability();
  38683. var pdfManager;
  38684. var source = data.source;
  38685. if (source.data) {
  38686. try {
  38687. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  38688. pdfManagerCapability.resolve(pdfManager);
  38689. } catch (ex) {
  38690. pdfManagerCapability.reject(ex);
  38691. }
  38692. return pdfManagerCapability.promise;
  38693. }
  38694. var pdfStream;
  38695. try {
  38696. if (source.chunkedViewerLoading) {
  38697. pdfStream = new PDFWorkerStream(source, handler);
  38698. } else {
  38699. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  38700. pdfStream = new PDFNetworkStream(data);
  38701. }
  38702. } catch (ex) {
  38703. pdfManagerCapability.reject(ex);
  38704. return pdfManagerCapability.promise;
  38705. }
  38706. var fullRequest = pdfStream.getFullReader();
  38707. fullRequest.headersReady.then(function () {
  38708. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  38709. fullRequest.onProgress = function (evt) {
  38710. handler.send('DocProgress', {
  38711. loaded: evt.loaded,
  38712. total: evt.total
  38713. });
  38714. };
  38715. }
  38716. if (!fullRequest.isRangeSupported) {
  38717. return;
  38718. }
  38719. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  38720. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  38721. msgHandler: handler,
  38722. url: source.url,
  38723. password: source.password,
  38724. length: fullRequest.contentLength,
  38725. disableAutoFetch: disableAutoFetch,
  38726. rangeChunkSize: source.rangeChunkSize
  38727. }, evaluatorOptions, docBaseUrl);
  38728. pdfManagerCapability.resolve(pdfManager);
  38729. cancelXHRs = null;
  38730. }).catch(function (reason) {
  38731. pdfManagerCapability.reject(reason);
  38732. cancelXHRs = null;
  38733. });
  38734. var cachedChunks = [], loaded = 0;
  38735. var flushChunks = function () {
  38736. var pdfFile = arraysToBytes(cachedChunks);
  38737. if (source.length && pdfFile.length !== source.length) {
  38738. warn('reported HTTP length is different from actual');
  38739. }
  38740. try {
  38741. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  38742. pdfManagerCapability.resolve(pdfManager);
  38743. } catch (ex) {
  38744. pdfManagerCapability.reject(ex);
  38745. }
  38746. cachedChunks = [];
  38747. };
  38748. var readPromise = new Promise(function (resolve, reject) {
  38749. var readChunk = function (chunk) {
  38750. try {
  38751. ensureNotTerminated();
  38752. if (chunk.done) {
  38753. if (!pdfManager) {
  38754. flushChunks();
  38755. }
  38756. cancelXHRs = null;
  38757. return;
  38758. }
  38759. var data = chunk.value;
  38760. loaded += arrayByteLength(data);
  38761. if (!fullRequest.isStreamingSupported) {
  38762. handler.send('DocProgress', {
  38763. loaded: loaded,
  38764. total: Math.max(loaded, fullRequest.contentLength || 0)
  38765. });
  38766. }
  38767. if (pdfManager) {
  38768. pdfManager.sendProgressiveData(data);
  38769. } else {
  38770. cachedChunks.push(data);
  38771. }
  38772. fullRequest.read().then(readChunk, reject);
  38773. } catch (e) {
  38774. reject(e);
  38775. }
  38776. };
  38777. fullRequest.read().then(readChunk, reject);
  38778. });
  38779. readPromise.catch(function (e) {
  38780. pdfManagerCapability.reject(e);
  38781. cancelXHRs = null;
  38782. });
  38783. cancelXHRs = function () {
  38784. pdfStream.cancelAllRequests('abort');
  38785. };
  38786. return pdfManagerCapability.promise;
  38787. }
  38788. function setupDoc(data) {
  38789. function onSuccess(doc) {
  38790. ensureNotTerminated();
  38791. handler.send('GetDoc', { pdfInfo: doc });
  38792. }
  38793. function onFailure(e) {
  38794. if (e instanceof PasswordException) {
  38795. var task = new WorkerTask('PasswordException: response ' + e.code);
  38796. startWorkerTask(task);
  38797. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38798. finishWorkerTask(task);
  38799. pdfManager.updatePassword(data.password);
  38800. pdfManagerReady();
  38801. }).catch(function (ex) {
  38802. finishWorkerTask(task);
  38803. handler.send('PasswordException', ex);
  38804. }.bind(null, e));
  38805. } else if (e instanceof InvalidPDFException) {
  38806. handler.send('InvalidPDF', e);
  38807. } else if (e instanceof MissingPDFException) {
  38808. handler.send('MissingPDF', e);
  38809. } else if (e instanceof UnexpectedResponseException) {
  38810. handler.send('UnexpectedResponse', e);
  38811. } else {
  38812. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38813. }
  38814. }
  38815. function pdfManagerReady() {
  38816. ensureNotTerminated();
  38817. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38818. ensureNotTerminated();
  38819. if (!(ex instanceof XRefParseException)) {
  38820. onFailure(ex);
  38821. return;
  38822. }
  38823. pdfManager.requestLoadedStream();
  38824. pdfManager.onLoadedStream().then(function () {
  38825. ensureNotTerminated();
  38826. loadDocument(true).then(onSuccess, onFailure);
  38827. });
  38828. }, onFailure);
  38829. }
  38830. ensureNotTerminated();
  38831. var evaluatorOptions = {
  38832. forceDataSchema: data.disableCreateObjectURL,
  38833. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38834. disableFontFace: data.disableFontFace,
  38835. disableNativeImageDecoder: data.disableNativeImageDecoder
  38836. };
  38837. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38838. if (terminated) {
  38839. newPdfManager.terminate();
  38840. throw new Error('Worker was terminated');
  38841. }
  38842. pdfManager = newPdfManager;
  38843. handler.send('PDFManagerReady', null);
  38844. pdfManager.onLoadedStream().then(function (stream) {
  38845. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38846. });
  38847. }).then(pdfManagerReady, onFailure);
  38848. }
  38849. handler.on('GetPage', function wphSetupGetPage(data) {
  38850. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38851. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38852. var refPromise = pdfManager.ensure(page, 'ref');
  38853. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38854. var viewPromise = pdfManager.ensure(page, 'view');
  38855. return Promise.all([
  38856. rotatePromise,
  38857. refPromise,
  38858. userUnitPromise,
  38859. viewPromise
  38860. ]).then(function (results) {
  38861. return {
  38862. rotate: results[0],
  38863. ref: results[1],
  38864. userUnit: results[2],
  38865. view: results[3]
  38866. };
  38867. });
  38868. });
  38869. });
  38870. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38871. var ref = new Ref(data.ref.num, data.ref.gen);
  38872. var catalog = pdfManager.pdfDocument.catalog;
  38873. return catalog.getPageIndex(ref);
  38874. });
  38875. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38876. return pdfManager.ensureCatalog('destinations');
  38877. });
  38878. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38879. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38880. });
  38881. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38882. return pdfManager.ensureCatalog('pageLabels');
  38883. });
  38884. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38885. return pdfManager.ensureCatalog('attachments');
  38886. });
  38887. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38888. return pdfManager.ensureCatalog('javaScript');
  38889. });
  38890. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38891. return pdfManager.ensureCatalog('documentOutline');
  38892. });
  38893. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38894. return Promise.all([
  38895. pdfManager.ensureDoc('documentInfo'),
  38896. pdfManager.ensureCatalog('metadata')
  38897. ]);
  38898. });
  38899. handler.on('GetData', function wphSetupGetData(data) {
  38900. pdfManager.requestLoadedStream();
  38901. return pdfManager.onLoadedStream().then(function (stream) {
  38902. return stream.bytes;
  38903. });
  38904. });
  38905. handler.on('GetStats', function wphSetupGetStats(data) {
  38906. return pdfManager.pdfDocument.xref.stats;
  38907. });
  38908. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38909. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38910. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38911. });
  38912. });
  38913. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38914. var pageIndex = data.pageIndex;
  38915. pdfManager.getPage(pageIndex).then(function (page) {
  38916. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38917. startWorkerTask(task);
  38918. var pageNum = pageIndex + 1;
  38919. var start = Date.now();
  38920. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38921. finishWorkerTask(task);
  38922. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38923. }, function (e) {
  38924. finishWorkerTask(task);
  38925. if (task.terminated) {
  38926. return;
  38927. }
  38928. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38929. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38930. var wrappedException;
  38931. if (typeof e === 'string') {
  38932. wrappedException = {
  38933. message: e,
  38934. stack: minimumStackMessage
  38935. };
  38936. } else if (typeof e === 'object') {
  38937. wrappedException = {
  38938. message: e.message || e.toString(),
  38939. stack: e.stack || minimumStackMessage
  38940. };
  38941. } else {
  38942. wrappedException = {
  38943. message: 'Unknown exception type: ' + typeof e,
  38944. stack: minimumStackMessage
  38945. };
  38946. }
  38947. handler.send('PageError', {
  38948. pageNum: pageNum,
  38949. error: wrappedException,
  38950. intent: data.intent
  38951. });
  38952. });
  38953. });
  38954. }, this);
  38955. handler.on('GetTextContent', function wphExtractText(data) {
  38956. var pageIndex = data.pageIndex;
  38957. var normalizeWhitespace = data.normalizeWhitespace;
  38958. var combineTextItems = data.combineTextItems;
  38959. return pdfManager.getPage(pageIndex).then(function (page) {
  38960. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38961. startWorkerTask(task);
  38962. var pageNum = pageIndex + 1;
  38963. var start = Date.now();
  38964. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38965. finishWorkerTask(task);
  38966. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38967. return textContent;
  38968. }, function (reason) {
  38969. finishWorkerTask(task);
  38970. if (task.terminated) {
  38971. return;
  38972. }
  38973. throw reason;
  38974. });
  38975. });
  38976. });
  38977. handler.on('Cleanup', function wphCleanup(data) {
  38978. return pdfManager.cleanup();
  38979. });
  38980. handler.on('Terminate', function wphTerminate(data) {
  38981. terminated = true;
  38982. if (pdfManager) {
  38983. pdfManager.terminate();
  38984. pdfManager = null;
  38985. }
  38986. if (cancelXHRs) {
  38987. cancelXHRs();
  38988. }
  38989. var waitOn = [];
  38990. WorkerTasks.forEach(function (task) {
  38991. waitOn.push(task.finished);
  38992. task.terminate();
  38993. });
  38994. return Promise.all(waitOn).then(function () {
  38995. handler.destroy();
  38996. handler = null;
  38997. });
  38998. });
  38999. handler.on('Ready', function wphReady(data) {
  39000. setupDoc(docParams);
  39001. docParams = null;
  39002. });
  39003. return workerHandlerName;
  39004. }
  39005. };
  39006. function initializeWorker() {
  39007. if (!('console' in globalScope)) {
  39008. var consoleTimer = {};
  39009. var workerConsole = {
  39010. log: function log() {
  39011. var args = Array.prototype.slice.call(arguments);
  39012. globalScope.postMessage({
  39013. targetName: 'main',
  39014. action: 'console_log',
  39015. data: args
  39016. });
  39017. },
  39018. error: function error() {
  39019. var args = Array.prototype.slice.call(arguments);
  39020. globalScope.postMessage({
  39021. targetName: 'main',
  39022. action: 'console_error',
  39023. data: args
  39024. });
  39025. throw 'pdf.js execution error';
  39026. },
  39027. time: function time(name) {
  39028. consoleTimer[name] = Date.now();
  39029. },
  39030. timeEnd: function timeEnd(name) {
  39031. var time = consoleTimer[name];
  39032. if (!time) {
  39033. error('Unknown timer name ' + name);
  39034. }
  39035. this.log('Timer:', name, Date.now() - time);
  39036. }
  39037. };
  39038. globalScope.console = workerConsole;
  39039. }
  39040. var handler = new MessageHandler('worker', 'main', self);
  39041. WorkerMessageHandler.setup(handler, self);
  39042. handler.send('ready', null);
  39043. }
  39044. function isNodeJS() {
  39045. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  39046. return typeof process === 'object' && process + '' === '[object process]';
  39047. }
  39048. return false;
  39049. }
  39050. if (typeof window === 'undefined' && !isNodeJS()) {
  39051. initializeWorker();
  39052. }
  39053. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  39054. exports.WorkerTask = WorkerTask;
  39055. exports.WorkerMessageHandler = WorkerMessageHandler;
  39056. /***/ }),
  39057. /* 23 */
  39058. /***/ (function(module, exports, __w_pdfjs_require__) {
  39059. "use strict";
  39060. var sharedUtil = __w_pdfjs_require__(0);
  39061. var error = sharedUtil.error;
  39062. function fixMetadata(meta) {
  39063. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  39064. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  39065. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  39066. });
  39067. var chars = '';
  39068. for (var i = 0; i < bytes.length; i += 2) {
  39069. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  39070. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  39071. }
  39072. return '>' + chars;
  39073. });
  39074. }
  39075. function Metadata(meta) {
  39076. if (typeof meta === 'string') {
  39077. meta = fixMetadata(meta);
  39078. var parser = new DOMParser();
  39079. meta = parser.parseFromString(meta, 'application/xml');
  39080. } else if (!(meta instanceof Document)) {
  39081. error('Metadata: Invalid metadata object');
  39082. }
  39083. this.metaDocument = meta;
  39084. this.metadata = Object.create(null);
  39085. this.parse();
  39086. }
  39087. Metadata.prototype = {
  39088. parse: function Metadata_parse() {
  39089. var doc = this.metaDocument;
  39090. var rdf = doc.documentElement;
  39091. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39092. rdf = rdf.firstChild;
  39093. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39094. rdf = rdf.nextSibling;
  39095. }
  39096. }
  39097. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39098. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39099. return;
  39100. }
  39101. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39102. for (i = 0, length = children.length; i < length; i++) {
  39103. desc = children[i];
  39104. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39105. continue;
  39106. }
  39107. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39108. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39109. entry = desc.childNodes[ii];
  39110. name = entry.nodeName.toLowerCase();
  39111. this.metadata[name] = entry.textContent.trim();
  39112. }
  39113. }
  39114. }
  39115. },
  39116. get: function Metadata_get(name) {
  39117. return this.metadata[name] || null;
  39118. },
  39119. has: function Metadata_has(name) {
  39120. return typeof this.metadata[name] !== 'undefined';
  39121. }
  39122. };
  39123. exports.Metadata = Metadata;
  39124. /***/ }),
  39125. /* 24 */
  39126. /***/ (function(module, exports, __w_pdfjs_require__) {
  39127. "use strict";
  39128. var sharedUtil = __w_pdfjs_require__(0);
  39129. var displayDOMUtils = __w_pdfjs_require__(3);
  39130. var shadow = sharedUtil.shadow;
  39131. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39132. var WebGLUtils = function WebGLUtilsClosure() {
  39133. function loadShader(gl, code, shaderType) {
  39134. var shader = gl.createShader(shaderType);
  39135. gl.shaderSource(shader, code);
  39136. gl.compileShader(shader);
  39137. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39138. if (!compiled) {
  39139. var errorMsg = gl.getShaderInfoLog(shader);
  39140. throw new Error('Error during shader compilation: ' + errorMsg);
  39141. }
  39142. return shader;
  39143. }
  39144. function createVertexShader(gl, code) {
  39145. return loadShader(gl, code, gl.VERTEX_SHADER);
  39146. }
  39147. function createFragmentShader(gl, code) {
  39148. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39149. }
  39150. function createProgram(gl, shaders) {
  39151. var program = gl.createProgram();
  39152. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39153. gl.attachShader(program, shaders[i]);
  39154. }
  39155. gl.linkProgram(program);
  39156. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39157. if (!linked) {
  39158. var errorMsg = gl.getProgramInfoLog(program);
  39159. throw new Error('Error during program linking: ' + errorMsg);
  39160. }
  39161. return program;
  39162. }
  39163. function createTexture(gl, image, textureId) {
  39164. gl.activeTexture(textureId);
  39165. var texture = gl.createTexture();
  39166. gl.bindTexture(gl.TEXTURE_2D, texture);
  39167. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39168. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39169. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39170. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39171. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39172. return texture;
  39173. }
  39174. var currentGL, currentCanvas;
  39175. function generateGL() {
  39176. if (currentGL) {
  39177. return;
  39178. }
  39179. currentCanvas = document.createElement('canvas');
  39180. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39181. }
  39182. var smaskVertexShaderCode = '\
  39183. attribute vec2 a_position; \
  39184. attribute vec2 a_texCoord; \
  39185. \
  39186. uniform vec2 u_resolution; \
  39187. \
  39188. varying vec2 v_texCoord; \
  39189. \
  39190. void main() { \
  39191. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39192. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39193. \
  39194. v_texCoord = a_texCoord; \
  39195. } ';
  39196. var smaskFragmentShaderCode = '\
  39197. precision mediump float; \
  39198. \
  39199. uniform vec4 u_backdrop; \
  39200. uniform int u_subtype; \
  39201. uniform sampler2D u_image; \
  39202. uniform sampler2D u_mask; \
  39203. \
  39204. varying vec2 v_texCoord; \
  39205. \
  39206. void main() { \
  39207. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39208. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39209. if (u_backdrop.a > 0.0) { \
  39210. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39211. u_backdrop.rgb * (1.0 - maskColor.a); \
  39212. } \
  39213. float lum; \
  39214. if (u_subtype == 0) { \
  39215. lum = maskColor.a; \
  39216. } else { \
  39217. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39218. maskColor.b * 0.11; \
  39219. } \
  39220. imageColor.a *= lum; \
  39221. imageColor.rgb *= imageColor.a; \
  39222. gl_FragColor = imageColor; \
  39223. } ';
  39224. var smaskCache = null;
  39225. function initSmaskGL() {
  39226. var canvas, gl;
  39227. generateGL();
  39228. canvas = currentCanvas;
  39229. currentCanvas = null;
  39230. gl = currentGL;
  39231. currentGL = null;
  39232. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39233. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39234. var program = createProgram(gl, [
  39235. vertexShader,
  39236. fragmentShader
  39237. ]);
  39238. gl.useProgram(program);
  39239. var cache = {};
  39240. cache.gl = gl;
  39241. cache.canvas = canvas;
  39242. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39243. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39244. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39245. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39246. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39247. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39248. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39249. var texCoordBuffer = gl.createBuffer();
  39250. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39251. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39252. 0.0,
  39253. 0.0,
  39254. 1.0,
  39255. 0.0,
  39256. 0.0,
  39257. 1.0,
  39258. 0.0,
  39259. 1.0,
  39260. 1.0,
  39261. 0.0,
  39262. 1.0,
  39263. 1.0
  39264. ]), gl.STATIC_DRAW);
  39265. gl.enableVertexAttribArray(texCoordLocation);
  39266. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39267. gl.uniform1i(texLayerLocation, 0);
  39268. gl.uniform1i(texMaskLocation, 1);
  39269. smaskCache = cache;
  39270. }
  39271. function composeSMask(layer, mask, properties) {
  39272. var width = layer.width, height = layer.height;
  39273. if (!smaskCache) {
  39274. initSmaskGL();
  39275. }
  39276. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39277. canvas.width = width;
  39278. canvas.height = height;
  39279. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39280. gl.uniform2f(cache.resolutionLocation, width, height);
  39281. if (properties.backdrop) {
  39282. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39283. } else {
  39284. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39285. }
  39286. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39287. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39288. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39289. var buffer = gl.createBuffer();
  39290. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39291. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39292. 0,
  39293. 0,
  39294. width,
  39295. 0,
  39296. 0,
  39297. height,
  39298. 0,
  39299. height,
  39300. width,
  39301. 0,
  39302. width,
  39303. height
  39304. ]), gl.STATIC_DRAW);
  39305. gl.enableVertexAttribArray(cache.positionLocation);
  39306. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39307. gl.clearColor(0, 0, 0, 0);
  39308. gl.enable(gl.BLEND);
  39309. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39310. gl.clear(gl.COLOR_BUFFER_BIT);
  39311. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39312. gl.flush();
  39313. gl.deleteTexture(texture);
  39314. gl.deleteTexture(maskTexture);
  39315. gl.deleteBuffer(buffer);
  39316. return canvas;
  39317. }
  39318. var figuresVertexShaderCode = '\
  39319. attribute vec2 a_position; \
  39320. attribute vec3 a_color; \
  39321. \
  39322. uniform vec2 u_resolution; \
  39323. uniform vec2 u_scale; \
  39324. uniform vec2 u_offset; \
  39325. \
  39326. varying vec4 v_color; \
  39327. \
  39328. void main() { \
  39329. vec2 position = (a_position + u_offset) * u_scale; \
  39330. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39331. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39332. \
  39333. v_color = vec4(a_color / 255.0, 1.0); \
  39334. } ';
  39335. var figuresFragmentShaderCode = '\
  39336. precision mediump float; \
  39337. \
  39338. varying vec4 v_color; \
  39339. \
  39340. void main() { \
  39341. gl_FragColor = v_color; \
  39342. } ';
  39343. var figuresCache = null;
  39344. function initFiguresGL() {
  39345. var canvas, gl;
  39346. generateGL();
  39347. canvas = currentCanvas;
  39348. currentCanvas = null;
  39349. gl = currentGL;
  39350. currentGL = null;
  39351. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39352. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39353. var program = createProgram(gl, [
  39354. vertexShader,
  39355. fragmentShader
  39356. ]);
  39357. gl.useProgram(program);
  39358. var cache = {};
  39359. cache.gl = gl;
  39360. cache.canvas = canvas;
  39361. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39362. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39363. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39364. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39365. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39366. figuresCache = cache;
  39367. }
  39368. function drawFigures(width, height, backgroundColor, figures, context) {
  39369. if (!figuresCache) {
  39370. initFiguresGL();
  39371. }
  39372. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39373. canvas.width = width;
  39374. canvas.height = height;
  39375. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39376. gl.uniform2f(cache.resolutionLocation, width, height);
  39377. var count = 0;
  39378. var i, ii, rows;
  39379. for (i = 0, ii = figures.length; i < ii; i++) {
  39380. switch (figures[i].type) {
  39381. case 'lattice':
  39382. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39383. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39384. break;
  39385. case 'triangles':
  39386. count += figures[i].coords.length;
  39387. break;
  39388. }
  39389. }
  39390. var coords = new Float32Array(count * 2);
  39391. var colors = new Uint8Array(count * 3);
  39392. var coordsMap = context.coords, colorsMap = context.colors;
  39393. var pIndex = 0, cIndex = 0;
  39394. for (i = 0, ii = figures.length; i < ii; i++) {
  39395. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39396. switch (figure.type) {
  39397. case 'lattice':
  39398. var cols = figure.verticesPerRow;
  39399. rows = ps.length / cols | 0;
  39400. for (var row = 1; row < rows; row++) {
  39401. var offset = row * cols + 1;
  39402. for (var col = 1; col < cols; col++, offset++) {
  39403. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39404. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39405. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39406. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39407. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39408. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39409. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39410. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39411. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39412. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39413. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39414. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39415. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39416. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39417. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39418. coords[pIndex + 6] = coords[pIndex + 2];
  39419. coords[pIndex + 7] = coords[pIndex + 3];
  39420. coords[pIndex + 8] = coords[pIndex + 4];
  39421. coords[pIndex + 9] = coords[pIndex + 5];
  39422. coords[pIndex + 10] = coordsMap[ps[offset]];
  39423. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39424. colors[cIndex + 9] = colors[cIndex + 3];
  39425. colors[cIndex + 10] = colors[cIndex + 4];
  39426. colors[cIndex + 11] = colors[cIndex + 5];
  39427. colors[cIndex + 12] = colors[cIndex + 6];
  39428. colors[cIndex + 13] = colors[cIndex + 7];
  39429. colors[cIndex + 14] = colors[cIndex + 8];
  39430. colors[cIndex + 15] = colorsMap[cs[offset]];
  39431. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39432. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39433. pIndex += 12;
  39434. cIndex += 18;
  39435. }
  39436. }
  39437. break;
  39438. case 'triangles':
  39439. for (var j = 0, jj = ps.length; j < jj; j++) {
  39440. coords[pIndex] = coordsMap[ps[j]];
  39441. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39442. colors[cIndex] = colorsMap[cs[j]];
  39443. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39444. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39445. pIndex += 2;
  39446. cIndex += 3;
  39447. }
  39448. break;
  39449. }
  39450. }
  39451. if (backgroundColor) {
  39452. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39453. } else {
  39454. gl.clearColor(0, 0, 0, 0);
  39455. }
  39456. gl.clear(gl.COLOR_BUFFER_BIT);
  39457. var coordsBuffer = gl.createBuffer();
  39458. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39459. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39460. gl.enableVertexAttribArray(cache.positionLocation);
  39461. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39462. var colorsBuffer = gl.createBuffer();
  39463. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39464. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39465. gl.enableVertexAttribArray(cache.colorLocation);
  39466. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39467. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39468. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39469. gl.drawArrays(gl.TRIANGLES, 0, count);
  39470. gl.flush();
  39471. gl.deleteBuffer(coordsBuffer);
  39472. gl.deleteBuffer(colorsBuffer);
  39473. return canvas;
  39474. }
  39475. function cleanup() {
  39476. if (smaskCache && smaskCache.canvas) {
  39477. smaskCache.canvas.width = 0;
  39478. smaskCache.canvas.height = 0;
  39479. }
  39480. if (figuresCache && figuresCache.canvas) {
  39481. figuresCache.canvas.width = 0;
  39482. figuresCache.canvas.height = 0;
  39483. }
  39484. smaskCache = null;
  39485. figuresCache = null;
  39486. }
  39487. return {
  39488. get isEnabled() {
  39489. if (getDefaultSetting('disableWebGL')) {
  39490. return false;
  39491. }
  39492. var enabled = false;
  39493. try {
  39494. generateGL();
  39495. enabled = !!currentGL;
  39496. } catch (e) {
  39497. }
  39498. return shadow(this, 'isEnabled', enabled);
  39499. },
  39500. composeSMask: composeSMask,
  39501. drawFigures: drawFigures,
  39502. clear: cleanup
  39503. };
  39504. }();
  39505. exports.WebGLUtils = WebGLUtils;
  39506. /***/ }),
  39507. /* 25 */
  39508. /***/ (function(module, exports, __w_pdfjs_require__) {
  39509. "use strict";
  39510. var sharedUtil = __w_pdfjs_require__(0);
  39511. var displayDOMUtils = __w_pdfjs_require__(3);
  39512. var displayAPI = __w_pdfjs_require__(10);
  39513. var displayAnnotationLayer = __w_pdfjs_require__(9);
  39514. var displayTextLayer = __w_pdfjs_require__(12);
  39515. var displayMetadata = __w_pdfjs_require__(23);
  39516. var displaySVG = __w_pdfjs_require__(11);
  39517. var globalScope = sharedUtil.globalScope;
  39518. var deprecated = sharedUtil.deprecated;
  39519. var warn = sharedUtil.warn;
  39520. var LinkTarget = displayDOMUtils.LinkTarget;
  39521. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39522. var isWorker = typeof window === 'undefined';
  39523. if (!globalScope.PDFJS) {
  39524. globalScope.PDFJS = {};
  39525. }
  39526. var PDFJS = globalScope.PDFJS;
  39527. PDFJS.version = '1.7.300';
  39528. PDFJS.build = 'cfaa621a';
  39529. PDFJS.pdfBug = false;
  39530. if (PDFJS.verbosity !== undefined) {
  39531. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39532. }
  39533. delete PDFJS.verbosity;
  39534. Object.defineProperty(PDFJS, 'verbosity', {
  39535. get: function () {
  39536. return sharedUtil.getVerbosityLevel();
  39537. },
  39538. set: function (level) {
  39539. sharedUtil.setVerbosityLevel(level);
  39540. },
  39541. enumerable: true,
  39542. configurable: true
  39543. });
  39544. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39545. PDFJS.OPS = sharedUtil.OPS;
  39546. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39547. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39548. PDFJS.shadow = sharedUtil.shadow;
  39549. PDFJS.createBlob = sharedUtil.createBlob;
  39550. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39551. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39552. };
  39553. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39554. configurable: true,
  39555. get: function PDFJS_isLittleEndian() {
  39556. var value = sharedUtil.isLittleEndian();
  39557. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39558. }
  39559. });
  39560. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39561. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39562. PDFJS.PasswordException = sharedUtil.PasswordException;
  39563. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39564. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39565. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39566. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39567. PDFJS.Util = sharedUtil.Util;
  39568. PDFJS.PageViewport = sharedUtil.PageViewport;
  39569. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39570. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39571. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39572. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39573. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39574. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39575. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39576. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39577. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39578. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39579. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39580. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39581. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39582. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39583. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39584. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39585. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39586. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39587. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39588. delete PDFJS.openExternalLinksInNewWindow;
  39589. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39590. get: function () {
  39591. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39592. },
  39593. set: function (value) {
  39594. if (value) {
  39595. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39596. }
  39597. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39598. warn('PDFJS.externalLinkTarget is already initialized');
  39599. return;
  39600. }
  39601. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  39602. },
  39603. enumerable: true,
  39604. configurable: true
  39605. });
  39606. if (savedOpenExternalLinksInNewWindow) {
  39607. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  39608. }
  39609. PDFJS.getDocument = displayAPI.getDocument;
  39610. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  39611. PDFJS.PDFWorker = displayAPI.PDFWorker;
  39612. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  39613. configurable: true,
  39614. get: function PDFJS_hasCanvasTypedArrays() {
  39615. var value = displayDOMUtils.hasCanvasTypedArrays();
  39616. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  39617. }
  39618. });
  39619. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  39620. PDFJS.LinkTarget = LinkTarget;
  39621. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  39622. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  39623. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  39624. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  39625. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  39626. PDFJS.Metadata = displayMetadata.Metadata;
  39627. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  39628. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  39629. exports.globalScope = globalScope;
  39630. exports.isWorker = isWorker;
  39631. exports.PDFJS = globalScope.PDFJS;
  39632. /***/ }),
  39633. /* 26 */
  39634. /***/ (function(module, exports) {
  39635. var g;
  39636. g = function () {
  39637. return this;
  39638. }();
  39639. try {
  39640. g = g || Function("return this")() || (1, eval)("this");
  39641. } catch (e) {
  39642. if (typeof window === "object")
  39643. g = window;
  39644. }
  39645. module.exports = g;
  39646. /***/ }),
  39647. /* 27 */
  39648. /***/ (function(module, exports, __w_pdfjs_require__) {
  39649. "use strict";
  39650. var sharedUtil = __w_pdfjs_require__(0);
  39651. var corePrimitives = __w_pdfjs_require__(1);
  39652. var coreStream = __w_pdfjs_require__(2);
  39653. var coreColorSpace = __w_pdfjs_require__(4);
  39654. var coreObj = __w_pdfjs_require__(19);
  39655. var coreEvaluator = __w_pdfjs_require__(17);
  39656. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  39657. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  39658. var AnnotationFlag = sharedUtil.AnnotationFlag;
  39659. var AnnotationType = sharedUtil.AnnotationType;
  39660. var OPS = sharedUtil.OPS;
  39661. var Util = sharedUtil.Util;
  39662. var isArray = sharedUtil.isArray;
  39663. var isInt = sharedUtil.isInt;
  39664. var stringToBytes = sharedUtil.stringToBytes;
  39665. var stringToPDFString = sharedUtil.stringToPDFString;
  39666. var warn = sharedUtil.warn;
  39667. var Dict = corePrimitives.Dict;
  39668. var isDict = corePrimitives.isDict;
  39669. var isName = corePrimitives.isName;
  39670. var isRef = corePrimitives.isRef;
  39671. var isStream = corePrimitives.isStream;
  39672. var Stream = coreStream.Stream;
  39673. var ColorSpace = coreColorSpace.ColorSpace;
  39674. var Catalog = coreObj.Catalog;
  39675. var ObjectLoader = coreObj.ObjectLoader;
  39676. var FileSpec = coreObj.FileSpec;
  39677. var OperatorList = coreEvaluator.OperatorList;
  39678. function AnnotationFactory() {
  39679. }
  39680. AnnotationFactory.prototype = {
  39681. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  39682. var dict = xref.fetchIfRef(ref);
  39683. if (!isDict(dict)) {
  39684. return;
  39685. }
  39686. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  39687. var subtype = dict.get('Subtype');
  39688. subtype = isName(subtype) ? subtype.name : null;
  39689. var parameters = {
  39690. xref: xref,
  39691. dict: dict,
  39692. ref: isRef(ref) ? ref : null,
  39693. subtype: subtype,
  39694. id: id,
  39695. pdfManager: pdfManager
  39696. };
  39697. switch (subtype) {
  39698. case 'Link':
  39699. return new LinkAnnotation(parameters);
  39700. case 'Text':
  39701. return new TextAnnotation(parameters);
  39702. case 'Widget':
  39703. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39704. fieldType = isName(fieldType) ? fieldType.name : null;
  39705. switch (fieldType) {
  39706. case 'Tx':
  39707. return new TextWidgetAnnotation(parameters);
  39708. case 'Btn':
  39709. return new ButtonWidgetAnnotation(parameters);
  39710. case 'Ch':
  39711. return new ChoiceWidgetAnnotation(parameters);
  39712. }
  39713. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  39714. return new WidgetAnnotation(parameters);
  39715. case 'Popup':
  39716. return new PopupAnnotation(parameters);
  39717. case 'Highlight':
  39718. return new HighlightAnnotation(parameters);
  39719. case 'Underline':
  39720. return new UnderlineAnnotation(parameters);
  39721. case 'Squiggly':
  39722. return new SquigglyAnnotation(parameters);
  39723. case 'StrikeOut':
  39724. return new StrikeOutAnnotation(parameters);
  39725. case 'FileAttachment':
  39726. return new FileAttachmentAnnotation(parameters);
  39727. default:
  39728. if (!subtype) {
  39729. warn('Annotation is missing the required /Subtype.');
  39730. } else {
  39731. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  39732. }
  39733. return new Annotation(parameters);
  39734. }
  39735. }
  39736. };
  39737. var Annotation = function AnnotationClosure() {
  39738. function getTransformMatrix(rect, bbox, matrix) {
  39739. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  39740. var minX = bounds[0];
  39741. var minY = bounds[1];
  39742. var maxX = bounds[2];
  39743. var maxY = bounds[3];
  39744. if (minX === maxX || minY === maxY) {
  39745. return [
  39746. 1,
  39747. 0,
  39748. 0,
  39749. 1,
  39750. rect[0],
  39751. rect[1]
  39752. ];
  39753. }
  39754. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  39755. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  39756. return [
  39757. xRatio,
  39758. 0,
  39759. 0,
  39760. yRatio,
  39761. rect[0] - minX * xRatio,
  39762. rect[1] - minY * yRatio
  39763. ];
  39764. }
  39765. function Annotation(params) {
  39766. var dict = params.dict;
  39767. this.setFlags(dict.get('F'));
  39768. this.setRectangle(dict.getArray('Rect'));
  39769. this.setColor(dict.getArray('C'));
  39770. this.setBorderStyle(dict);
  39771. this.setAppearance(dict);
  39772. this.data = {};
  39773. this.data.id = params.id;
  39774. this.data.subtype = params.subtype;
  39775. this.data.annotationFlags = this.flags;
  39776. this.data.rect = this.rectangle;
  39777. this.data.color = this.color;
  39778. this.data.borderStyle = this.borderStyle;
  39779. this.data.hasAppearance = !!this.appearance;
  39780. }
  39781. Annotation.prototype = {
  39782. _hasFlag: function Annotation_hasFlag(flags, flag) {
  39783. return !!(flags & flag);
  39784. },
  39785. _isViewable: function Annotation_isViewable(flags) {
  39786. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  39787. },
  39788. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  39789. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  39790. },
  39791. get viewable() {
  39792. if (this.flags === 0) {
  39793. return true;
  39794. }
  39795. return this._isViewable(this.flags);
  39796. },
  39797. get printable() {
  39798. if (this.flags === 0) {
  39799. return false;
  39800. }
  39801. return this._isPrintable(this.flags);
  39802. },
  39803. setFlags: function Annotation_setFlags(flags) {
  39804. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  39805. },
  39806. hasFlag: function Annotation_hasFlag(flag) {
  39807. return this._hasFlag(this.flags, flag);
  39808. },
  39809. setRectangle: function Annotation_setRectangle(rectangle) {
  39810. if (isArray(rectangle) && rectangle.length === 4) {
  39811. this.rectangle = Util.normalizeRect(rectangle);
  39812. } else {
  39813. this.rectangle = [
  39814. 0,
  39815. 0,
  39816. 0,
  39817. 0
  39818. ];
  39819. }
  39820. },
  39821. setColor: function Annotation_setColor(color) {
  39822. var rgbColor = new Uint8Array(3);
  39823. if (!isArray(color)) {
  39824. this.color = rgbColor;
  39825. return;
  39826. }
  39827. switch (color.length) {
  39828. case 0:
  39829. this.color = null;
  39830. break;
  39831. case 1:
  39832. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  39833. this.color = rgbColor;
  39834. break;
  39835. case 3:
  39836. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  39837. this.color = rgbColor;
  39838. break;
  39839. case 4:
  39840. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39841. this.color = rgbColor;
  39842. break;
  39843. default:
  39844. this.color = rgbColor;
  39845. break;
  39846. }
  39847. },
  39848. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39849. this.borderStyle = new AnnotationBorderStyle();
  39850. if (!isDict(borderStyle)) {
  39851. return;
  39852. }
  39853. if (borderStyle.has('BS')) {
  39854. var dict = borderStyle.get('BS');
  39855. var dictType = dict.get('Type');
  39856. if (!dictType || isName(dictType, 'Border')) {
  39857. this.borderStyle.setWidth(dict.get('W'));
  39858. this.borderStyle.setStyle(dict.get('S'));
  39859. this.borderStyle.setDashArray(dict.getArray('D'));
  39860. }
  39861. } else if (borderStyle.has('Border')) {
  39862. var array = borderStyle.getArray('Border');
  39863. if (isArray(array) && array.length >= 3) {
  39864. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39865. this.borderStyle.setVerticalCornerRadius(array[1]);
  39866. this.borderStyle.setWidth(array[2]);
  39867. if (array.length === 4) {
  39868. this.borderStyle.setDashArray(array[3]);
  39869. }
  39870. }
  39871. } else {
  39872. this.borderStyle.setWidth(0);
  39873. }
  39874. },
  39875. setAppearance: function Annotation_setAppearance(dict) {
  39876. this.appearance = null;
  39877. var appearanceStates = dict.get('AP');
  39878. if (!isDict(appearanceStates)) {
  39879. return;
  39880. }
  39881. var normalAppearanceState = appearanceStates.get('N');
  39882. if (isStream(normalAppearanceState)) {
  39883. this.appearance = normalAppearanceState;
  39884. return;
  39885. }
  39886. if (!isDict(normalAppearanceState)) {
  39887. return;
  39888. }
  39889. var as = dict.get('AS');
  39890. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39891. return;
  39892. }
  39893. this.appearance = normalAppearanceState.get(as.name);
  39894. },
  39895. _preparePopup: function Annotation_preparePopup(dict) {
  39896. if (!dict.has('C')) {
  39897. this.data.color = null;
  39898. }
  39899. this.data.hasPopup = dict.has('Popup');
  39900. this.data.title = stringToPDFString(dict.get('T') || '');
  39901. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39902. },
  39903. loadResources: function Annotation_loadResources(keys) {
  39904. return new Promise(function (resolve, reject) {
  39905. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39906. if (!resources) {
  39907. resolve();
  39908. return;
  39909. }
  39910. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39911. objectLoader.load().then(function () {
  39912. resolve(resources);
  39913. }, reject);
  39914. }, reject);
  39915. }.bind(this));
  39916. },
  39917. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39918. if (!this.appearance) {
  39919. return Promise.resolve(new OperatorList());
  39920. }
  39921. var data = this.data;
  39922. var appearanceDict = this.appearance.dict;
  39923. var resourcesPromise = this.loadResources([
  39924. 'ExtGState',
  39925. 'ColorSpace',
  39926. 'Pattern',
  39927. 'Shading',
  39928. 'XObject',
  39929. 'Font'
  39930. ]);
  39931. var bbox = appearanceDict.getArray('BBox') || [
  39932. 0,
  39933. 0,
  39934. 1,
  39935. 1
  39936. ];
  39937. var matrix = appearanceDict.getArray('Matrix') || [
  39938. 1,
  39939. 0,
  39940. 0,
  39941. 1,
  39942. 0,
  39943. 0
  39944. ];
  39945. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39946. var self = this;
  39947. return resourcesPromise.then(function (resources) {
  39948. var opList = new OperatorList();
  39949. opList.addOp(OPS.beginAnnotation, [
  39950. data.rect,
  39951. transform,
  39952. matrix
  39953. ]);
  39954. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39955. opList.addOp(OPS.endAnnotation, []);
  39956. self.appearance.reset();
  39957. return opList;
  39958. });
  39959. });
  39960. }
  39961. };
  39962. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39963. var annotationPromises = [];
  39964. for (var i = 0, n = annotations.length; i < n; ++i) {
  39965. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39966. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39967. }
  39968. }
  39969. return Promise.all(annotationPromises).then(function (operatorLists) {
  39970. opList.addOp(OPS.beginAnnotations, []);
  39971. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39972. opList.addOpList(operatorLists[i]);
  39973. }
  39974. opList.addOp(OPS.endAnnotations, []);
  39975. });
  39976. };
  39977. return Annotation;
  39978. }();
  39979. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39980. function AnnotationBorderStyle() {
  39981. this.width = 1;
  39982. this.style = AnnotationBorderStyleType.SOLID;
  39983. this.dashArray = [3];
  39984. this.horizontalCornerRadius = 0;
  39985. this.verticalCornerRadius = 0;
  39986. }
  39987. AnnotationBorderStyle.prototype = {
  39988. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39989. if (width === (width | 0)) {
  39990. this.width = width;
  39991. }
  39992. },
  39993. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39994. if (!style) {
  39995. return;
  39996. }
  39997. switch (style.name) {
  39998. case 'S':
  39999. this.style = AnnotationBorderStyleType.SOLID;
  40000. break;
  40001. case 'D':
  40002. this.style = AnnotationBorderStyleType.DASHED;
  40003. break;
  40004. case 'B':
  40005. this.style = AnnotationBorderStyleType.BEVELED;
  40006. break;
  40007. case 'I':
  40008. this.style = AnnotationBorderStyleType.INSET;
  40009. break;
  40010. case 'U':
  40011. this.style = AnnotationBorderStyleType.UNDERLINE;
  40012. break;
  40013. default:
  40014. break;
  40015. }
  40016. },
  40017. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  40018. if (isArray(dashArray) && dashArray.length > 0) {
  40019. var isValid = true;
  40020. var allZeros = true;
  40021. for (var i = 0, len = dashArray.length; i < len; i++) {
  40022. var element = dashArray[i];
  40023. var validNumber = +element >= 0;
  40024. if (!validNumber) {
  40025. isValid = false;
  40026. break;
  40027. } else if (element > 0) {
  40028. allZeros = false;
  40029. }
  40030. }
  40031. if (isValid && !allZeros) {
  40032. this.dashArray = dashArray;
  40033. } else {
  40034. this.width = 0;
  40035. }
  40036. } else if (dashArray) {
  40037. this.width = 0;
  40038. }
  40039. },
  40040. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  40041. if (radius === (radius | 0)) {
  40042. this.horizontalCornerRadius = radius;
  40043. }
  40044. },
  40045. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  40046. if (radius === (radius | 0)) {
  40047. this.verticalCornerRadius = radius;
  40048. }
  40049. }
  40050. };
  40051. return AnnotationBorderStyle;
  40052. }();
  40053. var WidgetAnnotation = function WidgetAnnotationClosure() {
  40054. function WidgetAnnotation(params) {
  40055. Annotation.call(this, params);
  40056. var dict = params.dict;
  40057. var data = this.data;
  40058. data.annotationType = AnnotationType.WIDGET;
  40059. data.fieldName = this._constructFieldName(dict);
  40060. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  40061. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  40062. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  40063. var fieldType = Util.getInheritableProperty(dict, 'FT');
  40064. data.fieldType = isName(fieldType) ? fieldType.name : null;
  40065. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  40066. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  40067. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  40068. data.fieldFlags = 0;
  40069. }
  40070. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  40071. if (data.fieldType === 'Sig') {
  40072. this.setFlags(AnnotationFlag.HIDDEN);
  40073. }
  40074. }
  40075. Util.inherit(WidgetAnnotation, Annotation, {
  40076. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  40077. if (!dict.has('T') && !dict.has('Parent')) {
  40078. warn('Unknown field name, falling back to empty field name.');
  40079. return '';
  40080. }
  40081. if (!dict.has('Parent')) {
  40082. return stringToPDFString(dict.get('T'));
  40083. }
  40084. var fieldName = [];
  40085. if (dict.has('T')) {
  40086. fieldName.unshift(stringToPDFString(dict.get('T')));
  40087. }
  40088. var loopDict = dict;
  40089. while (loopDict.has('Parent')) {
  40090. loopDict = loopDict.get('Parent');
  40091. if (loopDict.has('T')) {
  40092. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40093. }
  40094. }
  40095. return fieldName.join('.');
  40096. },
  40097. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40098. return !!(this.data.fieldFlags & flag);
  40099. }
  40100. });
  40101. return WidgetAnnotation;
  40102. }();
  40103. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40104. function TextWidgetAnnotation(params) {
  40105. WidgetAnnotation.call(this, params);
  40106. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40107. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40108. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40109. alignment = null;
  40110. }
  40111. this.data.textAlignment = alignment;
  40112. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40113. if (!isInt(maximumLength) || maximumLength < 0) {
  40114. maximumLength = null;
  40115. }
  40116. this.data.maxLen = maximumLength;
  40117. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40118. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40119. }
  40120. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40121. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40122. var operatorList = new OperatorList();
  40123. if (renderForms) {
  40124. return Promise.resolve(operatorList);
  40125. }
  40126. if (this.appearance) {
  40127. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40128. }
  40129. if (!this.data.defaultAppearance) {
  40130. return Promise.resolve(operatorList);
  40131. }
  40132. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40133. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40134. return operatorList;
  40135. });
  40136. }
  40137. });
  40138. return TextWidgetAnnotation;
  40139. }();
  40140. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40141. function ButtonWidgetAnnotation(params) {
  40142. WidgetAnnotation.call(this, params);
  40143. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40144. if (this.data.checkBox) {
  40145. if (!isName(this.data.fieldValue)) {
  40146. return;
  40147. }
  40148. this.data.fieldValue = this.data.fieldValue.name;
  40149. }
  40150. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40151. if (this.data.radioButton) {
  40152. this.data.fieldValue = this.data.buttonValue = null;
  40153. var fieldParent = params.dict.get('Parent');
  40154. if (isDict(fieldParent) && fieldParent.has('V')) {
  40155. var fieldParentValue = fieldParent.get('V');
  40156. if (isName(fieldParentValue)) {
  40157. this.data.fieldValue = fieldParentValue.name;
  40158. }
  40159. }
  40160. var appearanceStates = params.dict.get('AP');
  40161. if (!isDict(appearanceStates)) {
  40162. return;
  40163. }
  40164. var normalAppearanceState = appearanceStates.get('N');
  40165. if (!isDict(normalAppearanceState)) {
  40166. return;
  40167. }
  40168. var keys = normalAppearanceState.getKeys();
  40169. for (var i = 0, ii = keys.length; i < ii; i++) {
  40170. if (keys[i] !== 'Off') {
  40171. this.data.buttonValue = keys[i];
  40172. break;
  40173. }
  40174. }
  40175. }
  40176. }
  40177. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40178. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40179. var operatorList = new OperatorList();
  40180. if (renderForms) {
  40181. return Promise.resolve(operatorList);
  40182. }
  40183. if (this.appearance) {
  40184. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40185. }
  40186. return Promise.resolve(operatorList);
  40187. }
  40188. });
  40189. return ButtonWidgetAnnotation;
  40190. }();
  40191. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40192. function ChoiceWidgetAnnotation(params) {
  40193. WidgetAnnotation.call(this, params);
  40194. this.data.options = [];
  40195. var options = params.dict.get('Opt');
  40196. if (isArray(options)) {
  40197. var xref = params.xref;
  40198. for (var i = 0, ii = options.length; i < ii; i++) {
  40199. var option = xref.fetchIfRef(options[i]);
  40200. var isOptionArray = isArray(option);
  40201. this.data.options[i] = {
  40202. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40203. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40204. };
  40205. }
  40206. }
  40207. if (!isArray(this.data.fieldValue)) {
  40208. this.data.fieldValue = [this.data.fieldValue];
  40209. }
  40210. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40211. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40212. }
  40213. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40214. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40215. var operatorList = new OperatorList();
  40216. if (renderForms) {
  40217. return Promise.resolve(operatorList);
  40218. }
  40219. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40220. }
  40221. });
  40222. return ChoiceWidgetAnnotation;
  40223. }();
  40224. var TextAnnotation = function TextAnnotationClosure() {
  40225. var DEFAULT_ICON_SIZE = 22;
  40226. function TextAnnotation(parameters) {
  40227. Annotation.call(this, parameters);
  40228. this.data.annotationType = AnnotationType.TEXT;
  40229. if (this.data.hasAppearance) {
  40230. this.data.name = 'NoIcon';
  40231. } else {
  40232. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40233. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40234. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40235. }
  40236. this._preparePopup(parameters.dict);
  40237. }
  40238. Util.inherit(TextAnnotation, Annotation, {});
  40239. return TextAnnotation;
  40240. }();
  40241. var LinkAnnotation = function LinkAnnotationClosure() {
  40242. function LinkAnnotation(params) {
  40243. Annotation.call(this, params);
  40244. var data = this.data;
  40245. data.annotationType = AnnotationType.LINK;
  40246. Catalog.parseDestDictionary({
  40247. destDict: params.dict,
  40248. resultObj: data,
  40249. docBaseUrl: params.pdfManager.docBaseUrl
  40250. });
  40251. }
  40252. Util.inherit(LinkAnnotation, Annotation, {});
  40253. return LinkAnnotation;
  40254. }();
  40255. var PopupAnnotation = function PopupAnnotationClosure() {
  40256. function PopupAnnotation(parameters) {
  40257. Annotation.call(this, parameters);
  40258. this.data.annotationType = AnnotationType.POPUP;
  40259. var dict = parameters.dict;
  40260. var parentItem = dict.get('Parent');
  40261. if (!parentItem) {
  40262. warn('Popup annotation has a missing or invalid parent annotation.');
  40263. return;
  40264. }
  40265. this.data.parentId = dict.getRaw('Parent').toString();
  40266. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40267. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40268. if (!parentItem.has('C')) {
  40269. this.data.color = null;
  40270. } else {
  40271. this.setColor(parentItem.getArray('C'));
  40272. this.data.color = this.color;
  40273. }
  40274. if (!this.viewable) {
  40275. var parentFlags = parentItem.get('F');
  40276. if (this._isViewable(parentFlags)) {
  40277. this.setFlags(parentFlags);
  40278. }
  40279. }
  40280. }
  40281. Util.inherit(PopupAnnotation, Annotation, {});
  40282. return PopupAnnotation;
  40283. }();
  40284. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40285. function HighlightAnnotation(parameters) {
  40286. Annotation.call(this, parameters);
  40287. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40288. this._preparePopup(parameters.dict);
  40289. this.data.borderStyle.setWidth(0);
  40290. }
  40291. Util.inherit(HighlightAnnotation, Annotation, {});
  40292. return HighlightAnnotation;
  40293. }();
  40294. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40295. function UnderlineAnnotation(parameters) {
  40296. Annotation.call(this, parameters);
  40297. this.data.annotationType = AnnotationType.UNDERLINE;
  40298. this._preparePopup(parameters.dict);
  40299. this.data.borderStyle.setWidth(0);
  40300. }
  40301. Util.inherit(UnderlineAnnotation, Annotation, {});
  40302. return UnderlineAnnotation;
  40303. }();
  40304. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40305. function SquigglyAnnotation(parameters) {
  40306. Annotation.call(this, parameters);
  40307. this.data.annotationType = AnnotationType.SQUIGGLY;
  40308. this._preparePopup(parameters.dict);
  40309. this.data.borderStyle.setWidth(0);
  40310. }
  40311. Util.inherit(SquigglyAnnotation, Annotation, {});
  40312. return SquigglyAnnotation;
  40313. }();
  40314. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40315. function StrikeOutAnnotation(parameters) {
  40316. Annotation.call(this, parameters);
  40317. this.data.annotationType = AnnotationType.STRIKEOUT;
  40318. this._preparePopup(parameters.dict);
  40319. this.data.borderStyle.setWidth(0);
  40320. }
  40321. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40322. return StrikeOutAnnotation;
  40323. }();
  40324. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40325. function FileAttachmentAnnotation(parameters) {
  40326. Annotation.call(this, parameters);
  40327. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40328. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40329. this.data.file = file.serializable;
  40330. this._preparePopup(parameters.dict);
  40331. }
  40332. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40333. return FileAttachmentAnnotation;
  40334. }();
  40335. exports.Annotation = Annotation;
  40336. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40337. exports.AnnotationFactory = AnnotationFactory;
  40338. /***/ }),
  40339. /* 28 */
  40340. /***/ (function(module, exports, __w_pdfjs_require__) {
  40341. "use strict";
  40342. var sharedUtil = __w_pdfjs_require__(0);
  40343. var warn = sharedUtil.warn;
  40344. var baseTypes = [
  40345. 'BN',
  40346. 'BN',
  40347. 'BN',
  40348. 'BN',
  40349. 'BN',
  40350. 'BN',
  40351. 'BN',
  40352. 'BN',
  40353. 'BN',
  40354. 'S',
  40355. 'B',
  40356. 'S',
  40357. 'WS',
  40358. 'B',
  40359. 'BN',
  40360. 'BN',
  40361. 'BN',
  40362. 'BN',
  40363. 'BN',
  40364. 'BN',
  40365. 'BN',
  40366. 'BN',
  40367. 'BN',
  40368. 'BN',
  40369. 'BN',
  40370. 'BN',
  40371. 'BN',
  40372. 'BN',
  40373. 'B',
  40374. 'B',
  40375. 'B',
  40376. 'S',
  40377. 'WS',
  40378. 'ON',
  40379. 'ON',
  40380. 'ET',
  40381. 'ET',
  40382. 'ET',
  40383. 'ON',
  40384. 'ON',
  40385. 'ON',
  40386. 'ON',
  40387. 'ON',
  40388. 'ES',
  40389. 'CS',
  40390. 'ES',
  40391. 'CS',
  40392. 'CS',
  40393. 'EN',
  40394. 'EN',
  40395. 'EN',
  40396. 'EN',
  40397. 'EN',
  40398. 'EN',
  40399. 'EN',
  40400. 'EN',
  40401. 'EN',
  40402. 'EN',
  40403. 'CS',
  40404. 'ON',
  40405. 'ON',
  40406. 'ON',
  40407. 'ON',
  40408. 'ON',
  40409. 'ON',
  40410. 'L',
  40411. 'L',
  40412. 'L',
  40413. 'L',
  40414. 'L',
  40415. 'L',
  40416. 'L',
  40417. 'L',
  40418. 'L',
  40419. 'L',
  40420. 'L',
  40421. 'L',
  40422. 'L',
  40423. 'L',
  40424. 'L',
  40425. 'L',
  40426. 'L',
  40427. 'L',
  40428. 'L',
  40429. 'L',
  40430. 'L',
  40431. 'L',
  40432. 'L',
  40433. 'L',
  40434. 'L',
  40435. 'L',
  40436. 'ON',
  40437. 'ON',
  40438. 'ON',
  40439. 'ON',
  40440. 'ON',
  40441. 'ON',
  40442. 'L',
  40443. 'L',
  40444. 'L',
  40445. 'L',
  40446. 'L',
  40447. 'L',
  40448. 'L',
  40449. 'L',
  40450. 'L',
  40451. 'L',
  40452. 'L',
  40453. 'L',
  40454. 'L',
  40455. 'L',
  40456. 'L',
  40457. 'L',
  40458. 'L',
  40459. 'L',
  40460. 'L',
  40461. 'L',
  40462. 'L',
  40463. 'L',
  40464. 'L',
  40465. 'L',
  40466. 'L',
  40467. 'L',
  40468. 'ON',
  40469. 'ON',
  40470. 'ON',
  40471. 'ON',
  40472. 'BN',
  40473. 'BN',
  40474. 'BN',
  40475. 'BN',
  40476. 'BN',
  40477. 'BN',
  40478. 'B',
  40479. 'BN',
  40480. 'BN',
  40481. 'BN',
  40482. 'BN',
  40483. 'BN',
  40484. 'BN',
  40485. 'BN',
  40486. 'BN',
  40487. 'BN',
  40488. 'BN',
  40489. 'BN',
  40490. 'BN',
  40491. 'BN',
  40492. 'BN',
  40493. 'BN',
  40494. 'BN',
  40495. 'BN',
  40496. 'BN',
  40497. 'BN',
  40498. 'BN',
  40499. 'BN',
  40500. 'BN',
  40501. 'BN',
  40502. 'BN',
  40503. 'BN',
  40504. 'BN',
  40505. 'CS',
  40506. 'ON',
  40507. 'ET',
  40508. 'ET',
  40509. 'ET',
  40510. 'ET',
  40511. 'ON',
  40512. 'ON',
  40513. 'ON',
  40514. 'ON',
  40515. 'L',
  40516. 'ON',
  40517. 'ON',
  40518. 'BN',
  40519. 'ON',
  40520. 'ON',
  40521. 'ET',
  40522. 'ET',
  40523. 'EN',
  40524. 'EN',
  40525. 'ON',
  40526. 'L',
  40527. 'ON',
  40528. 'ON',
  40529. 'ON',
  40530. 'EN',
  40531. 'L',
  40532. 'ON',
  40533. 'ON',
  40534. 'ON',
  40535. 'ON',
  40536. 'ON',
  40537. 'L',
  40538. 'L',
  40539. 'L',
  40540. 'L',
  40541. 'L',
  40542. 'L',
  40543. 'L',
  40544. 'L',
  40545. 'L',
  40546. 'L',
  40547. 'L',
  40548. 'L',
  40549. 'L',
  40550. 'L',
  40551. 'L',
  40552. 'L',
  40553. 'L',
  40554. 'L',
  40555. 'L',
  40556. 'L',
  40557. 'L',
  40558. 'L',
  40559. 'L',
  40560. 'ON',
  40561. 'L',
  40562. 'L',
  40563. 'L',
  40564. 'L',
  40565. 'L',
  40566. 'L',
  40567. 'L',
  40568. 'L',
  40569. 'L',
  40570. 'L',
  40571. 'L',
  40572. 'L',
  40573. 'L',
  40574. 'L',
  40575. 'L',
  40576. 'L',
  40577. 'L',
  40578. 'L',
  40579. 'L',
  40580. 'L',
  40581. 'L',
  40582. 'L',
  40583. 'L',
  40584. 'L',
  40585. 'L',
  40586. 'L',
  40587. 'L',
  40588. 'L',
  40589. 'L',
  40590. 'L',
  40591. 'L',
  40592. 'ON',
  40593. 'L',
  40594. 'L',
  40595. 'L',
  40596. 'L',
  40597. 'L',
  40598. 'L',
  40599. 'L',
  40600. 'L'
  40601. ];
  40602. var arabicTypes = [
  40603. 'AN',
  40604. 'AN',
  40605. 'AN',
  40606. 'AN',
  40607. 'AN',
  40608. 'AN',
  40609. 'ON',
  40610. 'ON',
  40611. 'AL',
  40612. 'ET',
  40613. 'ET',
  40614. 'AL',
  40615. 'CS',
  40616. 'AL',
  40617. 'ON',
  40618. 'ON',
  40619. 'NSM',
  40620. 'NSM',
  40621. 'NSM',
  40622. 'NSM',
  40623. 'NSM',
  40624. 'NSM',
  40625. 'NSM',
  40626. 'NSM',
  40627. 'NSM',
  40628. 'NSM',
  40629. 'NSM',
  40630. 'AL',
  40631. 'AL',
  40632. '',
  40633. 'AL',
  40634. 'AL',
  40635. 'AL',
  40636. 'AL',
  40637. 'AL',
  40638. 'AL',
  40639. 'AL',
  40640. 'AL',
  40641. 'AL',
  40642. 'AL',
  40643. 'AL',
  40644. 'AL',
  40645. 'AL',
  40646. 'AL',
  40647. 'AL',
  40648. 'AL',
  40649. 'AL',
  40650. 'AL',
  40651. 'AL',
  40652. 'AL',
  40653. 'AL',
  40654. 'AL',
  40655. 'AL',
  40656. 'AL',
  40657. 'AL',
  40658. 'AL',
  40659. 'AL',
  40660. 'AL',
  40661. 'AL',
  40662. 'AL',
  40663. 'AL',
  40664. 'AL',
  40665. 'AL',
  40666. 'AL',
  40667. 'AL',
  40668. 'AL',
  40669. 'AL',
  40670. 'AL',
  40671. 'AL',
  40672. 'AL',
  40673. 'AL',
  40674. 'AL',
  40675. 'AL',
  40676. 'AL',
  40677. 'AL',
  40678. 'NSM',
  40679. 'NSM',
  40680. 'NSM',
  40681. 'NSM',
  40682. 'NSM',
  40683. 'NSM',
  40684. 'NSM',
  40685. 'NSM',
  40686. 'NSM',
  40687. 'NSM',
  40688. 'NSM',
  40689. 'NSM',
  40690. 'NSM',
  40691. 'NSM',
  40692. 'NSM',
  40693. 'NSM',
  40694. 'NSM',
  40695. 'NSM',
  40696. 'NSM',
  40697. 'NSM',
  40698. 'NSM',
  40699. 'AN',
  40700. 'AN',
  40701. 'AN',
  40702. 'AN',
  40703. 'AN',
  40704. 'AN',
  40705. 'AN',
  40706. 'AN',
  40707. 'AN',
  40708. 'AN',
  40709. 'ET',
  40710. 'AN',
  40711. 'AN',
  40712. 'AL',
  40713. 'AL',
  40714. 'AL',
  40715. 'NSM',
  40716. 'AL',
  40717. 'AL',
  40718. 'AL',
  40719. 'AL',
  40720. 'AL',
  40721. 'AL',
  40722. 'AL',
  40723. 'AL',
  40724. 'AL',
  40725. 'AL',
  40726. 'AL',
  40727. 'AL',
  40728. 'AL',
  40729. 'AL',
  40730. 'AL',
  40731. 'AL',
  40732. 'AL',
  40733. 'AL',
  40734. 'AL',
  40735. 'AL',
  40736. 'AL',
  40737. 'AL',
  40738. 'AL',
  40739. 'AL',
  40740. 'AL',
  40741. 'AL',
  40742. 'AL',
  40743. 'AL',
  40744. 'AL',
  40745. 'AL',
  40746. 'AL',
  40747. 'AL',
  40748. 'AL',
  40749. 'AL',
  40750. 'AL',
  40751. 'AL',
  40752. 'AL',
  40753. 'AL',
  40754. 'AL',
  40755. 'AL',
  40756. 'AL',
  40757. 'AL',
  40758. 'AL',
  40759. 'AL',
  40760. 'AL',
  40761. 'AL',
  40762. 'AL',
  40763. 'AL',
  40764. 'AL',
  40765. 'AL',
  40766. 'AL',
  40767. 'AL',
  40768. 'AL',
  40769. 'AL',
  40770. 'AL',
  40771. 'AL',
  40772. 'AL',
  40773. 'AL',
  40774. 'AL',
  40775. 'AL',
  40776. 'AL',
  40777. 'AL',
  40778. 'AL',
  40779. 'AL',
  40780. 'AL',
  40781. 'AL',
  40782. 'AL',
  40783. 'AL',
  40784. 'AL',
  40785. 'AL',
  40786. 'AL',
  40787. 'AL',
  40788. 'AL',
  40789. 'AL',
  40790. 'AL',
  40791. 'AL',
  40792. 'AL',
  40793. 'AL',
  40794. 'AL',
  40795. 'AL',
  40796. 'AL',
  40797. 'AL',
  40798. 'AL',
  40799. 'AL',
  40800. 'AL',
  40801. 'AL',
  40802. 'AL',
  40803. 'AL',
  40804. 'AL',
  40805. 'AL',
  40806. 'AL',
  40807. 'AL',
  40808. 'AL',
  40809. 'AL',
  40810. 'AL',
  40811. 'AL',
  40812. 'AL',
  40813. 'AL',
  40814. 'AL',
  40815. 'AL',
  40816. 'AL',
  40817. 'NSM',
  40818. 'NSM',
  40819. 'NSM',
  40820. 'NSM',
  40821. 'NSM',
  40822. 'NSM',
  40823. 'NSM',
  40824. 'AN',
  40825. 'ON',
  40826. 'NSM',
  40827. 'NSM',
  40828. 'NSM',
  40829. 'NSM',
  40830. 'NSM',
  40831. 'NSM',
  40832. 'AL',
  40833. 'AL',
  40834. 'NSM',
  40835. 'NSM',
  40836. 'ON',
  40837. 'NSM',
  40838. 'NSM',
  40839. 'NSM',
  40840. 'NSM',
  40841. 'AL',
  40842. 'AL',
  40843. 'EN',
  40844. 'EN',
  40845. 'EN',
  40846. 'EN',
  40847. 'EN',
  40848. 'EN',
  40849. 'EN',
  40850. 'EN',
  40851. 'EN',
  40852. 'EN',
  40853. 'AL',
  40854. 'AL',
  40855. 'AL',
  40856. 'AL',
  40857. 'AL',
  40858. 'AL'
  40859. ];
  40860. function isOdd(i) {
  40861. return (i & 1) !== 0;
  40862. }
  40863. function isEven(i) {
  40864. return (i & 1) === 0;
  40865. }
  40866. function findUnequal(arr, start, value) {
  40867. for (var j = start, jj = arr.length; j < jj; ++j) {
  40868. if (arr[j] !== value) {
  40869. return j;
  40870. }
  40871. }
  40872. return j;
  40873. }
  40874. function setValues(arr, start, end, value) {
  40875. for (var j = start; j < end; ++j) {
  40876. arr[j] = value;
  40877. }
  40878. }
  40879. function reverseValues(arr, start, end) {
  40880. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40881. var temp = arr[i];
  40882. arr[i] = arr[j];
  40883. arr[j] = temp;
  40884. }
  40885. }
  40886. function createBidiText(str, isLTR, vertical) {
  40887. return {
  40888. str: str,
  40889. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40890. };
  40891. }
  40892. var chars = [];
  40893. var types = [];
  40894. function bidi(str, startLevel, vertical) {
  40895. var isLTR = true;
  40896. var strLength = str.length;
  40897. if (strLength === 0 || vertical) {
  40898. return createBidiText(str, isLTR, vertical);
  40899. }
  40900. chars.length = strLength;
  40901. types.length = strLength;
  40902. var numBidi = 0;
  40903. var i, ii;
  40904. for (i = 0; i < strLength; ++i) {
  40905. chars[i] = str.charAt(i);
  40906. var charCode = str.charCodeAt(i);
  40907. var charType = 'L';
  40908. if (charCode <= 0x00ff) {
  40909. charType = baseTypes[charCode];
  40910. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40911. charType = 'R';
  40912. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40913. charType = arabicTypes[charCode & 0xff];
  40914. if (!charType) {
  40915. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40916. }
  40917. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40918. charType = 'AL';
  40919. }
  40920. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40921. numBidi++;
  40922. }
  40923. types[i] = charType;
  40924. }
  40925. if (numBidi === 0) {
  40926. isLTR = true;
  40927. return createBidiText(str, isLTR);
  40928. }
  40929. if (startLevel === -1) {
  40930. if (numBidi / strLength < 0.3) {
  40931. isLTR = true;
  40932. startLevel = 0;
  40933. } else {
  40934. isLTR = false;
  40935. startLevel = 1;
  40936. }
  40937. }
  40938. var levels = [];
  40939. for (i = 0; i < strLength; ++i) {
  40940. levels[i] = startLevel;
  40941. }
  40942. var e = isOdd(startLevel) ? 'R' : 'L';
  40943. var sor = e;
  40944. var eor = sor;
  40945. var lastType = sor;
  40946. for (i = 0; i < strLength; ++i) {
  40947. if (types[i] === 'NSM') {
  40948. types[i] = lastType;
  40949. } else {
  40950. lastType = types[i];
  40951. }
  40952. }
  40953. lastType = sor;
  40954. var t;
  40955. for (i = 0; i < strLength; ++i) {
  40956. t = types[i];
  40957. if (t === 'EN') {
  40958. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40959. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40960. lastType = t;
  40961. }
  40962. }
  40963. for (i = 0; i < strLength; ++i) {
  40964. t = types[i];
  40965. if (t === 'AL') {
  40966. types[i] = 'R';
  40967. }
  40968. }
  40969. for (i = 1; i < strLength - 1; ++i) {
  40970. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40971. types[i] = 'EN';
  40972. }
  40973. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40974. types[i] = types[i - 1];
  40975. }
  40976. }
  40977. for (i = 0; i < strLength; ++i) {
  40978. if (types[i] === 'EN') {
  40979. var j;
  40980. for (j = i - 1; j >= 0; --j) {
  40981. if (types[j] !== 'ET') {
  40982. break;
  40983. }
  40984. types[j] = 'EN';
  40985. }
  40986. for (j = i + 1; j < strLength; ++j) {
  40987. if (types[j] !== 'ET') {
  40988. break;
  40989. }
  40990. types[j] = 'EN';
  40991. }
  40992. }
  40993. }
  40994. for (i = 0; i < strLength; ++i) {
  40995. t = types[i];
  40996. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40997. types[i] = 'ON';
  40998. }
  40999. }
  41000. lastType = sor;
  41001. for (i = 0; i < strLength; ++i) {
  41002. t = types[i];
  41003. if (t === 'EN') {
  41004. types[i] = lastType === 'L' ? 'L' : 'EN';
  41005. } else if (t === 'R' || t === 'L') {
  41006. lastType = t;
  41007. }
  41008. }
  41009. for (i = 0; i < strLength; ++i) {
  41010. if (types[i] === 'ON') {
  41011. var end = findUnequal(types, i + 1, 'ON');
  41012. var before = sor;
  41013. if (i > 0) {
  41014. before = types[i - 1];
  41015. }
  41016. var after = eor;
  41017. if (end + 1 < strLength) {
  41018. after = types[end + 1];
  41019. }
  41020. if (before !== 'L') {
  41021. before = 'R';
  41022. }
  41023. if (after !== 'L') {
  41024. after = 'R';
  41025. }
  41026. if (before === after) {
  41027. setValues(types, i, end, before);
  41028. }
  41029. i = end - 1;
  41030. }
  41031. }
  41032. for (i = 0; i < strLength; ++i) {
  41033. if (types[i] === 'ON') {
  41034. types[i] = e;
  41035. }
  41036. }
  41037. for (i = 0; i < strLength; ++i) {
  41038. t = types[i];
  41039. if (isEven(levels[i])) {
  41040. if (t === 'R') {
  41041. levels[i] += 1;
  41042. } else if (t === 'AN' || t === 'EN') {
  41043. levels[i] += 2;
  41044. }
  41045. } else {
  41046. if (t === 'L' || t === 'AN' || t === 'EN') {
  41047. levels[i] += 1;
  41048. }
  41049. }
  41050. }
  41051. var highestLevel = -1;
  41052. var lowestOddLevel = 99;
  41053. var level;
  41054. for (i = 0, ii = levels.length; i < ii; ++i) {
  41055. level = levels[i];
  41056. if (highestLevel < level) {
  41057. highestLevel = level;
  41058. }
  41059. if (lowestOddLevel > level && isOdd(level)) {
  41060. lowestOddLevel = level;
  41061. }
  41062. }
  41063. for (level = highestLevel; level >= lowestOddLevel; --level) {
  41064. var start = -1;
  41065. for (i = 0, ii = levels.length; i < ii; ++i) {
  41066. if (levels[i] < level) {
  41067. if (start >= 0) {
  41068. reverseValues(chars, start, i);
  41069. start = -1;
  41070. }
  41071. } else if (start < 0) {
  41072. start = i;
  41073. }
  41074. }
  41075. if (start >= 0) {
  41076. reverseValues(chars, start, levels.length);
  41077. }
  41078. }
  41079. for (i = 0, ii = chars.length; i < ii; ++i) {
  41080. var ch = chars[i];
  41081. if (ch === '<' || ch === '>') {
  41082. chars[i] = '';
  41083. }
  41084. }
  41085. return createBidiText(chars.join(''), isLTR);
  41086. }
  41087. exports.bidi = bidi;
  41088. /***/ }),
  41089. /* 29 */
  41090. /***/ (function(module, exports, __w_pdfjs_require__) {
  41091. "use strict";
  41092. var ISOAdobeCharset = [
  41093. '.notdef',
  41094. 'space',
  41095. 'exclam',
  41096. 'quotedbl',
  41097. 'numbersign',
  41098. 'dollar',
  41099. 'percent',
  41100. 'ampersand',
  41101. 'quoteright',
  41102. 'parenleft',
  41103. 'parenright',
  41104. 'asterisk',
  41105. 'plus',
  41106. 'comma',
  41107. 'hyphen',
  41108. 'period',
  41109. 'slash',
  41110. 'zero',
  41111. 'one',
  41112. 'two',
  41113. 'three',
  41114. 'four',
  41115. 'five',
  41116. 'six',
  41117. 'seven',
  41118. 'eight',
  41119. 'nine',
  41120. 'colon',
  41121. 'semicolon',
  41122. 'less',
  41123. 'equal',
  41124. 'greater',
  41125. 'question',
  41126. 'at',
  41127. 'A',
  41128. 'B',
  41129. 'C',
  41130. 'D',
  41131. 'E',
  41132. 'F',
  41133. 'G',
  41134. 'H',
  41135. 'I',
  41136. 'J',
  41137. 'K',
  41138. 'L',
  41139. 'M',
  41140. 'N',
  41141. 'O',
  41142. 'P',
  41143. 'Q',
  41144. 'R',
  41145. 'S',
  41146. 'T',
  41147. 'U',
  41148. 'V',
  41149. 'W',
  41150. 'X',
  41151. 'Y',
  41152. 'Z',
  41153. 'bracketleft',
  41154. 'backslash',
  41155. 'bracketright',
  41156. 'asciicircum',
  41157. 'underscore',
  41158. 'quoteleft',
  41159. 'a',
  41160. 'b',
  41161. 'c',
  41162. 'd',
  41163. 'e',
  41164. 'f',
  41165. 'g',
  41166. 'h',
  41167. 'i',
  41168. 'j',
  41169. 'k',
  41170. 'l',
  41171. 'm',
  41172. 'n',
  41173. 'o',
  41174. 'p',
  41175. 'q',
  41176. 'r',
  41177. 's',
  41178. 't',
  41179. 'u',
  41180. 'v',
  41181. 'w',
  41182. 'x',
  41183. 'y',
  41184. 'z',
  41185. 'braceleft',
  41186. 'bar',
  41187. 'braceright',
  41188. 'asciitilde',
  41189. 'exclamdown',
  41190. 'cent',
  41191. 'sterling',
  41192. 'fraction',
  41193. 'yen',
  41194. 'florin',
  41195. 'section',
  41196. 'currency',
  41197. 'quotesingle',
  41198. 'quotedblleft',
  41199. 'guillemotleft',
  41200. 'guilsinglleft',
  41201. 'guilsinglright',
  41202. 'fi',
  41203. 'fl',
  41204. 'endash',
  41205. 'dagger',
  41206. 'daggerdbl',
  41207. 'periodcentered',
  41208. 'paragraph',
  41209. 'bullet',
  41210. 'quotesinglbase',
  41211. 'quotedblbase',
  41212. 'quotedblright',
  41213. 'guillemotright',
  41214. 'ellipsis',
  41215. 'perthousand',
  41216. 'questiondown',
  41217. 'grave',
  41218. 'acute',
  41219. 'circumflex',
  41220. 'tilde',
  41221. 'macron',
  41222. 'breve',
  41223. 'dotaccent',
  41224. 'dieresis',
  41225. 'ring',
  41226. 'cedilla',
  41227. 'hungarumlaut',
  41228. 'ogonek',
  41229. 'caron',
  41230. 'emdash',
  41231. 'AE',
  41232. 'ordfeminine',
  41233. 'Lslash',
  41234. 'Oslash',
  41235. 'OE',
  41236. 'ordmasculine',
  41237. 'ae',
  41238. 'dotlessi',
  41239. 'lslash',
  41240. 'oslash',
  41241. 'oe',
  41242. 'germandbls',
  41243. 'onesuperior',
  41244. 'logicalnot',
  41245. 'mu',
  41246. 'trademark',
  41247. 'Eth',
  41248. 'onehalf',
  41249. 'plusminus',
  41250. 'Thorn',
  41251. 'onequarter',
  41252. 'divide',
  41253. 'brokenbar',
  41254. 'degree',
  41255. 'thorn',
  41256. 'threequarters',
  41257. 'twosuperior',
  41258. 'registered',
  41259. 'minus',
  41260. 'eth',
  41261. 'multiply',
  41262. 'threesuperior',
  41263. 'copyright',
  41264. 'Aacute',
  41265. 'Acircumflex',
  41266. 'Adieresis',
  41267. 'Agrave',
  41268. 'Aring',
  41269. 'Atilde',
  41270. 'Ccedilla',
  41271. 'Eacute',
  41272. 'Ecircumflex',
  41273. 'Edieresis',
  41274. 'Egrave',
  41275. 'Iacute',
  41276. 'Icircumflex',
  41277. 'Idieresis',
  41278. 'Igrave',
  41279. 'Ntilde',
  41280. 'Oacute',
  41281. 'Ocircumflex',
  41282. 'Odieresis',
  41283. 'Ograve',
  41284. 'Otilde',
  41285. 'Scaron',
  41286. 'Uacute',
  41287. 'Ucircumflex',
  41288. 'Udieresis',
  41289. 'Ugrave',
  41290. 'Yacute',
  41291. 'Ydieresis',
  41292. 'Zcaron',
  41293. 'aacute',
  41294. 'acircumflex',
  41295. 'adieresis',
  41296. 'agrave',
  41297. 'aring',
  41298. 'atilde',
  41299. 'ccedilla',
  41300. 'eacute',
  41301. 'ecircumflex',
  41302. 'edieresis',
  41303. 'egrave',
  41304. 'iacute',
  41305. 'icircumflex',
  41306. 'idieresis',
  41307. 'igrave',
  41308. 'ntilde',
  41309. 'oacute',
  41310. 'ocircumflex',
  41311. 'odieresis',
  41312. 'ograve',
  41313. 'otilde',
  41314. 'scaron',
  41315. 'uacute',
  41316. 'ucircumflex',
  41317. 'udieresis',
  41318. 'ugrave',
  41319. 'yacute',
  41320. 'ydieresis',
  41321. 'zcaron'
  41322. ];
  41323. var ExpertCharset = [
  41324. '.notdef',
  41325. 'space',
  41326. 'exclamsmall',
  41327. 'Hungarumlautsmall',
  41328. 'dollaroldstyle',
  41329. 'dollarsuperior',
  41330. 'ampersandsmall',
  41331. 'Acutesmall',
  41332. 'parenleftsuperior',
  41333. 'parenrightsuperior',
  41334. 'twodotenleader',
  41335. 'onedotenleader',
  41336. 'comma',
  41337. 'hyphen',
  41338. 'period',
  41339. 'fraction',
  41340. 'zerooldstyle',
  41341. 'oneoldstyle',
  41342. 'twooldstyle',
  41343. 'threeoldstyle',
  41344. 'fouroldstyle',
  41345. 'fiveoldstyle',
  41346. 'sixoldstyle',
  41347. 'sevenoldstyle',
  41348. 'eightoldstyle',
  41349. 'nineoldstyle',
  41350. 'colon',
  41351. 'semicolon',
  41352. 'commasuperior',
  41353. 'threequartersemdash',
  41354. 'periodsuperior',
  41355. 'questionsmall',
  41356. 'asuperior',
  41357. 'bsuperior',
  41358. 'centsuperior',
  41359. 'dsuperior',
  41360. 'esuperior',
  41361. 'isuperior',
  41362. 'lsuperior',
  41363. 'msuperior',
  41364. 'nsuperior',
  41365. 'osuperior',
  41366. 'rsuperior',
  41367. 'ssuperior',
  41368. 'tsuperior',
  41369. 'ff',
  41370. 'fi',
  41371. 'fl',
  41372. 'ffi',
  41373. 'ffl',
  41374. 'parenleftinferior',
  41375. 'parenrightinferior',
  41376. 'Circumflexsmall',
  41377. 'hyphensuperior',
  41378. 'Gravesmall',
  41379. 'Asmall',
  41380. 'Bsmall',
  41381. 'Csmall',
  41382. 'Dsmall',
  41383. 'Esmall',
  41384. 'Fsmall',
  41385. 'Gsmall',
  41386. 'Hsmall',
  41387. 'Ismall',
  41388. 'Jsmall',
  41389. 'Ksmall',
  41390. 'Lsmall',
  41391. 'Msmall',
  41392. 'Nsmall',
  41393. 'Osmall',
  41394. 'Psmall',
  41395. 'Qsmall',
  41396. 'Rsmall',
  41397. 'Ssmall',
  41398. 'Tsmall',
  41399. 'Usmall',
  41400. 'Vsmall',
  41401. 'Wsmall',
  41402. 'Xsmall',
  41403. 'Ysmall',
  41404. 'Zsmall',
  41405. 'colonmonetary',
  41406. 'onefitted',
  41407. 'rupiah',
  41408. 'Tildesmall',
  41409. 'exclamdownsmall',
  41410. 'centoldstyle',
  41411. 'Lslashsmall',
  41412. 'Scaronsmall',
  41413. 'Zcaronsmall',
  41414. 'Dieresissmall',
  41415. 'Brevesmall',
  41416. 'Caronsmall',
  41417. 'Dotaccentsmall',
  41418. 'Macronsmall',
  41419. 'figuredash',
  41420. 'hypheninferior',
  41421. 'Ogoneksmall',
  41422. 'Ringsmall',
  41423. 'Cedillasmall',
  41424. 'onequarter',
  41425. 'onehalf',
  41426. 'threequarters',
  41427. 'questiondownsmall',
  41428. 'oneeighth',
  41429. 'threeeighths',
  41430. 'fiveeighths',
  41431. 'seveneighths',
  41432. 'onethird',
  41433. 'twothirds',
  41434. 'zerosuperior',
  41435. 'onesuperior',
  41436. 'twosuperior',
  41437. 'threesuperior',
  41438. 'foursuperior',
  41439. 'fivesuperior',
  41440. 'sixsuperior',
  41441. 'sevensuperior',
  41442. 'eightsuperior',
  41443. 'ninesuperior',
  41444. 'zeroinferior',
  41445. 'oneinferior',
  41446. 'twoinferior',
  41447. 'threeinferior',
  41448. 'fourinferior',
  41449. 'fiveinferior',
  41450. 'sixinferior',
  41451. 'seveninferior',
  41452. 'eightinferior',
  41453. 'nineinferior',
  41454. 'centinferior',
  41455. 'dollarinferior',
  41456. 'periodinferior',
  41457. 'commainferior',
  41458. 'Agravesmall',
  41459. 'Aacutesmall',
  41460. 'Acircumflexsmall',
  41461. 'Atildesmall',
  41462. 'Adieresissmall',
  41463. 'Aringsmall',
  41464. 'AEsmall',
  41465. 'Ccedillasmall',
  41466. 'Egravesmall',
  41467. 'Eacutesmall',
  41468. 'Ecircumflexsmall',
  41469. 'Edieresissmall',
  41470. 'Igravesmall',
  41471. 'Iacutesmall',
  41472. 'Icircumflexsmall',
  41473. 'Idieresissmall',
  41474. 'Ethsmall',
  41475. 'Ntildesmall',
  41476. 'Ogravesmall',
  41477. 'Oacutesmall',
  41478. 'Ocircumflexsmall',
  41479. 'Otildesmall',
  41480. 'Odieresissmall',
  41481. 'OEsmall',
  41482. 'Oslashsmall',
  41483. 'Ugravesmall',
  41484. 'Uacutesmall',
  41485. 'Ucircumflexsmall',
  41486. 'Udieresissmall',
  41487. 'Yacutesmall',
  41488. 'Thornsmall',
  41489. 'Ydieresissmall'
  41490. ];
  41491. var ExpertSubsetCharset = [
  41492. '.notdef',
  41493. 'space',
  41494. 'dollaroldstyle',
  41495. 'dollarsuperior',
  41496. 'parenleftsuperior',
  41497. 'parenrightsuperior',
  41498. 'twodotenleader',
  41499. 'onedotenleader',
  41500. 'comma',
  41501. 'hyphen',
  41502. 'period',
  41503. 'fraction',
  41504. 'zerooldstyle',
  41505. 'oneoldstyle',
  41506. 'twooldstyle',
  41507. 'threeoldstyle',
  41508. 'fouroldstyle',
  41509. 'fiveoldstyle',
  41510. 'sixoldstyle',
  41511. 'sevenoldstyle',
  41512. 'eightoldstyle',
  41513. 'nineoldstyle',
  41514. 'colon',
  41515. 'semicolon',
  41516. 'commasuperior',
  41517. 'threequartersemdash',
  41518. 'periodsuperior',
  41519. 'asuperior',
  41520. 'bsuperior',
  41521. 'centsuperior',
  41522. 'dsuperior',
  41523. 'esuperior',
  41524. 'isuperior',
  41525. 'lsuperior',
  41526. 'msuperior',
  41527. 'nsuperior',
  41528. 'osuperior',
  41529. 'rsuperior',
  41530. 'ssuperior',
  41531. 'tsuperior',
  41532. 'ff',
  41533. 'fi',
  41534. 'fl',
  41535. 'ffi',
  41536. 'ffl',
  41537. 'parenleftinferior',
  41538. 'parenrightinferior',
  41539. 'hyphensuperior',
  41540. 'colonmonetary',
  41541. 'onefitted',
  41542. 'rupiah',
  41543. 'centoldstyle',
  41544. 'figuredash',
  41545. 'hypheninferior',
  41546. 'onequarter',
  41547. 'onehalf',
  41548. 'threequarters',
  41549. 'oneeighth',
  41550. 'threeeighths',
  41551. 'fiveeighths',
  41552. 'seveneighths',
  41553. 'onethird',
  41554. 'twothirds',
  41555. 'zerosuperior',
  41556. 'onesuperior',
  41557. 'twosuperior',
  41558. 'threesuperior',
  41559. 'foursuperior',
  41560. 'fivesuperior',
  41561. 'sixsuperior',
  41562. 'sevensuperior',
  41563. 'eightsuperior',
  41564. 'ninesuperior',
  41565. 'zeroinferior',
  41566. 'oneinferior',
  41567. 'twoinferior',
  41568. 'threeinferior',
  41569. 'fourinferior',
  41570. 'fiveinferior',
  41571. 'sixinferior',
  41572. 'seveninferior',
  41573. 'eightinferior',
  41574. 'nineinferior',
  41575. 'centinferior',
  41576. 'dollarinferior',
  41577. 'periodinferior',
  41578. 'commainferior'
  41579. ];
  41580. exports.ISOAdobeCharset = ISOAdobeCharset;
  41581. exports.ExpertCharset = ExpertCharset;
  41582. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  41583. /***/ }),
  41584. /* 30 */
  41585. /***/ (function(module, exports, __w_pdfjs_require__) {
  41586. "use strict";
  41587. var sharedUtil = __w_pdfjs_require__(0);
  41588. var corePrimitives = __w_pdfjs_require__(1);
  41589. var coreStream = __w_pdfjs_require__(2);
  41590. var coreParser = __w_pdfjs_require__(6);
  41591. var Util = sharedUtil.Util;
  41592. var assert = sharedUtil.assert;
  41593. var warn = sharedUtil.warn;
  41594. var error = sharedUtil.error;
  41595. var isInt = sharedUtil.isInt;
  41596. var isString = sharedUtil.isString;
  41597. var MissingDataException = sharedUtil.MissingDataException;
  41598. var CMapCompressionType = sharedUtil.CMapCompressionType;
  41599. var isEOF = corePrimitives.isEOF;
  41600. var isName = corePrimitives.isName;
  41601. var isCmd = corePrimitives.isCmd;
  41602. var isStream = corePrimitives.isStream;
  41603. var Stream = coreStream.Stream;
  41604. var Lexer = coreParser.Lexer;
  41605. var BUILT_IN_CMAPS = [
  41606. 'Adobe-GB1-UCS2',
  41607. 'Adobe-CNS1-UCS2',
  41608. 'Adobe-Japan1-UCS2',
  41609. 'Adobe-Korea1-UCS2',
  41610. '78-EUC-H',
  41611. '78-EUC-V',
  41612. '78-H',
  41613. '78-RKSJ-H',
  41614. '78-RKSJ-V',
  41615. '78-V',
  41616. '78ms-RKSJ-H',
  41617. '78ms-RKSJ-V',
  41618. '83pv-RKSJ-H',
  41619. '90ms-RKSJ-H',
  41620. '90ms-RKSJ-V',
  41621. '90msp-RKSJ-H',
  41622. '90msp-RKSJ-V',
  41623. '90pv-RKSJ-H',
  41624. '90pv-RKSJ-V',
  41625. 'Add-H',
  41626. 'Add-RKSJ-H',
  41627. 'Add-RKSJ-V',
  41628. 'Add-V',
  41629. 'Adobe-CNS1-0',
  41630. 'Adobe-CNS1-1',
  41631. 'Adobe-CNS1-2',
  41632. 'Adobe-CNS1-3',
  41633. 'Adobe-CNS1-4',
  41634. 'Adobe-CNS1-5',
  41635. 'Adobe-CNS1-6',
  41636. 'Adobe-GB1-0',
  41637. 'Adobe-GB1-1',
  41638. 'Adobe-GB1-2',
  41639. 'Adobe-GB1-3',
  41640. 'Adobe-GB1-4',
  41641. 'Adobe-GB1-5',
  41642. 'Adobe-Japan1-0',
  41643. 'Adobe-Japan1-1',
  41644. 'Adobe-Japan1-2',
  41645. 'Adobe-Japan1-3',
  41646. 'Adobe-Japan1-4',
  41647. 'Adobe-Japan1-5',
  41648. 'Adobe-Japan1-6',
  41649. 'Adobe-Korea1-0',
  41650. 'Adobe-Korea1-1',
  41651. 'Adobe-Korea1-2',
  41652. 'B5-H',
  41653. 'B5-V',
  41654. 'B5pc-H',
  41655. 'B5pc-V',
  41656. 'CNS-EUC-H',
  41657. 'CNS-EUC-V',
  41658. 'CNS1-H',
  41659. 'CNS1-V',
  41660. 'CNS2-H',
  41661. 'CNS2-V',
  41662. 'ETHK-B5-H',
  41663. 'ETHK-B5-V',
  41664. 'ETen-B5-H',
  41665. 'ETen-B5-V',
  41666. 'ETenms-B5-H',
  41667. 'ETenms-B5-V',
  41668. 'EUC-H',
  41669. 'EUC-V',
  41670. 'Ext-H',
  41671. 'Ext-RKSJ-H',
  41672. 'Ext-RKSJ-V',
  41673. 'Ext-V',
  41674. 'GB-EUC-H',
  41675. 'GB-EUC-V',
  41676. 'GB-H',
  41677. 'GB-V',
  41678. 'GBK-EUC-H',
  41679. 'GBK-EUC-V',
  41680. 'GBK2K-H',
  41681. 'GBK2K-V',
  41682. 'GBKp-EUC-H',
  41683. 'GBKp-EUC-V',
  41684. 'GBT-EUC-H',
  41685. 'GBT-EUC-V',
  41686. 'GBT-H',
  41687. 'GBT-V',
  41688. 'GBTpc-EUC-H',
  41689. 'GBTpc-EUC-V',
  41690. 'GBpc-EUC-H',
  41691. 'GBpc-EUC-V',
  41692. 'H',
  41693. 'HKdla-B5-H',
  41694. 'HKdla-B5-V',
  41695. 'HKdlb-B5-H',
  41696. 'HKdlb-B5-V',
  41697. 'HKgccs-B5-H',
  41698. 'HKgccs-B5-V',
  41699. 'HKm314-B5-H',
  41700. 'HKm314-B5-V',
  41701. 'HKm471-B5-H',
  41702. 'HKm471-B5-V',
  41703. 'HKscs-B5-H',
  41704. 'HKscs-B5-V',
  41705. 'Hankaku',
  41706. 'Hiragana',
  41707. 'KSC-EUC-H',
  41708. 'KSC-EUC-V',
  41709. 'KSC-H',
  41710. 'KSC-Johab-H',
  41711. 'KSC-Johab-V',
  41712. 'KSC-V',
  41713. 'KSCms-UHC-H',
  41714. 'KSCms-UHC-HW-H',
  41715. 'KSCms-UHC-HW-V',
  41716. 'KSCms-UHC-V',
  41717. 'KSCpc-EUC-H',
  41718. 'KSCpc-EUC-V',
  41719. 'Katakana',
  41720. 'NWP-H',
  41721. 'NWP-V',
  41722. 'RKSJ-H',
  41723. 'RKSJ-V',
  41724. 'Roman',
  41725. 'UniCNS-UCS2-H',
  41726. 'UniCNS-UCS2-V',
  41727. 'UniCNS-UTF16-H',
  41728. 'UniCNS-UTF16-V',
  41729. 'UniCNS-UTF32-H',
  41730. 'UniCNS-UTF32-V',
  41731. 'UniCNS-UTF8-H',
  41732. 'UniCNS-UTF8-V',
  41733. 'UniGB-UCS2-H',
  41734. 'UniGB-UCS2-V',
  41735. 'UniGB-UTF16-H',
  41736. 'UniGB-UTF16-V',
  41737. 'UniGB-UTF32-H',
  41738. 'UniGB-UTF32-V',
  41739. 'UniGB-UTF8-H',
  41740. 'UniGB-UTF8-V',
  41741. 'UniJIS-UCS2-H',
  41742. 'UniJIS-UCS2-HW-H',
  41743. 'UniJIS-UCS2-HW-V',
  41744. 'UniJIS-UCS2-V',
  41745. 'UniJIS-UTF16-H',
  41746. 'UniJIS-UTF16-V',
  41747. 'UniJIS-UTF32-H',
  41748. 'UniJIS-UTF32-V',
  41749. 'UniJIS-UTF8-H',
  41750. 'UniJIS-UTF8-V',
  41751. 'UniJIS2004-UTF16-H',
  41752. 'UniJIS2004-UTF16-V',
  41753. 'UniJIS2004-UTF32-H',
  41754. 'UniJIS2004-UTF32-V',
  41755. 'UniJIS2004-UTF8-H',
  41756. 'UniJIS2004-UTF8-V',
  41757. 'UniJISPro-UCS2-HW-V',
  41758. 'UniJISPro-UCS2-V',
  41759. 'UniJISPro-UTF8-V',
  41760. 'UniJISX0213-UTF32-H',
  41761. 'UniJISX0213-UTF32-V',
  41762. 'UniJISX02132004-UTF32-H',
  41763. 'UniJISX02132004-UTF32-V',
  41764. 'UniKS-UCS2-H',
  41765. 'UniKS-UCS2-V',
  41766. 'UniKS-UTF16-H',
  41767. 'UniKS-UTF16-V',
  41768. 'UniKS-UTF32-H',
  41769. 'UniKS-UTF32-V',
  41770. 'UniKS-UTF8-H',
  41771. 'UniKS-UTF8-V',
  41772. 'V',
  41773. 'WP-Symbol'
  41774. ];
  41775. var CMap = function CMapClosure() {
  41776. function CMap(builtInCMap) {
  41777. this.codespaceRanges = [
  41778. [],
  41779. [],
  41780. [],
  41781. []
  41782. ];
  41783. this.numCodespaceRanges = 0;
  41784. this._map = [];
  41785. this.name = '';
  41786. this.vertical = false;
  41787. this.useCMap = null;
  41788. this.builtInCMap = builtInCMap;
  41789. }
  41790. CMap.prototype = {
  41791. addCodespaceRange: function (n, low, high) {
  41792. this.codespaceRanges[n - 1].push(low, high);
  41793. this.numCodespaceRanges++;
  41794. },
  41795. mapCidRange: function (low, high, dstLow) {
  41796. while (low <= high) {
  41797. this._map[low++] = dstLow++;
  41798. }
  41799. },
  41800. mapBfRange: function (low, high, dstLow) {
  41801. var lastByte = dstLow.length - 1;
  41802. while (low <= high) {
  41803. this._map[low++] = dstLow;
  41804. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  41805. }
  41806. },
  41807. mapBfRangeToArray: function (low, high, array) {
  41808. var i = 0, ii = array.length;
  41809. while (low <= high && i < ii) {
  41810. this._map[low] = array[i++];
  41811. ++low;
  41812. }
  41813. },
  41814. mapOne: function (src, dst) {
  41815. this._map[src] = dst;
  41816. },
  41817. lookup: function (code) {
  41818. return this._map[code];
  41819. },
  41820. contains: function (code) {
  41821. return this._map[code] !== undefined;
  41822. },
  41823. forEach: function (callback) {
  41824. var map = this._map;
  41825. var length = map.length;
  41826. var i;
  41827. if (length <= 0x10000) {
  41828. for (i = 0; i < length; i++) {
  41829. if (map[i] !== undefined) {
  41830. callback(i, map[i]);
  41831. }
  41832. }
  41833. } else {
  41834. for (i in this._map) {
  41835. callback(i, map[i]);
  41836. }
  41837. }
  41838. },
  41839. charCodeOf: function (value) {
  41840. return this._map.indexOf(value);
  41841. },
  41842. getMap: function () {
  41843. return this._map;
  41844. },
  41845. readCharCode: function (str, offset, out) {
  41846. var c = 0;
  41847. var codespaceRanges = this.codespaceRanges;
  41848. var codespaceRangesLen = this.codespaceRanges.length;
  41849. for (var n = 0; n < codespaceRangesLen; n++) {
  41850. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41851. var codespaceRange = codespaceRanges[n];
  41852. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41853. var low = codespaceRange[k++];
  41854. var high = codespaceRange[k++];
  41855. if (c >= low && c <= high) {
  41856. out.charcode = c;
  41857. out.length = n + 1;
  41858. return;
  41859. }
  41860. }
  41861. }
  41862. out.charcode = 0;
  41863. out.length = 1;
  41864. },
  41865. get length() {
  41866. return this._map.length;
  41867. },
  41868. get isIdentityCMap() {
  41869. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41870. return false;
  41871. }
  41872. if (this._map.length !== 0x10000) {
  41873. return false;
  41874. }
  41875. for (var i = 0; i < 0x10000; i++) {
  41876. if (this._map[i] !== i) {
  41877. return false;
  41878. }
  41879. }
  41880. return true;
  41881. }
  41882. };
  41883. return CMap;
  41884. }();
  41885. var IdentityCMap = function IdentityCMapClosure() {
  41886. function IdentityCMap(vertical, n) {
  41887. CMap.call(this);
  41888. this.vertical = vertical;
  41889. this.addCodespaceRange(n, 0, 0xffff);
  41890. }
  41891. Util.inherit(IdentityCMap, CMap, {});
  41892. IdentityCMap.prototype = {
  41893. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41894. mapCidRange: function (low, high, dstLow) {
  41895. error('should not call mapCidRange');
  41896. },
  41897. mapBfRange: function (low, high, dstLow) {
  41898. error('should not call mapBfRange');
  41899. },
  41900. mapBfRangeToArray: function (low, high, array) {
  41901. error('should not call mapBfRangeToArray');
  41902. },
  41903. mapOne: function (src, dst) {
  41904. error('should not call mapCidOne');
  41905. },
  41906. lookup: function (code) {
  41907. return isInt(code) && code <= 0xffff ? code : undefined;
  41908. },
  41909. contains: function (code) {
  41910. return isInt(code) && code <= 0xffff;
  41911. },
  41912. forEach: function (callback) {
  41913. for (var i = 0; i <= 0xffff; i++) {
  41914. callback(i, i);
  41915. }
  41916. },
  41917. charCodeOf: function (value) {
  41918. return isInt(value) && value <= 0xffff ? value : -1;
  41919. },
  41920. getMap: function () {
  41921. var map = new Array(0x10000);
  41922. for (var i = 0; i <= 0xffff; i++) {
  41923. map[i] = i;
  41924. }
  41925. return map;
  41926. },
  41927. readCharCode: CMap.prototype.readCharCode,
  41928. get length() {
  41929. return 0x10000;
  41930. },
  41931. get isIdentityCMap() {
  41932. error('should not access .isIdentityCMap');
  41933. }
  41934. };
  41935. return IdentityCMap;
  41936. }();
  41937. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41938. function hexToInt(a, size) {
  41939. var n = 0;
  41940. for (var i = 0; i <= size; i++) {
  41941. n = n << 8 | a[i];
  41942. }
  41943. return n >>> 0;
  41944. }
  41945. function hexToStr(a, size) {
  41946. if (size === 1) {
  41947. return String.fromCharCode(a[0], a[1]);
  41948. }
  41949. if (size === 3) {
  41950. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41951. }
  41952. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41953. }
  41954. function addHex(a, b, size) {
  41955. var c = 0;
  41956. for (var i = size; i >= 0; i--) {
  41957. c += a[i] + b[i];
  41958. a[i] = c & 255;
  41959. c >>= 8;
  41960. }
  41961. }
  41962. function incHex(a, size) {
  41963. var c = 1;
  41964. for (var i = size; i >= 0 && c > 0; i--) {
  41965. c += a[i];
  41966. a[i] = c & 255;
  41967. c >>= 8;
  41968. }
  41969. }
  41970. var MAX_NUM_SIZE = 16;
  41971. var MAX_ENCODED_NUM_SIZE = 19;
  41972. function BinaryCMapStream(data) {
  41973. this.buffer = data;
  41974. this.pos = 0;
  41975. this.end = data.length;
  41976. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41977. }
  41978. BinaryCMapStream.prototype = {
  41979. readByte: function () {
  41980. if (this.pos >= this.end) {
  41981. return -1;
  41982. }
  41983. return this.buffer[this.pos++];
  41984. },
  41985. readNumber: function () {
  41986. var n = 0;
  41987. var last;
  41988. do {
  41989. var b = this.readByte();
  41990. if (b < 0) {
  41991. error('unexpected EOF in bcmap');
  41992. }
  41993. last = !(b & 0x80);
  41994. n = n << 7 | b & 0x7F;
  41995. } while (!last);
  41996. return n;
  41997. },
  41998. readSigned: function () {
  41999. var n = this.readNumber();
  42000. return n & 1 ? ~(n >>> 1) : n >>> 1;
  42001. },
  42002. readHex: function (num, size) {
  42003. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  42004. this.pos += size + 1;
  42005. },
  42006. readHexNumber: function (num, size) {
  42007. var last;
  42008. var stack = this.tmpBuf, sp = 0;
  42009. do {
  42010. var b = this.readByte();
  42011. if (b < 0) {
  42012. error('unexpected EOF in bcmap');
  42013. }
  42014. last = !(b & 0x80);
  42015. stack[sp++] = b & 0x7F;
  42016. } while (!last);
  42017. var i = size, buffer = 0, bufferSize = 0;
  42018. while (i >= 0) {
  42019. while (bufferSize < 8 && stack.length > 0) {
  42020. buffer = stack[--sp] << bufferSize | buffer;
  42021. bufferSize += 7;
  42022. }
  42023. num[i] = buffer & 255;
  42024. i--;
  42025. buffer >>= 8;
  42026. bufferSize -= 8;
  42027. }
  42028. },
  42029. readHexSigned: function (num, size) {
  42030. this.readHexNumber(num, size);
  42031. var sign = num[size] & 1 ? 255 : 0;
  42032. var c = 0;
  42033. for (var i = 0; i <= size; i++) {
  42034. c = (c & 1) << 8 | num[i];
  42035. num[i] = c >> 1 ^ sign;
  42036. }
  42037. },
  42038. readString: function () {
  42039. var len = this.readNumber();
  42040. var s = '';
  42041. for (var i = 0; i < len; i++) {
  42042. s += String.fromCharCode(this.readNumber());
  42043. }
  42044. return s;
  42045. }
  42046. };
  42047. function processBinaryCMap(data, cMap, extend) {
  42048. return new Promise(function (resolve, reject) {
  42049. var stream = new BinaryCMapStream(data);
  42050. var header = stream.readByte();
  42051. cMap.vertical = !!(header & 1);
  42052. var useCMap = null;
  42053. var start = new Uint8Array(MAX_NUM_SIZE);
  42054. var end = new Uint8Array(MAX_NUM_SIZE);
  42055. var char = new Uint8Array(MAX_NUM_SIZE);
  42056. var charCode = new Uint8Array(MAX_NUM_SIZE);
  42057. var tmp = new Uint8Array(MAX_NUM_SIZE);
  42058. var code;
  42059. var b;
  42060. while ((b = stream.readByte()) >= 0) {
  42061. var type = b >> 5;
  42062. if (type === 7) {
  42063. switch (b & 0x1F) {
  42064. case 0:
  42065. stream.readString();
  42066. break;
  42067. case 1:
  42068. useCMap = stream.readString();
  42069. break;
  42070. }
  42071. continue;
  42072. }
  42073. var sequence = !!(b & 0x10);
  42074. var dataSize = b & 15;
  42075. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42076. var ucs2DataSize = 1;
  42077. var subitemsCount = stream.readNumber();
  42078. var i;
  42079. switch (type) {
  42080. case 0:
  42081. stream.readHex(start, dataSize);
  42082. stream.readHexNumber(end, dataSize);
  42083. addHex(end, start, dataSize);
  42084. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42085. for (i = 1; i < subitemsCount; i++) {
  42086. incHex(end, dataSize);
  42087. stream.readHexNumber(start, dataSize);
  42088. addHex(start, end, dataSize);
  42089. stream.readHexNumber(end, dataSize);
  42090. addHex(end, start, dataSize);
  42091. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42092. }
  42093. break;
  42094. case 1:
  42095. stream.readHex(start, dataSize);
  42096. stream.readHexNumber(end, dataSize);
  42097. addHex(end, start, dataSize);
  42098. code = stream.readNumber();
  42099. for (i = 1; i < subitemsCount; i++) {
  42100. incHex(end, dataSize);
  42101. stream.readHexNumber(start, dataSize);
  42102. addHex(start, end, dataSize);
  42103. stream.readHexNumber(end, dataSize);
  42104. addHex(end, start, dataSize);
  42105. code = stream.readNumber();
  42106. }
  42107. break;
  42108. case 2:
  42109. stream.readHex(char, dataSize);
  42110. code = stream.readNumber();
  42111. cMap.mapOne(hexToInt(char, dataSize), code);
  42112. for (i = 1; i < subitemsCount; i++) {
  42113. incHex(char, dataSize);
  42114. if (!sequence) {
  42115. stream.readHexNumber(tmp, dataSize);
  42116. addHex(char, tmp, dataSize);
  42117. }
  42118. code = stream.readSigned() + (code + 1);
  42119. cMap.mapOne(hexToInt(char, dataSize), code);
  42120. }
  42121. break;
  42122. case 3:
  42123. stream.readHex(start, dataSize);
  42124. stream.readHexNumber(end, dataSize);
  42125. addHex(end, start, dataSize);
  42126. code = stream.readNumber();
  42127. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42128. for (i = 1; i < subitemsCount; i++) {
  42129. incHex(end, dataSize);
  42130. if (!sequence) {
  42131. stream.readHexNumber(start, dataSize);
  42132. addHex(start, end, dataSize);
  42133. } else {
  42134. start.set(end);
  42135. }
  42136. stream.readHexNumber(end, dataSize);
  42137. addHex(end, start, dataSize);
  42138. code = stream.readNumber();
  42139. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42140. }
  42141. break;
  42142. case 4:
  42143. stream.readHex(char, ucs2DataSize);
  42144. stream.readHex(charCode, dataSize);
  42145. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42146. for (i = 1; i < subitemsCount; i++) {
  42147. incHex(char, ucs2DataSize);
  42148. if (!sequence) {
  42149. stream.readHexNumber(tmp, ucs2DataSize);
  42150. addHex(char, tmp, ucs2DataSize);
  42151. }
  42152. incHex(charCode, dataSize);
  42153. stream.readHexSigned(tmp, dataSize);
  42154. addHex(charCode, tmp, dataSize);
  42155. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42156. }
  42157. break;
  42158. case 5:
  42159. stream.readHex(start, ucs2DataSize);
  42160. stream.readHexNumber(end, ucs2DataSize);
  42161. addHex(end, start, ucs2DataSize);
  42162. stream.readHex(charCode, dataSize);
  42163. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42164. for (i = 1; i < subitemsCount; i++) {
  42165. incHex(end, ucs2DataSize);
  42166. if (!sequence) {
  42167. stream.readHexNumber(start, ucs2DataSize);
  42168. addHex(start, end, ucs2DataSize);
  42169. } else {
  42170. start.set(end);
  42171. }
  42172. stream.readHexNumber(end, ucs2DataSize);
  42173. addHex(end, start, ucs2DataSize);
  42174. stream.readHex(charCode, dataSize);
  42175. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42176. }
  42177. break;
  42178. default:
  42179. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  42180. return;
  42181. }
  42182. }
  42183. if (useCMap) {
  42184. resolve(extend(useCMap));
  42185. return;
  42186. }
  42187. resolve(cMap);
  42188. });
  42189. }
  42190. function BinaryCMapReader() {
  42191. }
  42192. BinaryCMapReader.prototype = { process: processBinaryCMap };
  42193. return BinaryCMapReader;
  42194. }();
  42195. var CMapFactory = function CMapFactoryClosure() {
  42196. function strToInt(str) {
  42197. var a = 0;
  42198. for (var i = 0; i < str.length; i++) {
  42199. a = a << 8 | str.charCodeAt(i);
  42200. }
  42201. return a >>> 0;
  42202. }
  42203. function expectString(obj) {
  42204. if (!isString(obj)) {
  42205. error('Malformed CMap: expected string.');
  42206. }
  42207. }
  42208. function expectInt(obj) {
  42209. if (!isInt(obj)) {
  42210. error('Malformed CMap: expected int.');
  42211. }
  42212. }
  42213. function parseBfChar(cMap, lexer) {
  42214. while (true) {
  42215. var obj = lexer.getObj();
  42216. if (isEOF(obj)) {
  42217. break;
  42218. }
  42219. if (isCmd(obj, 'endbfchar')) {
  42220. return;
  42221. }
  42222. expectString(obj);
  42223. var src = strToInt(obj);
  42224. obj = lexer.getObj();
  42225. expectString(obj);
  42226. var dst = obj;
  42227. cMap.mapOne(src, dst);
  42228. }
  42229. }
  42230. function parseBfRange(cMap, lexer) {
  42231. while (true) {
  42232. var obj = lexer.getObj();
  42233. if (isEOF(obj)) {
  42234. break;
  42235. }
  42236. if (isCmd(obj, 'endbfrange')) {
  42237. return;
  42238. }
  42239. expectString(obj);
  42240. var low = strToInt(obj);
  42241. obj = lexer.getObj();
  42242. expectString(obj);
  42243. var high = strToInt(obj);
  42244. obj = lexer.getObj();
  42245. if (isInt(obj) || isString(obj)) {
  42246. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42247. cMap.mapBfRange(low, high, dstLow);
  42248. } else if (isCmd(obj, '[')) {
  42249. obj = lexer.getObj();
  42250. var array = [];
  42251. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42252. array.push(obj);
  42253. obj = lexer.getObj();
  42254. }
  42255. cMap.mapBfRangeToArray(low, high, array);
  42256. } else {
  42257. break;
  42258. }
  42259. }
  42260. error('Invalid bf range.');
  42261. }
  42262. function parseCidChar(cMap, lexer) {
  42263. while (true) {
  42264. var obj = lexer.getObj();
  42265. if (isEOF(obj)) {
  42266. break;
  42267. }
  42268. if (isCmd(obj, 'endcidchar')) {
  42269. return;
  42270. }
  42271. expectString(obj);
  42272. var src = strToInt(obj);
  42273. obj = lexer.getObj();
  42274. expectInt(obj);
  42275. var dst = obj;
  42276. cMap.mapOne(src, dst);
  42277. }
  42278. }
  42279. function parseCidRange(cMap, lexer) {
  42280. while (true) {
  42281. var obj = lexer.getObj();
  42282. if (isEOF(obj)) {
  42283. break;
  42284. }
  42285. if (isCmd(obj, 'endcidrange')) {
  42286. return;
  42287. }
  42288. expectString(obj);
  42289. var low = strToInt(obj);
  42290. obj = lexer.getObj();
  42291. expectString(obj);
  42292. var high = strToInt(obj);
  42293. obj = lexer.getObj();
  42294. expectInt(obj);
  42295. var dstLow = obj;
  42296. cMap.mapCidRange(low, high, dstLow);
  42297. }
  42298. }
  42299. function parseCodespaceRange(cMap, lexer) {
  42300. while (true) {
  42301. var obj = lexer.getObj();
  42302. if (isEOF(obj)) {
  42303. break;
  42304. }
  42305. if (isCmd(obj, 'endcodespacerange')) {
  42306. return;
  42307. }
  42308. if (!isString(obj)) {
  42309. break;
  42310. }
  42311. var low = strToInt(obj);
  42312. obj = lexer.getObj();
  42313. if (!isString(obj)) {
  42314. break;
  42315. }
  42316. var high = strToInt(obj);
  42317. cMap.addCodespaceRange(obj.length, low, high);
  42318. }
  42319. error('Invalid codespace range.');
  42320. }
  42321. function parseWMode(cMap, lexer) {
  42322. var obj = lexer.getObj();
  42323. if (isInt(obj)) {
  42324. cMap.vertical = !!obj;
  42325. }
  42326. }
  42327. function parseCMapName(cMap, lexer) {
  42328. var obj = lexer.getObj();
  42329. if (isName(obj) && isString(obj.name)) {
  42330. cMap.name = obj.name;
  42331. }
  42332. }
  42333. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  42334. var previous;
  42335. var embededUseCMap;
  42336. objLoop:
  42337. while (true) {
  42338. try {
  42339. var obj = lexer.getObj();
  42340. if (isEOF(obj)) {
  42341. break;
  42342. } else if (isName(obj)) {
  42343. if (obj.name === 'WMode') {
  42344. parseWMode(cMap, lexer);
  42345. } else if (obj.name === 'CMapName') {
  42346. parseCMapName(cMap, lexer);
  42347. }
  42348. previous = obj;
  42349. } else if (isCmd(obj)) {
  42350. switch (obj.cmd) {
  42351. case 'endcmap':
  42352. break objLoop;
  42353. case 'usecmap':
  42354. if (isName(previous)) {
  42355. embededUseCMap = previous.name;
  42356. }
  42357. break;
  42358. case 'begincodespacerange':
  42359. parseCodespaceRange(cMap, lexer);
  42360. break;
  42361. case 'beginbfchar':
  42362. parseBfChar(cMap, lexer);
  42363. break;
  42364. case 'begincidchar':
  42365. parseCidChar(cMap, lexer);
  42366. break;
  42367. case 'beginbfrange':
  42368. parseBfRange(cMap, lexer);
  42369. break;
  42370. case 'begincidrange':
  42371. parseCidRange(cMap, lexer);
  42372. break;
  42373. }
  42374. }
  42375. } catch (ex) {
  42376. if (ex instanceof MissingDataException) {
  42377. throw ex;
  42378. }
  42379. warn('Invalid cMap data: ' + ex);
  42380. continue;
  42381. }
  42382. }
  42383. if (!useCMap && embededUseCMap) {
  42384. useCMap = embededUseCMap;
  42385. }
  42386. if (useCMap) {
  42387. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  42388. }
  42389. return Promise.resolve(cMap);
  42390. }
  42391. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  42392. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  42393. cMap.useCMap = newCMap;
  42394. if (cMap.numCodespaceRanges === 0) {
  42395. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42396. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42397. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42398. }
  42399. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42400. }
  42401. cMap.useCMap.forEach(function (key, value) {
  42402. if (!cMap.contains(key)) {
  42403. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42404. }
  42405. });
  42406. return cMap;
  42407. });
  42408. }
  42409. function createBuiltInCMap(name, fetchBuiltInCMap) {
  42410. if (name === 'Identity-H') {
  42411. return Promise.resolve(new IdentityCMap(false, 2));
  42412. } else if (name === 'Identity-V') {
  42413. return Promise.resolve(new IdentityCMap(true, 2));
  42414. }
  42415. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42416. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42417. }
  42418. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  42419. return fetchBuiltInCMap(name).then(function (data) {
  42420. var cMapData = data.cMapData, compressionType = data.compressionType;
  42421. var cMap = new CMap(true);
  42422. if (compressionType === CMapCompressionType.BINARY) {
  42423. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  42424. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  42425. });
  42426. }
  42427. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  42428. var lexer = new Lexer(new Stream(cMapData));
  42429. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  42430. });
  42431. }
  42432. return {
  42433. create: function (params) {
  42434. var encoding = params.encoding;
  42435. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  42436. var useCMap = params.useCMap;
  42437. if (isName(encoding)) {
  42438. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  42439. } else if (isStream(encoding)) {
  42440. var cMap = new CMap();
  42441. var lexer = new Lexer(encoding);
  42442. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  42443. if (parsedCMap.isIdentityCMap) {
  42444. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  42445. }
  42446. return parsedCMap;
  42447. });
  42448. }
  42449. return Promise.reject(new Error('Encoding required.'));
  42450. }
  42451. };
  42452. }();
  42453. exports.CMap = CMap;
  42454. exports.CMapFactory = CMapFactory;
  42455. exports.IdentityCMap = IdentityCMap;
  42456. /***/ }),
  42457. /* 31 */
  42458. /***/ (function(module, exports, __w_pdfjs_require__) {
  42459. "use strict";
  42460. var sharedUtil = __w_pdfjs_require__(0);
  42461. var corePrimitives = __w_pdfjs_require__(1);
  42462. var coreStream = __w_pdfjs_require__(2);
  42463. var coreObj = __w_pdfjs_require__(19);
  42464. var coreParser = __w_pdfjs_require__(6);
  42465. var coreCrypto = __w_pdfjs_require__(16);
  42466. var coreEvaluator = __w_pdfjs_require__(17);
  42467. var coreAnnotation = __w_pdfjs_require__(27);
  42468. var MissingDataException = sharedUtil.MissingDataException;
  42469. var Util = sharedUtil.Util;
  42470. var assert = sharedUtil.assert;
  42471. var error = sharedUtil.error;
  42472. var info = sharedUtil.info;
  42473. var isArray = sharedUtil.isArray;
  42474. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42475. var isNum = sharedUtil.isNum;
  42476. var isString = sharedUtil.isString;
  42477. var shadow = sharedUtil.shadow;
  42478. var stringToBytes = sharedUtil.stringToBytes;
  42479. var stringToPDFString = sharedUtil.stringToPDFString;
  42480. var warn = sharedUtil.warn;
  42481. var isSpace = sharedUtil.isSpace;
  42482. var Dict = corePrimitives.Dict;
  42483. var isDict = corePrimitives.isDict;
  42484. var isName = corePrimitives.isName;
  42485. var isStream = corePrimitives.isStream;
  42486. var NullStream = coreStream.NullStream;
  42487. var Stream = coreStream.Stream;
  42488. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42489. var Catalog = coreObj.Catalog;
  42490. var ObjectLoader = coreObj.ObjectLoader;
  42491. var XRef = coreObj.XRef;
  42492. var Linearization = coreParser.Linearization;
  42493. var calculateMD5 = coreCrypto.calculateMD5;
  42494. var OperatorList = coreEvaluator.OperatorList;
  42495. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42496. var Annotation = coreAnnotation.Annotation;
  42497. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42498. var Page = function PageClosure() {
  42499. var DEFAULT_USER_UNIT = 1.0;
  42500. var LETTER_SIZE_MEDIABOX = [
  42501. 0,
  42502. 0,
  42503. 612,
  42504. 792
  42505. ];
  42506. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  42507. this.pdfManager = pdfManager;
  42508. this.pageIndex = pageIndex;
  42509. this.pageDict = pageDict;
  42510. this.xref = xref;
  42511. this.ref = ref;
  42512. this.fontCache = fontCache;
  42513. this.builtInCMapCache = builtInCMapCache;
  42514. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42515. this.resourcesPromise = null;
  42516. var uniquePrefix = 'p' + this.pageIndex + '_';
  42517. var idCounters = { obj: 0 };
  42518. this.idFactory = {
  42519. createObjId: function () {
  42520. return uniquePrefix + ++idCounters.obj;
  42521. }
  42522. };
  42523. }
  42524. Page.prototype = {
  42525. getPageProp: function Page_getPageProp(key) {
  42526. return this.pageDict.get(key);
  42527. },
  42528. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42529. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42530. var MAX_LOOP_COUNT = 100;
  42531. getArray = getArray || false;
  42532. while (dict) {
  42533. var value = getArray ? dict.getArray(key) : dict.get(key);
  42534. if (value) {
  42535. if (!valueArray) {
  42536. valueArray = [];
  42537. }
  42538. valueArray.push(value);
  42539. }
  42540. if (++loopCount > MAX_LOOP_COUNT) {
  42541. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42542. break;
  42543. }
  42544. dict = dict.get('Parent');
  42545. }
  42546. if (!valueArray) {
  42547. return Dict.empty;
  42548. }
  42549. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42550. return valueArray[0];
  42551. }
  42552. return Dict.merge(this.xref, valueArray);
  42553. },
  42554. get content() {
  42555. return this.getPageProp('Contents');
  42556. },
  42557. get resources() {
  42558. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  42559. },
  42560. get mediaBox() {
  42561. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  42562. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  42563. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  42564. }
  42565. return shadow(this, 'mediaBox', mediaBox);
  42566. },
  42567. get cropBox() {
  42568. var cropBox = this.getInheritedPageProp('CropBox', true);
  42569. if (!isArray(cropBox) || cropBox.length !== 4) {
  42570. return shadow(this, 'cropBox', this.mediaBox);
  42571. }
  42572. return shadow(this, 'cropBox', cropBox);
  42573. },
  42574. get userUnit() {
  42575. var obj = this.getPageProp('UserUnit');
  42576. if (!isNum(obj) || obj <= 0) {
  42577. obj = DEFAULT_USER_UNIT;
  42578. }
  42579. return shadow(this, 'userUnit', obj);
  42580. },
  42581. get view() {
  42582. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  42583. if (mediaBox === cropBox) {
  42584. return shadow(this, 'view', mediaBox);
  42585. }
  42586. var intersection = Util.intersect(cropBox, mediaBox);
  42587. return shadow(this, 'view', intersection || mediaBox);
  42588. },
  42589. get rotate() {
  42590. var rotate = this.getInheritedPageProp('Rotate') || 0;
  42591. if (rotate % 90 !== 0) {
  42592. rotate = 0;
  42593. } else if (rotate >= 360) {
  42594. rotate = rotate % 360;
  42595. } else if (rotate < 0) {
  42596. rotate = (rotate % 360 + 360) % 360;
  42597. }
  42598. return shadow(this, 'rotate', rotate);
  42599. },
  42600. getContentStream: function Page_getContentStream() {
  42601. var content = this.content;
  42602. var stream;
  42603. if (isArray(content)) {
  42604. var xref = this.xref;
  42605. var i, n = content.length;
  42606. var streams = [];
  42607. for (i = 0; i < n; ++i) {
  42608. streams.push(xref.fetchIfRef(content[i]));
  42609. }
  42610. stream = new StreamsSequenceStream(streams);
  42611. } else if (isStream(content)) {
  42612. stream = content;
  42613. } else {
  42614. stream = new NullStream();
  42615. }
  42616. return stream;
  42617. },
  42618. loadResources: function Page_loadResources(keys) {
  42619. if (!this.resourcesPromise) {
  42620. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  42621. }
  42622. return this.resourcesPromise.then(function resourceSuccess() {
  42623. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  42624. return objectLoader.load();
  42625. }.bind(this));
  42626. },
  42627. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  42628. var self = this;
  42629. var pdfManager = this.pdfManager;
  42630. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42631. var resourcesPromise = this.loadResources([
  42632. 'ExtGState',
  42633. 'ColorSpace',
  42634. 'Pattern',
  42635. 'Shading',
  42636. 'XObject',
  42637. 'Font'
  42638. ]);
  42639. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  42640. var dataPromises = Promise.all([
  42641. contentStreamPromise,
  42642. resourcesPromise
  42643. ]);
  42644. var pageListPromise = dataPromises.then(function (data) {
  42645. var contentStream = data[0];
  42646. var opList = new OperatorList(intent, handler, self.pageIndex);
  42647. handler.send('StartRenderPage', {
  42648. transparency: partialEvaluator.hasBlendModes(self.resources),
  42649. pageIndex: self.pageIndex,
  42650. intent: intent
  42651. });
  42652. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  42653. return opList;
  42654. });
  42655. });
  42656. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  42657. return Promise.all([
  42658. pageListPromise,
  42659. annotationsPromise
  42660. ]).then(function (datas) {
  42661. var pageOpList = datas[0];
  42662. var annotations = datas[1];
  42663. if (annotations.length === 0) {
  42664. pageOpList.flush(true);
  42665. return pageOpList;
  42666. }
  42667. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  42668. return annotationsReadyPromise.then(function () {
  42669. pageOpList.flush(true);
  42670. return pageOpList;
  42671. });
  42672. });
  42673. },
  42674. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  42675. var handler = {
  42676. on: function nullHandlerOn() {
  42677. },
  42678. send: function nullHandlerSend() {
  42679. }
  42680. };
  42681. var self = this;
  42682. var pdfManager = this.pdfManager;
  42683. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42684. var resourcesPromise = this.loadResources([
  42685. 'ExtGState',
  42686. 'XObject',
  42687. 'Font'
  42688. ]);
  42689. var dataPromises = Promise.all([
  42690. contentStreamPromise,
  42691. resourcesPromise
  42692. ]);
  42693. return dataPromises.then(function (data) {
  42694. var contentStream = data[0];
  42695. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  42696. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  42697. });
  42698. },
  42699. getAnnotationsData: function Page_getAnnotationsData(intent) {
  42700. var annotations = this.annotations;
  42701. var annotationsData = [];
  42702. for (var i = 0, n = annotations.length; i < n; ++i) {
  42703. if (intent) {
  42704. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  42705. continue;
  42706. }
  42707. }
  42708. annotationsData.push(annotations[i].data);
  42709. }
  42710. return annotationsData;
  42711. },
  42712. get annotations() {
  42713. var annotations = [];
  42714. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  42715. var annotationFactory = new AnnotationFactory();
  42716. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  42717. var annotationRef = annotationRefs[i];
  42718. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  42719. if (annotation) {
  42720. annotations.push(annotation);
  42721. }
  42722. }
  42723. return shadow(this, 'annotations', annotations);
  42724. }
  42725. };
  42726. return Page;
  42727. }();
  42728. var PDFDocument = function PDFDocumentClosure() {
  42729. var FINGERPRINT_FIRST_BYTES = 1024;
  42730. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  42731. function PDFDocument(pdfManager, arg) {
  42732. var stream;
  42733. if (isStream(arg)) {
  42734. stream = arg;
  42735. } else if (isArrayBuffer(arg)) {
  42736. stream = new Stream(arg);
  42737. } else {
  42738. error('PDFDocument: Unknown argument type');
  42739. }
  42740. assert(stream.length > 0, 'stream must have data');
  42741. this.pdfManager = pdfManager;
  42742. this.stream = stream;
  42743. this.xref = new XRef(stream, pdfManager);
  42744. }
  42745. function find(stream, needle, limit, backwards) {
  42746. var pos = stream.pos;
  42747. var end = stream.end;
  42748. var strBuf = [];
  42749. if (pos + limit > end) {
  42750. limit = end - pos;
  42751. }
  42752. for (var n = 0; n < limit; ++n) {
  42753. strBuf.push(String.fromCharCode(stream.getByte()));
  42754. }
  42755. var str = strBuf.join('');
  42756. stream.pos = pos;
  42757. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  42758. if (index === -1) {
  42759. return false;
  42760. }
  42761. stream.pos += index;
  42762. return true;
  42763. }
  42764. var DocumentInfoValidators = {
  42765. get entries() {
  42766. return shadow(this, 'entries', {
  42767. Title: isString,
  42768. Author: isString,
  42769. Subject: isString,
  42770. Keywords: isString,
  42771. Creator: isString,
  42772. Producer: isString,
  42773. CreationDate: isString,
  42774. ModDate: isString,
  42775. Trapped: isName
  42776. });
  42777. }
  42778. };
  42779. PDFDocument.prototype = {
  42780. parse: function PDFDocument_parse(recoveryMode) {
  42781. this.setup(recoveryMode);
  42782. var version = this.catalog.catDict.get('Version');
  42783. if (isName(version)) {
  42784. this.pdfFormatVersion = version.name;
  42785. }
  42786. try {
  42787. this.acroForm = this.catalog.catDict.get('AcroForm');
  42788. if (this.acroForm) {
  42789. this.xfa = this.acroForm.get('XFA');
  42790. var fields = this.acroForm.get('Fields');
  42791. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  42792. this.acroForm = null;
  42793. }
  42794. }
  42795. } catch (ex) {
  42796. info('Something wrong with AcroForm entry');
  42797. this.acroForm = null;
  42798. }
  42799. },
  42800. get linearization() {
  42801. var linearization = null;
  42802. if (this.stream.length) {
  42803. try {
  42804. linearization = Linearization.create(this.stream);
  42805. } catch (err) {
  42806. if (err instanceof MissingDataException) {
  42807. throw err;
  42808. }
  42809. info(err);
  42810. }
  42811. }
  42812. return shadow(this, 'linearization', linearization);
  42813. },
  42814. get startXRef() {
  42815. var stream = this.stream;
  42816. var startXRef = 0;
  42817. var linearization = this.linearization;
  42818. if (linearization) {
  42819. stream.reset();
  42820. if (find(stream, 'endobj', 1024)) {
  42821. startXRef = stream.pos + 6;
  42822. }
  42823. } else {
  42824. var step = 1024;
  42825. var found = false, pos = stream.end;
  42826. while (!found && pos > 0) {
  42827. pos -= step - 'startxref'.length;
  42828. if (pos < 0) {
  42829. pos = 0;
  42830. }
  42831. stream.pos = pos;
  42832. found = find(stream, 'startxref', step, true);
  42833. }
  42834. if (found) {
  42835. stream.skip(9);
  42836. var ch;
  42837. do {
  42838. ch = stream.getByte();
  42839. } while (isSpace(ch));
  42840. var str = '';
  42841. while (ch >= 0x20 && ch <= 0x39) {
  42842. str += String.fromCharCode(ch);
  42843. ch = stream.getByte();
  42844. }
  42845. startXRef = parseInt(str, 10);
  42846. if (isNaN(startXRef)) {
  42847. startXRef = 0;
  42848. }
  42849. }
  42850. }
  42851. return shadow(this, 'startXRef', startXRef);
  42852. },
  42853. get mainXRefEntriesOffset() {
  42854. var mainXRefEntriesOffset = 0;
  42855. var linearization = this.linearization;
  42856. if (linearization) {
  42857. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42858. }
  42859. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42860. },
  42861. checkHeader: function PDFDocument_checkHeader() {
  42862. var stream = this.stream;
  42863. stream.reset();
  42864. if (find(stream, '%PDF-', 1024)) {
  42865. stream.moveStart();
  42866. var MAX_VERSION_LENGTH = 12;
  42867. var version = '', ch;
  42868. while ((ch = stream.getByte()) > 0x20) {
  42869. if (version.length >= MAX_VERSION_LENGTH) {
  42870. break;
  42871. }
  42872. version += String.fromCharCode(ch);
  42873. }
  42874. if (!this.pdfFormatVersion) {
  42875. this.pdfFormatVersion = version.substring(5);
  42876. }
  42877. return;
  42878. }
  42879. },
  42880. parseStartXRef: function PDFDocument_parseStartXRef() {
  42881. var startXRef = this.startXRef;
  42882. this.xref.setStartXRef(startXRef);
  42883. },
  42884. setup: function PDFDocument_setup(recoveryMode) {
  42885. this.xref.parse(recoveryMode);
  42886. var self = this;
  42887. var pageFactory = {
  42888. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42889. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42890. }
  42891. };
  42892. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42893. },
  42894. get numPages() {
  42895. var linearization = this.linearization;
  42896. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42897. return shadow(this, 'numPages', num);
  42898. },
  42899. get documentInfo() {
  42900. var docInfo = {
  42901. PDFFormatVersion: this.pdfFormatVersion,
  42902. IsAcroFormPresent: !!this.acroForm,
  42903. IsXFAPresent: !!this.xfa
  42904. };
  42905. var infoDict;
  42906. try {
  42907. infoDict = this.xref.trailer.get('Info');
  42908. } catch (err) {
  42909. info('The document information dictionary is invalid.');
  42910. }
  42911. if (infoDict) {
  42912. var validEntries = DocumentInfoValidators.entries;
  42913. for (var key in validEntries) {
  42914. if (infoDict.has(key)) {
  42915. var value = infoDict.get(key);
  42916. if (validEntries[key](value)) {
  42917. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42918. } else {
  42919. info('Bad value in document info for "' + key + '"');
  42920. }
  42921. }
  42922. }
  42923. }
  42924. return shadow(this, 'documentInfo', docInfo);
  42925. },
  42926. get fingerprint() {
  42927. var xref = this.xref, hash, fileID = '';
  42928. var idArray = xref.trailer.get('ID');
  42929. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42930. hash = stringToBytes(idArray[0]);
  42931. } else {
  42932. if (this.stream.ensureRange) {
  42933. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42934. }
  42935. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42936. }
  42937. for (var i = 0, n = hash.length; i < n; i++) {
  42938. var hex = hash[i].toString(16);
  42939. fileID += hex.length === 1 ? '0' + hex : hex;
  42940. }
  42941. return shadow(this, 'fingerprint', fileID);
  42942. },
  42943. getPage: function PDFDocument_getPage(pageIndex) {
  42944. return this.catalog.getPage(pageIndex);
  42945. },
  42946. cleanup: function PDFDocument_cleanup() {
  42947. return this.catalog.cleanup();
  42948. }
  42949. };
  42950. return PDFDocument;
  42951. }();
  42952. exports.Page = Page;
  42953. exports.PDFDocument = PDFDocument;
  42954. /***/ }),
  42955. /* 32 */
  42956. /***/ (function(module, exports, __w_pdfjs_require__) {
  42957. "use strict";
  42958. var sharedUtil = __w_pdfjs_require__(0);
  42959. var coreStream = __w_pdfjs_require__(2);
  42960. var coreGlyphList = __w_pdfjs_require__(8);
  42961. var coreEncodings = __w_pdfjs_require__(5);
  42962. var coreCFFParser = __w_pdfjs_require__(14);
  42963. var Util = sharedUtil.Util;
  42964. var bytesToString = sharedUtil.bytesToString;
  42965. var error = sharedUtil.error;
  42966. var Stream = coreStream.Stream;
  42967. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42968. var StandardEncoding = coreEncodings.StandardEncoding;
  42969. var CFFParser = coreCFFParser.CFFParser;
  42970. var FontRendererFactory = function FontRendererFactoryClosure() {
  42971. function getLong(data, offset) {
  42972. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42973. }
  42974. function getUshort(data, offset) {
  42975. return data[offset] << 8 | data[offset + 1];
  42976. }
  42977. function parseCmap(data, start, end) {
  42978. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42979. var format = getUshort(data, start + offset);
  42980. var ranges, p, i;
  42981. if (format === 4) {
  42982. getUshort(data, start + offset + 2);
  42983. var segCount = getUshort(data, start + offset + 6) >> 1;
  42984. p = start + offset + 14;
  42985. ranges = [];
  42986. for (i = 0; i < segCount; i++, p += 2) {
  42987. ranges[i] = { end: getUshort(data, p) };
  42988. }
  42989. p += 2;
  42990. for (i = 0; i < segCount; i++, p += 2) {
  42991. ranges[i].start = getUshort(data, p);
  42992. }
  42993. for (i = 0; i < segCount; i++, p += 2) {
  42994. ranges[i].idDelta = getUshort(data, p);
  42995. }
  42996. for (i = 0; i < segCount; i++, p += 2) {
  42997. var idOffset = getUshort(data, p);
  42998. if (idOffset === 0) {
  42999. continue;
  43000. }
  43001. ranges[i].ids = [];
  43002. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  43003. ranges[i].ids[j] = getUshort(data, p + idOffset);
  43004. idOffset += 2;
  43005. }
  43006. }
  43007. return ranges;
  43008. } else if (format === 12) {
  43009. getLong(data, start + offset + 4);
  43010. var groups = getLong(data, start + offset + 12);
  43011. p = start + offset + 16;
  43012. ranges = [];
  43013. for (i = 0; i < groups; i++) {
  43014. ranges.push({
  43015. start: getLong(data, p),
  43016. end: getLong(data, p + 4),
  43017. idDelta: getLong(data, p + 8) - getLong(data, p)
  43018. });
  43019. p += 12;
  43020. }
  43021. return ranges;
  43022. }
  43023. error('not supported cmap: ' + format);
  43024. }
  43025. function parseCff(data, start, end, seacAnalysisEnabled) {
  43026. var properties = {};
  43027. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  43028. var cff = parser.parse();
  43029. return {
  43030. glyphs: cff.charStrings.objects,
  43031. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  43032. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  43033. };
  43034. }
  43035. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  43036. var itemSize, itemDecode;
  43037. if (isGlyphLocationsLong) {
  43038. itemSize = 4;
  43039. itemDecode = function fontItemDecodeLong(data, offset) {
  43040. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43041. };
  43042. } else {
  43043. itemSize = 2;
  43044. itemDecode = function fontItemDecode(data, offset) {
  43045. return data[offset] << 9 | data[offset + 1] << 1;
  43046. };
  43047. }
  43048. var glyphs = [];
  43049. var startOffset = itemDecode(loca, 0);
  43050. for (var j = itemSize; j < loca.length; j += itemSize) {
  43051. var endOffset = itemDecode(loca, j);
  43052. glyphs.push(glyf.subarray(startOffset, endOffset));
  43053. startOffset = endOffset;
  43054. }
  43055. return glyphs;
  43056. }
  43057. function lookupCmap(ranges, unicode) {
  43058. var code = unicode.charCodeAt(0), gid = 0;
  43059. var l = 0, r = ranges.length - 1;
  43060. while (l < r) {
  43061. var c = l + r + 1 >> 1;
  43062. if (code < ranges[c].start) {
  43063. r = c - 1;
  43064. } else {
  43065. l = c;
  43066. }
  43067. }
  43068. if (ranges[l].start <= code && code <= ranges[l].end) {
  43069. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43070. }
  43071. return {
  43072. charCode: code,
  43073. glyphId: gid
  43074. };
  43075. }
  43076. function compileGlyf(code, cmds, font) {
  43077. function moveTo(x, y) {
  43078. cmds.push({
  43079. cmd: 'moveTo',
  43080. args: [
  43081. x,
  43082. y
  43083. ]
  43084. });
  43085. }
  43086. function lineTo(x, y) {
  43087. cmds.push({
  43088. cmd: 'lineTo',
  43089. args: [
  43090. x,
  43091. y
  43092. ]
  43093. });
  43094. }
  43095. function quadraticCurveTo(xa, ya, x, y) {
  43096. cmds.push({
  43097. cmd: 'quadraticCurveTo',
  43098. args: [
  43099. xa,
  43100. ya,
  43101. x,
  43102. y
  43103. ]
  43104. });
  43105. }
  43106. var i = 0;
  43107. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43108. var flags;
  43109. var x = 0, y = 0;
  43110. i += 10;
  43111. if (numberOfContours < 0) {
  43112. do {
  43113. flags = code[i] << 8 | code[i + 1];
  43114. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43115. i += 4;
  43116. var arg1, arg2;
  43117. if (flags & 0x01) {
  43118. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43119. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43120. i += 4;
  43121. } else {
  43122. arg1 = code[i++];
  43123. arg2 = code[i++];
  43124. }
  43125. if (flags & 0x02) {
  43126. x = arg1;
  43127. y = arg2;
  43128. } else {
  43129. x = 0;
  43130. y = 0;
  43131. }
  43132. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43133. if (flags & 0x08) {
  43134. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43135. i += 2;
  43136. } else if (flags & 0x40) {
  43137. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43138. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43139. i += 4;
  43140. } else if (flags & 0x80) {
  43141. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43142. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43143. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43144. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43145. i += 8;
  43146. }
  43147. var subglyph = font.glyphs[glyphIndex];
  43148. if (subglyph) {
  43149. cmds.push({ cmd: 'save' });
  43150. cmds.push({
  43151. cmd: 'transform',
  43152. args: [
  43153. scaleX,
  43154. scale01,
  43155. scale10,
  43156. scaleY,
  43157. x,
  43158. y
  43159. ]
  43160. });
  43161. compileGlyf(subglyph, cmds, font);
  43162. cmds.push({ cmd: 'restore' });
  43163. }
  43164. } while (flags & 0x20);
  43165. } else {
  43166. var endPtsOfContours = [];
  43167. var j, jj;
  43168. for (j = 0; j < numberOfContours; j++) {
  43169. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43170. i += 2;
  43171. }
  43172. var instructionLength = code[i] << 8 | code[i + 1];
  43173. i += 2 + instructionLength;
  43174. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43175. var points = [];
  43176. while (points.length < numberOfPoints) {
  43177. flags = code[i++];
  43178. var repeat = 1;
  43179. if (flags & 0x08) {
  43180. repeat += code[i++];
  43181. }
  43182. while (repeat-- > 0) {
  43183. points.push({ flags: flags });
  43184. }
  43185. }
  43186. for (j = 0; j < numberOfPoints; j++) {
  43187. switch (points[j].flags & 0x12) {
  43188. case 0x00:
  43189. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43190. i += 2;
  43191. break;
  43192. case 0x02:
  43193. x -= code[i++];
  43194. break;
  43195. case 0x12:
  43196. x += code[i++];
  43197. break;
  43198. }
  43199. points[j].x = x;
  43200. }
  43201. for (j = 0; j < numberOfPoints; j++) {
  43202. switch (points[j].flags & 0x24) {
  43203. case 0x00:
  43204. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43205. i += 2;
  43206. break;
  43207. case 0x04:
  43208. y -= code[i++];
  43209. break;
  43210. case 0x24:
  43211. y += code[i++];
  43212. break;
  43213. }
  43214. points[j].y = y;
  43215. }
  43216. var startPoint = 0;
  43217. for (i = 0; i < numberOfContours; i++) {
  43218. var endPoint = endPtsOfContours[i];
  43219. var contour = points.slice(startPoint, endPoint + 1);
  43220. if (contour[0].flags & 1) {
  43221. contour.push(contour[0]);
  43222. } else if (contour[contour.length - 1].flags & 1) {
  43223. contour.unshift(contour[contour.length - 1]);
  43224. } else {
  43225. var p = {
  43226. flags: 1,
  43227. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43228. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43229. };
  43230. contour.unshift(p);
  43231. contour.push(p);
  43232. }
  43233. moveTo(contour[0].x, contour[0].y);
  43234. for (j = 1, jj = contour.length; j < jj; j++) {
  43235. if (contour[j].flags & 1) {
  43236. lineTo(contour[j].x, contour[j].y);
  43237. } else if (contour[j + 1].flags & 1) {
  43238. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43239. j++;
  43240. } else {
  43241. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43242. }
  43243. }
  43244. startPoint = endPoint + 1;
  43245. }
  43246. }
  43247. }
  43248. function compileCharString(code, cmds, font) {
  43249. var stack = [];
  43250. var x = 0, y = 0;
  43251. var stems = 0;
  43252. function moveTo(x, y) {
  43253. cmds.push({
  43254. cmd: 'moveTo',
  43255. args: [
  43256. x,
  43257. y
  43258. ]
  43259. });
  43260. }
  43261. function lineTo(x, y) {
  43262. cmds.push({
  43263. cmd: 'lineTo',
  43264. args: [
  43265. x,
  43266. y
  43267. ]
  43268. });
  43269. }
  43270. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43271. cmds.push({
  43272. cmd: 'bezierCurveTo',
  43273. args: [
  43274. x1,
  43275. y1,
  43276. x2,
  43277. y2,
  43278. x,
  43279. y
  43280. ]
  43281. });
  43282. }
  43283. function parse(code) {
  43284. var i = 0;
  43285. while (i < code.length) {
  43286. var stackClean = false;
  43287. var v = code[i++];
  43288. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43289. switch (v) {
  43290. case 1:
  43291. stems += stack.length >> 1;
  43292. stackClean = true;
  43293. break;
  43294. case 3:
  43295. stems += stack.length >> 1;
  43296. stackClean = true;
  43297. break;
  43298. case 4:
  43299. y += stack.pop();
  43300. moveTo(x, y);
  43301. stackClean = true;
  43302. break;
  43303. case 5:
  43304. while (stack.length > 0) {
  43305. x += stack.shift();
  43306. y += stack.shift();
  43307. lineTo(x, y);
  43308. }
  43309. break;
  43310. case 6:
  43311. while (stack.length > 0) {
  43312. x += stack.shift();
  43313. lineTo(x, y);
  43314. if (stack.length === 0) {
  43315. break;
  43316. }
  43317. y += stack.shift();
  43318. lineTo(x, y);
  43319. }
  43320. break;
  43321. case 7:
  43322. while (stack.length > 0) {
  43323. y += stack.shift();
  43324. lineTo(x, y);
  43325. if (stack.length === 0) {
  43326. break;
  43327. }
  43328. x += stack.shift();
  43329. lineTo(x, y);
  43330. }
  43331. break;
  43332. case 8:
  43333. while (stack.length > 0) {
  43334. xa = x + stack.shift();
  43335. ya = y + stack.shift();
  43336. xb = xa + stack.shift();
  43337. yb = ya + stack.shift();
  43338. x = xb + stack.shift();
  43339. y = yb + stack.shift();
  43340. bezierCurveTo(xa, ya, xb, yb, x, y);
  43341. }
  43342. break;
  43343. case 10:
  43344. n = stack.pop() + font.subrsBias;
  43345. subrCode = font.subrs[n];
  43346. if (subrCode) {
  43347. parse(subrCode);
  43348. }
  43349. break;
  43350. case 11:
  43351. return;
  43352. case 12:
  43353. v = code[i++];
  43354. switch (v) {
  43355. case 34:
  43356. xa = x + stack.shift();
  43357. xb = xa + stack.shift();
  43358. y1 = y + stack.shift();
  43359. x = xb + stack.shift();
  43360. bezierCurveTo(xa, y, xb, y1, x, y1);
  43361. xa = x + stack.shift();
  43362. xb = xa + stack.shift();
  43363. x = xb + stack.shift();
  43364. bezierCurveTo(xa, y1, xb, y, x, y);
  43365. break;
  43366. case 35:
  43367. xa = x + stack.shift();
  43368. ya = y + stack.shift();
  43369. xb = xa + stack.shift();
  43370. yb = ya + stack.shift();
  43371. x = xb + stack.shift();
  43372. y = yb + stack.shift();
  43373. bezierCurveTo(xa, ya, xb, yb, x, y);
  43374. xa = x + stack.shift();
  43375. ya = y + stack.shift();
  43376. xb = xa + stack.shift();
  43377. yb = ya + stack.shift();
  43378. x = xb + stack.shift();
  43379. y = yb + stack.shift();
  43380. bezierCurveTo(xa, ya, xb, yb, x, y);
  43381. stack.pop();
  43382. break;
  43383. case 36:
  43384. xa = x + stack.shift();
  43385. y1 = y + stack.shift();
  43386. xb = xa + stack.shift();
  43387. y2 = y1 + stack.shift();
  43388. x = xb + stack.shift();
  43389. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43390. xa = x + stack.shift();
  43391. xb = xa + stack.shift();
  43392. y3 = y2 + stack.shift();
  43393. x = xb + stack.shift();
  43394. bezierCurveTo(xa, y2, xb, y3, x, y);
  43395. break;
  43396. case 37:
  43397. var x0 = x, y0 = y;
  43398. xa = x + stack.shift();
  43399. ya = y + stack.shift();
  43400. xb = xa + stack.shift();
  43401. yb = ya + stack.shift();
  43402. x = xb + stack.shift();
  43403. y = yb + stack.shift();
  43404. bezierCurveTo(xa, ya, xb, yb, x, y);
  43405. xa = x + stack.shift();
  43406. ya = y + stack.shift();
  43407. xb = xa + stack.shift();
  43408. yb = ya + stack.shift();
  43409. x = xb;
  43410. y = yb;
  43411. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43412. x += stack.shift();
  43413. } else {
  43414. y += stack.shift();
  43415. }
  43416. bezierCurveTo(xa, ya, xb, yb, x, y);
  43417. break;
  43418. default:
  43419. error('unknown operator: 12 ' + v);
  43420. }
  43421. break;
  43422. case 14:
  43423. if (stack.length >= 4) {
  43424. var achar = stack.pop();
  43425. var bchar = stack.pop();
  43426. y = stack.pop();
  43427. x = stack.pop();
  43428. cmds.push({ cmd: 'save' });
  43429. cmds.push({
  43430. cmd: 'translate',
  43431. args: [
  43432. x,
  43433. y
  43434. ]
  43435. });
  43436. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43437. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43438. cmds.push({ cmd: 'restore' });
  43439. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43440. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43441. }
  43442. return;
  43443. case 18:
  43444. stems += stack.length >> 1;
  43445. stackClean = true;
  43446. break;
  43447. case 19:
  43448. stems += stack.length >> 1;
  43449. i += stems + 7 >> 3;
  43450. stackClean = true;
  43451. break;
  43452. case 20:
  43453. stems += stack.length >> 1;
  43454. i += stems + 7 >> 3;
  43455. stackClean = true;
  43456. break;
  43457. case 21:
  43458. y += stack.pop();
  43459. x += stack.pop();
  43460. moveTo(x, y);
  43461. stackClean = true;
  43462. break;
  43463. case 22:
  43464. x += stack.pop();
  43465. moveTo(x, y);
  43466. stackClean = true;
  43467. break;
  43468. case 23:
  43469. stems += stack.length >> 1;
  43470. stackClean = true;
  43471. break;
  43472. case 24:
  43473. while (stack.length > 2) {
  43474. xa = x + stack.shift();
  43475. ya = y + stack.shift();
  43476. xb = xa + stack.shift();
  43477. yb = ya + stack.shift();
  43478. x = xb + stack.shift();
  43479. y = yb + stack.shift();
  43480. bezierCurveTo(xa, ya, xb, yb, x, y);
  43481. }
  43482. x += stack.shift();
  43483. y += stack.shift();
  43484. lineTo(x, y);
  43485. break;
  43486. case 25:
  43487. while (stack.length > 6) {
  43488. x += stack.shift();
  43489. y += stack.shift();
  43490. lineTo(x, y);
  43491. }
  43492. xa = x + stack.shift();
  43493. ya = y + stack.shift();
  43494. xb = xa + stack.shift();
  43495. yb = ya + stack.shift();
  43496. x = xb + stack.shift();
  43497. y = yb + stack.shift();
  43498. bezierCurveTo(xa, ya, xb, yb, x, y);
  43499. break;
  43500. case 26:
  43501. if (stack.length % 2) {
  43502. x += stack.shift();
  43503. }
  43504. while (stack.length > 0) {
  43505. xa = x;
  43506. ya = y + stack.shift();
  43507. xb = xa + stack.shift();
  43508. yb = ya + stack.shift();
  43509. x = xb;
  43510. y = yb + stack.shift();
  43511. bezierCurveTo(xa, ya, xb, yb, x, y);
  43512. }
  43513. break;
  43514. case 27:
  43515. if (stack.length % 2) {
  43516. y += stack.shift();
  43517. }
  43518. while (stack.length > 0) {
  43519. xa = x + stack.shift();
  43520. ya = y;
  43521. xb = xa + stack.shift();
  43522. yb = ya + stack.shift();
  43523. x = xb + stack.shift();
  43524. y = yb;
  43525. bezierCurveTo(xa, ya, xb, yb, x, y);
  43526. }
  43527. break;
  43528. case 28:
  43529. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43530. i += 2;
  43531. break;
  43532. case 29:
  43533. n = stack.pop() + font.gsubrsBias;
  43534. subrCode = font.gsubrs[n];
  43535. if (subrCode) {
  43536. parse(subrCode);
  43537. }
  43538. break;
  43539. case 30:
  43540. while (stack.length > 0) {
  43541. xa = x;
  43542. ya = y + stack.shift();
  43543. xb = xa + stack.shift();
  43544. yb = ya + stack.shift();
  43545. x = xb + stack.shift();
  43546. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43547. bezierCurveTo(xa, ya, xb, yb, x, y);
  43548. if (stack.length === 0) {
  43549. break;
  43550. }
  43551. xa = x + stack.shift();
  43552. ya = y;
  43553. xb = xa + stack.shift();
  43554. yb = ya + stack.shift();
  43555. y = yb + stack.shift();
  43556. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43557. bezierCurveTo(xa, ya, xb, yb, x, y);
  43558. }
  43559. break;
  43560. case 31:
  43561. while (stack.length > 0) {
  43562. xa = x + stack.shift();
  43563. ya = y;
  43564. xb = xa + stack.shift();
  43565. yb = ya + stack.shift();
  43566. y = yb + stack.shift();
  43567. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43568. bezierCurveTo(xa, ya, xb, yb, x, y);
  43569. if (stack.length === 0) {
  43570. break;
  43571. }
  43572. xa = x;
  43573. ya = y + stack.shift();
  43574. xb = xa + stack.shift();
  43575. yb = ya + stack.shift();
  43576. x = xb + stack.shift();
  43577. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43578. bezierCurveTo(xa, ya, xb, yb, x, y);
  43579. }
  43580. break;
  43581. default:
  43582. if (v < 32) {
  43583. error('unknown operator: ' + v);
  43584. }
  43585. if (v < 247) {
  43586. stack.push(v - 139);
  43587. } else if (v < 251) {
  43588. stack.push((v - 247) * 256 + code[i++] + 108);
  43589. } else if (v < 255) {
  43590. stack.push(-(v - 251) * 256 - code[i++] - 108);
  43591. } else {
  43592. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  43593. i += 4;
  43594. }
  43595. break;
  43596. }
  43597. if (stackClean) {
  43598. stack.length = 0;
  43599. }
  43600. }
  43601. }
  43602. parse(code);
  43603. }
  43604. var noop = '';
  43605. function CompiledFont(fontMatrix) {
  43606. this.compiledGlyphs = Object.create(null);
  43607. this.compiledCharCodeToGlyphId = Object.create(null);
  43608. this.fontMatrix = fontMatrix;
  43609. }
  43610. CompiledFont.prototype = {
  43611. getPathJs: function (unicode) {
  43612. var cmap = lookupCmap(this.cmap, unicode);
  43613. var fn = this.compiledGlyphs[cmap.glyphId];
  43614. if (!fn) {
  43615. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  43616. this.compiledGlyphs[cmap.glyphId] = fn;
  43617. }
  43618. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  43619. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  43620. }
  43621. return fn;
  43622. },
  43623. compileGlyph: function (code) {
  43624. if (!code || code.length === 0 || code[0] === 14) {
  43625. return noop;
  43626. }
  43627. var cmds = [];
  43628. cmds.push({ cmd: 'save' });
  43629. cmds.push({
  43630. cmd: 'transform',
  43631. args: this.fontMatrix.slice()
  43632. });
  43633. cmds.push({
  43634. cmd: 'scale',
  43635. args: [
  43636. 'size',
  43637. '-size'
  43638. ]
  43639. });
  43640. this.compileGlyphImpl(code, cmds);
  43641. cmds.push({ cmd: 'restore' });
  43642. return cmds;
  43643. },
  43644. compileGlyphImpl: function () {
  43645. error('Children classes should implement this.');
  43646. },
  43647. hasBuiltPath: function (unicode) {
  43648. var cmap = lookupCmap(this.cmap, unicode);
  43649. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  43650. }
  43651. };
  43652. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  43653. fontMatrix = fontMatrix || [
  43654. 0.000488,
  43655. 0,
  43656. 0,
  43657. 0.000488,
  43658. 0,
  43659. 0
  43660. ];
  43661. CompiledFont.call(this, fontMatrix);
  43662. this.glyphs = glyphs;
  43663. this.cmap = cmap;
  43664. }
  43665. Util.inherit(TrueTypeCompiled, CompiledFont, {
  43666. compileGlyphImpl: function (code, cmds) {
  43667. compileGlyf(code, cmds, this);
  43668. }
  43669. });
  43670. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  43671. fontMatrix = fontMatrix || [
  43672. 0.001,
  43673. 0,
  43674. 0,
  43675. 0.001,
  43676. 0,
  43677. 0
  43678. ];
  43679. CompiledFont.call(this, fontMatrix);
  43680. this.glyphs = cffInfo.glyphs;
  43681. this.gsubrs = cffInfo.gsubrs || [];
  43682. this.subrs = cffInfo.subrs || [];
  43683. this.cmap = cmap;
  43684. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  43685. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  43686. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  43687. }
  43688. Util.inherit(Type2Compiled, CompiledFont, {
  43689. compileGlyphImpl: function (code, cmds) {
  43690. compileCharString(code, cmds, this);
  43691. }
  43692. });
  43693. return {
  43694. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  43695. var data = new Uint8Array(font.data);
  43696. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  43697. var numTables = getUshort(data, 4);
  43698. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  43699. var tag = bytesToString(data.subarray(p, p + 4));
  43700. var offset = getLong(data, p + 8);
  43701. var length = getLong(data, p + 12);
  43702. switch (tag) {
  43703. case 'cmap':
  43704. cmap = parseCmap(data, offset, offset + length);
  43705. break;
  43706. case 'glyf':
  43707. glyf = data.subarray(offset, offset + length);
  43708. break;
  43709. case 'loca':
  43710. loca = data.subarray(offset, offset + length);
  43711. break;
  43712. case 'head':
  43713. unitsPerEm = getUshort(data, offset + 18);
  43714. indexToLocFormat = getUshort(data, offset + 50);
  43715. break;
  43716. case 'CFF ':
  43717. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  43718. break;
  43719. }
  43720. }
  43721. if (glyf) {
  43722. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  43723. 1 / unitsPerEm,
  43724. 0,
  43725. 0,
  43726. 1 / unitsPerEm,
  43727. 0,
  43728. 0
  43729. ];
  43730. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  43731. }
  43732. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  43733. }
  43734. };
  43735. }();
  43736. exports.FontRendererFactory = FontRendererFactory;
  43737. /***/ }),
  43738. /* 33 */
  43739. /***/ (function(module, exports, __w_pdfjs_require__) {
  43740. "use strict";
  43741. var sharedUtil = __w_pdfjs_require__(0);
  43742. var corePrimitives = __w_pdfjs_require__(1);
  43743. var coreStream = __w_pdfjs_require__(2);
  43744. var coreGlyphList = __w_pdfjs_require__(8);
  43745. var coreFontRenderer = __w_pdfjs_require__(32);
  43746. var coreEncodings = __w_pdfjs_require__(5);
  43747. var coreStandardFonts = __w_pdfjs_require__(20);
  43748. var coreUnicode = __w_pdfjs_require__(21);
  43749. var coreType1Parser = __w_pdfjs_require__(43);
  43750. var coreCFFParser = __w_pdfjs_require__(14);
  43751. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43752. var FontType = sharedUtil.FontType;
  43753. var assert = sharedUtil.assert;
  43754. var bytesToString = sharedUtil.bytesToString;
  43755. var error = sharedUtil.error;
  43756. var info = sharedUtil.info;
  43757. var isArray = sharedUtil.isArray;
  43758. var isInt = sharedUtil.isInt;
  43759. var isNum = sharedUtil.isNum;
  43760. var readUint32 = sharedUtil.readUint32;
  43761. var shadow = sharedUtil.shadow;
  43762. var string32 = sharedUtil.string32;
  43763. var warn = sharedUtil.warn;
  43764. var MissingDataException = sharedUtil.MissingDataException;
  43765. var isSpace = sharedUtil.isSpace;
  43766. var Stream = coreStream.Stream;
  43767. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43768. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  43769. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  43770. var StandardEncoding = coreEncodings.StandardEncoding;
  43771. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  43772. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  43773. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  43774. var getEncoding = coreEncodings.getEncoding;
  43775. var getStdFontMap = coreStandardFonts.getStdFontMap;
  43776. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  43777. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  43778. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  43779. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  43780. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  43781. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  43782. var Type1Parser = coreType1Parser.Type1Parser;
  43783. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  43784. var CFFParser = coreCFFParser.CFFParser;
  43785. var CFFCompiler = coreCFFParser.CFFCompiler;
  43786. var CFF = coreCFFParser.CFF;
  43787. var CFFHeader = coreCFFParser.CFFHeader;
  43788. var CFFTopDict = coreCFFParser.CFFTopDict;
  43789. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  43790. var CFFStrings = coreCFFParser.CFFStrings;
  43791. var CFFIndex = coreCFFParser.CFFIndex;
  43792. var CFFCharset = coreCFFParser.CFFCharset;
  43793. var PRIVATE_USE_OFFSET_START = 0xE000;
  43794. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  43795. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  43796. var PDF_GLYPH_SPACE_UNITS = 1000;
  43797. var SEAC_ANALYSIS_ENABLED = false;
  43798. var FontFlags = {
  43799. FixedPitch: 1,
  43800. Serif: 2,
  43801. Symbolic: 4,
  43802. Script: 8,
  43803. Nonsymbolic: 32,
  43804. Italic: 64,
  43805. AllCap: 65536,
  43806. SmallCap: 131072,
  43807. ForceBold: 262144
  43808. };
  43809. var MacStandardGlyphOrdering = [
  43810. '.notdef',
  43811. '.null',
  43812. 'nonmarkingreturn',
  43813. 'space',
  43814. 'exclam',
  43815. 'quotedbl',
  43816. 'numbersign',
  43817. 'dollar',
  43818. 'percent',
  43819. 'ampersand',
  43820. 'quotesingle',
  43821. 'parenleft',
  43822. 'parenright',
  43823. 'asterisk',
  43824. 'plus',
  43825. 'comma',
  43826. 'hyphen',
  43827. 'period',
  43828. 'slash',
  43829. 'zero',
  43830. 'one',
  43831. 'two',
  43832. 'three',
  43833. 'four',
  43834. 'five',
  43835. 'six',
  43836. 'seven',
  43837. 'eight',
  43838. 'nine',
  43839. 'colon',
  43840. 'semicolon',
  43841. 'less',
  43842. 'equal',
  43843. 'greater',
  43844. 'question',
  43845. 'at',
  43846. 'A',
  43847. 'B',
  43848. 'C',
  43849. 'D',
  43850. 'E',
  43851. 'F',
  43852. 'G',
  43853. 'H',
  43854. 'I',
  43855. 'J',
  43856. 'K',
  43857. 'L',
  43858. 'M',
  43859. 'N',
  43860. 'O',
  43861. 'P',
  43862. 'Q',
  43863. 'R',
  43864. 'S',
  43865. 'T',
  43866. 'U',
  43867. 'V',
  43868. 'W',
  43869. 'X',
  43870. 'Y',
  43871. 'Z',
  43872. 'bracketleft',
  43873. 'backslash',
  43874. 'bracketright',
  43875. 'asciicircum',
  43876. 'underscore',
  43877. 'grave',
  43878. 'a',
  43879. 'b',
  43880. 'c',
  43881. 'd',
  43882. 'e',
  43883. 'f',
  43884. 'g',
  43885. 'h',
  43886. 'i',
  43887. 'j',
  43888. 'k',
  43889. 'l',
  43890. 'm',
  43891. 'n',
  43892. 'o',
  43893. 'p',
  43894. 'q',
  43895. 'r',
  43896. 's',
  43897. 't',
  43898. 'u',
  43899. 'v',
  43900. 'w',
  43901. 'x',
  43902. 'y',
  43903. 'z',
  43904. 'braceleft',
  43905. 'bar',
  43906. 'braceright',
  43907. 'asciitilde',
  43908. 'Adieresis',
  43909. 'Aring',
  43910. 'Ccedilla',
  43911. 'Eacute',
  43912. 'Ntilde',
  43913. 'Odieresis',
  43914. 'Udieresis',
  43915. 'aacute',
  43916. 'agrave',
  43917. 'acircumflex',
  43918. 'adieresis',
  43919. 'atilde',
  43920. 'aring',
  43921. 'ccedilla',
  43922. 'eacute',
  43923. 'egrave',
  43924. 'ecircumflex',
  43925. 'edieresis',
  43926. 'iacute',
  43927. 'igrave',
  43928. 'icircumflex',
  43929. 'idieresis',
  43930. 'ntilde',
  43931. 'oacute',
  43932. 'ograve',
  43933. 'ocircumflex',
  43934. 'odieresis',
  43935. 'otilde',
  43936. 'uacute',
  43937. 'ugrave',
  43938. 'ucircumflex',
  43939. 'udieresis',
  43940. 'dagger',
  43941. 'degree',
  43942. 'cent',
  43943. 'sterling',
  43944. 'section',
  43945. 'bullet',
  43946. 'paragraph',
  43947. 'germandbls',
  43948. 'registered',
  43949. 'copyright',
  43950. 'trademark',
  43951. 'acute',
  43952. 'dieresis',
  43953. 'notequal',
  43954. 'AE',
  43955. 'Oslash',
  43956. 'infinity',
  43957. 'plusminus',
  43958. 'lessequal',
  43959. 'greaterequal',
  43960. 'yen',
  43961. 'mu',
  43962. 'partialdiff',
  43963. 'summation',
  43964. 'product',
  43965. 'pi',
  43966. 'integral',
  43967. 'ordfeminine',
  43968. 'ordmasculine',
  43969. 'Omega',
  43970. 'ae',
  43971. 'oslash',
  43972. 'questiondown',
  43973. 'exclamdown',
  43974. 'logicalnot',
  43975. 'radical',
  43976. 'florin',
  43977. 'approxequal',
  43978. 'Delta',
  43979. 'guillemotleft',
  43980. 'guillemotright',
  43981. 'ellipsis',
  43982. 'nonbreakingspace',
  43983. 'Agrave',
  43984. 'Atilde',
  43985. 'Otilde',
  43986. 'OE',
  43987. 'oe',
  43988. 'endash',
  43989. 'emdash',
  43990. 'quotedblleft',
  43991. 'quotedblright',
  43992. 'quoteleft',
  43993. 'quoteright',
  43994. 'divide',
  43995. 'lozenge',
  43996. 'ydieresis',
  43997. 'Ydieresis',
  43998. 'fraction',
  43999. 'currency',
  44000. 'guilsinglleft',
  44001. 'guilsinglright',
  44002. 'fi',
  44003. 'fl',
  44004. 'daggerdbl',
  44005. 'periodcentered',
  44006. 'quotesinglbase',
  44007. 'quotedblbase',
  44008. 'perthousand',
  44009. 'Acircumflex',
  44010. 'Ecircumflex',
  44011. 'Aacute',
  44012. 'Edieresis',
  44013. 'Egrave',
  44014. 'Iacute',
  44015. 'Icircumflex',
  44016. 'Idieresis',
  44017. 'Igrave',
  44018. 'Oacute',
  44019. 'Ocircumflex',
  44020. 'apple',
  44021. 'Ograve',
  44022. 'Uacute',
  44023. 'Ucircumflex',
  44024. 'Ugrave',
  44025. 'dotlessi',
  44026. 'circumflex',
  44027. 'tilde',
  44028. 'macron',
  44029. 'breve',
  44030. 'dotaccent',
  44031. 'ring',
  44032. 'cedilla',
  44033. 'hungarumlaut',
  44034. 'ogonek',
  44035. 'caron',
  44036. 'Lslash',
  44037. 'lslash',
  44038. 'Scaron',
  44039. 'scaron',
  44040. 'Zcaron',
  44041. 'zcaron',
  44042. 'brokenbar',
  44043. 'Eth',
  44044. 'eth',
  44045. 'Yacute',
  44046. 'yacute',
  44047. 'Thorn',
  44048. 'thorn',
  44049. 'minus',
  44050. 'multiply',
  44051. 'onesuperior',
  44052. 'twosuperior',
  44053. 'threesuperior',
  44054. 'onehalf',
  44055. 'onequarter',
  44056. 'threequarters',
  44057. 'franc',
  44058. 'Gbreve',
  44059. 'gbreve',
  44060. 'Idotaccent',
  44061. 'Scedilla',
  44062. 'scedilla',
  44063. 'Cacute',
  44064. 'cacute',
  44065. 'Ccaron',
  44066. 'ccaron',
  44067. 'dcroat'
  44068. ];
  44069. function adjustWidths(properties) {
  44070. if (!properties.fontMatrix) {
  44071. return;
  44072. }
  44073. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44074. return;
  44075. }
  44076. var scale = 0.001 / properties.fontMatrix[0];
  44077. var glyphsWidths = properties.widths;
  44078. for (var glyph in glyphsWidths) {
  44079. glyphsWidths[glyph] *= scale;
  44080. }
  44081. properties.defaultWidth *= scale;
  44082. }
  44083. function adjustToUnicode(properties, builtInEncoding) {
  44084. if (properties.hasIncludedToUnicodeMap) {
  44085. return;
  44086. }
  44087. if (properties.hasEncoding) {
  44088. return;
  44089. }
  44090. if (builtInEncoding === properties.defaultEncoding) {
  44091. return;
  44092. }
  44093. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44094. return;
  44095. }
  44096. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44097. for (var charCode in builtInEncoding) {
  44098. var glyphName = builtInEncoding[charCode];
  44099. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44100. if (unicode !== -1) {
  44101. toUnicode[charCode] = String.fromCharCode(unicode);
  44102. }
  44103. }
  44104. properties.toUnicode.amend(toUnicode);
  44105. }
  44106. function getFontType(type, subtype) {
  44107. switch (type) {
  44108. case 'Type1':
  44109. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44110. case 'CIDFontType0':
  44111. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44112. case 'OpenType':
  44113. return FontType.OPENTYPE;
  44114. case 'TrueType':
  44115. return FontType.TRUETYPE;
  44116. case 'CIDFontType2':
  44117. return FontType.CIDFONTTYPE2;
  44118. case 'MMType1':
  44119. return FontType.MMTYPE1;
  44120. case 'Type0':
  44121. return FontType.TYPE0;
  44122. default:
  44123. return FontType.UNKNOWN;
  44124. }
  44125. }
  44126. function recoverGlyphName(name, glyphsUnicodeMap) {
  44127. if (glyphsUnicodeMap[name] !== undefined) {
  44128. return name;
  44129. }
  44130. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44131. if (unicode !== -1) {
  44132. for (var key in glyphsUnicodeMap) {
  44133. if (glyphsUnicodeMap[key] === unicode) {
  44134. return key;
  44135. }
  44136. }
  44137. }
  44138. info('Unable to recover a standard glyph name for: ' + name);
  44139. return name;
  44140. }
  44141. var Glyph = function GlyphClosure() {
  44142. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44143. this.fontChar = fontChar;
  44144. this.unicode = unicode;
  44145. this.accent = accent;
  44146. this.width = width;
  44147. this.vmetric = vmetric;
  44148. this.operatorListId = operatorListId;
  44149. this.isSpace = isSpace;
  44150. this.isInFont = isInFont;
  44151. }
  44152. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44153. 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;
  44154. };
  44155. return Glyph;
  44156. }();
  44157. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44158. function ToUnicodeMap(cmap) {
  44159. this._map = cmap;
  44160. }
  44161. ToUnicodeMap.prototype = {
  44162. get length() {
  44163. return this._map.length;
  44164. },
  44165. forEach: function (callback) {
  44166. for (var charCode in this._map) {
  44167. callback(charCode, this._map[charCode].charCodeAt(0));
  44168. }
  44169. },
  44170. has: function (i) {
  44171. return this._map[i] !== undefined;
  44172. },
  44173. get: function (i) {
  44174. return this._map[i];
  44175. },
  44176. charCodeOf: function (v) {
  44177. return this._map.indexOf(v);
  44178. },
  44179. amend: function (map) {
  44180. for (var charCode in map) {
  44181. this._map[charCode] = map[charCode];
  44182. }
  44183. }
  44184. };
  44185. return ToUnicodeMap;
  44186. }();
  44187. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44188. function IdentityToUnicodeMap(firstChar, lastChar) {
  44189. this.firstChar = firstChar;
  44190. this.lastChar = lastChar;
  44191. }
  44192. IdentityToUnicodeMap.prototype = {
  44193. get length() {
  44194. return this.lastChar + 1 - this.firstChar;
  44195. },
  44196. forEach: function (callback) {
  44197. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44198. callback(i, i);
  44199. }
  44200. },
  44201. has: function (i) {
  44202. return this.firstChar <= i && i <= this.lastChar;
  44203. },
  44204. get: function (i) {
  44205. if (this.firstChar <= i && i <= this.lastChar) {
  44206. return String.fromCharCode(i);
  44207. }
  44208. return undefined;
  44209. },
  44210. charCodeOf: function (v) {
  44211. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44212. },
  44213. amend: function (map) {
  44214. error('Should not call amend()');
  44215. }
  44216. };
  44217. return IdentityToUnicodeMap;
  44218. }();
  44219. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44220. function writeInt16(dest, offset, num) {
  44221. dest[offset] = num >> 8 & 0xFF;
  44222. dest[offset + 1] = num & 0xFF;
  44223. }
  44224. function writeInt32(dest, offset, num) {
  44225. dest[offset] = num >> 24 & 0xFF;
  44226. dest[offset + 1] = num >> 16 & 0xFF;
  44227. dest[offset + 2] = num >> 8 & 0xFF;
  44228. dest[offset + 3] = num & 0xFF;
  44229. }
  44230. function writeData(dest, offset, data) {
  44231. var i, ii;
  44232. if (data instanceof Uint8Array) {
  44233. dest.set(data, offset);
  44234. } else if (typeof data === 'string') {
  44235. for (i = 0, ii = data.length; i < ii; i++) {
  44236. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44237. }
  44238. } else {
  44239. for (i = 0, ii = data.length; i < ii; i++) {
  44240. dest[offset++] = data[i] & 0xFF;
  44241. }
  44242. }
  44243. }
  44244. function OpenTypeFileBuilder(sfnt) {
  44245. this.sfnt = sfnt;
  44246. this.tables = Object.create(null);
  44247. }
  44248. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44249. var maxPower2 = 1, log2 = 0;
  44250. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44251. maxPower2 <<= 1;
  44252. log2++;
  44253. }
  44254. var searchRange = maxPower2 * entrySize;
  44255. return {
  44256. range: searchRange,
  44257. entry: log2,
  44258. rangeShift: entrySize * entriesCount - searchRange
  44259. };
  44260. };
  44261. var OTF_HEADER_SIZE = 12;
  44262. var OTF_TABLE_ENTRY_SIZE = 16;
  44263. OpenTypeFileBuilder.prototype = {
  44264. toArray: function OpenTypeFileBuilder_toArray() {
  44265. var sfnt = this.sfnt;
  44266. var tables = this.tables;
  44267. var tablesNames = Object.keys(tables);
  44268. tablesNames.sort();
  44269. var numTables = tablesNames.length;
  44270. var i, j, jj, table, tableName;
  44271. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44272. var tableOffsets = [offset];
  44273. for (i = 0; i < numTables; i++) {
  44274. table = tables[tablesNames[i]];
  44275. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44276. offset += paddedLength;
  44277. tableOffsets.push(offset);
  44278. }
  44279. var file = new Uint8Array(offset);
  44280. for (i = 0; i < numTables; i++) {
  44281. table = tables[tablesNames[i]];
  44282. writeData(file, tableOffsets[i], table);
  44283. }
  44284. if (sfnt === 'true') {
  44285. sfnt = string32(0x00010000);
  44286. }
  44287. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44288. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44289. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44290. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44291. writeInt16(file, 4, numTables);
  44292. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44293. writeInt16(file, 6, searchParams.range);
  44294. writeInt16(file, 8, searchParams.entry);
  44295. writeInt16(file, 10, searchParams.rangeShift);
  44296. offset = OTF_HEADER_SIZE;
  44297. for (i = 0; i < numTables; i++) {
  44298. tableName = tablesNames[i];
  44299. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44300. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44301. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44302. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44303. var checksum = 0;
  44304. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44305. var quad = readUint32(file, j);
  44306. checksum = checksum + quad >>> 0;
  44307. }
  44308. writeInt32(file, offset + 4, checksum);
  44309. writeInt32(file, offset + 8, tableOffsets[i]);
  44310. writeInt32(file, offset + 12, tables[tableName].length);
  44311. offset += OTF_TABLE_ENTRY_SIZE;
  44312. }
  44313. return file;
  44314. },
  44315. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44316. if (tag in this.tables) {
  44317. throw new Error('Table ' + tag + ' already exists');
  44318. }
  44319. this.tables[tag] = data;
  44320. }
  44321. };
  44322. return OpenTypeFileBuilder;
  44323. }();
  44324. var ProblematicCharRanges = new Int32Array([
  44325. 0x0000,
  44326. 0x0020,
  44327. 0x007F,
  44328. 0x00A1,
  44329. 0x00AD,
  44330. 0x00AE,
  44331. 0x0600,
  44332. 0x0780,
  44333. 0x08A0,
  44334. 0x10A0,
  44335. 0x1780,
  44336. 0x1800,
  44337. 0x1C00,
  44338. 0x1C50,
  44339. 0x2000,
  44340. 0x2010,
  44341. 0x2011,
  44342. 0x2012,
  44343. 0x2028,
  44344. 0x2030,
  44345. 0x205F,
  44346. 0x2070,
  44347. 0x25CC,
  44348. 0x25CD,
  44349. 0x3000,
  44350. 0x3001,
  44351. 0xAA60,
  44352. 0xAA80,
  44353. 0xFFF0,
  44354. 0x10000
  44355. ]);
  44356. var Font = function FontClosure() {
  44357. function Font(name, file, properties) {
  44358. var charCode, glyphName, unicode;
  44359. this.name = name;
  44360. this.loadedName = properties.loadedName;
  44361. this.isType3Font = properties.isType3Font;
  44362. this.sizes = [];
  44363. this.missingFile = false;
  44364. this.glyphCache = Object.create(null);
  44365. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44366. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44367. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44368. var type = properties.type;
  44369. var subtype = properties.subtype;
  44370. this.type = type;
  44371. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44372. this.differences = properties.differences;
  44373. this.widths = properties.widths;
  44374. this.defaultWidth = properties.defaultWidth;
  44375. this.composite = properties.composite;
  44376. this.wideChars = properties.wideChars;
  44377. this.cMap = properties.cMap;
  44378. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44379. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44380. this.fontMatrix = properties.fontMatrix;
  44381. this.bbox = properties.bbox;
  44382. this.toUnicode = properties.toUnicode;
  44383. this.toFontChar = [];
  44384. if (properties.type === 'Type3') {
  44385. for (charCode = 0; charCode < 256; charCode++) {
  44386. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44387. }
  44388. this.fontType = FontType.TYPE3;
  44389. return;
  44390. }
  44391. this.cidEncoding = properties.cidEncoding;
  44392. this.vertical = properties.vertical;
  44393. if (this.vertical) {
  44394. this.vmetrics = properties.vmetrics;
  44395. this.defaultVMetrics = properties.defaultVMetrics;
  44396. }
  44397. var glyphsUnicodeMap;
  44398. if (!file || file.isEmpty) {
  44399. if (file) {
  44400. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44401. }
  44402. this.missingFile = true;
  44403. var fontName = name.replace(/[,_]/g, '-');
  44404. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44405. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44406. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44407. this.bold = fontName.search(/bold/gi) !== -1;
  44408. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44409. this.black = name.search(/Black/g) !== -1;
  44410. this.remeasure = Object.keys(this.widths).length > 0;
  44411. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44412. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44413. var map = [];
  44414. for (charCode in GlyphMapForStandardFonts) {
  44415. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44416. }
  44417. if (/Arial-?Black/i.test(name)) {
  44418. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44419. for (charCode in SupplementalGlyphMapForArialBlack) {
  44420. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44421. }
  44422. }
  44423. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44424. if (!isIdentityUnicode) {
  44425. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44426. map[+charCode] = unicodeCharCode;
  44427. });
  44428. }
  44429. this.toFontChar = map;
  44430. this.toUnicode = new ToUnicodeMap(map);
  44431. } else if (/Symbol/i.test(fontName)) {
  44432. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44433. } else if (/Dingbats/i.test(fontName)) {
  44434. if (/Wingdings/i.test(name)) {
  44435. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44436. }
  44437. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44438. } else if (isStandardFont) {
  44439. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44440. } else {
  44441. glyphsUnicodeMap = getGlyphsUnicode();
  44442. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44443. if (!this.composite) {
  44444. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44445. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44446. if (unicode !== -1) {
  44447. unicodeCharCode = unicode;
  44448. }
  44449. }
  44450. this.toFontChar[charCode] = unicodeCharCode;
  44451. }.bind(this));
  44452. }
  44453. this.loadedName = fontName.split('-')[0];
  44454. this.loading = false;
  44455. this.fontType = getFontType(type, subtype);
  44456. return;
  44457. }
  44458. if (subtype === 'Type1C') {
  44459. if (type !== 'Type1' && type !== 'MMType1') {
  44460. if (isTrueTypeFile(file)) {
  44461. subtype = 'TrueType';
  44462. } else {
  44463. type = 'Type1';
  44464. }
  44465. } else if (isOpenTypeFile(file)) {
  44466. type = subtype = 'OpenType';
  44467. }
  44468. }
  44469. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44470. type = 'CIDFontType0';
  44471. }
  44472. if (subtype === 'OpenType') {
  44473. type = 'OpenType';
  44474. }
  44475. if (type === 'CIDFontType0') {
  44476. if (isType1File(file)) {
  44477. subtype = 'CIDFontType0';
  44478. } else if (isOpenTypeFile(file)) {
  44479. type = subtype = 'OpenType';
  44480. } else {
  44481. subtype = 'CIDFontType0C';
  44482. }
  44483. }
  44484. var data;
  44485. switch (type) {
  44486. case 'MMType1':
  44487. info('MMType1 font (' + name + '), falling back to Type1.');
  44488. case 'Type1':
  44489. case 'CIDFontType0':
  44490. this.mimetype = 'font/opentype';
  44491. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44492. adjustWidths(properties);
  44493. data = this.convert(name, cff, properties);
  44494. break;
  44495. case 'OpenType':
  44496. case 'TrueType':
  44497. case 'CIDFontType2':
  44498. this.mimetype = 'font/opentype';
  44499. data = this.checkAndRepair(name, file, properties);
  44500. if (this.isOpenType) {
  44501. adjustWidths(properties);
  44502. type = 'OpenType';
  44503. }
  44504. break;
  44505. default:
  44506. error('Font ' + type + ' is not supported');
  44507. break;
  44508. }
  44509. this.data = data;
  44510. this.fontType = getFontType(type, subtype);
  44511. this.fontMatrix = properties.fontMatrix;
  44512. this.widths = properties.widths;
  44513. this.defaultWidth = properties.defaultWidth;
  44514. this.toUnicode = properties.toUnicode;
  44515. this.encoding = properties.baseEncoding;
  44516. this.seacMap = properties.seacMap;
  44517. this.loading = true;
  44518. }
  44519. Font.getFontID = function () {
  44520. var ID = 1;
  44521. return function Font_getFontID() {
  44522. return String(ID++);
  44523. };
  44524. }();
  44525. function int16(b0, b1) {
  44526. return (b0 << 8) + b1;
  44527. }
  44528. function signedInt16(b0, b1) {
  44529. var value = (b0 << 8) + b1;
  44530. return value & 1 << 15 ? value - 0x10000 : value;
  44531. }
  44532. function int32(b0, b1, b2, b3) {
  44533. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44534. }
  44535. function string16(value) {
  44536. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44537. }
  44538. function safeString16(value) {
  44539. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44540. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44541. }
  44542. function isTrueTypeFile(file) {
  44543. var header = file.peekBytes(4);
  44544. return readUint32(header, 0) === 0x00010000;
  44545. }
  44546. function isOpenTypeFile(file) {
  44547. var header = file.peekBytes(4);
  44548. return bytesToString(header) === 'OTTO';
  44549. }
  44550. function isType1File(file) {
  44551. var header = file.peekBytes(2);
  44552. if (header[0] === 0x25 && header[1] === 0x21) {
  44553. return true;
  44554. }
  44555. if (header[0] === 0x80 && header[1] === 0x01) {
  44556. return true;
  44557. }
  44558. return false;
  44559. }
  44560. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  44561. var toFontChar = [], unicode;
  44562. for (var i = 0, ii = encoding.length; i < ii; i++) {
  44563. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  44564. if (unicode !== -1) {
  44565. toFontChar[i] = unicode;
  44566. }
  44567. }
  44568. for (var charCode in differences) {
  44569. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  44570. if (unicode !== -1) {
  44571. toFontChar[+charCode] = unicode;
  44572. }
  44573. }
  44574. return toFontChar;
  44575. }
  44576. function isProblematicUnicodeLocation(code) {
  44577. var i = 0, j = ProblematicCharRanges.length - 1;
  44578. while (i < j) {
  44579. var c = i + j + 1 >> 1;
  44580. if (code < ProblematicCharRanges[c]) {
  44581. j = c - 1;
  44582. } else {
  44583. i = c;
  44584. }
  44585. }
  44586. return !(i & 1);
  44587. }
  44588. function adjustMapping(charCodeToGlyphId, properties) {
  44589. var toUnicode = properties.toUnicode;
  44590. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  44591. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  44592. var newMap = Object.create(null);
  44593. var toFontChar = [];
  44594. var usedFontCharCodes = [];
  44595. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  44596. for (var originalCharCode in charCodeToGlyphId) {
  44597. originalCharCode |= 0;
  44598. var glyphId = charCodeToGlyphId[originalCharCode];
  44599. var fontCharCode = originalCharCode;
  44600. var hasUnicodeValue = false;
  44601. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  44602. hasUnicodeValue = true;
  44603. var unicode = toUnicode.get(fontCharCode);
  44604. if (unicode.length === 1) {
  44605. fontCharCode = unicode.charCodeAt(0);
  44606. }
  44607. }
  44608. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  44609. do {
  44610. fontCharCode = nextAvailableFontCharCode++;
  44611. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  44612. fontCharCode = 0xF020;
  44613. nextAvailableFontCharCode = fontCharCode + 1;
  44614. }
  44615. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  44616. }
  44617. newMap[fontCharCode] = glyphId;
  44618. toFontChar[originalCharCode] = fontCharCode;
  44619. usedFontCharCodes[fontCharCode] = true;
  44620. }
  44621. return {
  44622. toFontChar: toFontChar,
  44623. charCodeToGlyphId: newMap,
  44624. nextAvailableFontCharCode: nextAvailableFontCharCode
  44625. };
  44626. }
  44627. function getRanges(glyphs, numGlyphs) {
  44628. var codes = [];
  44629. for (var charCode in glyphs) {
  44630. if (glyphs[charCode] >= numGlyphs) {
  44631. continue;
  44632. }
  44633. codes.push({
  44634. fontCharCode: charCode | 0,
  44635. glyphId: glyphs[charCode]
  44636. });
  44637. }
  44638. codes.sort(function fontGetRangesSort(a, b) {
  44639. return a.fontCharCode - b.fontCharCode;
  44640. });
  44641. var ranges = [];
  44642. var length = codes.length;
  44643. for (var n = 0; n < length;) {
  44644. var start = codes[n].fontCharCode;
  44645. var codeIndices = [codes[n].glyphId];
  44646. ++n;
  44647. var end = start;
  44648. while (n < length && end + 1 === codes[n].fontCharCode) {
  44649. codeIndices.push(codes[n].glyphId);
  44650. ++end;
  44651. ++n;
  44652. if (end === 0xFFFF) {
  44653. break;
  44654. }
  44655. }
  44656. ranges.push([
  44657. start,
  44658. end,
  44659. codeIndices
  44660. ]);
  44661. }
  44662. return ranges;
  44663. }
  44664. function createCmapTable(glyphs, numGlyphs) {
  44665. var ranges = getRanges(glyphs, numGlyphs);
  44666. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  44667. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  44668. var i, ii, j, jj;
  44669. for (i = ranges.length - 1; i >= 0; --i) {
  44670. if (ranges[i][0] <= 0xFFFF) {
  44671. break;
  44672. }
  44673. }
  44674. var bmpLength = i + 1;
  44675. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  44676. ranges[i][1] = 0xFFFE;
  44677. }
  44678. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  44679. var segCount = bmpLength + trailingRangesCount;
  44680. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  44681. var startCount = '';
  44682. var endCount = '';
  44683. var idDeltas = '';
  44684. var idRangeOffsets = '';
  44685. var glyphsIds = '';
  44686. var bias = 0;
  44687. var range, start, end, codes;
  44688. for (i = 0, ii = bmpLength; i < ii; i++) {
  44689. range = ranges[i];
  44690. start = range[0];
  44691. end = range[1];
  44692. startCount += string16(start);
  44693. endCount += string16(end);
  44694. codes = range[2];
  44695. var contiguous = true;
  44696. for (j = 1, jj = codes.length; j < jj; ++j) {
  44697. if (codes[j] !== codes[j - 1] + 1) {
  44698. contiguous = false;
  44699. break;
  44700. }
  44701. }
  44702. if (!contiguous) {
  44703. var offset = (segCount - i) * 2 + bias * 2;
  44704. bias += end - start + 1;
  44705. idDeltas += string16(0);
  44706. idRangeOffsets += string16(offset);
  44707. for (j = 0, jj = codes.length; j < jj; ++j) {
  44708. glyphsIds += string16(codes[j]);
  44709. }
  44710. } else {
  44711. var startCode = codes[0];
  44712. idDeltas += string16(startCode - start & 0xFFFF);
  44713. idRangeOffsets += string16(0);
  44714. }
  44715. }
  44716. if (trailingRangesCount > 0) {
  44717. endCount += '\xFF\xFF';
  44718. startCount += '\xFF\xFF';
  44719. idDeltas += '\x00\x01';
  44720. idRangeOffsets += '\x00\x00';
  44721. }
  44722. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  44723. var format31012 = '';
  44724. var header31012 = '';
  44725. if (numTables > 1) {
  44726. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  44727. format31012 = '';
  44728. for (i = 0, ii = ranges.length; i < ii; i++) {
  44729. range = ranges[i];
  44730. start = range[0];
  44731. codes = range[2];
  44732. var code = codes[0];
  44733. for (j = 1, jj = codes.length; j < jj; ++j) {
  44734. if (codes[j] !== codes[j - 1] + 1) {
  44735. end = range[0] + j - 1;
  44736. format31012 += string32(start) + string32(end) + string32(code);
  44737. start = end + 1;
  44738. code = codes[j];
  44739. }
  44740. }
  44741. format31012 += string32(start) + string32(range[1]) + string32(code);
  44742. }
  44743. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  44744. }
  44745. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  44746. }
  44747. function validateOS2Table(os2) {
  44748. var stream = new Stream(os2.data);
  44749. var version = stream.getUint16();
  44750. stream.getBytes(60);
  44751. var selection = stream.getUint16();
  44752. if (version < 4 && selection & 0x0300) {
  44753. return false;
  44754. }
  44755. var firstChar = stream.getUint16();
  44756. var lastChar = stream.getUint16();
  44757. if (firstChar > lastChar) {
  44758. return false;
  44759. }
  44760. stream.getBytes(6);
  44761. var usWinAscent = stream.getUint16();
  44762. if (usWinAscent === 0) {
  44763. return false;
  44764. }
  44765. os2.data[8] = os2.data[9] = 0;
  44766. return true;
  44767. }
  44768. function createOS2Table(properties, charstrings, override) {
  44769. override = override || {
  44770. unitsPerEm: 0,
  44771. yMax: 0,
  44772. yMin: 0,
  44773. ascent: 0,
  44774. descent: 0
  44775. };
  44776. var ulUnicodeRange1 = 0;
  44777. var ulUnicodeRange2 = 0;
  44778. var ulUnicodeRange3 = 0;
  44779. var ulUnicodeRange4 = 0;
  44780. var firstCharIndex = null;
  44781. var lastCharIndex = 0;
  44782. if (charstrings) {
  44783. for (var code in charstrings) {
  44784. code |= 0;
  44785. if (firstCharIndex > code || !firstCharIndex) {
  44786. firstCharIndex = code;
  44787. }
  44788. if (lastCharIndex < code) {
  44789. lastCharIndex = code;
  44790. }
  44791. var position = getUnicodeRangeFor(code);
  44792. if (position < 32) {
  44793. ulUnicodeRange1 |= 1 << position;
  44794. } else if (position < 64) {
  44795. ulUnicodeRange2 |= 1 << position - 32;
  44796. } else if (position < 96) {
  44797. ulUnicodeRange3 |= 1 << position - 64;
  44798. } else if (position < 123) {
  44799. ulUnicodeRange4 |= 1 << position - 96;
  44800. } else {
  44801. error('Unicode ranges Bits > 123 are reserved for internal usage');
  44802. }
  44803. }
  44804. } else {
  44805. firstCharIndex = 0;
  44806. lastCharIndex = 255;
  44807. }
  44808. var bbox = properties.bbox || [
  44809. 0,
  44810. 0,
  44811. 0,
  44812. 0
  44813. ];
  44814. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44815. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  44816. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  44817. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  44818. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  44819. typoDescent = -typoDescent;
  44820. }
  44821. var winAscent = override.yMax || typoAscent;
  44822. var winDescent = -override.yMin || -typoDescent;
  44823. 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';
  44824. }
  44825. function createPostTable(properties) {
  44826. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  44827. 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';
  44828. }
  44829. function createNameTable(name, proto) {
  44830. if (!proto) {
  44831. proto = [
  44832. [],
  44833. []
  44834. ];
  44835. }
  44836. var strings = [
  44837. proto[0][0] || 'Original licence',
  44838. proto[0][1] || name,
  44839. proto[0][2] || 'Unknown',
  44840. proto[0][3] || 'uniqueID',
  44841. proto[0][4] || name,
  44842. proto[0][5] || 'Version 0.11',
  44843. proto[0][6] || '',
  44844. proto[0][7] || 'Unknown',
  44845. proto[0][8] || 'Unknown',
  44846. proto[0][9] || 'Unknown'
  44847. ];
  44848. var stringsUnicode = [];
  44849. var i, ii, j, jj, str;
  44850. for (i = 0, ii = strings.length; i < ii; i++) {
  44851. str = proto[1][i] || strings[i];
  44852. var strBufUnicode = [];
  44853. for (j = 0, jj = str.length; j < jj; j++) {
  44854. strBufUnicode.push(string16(str.charCodeAt(j)));
  44855. }
  44856. stringsUnicode.push(strBufUnicode.join(''));
  44857. }
  44858. var names = [
  44859. strings,
  44860. stringsUnicode
  44861. ];
  44862. var platforms = [
  44863. '\x00\x01',
  44864. '\x00\x03'
  44865. ];
  44866. var encodings = [
  44867. '\x00\x00',
  44868. '\x00\x01'
  44869. ];
  44870. var languages = [
  44871. '\x00\x00',
  44872. '\x04\x09'
  44873. ];
  44874. var namesRecordCount = strings.length * platforms.length;
  44875. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44876. var strOffset = 0;
  44877. for (i = 0, ii = platforms.length; i < ii; i++) {
  44878. var strs = names[i];
  44879. for (j = 0, jj = strs.length; j < jj; j++) {
  44880. str = strs[j];
  44881. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44882. nameTable += nameRecord;
  44883. strOffset += str.length;
  44884. }
  44885. }
  44886. nameTable += strings.join('') + stringsUnicode.join('');
  44887. return nameTable;
  44888. }
  44889. Font.prototype = {
  44890. name: null,
  44891. font: null,
  44892. mimetype: null,
  44893. encoding: null,
  44894. get renderer() {
  44895. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44896. return shadow(this, 'renderer', renderer);
  44897. },
  44898. exportData: function Font_exportData() {
  44899. var data = {};
  44900. for (var i in this) {
  44901. if (this.hasOwnProperty(i)) {
  44902. data[i] = this[i];
  44903. }
  44904. }
  44905. return data;
  44906. },
  44907. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44908. function readTableEntry(file) {
  44909. var tag = bytesToString(file.getBytes(4));
  44910. var checksum = file.getInt32() >>> 0;
  44911. var offset = file.getInt32() >>> 0;
  44912. var length = file.getInt32() >>> 0;
  44913. var previousPosition = file.pos;
  44914. file.pos = file.start ? file.start : 0;
  44915. file.skip(offset);
  44916. var data = file.getBytes(length);
  44917. file.pos = previousPosition;
  44918. if (tag === 'head') {
  44919. data[8] = data[9] = data[10] = data[11] = 0;
  44920. data[17] |= 0x20;
  44921. }
  44922. return {
  44923. tag: tag,
  44924. checksum: checksum,
  44925. length: length,
  44926. offset: offset,
  44927. data: data
  44928. };
  44929. }
  44930. function readOpenTypeHeader(ttf) {
  44931. return {
  44932. version: bytesToString(ttf.getBytes(4)),
  44933. numTables: ttf.getUint16(),
  44934. searchRange: ttf.getUint16(),
  44935. entrySelector: ttf.getUint16(),
  44936. rangeShift: ttf.getUint16()
  44937. };
  44938. }
  44939. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44940. if (!cmap) {
  44941. warn('No cmap table available.');
  44942. return {
  44943. platformId: -1,
  44944. encodingId: -1,
  44945. mappings: [],
  44946. hasShortCmap: false
  44947. };
  44948. }
  44949. var segment;
  44950. var start = (font.start ? font.start : 0) + cmap.offset;
  44951. font.pos = start;
  44952. font.getUint16();
  44953. var numTables = font.getUint16();
  44954. var potentialTable;
  44955. var canBreak = false;
  44956. for (var i = 0; i < numTables; i++) {
  44957. var platformId = font.getUint16();
  44958. var encodingId = font.getUint16();
  44959. var offset = font.getInt32() >>> 0;
  44960. var useTable = false;
  44961. if (platformId === 0 && encodingId === 0) {
  44962. useTable = true;
  44963. } else if (platformId === 1 && encodingId === 0) {
  44964. useTable = true;
  44965. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44966. useTable = true;
  44967. if (!isSymbolicFont) {
  44968. canBreak = true;
  44969. }
  44970. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44971. useTable = true;
  44972. canBreak = true;
  44973. }
  44974. if (useTable) {
  44975. potentialTable = {
  44976. platformId: platformId,
  44977. encodingId: encodingId,
  44978. offset: offset
  44979. };
  44980. }
  44981. if (canBreak) {
  44982. break;
  44983. }
  44984. }
  44985. if (potentialTable) {
  44986. font.pos = start + potentialTable.offset;
  44987. }
  44988. if (!potentialTable || font.peekByte() === -1) {
  44989. warn('Could not find a preferred cmap table.');
  44990. return {
  44991. platformId: -1,
  44992. encodingId: -1,
  44993. mappings: [],
  44994. hasShortCmap: false
  44995. };
  44996. }
  44997. var format = font.getUint16();
  44998. font.getUint16();
  44999. font.getUint16();
  45000. var hasShortCmap = false;
  45001. var mappings = [];
  45002. var j, glyphId;
  45003. if (format === 0) {
  45004. for (j = 0; j < 256; j++) {
  45005. var index = font.getByte();
  45006. if (!index) {
  45007. continue;
  45008. }
  45009. mappings.push({
  45010. charCode: j,
  45011. glyphId: index
  45012. });
  45013. }
  45014. hasShortCmap = true;
  45015. } else if (format === 4) {
  45016. var segCount = font.getUint16() >> 1;
  45017. font.getBytes(6);
  45018. var segIndex, segments = [];
  45019. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45020. segments.push({ end: font.getUint16() });
  45021. }
  45022. font.getUint16();
  45023. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45024. segments[segIndex].start = font.getUint16();
  45025. }
  45026. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45027. segments[segIndex].delta = font.getUint16();
  45028. }
  45029. var offsetsCount = 0;
  45030. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45031. segment = segments[segIndex];
  45032. var rangeOffset = font.getUint16();
  45033. if (!rangeOffset) {
  45034. segment.offsetIndex = -1;
  45035. continue;
  45036. }
  45037. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  45038. segment.offsetIndex = offsetIndex;
  45039. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  45040. }
  45041. var offsets = [];
  45042. for (j = 0; j < offsetsCount; j++) {
  45043. offsets.push(font.getUint16());
  45044. }
  45045. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45046. segment = segments[segIndex];
  45047. start = segment.start;
  45048. var end = segment.end;
  45049. var delta = segment.delta;
  45050. offsetIndex = segment.offsetIndex;
  45051. for (j = start; j <= end; j++) {
  45052. if (j === 0xFFFF) {
  45053. continue;
  45054. }
  45055. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45056. glyphId = glyphId + delta & 0xFFFF;
  45057. if (glyphId === 0) {
  45058. continue;
  45059. }
  45060. mappings.push({
  45061. charCode: j,
  45062. glyphId: glyphId
  45063. });
  45064. }
  45065. }
  45066. } else if (format === 6) {
  45067. var firstCode = font.getUint16();
  45068. var entryCount = font.getUint16();
  45069. for (j = 0; j < entryCount; j++) {
  45070. glyphId = font.getUint16();
  45071. var charCode = firstCode + j;
  45072. mappings.push({
  45073. charCode: charCode,
  45074. glyphId: glyphId
  45075. });
  45076. }
  45077. } else {
  45078. warn('cmap table has unsupported format: ' + format);
  45079. return {
  45080. platformId: -1,
  45081. encodingId: -1,
  45082. mappings: [],
  45083. hasShortCmap: false
  45084. };
  45085. }
  45086. mappings.sort(function (a, b) {
  45087. return a.charCode - b.charCode;
  45088. });
  45089. for (i = 1; i < mappings.length; i++) {
  45090. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45091. mappings.splice(i, 1);
  45092. i--;
  45093. }
  45094. }
  45095. return {
  45096. platformId: potentialTable.platformId,
  45097. encodingId: potentialTable.encodingId,
  45098. mappings: mappings,
  45099. hasShortCmap: hasShortCmap
  45100. };
  45101. }
  45102. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45103. if (!header) {
  45104. if (metrics) {
  45105. metrics.data = null;
  45106. }
  45107. return;
  45108. }
  45109. font.pos = (font.start ? font.start : 0) + header.offset;
  45110. font.pos += header.length - 2;
  45111. var numOfMetrics = font.getUint16();
  45112. if (numOfMetrics > numGlyphs) {
  45113. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45114. numOfMetrics = numGlyphs;
  45115. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45116. header.data[35] = numOfMetrics & 0x00ff;
  45117. }
  45118. var numOfSidebearings = numGlyphs - numOfMetrics;
  45119. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45120. if (numMissing > 0) {
  45121. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45122. entries.set(metrics.data);
  45123. metrics.data = entries;
  45124. }
  45125. }
  45126. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45127. if (sourceEnd - sourceStart <= 12) {
  45128. return 0;
  45129. }
  45130. var glyf = source.subarray(sourceStart, sourceEnd);
  45131. var contoursCount = glyf[0] << 8 | glyf[1];
  45132. if (contoursCount & 0x8000) {
  45133. dest.set(glyf, destStart);
  45134. return glyf.length;
  45135. }
  45136. var i, j = 10, flagsCount = 0;
  45137. for (i = 0; i < contoursCount; i++) {
  45138. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45139. flagsCount = endPoint + 1;
  45140. j += 2;
  45141. }
  45142. var instructionsStart = j;
  45143. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45144. j += 2 + instructionsLength;
  45145. var instructionsEnd = j;
  45146. var coordinatesLength = 0;
  45147. for (i = 0; i < flagsCount; i++) {
  45148. var flag = glyf[j++];
  45149. if (flag & 0xC0) {
  45150. glyf[j - 1] = flag & 0x3F;
  45151. }
  45152. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45153. coordinatesLength += xyLength;
  45154. if (flag & 8) {
  45155. var repeat = glyf[j++];
  45156. i += repeat;
  45157. coordinatesLength += repeat * xyLength;
  45158. }
  45159. }
  45160. if (coordinatesLength === 0) {
  45161. return 0;
  45162. }
  45163. var glyphDataLength = j + coordinatesLength;
  45164. if (glyphDataLength > glyf.length) {
  45165. return 0;
  45166. }
  45167. if (!hintsValid && instructionsLength > 0) {
  45168. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45169. dest.set([
  45170. 0,
  45171. 0
  45172. ], destStart + instructionsStart);
  45173. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45174. glyphDataLength -= instructionsLength;
  45175. if (glyf.length - glyphDataLength > 3) {
  45176. glyphDataLength = glyphDataLength + 3 & ~3;
  45177. }
  45178. return glyphDataLength;
  45179. }
  45180. if (glyf.length - glyphDataLength > 3) {
  45181. glyphDataLength = glyphDataLength + 3 & ~3;
  45182. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45183. return glyphDataLength;
  45184. }
  45185. dest.set(glyf, destStart);
  45186. return glyf.length;
  45187. }
  45188. function sanitizeHead(head, numGlyphs, locaLength) {
  45189. var data = head.data;
  45190. var version = int32(data[0], data[1], data[2], data[3]);
  45191. if (version >> 16 !== 1) {
  45192. info('Attempting to fix invalid version in head table: ' + version);
  45193. data[0] = 0;
  45194. data[1] = 1;
  45195. data[2] = 0;
  45196. data[3] = 0;
  45197. }
  45198. var indexToLocFormat = int16(data[50], data[51]);
  45199. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45200. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45201. var numGlyphsPlusOne = numGlyphs + 1;
  45202. if (locaLength === numGlyphsPlusOne << 1) {
  45203. data[50] = 0;
  45204. data[51] = 0;
  45205. } else if (locaLength === numGlyphsPlusOne << 2) {
  45206. data[50] = 0;
  45207. data[51] = 1;
  45208. } else {
  45209. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45210. }
  45211. }
  45212. }
  45213. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45214. var itemSize, itemDecode, itemEncode;
  45215. if (isGlyphLocationsLong) {
  45216. itemSize = 4;
  45217. itemDecode = function fontItemDecodeLong(data, offset) {
  45218. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45219. };
  45220. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45221. data[offset] = value >>> 24 & 0xFF;
  45222. data[offset + 1] = value >> 16 & 0xFF;
  45223. data[offset + 2] = value >> 8 & 0xFF;
  45224. data[offset + 3] = value & 0xFF;
  45225. };
  45226. } else {
  45227. itemSize = 2;
  45228. itemDecode = function fontItemDecode(data, offset) {
  45229. return data[offset] << 9 | data[offset + 1] << 1;
  45230. };
  45231. itemEncode = function fontItemEncode(data, offset, value) {
  45232. data[offset] = value >> 9 & 0xFF;
  45233. data[offset + 1] = value >> 1 & 0xFF;
  45234. };
  45235. }
  45236. var locaData = loca.data;
  45237. var locaDataSize = itemSize * (1 + numGlyphs);
  45238. if (locaData.length !== locaDataSize) {
  45239. locaData = new Uint8Array(locaDataSize);
  45240. locaData.set(loca.data.subarray(0, locaDataSize));
  45241. loca.data = locaData;
  45242. }
  45243. var oldGlyfData = glyf.data;
  45244. var oldGlyfDataLength = oldGlyfData.length;
  45245. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45246. var startOffset = itemDecode(locaData, 0);
  45247. var writeOffset = 0;
  45248. var missingGlyphData = Object.create(null);
  45249. itemEncode(locaData, 0, writeOffset);
  45250. var i, j;
  45251. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45252. var endOffset = itemDecode(locaData, j);
  45253. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45254. endOffset = oldGlyfDataLength;
  45255. }
  45256. if (endOffset > oldGlyfDataLength) {
  45257. itemEncode(locaData, j, writeOffset);
  45258. startOffset = endOffset;
  45259. continue;
  45260. }
  45261. if (startOffset === endOffset) {
  45262. missingGlyphData[i] = true;
  45263. }
  45264. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45265. writeOffset += newLength;
  45266. itemEncode(locaData, j, writeOffset);
  45267. startOffset = endOffset;
  45268. }
  45269. if (writeOffset === 0) {
  45270. var simpleGlyph = new Uint8Array([
  45271. 0,
  45272. 1,
  45273. 0,
  45274. 0,
  45275. 0,
  45276. 0,
  45277. 0,
  45278. 0,
  45279. 0,
  45280. 0,
  45281. 0,
  45282. 0,
  45283. 0,
  45284. 0,
  45285. 49,
  45286. 0
  45287. ]);
  45288. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45289. itemEncode(locaData, j, simpleGlyph.length);
  45290. }
  45291. glyf.data = simpleGlyph;
  45292. return missingGlyphData;
  45293. }
  45294. if (dupFirstEntry) {
  45295. var firstEntryLength = itemDecode(locaData, itemSize);
  45296. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45297. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45298. } else {
  45299. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45300. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45301. }
  45302. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45303. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45304. } else {
  45305. glyf.data = newGlyfData.subarray(0, writeOffset);
  45306. }
  45307. return missingGlyphData;
  45308. }
  45309. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45310. var start = (font.start ? font.start : 0) + post.offset;
  45311. font.pos = start;
  45312. var length = post.length, end = start + length;
  45313. var version = font.getInt32();
  45314. font.getBytes(28);
  45315. var glyphNames;
  45316. var valid = true;
  45317. var i;
  45318. switch (version) {
  45319. case 0x00010000:
  45320. glyphNames = MacStandardGlyphOrdering;
  45321. break;
  45322. case 0x00020000:
  45323. var numGlyphs = font.getUint16();
  45324. if (numGlyphs !== maxpNumGlyphs) {
  45325. valid = false;
  45326. break;
  45327. }
  45328. var glyphNameIndexes = [];
  45329. for (i = 0; i < numGlyphs; ++i) {
  45330. var index = font.getUint16();
  45331. if (index >= 32768) {
  45332. valid = false;
  45333. break;
  45334. }
  45335. glyphNameIndexes.push(index);
  45336. }
  45337. if (!valid) {
  45338. break;
  45339. }
  45340. var customNames = [];
  45341. var strBuf = [];
  45342. while (font.pos < end) {
  45343. var stringLength = font.getByte();
  45344. strBuf.length = stringLength;
  45345. for (i = 0; i < stringLength; ++i) {
  45346. strBuf[i] = String.fromCharCode(font.getByte());
  45347. }
  45348. customNames.push(strBuf.join(''));
  45349. }
  45350. glyphNames = [];
  45351. for (i = 0; i < numGlyphs; ++i) {
  45352. var j = glyphNameIndexes[i];
  45353. if (j < 258) {
  45354. glyphNames.push(MacStandardGlyphOrdering[j]);
  45355. continue;
  45356. }
  45357. glyphNames.push(customNames[j - 258]);
  45358. }
  45359. break;
  45360. case 0x00030000:
  45361. break;
  45362. default:
  45363. warn('Unknown/unsupported post table version ' + version);
  45364. valid = false;
  45365. if (properties.defaultEncoding) {
  45366. glyphNames = properties.defaultEncoding;
  45367. }
  45368. break;
  45369. }
  45370. properties.glyphNames = glyphNames;
  45371. return valid;
  45372. }
  45373. function readNameTable(nameTable) {
  45374. var start = (font.start ? font.start : 0) + nameTable.offset;
  45375. font.pos = start;
  45376. var names = [
  45377. [],
  45378. []
  45379. ];
  45380. var length = nameTable.length, end = start + length;
  45381. var format = font.getUint16();
  45382. var FORMAT_0_HEADER_LENGTH = 6;
  45383. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45384. return names;
  45385. }
  45386. var numRecords = font.getUint16();
  45387. var stringsStart = font.getUint16();
  45388. var records = [];
  45389. var NAME_RECORD_LENGTH = 12;
  45390. var i, ii;
  45391. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45392. var r = {
  45393. platform: font.getUint16(),
  45394. encoding: font.getUint16(),
  45395. language: font.getUint16(),
  45396. name: font.getUint16(),
  45397. length: font.getUint16(),
  45398. offset: font.getUint16()
  45399. };
  45400. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45401. records.push(r);
  45402. }
  45403. }
  45404. for (i = 0, ii = records.length; i < ii; i++) {
  45405. var record = records[i];
  45406. if (record.length <= 0) {
  45407. continue;
  45408. }
  45409. var pos = start + stringsStart + record.offset;
  45410. if (pos + record.length > end) {
  45411. continue;
  45412. }
  45413. font.pos = pos;
  45414. var nameIndex = record.name;
  45415. if (record.encoding) {
  45416. var str = '';
  45417. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45418. str += String.fromCharCode(font.getUint16());
  45419. }
  45420. names[1][nameIndex] = str;
  45421. } else {
  45422. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45423. }
  45424. }
  45425. return names;
  45426. }
  45427. var TTOpsStackDeltas = [
  45428. 0,
  45429. 0,
  45430. 0,
  45431. 0,
  45432. 0,
  45433. 0,
  45434. 0,
  45435. 0,
  45436. -2,
  45437. -2,
  45438. -2,
  45439. -2,
  45440. 0,
  45441. 0,
  45442. -2,
  45443. -5,
  45444. -1,
  45445. -1,
  45446. -1,
  45447. -1,
  45448. -1,
  45449. -1,
  45450. -1,
  45451. -1,
  45452. 0,
  45453. 0,
  45454. -1,
  45455. 0,
  45456. -1,
  45457. -1,
  45458. -1,
  45459. -1,
  45460. 1,
  45461. -1,
  45462. -999,
  45463. 0,
  45464. 1,
  45465. 0,
  45466. -1,
  45467. -2,
  45468. 0,
  45469. -1,
  45470. -2,
  45471. -1,
  45472. -1,
  45473. 0,
  45474. -1,
  45475. -1,
  45476. 0,
  45477. 0,
  45478. -999,
  45479. -999,
  45480. -1,
  45481. -1,
  45482. -1,
  45483. -1,
  45484. -2,
  45485. -999,
  45486. -2,
  45487. -2,
  45488. -999,
  45489. 0,
  45490. -2,
  45491. -2,
  45492. 0,
  45493. 0,
  45494. -2,
  45495. 0,
  45496. -2,
  45497. 0,
  45498. 0,
  45499. 0,
  45500. -2,
  45501. -1,
  45502. -1,
  45503. 1,
  45504. 1,
  45505. 0,
  45506. 0,
  45507. -1,
  45508. -1,
  45509. -1,
  45510. -1,
  45511. -1,
  45512. -1,
  45513. -1,
  45514. 0,
  45515. 0,
  45516. -1,
  45517. 0,
  45518. -1,
  45519. -1,
  45520. 0,
  45521. -999,
  45522. -1,
  45523. -1,
  45524. -1,
  45525. -1,
  45526. -1,
  45527. -1,
  45528. 0,
  45529. 0,
  45530. 0,
  45531. 0,
  45532. 0,
  45533. 0,
  45534. 0,
  45535. 0,
  45536. 0,
  45537. 0,
  45538. 0,
  45539. 0,
  45540. -2,
  45541. -999,
  45542. -999,
  45543. -999,
  45544. -999,
  45545. -999,
  45546. -1,
  45547. -1,
  45548. -2,
  45549. -2,
  45550. 0,
  45551. 0,
  45552. 0,
  45553. 0,
  45554. -1,
  45555. -1,
  45556. -999,
  45557. -2,
  45558. -2,
  45559. 0,
  45560. 0,
  45561. -1,
  45562. -2,
  45563. -2,
  45564. 0,
  45565. 0,
  45566. 0,
  45567. -1,
  45568. -1,
  45569. -1,
  45570. -2
  45571. ];
  45572. function sanitizeTTProgram(table, ttContext) {
  45573. var data = table.data;
  45574. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  45575. var stack = [];
  45576. var callstack = [];
  45577. var functionsCalled = [];
  45578. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  45579. var inFDEF = false, ifLevel = 0, inELSE = 0;
  45580. for (var ii = data.length; i < ii;) {
  45581. var op = data[i++];
  45582. if (op === 0x40) {
  45583. n = data[i++];
  45584. if (inFDEF || inELSE) {
  45585. i += n;
  45586. } else {
  45587. for (j = 0; j < n; j++) {
  45588. stack.push(data[i++]);
  45589. }
  45590. }
  45591. } else if (op === 0x41) {
  45592. n = data[i++];
  45593. if (inFDEF || inELSE) {
  45594. i += n * 2;
  45595. } else {
  45596. for (j = 0; j < n; j++) {
  45597. b = data[i++];
  45598. stack.push(b << 8 | data[i++]);
  45599. }
  45600. }
  45601. } else if ((op & 0xF8) === 0xB0) {
  45602. n = op - 0xB0 + 1;
  45603. if (inFDEF || inELSE) {
  45604. i += n;
  45605. } else {
  45606. for (j = 0; j < n; j++) {
  45607. stack.push(data[i++]);
  45608. }
  45609. }
  45610. } else if ((op & 0xF8) === 0xB8) {
  45611. n = op - 0xB8 + 1;
  45612. if (inFDEF || inELSE) {
  45613. i += n * 2;
  45614. } else {
  45615. for (j = 0; j < n; j++) {
  45616. b = data[i++];
  45617. stack.push(b << 8 | data[i++]);
  45618. }
  45619. }
  45620. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  45621. if (!inFDEF && !inELSE) {
  45622. funcId = stack[stack.length - 1];
  45623. ttContext.functionsUsed[funcId] = true;
  45624. if (funcId in ttContext.functionsStackDeltas) {
  45625. stack.length += ttContext.functionsStackDeltas[funcId];
  45626. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  45627. callstack.push({
  45628. data: data,
  45629. i: i,
  45630. stackTop: stack.length - 1
  45631. });
  45632. functionsCalled.push(funcId);
  45633. pc = ttContext.functionsDefined[funcId];
  45634. if (!pc) {
  45635. warn('TT: CALL non-existent function');
  45636. ttContext.hintsValid = false;
  45637. return;
  45638. }
  45639. data = pc.data;
  45640. i = pc.i;
  45641. }
  45642. }
  45643. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  45644. if (inFDEF || inELSE) {
  45645. warn('TT: nested FDEFs not allowed');
  45646. tooComplexToFollowFunctions = true;
  45647. }
  45648. inFDEF = true;
  45649. lastDeff = i;
  45650. funcId = stack.pop();
  45651. ttContext.functionsDefined[funcId] = {
  45652. data: data,
  45653. i: i
  45654. };
  45655. } else if (op === 0x2D) {
  45656. if (inFDEF) {
  45657. inFDEF = false;
  45658. lastEndf = i;
  45659. } else {
  45660. pc = callstack.pop();
  45661. if (!pc) {
  45662. warn('TT: ENDF bad stack');
  45663. ttContext.hintsValid = false;
  45664. return;
  45665. }
  45666. funcId = functionsCalled.pop();
  45667. data = pc.data;
  45668. i = pc.i;
  45669. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  45670. }
  45671. } else if (op === 0x89) {
  45672. if (inFDEF || inELSE) {
  45673. warn('TT: nested IDEFs not allowed');
  45674. tooComplexToFollowFunctions = true;
  45675. }
  45676. inFDEF = true;
  45677. lastDeff = i;
  45678. } else if (op === 0x58) {
  45679. ++ifLevel;
  45680. } else if (op === 0x1B) {
  45681. inELSE = ifLevel;
  45682. } else if (op === 0x59) {
  45683. if (inELSE === ifLevel) {
  45684. inELSE = 0;
  45685. }
  45686. --ifLevel;
  45687. } else if (op === 0x1C) {
  45688. if (!inFDEF && !inELSE) {
  45689. var offset = stack[stack.length - 1];
  45690. if (offset > 0) {
  45691. i += offset - 1;
  45692. }
  45693. }
  45694. }
  45695. if (!inFDEF && !inELSE) {
  45696. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  45697. if (op >= 0x71 && op <= 0x75) {
  45698. n = stack.pop();
  45699. if (!isNaN(n)) {
  45700. stackDelta = -n * 2;
  45701. }
  45702. }
  45703. while (stackDelta < 0 && stack.length > 0) {
  45704. stack.pop();
  45705. stackDelta++;
  45706. }
  45707. while (stackDelta > 0) {
  45708. stack.push(NaN);
  45709. stackDelta--;
  45710. }
  45711. }
  45712. }
  45713. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  45714. var content = [data];
  45715. if (i > data.length) {
  45716. content.push(new Uint8Array(i - data.length));
  45717. }
  45718. if (lastDeff > lastEndf) {
  45719. warn('TT: complementing a missing function tail');
  45720. content.push(new Uint8Array([
  45721. 0x22,
  45722. 0x2D
  45723. ]));
  45724. }
  45725. foldTTTable(table, content);
  45726. }
  45727. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  45728. if (ttContext.tooComplexToFollowFunctions) {
  45729. return;
  45730. }
  45731. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  45732. warn('TT: more functions defined than expected');
  45733. ttContext.hintsValid = false;
  45734. return;
  45735. }
  45736. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  45737. if (j > maxFunctionDefs) {
  45738. warn('TT: invalid function id: ' + j);
  45739. ttContext.hintsValid = false;
  45740. return;
  45741. }
  45742. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  45743. warn('TT: undefined function: ' + j);
  45744. ttContext.hintsValid = false;
  45745. return;
  45746. }
  45747. }
  45748. }
  45749. function foldTTTable(table, content) {
  45750. if (content.length > 1) {
  45751. var newLength = 0;
  45752. var j, jj;
  45753. for (j = 0, jj = content.length; j < jj; j++) {
  45754. newLength += content[j].length;
  45755. }
  45756. newLength = newLength + 3 & ~3;
  45757. var result = new Uint8Array(newLength);
  45758. var pos = 0;
  45759. for (j = 0, jj = content.length; j < jj; j++) {
  45760. result.set(content[j], pos);
  45761. pos += content[j].length;
  45762. }
  45763. table.data = result;
  45764. table.length = newLength;
  45765. }
  45766. }
  45767. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  45768. var ttContext = {
  45769. functionsDefined: [],
  45770. functionsUsed: [],
  45771. functionsStackDeltas: [],
  45772. tooComplexToFollowFunctions: false,
  45773. hintsValid: true
  45774. };
  45775. if (fpgm) {
  45776. sanitizeTTProgram(fpgm, ttContext);
  45777. }
  45778. if (prep) {
  45779. sanitizeTTProgram(prep, ttContext);
  45780. }
  45781. if (fpgm) {
  45782. checkInvalidFunctions(ttContext, maxFunctionDefs);
  45783. }
  45784. if (cvt && cvt.length & 1) {
  45785. var cvtData = new Uint8Array(cvt.length + 1);
  45786. cvtData.set(cvt.data);
  45787. cvt.data = cvtData;
  45788. }
  45789. return ttContext.hintsValid;
  45790. }
  45791. font = new Stream(new Uint8Array(font.getBytes()));
  45792. var VALID_TABLES = [
  45793. 'OS/2',
  45794. 'cmap',
  45795. 'head',
  45796. 'hhea',
  45797. 'hmtx',
  45798. 'maxp',
  45799. 'name',
  45800. 'post',
  45801. 'loca',
  45802. 'glyf',
  45803. 'fpgm',
  45804. 'prep',
  45805. 'cvt ',
  45806. 'CFF '
  45807. ];
  45808. var header = readOpenTypeHeader(font);
  45809. var numTables = header.numTables;
  45810. var cff, cffFile;
  45811. var tables = Object.create(null);
  45812. tables['OS/2'] = null;
  45813. tables['cmap'] = null;
  45814. tables['head'] = null;
  45815. tables['hhea'] = null;
  45816. tables['hmtx'] = null;
  45817. tables['maxp'] = null;
  45818. tables['name'] = null;
  45819. tables['post'] = null;
  45820. var table;
  45821. for (var i = 0; i < numTables; i++) {
  45822. table = readTableEntry(font);
  45823. if (VALID_TABLES.indexOf(table.tag) < 0) {
  45824. continue;
  45825. }
  45826. if (table.length === 0) {
  45827. continue;
  45828. }
  45829. tables[table.tag] = table;
  45830. }
  45831. var isTrueType = !tables['CFF '];
  45832. if (!isTrueType) {
  45833. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  45834. cffFile = new Stream(tables['CFF '].data);
  45835. cff = new CFFFont(cffFile, properties);
  45836. adjustWidths(properties);
  45837. return this.convert(name, cff, properties);
  45838. }
  45839. delete tables['glyf'];
  45840. delete tables['loca'];
  45841. delete tables['fpgm'];
  45842. delete tables['prep'];
  45843. delete tables['cvt '];
  45844. this.isOpenType = true;
  45845. } else {
  45846. if (!tables['loca']) {
  45847. error('Required "loca" table is not found');
  45848. }
  45849. if (!tables['glyf']) {
  45850. warn('Required "glyf" table is not found -- trying to recover.');
  45851. tables['glyf'] = {
  45852. tag: 'glyf',
  45853. data: new Uint8Array(0)
  45854. };
  45855. }
  45856. this.isOpenType = false;
  45857. }
  45858. if (!tables['maxp']) {
  45859. error('Required "maxp" table is not found');
  45860. }
  45861. font.pos = (font.start || 0) + tables['maxp'].offset;
  45862. var version = font.getInt32();
  45863. var numGlyphs = font.getUint16();
  45864. var maxFunctionDefs = 0;
  45865. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45866. font.pos += 8;
  45867. var maxZones = font.getUint16();
  45868. if (maxZones > 2) {
  45869. tables['maxp'].data[14] = 0;
  45870. tables['maxp'].data[15] = 2;
  45871. }
  45872. font.pos += 4;
  45873. maxFunctionDefs = font.getUint16();
  45874. }
  45875. var dupFirstEntry = false;
  45876. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45877. dupFirstEntry = true;
  45878. numGlyphs++;
  45879. tables['maxp'].data[4] = numGlyphs >> 8;
  45880. tables['maxp'].data[5] = numGlyphs & 255;
  45881. }
  45882. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45883. if (!hintsValid) {
  45884. delete tables['fpgm'];
  45885. delete tables['prep'];
  45886. delete tables['cvt '];
  45887. }
  45888. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45889. if (!tables['head']) {
  45890. error('Required "head" table is not found');
  45891. }
  45892. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45893. var missingGlyphs = Object.create(null);
  45894. if (isTrueType) {
  45895. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45896. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45897. }
  45898. if (!tables['hhea']) {
  45899. error('Required "hhea" table is not found');
  45900. }
  45901. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45902. tables['hhea'].data[10] = 0xFF;
  45903. tables['hhea'].data[11] = 0xFF;
  45904. }
  45905. var metricsOverride = {
  45906. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45907. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45908. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45909. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45910. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45911. };
  45912. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45913. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45914. if (tables['post']) {
  45915. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45916. if (!valid) {
  45917. tables['post'] = null;
  45918. }
  45919. }
  45920. var charCodeToGlyphId = [], charCode;
  45921. var toUnicode = properties.toUnicode, widths = properties.widths;
  45922. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45923. function hasGlyph(glyphId, charCode, widthCode) {
  45924. if (!missingGlyphs[glyphId]) {
  45925. return true;
  45926. }
  45927. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45928. return true;
  45929. }
  45930. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45931. return true;
  45932. }
  45933. return false;
  45934. }
  45935. if (properties.composite) {
  45936. var cidToGidMap = properties.cidToGidMap || [];
  45937. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45938. properties.cMap.forEach(function (charCode, cid) {
  45939. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45940. var glyphId = -1;
  45941. if (isCidToGidMapEmpty) {
  45942. glyphId = cid;
  45943. } else if (cidToGidMap[cid] !== undefined) {
  45944. glyphId = cidToGidMap[cid];
  45945. }
  45946. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45947. charCodeToGlyphId[charCode] = glyphId;
  45948. }
  45949. });
  45950. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45951. charCodeToGlyphId[0] = numGlyphs - 1;
  45952. }
  45953. } else {
  45954. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45955. var cmapPlatformId = cmapTable.platformId;
  45956. var cmapEncodingId = cmapTable.encodingId;
  45957. var cmapMappings = cmapTable.mappings;
  45958. var cmapMappingsLength = cmapMappings.length;
  45959. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45960. var baseEncoding = [];
  45961. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45962. baseEncoding = getEncoding(properties.baseEncodingName);
  45963. }
  45964. var glyphsUnicodeMap = getGlyphsUnicode();
  45965. for (charCode = 0; charCode < 256; charCode++) {
  45966. var glyphName, standardGlyphName;
  45967. if (this.differences && charCode in this.differences) {
  45968. glyphName = this.differences[charCode];
  45969. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45970. glyphName = baseEncoding[charCode];
  45971. } else {
  45972. glyphName = StandardEncoding[charCode];
  45973. }
  45974. if (!glyphName) {
  45975. continue;
  45976. }
  45977. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45978. var unicodeOrCharCode, isUnicode = false;
  45979. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45980. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45981. isUnicode = true;
  45982. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45983. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45984. }
  45985. var found = false;
  45986. for (i = 0; i < cmapMappingsLength; ++i) {
  45987. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45988. continue;
  45989. }
  45990. var code = isUnicode ? charCode : unicodeOrCharCode;
  45991. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45992. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45993. found = true;
  45994. break;
  45995. }
  45996. }
  45997. if (!found && properties.glyphNames) {
  45998. var glyphId = properties.glyphNames.indexOf(glyphName);
  45999. if (glyphId === -1 && standardGlyphName !== glyphName) {
  46000. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  46001. }
  46002. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  46003. charCodeToGlyphId[charCode] = glyphId;
  46004. found = true;
  46005. }
  46006. }
  46007. if (!found) {
  46008. charCodeToGlyphId[charCode] = 0;
  46009. }
  46010. }
  46011. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  46012. for (i = 0; i < cmapMappingsLength; ++i) {
  46013. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  46014. }
  46015. } else {
  46016. for (i = 0; i < cmapMappingsLength; ++i) {
  46017. charCode = cmapMappings[i].charCode & 0xFF;
  46018. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  46019. }
  46020. }
  46021. }
  46022. if (charCodeToGlyphId.length === 0) {
  46023. charCodeToGlyphId[0] = 0;
  46024. }
  46025. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  46026. this.toFontChar = newMapping.toFontChar;
  46027. tables['cmap'] = {
  46028. tag: 'cmap',
  46029. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  46030. };
  46031. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  46032. tables['OS/2'] = {
  46033. tag: 'OS/2',
  46034. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  46035. };
  46036. }
  46037. if (!tables['post']) {
  46038. tables['post'] = {
  46039. tag: 'post',
  46040. data: createPostTable(properties)
  46041. };
  46042. }
  46043. if (!isTrueType) {
  46044. try {
  46045. cffFile = new Stream(tables['CFF '].data);
  46046. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  46047. cff = parser.parse();
  46048. var compiler = new CFFCompiler(cff);
  46049. tables['CFF '].data = compiler.compile();
  46050. } catch (e) {
  46051. warn('Failed to compile font ' + properties.loadedName);
  46052. }
  46053. }
  46054. if (!tables['name']) {
  46055. tables['name'] = {
  46056. tag: 'name',
  46057. data: createNameTable(this.name)
  46058. };
  46059. } else {
  46060. var namePrototype = readNameTable(tables['name']);
  46061. tables['name'].data = createNameTable(name, namePrototype);
  46062. }
  46063. var builder = new OpenTypeFileBuilder(header.version);
  46064. for (var tableTag in tables) {
  46065. builder.addTable(tableTag, tables[tableTag].data);
  46066. }
  46067. return builder.toArray();
  46068. },
  46069. convert: function Font_convert(fontName, font, properties) {
  46070. properties.fixedPitch = false;
  46071. if (properties.builtInEncoding) {
  46072. adjustToUnicode(properties, properties.builtInEncoding);
  46073. }
  46074. var mapping = font.getGlyphMapping(properties);
  46075. var newMapping = adjustMapping(mapping, properties);
  46076. this.toFontChar = newMapping.toFontChar;
  46077. var numGlyphs = font.numGlyphs;
  46078. function getCharCodes(charCodeToGlyphId, glyphId) {
  46079. var charCodes = null;
  46080. for (var charCode in charCodeToGlyphId) {
  46081. if (glyphId === charCodeToGlyphId[charCode]) {
  46082. if (!charCodes) {
  46083. charCodes = [];
  46084. }
  46085. charCodes.push(charCode | 0);
  46086. }
  46087. }
  46088. return charCodes;
  46089. }
  46090. function createCharCode(charCodeToGlyphId, glyphId) {
  46091. for (var charCode in charCodeToGlyphId) {
  46092. if (glyphId === charCodeToGlyphId[charCode]) {
  46093. return charCode | 0;
  46094. }
  46095. }
  46096. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46097. return newMapping.nextAvailableFontCharCode++;
  46098. }
  46099. var seacs = font.seacs;
  46100. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46101. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46102. var charset = font.getCharset();
  46103. var seacMap = Object.create(null);
  46104. for (var glyphId in seacs) {
  46105. glyphId |= 0;
  46106. var seac = seacs[glyphId];
  46107. var baseGlyphName = StandardEncoding[seac[2]];
  46108. var accentGlyphName = StandardEncoding[seac[3]];
  46109. var baseGlyphId = charset.indexOf(baseGlyphName);
  46110. var accentGlyphId = charset.indexOf(accentGlyphName);
  46111. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46112. continue;
  46113. }
  46114. var accentOffset = {
  46115. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46116. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46117. };
  46118. var charCodes = getCharCodes(mapping, glyphId);
  46119. if (!charCodes) {
  46120. continue;
  46121. }
  46122. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46123. var charCode = charCodes[i];
  46124. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46125. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46126. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46127. seacMap[charCode] = {
  46128. baseFontCharCode: baseFontCharCode,
  46129. accentFontCharCode: accentFontCharCode,
  46130. accentOffset: accentOffset
  46131. };
  46132. }
  46133. }
  46134. properties.seacMap = seacMap;
  46135. }
  46136. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46137. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46138. builder.addTable('CFF ', font.data);
  46139. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46140. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46141. 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');
  46142. 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));
  46143. builder.addTable('hmtx', function fontFieldsHmtx() {
  46144. var charstrings = font.charstrings;
  46145. var cffWidths = font.cff ? font.cff.widths : null;
  46146. var hmtx = '\x00\x00\x00\x00';
  46147. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46148. var width = 0;
  46149. if (charstrings) {
  46150. var charstring = charstrings[i - 1];
  46151. width = 'width' in charstring ? charstring.width : 0;
  46152. } else if (cffWidths) {
  46153. width = Math.ceil(cffWidths[i] || 0);
  46154. }
  46155. hmtx += string16(width) + string16(0);
  46156. }
  46157. return hmtx;
  46158. }());
  46159. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46160. builder.addTable('name', createNameTable(fontName));
  46161. builder.addTable('post', createPostTable(properties));
  46162. return builder.toArray();
  46163. },
  46164. get spaceWidth() {
  46165. if ('_shadowWidth' in this) {
  46166. return this._shadowWidth;
  46167. }
  46168. var possibleSpaceReplacements = [
  46169. 'space',
  46170. 'minus',
  46171. 'one',
  46172. 'i',
  46173. 'I'
  46174. ];
  46175. var width;
  46176. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46177. var glyphName = possibleSpaceReplacements[i];
  46178. if (glyphName in this.widths) {
  46179. width = this.widths[glyphName];
  46180. break;
  46181. }
  46182. var glyphsUnicodeMap = getGlyphsUnicode();
  46183. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46184. var charcode = 0;
  46185. if (this.composite) {
  46186. if (this.cMap.contains(glyphUnicode)) {
  46187. charcode = this.cMap.lookup(glyphUnicode);
  46188. }
  46189. }
  46190. if (!charcode && this.toUnicode) {
  46191. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46192. }
  46193. if (charcode <= 0) {
  46194. charcode = glyphUnicode;
  46195. }
  46196. width = this.widths[charcode];
  46197. if (width) {
  46198. break;
  46199. }
  46200. }
  46201. width = width || this.defaultWidth;
  46202. this._shadowWidth = width;
  46203. return width;
  46204. },
  46205. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46206. var fontCharCode, width, operatorListId;
  46207. var widthCode = charcode;
  46208. if (this.cMap && this.cMap.contains(charcode)) {
  46209. widthCode = this.cMap.lookup(charcode);
  46210. }
  46211. width = this.widths[widthCode];
  46212. width = isNum(width) ? width : this.defaultWidth;
  46213. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46214. var unicode = this.toUnicode.get(charcode) || charcode;
  46215. if (typeof unicode === 'number') {
  46216. unicode = String.fromCharCode(unicode);
  46217. }
  46218. var isInFont = charcode in this.toFontChar;
  46219. fontCharCode = this.toFontChar[charcode] || charcode;
  46220. if (this.missingFile) {
  46221. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46222. }
  46223. if (this.isType3Font) {
  46224. operatorListId = fontCharCode;
  46225. }
  46226. var accent = null;
  46227. if (this.seacMap && this.seacMap[charcode]) {
  46228. isInFont = true;
  46229. var seac = this.seacMap[charcode];
  46230. fontCharCode = seac.baseFontCharCode;
  46231. accent = {
  46232. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46233. offset: seac.accentOffset
  46234. };
  46235. }
  46236. var fontChar = String.fromCharCode(fontCharCode);
  46237. var glyph = this.glyphCache[charcode];
  46238. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46239. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46240. this.glyphCache[charcode] = glyph;
  46241. }
  46242. return glyph;
  46243. },
  46244. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46245. var charsCache = this.charsCache;
  46246. var glyphs, glyph, charcode;
  46247. if (charsCache) {
  46248. glyphs = charsCache[chars];
  46249. if (glyphs) {
  46250. return glyphs;
  46251. }
  46252. }
  46253. if (!charsCache) {
  46254. charsCache = this.charsCache = Object.create(null);
  46255. }
  46256. glyphs = [];
  46257. var charsCacheKey = chars;
  46258. var i = 0, ii;
  46259. if (this.cMap) {
  46260. var c = Object.create(null);
  46261. while (i < chars.length) {
  46262. this.cMap.readCharCode(chars, i, c);
  46263. charcode = c.charcode;
  46264. var length = c.length;
  46265. i += length;
  46266. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46267. glyph = this.charToGlyph(charcode, isSpace);
  46268. glyphs.push(glyph);
  46269. }
  46270. } else {
  46271. for (i = 0, ii = chars.length; i < ii; ++i) {
  46272. charcode = chars.charCodeAt(i);
  46273. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46274. glyphs.push(glyph);
  46275. }
  46276. }
  46277. return charsCache[charsCacheKey] = glyphs;
  46278. }
  46279. };
  46280. return Font;
  46281. }();
  46282. var ErrorFont = function ErrorFontClosure() {
  46283. function ErrorFont(error) {
  46284. this.error = error;
  46285. this.loadedName = 'g_font_error';
  46286. this.loading = false;
  46287. }
  46288. ErrorFont.prototype = {
  46289. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46290. return [];
  46291. },
  46292. exportData: function ErrorFont_exportData() {
  46293. return { error: this.error };
  46294. }
  46295. };
  46296. return ErrorFont;
  46297. }();
  46298. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46299. var charCodeToGlyphId = Object.create(null);
  46300. var glyphId, charCode, baseEncoding;
  46301. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46302. if (properties.baseEncodingName) {
  46303. baseEncoding = getEncoding(properties.baseEncodingName);
  46304. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46305. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46306. if (glyphId >= 0) {
  46307. charCodeToGlyphId[charCode] = glyphId;
  46308. } else {
  46309. charCodeToGlyphId[charCode] = 0;
  46310. }
  46311. }
  46312. } else if (isSymbolicFont) {
  46313. for (charCode in builtInEncoding) {
  46314. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46315. }
  46316. } else {
  46317. baseEncoding = StandardEncoding;
  46318. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46319. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46320. if (glyphId >= 0) {
  46321. charCodeToGlyphId[charCode] = glyphId;
  46322. } else {
  46323. charCodeToGlyphId[charCode] = 0;
  46324. }
  46325. }
  46326. }
  46327. var differences = properties.differences, glyphsUnicodeMap;
  46328. if (differences) {
  46329. for (charCode in differences) {
  46330. var glyphName = differences[charCode];
  46331. glyphId = glyphNames.indexOf(glyphName);
  46332. if (glyphId === -1) {
  46333. if (!glyphsUnicodeMap) {
  46334. glyphsUnicodeMap = getGlyphsUnicode();
  46335. }
  46336. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46337. if (standardGlyphName !== glyphName) {
  46338. glyphId = glyphNames.indexOf(standardGlyphName);
  46339. }
  46340. }
  46341. if (glyphId >= 0) {
  46342. charCodeToGlyphId[charCode] = glyphId;
  46343. } else {
  46344. charCodeToGlyphId[charCode] = 0;
  46345. }
  46346. }
  46347. }
  46348. return charCodeToGlyphId;
  46349. }
  46350. var Type1Font = function Type1FontClosure() {
  46351. function findBlock(streamBytes, signature, startIndex) {
  46352. var streamBytesLength = streamBytes.length;
  46353. var signatureLength = signature.length;
  46354. var scanLength = streamBytesLength - signatureLength;
  46355. var i = startIndex, j, found = false;
  46356. while (i < scanLength) {
  46357. j = 0;
  46358. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46359. j++;
  46360. }
  46361. if (j >= signatureLength) {
  46362. i += j;
  46363. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46364. i++;
  46365. }
  46366. found = true;
  46367. break;
  46368. }
  46369. i++;
  46370. }
  46371. return {
  46372. found: found,
  46373. length: i
  46374. };
  46375. }
  46376. function getHeaderBlock(stream, suggestedLength) {
  46377. var EEXEC_SIGNATURE = [
  46378. 0x65,
  46379. 0x65,
  46380. 0x78,
  46381. 0x65,
  46382. 0x63
  46383. ];
  46384. var streamStartPos = stream.pos;
  46385. var headerBytes, headerBytesLength, block;
  46386. try {
  46387. headerBytes = stream.getBytes(suggestedLength);
  46388. headerBytesLength = headerBytes.length;
  46389. } catch (ex) {
  46390. if (ex instanceof MissingDataException) {
  46391. throw ex;
  46392. }
  46393. }
  46394. if (headerBytesLength === suggestedLength) {
  46395. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46396. if (block.found && block.length === suggestedLength) {
  46397. return {
  46398. stream: new Stream(headerBytes),
  46399. length: suggestedLength
  46400. };
  46401. }
  46402. }
  46403. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46404. stream.pos = streamStartPos;
  46405. var SCAN_BLOCK_LENGTH = 2048;
  46406. var actualLength;
  46407. while (true) {
  46408. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46409. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46410. if (block.length === 0) {
  46411. break;
  46412. }
  46413. stream.pos += block.length;
  46414. if (block.found) {
  46415. actualLength = stream.pos - streamStartPos;
  46416. break;
  46417. }
  46418. }
  46419. stream.pos = streamStartPos;
  46420. if (actualLength) {
  46421. return {
  46422. stream: new Stream(stream.getBytes(actualLength)),
  46423. length: actualLength
  46424. };
  46425. }
  46426. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46427. return {
  46428. stream: new Stream(stream.getBytes(suggestedLength)),
  46429. length: suggestedLength
  46430. };
  46431. }
  46432. function getEexecBlock(stream, suggestedLength) {
  46433. var eexecBytes = stream.getBytes();
  46434. return {
  46435. stream: new Stream(eexecBytes),
  46436. length: eexecBytes.length
  46437. };
  46438. }
  46439. function Type1Font(name, file, properties) {
  46440. var PFB_HEADER_SIZE = 6;
  46441. var headerBlockLength = properties.length1;
  46442. var eexecBlockLength = properties.length2;
  46443. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46444. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46445. if (pfbHeaderPresent) {
  46446. file.skip(PFB_HEADER_SIZE);
  46447. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46448. }
  46449. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46450. headerBlockLength = headerBlock.length;
  46451. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46452. headerBlockParser.extractFontHeader(properties);
  46453. if (pfbHeaderPresent) {
  46454. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46455. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46456. }
  46457. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46458. eexecBlockLength = eexecBlock.length;
  46459. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46460. var data = eexecBlockParser.extractFontProgram();
  46461. for (var info in data.properties) {
  46462. properties[info] = data.properties[info];
  46463. }
  46464. var charstrings = data.charstrings;
  46465. var type2Charstrings = this.getType2Charstrings(charstrings);
  46466. var subrs = this.getType2Subrs(data.subrs);
  46467. this.charstrings = charstrings;
  46468. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46469. this.seacs = this.getSeacs(data.charstrings);
  46470. }
  46471. Type1Font.prototype = {
  46472. get numGlyphs() {
  46473. return this.charstrings.length + 1;
  46474. },
  46475. getCharset: function Type1Font_getCharset() {
  46476. var charset = ['.notdef'];
  46477. var charstrings = this.charstrings;
  46478. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46479. charset.push(charstrings[glyphId].glyphName);
  46480. }
  46481. return charset;
  46482. },
  46483. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46484. var charstrings = this.charstrings;
  46485. var glyphNames = ['.notdef'], glyphId;
  46486. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46487. glyphNames.push(charstrings[glyphId].glyphName);
  46488. }
  46489. var encoding = properties.builtInEncoding;
  46490. if (encoding) {
  46491. var builtInEncoding = Object.create(null);
  46492. for (var charCode in encoding) {
  46493. glyphId = glyphNames.indexOf(encoding[charCode]);
  46494. if (glyphId >= 0) {
  46495. builtInEncoding[charCode] = glyphId;
  46496. }
  46497. }
  46498. }
  46499. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46500. },
  46501. getSeacs: function Type1Font_getSeacs(charstrings) {
  46502. var i, ii;
  46503. var seacMap = [];
  46504. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46505. var charstring = charstrings[i];
  46506. if (charstring.seac) {
  46507. seacMap[i + 1] = charstring.seac;
  46508. }
  46509. }
  46510. return seacMap;
  46511. },
  46512. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46513. var type2Charstrings = [];
  46514. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46515. type2Charstrings.push(type1Charstrings[i].charstring);
  46516. }
  46517. return type2Charstrings;
  46518. },
  46519. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46520. var bias = 0;
  46521. var count = type1Subrs.length;
  46522. if (count < 1133) {
  46523. bias = 107;
  46524. } else if (count < 33769) {
  46525. bias = 1131;
  46526. } else {
  46527. bias = 32768;
  46528. }
  46529. var type2Subrs = [];
  46530. var i;
  46531. for (i = 0; i < bias; i++) {
  46532. type2Subrs.push([0x0B]);
  46533. }
  46534. for (i = 0; i < count; i++) {
  46535. type2Subrs.push(type1Subrs[i]);
  46536. }
  46537. return type2Subrs;
  46538. },
  46539. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46540. var cff = new CFF();
  46541. cff.header = new CFFHeader(1, 0, 4, 4);
  46542. cff.names = [name];
  46543. var topDict = new CFFTopDict();
  46544. topDict.setByName('version', 391);
  46545. topDict.setByName('Notice', 392);
  46546. topDict.setByName('FullName', 393);
  46547. topDict.setByName('FamilyName', 394);
  46548. topDict.setByName('Weight', 395);
  46549. topDict.setByName('Encoding', null);
  46550. topDict.setByName('FontMatrix', properties.fontMatrix);
  46551. topDict.setByName('FontBBox', properties.bbox);
  46552. topDict.setByName('charset', null);
  46553. topDict.setByName('CharStrings', null);
  46554. topDict.setByName('Private', null);
  46555. cff.topDict = topDict;
  46556. var strings = new CFFStrings();
  46557. strings.add('Version 0.11');
  46558. strings.add('See original notice');
  46559. strings.add(name);
  46560. strings.add(name);
  46561. strings.add('Medium');
  46562. cff.strings = strings;
  46563. cff.globalSubrIndex = new CFFIndex();
  46564. var count = glyphs.length;
  46565. var charsetArray = [0];
  46566. var i, ii;
  46567. for (i = 0; i < count; i++) {
  46568. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  46569. if (index === -1) {
  46570. index = 0;
  46571. }
  46572. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  46573. }
  46574. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  46575. var charStringsIndex = new CFFIndex();
  46576. charStringsIndex.add([
  46577. 0x8B,
  46578. 0x0E
  46579. ]);
  46580. for (i = 0; i < count; i++) {
  46581. var glyph = glyphs[i];
  46582. if (glyph.length === 0) {
  46583. charStringsIndex.add([
  46584. 0x8B,
  46585. 0x0E
  46586. ]);
  46587. continue;
  46588. }
  46589. charStringsIndex.add(glyph);
  46590. }
  46591. cff.charStrings = charStringsIndex;
  46592. var privateDict = new CFFPrivateDict();
  46593. privateDict.setByName('Subrs', null);
  46594. var fields = [
  46595. 'BlueValues',
  46596. 'OtherBlues',
  46597. 'FamilyBlues',
  46598. 'FamilyOtherBlues',
  46599. 'StemSnapH',
  46600. 'StemSnapV',
  46601. 'BlueShift',
  46602. 'BlueFuzz',
  46603. 'BlueScale',
  46604. 'LanguageGroup',
  46605. 'ExpansionFactor',
  46606. 'ForceBold',
  46607. 'StdHW',
  46608. 'StdVW'
  46609. ];
  46610. for (i = 0, ii = fields.length; i < ii; i++) {
  46611. var field = fields[i];
  46612. if (!(field in properties.privateData)) {
  46613. continue;
  46614. }
  46615. var value = properties.privateData[field];
  46616. if (isArray(value)) {
  46617. for (var j = value.length - 1; j > 0; j--) {
  46618. value[j] -= value[j - 1];
  46619. }
  46620. }
  46621. privateDict.setByName(field, value);
  46622. }
  46623. cff.topDict.privateDict = privateDict;
  46624. var subrIndex = new CFFIndex();
  46625. for (i = 0, ii = subrs.length; i < ii; i++) {
  46626. subrIndex.add(subrs[i]);
  46627. }
  46628. privateDict.subrsIndex = subrIndex;
  46629. var compiler = new CFFCompiler(cff);
  46630. return compiler.compile();
  46631. }
  46632. };
  46633. return Type1Font;
  46634. }();
  46635. var CFFFont = function CFFFontClosure() {
  46636. function CFFFont(file, properties) {
  46637. this.properties = properties;
  46638. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  46639. this.cff = parser.parse();
  46640. var compiler = new CFFCompiler(this.cff);
  46641. this.seacs = this.cff.seacs;
  46642. try {
  46643. this.data = compiler.compile();
  46644. } catch (e) {
  46645. warn('Failed to compile font ' + properties.loadedName);
  46646. this.data = file;
  46647. }
  46648. }
  46649. CFFFont.prototype = {
  46650. get numGlyphs() {
  46651. return this.cff.charStrings.count;
  46652. },
  46653. getCharset: function CFFFont_getCharset() {
  46654. return this.cff.charset.charset;
  46655. },
  46656. getGlyphMapping: function CFFFont_getGlyphMapping() {
  46657. var cff = this.cff;
  46658. var properties = this.properties;
  46659. var charsets = cff.charset.charset;
  46660. var charCodeToGlyphId;
  46661. var glyphId;
  46662. if (properties.composite) {
  46663. charCodeToGlyphId = Object.create(null);
  46664. if (cff.isCIDFont) {
  46665. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  46666. var cid = charsets[glyphId];
  46667. var charCode = properties.cMap.charCodeOf(cid);
  46668. charCodeToGlyphId[charCode] = glyphId;
  46669. }
  46670. } else {
  46671. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  46672. charCodeToGlyphId[glyphId] = glyphId;
  46673. }
  46674. }
  46675. return charCodeToGlyphId;
  46676. }
  46677. var encoding = cff.encoding ? cff.encoding.encoding : null;
  46678. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  46679. return charCodeToGlyphId;
  46680. }
  46681. };
  46682. return CFFFont;
  46683. }();
  46684. (function checkSeacSupport() {
  46685. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  46686. SEAC_ANALYSIS_ENABLED = true;
  46687. }
  46688. }());
  46689. (function checkChromeWindows() {
  46690. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  46691. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  46692. }
  46693. }());
  46694. exports.ErrorFont = ErrorFont;
  46695. exports.Font = Font;
  46696. exports.FontFlags = FontFlags;
  46697. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  46698. exports.ToUnicodeMap = ToUnicodeMap;
  46699. exports.getFontType = getFontType;
  46700. /***/ }),
  46701. /* 34 */
  46702. /***/ (function(module, exports, __w_pdfjs_require__) {
  46703. "use strict";
  46704. var sharedUtil = __w_pdfjs_require__(0);
  46705. var corePrimitives = __w_pdfjs_require__(1);
  46706. var coreColorSpace = __w_pdfjs_require__(4);
  46707. var coreStream = __w_pdfjs_require__(2);
  46708. var coreJpx = __w_pdfjs_require__(18);
  46709. var ImageKind = sharedUtil.ImageKind;
  46710. var assert = sharedUtil.assert;
  46711. var error = sharedUtil.error;
  46712. var info = sharedUtil.info;
  46713. var isArray = sharedUtil.isArray;
  46714. var warn = sharedUtil.warn;
  46715. var Name = corePrimitives.Name;
  46716. var isStream = corePrimitives.isStream;
  46717. var ColorSpace = coreColorSpace.ColorSpace;
  46718. var DecodeStream = coreStream.DecodeStream;
  46719. var JpegStream = coreStream.JpegStream;
  46720. var JpxImage = coreJpx.JpxImage;
  46721. var PDFImage = function PDFImageClosure() {
  46722. function handleImageData(image, nativeDecoder) {
  46723. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  46724. return nativeDecoder.decode(image);
  46725. }
  46726. return Promise.resolve(image);
  46727. }
  46728. function decodeAndClamp(value, addend, coefficient, max) {
  46729. value = addend + value * coefficient;
  46730. return value < 0 ? 0 : value > max ? max : value;
  46731. }
  46732. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46733. var length = w2 * h2;
  46734. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46735. var xRatio = w1 / w2;
  46736. var yRatio = h1 / h2;
  46737. var i, j, py, newIndex = 0, oldIndex;
  46738. var xScaled = new Uint16Array(w2);
  46739. var w1Scanline = w1;
  46740. for (i = 0; i < w2; i++) {
  46741. xScaled[i] = Math.floor(i * xRatio);
  46742. }
  46743. for (i = 0; i < h2; i++) {
  46744. py = Math.floor(i * yRatio) * w1Scanline;
  46745. for (j = 0; j < w2; j++) {
  46746. oldIndex = py + xScaled[j];
  46747. dest[newIndex++] = src[oldIndex];
  46748. }
  46749. }
  46750. return dest;
  46751. }
  46752. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  46753. this.image = image;
  46754. var dict = image.dict;
  46755. if (dict.has('Filter')) {
  46756. var filter = dict.get('Filter').name;
  46757. if (filter === 'JPXDecode') {
  46758. var jpxImage = new JpxImage();
  46759. jpxImage.parseImageProperties(image.stream);
  46760. image.stream.reset();
  46761. image.bitsPerComponent = jpxImage.bitsPerComponent;
  46762. image.numComps = jpxImage.componentsCount;
  46763. } else if (filter === 'JBIG2Decode') {
  46764. image.bitsPerComponent = 1;
  46765. image.numComps = 1;
  46766. }
  46767. }
  46768. this.width = dict.get('Width', 'W');
  46769. this.height = dict.get('Height', 'H');
  46770. if (this.width < 1 || this.height < 1) {
  46771. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  46772. }
  46773. this.interpolate = dict.get('Interpolate', 'I') || false;
  46774. this.imageMask = dict.get('ImageMask', 'IM') || false;
  46775. this.matte = dict.get('Matte') || false;
  46776. var bitsPerComponent = image.bitsPerComponent;
  46777. if (!bitsPerComponent) {
  46778. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  46779. if (!bitsPerComponent) {
  46780. if (this.imageMask) {
  46781. bitsPerComponent = 1;
  46782. } else {
  46783. error('Bits per component missing in image: ' + this.imageMask);
  46784. }
  46785. }
  46786. }
  46787. this.bpc = bitsPerComponent;
  46788. if (!this.imageMask) {
  46789. var colorSpace = dict.get('ColorSpace', 'CS');
  46790. if (!colorSpace) {
  46791. info('JPX images (which do not require color spaces)');
  46792. switch (image.numComps) {
  46793. case 1:
  46794. colorSpace = Name.get('DeviceGray');
  46795. break;
  46796. case 3:
  46797. colorSpace = Name.get('DeviceRGB');
  46798. break;
  46799. case 4:
  46800. colorSpace = Name.get('DeviceCMYK');
  46801. break;
  46802. default:
  46803. error('JPX images with ' + this.numComps + ' color components not supported.');
  46804. }
  46805. }
  46806. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  46807. this.numComps = this.colorSpace.numComps;
  46808. }
  46809. this.decode = dict.getArray('Decode', 'D');
  46810. this.needsDecode = false;
  46811. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  46812. this.needsDecode = true;
  46813. var max = (1 << bitsPerComponent) - 1;
  46814. this.decodeCoefficients = [];
  46815. this.decodeAddends = [];
  46816. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  46817. var dmin = this.decode[i];
  46818. var dmax = this.decode[i + 1];
  46819. this.decodeCoefficients[j] = dmax - dmin;
  46820. this.decodeAddends[j] = max * dmin;
  46821. }
  46822. }
  46823. if (smask) {
  46824. this.smask = new PDFImage(xref, res, smask, false);
  46825. } else if (mask) {
  46826. if (isStream(mask)) {
  46827. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  46828. if (!imageMask) {
  46829. warn('Ignoring /Mask in image without /ImageMask.');
  46830. } else {
  46831. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  46832. }
  46833. } else {
  46834. this.mask = mask;
  46835. }
  46836. }
  46837. }
  46838. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46839. var imagePromise = handleImageData(image, nativeDecoder);
  46840. var smaskPromise;
  46841. var maskPromise;
  46842. var smask = image.dict.get('SMask');
  46843. var mask = image.dict.get('Mask');
  46844. if (smask) {
  46845. smaskPromise = handleImageData(smask, nativeDecoder);
  46846. maskPromise = Promise.resolve(null);
  46847. } else {
  46848. smaskPromise = Promise.resolve(null);
  46849. if (mask) {
  46850. if (isStream(mask)) {
  46851. maskPromise = handleImageData(mask, nativeDecoder);
  46852. } else if (isArray(mask)) {
  46853. maskPromise = Promise.resolve(mask);
  46854. } else {
  46855. warn('Unsupported mask format.');
  46856. maskPromise = Promise.resolve(null);
  46857. }
  46858. } else {
  46859. maskPromise = Promise.resolve(null);
  46860. }
  46861. }
  46862. return Promise.all([
  46863. imagePromise,
  46864. smaskPromise,
  46865. maskPromise
  46866. ]).then(function (results) {
  46867. var imageData = results[0];
  46868. var smaskData = results[1];
  46869. var maskData = results[2];
  46870. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46871. });
  46872. };
  46873. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46874. var computedLength = (width + 7 >> 3) * height;
  46875. var actualLength = imgArray.byteLength;
  46876. var haveFullData = computedLength === actualLength;
  46877. var data, i;
  46878. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46879. data = imgArray;
  46880. } else if (!inverseDecode) {
  46881. data = new Uint8Array(actualLength);
  46882. data.set(imgArray);
  46883. } else {
  46884. data = new Uint8Array(computedLength);
  46885. data.set(imgArray);
  46886. for (i = actualLength; i < computedLength; i++) {
  46887. data[i] = 0xff;
  46888. }
  46889. }
  46890. if (inverseDecode) {
  46891. for (i = 0; i < actualLength; i++) {
  46892. data[i] = ~data[i];
  46893. }
  46894. }
  46895. return {
  46896. data: data,
  46897. width: width,
  46898. height: height
  46899. };
  46900. };
  46901. PDFImage.prototype = {
  46902. get drawWidth() {
  46903. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46904. },
  46905. get drawHeight() {
  46906. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46907. },
  46908. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46909. var bpc = this.bpc;
  46910. var numComps = this.numComps;
  46911. var decodeAddends = this.decodeAddends;
  46912. var decodeCoefficients = this.decodeCoefficients;
  46913. var max = (1 << bpc) - 1;
  46914. var i, ii;
  46915. if (bpc === 1) {
  46916. for (i = 0, ii = buffer.length; i < ii; i++) {
  46917. buffer[i] = +!buffer[i];
  46918. }
  46919. return;
  46920. }
  46921. var index = 0;
  46922. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46923. for (var j = 0; j < numComps; j++) {
  46924. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46925. index++;
  46926. }
  46927. }
  46928. },
  46929. getComponents: function PDFImage_getComponents(buffer) {
  46930. var bpc = this.bpc;
  46931. if (bpc === 8) {
  46932. return buffer;
  46933. }
  46934. var width = this.width;
  46935. var height = this.height;
  46936. var numComps = this.numComps;
  46937. var length = width * height * numComps;
  46938. var bufferPos = 0;
  46939. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46940. var rowComps = width * numComps;
  46941. var max = (1 << bpc) - 1;
  46942. var i = 0, ii, buf;
  46943. if (bpc === 1) {
  46944. var mask, loop1End, loop2End;
  46945. for (var j = 0; j < height; j++) {
  46946. loop1End = i + (rowComps & ~7);
  46947. loop2End = i + rowComps;
  46948. while (i < loop1End) {
  46949. buf = buffer[bufferPos++];
  46950. output[i] = buf >> 7 & 1;
  46951. output[i + 1] = buf >> 6 & 1;
  46952. output[i + 2] = buf >> 5 & 1;
  46953. output[i + 3] = buf >> 4 & 1;
  46954. output[i + 4] = buf >> 3 & 1;
  46955. output[i + 5] = buf >> 2 & 1;
  46956. output[i + 6] = buf >> 1 & 1;
  46957. output[i + 7] = buf & 1;
  46958. i += 8;
  46959. }
  46960. if (i < loop2End) {
  46961. buf = buffer[bufferPos++];
  46962. mask = 128;
  46963. while (i < loop2End) {
  46964. output[i++] = +!!(buf & mask);
  46965. mask >>= 1;
  46966. }
  46967. }
  46968. }
  46969. } else {
  46970. var bits = 0;
  46971. buf = 0;
  46972. for (i = 0, ii = length; i < ii; ++i) {
  46973. if (i % rowComps === 0) {
  46974. buf = 0;
  46975. bits = 0;
  46976. }
  46977. while (bits < bpc) {
  46978. buf = buf << 8 | buffer[bufferPos++];
  46979. bits += 8;
  46980. }
  46981. var remainingBits = bits - bpc;
  46982. var value = buf >> remainingBits;
  46983. output[i] = value < 0 ? 0 : value > max ? max : value;
  46984. buf = buf & (1 << remainingBits) - 1;
  46985. bits = remainingBits;
  46986. }
  46987. }
  46988. return output;
  46989. },
  46990. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46991. var smask = this.smask;
  46992. var mask = this.mask;
  46993. var alphaBuf, sw, sh, i, ii, j;
  46994. if (smask) {
  46995. sw = smask.width;
  46996. sh = smask.height;
  46997. alphaBuf = new Uint8Array(sw * sh);
  46998. smask.fillGrayBuffer(alphaBuf);
  46999. if (sw !== width || sh !== height) {
  47000. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  47001. }
  47002. } else if (mask) {
  47003. if (mask instanceof PDFImage) {
  47004. sw = mask.width;
  47005. sh = mask.height;
  47006. alphaBuf = new Uint8Array(sw * sh);
  47007. mask.numComps = 1;
  47008. mask.fillGrayBuffer(alphaBuf);
  47009. for (i = 0, ii = sw * sh; i < ii; ++i) {
  47010. alphaBuf[i] = 255 - alphaBuf[i];
  47011. }
  47012. if (sw !== width || sh !== height) {
  47013. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  47014. }
  47015. } else if (isArray(mask)) {
  47016. alphaBuf = new Uint8Array(width * height);
  47017. var numComps = this.numComps;
  47018. for (i = 0, ii = width * height; i < ii; ++i) {
  47019. var opacity = 0;
  47020. var imageOffset = i * numComps;
  47021. for (j = 0; j < numComps; ++j) {
  47022. var color = image[imageOffset + j];
  47023. var maskOffset = j * 2;
  47024. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  47025. opacity = 255;
  47026. break;
  47027. }
  47028. }
  47029. alphaBuf[i] = opacity;
  47030. }
  47031. } else {
  47032. error('Unknown mask format.');
  47033. }
  47034. }
  47035. if (alphaBuf) {
  47036. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47037. rgbaBuf[j] = alphaBuf[i];
  47038. }
  47039. } else {
  47040. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47041. rgbaBuf[j] = 255;
  47042. }
  47043. }
  47044. },
  47045. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47046. var matte = this.smask && this.smask.matte;
  47047. if (!matte) {
  47048. return;
  47049. }
  47050. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47051. var matteR = matteRgb[0];
  47052. var matteG = matteRgb[1];
  47053. var matteB = matteRgb[2];
  47054. var length = width * height * 4;
  47055. var r, g, b;
  47056. for (var i = 0; i < length; i += 4) {
  47057. var alpha = buffer[i + 3];
  47058. if (alpha === 0) {
  47059. buffer[i] = 255;
  47060. buffer[i + 1] = 255;
  47061. buffer[i + 2] = 255;
  47062. continue;
  47063. }
  47064. var k = 255 / alpha;
  47065. r = (buffer[i] - matteR) * k + matteR;
  47066. g = (buffer[i + 1] - matteG) * k + matteG;
  47067. b = (buffer[i + 2] - matteB) * k + matteB;
  47068. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47069. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47070. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47071. }
  47072. },
  47073. createImageData: function PDFImage_createImageData(forceRGBA) {
  47074. var drawWidth = this.drawWidth;
  47075. var drawHeight = this.drawHeight;
  47076. var imgData = {
  47077. width: drawWidth,
  47078. height: drawHeight
  47079. };
  47080. var numComps = this.numComps;
  47081. var originalWidth = this.width;
  47082. var originalHeight = this.height;
  47083. var bpc = this.bpc;
  47084. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47085. var imgArray;
  47086. if (!forceRGBA) {
  47087. var kind;
  47088. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47089. kind = ImageKind.GRAYSCALE_1BPP;
  47090. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47091. kind = ImageKind.RGB_24BPP;
  47092. }
  47093. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47094. imgData.kind = kind;
  47095. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47096. if (this.image instanceof DecodeStream) {
  47097. imgData.data = imgArray;
  47098. } else {
  47099. var newArray = new Uint8Array(imgArray.length);
  47100. newArray.set(imgArray);
  47101. imgData.data = newArray;
  47102. }
  47103. if (this.needsDecode) {
  47104. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47105. var buffer = imgData.data;
  47106. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47107. buffer[i] ^= 0xff;
  47108. }
  47109. }
  47110. return imgData;
  47111. }
  47112. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47113. imgData.kind = ImageKind.RGB_24BPP;
  47114. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47115. return imgData;
  47116. }
  47117. }
  47118. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47119. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47120. var comps = this.getComponents(imgArray);
  47121. var alpha01, maybeUndoPreblend;
  47122. if (!forceRGBA && !this.smask && !this.mask) {
  47123. imgData.kind = ImageKind.RGB_24BPP;
  47124. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47125. alpha01 = 0;
  47126. maybeUndoPreblend = false;
  47127. } else {
  47128. imgData.kind = ImageKind.RGBA_32BPP;
  47129. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47130. alpha01 = 1;
  47131. maybeUndoPreblend = true;
  47132. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47133. }
  47134. if (this.needsDecode) {
  47135. this.decodeBuffer(comps);
  47136. }
  47137. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47138. if (maybeUndoPreblend) {
  47139. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47140. }
  47141. return imgData;
  47142. },
  47143. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47144. var numComps = this.numComps;
  47145. if (numComps !== 1) {
  47146. error('Reading gray scale from a color image: ' + numComps);
  47147. }
  47148. var width = this.width;
  47149. var height = this.height;
  47150. var bpc = this.bpc;
  47151. var rowBytes = width * numComps * bpc + 7 >> 3;
  47152. var imgArray = this.getImageBytes(height * rowBytes);
  47153. var comps = this.getComponents(imgArray);
  47154. var i, length;
  47155. if (bpc === 1) {
  47156. length = width * height;
  47157. if (this.needsDecode) {
  47158. for (i = 0; i < length; ++i) {
  47159. buffer[i] = comps[i] - 1 & 255;
  47160. }
  47161. } else {
  47162. for (i = 0; i < length; ++i) {
  47163. buffer[i] = -comps[i] & 255;
  47164. }
  47165. }
  47166. return;
  47167. }
  47168. if (this.needsDecode) {
  47169. this.decodeBuffer(comps);
  47170. }
  47171. length = width * height;
  47172. var scale = 255 / ((1 << bpc) - 1);
  47173. for (i = 0; i < length; ++i) {
  47174. buffer[i] = scale * comps[i] | 0;
  47175. }
  47176. },
  47177. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47178. this.image.reset();
  47179. this.image.drawWidth = drawWidth || this.width;
  47180. this.image.drawHeight = drawHeight || this.height;
  47181. this.image.forceRGB = !!forceRGB;
  47182. return this.image.getBytes(length);
  47183. }
  47184. };
  47185. return PDFImage;
  47186. }();
  47187. exports.PDFImage = PDFImage;
  47188. /***/ }),
  47189. /* 35 */
  47190. /***/ (function(module, exports, __w_pdfjs_require__) {
  47191. "use strict";
  47192. var sharedUtil = __w_pdfjs_require__(0);
  47193. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  47194. var error = sharedUtil.error;
  47195. var log2 = sharedUtil.log2;
  47196. var readInt8 = sharedUtil.readInt8;
  47197. var readUint16 = sharedUtil.readUint16;
  47198. var readUint32 = sharedUtil.readUint32;
  47199. var shadow = sharedUtil.shadow;
  47200. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47201. var Jbig2Image = function Jbig2ImageClosure() {
  47202. function ContextCache() {
  47203. }
  47204. ContextCache.prototype = {
  47205. getContexts: function (id) {
  47206. if (id in this) {
  47207. return this[id];
  47208. }
  47209. return this[id] = new Int8Array(1 << 16);
  47210. }
  47211. };
  47212. function DecodingContext(data, start, end) {
  47213. this.data = data;
  47214. this.start = start;
  47215. this.end = end;
  47216. }
  47217. DecodingContext.prototype = {
  47218. get decoder() {
  47219. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47220. return shadow(this, 'decoder', decoder);
  47221. },
  47222. get contextCache() {
  47223. var cache = new ContextCache();
  47224. return shadow(this, 'contextCache', cache);
  47225. }
  47226. };
  47227. function decodeInteger(contextCache, procedure, decoder) {
  47228. var contexts = contextCache.getContexts(procedure);
  47229. var prev = 1;
  47230. function readBits(length) {
  47231. var v = 0;
  47232. for (var i = 0; i < length; i++) {
  47233. var bit = decoder.readBit(contexts, prev);
  47234. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47235. v = v << 1 | bit;
  47236. }
  47237. return v >>> 0;
  47238. }
  47239. var sign = readBits(1);
  47240. 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);
  47241. return sign === 0 ? value : value > 0 ? -value : null;
  47242. }
  47243. function decodeIAID(contextCache, decoder, codeLength) {
  47244. var contexts = contextCache.getContexts('IAID');
  47245. var prev = 1;
  47246. for (var i = 0; i < codeLength; i++) {
  47247. var bit = decoder.readBit(contexts, prev);
  47248. prev = prev << 1 | bit;
  47249. }
  47250. if (codeLength < 31) {
  47251. return prev & (1 << codeLength) - 1;
  47252. }
  47253. return prev & 0x7FFFFFFF;
  47254. }
  47255. var SegmentTypes = [
  47256. 'SymbolDictionary',
  47257. null,
  47258. null,
  47259. null,
  47260. 'IntermediateTextRegion',
  47261. null,
  47262. 'ImmediateTextRegion',
  47263. 'ImmediateLosslessTextRegion',
  47264. null,
  47265. null,
  47266. null,
  47267. null,
  47268. null,
  47269. null,
  47270. null,
  47271. null,
  47272. 'patternDictionary',
  47273. null,
  47274. null,
  47275. null,
  47276. 'IntermediateHalftoneRegion',
  47277. null,
  47278. 'ImmediateHalftoneRegion',
  47279. 'ImmediateLosslessHalftoneRegion',
  47280. null,
  47281. null,
  47282. null,
  47283. null,
  47284. null,
  47285. null,
  47286. null,
  47287. null,
  47288. null,
  47289. null,
  47290. null,
  47291. null,
  47292. 'IntermediateGenericRegion',
  47293. null,
  47294. 'ImmediateGenericRegion',
  47295. 'ImmediateLosslessGenericRegion',
  47296. 'IntermediateGenericRefinementRegion',
  47297. null,
  47298. 'ImmediateGenericRefinementRegion',
  47299. 'ImmediateLosslessGenericRefinementRegion',
  47300. null,
  47301. null,
  47302. null,
  47303. null,
  47304. 'PageInformation',
  47305. 'EndOfPage',
  47306. 'EndOfStripe',
  47307. 'EndOfFile',
  47308. 'Profiles',
  47309. 'Tables',
  47310. null,
  47311. null,
  47312. null,
  47313. null,
  47314. null,
  47315. null,
  47316. null,
  47317. null,
  47318. 'Extension'
  47319. ];
  47320. var CodingTemplates = [
  47321. [
  47322. {
  47323. x: -1,
  47324. y: -2
  47325. },
  47326. {
  47327. x: 0,
  47328. y: -2
  47329. },
  47330. {
  47331. x: 1,
  47332. y: -2
  47333. },
  47334. {
  47335. x: -2,
  47336. y: -1
  47337. },
  47338. {
  47339. x: -1,
  47340. y: -1
  47341. },
  47342. {
  47343. x: 0,
  47344. y: -1
  47345. },
  47346. {
  47347. x: 1,
  47348. y: -1
  47349. },
  47350. {
  47351. x: 2,
  47352. y: -1
  47353. },
  47354. {
  47355. x: -4,
  47356. y: 0
  47357. },
  47358. {
  47359. x: -3,
  47360. y: 0
  47361. },
  47362. {
  47363. x: -2,
  47364. y: 0
  47365. },
  47366. {
  47367. x: -1,
  47368. y: 0
  47369. }
  47370. ],
  47371. [
  47372. {
  47373. x: -1,
  47374. y: -2
  47375. },
  47376. {
  47377. x: 0,
  47378. y: -2
  47379. },
  47380. {
  47381. x: 1,
  47382. y: -2
  47383. },
  47384. {
  47385. x: 2,
  47386. y: -2
  47387. },
  47388. {
  47389. x: -2,
  47390. y: -1
  47391. },
  47392. {
  47393. x: -1,
  47394. y: -1
  47395. },
  47396. {
  47397. x: 0,
  47398. y: -1
  47399. },
  47400. {
  47401. x: 1,
  47402. y: -1
  47403. },
  47404. {
  47405. x: 2,
  47406. y: -1
  47407. },
  47408. {
  47409. x: -3,
  47410. y: 0
  47411. },
  47412. {
  47413. x: -2,
  47414. y: 0
  47415. },
  47416. {
  47417. x: -1,
  47418. y: 0
  47419. }
  47420. ],
  47421. [
  47422. {
  47423. x: -1,
  47424. y: -2
  47425. },
  47426. {
  47427. x: 0,
  47428. y: -2
  47429. },
  47430. {
  47431. x: 1,
  47432. y: -2
  47433. },
  47434. {
  47435. x: -2,
  47436. y: -1
  47437. },
  47438. {
  47439. x: -1,
  47440. y: -1
  47441. },
  47442. {
  47443. x: 0,
  47444. y: -1
  47445. },
  47446. {
  47447. x: 1,
  47448. y: -1
  47449. },
  47450. {
  47451. x: -2,
  47452. y: 0
  47453. },
  47454. {
  47455. x: -1,
  47456. y: 0
  47457. }
  47458. ],
  47459. [
  47460. {
  47461. x: -3,
  47462. y: -1
  47463. },
  47464. {
  47465. x: -2,
  47466. y: -1
  47467. },
  47468. {
  47469. x: -1,
  47470. y: -1
  47471. },
  47472. {
  47473. x: 0,
  47474. y: -1
  47475. },
  47476. {
  47477. x: 1,
  47478. y: -1
  47479. },
  47480. {
  47481. x: -4,
  47482. y: 0
  47483. },
  47484. {
  47485. x: -3,
  47486. y: 0
  47487. },
  47488. {
  47489. x: -2,
  47490. y: 0
  47491. },
  47492. {
  47493. x: -1,
  47494. y: 0
  47495. }
  47496. ]
  47497. ];
  47498. var RefinementTemplates = [
  47499. {
  47500. coding: [
  47501. {
  47502. x: 0,
  47503. y: -1
  47504. },
  47505. {
  47506. x: 1,
  47507. y: -1
  47508. },
  47509. {
  47510. x: -1,
  47511. y: 0
  47512. }
  47513. ],
  47514. reference: [
  47515. {
  47516. x: 0,
  47517. y: -1
  47518. },
  47519. {
  47520. x: 1,
  47521. y: -1
  47522. },
  47523. {
  47524. x: -1,
  47525. y: 0
  47526. },
  47527. {
  47528. x: 0,
  47529. y: 0
  47530. },
  47531. {
  47532. x: 1,
  47533. y: 0
  47534. },
  47535. {
  47536. x: -1,
  47537. y: 1
  47538. },
  47539. {
  47540. x: 0,
  47541. y: 1
  47542. },
  47543. {
  47544. x: 1,
  47545. y: 1
  47546. }
  47547. ]
  47548. },
  47549. {
  47550. coding: [
  47551. {
  47552. x: -1,
  47553. y: -1
  47554. },
  47555. {
  47556. x: 0,
  47557. y: -1
  47558. },
  47559. {
  47560. x: 1,
  47561. y: -1
  47562. },
  47563. {
  47564. x: -1,
  47565. y: 0
  47566. }
  47567. ],
  47568. reference: [
  47569. {
  47570. x: 0,
  47571. y: -1
  47572. },
  47573. {
  47574. x: -1,
  47575. y: 0
  47576. },
  47577. {
  47578. x: 0,
  47579. y: 0
  47580. },
  47581. {
  47582. x: 1,
  47583. y: 0
  47584. },
  47585. {
  47586. x: 0,
  47587. y: 1
  47588. },
  47589. {
  47590. x: 1,
  47591. y: 1
  47592. }
  47593. ]
  47594. }
  47595. ];
  47596. var ReusedContexts = [
  47597. 0x9B25,
  47598. 0x0795,
  47599. 0x00E5,
  47600. 0x0195
  47601. ];
  47602. var RefinementReusedContexts = [
  47603. 0x0020,
  47604. 0x0008
  47605. ];
  47606. function decodeBitmapTemplate0(width, height, decodingContext) {
  47607. var decoder = decodingContext.decoder;
  47608. var contexts = decodingContext.contextCache.getContexts('GB');
  47609. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  47610. var OLD_PIXEL_MASK = 0x7BF7;
  47611. for (i = 0; i < height; i++) {
  47612. row = bitmap[i] = new Uint8Array(width);
  47613. row1 = i < 1 ? row : bitmap[i - 1];
  47614. row2 = i < 2 ? row : bitmap[i - 2];
  47615. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  47616. for (j = 0; j < width; j++) {
  47617. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  47618. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  47619. }
  47620. }
  47621. return bitmap;
  47622. }
  47623. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  47624. if (mmr) {
  47625. error('JBIG2 error: MMR encoding is not supported');
  47626. }
  47627. 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) {
  47628. return decodeBitmapTemplate0(width, height, decodingContext);
  47629. }
  47630. var useskip = !!skip;
  47631. var template = CodingTemplates[templateIndex].concat(at);
  47632. template.sort(function (a, b) {
  47633. return a.y - b.y || a.x - b.x;
  47634. });
  47635. var templateLength = template.length;
  47636. var templateX = new Int8Array(templateLength);
  47637. var templateY = new Int8Array(templateLength);
  47638. var changingTemplateEntries = [];
  47639. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  47640. var c, k;
  47641. for (k = 0; k < templateLength; k++) {
  47642. templateX[k] = template[k].x;
  47643. templateY[k] = template[k].y;
  47644. minX = Math.min(minX, template[k].x);
  47645. maxX = Math.max(maxX, template[k].x);
  47646. minY = Math.min(minY, template[k].y);
  47647. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  47648. reuseMask |= 1 << templateLength - 1 - k;
  47649. } else {
  47650. changingTemplateEntries.push(k);
  47651. }
  47652. }
  47653. var changingEntriesLength = changingTemplateEntries.length;
  47654. var changingTemplateX = new Int8Array(changingEntriesLength);
  47655. var changingTemplateY = new Int8Array(changingEntriesLength);
  47656. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  47657. for (c = 0; c < changingEntriesLength; c++) {
  47658. k = changingTemplateEntries[c];
  47659. changingTemplateX[c] = template[k].x;
  47660. changingTemplateY[c] = template[k].y;
  47661. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  47662. }
  47663. var sbb_left = -minX;
  47664. var sbb_top = -minY;
  47665. var sbb_right = width - maxX;
  47666. var pseudoPixelContext = ReusedContexts[templateIndex];
  47667. var row = new Uint8Array(width);
  47668. var bitmap = [];
  47669. var decoder = decodingContext.decoder;
  47670. var contexts = decodingContext.contextCache.getContexts('GB');
  47671. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  47672. for (var i = 0; i < height; i++) {
  47673. if (prediction) {
  47674. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47675. ltp ^= sltp;
  47676. if (ltp) {
  47677. bitmap.push(row);
  47678. continue;
  47679. }
  47680. }
  47681. row = new Uint8Array(row);
  47682. bitmap.push(row);
  47683. for (j = 0; j < width; j++) {
  47684. if (useskip && skip[i][j]) {
  47685. row[j] = 0;
  47686. continue;
  47687. }
  47688. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  47689. contextLabel = contextLabel << 1 & reuseMask;
  47690. for (k = 0; k < changingEntriesLength; k++) {
  47691. i0 = i + changingTemplateY[k];
  47692. j0 = j + changingTemplateX[k];
  47693. bit = bitmap[i0][j0];
  47694. if (bit) {
  47695. bit = changingTemplateBit[k];
  47696. contextLabel |= bit;
  47697. }
  47698. }
  47699. } else {
  47700. contextLabel = 0;
  47701. shift = templateLength - 1;
  47702. for (k = 0; k < templateLength; k++, shift--) {
  47703. j0 = j + templateX[k];
  47704. if (j0 >= 0 && j0 < width) {
  47705. i0 = i + templateY[k];
  47706. if (i0 >= 0) {
  47707. bit = bitmap[i0][j0];
  47708. if (bit) {
  47709. contextLabel |= bit << shift;
  47710. }
  47711. }
  47712. }
  47713. }
  47714. }
  47715. var pixel = decoder.readBit(contexts, contextLabel);
  47716. row[j] = pixel;
  47717. }
  47718. }
  47719. return bitmap;
  47720. }
  47721. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  47722. var codingTemplate = RefinementTemplates[templateIndex].coding;
  47723. if (templateIndex === 0) {
  47724. codingTemplate = codingTemplate.concat([at[0]]);
  47725. }
  47726. var codingTemplateLength = codingTemplate.length;
  47727. var codingTemplateX = new Int32Array(codingTemplateLength);
  47728. var codingTemplateY = new Int32Array(codingTemplateLength);
  47729. var k;
  47730. for (k = 0; k < codingTemplateLength; k++) {
  47731. codingTemplateX[k] = codingTemplate[k].x;
  47732. codingTemplateY[k] = codingTemplate[k].y;
  47733. }
  47734. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  47735. if (templateIndex === 0) {
  47736. referenceTemplate = referenceTemplate.concat([at[1]]);
  47737. }
  47738. var referenceTemplateLength = referenceTemplate.length;
  47739. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  47740. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  47741. for (k = 0; k < referenceTemplateLength; k++) {
  47742. referenceTemplateX[k] = referenceTemplate[k].x;
  47743. referenceTemplateY[k] = referenceTemplate[k].y;
  47744. }
  47745. var referenceWidth = referenceBitmap[0].length;
  47746. var referenceHeight = referenceBitmap.length;
  47747. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  47748. var bitmap = [];
  47749. var decoder = decodingContext.decoder;
  47750. var contexts = decodingContext.contextCache.getContexts('GR');
  47751. var ltp = 0;
  47752. for (var i = 0; i < height; i++) {
  47753. if (prediction) {
  47754. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47755. ltp ^= sltp;
  47756. if (ltp) {
  47757. error('JBIG2 error: prediction is not supported');
  47758. }
  47759. }
  47760. var row = new Uint8Array(width);
  47761. bitmap.push(row);
  47762. for (var j = 0; j < width; j++) {
  47763. var i0, j0;
  47764. var contextLabel = 0;
  47765. for (k = 0; k < codingTemplateLength; k++) {
  47766. i0 = i + codingTemplateY[k];
  47767. j0 = j + codingTemplateX[k];
  47768. if (i0 < 0 || j0 < 0 || j0 >= width) {
  47769. contextLabel <<= 1;
  47770. } else {
  47771. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  47772. }
  47773. }
  47774. for (k = 0; k < referenceTemplateLength; k++) {
  47775. i0 = i + referenceTemplateY[k] + offsetY;
  47776. j0 = j + referenceTemplateX[k] + offsetX;
  47777. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  47778. contextLabel <<= 1;
  47779. } else {
  47780. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  47781. }
  47782. }
  47783. var pixel = decoder.readBit(contexts, contextLabel);
  47784. row[j] = pixel;
  47785. }
  47786. }
  47787. return bitmap;
  47788. }
  47789. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  47790. if (huffman) {
  47791. error('JBIG2 error: huffman is not supported');
  47792. }
  47793. var newSymbols = [];
  47794. var currentHeight = 0;
  47795. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  47796. var decoder = decodingContext.decoder;
  47797. var contextCache = decodingContext.contextCache;
  47798. while (newSymbols.length < numberOfNewSymbols) {
  47799. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  47800. currentHeight += deltaHeight;
  47801. var currentWidth = 0;
  47802. while (true) {
  47803. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  47804. if (deltaWidth === null) {
  47805. break;
  47806. }
  47807. currentWidth += deltaWidth;
  47808. var bitmap;
  47809. if (refinement) {
  47810. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  47811. if (numberOfInstances > 1) {
  47812. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  47813. } else {
  47814. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47815. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47816. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47817. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  47818. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  47819. }
  47820. } else {
  47821. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  47822. }
  47823. newSymbols.push(bitmap);
  47824. }
  47825. }
  47826. var exportedSymbols = [];
  47827. var flags = [], currentFlag = false;
  47828. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  47829. while (flags.length < totalSymbolsLength) {
  47830. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  47831. while (runLength--) {
  47832. flags.push(currentFlag);
  47833. }
  47834. currentFlag = !currentFlag;
  47835. }
  47836. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47837. if (flags[i]) {
  47838. exportedSymbols.push(symbols[i]);
  47839. }
  47840. }
  47841. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47842. if (flags[i]) {
  47843. exportedSymbols.push(newSymbols[j]);
  47844. }
  47845. }
  47846. return exportedSymbols;
  47847. }
  47848. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47849. if (huffman) {
  47850. error('JBIG2 error: huffman is not supported');
  47851. }
  47852. var bitmap = [];
  47853. var i, row;
  47854. for (i = 0; i < height; i++) {
  47855. row = new Uint8Array(width);
  47856. if (defaultPixelValue) {
  47857. for (var j = 0; j < width; j++) {
  47858. row[j] = defaultPixelValue;
  47859. }
  47860. }
  47861. bitmap.push(row);
  47862. }
  47863. var decoder = decodingContext.decoder;
  47864. var contextCache = decodingContext.contextCache;
  47865. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47866. var firstS = 0;
  47867. i = 0;
  47868. while (i < numberOfSymbolInstances) {
  47869. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47870. stripT += deltaT;
  47871. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47872. firstS += deltaFirstS;
  47873. var currentS = firstS;
  47874. do {
  47875. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47876. var t = stripSize * stripT + currentT;
  47877. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47878. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47879. var symbolBitmap = inputSymbols[symbolId];
  47880. var symbolWidth = symbolBitmap[0].length;
  47881. var symbolHeight = symbolBitmap.length;
  47882. if (applyRefinement) {
  47883. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47884. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47885. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47886. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47887. symbolWidth += rdw;
  47888. symbolHeight += rdh;
  47889. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47890. }
  47891. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47892. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47893. var s2, t2, symbolRow;
  47894. if (transposed) {
  47895. for (s2 = 0; s2 < symbolHeight; s2++) {
  47896. row = bitmap[offsetS + s2];
  47897. if (!row) {
  47898. continue;
  47899. }
  47900. symbolRow = symbolBitmap[s2];
  47901. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47902. switch (combinationOperator) {
  47903. case 0:
  47904. for (t2 = 0; t2 < maxWidth; t2++) {
  47905. row[offsetT + t2] |= symbolRow[t2];
  47906. }
  47907. break;
  47908. case 2:
  47909. for (t2 = 0; t2 < maxWidth; t2++) {
  47910. row[offsetT + t2] ^= symbolRow[t2];
  47911. }
  47912. break;
  47913. default:
  47914. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47915. }
  47916. }
  47917. currentS += symbolHeight - 1;
  47918. } else {
  47919. for (t2 = 0; t2 < symbolHeight; t2++) {
  47920. row = bitmap[offsetT + t2];
  47921. if (!row) {
  47922. continue;
  47923. }
  47924. symbolRow = symbolBitmap[t2];
  47925. switch (combinationOperator) {
  47926. case 0:
  47927. for (s2 = 0; s2 < symbolWidth; s2++) {
  47928. row[offsetS + s2] |= symbolRow[s2];
  47929. }
  47930. break;
  47931. case 2:
  47932. for (s2 = 0; s2 < symbolWidth; s2++) {
  47933. row[offsetS + s2] ^= symbolRow[s2];
  47934. }
  47935. break;
  47936. default:
  47937. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47938. }
  47939. }
  47940. currentS += symbolWidth - 1;
  47941. }
  47942. i++;
  47943. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47944. if (deltaS === null) {
  47945. break;
  47946. }
  47947. currentS += deltaS + dsOffset;
  47948. } while (true);
  47949. }
  47950. return bitmap;
  47951. }
  47952. function readSegmentHeader(data, start) {
  47953. var segmentHeader = {};
  47954. segmentHeader.number = readUint32(data, start);
  47955. var flags = data[start + 4];
  47956. var segmentType = flags & 0x3F;
  47957. if (!SegmentTypes[segmentType]) {
  47958. error('JBIG2 error: invalid segment type: ' + segmentType);
  47959. }
  47960. segmentHeader.type = segmentType;
  47961. segmentHeader.typeName = SegmentTypes[segmentType];
  47962. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47963. var pageAssociationFieldSize = !!(flags & 0x40);
  47964. var referredFlags = data[start + 5];
  47965. var referredToCount = referredFlags >> 5 & 7;
  47966. var retainBits = [referredFlags & 31];
  47967. var position = start + 6;
  47968. if (referredFlags === 7) {
  47969. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47970. position += 3;
  47971. var bytes = referredToCount + 7 >> 3;
  47972. retainBits[0] = data[position++];
  47973. while (--bytes > 0) {
  47974. retainBits.push(data[position++]);
  47975. }
  47976. } else if (referredFlags === 5 || referredFlags === 6) {
  47977. error('JBIG2 error: invalid referred-to flags');
  47978. }
  47979. segmentHeader.retainBits = retainBits;
  47980. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47981. var referredTo = [];
  47982. var i, ii;
  47983. for (i = 0; i < referredToCount; i++) {
  47984. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47985. referredTo.push(number);
  47986. position += referredToSegmentNumberSize;
  47987. }
  47988. segmentHeader.referredTo = referredTo;
  47989. if (!pageAssociationFieldSize) {
  47990. segmentHeader.pageAssociation = data[position++];
  47991. } else {
  47992. segmentHeader.pageAssociation = readUint32(data, position);
  47993. position += 4;
  47994. }
  47995. segmentHeader.length = readUint32(data, position);
  47996. position += 4;
  47997. if (segmentHeader.length === 0xFFFFFFFF) {
  47998. if (segmentType === 38) {
  47999. var genericRegionInfo = readRegionSegmentInformation(data, position);
  48000. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  48001. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  48002. var searchPatternLength = 6;
  48003. var searchPattern = new Uint8Array(searchPatternLength);
  48004. if (!genericRegionMmr) {
  48005. searchPattern[0] = 0xFF;
  48006. searchPattern[1] = 0xAC;
  48007. }
  48008. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  48009. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  48010. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  48011. searchPattern[5] = genericRegionInfo.height & 0xFF;
  48012. for (i = position, ii = data.length; i < ii; i++) {
  48013. var j = 0;
  48014. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  48015. j++;
  48016. }
  48017. if (j === searchPatternLength) {
  48018. segmentHeader.length = i + searchPatternLength;
  48019. break;
  48020. }
  48021. }
  48022. if (segmentHeader.length === 0xFFFFFFFF) {
  48023. error('JBIG2 error: segment end was not found');
  48024. }
  48025. } else {
  48026. error('JBIG2 error: invalid unknown segment length');
  48027. }
  48028. }
  48029. segmentHeader.headerEnd = position;
  48030. return segmentHeader;
  48031. }
  48032. function readSegments(header, data, start, end) {
  48033. var segments = [];
  48034. var position = start;
  48035. while (position < end) {
  48036. var segmentHeader = readSegmentHeader(data, position);
  48037. position = segmentHeader.headerEnd;
  48038. var segment = {
  48039. header: segmentHeader,
  48040. data: data
  48041. };
  48042. if (!header.randomAccess) {
  48043. segment.start = position;
  48044. position += segmentHeader.length;
  48045. segment.end = position;
  48046. }
  48047. segments.push(segment);
  48048. if (segmentHeader.type === 51) {
  48049. break;
  48050. }
  48051. }
  48052. if (header.randomAccess) {
  48053. for (var i = 0, ii = segments.length; i < ii; i++) {
  48054. segments[i].start = position;
  48055. position += segments[i].header.length;
  48056. segments[i].end = position;
  48057. }
  48058. }
  48059. return segments;
  48060. }
  48061. function readRegionSegmentInformation(data, start) {
  48062. return {
  48063. width: readUint32(data, start),
  48064. height: readUint32(data, start + 4),
  48065. x: readUint32(data, start + 8),
  48066. y: readUint32(data, start + 12),
  48067. combinationOperator: data[start + 16] & 7
  48068. };
  48069. }
  48070. var RegionSegmentInformationFieldLength = 17;
  48071. function processSegment(segment, visitor) {
  48072. var header = segment.header;
  48073. var data = segment.data, position = segment.start, end = segment.end;
  48074. var args, at, i, atLength;
  48075. switch (header.type) {
  48076. case 0:
  48077. var dictionary = {};
  48078. var dictionaryFlags = readUint16(data, position);
  48079. dictionary.huffman = !!(dictionaryFlags & 1);
  48080. dictionary.refinement = !!(dictionaryFlags & 2);
  48081. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48082. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48083. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48084. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48085. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48086. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48087. dictionary.template = dictionaryFlags >> 10 & 3;
  48088. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48089. position += 2;
  48090. if (!dictionary.huffman) {
  48091. atLength = dictionary.template === 0 ? 4 : 1;
  48092. at = [];
  48093. for (i = 0; i < atLength; i++) {
  48094. at.push({
  48095. x: readInt8(data, position),
  48096. y: readInt8(data, position + 1)
  48097. });
  48098. position += 2;
  48099. }
  48100. dictionary.at = at;
  48101. }
  48102. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48103. at = [];
  48104. for (i = 0; i < 2; i++) {
  48105. at.push({
  48106. x: readInt8(data, position),
  48107. y: readInt8(data, position + 1)
  48108. });
  48109. position += 2;
  48110. }
  48111. dictionary.refinementAt = at;
  48112. }
  48113. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48114. position += 4;
  48115. dictionary.numberOfNewSymbols = readUint32(data, position);
  48116. position += 4;
  48117. args = [
  48118. dictionary,
  48119. header.number,
  48120. header.referredTo,
  48121. data,
  48122. position,
  48123. end
  48124. ];
  48125. break;
  48126. case 6:
  48127. case 7:
  48128. var textRegion = {};
  48129. textRegion.info = readRegionSegmentInformation(data, position);
  48130. position += RegionSegmentInformationFieldLength;
  48131. var textRegionSegmentFlags = readUint16(data, position);
  48132. position += 2;
  48133. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48134. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48135. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48136. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48137. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48138. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48139. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48140. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48141. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48142. if (textRegion.huffman) {
  48143. var textRegionHuffmanFlags = readUint16(data, position);
  48144. position += 2;
  48145. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48146. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48147. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48148. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48149. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48150. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48151. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48152. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48153. }
  48154. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48155. at = [];
  48156. for (i = 0; i < 2; i++) {
  48157. at.push({
  48158. x: readInt8(data, position),
  48159. y: readInt8(data, position + 1)
  48160. });
  48161. position += 2;
  48162. }
  48163. textRegion.refinementAt = at;
  48164. }
  48165. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48166. position += 4;
  48167. if (textRegion.huffman) {
  48168. error('JBIG2 error: huffman is not supported');
  48169. }
  48170. args = [
  48171. textRegion,
  48172. header.referredTo,
  48173. data,
  48174. position,
  48175. end
  48176. ];
  48177. break;
  48178. case 38:
  48179. case 39:
  48180. var genericRegion = {};
  48181. genericRegion.info = readRegionSegmentInformation(data, position);
  48182. position += RegionSegmentInformationFieldLength;
  48183. var genericRegionSegmentFlags = data[position++];
  48184. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48185. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48186. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48187. if (!genericRegion.mmr) {
  48188. atLength = genericRegion.template === 0 ? 4 : 1;
  48189. at = [];
  48190. for (i = 0; i < atLength; i++) {
  48191. at.push({
  48192. x: readInt8(data, position),
  48193. y: readInt8(data, position + 1)
  48194. });
  48195. position += 2;
  48196. }
  48197. genericRegion.at = at;
  48198. }
  48199. args = [
  48200. genericRegion,
  48201. data,
  48202. position,
  48203. end
  48204. ];
  48205. break;
  48206. case 48:
  48207. var pageInfo = {
  48208. width: readUint32(data, position),
  48209. height: readUint32(data, position + 4),
  48210. resolutionX: readUint32(data, position + 8),
  48211. resolutionY: readUint32(data, position + 12)
  48212. };
  48213. if (pageInfo.height === 0xFFFFFFFF) {
  48214. delete pageInfo.height;
  48215. }
  48216. var pageSegmentFlags = data[position + 16];
  48217. readUint16(data, position + 17);
  48218. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48219. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48220. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48221. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48222. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48223. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48224. args = [pageInfo];
  48225. break;
  48226. case 49:
  48227. break;
  48228. case 50:
  48229. break;
  48230. case 51:
  48231. break;
  48232. case 62:
  48233. break;
  48234. default:
  48235. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48236. }
  48237. var callbackName = 'on' + header.typeName;
  48238. if (callbackName in visitor) {
  48239. visitor[callbackName].apply(visitor, args);
  48240. }
  48241. }
  48242. function processSegments(segments, visitor) {
  48243. for (var i = 0, ii = segments.length; i < ii; i++) {
  48244. processSegment(segments[i], visitor);
  48245. }
  48246. }
  48247. function parseJbig2(data, start, end) {
  48248. var position = start;
  48249. 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) {
  48250. error('JBIG2 error: invalid header');
  48251. }
  48252. var header = {};
  48253. position += 8;
  48254. var flags = data[position++];
  48255. header.randomAccess = !(flags & 1);
  48256. if (!(flags & 2)) {
  48257. header.numberOfPages = readUint32(data, position);
  48258. position += 4;
  48259. }
  48260. readSegments(header, data, position, end);
  48261. error('Not implemented');
  48262. }
  48263. function parseJbig2Chunks(chunks) {
  48264. var visitor = new SimpleSegmentVisitor();
  48265. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48266. var chunk = chunks[i];
  48267. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48268. processSegments(segments, visitor);
  48269. }
  48270. return visitor.buffer;
  48271. }
  48272. function SimpleSegmentVisitor() {
  48273. }
  48274. SimpleSegmentVisitor.prototype = {
  48275. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48276. this.currentPageInfo = info;
  48277. var rowSize = info.width + 7 >> 3;
  48278. var buffer = new Uint8Array(rowSize * info.height);
  48279. if (info.defaultPixelValue) {
  48280. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48281. buffer[i] = 0xFF;
  48282. }
  48283. }
  48284. this.buffer = buffer;
  48285. },
  48286. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48287. var pageInfo = this.currentPageInfo;
  48288. var width = regionInfo.width, height = regionInfo.height;
  48289. var rowSize = pageInfo.width + 7 >> 3;
  48290. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48291. var buffer = this.buffer;
  48292. var mask0 = 128 >> (regionInfo.x & 7);
  48293. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48294. var i, j, mask, offset;
  48295. switch (combinationOperator) {
  48296. case 0:
  48297. for (i = 0; i < height; i++) {
  48298. mask = mask0;
  48299. offset = offset0;
  48300. for (j = 0; j < width; j++) {
  48301. if (bitmap[i][j]) {
  48302. buffer[offset] |= mask;
  48303. }
  48304. mask >>= 1;
  48305. if (!mask) {
  48306. mask = 128;
  48307. offset++;
  48308. }
  48309. }
  48310. offset0 += rowSize;
  48311. }
  48312. break;
  48313. case 2:
  48314. for (i = 0; i < height; i++) {
  48315. mask = mask0;
  48316. offset = offset0;
  48317. for (j = 0; j < width; j++) {
  48318. if (bitmap[i][j]) {
  48319. buffer[offset] ^= mask;
  48320. }
  48321. mask >>= 1;
  48322. if (!mask) {
  48323. mask = 128;
  48324. offset++;
  48325. }
  48326. }
  48327. offset0 += rowSize;
  48328. }
  48329. break;
  48330. default:
  48331. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48332. }
  48333. },
  48334. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48335. var regionInfo = region.info;
  48336. var decodingContext = new DecodingContext(data, start, end);
  48337. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48338. this.drawBitmap(regionInfo, bitmap);
  48339. },
  48340. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48341. this.onImmediateGenericRegion.apply(this, arguments);
  48342. },
  48343. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48344. var huffmanTables;
  48345. if (dictionary.huffman) {
  48346. error('JBIG2 error: huffman is not supported');
  48347. }
  48348. var symbols = this.symbols;
  48349. if (!symbols) {
  48350. this.symbols = symbols = {};
  48351. }
  48352. var inputSymbols = [];
  48353. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48354. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48355. }
  48356. var decodingContext = new DecodingContext(data, start, end);
  48357. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48358. },
  48359. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48360. var regionInfo = region.info;
  48361. var huffmanTables;
  48362. var symbols = this.symbols;
  48363. var inputSymbols = [];
  48364. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48365. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48366. }
  48367. var symbolCodeLength = log2(inputSymbols.length);
  48368. var decodingContext = new DecodingContext(data, start, end);
  48369. 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);
  48370. this.drawBitmap(regionInfo, bitmap);
  48371. },
  48372. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48373. this.onImmediateTextRegion.apply(this, arguments);
  48374. }
  48375. };
  48376. function Jbig2Image() {
  48377. }
  48378. Jbig2Image.prototype = {
  48379. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48380. return parseJbig2Chunks(chunks);
  48381. }
  48382. };
  48383. return Jbig2Image;
  48384. }();
  48385. exports.Jbig2Image = Jbig2Image;
  48386. /***/ }),
  48387. /* 36 */
  48388. /***/ (function(module, exports, __w_pdfjs_require__) {
  48389. "use strict";
  48390. var sharedUtil = __w_pdfjs_require__(0);
  48391. var error = sharedUtil.error;
  48392. var JpegImage = function JpegImageClosure() {
  48393. var dctZigZag = new Uint8Array([
  48394. 0,
  48395. 1,
  48396. 8,
  48397. 16,
  48398. 9,
  48399. 2,
  48400. 3,
  48401. 10,
  48402. 17,
  48403. 24,
  48404. 32,
  48405. 25,
  48406. 18,
  48407. 11,
  48408. 4,
  48409. 5,
  48410. 12,
  48411. 19,
  48412. 26,
  48413. 33,
  48414. 40,
  48415. 48,
  48416. 41,
  48417. 34,
  48418. 27,
  48419. 20,
  48420. 13,
  48421. 6,
  48422. 7,
  48423. 14,
  48424. 21,
  48425. 28,
  48426. 35,
  48427. 42,
  48428. 49,
  48429. 56,
  48430. 57,
  48431. 50,
  48432. 43,
  48433. 36,
  48434. 29,
  48435. 22,
  48436. 15,
  48437. 23,
  48438. 30,
  48439. 37,
  48440. 44,
  48441. 51,
  48442. 58,
  48443. 59,
  48444. 52,
  48445. 45,
  48446. 38,
  48447. 31,
  48448. 39,
  48449. 46,
  48450. 53,
  48451. 60,
  48452. 61,
  48453. 54,
  48454. 47,
  48455. 55,
  48456. 62,
  48457. 63
  48458. ]);
  48459. var dctCos1 = 4017;
  48460. var dctSin1 = 799;
  48461. var dctCos3 = 3406;
  48462. var dctSin3 = 2276;
  48463. var dctCos6 = 1567;
  48464. var dctSin6 = 3784;
  48465. var dctSqrt2 = 5793;
  48466. var dctSqrt1d2 = 2896;
  48467. function JpegImage() {
  48468. this.decodeTransform = null;
  48469. this.colorTransform = -1;
  48470. }
  48471. function buildHuffmanTable(codeLengths, values) {
  48472. var k = 0, code = [], i, j, length = 16;
  48473. while (length > 0 && !codeLengths[length - 1]) {
  48474. length--;
  48475. }
  48476. code.push({
  48477. children: [],
  48478. index: 0
  48479. });
  48480. var p = code[0], q;
  48481. for (i = 0; i < length; i++) {
  48482. for (j = 0; j < codeLengths[i]; j++) {
  48483. p = code.pop();
  48484. p.children[p.index] = values[k];
  48485. while (p.index > 0) {
  48486. p = code.pop();
  48487. }
  48488. p.index++;
  48489. code.push(p);
  48490. while (code.length <= i) {
  48491. code.push(q = {
  48492. children: [],
  48493. index: 0
  48494. });
  48495. p.children[p.index] = q.children;
  48496. p = q;
  48497. }
  48498. k++;
  48499. }
  48500. if (i + 1 < length) {
  48501. code.push(q = {
  48502. children: [],
  48503. index: 0
  48504. });
  48505. p.children[p.index] = q.children;
  48506. p = q;
  48507. }
  48508. }
  48509. return code[0].children;
  48510. }
  48511. function getBlockBufferOffset(component, row, col) {
  48512. return 64 * ((component.blocksPerLine + 1) * row + col);
  48513. }
  48514. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48515. var mcusPerLine = frame.mcusPerLine;
  48516. var progressive = frame.progressive;
  48517. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48518. function readBit() {
  48519. if (bitsCount > 0) {
  48520. bitsCount--;
  48521. return bitsData >> bitsCount & 1;
  48522. }
  48523. bitsData = data[offset++];
  48524. if (bitsData === 0xFF) {
  48525. var nextByte = data[offset++];
  48526. if (nextByte) {
  48527. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48528. }
  48529. }
  48530. bitsCount = 7;
  48531. return bitsData >>> 7;
  48532. }
  48533. function decodeHuffman(tree) {
  48534. var node = tree;
  48535. while (true) {
  48536. node = node[readBit()];
  48537. if (typeof node === 'number') {
  48538. return node;
  48539. }
  48540. if (typeof node !== 'object') {
  48541. error('JPEG error: invalid huffman sequence');
  48542. }
  48543. }
  48544. }
  48545. function receive(length) {
  48546. var n = 0;
  48547. while (length > 0) {
  48548. n = n << 1 | readBit();
  48549. length--;
  48550. }
  48551. return n;
  48552. }
  48553. function receiveAndExtend(length) {
  48554. if (length === 1) {
  48555. return readBit() === 1 ? 1 : -1;
  48556. }
  48557. var n = receive(length);
  48558. if (n >= 1 << length - 1) {
  48559. return n;
  48560. }
  48561. return n + (-1 << length) + 1;
  48562. }
  48563. function decodeBaseline(component, offset) {
  48564. var t = decodeHuffman(component.huffmanTableDC);
  48565. var diff = t === 0 ? 0 : receiveAndExtend(t);
  48566. component.blockData[offset] = component.pred += diff;
  48567. var k = 1;
  48568. while (k < 64) {
  48569. var rs = decodeHuffman(component.huffmanTableAC);
  48570. var s = rs & 15, r = rs >> 4;
  48571. if (s === 0) {
  48572. if (r < 15) {
  48573. break;
  48574. }
  48575. k += 16;
  48576. continue;
  48577. }
  48578. k += r;
  48579. var z = dctZigZag[k];
  48580. component.blockData[offset + z] = receiveAndExtend(s);
  48581. k++;
  48582. }
  48583. }
  48584. function decodeDCFirst(component, offset) {
  48585. var t = decodeHuffman(component.huffmanTableDC);
  48586. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  48587. component.blockData[offset] = component.pred += diff;
  48588. }
  48589. function decodeDCSuccessive(component, offset) {
  48590. component.blockData[offset] |= readBit() << successive;
  48591. }
  48592. var eobrun = 0;
  48593. function decodeACFirst(component, offset) {
  48594. if (eobrun > 0) {
  48595. eobrun--;
  48596. return;
  48597. }
  48598. var k = spectralStart, e = spectralEnd;
  48599. while (k <= e) {
  48600. var rs = decodeHuffman(component.huffmanTableAC);
  48601. var s = rs & 15, r = rs >> 4;
  48602. if (s === 0) {
  48603. if (r < 15) {
  48604. eobrun = receive(r) + (1 << r) - 1;
  48605. break;
  48606. }
  48607. k += 16;
  48608. continue;
  48609. }
  48610. k += r;
  48611. var z = dctZigZag[k];
  48612. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  48613. k++;
  48614. }
  48615. }
  48616. var successiveACState = 0, successiveACNextValue;
  48617. function decodeACSuccessive(component, offset) {
  48618. var k = spectralStart;
  48619. var e = spectralEnd;
  48620. var r = 0;
  48621. var s;
  48622. var rs;
  48623. while (k <= e) {
  48624. var z = dctZigZag[k];
  48625. switch (successiveACState) {
  48626. case 0:
  48627. rs = decodeHuffman(component.huffmanTableAC);
  48628. s = rs & 15;
  48629. r = rs >> 4;
  48630. if (s === 0) {
  48631. if (r < 15) {
  48632. eobrun = receive(r) + (1 << r);
  48633. successiveACState = 4;
  48634. } else {
  48635. r = 16;
  48636. successiveACState = 1;
  48637. }
  48638. } else {
  48639. if (s !== 1) {
  48640. error('JPEG error: invalid ACn encoding');
  48641. }
  48642. successiveACNextValue = receiveAndExtend(s);
  48643. successiveACState = r ? 2 : 3;
  48644. }
  48645. continue;
  48646. case 1:
  48647. case 2:
  48648. if (component.blockData[offset + z]) {
  48649. component.blockData[offset + z] += readBit() << successive;
  48650. } else {
  48651. r--;
  48652. if (r === 0) {
  48653. successiveACState = successiveACState === 2 ? 3 : 0;
  48654. }
  48655. }
  48656. break;
  48657. case 3:
  48658. if (component.blockData[offset + z]) {
  48659. component.blockData[offset + z] += readBit() << successive;
  48660. } else {
  48661. component.blockData[offset + z] = successiveACNextValue << successive;
  48662. successiveACState = 0;
  48663. }
  48664. break;
  48665. case 4:
  48666. if (component.blockData[offset + z]) {
  48667. component.blockData[offset + z] += readBit() << successive;
  48668. }
  48669. break;
  48670. }
  48671. k++;
  48672. }
  48673. if (successiveACState === 4) {
  48674. eobrun--;
  48675. if (eobrun === 0) {
  48676. successiveACState = 0;
  48677. }
  48678. }
  48679. }
  48680. function decodeMcu(component, decode, mcu, row, col) {
  48681. var mcuRow = mcu / mcusPerLine | 0;
  48682. var mcuCol = mcu % mcusPerLine;
  48683. var blockRow = mcuRow * component.v + row;
  48684. var blockCol = mcuCol * component.h + col;
  48685. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48686. decode(component, offset);
  48687. }
  48688. function decodeBlock(component, decode, mcu) {
  48689. var blockRow = mcu / component.blocksPerLine | 0;
  48690. var blockCol = mcu % component.blocksPerLine;
  48691. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48692. decode(component, offset);
  48693. }
  48694. var componentsLength = components.length;
  48695. var component, i, j, k, n;
  48696. var decodeFn;
  48697. if (progressive) {
  48698. if (spectralStart === 0) {
  48699. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  48700. } else {
  48701. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  48702. }
  48703. } else {
  48704. decodeFn = decodeBaseline;
  48705. }
  48706. var mcu = 0, marker;
  48707. var mcuExpected;
  48708. if (componentsLength === 1) {
  48709. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  48710. } else {
  48711. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  48712. }
  48713. if (!resetInterval) {
  48714. resetInterval = mcuExpected;
  48715. }
  48716. var h, v;
  48717. while (mcu < mcuExpected) {
  48718. for (i = 0; i < componentsLength; i++) {
  48719. components[i].pred = 0;
  48720. }
  48721. eobrun = 0;
  48722. if (componentsLength === 1) {
  48723. component = components[0];
  48724. for (n = 0; n < resetInterval; n++) {
  48725. decodeBlock(component, decodeFn, mcu);
  48726. mcu++;
  48727. }
  48728. } else {
  48729. for (n = 0; n < resetInterval; n++) {
  48730. for (i = 0; i < componentsLength; i++) {
  48731. component = components[i];
  48732. h = component.h;
  48733. v = component.v;
  48734. for (j = 0; j < v; j++) {
  48735. for (k = 0; k < h; k++) {
  48736. decodeMcu(component, decodeFn, mcu, j, k);
  48737. }
  48738. }
  48739. }
  48740. mcu++;
  48741. }
  48742. }
  48743. bitsCount = 0;
  48744. marker = data[offset] << 8 | data[offset + 1];
  48745. while (data[offset] === 0x00 && offset < data.length - 1) {
  48746. offset++;
  48747. marker = data[offset] << 8 | data[offset + 1];
  48748. }
  48749. if (marker <= 0xFF00) {
  48750. error('JPEG error: marker was not found');
  48751. }
  48752. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  48753. offset += 2;
  48754. } else {
  48755. break;
  48756. }
  48757. }
  48758. return offset - startOffset;
  48759. }
  48760. function quantizeAndInverse(component, blockBufferOffset, p) {
  48761. var qt = component.quantizationTable, blockData = component.blockData;
  48762. var v0, v1, v2, v3, v4, v5, v6, v7;
  48763. var p0, p1, p2, p3, p4, p5, p6, p7;
  48764. var t;
  48765. if (!qt) {
  48766. error('JPEG error: missing required Quantization Table.');
  48767. }
  48768. for (var row = 0; row < 64; row += 8) {
  48769. p0 = blockData[blockBufferOffset + row];
  48770. p1 = blockData[blockBufferOffset + row + 1];
  48771. p2 = blockData[blockBufferOffset + row + 2];
  48772. p3 = blockData[blockBufferOffset + row + 3];
  48773. p4 = blockData[blockBufferOffset + row + 4];
  48774. p5 = blockData[blockBufferOffset + row + 5];
  48775. p6 = blockData[blockBufferOffset + row + 6];
  48776. p7 = blockData[blockBufferOffset + row + 7];
  48777. p0 *= qt[row];
  48778. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48779. t = dctSqrt2 * p0 + 512 >> 10;
  48780. p[row] = t;
  48781. p[row + 1] = t;
  48782. p[row + 2] = t;
  48783. p[row + 3] = t;
  48784. p[row + 4] = t;
  48785. p[row + 5] = t;
  48786. p[row + 6] = t;
  48787. p[row + 7] = t;
  48788. continue;
  48789. }
  48790. p1 *= qt[row + 1];
  48791. p2 *= qt[row + 2];
  48792. p3 *= qt[row + 3];
  48793. p4 *= qt[row + 4];
  48794. p5 *= qt[row + 5];
  48795. p6 *= qt[row + 6];
  48796. p7 *= qt[row + 7];
  48797. v0 = dctSqrt2 * p0 + 128 >> 8;
  48798. v1 = dctSqrt2 * p4 + 128 >> 8;
  48799. v2 = p2;
  48800. v3 = p6;
  48801. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  48802. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  48803. v5 = p3 << 4;
  48804. v6 = p5 << 4;
  48805. v0 = v0 + v1 + 1 >> 1;
  48806. v1 = v0 - v1;
  48807. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  48808. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  48809. v3 = t;
  48810. v4 = v4 + v6 + 1 >> 1;
  48811. v6 = v4 - v6;
  48812. v7 = v7 + v5 + 1 >> 1;
  48813. v5 = v7 - v5;
  48814. v0 = v0 + v3 + 1 >> 1;
  48815. v3 = v0 - v3;
  48816. v1 = v1 + v2 + 1 >> 1;
  48817. v2 = v1 - v2;
  48818. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48819. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48820. v7 = t;
  48821. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48822. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48823. v6 = t;
  48824. p[row] = v0 + v7;
  48825. p[row + 7] = v0 - v7;
  48826. p[row + 1] = v1 + v6;
  48827. p[row + 6] = v1 - v6;
  48828. p[row + 2] = v2 + v5;
  48829. p[row + 5] = v2 - v5;
  48830. p[row + 3] = v3 + v4;
  48831. p[row + 4] = v3 - v4;
  48832. }
  48833. for (var col = 0; col < 8; ++col) {
  48834. p0 = p[col];
  48835. p1 = p[col + 8];
  48836. p2 = p[col + 16];
  48837. p3 = p[col + 24];
  48838. p4 = p[col + 32];
  48839. p5 = p[col + 40];
  48840. p6 = p[col + 48];
  48841. p7 = p[col + 56];
  48842. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48843. t = dctSqrt2 * p0 + 8192 >> 14;
  48844. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48845. blockData[blockBufferOffset + col] = t;
  48846. blockData[blockBufferOffset + col + 8] = t;
  48847. blockData[blockBufferOffset + col + 16] = t;
  48848. blockData[blockBufferOffset + col + 24] = t;
  48849. blockData[blockBufferOffset + col + 32] = t;
  48850. blockData[blockBufferOffset + col + 40] = t;
  48851. blockData[blockBufferOffset + col + 48] = t;
  48852. blockData[blockBufferOffset + col + 56] = t;
  48853. continue;
  48854. }
  48855. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48856. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48857. v2 = p2;
  48858. v3 = p6;
  48859. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48860. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48861. v5 = p3;
  48862. v6 = p5;
  48863. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48864. v1 = v0 - v1;
  48865. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48866. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48867. v3 = t;
  48868. v4 = v4 + v6 + 1 >> 1;
  48869. v6 = v4 - v6;
  48870. v7 = v7 + v5 + 1 >> 1;
  48871. v5 = v7 - v5;
  48872. v0 = v0 + v3 + 1 >> 1;
  48873. v3 = v0 - v3;
  48874. v1 = v1 + v2 + 1 >> 1;
  48875. v2 = v1 - v2;
  48876. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48877. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48878. v7 = t;
  48879. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48880. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48881. v6 = t;
  48882. p0 = v0 + v7;
  48883. p7 = v0 - v7;
  48884. p1 = v1 + v6;
  48885. p6 = v1 - v6;
  48886. p2 = v2 + v5;
  48887. p5 = v2 - v5;
  48888. p3 = v3 + v4;
  48889. p4 = v3 - v4;
  48890. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48891. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48892. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48893. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48894. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48895. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48896. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48897. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48898. blockData[blockBufferOffset + col] = p0;
  48899. blockData[blockBufferOffset + col + 8] = p1;
  48900. blockData[blockBufferOffset + col + 16] = p2;
  48901. blockData[blockBufferOffset + col + 24] = p3;
  48902. blockData[blockBufferOffset + col + 32] = p4;
  48903. blockData[blockBufferOffset + col + 40] = p5;
  48904. blockData[blockBufferOffset + col + 48] = p6;
  48905. blockData[blockBufferOffset + col + 56] = p7;
  48906. }
  48907. }
  48908. function buildComponentData(frame, component) {
  48909. var blocksPerLine = component.blocksPerLine;
  48910. var blocksPerColumn = component.blocksPerColumn;
  48911. var computationBuffer = new Int16Array(64);
  48912. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48913. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48914. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48915. quantizeAndInverse(component, offset, computationBuffer);
  48916. }
  48917. }
  48918. return component.blockData;
  48919. }
  48920. function clamp0to255(a) {
  48921. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48922. }
  48923. JpegImage.prototype = {
  48924. parse: function parse(data) {
  48925. function readUint16() {
  48926. var value = data[offset] << 8 | data[offset + 1];
  48927. offset += 2;
  48928. return value;
  48929. }
  48930. function readDataBlock() {
  48931. var length = readUint16();
  48932. var array = data.subarray(offset, offset + length - 2);
  48933. offset += array.length;
  48934. return array;
  48935. }
  48936. function prepareComponents(frame) {
  48937. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48938. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48939. for (var i = 0; i < frame.components.length; i++) {
  48940. component = frame.components[i];
  48941. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48942. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48943. var blocksPerLineForMcu = mcusPerLine * component.h;
  48944. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48945. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48946. component.blockData = new Int16Array(blocksBufferSize);
  48947. component.blocksPerLine = blocksPerLine;
  48948. component.blocksPerColumn = blocksPerColumn;
  48949. }
  48950. frame.mcusPerLine = mcusPerLine;
  48951. frame.mcusPerColumn = mcusPerColumn;
  48952. }
  48953. var offset = 0;
  48954. var jfif = null;
  48955. var adobe = null;
  48956. var frame, resetInterval;
  48957. var quantizationTables = [];
  48958. var huffmanTablesAC = [], huffmanTablesDC = [];
  48959. var fileMarker = readUint16();
  48960. if (fileMarker !== 0xFFD8) {
  48961. error('JPEG error: SOI not found');
  48962. }
  48963. fileMarker = readUint16();
  48964. while (fileMarker !== 0xFFD9) {
  48965. var i, j, l;
  48966. switch (fileMarker) {
  48967. case 0xFFE0:
  48968. case 0xFFE1:
  48969. case 0xFFE2:
  48970. case 0xFFE3:
  48971. case 0xFFE4:
  48972. case 0xFFE5:
  48973. case 0xFFE6:
  48974. case 0xFFE7:
  48975. case 0xFFE8:
  48976. case 0xFFE9:
  48977. case 0xFFEA:
  48978. case 0xFFEB:
  48979. case 0xFFEC:
  48980. case 0xFFED:
  48981. case 0xFFEE:
  48982. case 0xFFEF:
  48983. case 0xFFFE:
  48984. var appData = readDataBlock();
  48985. if (fileMarker === 0xFFE0) {
  48986. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48987. jfif = {
  48988. version: {
  48989. major: appData[5],
  48990. minor: appData[6]
  48991. },
  48992. densityUnits: appData[7],
  48993. xDensity: appData[8] << 8 | appData[9],
  48994. yDensity: appData[10] << 8 | appData[11],
  48995. thumbWidth: appData[12],
  48996. thumbHeight: appData[13],
  48997. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48998. };
  48999. }
  49000. }
  49001. if (fileMarker === 0xFFEE) {
  49002. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  49003. adobe = {
  49004. version: appData[5] << 8 | appData[6],
  49005. flags0: appData[7] << 8 | appData[8],
  49006. flags1: appData[9] << 8 | appData[10],
  49007. transformCode: appData[11]
  49008. };
  49009. }
  49010. }
  49011. break;
  49012. case 0xFFDB:
  49013. var quantizationTablesLength = readUint16();
  49014. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  49015. var z;
  49016. while (offset < quantizationTablesEnd) {
  49017. var quantizationTableSpec = data[offset++];
  49018. var tableData = new Uint16Array(64);
  49019. if (quantizationTableSpec >> 4 === 0) {
  49020. for (j = 0; j < 64; j++) {
  49021. z = dctZigZag[j];
  49022. tableData[z] = data[offset++];
  49023. }
  49024. } else if (quantizationTableSpec >> 4 === 1) {
  49025. for (j = 0; j < 64; j++) {
  49026. z = dctZigZag[j];
  49027. tableData[z] = readUint16();
  49028. }
  49029. } else {
  49030. error('JPEG error: DQT - invalid table spec');
  49031. }
  49032. quantizationTables[quantizationTableSpec & 15] = tableData;
  49033. }
  49034. break;
  49035. case 0xFFC0:
  49036. case 0xFFC1:
  49037. case 0xFFC2:
  49038. if (frame) {
  49039. error('JPEG error: Only single frame JPEGs supported');
  49040. }
  49041. readUint16();
  49042. frame = {};
  49043. frame.extended = fileMarker === 0xFFC1;
  49044. frame.progressive = fileMarker === 0xFFC2;
  49045. frame.precision = data[offset++];
  49046. frame.scanLines = readUint16();
  49047. frame.samplesPerLine = readUint16();
  49048. frame.components = [];
  49049. frame.componentIds = {};
  49050. var componentsCount = data[offset++], componentId;
  49051. var maxH = 0, maxV = 0;
  49052. for (i = 0; i < componentsCount; i++) {
  49053. componentId = data[offset];
  49054. var h = data[offset + 1] >> 4;
  49055. var v = data[offset + 1] & 15;
  49056. if (maxH < h) {
  49057. maxH = h;
  49058. }
  49059. if (maxV < v) {
  49060. maxV = v;
  49061. }
  49062. var qId = data[offset + 2];
  49063. l = frame.components.push({
  49064. h: h,
  49065. v: v,
  49066. quantizationId: qId,
  49067. quantizationTable: null
  49068. });
  49069. frame.componentIds[componentId] = l - 1;
  49070. offset += 3;
  49071. }
  49072. frame.maxH = maxH;
  49073. frame.maxV = maxV;
  49074. prepareComponents(frame);
  49075. break;
  49076. case 0xFFC4:
  49077. var huffmanLength = readUint16();
  49078. for (i = 2; i < huffmanLength;) {
  49079. var huffmanTableSpec = data[offset++];
  49080. var codeLengths = new Uint8Array(16);
  49081. var codeLengthSum = 0;
  49082. for (j = 0; j < 16; j++, offset++) {
  49083. codeLengthSum += codeLengths[j] = data[offset];
  49084. }
  49085. var huffmanValues = new Uint8Array(codeLengthSum);
  49086. for (j = 0; j < codeLengthSum; j++, offset++) {
  49087. huffmanValues[j] = data[offset];
  49088. }
  49089. i += 17 + codeLengthSum;
  49090. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49091. }
  49092. break;
  49093. case 0xFFDD:
  49094. readUint16();
  49095. resetInterval = readUint16();
  49096. break;
  49097. case 0xFFDA:
  49098. readUint16();
  49099. var selectorsCount = data[offset++];
  49100. var components = [], component;
  49101. for (i = 0; i < selectorsCount; i++) {
  49102. var componentIndex = frame.componentIds[data[offset++]];
  49103. component = frame.components[componentIndex];
  49104. var tableSpec = data[offset++];
  49105. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49106. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49107. components.push(component);
  49108. }
  49109. var spectralStart = data[offset++];
  49110. var spectralEnd = data[offset++];
  49111. var successiveApproximation = data[offset++];
  49112. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49113. offset += processed;
  49114. break;
  49115. case 0xFFFF:
  49116. if (data[offset] !== 0xFF) {
  49117. offset--;
  49118. }
  49119. break;
  49120. default:
  49121. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49122. offset -= 3;
  49123. break;
  49124. }
  49125. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49126. }
  49127. fileMarker = readUint16();
  49128. }
  49129. this.width = frame.samplesPerLine;
  49130. this.height = frame.scanLines;
  49131. this.jfif = jfif;
  49132. this.adobe = adobe;
  49133. this.components = [];
  49134. for (i = 0; i < frame.components.length; i++) {
  49135. component = frame.components[i];
  49136. var quantizationTable = quantizationTables[component.quantizationId];
  49137. if (quantizationTable) {
  49138. component.quantizationTable = quantizationTable;
  49139. }
  49140. this.components.push({
  49141. output: buildComponentData(frame, component),
  49142. scaleX: component.h / frame.maxH,
  49143. scaleY: component.v / frame.maxV,
  49144. blocksPerLine: component.blocksPerLine,
  49145. blocksPerColumn: component.blocksPerColumn
  49146. });
  49147. }
  49148. this.numComponents = this.components.length;
  49149. },
  49150. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49151. var scaleX = this.width / width, scaleY = this.height / height;
  49152. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49153. var x, y, i, j, k;
  49154. var index;
  49155. var offset = 0;
  49156. var output;
  49157. var numComponents = this.components.length;
  49158. var dataLength = width * height * numComponents;
  49159. var data = new Uint8Array(dataLength);
  49160. var xScaleBlockOffset = new Uint32Array(width);
  49161. var mask3LSB = 0xfffffff8;
  49162. for (i = 0; i < numComponents; i++) {
  49163. component = this.components[i];
  49164. componentScaleX = component.scaleX * scaleX;
  49165. componentScaleY = component.scaleY * scaleY;
  49166. offset = i;
  49167. output = component.output;
  49168. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49169. for (x = 0; x < width; x++) {
  49170. j = 0 | x * componentScaleX;
  49171. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49172. }
  49173. for (y = 0; y < height; y++) {
  49174. j = 0 | y * componentScaleY;
  49175. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49176. for (x = 0; x < width; x++) {
  49177. data[offset] = output[index + xScaleBlockOffset[x]];
  49178. offset += numComponents;
  49179. }
  49180. }
  49181. }
  49182. var transform = this.decodeTransform;
  49183. if (transform) {
  49184. for (i = 0; i < dataLength;) {
  49185. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49186. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49187. }
  49188. }
  49189. }
  49190. return data;
  49191. },
  49192. _isColorConversionNeeded: function isColorConversionNeeded() {
  49193. if (this.adobe && this.adobe.transformCode) {
  49194. return true;
  49195. } else if (this.numComponents === 3) {
  49196. if (!this.adobe && this.colorTransform === 0) {
  49197. return false;
  49198. }
  49199. return true;
  49200. }
  49201. if (!this.adobe && this.colorTransform === 1) {
  49202. return true;
  49203. }
  49204. return false;
  49205. },
  49206. _convertYccToRgb: function convertYccToRgb(data) {
  49207. var Y, Cb, Cr;
  49208. for (var i = 0, length = data.length; i < length; i += 3) {
  49209. Y = data[i];
  49210. Cb = data[i + 1];
  49211. Cr = data[i + 2];
  49212. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49213. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49214. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49215. }
  49216. return data;
  49217. },
  49218. _convertYcckToRgb: function convertYcckToRgb(data) {
  49219. var Y, Cb, Cr, k;
  49220. var offset = 0;
  49221. for (var i = 0, length = data.length; i < length; i += 4) {
  49222. Y = data[i];
  49223. Cb = data[i + 1];
  49224. Cr = data[i + 2];
  49225. k = data[i + 3];
  49226. 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);
  49227. 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);
  49228. 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);
  49229. data[offset++] = clamp0to255(r);
  49230. data[offset++] = clamp0to255(g);
  49231. data[offset++] = clamp0to255(b);
  49232. }
  49233. return data;
  49234. },
  49235. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49236. var Y, Cb, Cr;
  49237. for (var i = 0, length = data.length; i < length; i += 4) {
  49238. Y = data[i];
  49239. Cb = data[i + 1];
  49240. Cr = data[i + 2];
  49241. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49242. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49243. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49244. }
  49245. return data;
  49246. },
  49247. _convertCmykToRgb: function convertCmykToRgb(data) {
  49248. var c, m, y, k;
  49249. var offset = 0;
  49250. var min = -255 * 255 * 255;
  49251. var scale = 1 / 255 / 255;
  49252. for (var i = 0, length = data.length; i < length; i += 4) {
  49253. c = data[i];
  49254. m = data[i + 1];
  49255. y = data[i + 2];
  49256. k = data[i + 3];
  49257. 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);
  49258. 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);
  49259. 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);
  49260. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49261. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49262. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49263. }
  49264. return data;
  49265. },
  49266. getData: function getData(width, height, forceRGBoutput) {
  49267. if (this.numComponents > 4) {
  49268. error('JPEG error: Unsupported color mode');
  49269. }
  49270. var data = this._getLinearizedBlockData(width, height);
  49271. if (this.numComponents === 1 && forceRGBoutput) {
  49272. var dataLength = data.length;
  49273. var rgbData = new Uint8Array(dataLength * 3);
  49274. var offset = 0;
  49275. for (var i = 0; i < dataLength; i++) {
  49276. var grayColor = data[i];
  49277. rgbData[offset++] = grayColor;
  49278. rgbData[offset++] = grayColor;
  49279. rgbData[offset++] = grayColor;
  49280. }
  49281. return rgbData;
  49282. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49283. return this._convertYccToRgb(data);
  49284. } else if (this.numComponents === 4) {
  49285. if (this._isColorConversionNeeded()) {
  49286. if (forceRGBoutput) {
  49287. return this._convertYcckToRgb(data);
  49288. }
  49289. return this._convertYcckToCmyk(data);
  49290. } else if (forceRGBoutput) {
  49291. return this._convertCmykToRgb(data);
  49292. }
  49293. }
  49294. return data;
  49295. }
  49296. };
  49297. return JpegImage;
  49298. }();
  49299. exports.JpegImage = JpegImage;
  49300. /***/ }),
  49301. /* 37 */
  49302. /***/ (function(module, exports, __w_pdfjs_require__) {
  49303. "use strict";
  49304. var sharedUtil = __w_pdfjs_require__(0);
  49305. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49306. var getMetrics = getLookupTableFactory(function (t) {
  49307. t['Courier'] = 600;
  49308. t['Courier-Bold'] = 600;
  49309. t['Courier-BoldOblique'] = 600;
  49310. t['Courier-Oblique'] = 600;
  49311. t['Helvetica'] = getLookupTableFactory(function (t) {
  49312. t['space'] = 278;
  49313. t['exclam'] = 278;
  49314. t['quotedbl'] = 355;
  49315. t['numbersign'] = 556;
  49316. t['dollar'] = 556;
  49317. t['percent'] = 889;
  49318. t['ampersand'] = 667;
  49319. t['quoteright'] = 222;
  49320. t['parenleft'] = 333;
  49321. t['parenright'] = 333;
  49322. t['asterisk'] = 389;
  49323. t['plus'] = 584;
  49324. t['comma'] = 278;
  49325. t['hyphen'] = 333;
  49326. t['period'] = 278;
  49327. t['slash'] = 278;
  49328. t['zero'] = 556;
  49329. t['one'] = 556;
  49330. t['two'] = 556;
  49331. t['three'] = 556;
  49332. t['four'] = 556;
  49333. t['five'] = 556;
  49334. t['six'] = 556;
  49335. t['seven'] = 556;
  49336. t['eight'] = 556;
  49337. t['nine'] = 556;
  49338. t['colon'] = 278;
  49339. t['semicolon'] = 278;
  49340. t['less'] = 584;
  49341. t['equal'] = 584;
  49342. t['greater'] = 584;
  49343. t['question'] = 556;
  49344. t['at'] = 1015;
  49345. t['A'] = 667;
  49346. t['B'] = 667;
  49347. t['C'] = 722;
  49348. t['D'] = 722;
  49349. t['E'] = 667;
  49350. t['F'] = 611;
  49351. t['G'] = 778;
  49352. t['H'] = 722;
  49353. t['I'] = 278;
  49354. t['J'] = 500;
  49355. t['K'] = 667;
  49356. t['L'] = 556;
  49357. t['M'] = 833;
  49358. t['N'] = 722;
  49359. t['O'] = 778;
  49360. t['P'] = 667;
  49361. t['Q'] = 778;
  49362. t['R'] = 722;
  49363. t['S'] = 667;
  49364. t['T'] = 611;
  49365. t['U'] = 722;
  49366. t['V'] = 667;
  49367. t['W'] = 944;
  49368. t['X'] = 667;
  49369. t['Y'] = 667;
  49370. t['Z'] = 611;
  49371. t['bracketleft'] = 278;
  49372. t['backslash'] = 278;
  49373. t['bracketright'] = 278;
  49374. t['asciicircum'] = 469;
  49375. t['underscore'] = 556;
  49376. t['quoteleft'] = 222;
  49377. t['a'] = 556;
  49378. t['b'] = 556;
  49379. t['c'] = 500;
  49380. t['d'] = 556;
  49381. t['e'] = 556;
  49382. t['f'] = 278;
  49383. t['g'] = 556;
  49384. t['h'] = 556;
  49385. t['i'] = 222;
  49386. t['j'] = 222;
  49387. t['k'] = 500;
  49388. t['l'] = 222;
  49389. t['m'] = 833;
  49390. t['n'] = 556;
  49391. t['o'] = 556;
  49392. t['p'] = 556;
  49393. t['q'] = 556;
  49394. t['r'] = 333;
  49395. t['s'] = 500;
  49396. t['t'] = 278;
  49397. t['u'] = 556;
  49398. t['v'] = 500;
  49399. t['w'] = 722;
  49400. t['x'] = 500;
  49401. t['y'] = 500;
  49402. t['z'] = 500;
  49403. t['braceleft'] = 334;
  49404. t['bar'] = 260;
  49405. t['braceright'] = 334;
  49406. t['asciitilde'] = 584;
  49407. t['exclamdown'] = 333;
  49408. t['cent'] = 556;
  49409. t['sterling'] = 556;
  49410. t['fraction'] = 167;
  49411. t['yen'] = 556;
  49412. t['florin'] = 556;
  49413. t['section'] = 556;
  49414. t['currency'] = 556;
  49415. t['quotesingle'] = 191;
  49416. t['quotedblleft'] = 333;
  49417. t['guillemotleft'] = 556;
  49418. t['guilsinglleft'] = 333;
  49419. t['guilsinglright'] = 333;
  49420. t['fi'] = 500;
  49421. t['fl'] = 500;
  49422. t['endash'] = 556;
  49423. t['dagger'] = 556;
  49424. t['daggerdbl'] = 556;
  49425. t['periodcentered'] = 278;
  49426. t['paragraph'] = 537;
  49427. t['bullet'] = 350;
  49428. t['quotesinglbase'] = 222;
  49429. t['quotedblbase'] = 333;
  49430. t['quotedblright'] = 333;
  49431. t['guillemotright'] = 556;
  49432. t['ellipsis'] = 1000;
  49433. t['perthousand'] = 1000;
  49434. t['questiondown'] = 611;
  49435. t['grave'] = 333;
  49436. t['acute'] = 333;
  49437. t['circumflex'] = 333;
  49438. t['tilde'] = 333;
  49439. t['macron'] = 333;
  49440. t['breve'] = 333;
  49441. t['dotaccent'] = 333;
  49442. t['dieresis'] = 333;
  49443. t['ring'] = 333;
  49444. t['cedilla'] = 333;
  49445. t['hungarumlaut'] = 333;
  49446. t['ogonek'] = 333;
  49447. t['caron'] = 333;
  49448. t['emdash'] = 1000;
  49449. t['AE'] = 1000;
  49450. t['ordfeminine'] = 370;
  49451. t['Lslash'] = 556;
  49452. t['Oslash'] = 778;
  49453. t['OE'] = 1000;
  49454. t['ordmasculine'] = 365;
  49455. t['ae'] = 889;
  49456. t['dotlessi'] = 278;
  49457. t['lslash'] = 222;
  49458. t['oslash'] = 611;
  49459. t['oe'] = 944;
  49460. t['germandbls'] = 611;
  49461. t['Idieresis'] = 278;
  49462. t['eacute'] = 556;
  49463. t['abreve'] = 556;
  49464. t['uhungarumlaut'] = 556;
  49465. t['ecaron'] = 556;
  49466. t['Ydieresis'] = 667;
  49467. t['divide'] = 584;
  49468. t['Yacute'] = 667;
  49469. t['Acircumflex'] = 667;
  49470. t['aacute'] = 556;
  49471. t['Ucircumflex'] = 722;
  49472. t['yacute'] = 500;
  49473. t['scommaaccent'] = 500;
  49474. t['ecircumflex'] = 556;
  49475. t['Uring'] = 722;
  49476. t['Udieresis'] = 722;
  49477. t['aogonek'] = 556;
  49478. t['Uacute'] = 722;
  49479. t['uogonek'] = 556;
  49480. t['Edieresis'] = 667;
  49481. t['Dcroat'] = 722;
  49482. t['commaaccent'] = 250;
  49483. t['copyright'] = 737;
  49484. t['Emacron'] = 667;
  49485. t['ccaron'] = 500;
  49486. t['aring'] = 556;
  49487. t['Ncommaaccent'] = 722;
  49488. t['lacute'] = 222;
  49489. t['agrave'] = 556;
  49490. t['Tcommaaccent'] = 611;
  49491. t['Cacute'] = 722;
  49492. t['atilde'] = 556;
  49493. t['Edotaccent'] = 667;
  49494. t['scaron'] = 500;
  49495. t['scedilla'] = 500;
  49496. t['iacute'] = 278;
  49497. t['lozenge'] = 471;
  49498. t['Rcaron'] = 722;
  49499. t['Gcommaaccent'] = 778;
  49500. t['ucircumflex'] = 556;
  49501. t['acircumflex'] = 556;
  49502. t['Amacron'] = 667;
  49503. t['rcaron'] = 333;
  49504. t['ccedilla'] = 500;
  49505. t['Zdotaccent'] = 611;
  49506. t['Thorn'] = 667;
  49507. t['Omacron'] = 778;
  49508. t['Racute'] = 722;
  49509. t['Sacute'] = 667;
  49510. t['dcaron'] = 643;
  49511. t['Umacron'] = 722;
  49512. t['uring'] = 556;
  49513. t['threesuperior'] = 333;
  49514. t['Ograve'] = 778;
  49515. t['Agrave'] = 667;
  49516. t['Abreve'] = 667;
  49517. t['multiply'] = 584;
  49518. t['uacute'] = 556;
  49519. t['Tcaron'] = 611;
  49520. t['partialdiff'] = 476;
  49521. t['ydieresis'] = 500;
  49522. t['Nacute'] = 722;
  49523. t['icircumflex'] = 278;
  49524. t['Ecircumflex'] = 667;
  49525. t['adieresis'] = 556;
  49526. t['edieresis'] = 556;
  49527. t['cacute'] = 500;
  49528. t['nacute'] = 556;
  49529. t['umacron'] = 556;
  49530. t['Ncaron'] = 722;
  49531. t['Iacute'] = 278;
  49532. t['plusminus'] = 584;
  49533. t['brokenbar'] = 260;
  49534. t['registered'] = 737;
  49535. t['Gbreve'] = 778;
  49536. t['Idotaccent'] = 278;
  49537. t['summation'] = 600;
  49538. t['Egrave'] = 667;
  49539. t['racute'] = 333;
  49540. t['omacron'] = 556;
  49541. t['Zacute'] = 611;
  49542. t['Zcaron'] = 611;
  49543. t['greaterequal'] = 549;
  49544. t['Eth'] = 722;
  49545. t['Ccedilla'] = 722;
  49546. t['lcommaaccent'] = 222;
  49547. t['tcaron'] = 317;
  49548. t['eogonek'] = 556;
  49549. t['Uogonek'] = 722;
  49550. t['Aacute'] = 667;
  49551. t['Adieresis'] = 667;
  49552. t['egrave'] = 556;
  49553. t['zacute'] = 500;
  49554. t['iogonek'] = 222;
  49555. t['Oacute'] = 778;
  49556. t['oacute'] = 556;
  49557. t['amacron'] = 556;
  49558. t['sacute'] = 500;
  49559. t['idieresis'] = 278;
  49560. t['Ocircumflex'] = 778;
  49561. t['Ugrave'] = 722;
  49562. t['Delta'] = 612;
  49563. t['thorn'] = 556;
  49564. t['twosuperior'] = 333;
  49565. t['Odieresis'] = 778;
  49566. t['mu'] = 556;
  49567. t['igrave'] = 278;
  49568. t['ohungarumlaut'] = 556;
  49569. t['Eogonek'] = 667;
  49570. t['dcroat'] = 556;
  49571. t['threequarters'] = 834;
  49572. t['Scedilla'] = 667;
  49573. t['lcaron'] = 299;
  49574. t['Kcommaaccent'] = 667;
  49575. t['Lacute'] = 556;
  49576. t['trademark'] = 1000;
  49577. t['edotaccent'] = 556;
  49578. t['Igrave'] = 278;
  49579. t['Imacron'] = 278;
  49580. t['Lcaron'] = 556;
  49581. t['onehalf'] = 834;
  49582. t['lessequal'] = 549;
  49583. t['ocircumflex'] = 556;
  49584. t['ntilde'] = 556;
  49585. t['Uhungarumlaut'] = 722;
  49586. t['Eacute'] = 667;
  49587. t['emacron'] = 556;
  49588. t['gbreve'] = 556;
  49589. t['onequarter'] = 834;
  49590. t['Scaron'] = 667;
  49591. t['Scommaaccent'] = 667;
  49592. t['Ohungarumlaut'] = 778;
  49593. t['degree'] = 400;
  49594. t['ograve'] = 556;
  49595. t['Ccaron'] = 722;
  49596. t['ugrave'] = 556;
  49597. t['radical'] = 453;
  49598. t['Dcaron'] = 722;
  49599. t['rcommaaccent'] = 333;
  49600. t['Ntilde'] = 722;
  49601. t['otilde'] = 556;
  49602. t['Rcommaaccent'] = 722;
  49603. t['Lcommaaccent'] = 556;
  49604. t['Atilde'] = 667;
  49605. t['Aogonek'] = 667;
  49606. t['Aring'] = 667;
  49607. t['Otilde'] = 778;
  49608. t['zdotaccent'] = 500;
  49609. t['Ecaron'] = 667;
  49610. t['Iogonek'] = 278;
  49611. t['kcommaaccent'] = 500;
  49612. t['minus'] = 584;
  49613. t['Icircumflex'] = 278;
  49614. t['ncaron'] = 556;
  49615. t['tcommaaccent'] = 278;
  49616. t['logicalnot'] = 584;
  49617. t['odieresis'] = 556;
  49618. t['udieresis'] = 556;
  49619. t['notequal'] = 549;
  49620. t['gcommaaccent'] = 556;
  49621. t['eth'] = 556;
  49622. t['zcaron'] = 500;
  49623. t['ncommaaccent'] = 556;
  49624. t['onesuperior'] = 333;
  49625. t['imacron'] = 278;
  49626. t['Euro'] = 556;
  49627. });
  49628. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  49629. t['space'] = 278;
  49630. t['exclam'] = 333;
  49631. t['quotedbl'] = 474;
  49632. t['numbersign'] = 556;
  49633. t['dollar'] = 556;
  49634. t['percent'] = 889;
  49635. t['ampersand'] = 722;
  49636. t['quoteright'] = 278;
  49637. t['parenleft'] = 333;
  49638. t['parenright'] = 333;
  49639. t['asterisk'] = 389;
  49640. t['plus'] = 584;
  49641. t['comma'] = 278;
  49642. t['hyphen'] = 333;
  49643. t['period'] = 278;
  49644. t['slash'] = 278;
  49645. t['zero'] = 556;
  49646. t['one'] = 556;
  49647. t['two'] = 556;
  49648. t['three'] = 556;
  49649. t['four'] = 556;
  49650. t['five'] = 556;
  49651. t['six'] = 556;
  49652. t['seven'] = 556;
  49653. t['eight'] = 556;
  49654. t['nine'] = 556;
  49655. t['colon'] = 333;
  49656. t['semicolon'] = 333;
  49657. t['less'] = 584;
  49658. t['equal'] = 584;
  49659. t['greater'] = 584;
  49660. t['question'] = 611;
  49661. t['at'] = 975;
  49662. t['A'] = 722;
  49663. t['B'] = 722;
  49664. t['C'] = 722;
  49665. t['D'] = 722;
  49666. t['E'] = 667;
  49667. t['F'] = 611;
  49668. t['G'] = 778;
  49669. t['H'] = 722;
  49670. t['I'] = 278;
  49671. t['J'] = 556;
  49672. t['K'] = 722;
  49673. t['L'] = 611;
  49674. t['M'] = 833;
  49675. t['N'] = 722;
  49676. t['O'] = 778;
  49677. t['P'] = 667;
  49678. t['Q'] = 778;
  49679. t['R'] = 722;
  49680. t['S'] = 667;
  49681. t['T'] = 611;
  49682. t['U'] = 722;
  49683. t['V'] = 667;
  49684. t['W'] = 944;
  49685. t['X'] = 667;
  49686. t['Y'] = 667;
  49687. t['Z'] = 611;
  49688. t['bracketleft'] = 333;
  49689. t['backslash'] = 278;
  49690. t['bracketright'] = 333;
  49691. t['asciicircum'] = 584;
  49692. t['underscore'] = 556;
  49693. t['quoteleft'] = 278;
  49694. t['a'] = 556;
  49695. t['b'] = 611;
  49696. t['c'] = 556;
  49697. t['d'] = 611;
  49698. t['e'] = 556;
  49699. t['f'] = 333;
  49700. t['g'] = 611;
  49701. t['h'] = 611;
  49702. t['i'] = 278;
  49703. t['j'] = 278;
  49704. t['k'] = 556;
  49705. t['l'] = 278;
  49706. t['m'] = 889;
  49707. t['n'] = 611;
  49708. t['o'] = 611;
  49709. t['p'] = 611;
  49710. t['q'] = 611;
  49711. t['r'] = 389;
  49712. t['s'] = 556;
  49713. t['t'] = 333;
  49714. t['u'] = 611;
  49715. t['v'] = 556;
  49716. t['w'] = 778;
  49717. t['x'] = 556;
  49718. t['y'] = 556;
  49719. t['z'] = 500;
  49720. t['braceleft'] = 389;
  49721. t['bar'] = 280;
  49722. t['braceright'] = 389;
  49723. t['asciitilde'] = 584;
  49724. t['exclamdown'] = 333;
  49725. t['cent'] = 556;
  49726. t['sterling'] = 556;
  49727. t['fraction'] = 167;
  49728. t['yen'] = 556;
  49729. t['florin'] = 556;
  49730. t['section'] = 556;
  49731. t['currency'] = 556;
  49732. t['quotesingle'] = 238;
  49733. t['quotedblleft'] = 500;
  49734. t['guillemotleft'] = 556;
  49735. t['guilsinglleft'] = 333;
  49736. t['guilsinglright'] = 333;
  49737. t['fi'] = 611;
  49738. t['fl'] = 611;
  49739. t['endash'] = 556;
  49740. t['dagger'] = 556;
  49741. t['daggerdbl'] = 556;
  49742. t['periodcentered'] = 278;
  49743. t['paragraph'] = 556;
  49744. t['bullet'] = 350;
  49745. t['quotesinglbase'] = 278;
  49746. t['quotedblbase'] = 500;
  49747. t['quotedblright'] = 500;
  49748. t['guillemotright'] = 556;
  49749. t['ellipsis'] = 1000;
  49750. t['perthousand'] = 1000;
  49751. t['questiondown'] = 611;
  49752. t['grave'] = 333;
  49753. t['acute'] = 333;
  49754. t['circumflex'] = 333;
  49755. t['tilde'] = 333;
  49756. t['macron'] = 333;
  49757. t['breve'] = 333;
  49758. t['dotaccent'] = 333;
  49759. t['dieresis'] = 333;
  49760. t['ring'] = 333;
  49761. t['cedilla'] = 333;
  49762. t['hungarumlaut'] = 333;
  49763. t['ogonek'] = 333;
  49764. t['caron'] = 333;
  49765. t['emdash'] = 1000;
  49766. t['AE'] = 1000;
  49767. t['ordfeminine'] = 370;
  49768. t['Lslash'] = 611;
  49769. t['Oslash'] = 778;
  49770. t['OE'] = 1000;
  49771. t['ordmasculine'] = 365;
  49772. t['ae'] = 889;
  49773. t['dotlessi'] = 278;
  49774. t['lslash'] = 278;
  49775. t['oslash'] = 611;
  49776. t['oe'] = 944;
  49777. t['germandbls'] = 611;
  49778. t['Idieresis'] = 278;
  49779. t['eacute'] = 556;
  49780. t['abreve'] = 556;
  49781. t['uhungarumlaut'] = 611;
  49782. t['ecaron'] = 556;
  49783. t['Ydieresis'] = 667;
  49784. t['divide'] = 584;
  49785. t['Yacute'] = 667;
  49786. t['Acircumflex'] = 722;
  49787. t['aacute'] = 556;
  49788. t['Ucircumflex'] = 722;
  49789. t['yacute'] = 556;
  49790. t['scommaaccent'] = 556;
  49791. t['ecircumflex'] = 556;
  49792. t['Uring'] = 722;
  49793. t['Udieresis'] = 722;
  49794. t['aogonek'] = 556;
  49795. t['Uacute'] = 722;
  49796. t['uogonek'] = 611;
  49797. t['Edieresis'] = 667;
  49798. t['Dcroat'] = 722;
  49799. t['commaaccent'] = 250;
  49800. t['copyright'] = 737;
  49801. t['Emacron'] = 667;
  49802. t['ccaron'] = 556;
  49803. t['aring'] = 556;
  49804. t['Ncommaaccent'] = 722;
  49805. t['lacute'] = 278;
  49806. t['agrave'] = 556;
  49807. t['Tcommaaccent'] = 611;
  49808. t['Cacute'] = 722;
  49809. t['atilde'] = 556;
  49810. t['Edotaccent'] = 667;
  49811. t['scaron'] = 556;
  49812. t['scedilla'] = 556;
  49813. t['iacute'] = 278;
  49814. t['lozenge'] = 494;
  49815. t['Rcaron'] = 722;
  49816. t['Gcommaaccent'] = 778;
  49817. t['ucircumflex'] = 611;
  49818. t['acircumflex'] = 556;
  49819. t['Amacron'] = 722;
  49820. t['rcaron'] = 389;
  49821. t['ccedilla'] = 556;
  49822. t['Zdotaccent'] = 611;
  49823. t['Thorn'] = 667;
  49824. t['Omacron'] = 778;
  49825. t['Racute'] = 722;
  49826. t['Sacute'] = 667;
  49827. t['dcaron'] = 743;
  49828. t['Umacron'] = 722;
  49829. t['uring'] = 611;
  49830. t['threesuperior'] = 333;
  49831. t['Ograve'] = 778;
  49832. t['Agrave'] = 722;
  49833. t['Abreve'] = 722;
  49834. t['multiply'] = 584;
  49835. t['uacute'] = 611;
  49836. t['Tcaron'] = 611;
  49837. t['partialdiff'] = 494;
  49838. t['ydieresis'] = 556;
  49839. t['Nacute'] = 722;
  49840. t['icircumflex'] = 278;
  49841. t['Ecircumflex'] = 667;
  49842. t['adieresis'] = 556;
  49843. t['edieresis'] = 556;
  49844. t['cacute'] = 556;
  49845. t['nacute'] = 611;
  49846. t['umacron'] = 611;
  49847. t['Ncaron'] = 722;
  49848. t['Iacute'] = 278;
  49849. t['plusminus'] = 584;
  49850. t['brokenbar'] = 280;
  49851. t['registered'] = 737;
  49852. t['Gbreve'] = 778;
  49853. t['Idotaccent'] = 278;
  49854. t['summation'] = 600;
  49855. t['Egrave'] = 667;
  49856. t['racute'] = 389;
  49857. t['omacron'] = 611;
  49858. t['Zacute'] = 611;
  49859. t['Zcaron'] = 611;
  49860. t['greaterequal'] = 549;
  49861. t['Eth'] = 722;
  49862. t['Ccedilla'] = 722;
  49863. t['lcommaaccent'] = 278;
  49864. t['tcaron'] = 389;
  49865. t['eogonek'] = 556;
  49866. t['Uogonek'] = 722;
  49867. t['Aacute'] = 722;
  49868. t['Adieresis'] = 722;
  49869. t['egrave'] = 556;
  49870. t['zacute'] = 500;
  49871. t['iogonek'] = 278;
  49872. t['Oacute'] = 778;
  49873. t['oacute'] = 611;
  49874. t['amacron'] = 556;
  49875. t['sacute'] = 556;
  49876. t['idieresis'] = 278;
  49877. t['Ocircumflex'] = 778;
  49878. t['Ugrave'] = 722;
  49879. t['Delta'] = 612;
  49880. t['thorn'] = 611;
  49881. t['twosuperior'] = 333;
  49882. t['Odieresis'] = 778;
  49883. t['mu'] = 611;
  49884. t['igrave'] = 278;
  49885. t['ohungarumlaut'] = 611;
  49886. t['Eogonek'] = 667;
  49887. t['dcroat'] = 611;
  49888. t['threequarters'] = 834;
  49889. t['Scedilla'] = 667;
  49890. t['lcaron'] = 400;
  49891. t['Kcommaaccent'] = 722;
  49892. t['Lacute'] = 611;
  49893. t['trademark'] = 1000;
  49894. t['edotaccent'] = 556;
  49895. t['Igrave'] = 278;
  49896. t['Imacron'] = 278;
  49897. t['Lcaron'] = 611;
  49898. t['onehalf'] = 834;
  49899. t['lessequal'] = 549;
  49900. t['ocircumflex'] = 611;
  49901. t['ntilde'] = 611;
  49902. t['Uhungarumlaut'] = 722;
  49903. t['Eacute'] = 667;
  49904. t['emacron'] = 556;
  49905. t['gbreve'] = 611;
  49906. t['onequarter'] = 834;
  49907. t['Scaron'] = 667;
  49908. t['Scommaaccent'] = 667;
  49909. t['Ohungarumlaut'] = 778;
  49910. t['degree'] = 400;
  49911. t['ograve'] = 611;
  49912. t['Ccaron'] = 722;
  49913. t['ugrave'] = 611;
  49914. t['radical'] = 549;
  49915. t['Dcaron'] = 722;
  49916. t['rcommaaccent'] = 389;
  49917. t['Ntilde'] = 722;
  49918. t['otilde'] = 611;
  49919. t['Rcommaaccent'] = 722;
  49920. t['Lcommaaccent'] = 611;
  49921. t['Atilde'] = 722;
  49922. t['Aogonek'] = 722;
  49923. t['Aring'] = 722;
  49924. t['Otilde'] = 778;
  49925. t['zdotaccent'] = 500;
  49926. t['Ecaron'] = 667;
  49927. t['Iogonek'] = 278;
  49928. t['kcommaaccent'] = 556;
  49929. t['minus'] = 584;
  49930. t['Icircumflex'] = 278;
  49931. t['ncaron'] = 611;
  49932. t['tcommaaccent'] = 333;
  49933. t['logicalnot'] = 584;
  49934. t['odieresis'] = 611;
  49935. t['udieresis'] = 611;
  49936. t['notequal'] = 549;
  49937. t['gcommaaccent'] = 611;
  49938. t['eth'] = 611;
  49939. t['zcaron'] = 500;
  49940. t['ncommaaccent'] = 611;
  49941. t['onesuperior'] = 333;
  49942. t['imacron'] = 278;
  49943. t['Euro'] = 556;
  49944. });
  49945. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49946. t['space'] = 278;
  49947. t['exclam'] = 333;
  49948. t['quotedbl'] = 474;
  49949. t['numbersign'] = 556;
  49950. t['dollar'] = 556;
  49951. t['percent'] = 889;
  49952. t['ampersand'] = 722;
  49953. t['quoteright'] = 278;
  49954. t['parenleft'] = 333;
  49955. t['parenright'] = 333;
  49956. t['asterisk'] = 389;
  49957. t['plus'] = 584;
  49958. t['comma'] = 278;
  49959. t['hyphen'] = 333;
  49960. t['period'] = 278;
  49961. t['slash'] = 278;
  49962. t['zero'] = 556;
  49963. t['one'] = 556;
  49964. t['two'] = 556;
  49965. t['three'] = 556;
  49966. t['four'] = 556;
  49967. t['five'] = 556;
  49968. t['six'] = 556;
  49969. t['seven'] = 556;
  49970. t['eight'] = 556;
  49971. t['nine'] = 556;
  49972. t['colon'] = 333;
  49973. t['semicolon'] = 333;
  49974. t['less'] = 584;
  49975. t['equal'] = 584;
  49976. t['greater'] = 584;
  49977. t['question'] = 611;
  49978. t['at'] = 975;
  49979. t['A'] = 722;
  49980. t['B'] = 722;
  49981. t['C'] = 722;
  49982. t['D'] = 722;
  49983. t['E'] = 667;
  49984. t['F'] = 611;
  49985. t['G'] = 778;
  49986. t['H'] = 722;
  49987. t['I'] = 278;
  49988. t['J'] = 556;
  49989. t['K'] = 722;
  49990. t['L'] = 611;
  49991. t['M'] = 833;
  49992. t['N'] = 722;
  49993. t['O'] = 778;
  49994. t['P'] = 667;
  49995. t['Q'] = 778;
  49996. t['R'] = 722;
  49997. t['S'] = 667;
  49998. t['T'] = 611;
  49999. t['U'] = 722;
  50000. t['V'] = 667;
  50001. t['W'] = 944;
  50002. t['X'] = 667;
  50003. t['Y'] = 667;
  50004. t['Z'] = 611;
  50005. t['bracketleft'] = 333;
  50006. t['backslash'] = 278;
  50007. t['bracketright'] = 333;
  50008. t['asciicircum'] = 584;
  50009. t['underscore'] = 556;
  50010. t['quoteleft'] = 278;
  50011. t['a'] = 556;
  50012. t['b'] = 611;
  50013. t['c'] = 556;
  50014. t['d'] = 611;
  50015. t['e'] = 556;
  50016. t['f'] = 333;
  50017. t['g'] = 611;
  50018. t['h'] = 611;
  50019. t['i'] = 278;
  50020. t['j'] = 278;
  50021. t['k'] = 556;
  50022. t['l'] = 278;
  50023. t['m'] = 889;
  50024. t['n'] = 611;
  50025. t['o'] = 611;
  50026. t['p'] = 611;
  50027. t['q'] = 611;
  50028. t['r'] = 389;
  50029. t['s'] = 556;
  50030. t['t'] = 333;
  50031. t['u'] = 611;
  50032. t['v'] = 556;
  50033. t['w'] = 778;
  50034. t['x'] = 556;
  50035. t['y'] = 556;
  50036. t['z'] = 500;
  50037. t['braceleft'] = 389;
  50038. t['bar'] = 280;
  50039. t['braceright'] = 389;
  50040. t['asciitilde'] = 584;
  50041. t['exclamdown'] = 333;
  50042. t['cent'] = 556;
  50043. t['sterling'] = 556;
  50044. t['fraction'] = 167;
  50045. t['yen'] = 556;
  50046. t['florin'] = 556;
  50047. t['section'] = 556;
  50048. t['currency'] = 556;
  50049. t['quotesingle'] = 238;
  50050. t['quotedblleft'] = 500;
  50051. t['guillemotleft'] = 556;
  50052. t['guilsinglleft'] = 333;
  50053. t['guilsinglright'] = 333;
  50054. t['fi'] = 611;
  50055. t['fl'] = 611;
  50056. t['endash'] = 556;
  50057. t['dagger'] = 556;
  50058. t['daggerdbl'] = 556;
  50059. t['periodcentered'] = 278;
  50060. t['paragraph'] = 556;
  50061. t['bullet'] = 350;
  50062. t['quotesinglbase'] = 278;
  50063. t['quotedblbase'] = 500;
  50064. t['quotedblright'] = 500;
  50065. t['guillemotright'] = 556;
  50066. t['ellipsis'] = 1000;
  50067. t['perthousand'] = 1000;
  50068. t['questiondown'] = 611;
  50069. t['grave'] = 333;
  50070. t['acute'] = 333;
  50071. t['circumflex'] = 333;
  50072. t['tilde'] = 333;
  50073. t['macron'] = 333;
  50074. t['breve'] = 333;
  50075. t['dotaccent'] = 333;
  50076. t['dieresis'] = 333;
  50077. t['ring'] = 333;
  50078. t['cedilla'] = 333;
  50079. t['hungarumlaut'] = 333;
  50080. t['ogonek'] = 333;
  50081. t['caron'] = 333;
  50082. t['emdash'] = 1000;
  50083. t['AE'] = 1000;
  50084. t['ordfeminine'] = 370;
  50085. t['Lslash'] = 611;
  50086. t['Oslash'] = 778;
  50087. t['OE'] = 1000;
  50088. t['ordmasculine'] = 365;
  50089. t['ae'] = 889;
  50090. t['dotlessi'] = 278;
  50091. t['lslash'] = 278;
  50092. t['oslash'] = 611;
  50093. t['oe'] = 944;
  50094. t['germandbls'] = 611;
  50095. t['Idieresis'] = 278;
  50096. t['eacute'] = 556;
  50097. t['abreve'] = 556;
  50098. t['uhungarumlaut'] = 611;
  50099. t['ecaron'] = 556;
  50100. t['Ydieresis'] = 667;
  50101. t['divide'] = 584;
  50102. t['Yacute'] = 667;
  50103. t['Acircumflex'] = 722;
  50104. t['aacute'] = 556;
  50105. t['Ucircumflex'] = 722;
  50106. t['yacute'] = 556;
  50107. t['scommaaccent'] = 556;
  50108. t['ecircumflex'] = 556;
  50109. t['Uring'] = 722;
  50110. t['Udieresis'] = 722;
  50111. t['aogonek'] = 556;
  50112. t['Uacute'] = 722;
  50113. t['uogonek'] = 611;
  50114. t['Edieresis'] = 667;
  50115. t['Dcroat'] = 722;
  50116. t['commaaccent'] = 250;
  50117. t['copyright'] = 737;
  50118. t['Emacron'] = 667;
  50119. t['ccaron'] = 556;
  50120. t['aring'] = 556;
  50121. t['Ncommaaccent'] = 722;
  50122. t['lacute'] = 278;
  50123. t['agrave'] = 556;
  50124. t['Tcommaaccent'] = 611;
  50125. t['Cacute'] = 722;
  50126. t['atilde'] = 556;
  50127. t['Edotaccent'] = 667;
  50128. t['scaron'] = 556;
  50129. t['scedilla'] = 556;
  50130. t['iacute'] = 278;
  50131. t['lozenge'] = 494;
  50132. t['Rcaron'] = 722;
  50133. t['Gcommaaccent'] = 778;
  50134. t['ucircumflex'] = 611;
  50135. t['acircumflex'] = 556;
  50136. t['Amacron'] = 722;
  50137. t['rcaron'] = 389;
  50138. t['ccedilla'] = 556;
  50139. t['Zdotaccent'] = 611;
  50140. t['Thorn'] = 667;
  50141. t['Omacron'] = 778;
  50142. t['Racute'] = 722;
  50143. t['Sacute'] = 667;
  50144. t['dcaron'] = 743;
  50145. t['Umacron'] = 722;
  50146. t['uring'] = 611;
  50147. t['threesuperior'] = 333;
  50148. t['Ograve'] = 778;
  50149. t['Agrave'] = 722;
  50150. t['Abreve'] = 722;
  50151. t['multiply'] = 584;
  50152. t['uacute'] = 611;
  50153. t['Tcaron'] = 611;
  50154. t['partialdiff'] = 494;
  50155. t['ydieresis'] = 556;
  50156. t['Nacute'] = 722;
  50157. t['icircumflex'] = 278;
  50158. t['Ecircumflex'] = 667;
  50159. t['adieresis'] = 556;
  50160. t['edieresis'] = 556;
  50161. t['cacute'] = 556;
  50162. t['nacute'] = 611;
  50163. t['umacron'] = 611;
  50164. t['Ncaron'] = 722;
  50165. t['Iacute'] = 278;
  50166. t['plusminus'] = 584;
  50167. t['brokenbar'] = 280;
  50168. t['registered'] = 737;
  50169. t['Gbreve'] = 778;
  50170. t['Idotaccent'] = 278;
  50171. t['summation'] = 600;
  50172. t['Egrave'] = 667;
  50173. t['racute'] = 389;
  50174. t['omacron'] = 611;
  50175. t['Zacute'] = 611;
  50176. t['Zcaron'] = 611;
  50177. t['greaterequal'] = 549;
  50178. t['Eth'] = 722;
  50179. t['Ccedilla'] = 722;
  50180. t['lcommaaccent'] = 278;
  50181. t['tcaron'] = 389;
  50182. t['eogonek'] = 556;
  50183. t['Uogonek'] = 722;
  50184. t['Aacute'] = 722;
  50185. t['Adieresis'] = 722;
  50186. t['egrave'] = 556;
  50187. t['zacute'] = 500;
  50188. t['iogonek'] = 278;
  50189. t['Oacute'] = 778;
  50190. t['oacute'] = 611;
  50191. t['amacron'] = 556;
  50192. t['sacute'] = 556;
  50193. t['idieresis'] = 278;
  50194. t['Ocircumflex'] = 778;
  50195. t['Ugrave'] = 722;
  50196. t['Delta'] = 612;
  50197. t['thorn'] = 611;
  50198. t['twosuperior'] = 333;
  50199. t['Odieresis'] = 778;
  50200. t['mu'] = 611;
  50201. t['igrave'] = 278;
  50202. t['ohungarumlaut'] = 611;
  50203. t['Eogonek'] = 667;
  50204. t['dcroat'] = 611;
  50205. t['threequarters'] = 834;
  50206. t['Scedilla'] = 667;
  50207. t['lcaron'] = 400;
  50208. t['Kcommaaccent'] = 722;
  50209. t['Lacute'] = 611;
  50210. t['trademark'] = 1000;
  50211. t['edotaccent'] = 556;
  50212. t['Igrave'] = 278;
  50213. t['Imacron'] = 278;
  50214. t['Lcaron'] = 611;
  50215. t['onehalf'] = 834;
  50216. t['lessequal'] = 549;
  50217. t['ocircumflex'] = 611;
  50218. t['ntilde'] = 611;
  50219. t['Uhungarumlaut'] = 722;
  50220. t['Eacute'] = 667;
  50221. t['emacron'] = 556;
  50222. t['gbreve'] = 611;
  50223. t['onequarter'] = 834;
  50224. t['Scaron'] = 667;
  50225. t['Scommaaccent'] = 667;
  50226. t['Ohungarumlaut'] = 778;
  50227. t['degree'] = 400;
  50228. t['ograve'] = 611;
  50229. t['Ccaron'] = 722;
  50230. t['ugrave'] = 611;
  50231. t['radical'] = 549;
  50232. t['Dcaron'] = 722;
  50233. t['rcommaaccent'] = 389;
  50234. t['Ntilde'] = 722;
  50235. t['otilde'] = 611;
  50236. t['Rcommaaccent'] = 722;
  50237. t['Lcommaaccent'] = 611;
  50238. t['Atilde'] = 722;
  50239. t['Aogonek'] = 722;
  50240. t['Aring'] = 722;
  50241. t['Otilde'] = 778;
  50242. t['zdotaccent'] = 500;
  50243. t['Ecaron'] = 667;
  50244. t['Iogonek'] = 278;
  50245. t['kcommaaccent'] = 556;
  50246. t['minus'] = 584;
  50247. t['Icircumflex'] = 278;
  50248. t['ncaron'] = 611;
  50249. t['tcommaaccent'] = 333;
  50250. t['logicalnot'] = 584;
  50251. t['odieresis'] = 611;
  50252. t['udieresis'] = 611;
  50253. t['notequal'] = 549;
  50254. t['gcommaaccent'] = 611;
  50255. t['eth'] = 611;
  50256. t['zcaron'] = 500;
  50257. t['ncommaaccent'] = 611;
  50258. t['onesuperior'] = 333;
  50259. t['imacron'] = 278;
  50260. t['Euro'] = 556;
  50261. });
  50262. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50263. t['space'] = 278;
  50264. t['exclam'] = 278;
  50265. t['quotedbl'] = 355;
  50266. t['numbersign'] = 556;
  50267. t['dollar'] = 556;
  50268. t['percent'] = 889;
  50269. t['ampersand'] = 667;
  50270. t['quoteright'] = 222;
  50271. t['parenleft'] = 333;
  50272. t['parenright'] = 333;
  50273. t['asterisk'] = 389;
  50274. t['plus'] = 584;
  50275. t['comma'] = 278;
  50276. t['hyphen'] = 333;
  50277. t['period'] = 278;
  50278. t['slash'] = 278;
  50279. t['zero'] = 556;
  50280. t['one'] = 556;
  50281. t['two'] = 556;
  50282. t['three'] = 556;
  50283. t['four'] = 556;
  50284. t['five'] = 556;
  50285. t['six'] = 556;
  50286. t['seven'] = 556;
  50287. t['eight'] = 556;
  50288. t['nine'] = 556;
  50289. t['colon'] = 278;
  50290. t['semicolon'] = 278;
  50291. t['less'] = 584;
  50292. t['equal'] = 584;
  50293. t['greater'] = 584;
  50294. t['question'] = 556;
  50295. t['at'] = 1015;
  50296. t['A'] = 667;
  50297. t['B'] = 667;
  50298. t['C'] = 722;
  50299. t['D'] = 722;
  50300. t['E'] = 667;
  50301. t['F'] = 611;
  50302. t['G'] = 778;
  50303. t['H'] = 722;
  50304. t['I'] = 278;
  50305. t['J'] = 500;
  50306. t['K'] = 667;
  50307. t['L'] = 556;
  50308. t['M'] = 833;
  50309. t['N'] = 722;
  50310. t['O'] = 778;
  50311. t['P'] = 667;
  50312. t['Q'] = 778;
  50313. t['R'] = 722;
  50314. t['S'] = 667;
  50315. t['T'] = 611;
  50316. t['U'] = 722;
  50317. t['V'] = 667;
  50318. t['W'] = 944;
  50319. t['X'] = 667;
  50320. t['Y'] = 667;
  50321. t['Z'] = 611;
  50322. t['bracketleft'] = 278;
  50323. t['backslash'] = 278;
  50324. t['bracketright'] = 278;
  50325. t['asciicircum'] = 469;
  50326. t['underscore'] = 556;
  50327. t['quoteleft'] = 222;
  50328. t['a'] = 556;
  50329. t['b'] = 556;
  50330. t['c'] = 500;
  50331. t['d'] = 556;
  50332. t['e'] = 556;
  50333. t['f'] = 278;
  50334. t['g'] = 556;
  50335. t['h'] = 556;
  50336. t['i'] = 222;
  50337. t['j'] = 222;
  50338. t['k'] = 500;
  50339. t['l'] = 222;
  50340. t['m'] = 833;
  50341. t['n'] = 556;
  50342. t['o'] = 556;
  50343. t['p'] = 556;
  50344. t['q'] = 556;
  50345. t['r'] = 333;
  50346. t['s'] = 500;
  50347. t['t'] = 278;
  50348. t['u'] = 556;
  50349. t['v'] = 500;
  50350. t['w'] = 722;
  50351. t['x'] = 500;
  50352. t['y'] = 500;
  50353. t['z'] = 500;
  50354. t['braceleft'] = 334;
  50355. t['bar'] = 260;
  50356. t['braceright'] = 334;
  50357. t['asciitilde'] = 584;
  50358. t['exclamdown'] = 333;
  50359. t['cent'] = 556;
  50360. t['sterling'] = 556;
  50361. t['fraction'] = 167;
  50362. t['yen'] = 556;
  50363. t['florin'] = 556;
  50364. t['section'] = 556;
  50365. t['currency'] = 556;
  50366. t['quotesingle'] = 191;
  50367. t['quotedblleft'] = 333;
  50368. t['guillemotleft'] = 556;
  50369. t['guilsinglleft'] = 333;
  50370. t['guilsinglright'] = 333;
  50371. t['fi'] = 500;
  50372. t['fl'] = 500;
  50373. t['endash'] = 556;
  50374. t['dagger'] = 556;
  50375. t['daggerdbl'] = 556;
  50376. t['periodcentered'] = 278;
  50377. t['paragraph'] = 537;
  50378. t['bullet'] = 350;
  50379. t['quotesinglbase'] = 222;
  50380. t['quotedblbase'] = 333;
  50381. t['quotedblright'] = 333;
  50382. t['guillemotright'] = 556;
  50383. t['ellipsis'] = 1000;
  50384. t['perthousand'] = 1000;
  50385. t['questiondown'] = 611;
  50386. t['grave'] = 333;
  50387. t['acute'] = 333;
  50388. t['circumflex'] = 333;
  50389. t['tilde'] = 333;
  50390. t['macron'] = 333;
  50391. t['breve'] = 333;
  50392. t['dotaccent'] = 333;
  50393. t['dieresis'] = 333;
  50394. t['ring'] = 333;
  50395. t['cedilla'] = 333;
  50396. t['hungarumlaut'] = 333;
  50397. t['ogonek'] = 333;
  50398. t['caron'] = 333;
  50399. t['emdash'] = 1000;
  50400. t['AE'] = 1000;
  50401. t['ordfeminine'] = 370;
  50402. t['Lslash'] = 556;
  50403. t['Oslash'] = 778;
  50404. t['OE'] = 1000;
  50405. t['ordmasculine'] = 365;
  50406. t['ae'] = 889;
  50407. t['dotlessi'] = 278;
  50408. t['lslash'] = 222;
  50409. t['oslash'] = 611;
  50410. t['oe'] = 944;
  50411. t['germandbls'] = 611;
  50412. t['Idieresis'] = 278;
  50413. t['eacute'] = 556;
  50414. t['abreve'] = 556;
  50415. t['uhungarumlaut'] = 556;
  50416. t['ecaron'] = 556;
  50417. t['Ydieresis'] = 667;
  50418. t['divide'] = 584;
  50419. t['Yacute'] = 667;
  50420. t['Acircumflex'] = 667;
  50421. t['aacute'] = 556;
  50422. t['Ucircumflex'] = 722;
  50423. t['yacute'] = 500;
  50424. t['scommaaccent'] = 500;
  50425. t['ecircumflex'] = 556;
  50426. t['Uring'] = 722;
  50427. t['Udieresis'] = 722;
  50428. t['aogonek'] = 556;
  50429. t['Uacute'] = 722;
  50430. t['uogonek'] = 556;
  50431. t['Edieresis'] = 667;
  50432. t['Dcroat'] = 722;
  50433. t['commaaccent'] = 250;
  50434. t['copyright'] = 737;
  50435. t['Emacron'] = 667;
  50436. t['ccaron'] = 500;
  50437. t['aring'] = 556;
  50438. t['Ncommaaccent'] = 722;
  50439. t['lacute'] = 222;
  50440. t['agrave'] = 556;
  50441. t['Tcommaaccent'] = 611;
  50442. t['Cacute'] = 722;
  50443. t['atilde'] = 556;
  50444. t['Edotaccent'] = 667;
  50445. t['scaron'] = 500;
  50446. t['scedilla'] = 500;
  50447. t['iacute'] = 278;
  50448. t['lozenge'] = 471;
  50449. t['Rcaron'] = 722;
  50450. t['Gcommaaccent'] = 778;
  50451. t['ucircumflex'] = 556;
  50452. t['acircumflex'] = 556;
  50453. t['Amacron'] = 667;
  50454. t['rcaron'] = 333;
  50455. t['ccedilla'] = 500;
  50456. t['Zdotaccent'] = 611;
  50457. t['Thorn'] = 667;
  50458. t['Omacron'] = 778;
  50459. t['Racute'] = 722;
  50460. t['Sacute'] = 667;
  50461. t['dcaron'] = 643;
  50462. t['Umacron'] = 722;
  50463. t['uring'] = 556;
  50464. t['threesuperior'] = 333;
  50465. t['Ograve'] = 778;
  50466. t['Agrave'] = 667;
  50467. t['Abreve'] = 667;
  50468. t['multiply'] = 584;
  50469. t['uacute'] = 556;
  50470. t['Tcaron'] = 611;
  50471. t['partialdiff'] = 476;
  50472. t['ydieresis'] = 500;
  50473. t['Nacute'] = 722;
  50474. t['icircumflex'] = 278;
  50475. t['Ecircumflex'] = 667;
  50476. t['adieresis'] = 556;
  50477. t['edieresis'] = 556;
  50478. t['cacute'] = 500;
  50479. t['nacute'] = 556;
  50480. t['umacron'] = 556;
  50481. t['Ncaron'] = 722;
  50482. t['Iacute'] = 278;
  50483. t['plusminus'] = 584;
  50484. t['brokenbar'] = 260;
  50485. t['registered'] = 737;
  50486. t['Gbreve'] = 778;
  50487. t['Idotaccent'] = 278;
  50488. t['summation'] = 600;
  50489. t['Egrave'] = 667;
  50490. t['racute'] = 333;
  50491. t['omacron'] = 556;
  50492. t['Zacute'] = 611;
  50493. t['Zcaron'] = 611;
  50494. t['greaterequal'] = 549;
  50495. t['Eth'] = 722;
  50496. t['Ccedilla'] = 722;
  50497. t['lcommaaccent'] = 222;
  50498. t['tcaron'] = 317;
  50499. t['eogonek'] = 556;
  50500. t['Uogonek'] = 722;
  50501. t['Aacute'] = 667;
  50502. t['Adieresis'] = 667;
  50503. t['egrave'] = 556;
  50504. t['zacute'] = 500;
  50505. t['iogonek'] = 222;
  50506. t['Oacute'] = 778;
  50507. t['oacute'] = 556;
  50508. t['amacron'] = 556;
  50509. t['sacute'] = 500;
  50510. t['idieresis'] = 278;
  50511. t['Ocircumflex'] = 778;
  50512. t['Ugrave'] = 722;
  50513. t['Delta'] = 612;
  50514. t['thorn'] = 556;
  50515. t['twosuperior'] = 333;
  50516. t['Odieresis'] = 778;
  50517. t['mu'] = 556;
  50518. t['igrave'] = 278;
  50519. t['ohungarumlaut'] = 556;
  50520. t['Eogonek'] = 667;
  50521. t['dcroat'] = 556;
  50522. t['threequarters'] = 834;
  50523. t['Scedilla'] = 667;
  50524. t['lcaron'] = 299;
  50525. t['Kcommaaccent'] = 667;
  50526. t['Lacute'] = 556;
  50527. t['trademark'] = 1000;
  50528. t['edotaccent'] = 556;
  50529. t['Igrave'] = 278;
  50530. t['Imacron'] = 278;
  50531. t['Lcaron'] = 556;
  50532. t['onehalf'] = 834;
  50533. t['lessequal'] = 549;
  50534. t['ocircumflex'] = 556;
  50535. t['ntilde'] = 556;
  50536. t['Uhungarumlaut'] = 722;
  50537. t['Eacute'] = 667;
  50538. t['emacron'] = 556;
  50539. t['gbreve'] = 556;
  50540. t['onequarter'] = 834;
  50541. t['Scaron'] = 667;
  50542. t['Scommaaccent'] = 667;
  50543. t['Ohungarumlaut'] = 778;
  50544. t['degree'] = 400;
  50545. t['ograve'] = 556;
  50546. t['Ccaron'] = 722;
  50547. t['ugrave'] = 556;
  50548. t['radical'] = 453;
  50549. t['Dcaron'] = 722;
  50550. t['rcommaaccent'] = 333;
  50551. t['Ntilde'] = 722;
  50552. t['otilde'] = 556;
  50553. t['Rcommaaccent'] = 722;
  50554. t['Lcommaaccent'] = 556;
  50555. t['Atilde'] = 667;
  50556. t['Aogonek'] = 667;
  50557. t['Aring'] = 667;
  50558. t['Otilde'] = 778;
  50559. t['zdotaccent'] = 500;
  50560. t['Ecaron'] = 667;
  50561. t['Iogonek'] = 278;
  50562. t['kcommaaccent'] = 500;
  50563. t['minus'] = 584;
  50564. t['Icircumflex'] = 278;
  50565. t['ncaron'] = 556;
  50566. t['tcommaaccent'] = 278;
  50567. t['logicalnot'] = 584;
  50568. t['odieresis'] = 556;
  50569. t['udieresis'] = 556;
  50570. t['notequal'] = 549;
  50571. t['gcommaaccent'] = 556;
  50572. t['eth'] = 556;
  50573. t['zcaron'] = 500;
  50574. t['ncommaaccent'] = 556;
  50575. t['onesuperior'] = 333;
  50576. t['imacron'] = 278;
  50577. t['Euro'] = 556;
  50578. });
  50579. t['Symbol'] = getLookupTableFactory(function (t) {
  50580. t['space'] = 250;
  50581. t['exclam'] = 333;
  50582. t['universal'] = 713;
  50583. t['numbersign'] = 500;
  50584. t['existential'] = 549;
  50585. t['percent'] = 833;
  50586. t['ampersand'] = 778;
  50587. t['suchthat'] = 439;
  50588. t['parenleft'] = 333;
  50589. t['parenright'] = 333;
  50590. t['asteriskmath'] = 500;
  50591. t['plus'] = 549;
  50592. t['comma'] = 250;
  50593. t['minus'] = 549;
  50594. t['period'] = 250;
  50595. t['slash'] = 278;
  50596. t['zero'] = 500;
  50597. t['one'] = 500;
  50598. t['two'] = 500;
  50599. t['three'] = 500;
  50600. t['four'] = 500;
  50601. t['five'] = 500;
  50602. t['six'] = 500;
  50603. t['seven'] = 500;
  50604. t['eight'] = 500;
  50605. t['nine'] = 500;
  50606. t['colon'] = 278;
  50607. t['semicolon'] = 278;
  50608. t['less'] = 549;
  50609. t['equal'] = 549;
  50610. t['greater'] = 549;
  50611. t['question'] = 444;
  50612. t['congruent'] = 549;
  50613. t['Alpha'] = 722;
  50614. t['Beta'] = 667;
  50615. t['Chi'] = 722;
  50616. t['Delta'] = 612;
  50617. t['Epsilon'] = 611;
  50618. t['Phi'] = 763;
  50619. t['Gamma'] = 603;
  50620. t['Eta'] = 722;
  50621. t['Iota'] = 333;
  50622. t['theta1'] = 631;
  50623. t['Kappa'] = 722;
  50624. t['Lambda'] = 686;
  50625. t['Mu'] = 889;
  50626. t['Nu'] = 722;
  50627. t['Omicron'] = 722;
  50628. t['Pi'] = 768;
  50629. t['Theta'] = 741;
  50630. t['Rho'] = 556;
  50631. t['Sigma'] = 592;
  50632. t['Tau'] = 611;
  50633. t['Upsilon'] = 690;
  50634. t['sigma1'] = 439;
  50635. t['Omega'] = 768;
  50636. t['Xi'] = 645;
  50637. t['Psi'] = 795;
  50638. t['Zeta'] = 611;
  50639. t['bracketleft'] = 333;
  50640. t['therefore'] = 863;
  50641. t['bracketright'] = 333;
  50642. t['perpendicular'] = 658;
  50643. t['underscore'] = 500;
  50644. t['radicalex'] = 500;
  50645. t['alpha'] = 631;
  50646. t['beta'] = 549;
  50647. t['chi'] = 549;
  50648. t['delta'] = 494;
  50649. t['epsilon'] = 439;
  50650. t['phi'] = 521;
  50651. t['gamma'] = 411;
  50652. t['eta'] = 603;
  50653. t['iota'] = 329;
  50654. t['phi1'] = 603;
  50655. t['kappa'] = 549;
  50656. t['lambda'] = 549;
  50657. t['mu'] = 576;
  50658. t['nu'] = 521;
  50659. t['omicron'] = 549;
  50660. t['pi'] = 549;
  50661. t['theta'] = 521;
  50662. t['rho'] = 549;
  50663. t['sigma'] = 603;
  50664. t['tau'] = 439;
  50665. t['upsilon'] = 576;
  50666. t['omega1'] = 713;
  50667. t['omega'] = 686;
  50668. t['xi'] = 493;
  50669. t['psi'] = 686;
  50670. t['zeta'] = 494;
  50671. t['braceleft'] = 480;
  50672. t['bar'] = 200;
  50673. t['braceright'] = 480;
  50674. t['similar'] = 549;
  50675. t['Euro'] = 750;
  50676. t['Upsilon1'] = 620;
  50677. t['minute'] = 247;
  50678. t['lessequal'] = 549;
  50679. t['fraction'] = 167;
  50680. t['infinity'] = 713;
  50681. t['florin'] = 500;
  50682. t['club'] = 753;
  50683. t['diamond'] = 753;
  50684. t['heart'] = 753;
  50685. t['spade'] = 753;
  50686. t['arrowboth'] = 1042;
  50687. t['arrowleft'] = 987;
  50688. t['arrowup'] = 603;
  50689. t['arrowright'] = 987;
  50690. t['arrowdown'] = 603;
  50691. t['degree'] = 400;
  50692. t['plusminus'] = 549;
  50693. t['second'] = 411;
  50694. t['greaterequal'] = 549;
  50695. t['multiply'] = 549;
  50696. t['proportional'] = 713;
  50697. t['partialdiff'] = 494;
  50698. t['bullet'] = 460;
  50699. t['divide'] = 549;
  50700. t['notequal'] = 549;
  50701. t['equivalence'] = 549;
  50702. t['approxequal'] = 549;
  50703. t['ellipsis'] = 1000;
  50704. t['arrowvertex'] = 603;
  50705. t['arrowhorizex'] = 1000;
  50706. t['carriagereturn'] = 658;
  50707. t['aleph'] = 823;
  50708. t['Ifraktur'] = 686;
  50709. t['Rfraktur'] = 795;
  50710. t['weierstrass'] = 987;
  50711. t['circlemultiply'] = 768;
  50712. t['circleplus'] = 768;
  50713. t['emptyset'] = 823;
  50714. t['intersection'] = 768;
  50715. t['union'] = 768;
  50716. t['propersuperset'] = 713;
  50717. t['reflexsuperset'] = 713;
  50718. t['notsubset'] = 713;
  50719. t['propersubset'] = 713;
  50720. t['reflexsubset'] = 713;
  50721. t['element'] = 713;
  50722. t['notelement'] = 713;
  50723. t['angle'] = 768;
  50724. t['gradient'] = 713;
  50725. t['registerserif'] = 790;
  50726. t['copyrightserif'] = 790;
  50727. t['trademarkserif'] = 890;
  50728. t['product'] = 823;
  50729. t['radical'] = 549;
  50730. t['dotmath'] = 250;
  50731. t['logicalnot'] = 713;
  50732. t['logicaland'] = 603;
  50733. t['logicalor'] = 603;
  50734. t['arrowdblboth'] = 1042;
  50735. t['arrowdblleft'] = 987;
  50736. t['arrowdblup'] = 603;
  50737. t['arrowdblright'] = 987;
  50738. t['arrowdbldown'] = 603;
  50739. t['lozenge'] = 494;
  50740. t['angleleft'] = 329;
  50741. t['registersans'] = 790;
  50742. t['copyrightsans'] = 790;
  50743. t['trademarksans'] = 786;
  50744. t['summation'] = 713;
  50745. t['parenlefttp'] = 384;
  50746. t['parenleftex'] = 384;
  50747. t['parenleftbt'] = 384;
  50748. t['bracketlefttp'] = 384;
  50749. t['bracketleftex'] = 384;
  50750. t['bracketleftbt'] = 384;
  50751. t['bracelefttp'] = 494;
  50752. t['braceleftmid'] = 494;
  50753. t['braceleftbt'] = 494;
  50754. t['braceex'] = 494;
  50755. t['angleright'] = 329;
  50756. t['integral'] = 274;
  50757. t['integraltp'] = 686;
  50758. t['integralex'] = 686;
  50759. t['integralbt'] = 686;
  50760. t['parenrighttp'] = 384;
  50761. t['parenrightex'] = 384;
  50762. t['parenrightbt'] = 384;
  50763. t['bracketrighttp'] = 384;
  50764. t['bracketrightex'] = 384;
  50765. t['bracketrightbt'] = 384;
  50766. t['bracerighttp'] = 494;
  50767. t['bracerightmid'] = 494;
  50768. t['bracerightbt'] = 494;
  50769. t['apple'] = 790;
  50770. });
  50771. t['Times-Roman'] = getLookupTableFactory(function (t) {
  50772. t['space'] = 250;
  50773. t['exclam'] = 333;
  50774. t['quotedbl'] = 408;
  50775. t['numbersign'] = 500;
  50776. t['dollar'] = 500;
  50777. t['percent'] = 833;
  50778. t['ampersand'] = 778;
  50779. t['quoteright'] = 333;
  50780. t['parenleft'] = 333;
  50781. t['parenright'] = 333;
  50782. t['asterisk'] = 500;
  50783. t['plus'] = 564;
  50784. t['comma'] = 250;
  50785. t['hyphen'] = 333;
  50786. t['period'] = 250;
  50787. t['slash'] = 278;
  50788. t['zero'] = 500;
  50789. t['one'] = 500;
  50790. t['two'] = 500;
  50791. t['three'] = 500;
  50792. t['four'] = 500;
  50793. t['five'] = 500;
  50794. t['six'] = 500;
  50795. t['seven'] = 500;
  50796. t['eight'] = 500;
  50797. t['nine'] = 500;
  50798. t['colon'] = 278;
  50799. t['semicolon'] = 278;
  50800. t['less'] = 564;
  50801. t['equal'] = 564;
  50802. t['greater'] = 564;
  50803. t['question'] = 444;
  50804. t['at'] = 921;
  50805. t['A'] = 722;
  50806. t['B'] = 667;
  50807. t['C'] = 667;
  50808. t['D'] = 722;
  50809. t['E'] = 611;
  50810. t['F'] = 556;
  50811. t['G'] = 722;
  50812. t['H'] = 722;
  50813. t['I'] = 333;
  50814. t['J'] = 389;
  50815. t['K'] = 722;
  50816. t['L'] = 611;
  50817. t['M'] = 889;
  50818. t['N'] = 722;
  50819. t['O'] = 722;
  50820. t['P'] = 556;
  50821. t['Q'] = 722;
  50822. t['R'] = 667;
  50823. t['S'] = 556;
  50824. t['T'] = 611;
  50825. t['U'] = 722;
  50826. t['V'] = 722;
  50827. t['W'] = 944;
  50828. t['X'] = 722;
  50829. t['Y'] = 722;
  50830. t['Z'] = 611;
  50831. t['bracketleft'] = 333;
  50832. t['backslash'] = 278;
  50833. t['bracketright'] = 333;
  50834. t['asciicircum'] = 469;
  50835. t['underscore'] = 500;
  50836. t['quoteleft'] = 333;
  50837. t['a'] = 444;
  50838. t['b'] = 500;
  50839. t['c'] = 444;
  50840. t['d'] = 500;
  50841. t['e'] = 444;
  50842. t['f'] = 333;
  50843. t['g'] = 500;
  50844. t['h'] = 500;
  50845. t['i'] = 278;
  50846. t['j'] = 278;
  50847. t['k'] = 500;
  50848. t['l'] = 278;
  50849. t['m'] = 778;
  50850. t['n'] = 500;
  50851. t['o'] = 500;
  50852. t['p'] = 500;
  50853. t['q'] = 500;
  50854. t['r'] = 333;
  50855. t['s'] = 389;
  50856. t['t'] = 278;
  50857. t['u'] = 500;
  50858. t['v'] = 500;
  50859. t['w'] = 722;
  50860. t['x'] = 500;
  50861. t['y'] = 500;
  50862. t['z'] = 444;
  50863. t['braceleft'] = 480;
  50864. t['bar'] = 200;
  50865. t['braceright'] = 480;
  50866. t['asciitilde'] = 541;
  50867. t['exclamdown'] = 333;
  50868. t['cent'] = 500;
  50869. t['sterling'] = 500;
  50870. t['fraction'] = 167;
  50871. t['yen'] = 500;
  50872. t['florin'] = 500;
  50873. t['section'] = 500;
  50874. t['currency'] = 500;
  50875. t['quotesingle'] = 180;
  50876. t['quotedblleft'] = 444;
  50877. t['guillemotleft'] = 500;
  50878. t['guilsinglleft'] = 333;
  50879. t['guilsinglright'] = 333;
  50880. t['fi'] = 556;
  50881. t['fl'] = 556;
  50882. t['endash'] = 500;
  50883. t['dagger'] = 500;
  50884. t['daggerdbl'] = 500;
  50885. t['periodcentered'] = 250;
  50886. t['paragraph'] = 453;
  50887. t['bullet'] = 350;
  50888. t['quotesinglbase'] = 333;
  50889. t['quotedblbase'] = 444;
  50890. t['quotedblright'] = 444;
  50891. t['guillemotright'] = 500;
  50892. t['ellipsis'] = 1000;
  50893. t['perthousand'] = 1000;
  50894. t['questiondown'] = 444;
  50895. t['grave'] = 333;
  50896. t['acute'] = 333;
  50897. t['circumflex'] = 333;
  50898. t['tilde'] = 333;
  50899. t['macron'] = 333;
  50900. t['breve'] = 333;
  50901. t['dotaccent'] = 333;
  50902. t['dieresis'] = 333;
  50903. t['ring'] = 333;
  50904. t['cedilla'] = 333;
  50905. t['hungarumlaut'] = 333;
  50906. t['ogonek'] = 333;
  50907. t['caron'] = 333;
  50908. t['emdash'] = 1000;
  50909. t['AE'] = 889;
  50910. t['ordfeminine'] = 276;
  50911. t['Lslash'] = 611;
  50912. t['Oslash'] = 722;
  50913. t['OE'] = 889;
  50914. t['ordmasculine'] = 310;
  50915. t['ae'] = 667;
  50916. t['dotlessi'] = 278;
  50917. t['lslash'] = 278;
  50918. t['oslash'] = 500;
  50919. t['oe'] = 722;
  50920. t['germandbls'] = 500;
  50921. t['Idieresis'] = 333;
  50922. t['eacute'] = 444;
  50923. t['abreve'] = 444;
  50924. t['uhungarumlaut'] = 500;
  50925. t['ecaron'] = 444;
  50926. t['Ydieresis'] = 722;
  50927. t['divide'] = 564;
  50928. t['Yacute'] = 722;
  50929. t['Acircumflex'] = 722;
  50930. t['aacute'] = 444;
  50931. t['Ucircumflex'] = 722;
  50932. t['yacute'] = 500;
  50933. t['scommaaccent'] = 389;
  50934. t['ecircumflex'] = 444;
  50935. t['Uring'] = 722;
  50936. t['Udieresis'] = 722;
  50937. t['aogonek'] = 444;
  50938. t['Uacute'] = 722;
  50939. t['uogonek'] = 500;
  50940. t['Edieresis'] = 611;
  50941. t['Dcroat'] = 722;
  50942. t['commaaccent'] = 250;
  50943. t['copyright'] = 760;
  50944. t['Emacron'] = 611;
  50945. t['ccaron'] = 444;
  50946. t['aring'] = 444;
  50947. t['Ncommaaccent'] = 722;
  50948. t['lacute'] = 278;
  50949. t['agrave'] = 444;
  50950. t['Tcommaaccent'] = 611;
  50951. t['Cacute'] = 667;
  50952. t['atilde'] = 444;
  50953. t['Edotaccent'] = 611;
  50954. t['scaron'] = 389;
  50955. t['scedilla'] = 389;
  50956. t['iacute'] = 278;
  50957. t['lozenge'] = 471;
  50958. t['Rcaron'] = 667;
  50959. t['Gcommaaccent'] = 722;
  50960. t['ucircumflex'] = 500;
  50961. t['acircumflex'] = 444;
  50962. t['Amacron'] = 722;
  50963. t['rcaron'] = 333;
  50964. t['ccedilla'] = 444;
  50965. t['Zdotaccent'] = 611;
  50966. t['Thorn'] = 556;
  50967. t['Omacron'] = 722;
  50968. t['Racute'] = 667;
  50969. t['Sacute'] = 556;
  50970. t['dcaron'] = 588;
  50971. t['Umacron'] = 722;
  50972. t['uring'] = 500;
  50973. t['threesuperior'] = 300;
  50974. t['Ograve'] = 722;
  50975. t['Agrave'] = 722;
  50976. t['Abreve'] = 722;
  50977. t['multiply'] = 564;
  50978. t['uacute'] = 500;
  50979. t['Tcaron'] = 611;
  50980. t['partialdiff'] = 476;
  50981. t['ydieresis'] = 500;
  50982. t['Nacute'] = 722;
  50983. t['icircumflex'] = 278;
  50984. t['Ecircumflex'] = 611;
  50985. t['adieresis'] = 444;
  50986. t['edieresis'] = 444;
  50987. t['cacute'] = 444;
  50988. t['nacute'] = 500;
  50989. t['umacron'] = 500;
  50990. t['Ncaron'] = 722;
  50991. t['Iacute'] = 333;
  50992. t['plusminus'] = 564;
  50993. t['brokenbar'] = 200;
  50994. t['registered'] = 760;
  50995. t['Gbreve'] = 722;
  50996. t['Idotaccent'] = 333;
  50997. t['summation'] = 600;
  50998. t['Egrave'] = 611;
  50999. t['racute'] = 333;
  51000. t['omacron'] = 500;
  51001. t['Zacute'] = 611;
  51002. t['Zcaron'] = 611;
  51003. t['greaterequal'] = 549;
  51004. t['Eth'] = 722;
  51005. t['Ccedilla'] = 667;
  51006. t['lcommaaccent'] = 278;
  51007. t['tcaron'] = 326;
  51008. t['eogonek'] = 444;
  51009. t['Uogonek'] = 722;
  51010. t['Aacute'] = 722;
  51011. t['Adieresis'] = 722;
  51012. t['egrave'] = 444;
  51013. t['zacute'] = 444;
  51014. t['iogonek'] = 278;
  51015. t['Oacute'] = 722;
  51016. t['oacute'] = 500;
  51017. t['amacron'] = 444;
  51018. t['sacute'] = 389;
  51019. t['idieresis'] = 278;
  51020. t['Ocircumflex'] = 722;
  51021. t['Ugrave'] = 722;
  51022. t['Delta'] = 612;
  51023. t['thorn'] = 500;
  51024. t['twosuperior'] = 300;
  51025. t['Odieresis'] = 722;
  51026. t['mu'] = 500;
  51027. t['igrave'] = 278;
  51028. t['ohungarumlaut'] = 500;
  51029. t['Eogonek'] = 611;
  51030. t['dcroat'] = 500;
  51031. t['threequarters'] = 750;
  51032. t['Scedilla'] = 556;
  51033. t['lcaron'] = 344;
  51034. t['Kcommaaccent'] = 722;
  51035. t['Lacute'] = 611;
  51036. t['trademark'] = 980;
  51037. t['edotaccent'] = 444;
  51038. t['Igrave'] = 333;
  51039. t['Imacron'] = 333;
  51040. t['Lcaron'] = 611;
  51041. t['onehalf'] = 750;
  51042. t['lessequal'] = 549;
  51043. t['ocircumflex'] = 500;
  51044. t['ntilde'] = 500;
  51045. t['Uhungarumlaut'] = 722;
  51046. t['Eacute'] = 611;
  51047. t['emacron'] = 444;
  51048. t['gbreve'] = 500;
  51049. t['onequarter'] = 750;
  51050. t['Scaron'] = 556;
  51051. t['Scommaaccent'] = 556;
  51052. t['Ohungarumlaut'] = 722;
  51053. t['degree'] = 400;
  51054. t['ograve'] = 500;
  51055. t['Ccaron'] = 667;
  51056. t['ugrave'] = 500;
  51057. t['radical'] = 453;
  51058. t['Dcaron'] = 722;
  51059. t['rcommaaccent'] = 333;
  51060. t['Ntilde'] = 722;
  51061. t['otilde'] = 500;
  51062. t['Rcommaaccent'] = 667;
  51063. t['Lcommaaccent'] = 611;
  51064. t['Atilde'] = 722;
  51065. t['Aogonek'] = 722;
  51066. t['Aring'] = 722;
  51067. t['Otilde'] = 722;
  51068. t['zdotaccent'] = 444;
  51069. t['Ecaron'] = 611;
  51070. t['Iogonek'] = 333;
  51071. t['kcommaaccent'] = 500;
  51072. t['minus'] = 564;
  51073. t['Icircumflex'] = 333;
  51074. t['ncaron'] = 500;
  51075. t['tcommaaccent'] = 278;
  51076. t['logicalnot'] = 564;
  51077. t['odieresis'] = 500;
  51078. t['udieresis'] = 500;
  51079. t['notequal'] = 549;
  51080. t['gcommaaccent'] = 500;
  51081. t['eth'] = 500;
  51082. t['zcaron'] = 444;
  51083. t['ncommaaccent'] = 500;
  51084. t['onesuperior'] = 300;
  51085. t['imacron'] = 278;
  51086. t['Euro'] = 500;
  51087. });
  51088. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51089. t['space'] = 250;
  51090. t['exclam'] = 333;
  51091. t['quotedbl'] = 555;
  51092. t['numbersign'] = 500;
  51093. t['dollar'] = 500;
  51094. t['percent'] = 1000;
  51095. t['ampersand'] = 833;
  51096. t['quoteright'] = 333;
  51097. t['parenleft'] = 333;
  51098. t['parenright'] = 333;
  51099. t['asterisk'] = 500;
  51100. t['plus'] = 570;
  51101. t['comma'] = 250;
  51102. t['hyphen'] = 333;
  51103. t['period'] = 250;
  51104. t['slash'] = 278;
  51105. t['zero'] = 500;
  51106. t['one'] = 500;
  51107. t['two'] = 500;
  51108. t['three'] = 500;
  51109. t['four'] = 500;
  51110. t['five'] = 500;
  51111. t['six'] = 500;
  51112. t['seven'] = 500;
  51113. t['eight'] = 500;
  51114. t['nine'] = 500;
  51115. t['colon'] = 333;
  51116. t['semicolon'] = 333;
  51117. t['less'] = 570;
  51118. t['equal'] = 570;
  51119. t['greater'] = 570;
  51120. t['question'] = 500;
  51121. t['at'] = 930;
  51122. t['A'] = 722;
  51123. t['B'] = 667;
  51124. t['C'] = 722;
  51125. t['D'] = 722;
  51126. t['E'] = 667;
  51127. t['F'] = 611;
  51128. t['G'] = 778;
  51129. t['H'] = 778;
  51130. t['I'] = 389;
  51131. t['J'] = 500;
  51132. t['K'] = 778;
  51133. t['L'] = 667;
  51134. t['M'] = 944;
  51135. t['N'] = 722;
  51136. t['O'] = 778;
  51137. t['P'] = 611;
  51138. t['Q'] = 778;
  51139. t['R'] = 722;
  51140. t['S'] = 556;
  51141. t['T'] = 667;
  51142. t['U'] = 722;
  51143. t['V'] = 722;
  51144. t['W'] = 1000;
  51145. t['X'] = 722;
  51146. t['Y'] = 722;
  51147. t['Z'] = 667;
  51148. t['bracketleft'] = 333;
  51149. t['backslash'] = 278;
  51150. t['bracketright'] = 333;
  51151. t['asciicircum'] = 581;
  51152. t['underscore'] = 500;
  51153. t['quoteleft'] = 333;
  51154. t['a'] = 500;
  51155. t['b'] = 556;
  51156. t['c'] = 444;
  51157. t['d'] = 556;
  51158. t['e'] = 444;
  51159. t['f'] = 333;
  51160. t['g'] = 500;
  51161. t['h'] = 556;
  51162. t['i'] = 278;
  51163. t['j'] = 333;
  51164. t['k'] = 556;
  51165. t['l'] = 278;
  51166. t['m'] = 833;
  51167. t['n'] = 556;
  51168. t['o'] = 500;
  51169. t['p'] = 556;
  51170. t['q'] = 556;
  51171. t['r'] = 444;
  51172. t['s'] = 389;
  51173. t['t'] = 333;
  51174. t['u'] = 556;
  51175. t['v'] = 500;
  51176. t['w'] = 722;
  51177. t['x'] = 500;
  51178. t['y'] = 500;
  51179. t['z'] = 444;
  51180. t['braceleft'] = 394;
  51181. t['bar'] = 220;
  51182. t['braceright'] = 394;
  51183. t['asciitilde'] = 520;
  51184. t['exclamdown'] = 333;
  51185. t['cent'] = 500;
  51186. t['sterling'] = 500;
  51187. t['fraction'] = 167;
  51188. t['yen'] = 500;
  51189. t['florin'] = 500;
  51190. t['section'] = 500;
  51191. t['currency'] = 500;
  51192. t['quotesingle'] = 278;
  51193. t['quotedblleft'] = 500;
  51194. t['guillemotleft'] = 500;
  51195. t['guilsinglleft'] = 333;
  51196. t['guilsinglright'] = 333;
  51197. t['fi'] = 556;
  51198. t['fl'] = 556;
  51199. t['endash'] = 500;
  51200. t['dagger'] = 500;
  51201. t['daggerdbl'] = 500;
  51202. t['periodcentered'] = 250;
  51203. t['paragraph'] = 540;
  51204. t['bullet'] = 350;
  51205. t['quotesinglbase'] = 333;
  51206. t['quotedblbase'] = 500;
  51207. t['quotedblright'] = 500;
  51208. t['guillemotright'] = 500;
  51209. t['ellipsis'] = 1000;
  51210. t['perthousand'] = 1000;
  51211. t['questiondown'] = 500;
  51212. t['grave'] = 333;
  51213. t['acute'] = 333;
  51214. t['circumflex'] = 333;
  51215. t['tilde'] = 333;
  51216. t['macron'] = 333;
  51217. t['breve'] = 333;
  51218. t['dotaccent'] = 333;
  51219. t['dieresis'] = 333;
  51220. t['ring'] = 333;
  51221. t['cedilla'] = 333;
  51222. t['hungarumlaut'] = 333;
  51223. t['ogonek'] = 333;
  51224. t['caron'] = 333;
  51225. t['emdash'] = 1000;
  51226. t['AE'] = 1000;
  51227. t['ordfeminine'] = 300;
  51228. t['Lslash'] = 667;
  51229. t['Oslash'] = 778;
  51230. t['OE'] = 1000;
  51231. t['ordmasculine'] = 330;
  51232. t['ae'] = 722;
  51233. t['dotlessi'] = 278;
  51234. t['lslash'] = 278;
  51235. t['oslash'] = 500;
  51236. t['oe'] = 722;
  51237. t['germandbls'] = 556;
  51238. t['Idieresis'] = 389;
  51239. t['eacute'] = 444;
  51240. t['abreve'] = 500;
  51241. t['uhungarumlaut'] = 556;
  51242. t['ecaron'] = 444;
  51243. t['Ydieresis'] = 722;
  51244. t['divide'] = 570;
  51245. t['Yacute'] = 722;
  51246. t['Acircumflex'] = 722;
  51247. t['aacute'] = 500;
  51248. t['Ucircumflex'] = 722;
  51249. t['yacute'] = 500;
  51250. t['scommaaccent'] = 389;
  51251. t['ecircumflex'] = 444;
  51252. t['Uring'] = 722;
  51253. t['Udieresis'] = 722;
  51254. t['aogonek'] = 500;
  51255. t['Uacute'] = 722;
  51256. t['uogonek'] = 556;
  51257. t['Edieresis'] = 667;
  51258. t['Dcroat'] = 722;
  51259. t['commaaccent'] = 250;
  51260. t['copyright'] = 747;
  51261. t['Emacron'] = 667;
  51262. t['ccaron'] = 444;
  51263. t['aring'] = 500;
  51264. t['Ncommaaccent'] = 722;
  51265. t['lacute'] = 278;
  51266. t['agrave'] = 500;
  51267. t['Tcommaaccent'] = 667;
  51268. t['Cacute'] = 722;
  51269. t['atilde'] = 500;
  51270. t['Edotaccent'] = 667;
  51271. t['scaron'] = 389;
  51272. t['scedilla'] = 389;
  51273. t['iacute'] = 278;
  51274. t['lozenge'] = 494;
  51275. t['Rcaron'] = 722;
  51276. t['Gcommaaccent'] = 778;
  51277. t['ucircumflex'] = 556;
  51278. t['acircumflex'] = 500;
  51279. t['Amacron'] = 722;
  51280. t['rcaron'] = 444;
  51281. t['ccedilla'] = 444;
  51282. t['Zdotaccent'] = 667;
  51283. t['Thorn'] = 611;
  51284. t['Omacron'] = 778;
  51285. t['Racute'] = 722;
  51286. t['Sacute'] = 556;
  51287. t['dcaron'] = 672;
  51288. t['Umacron'] = 722;
  51289. t['uring'] = 556;
  51290. t['threesuperior'] = 300;
  51291. t['Ograve'] = 778;
  51292. t['Agrave'] = 722;
  51293. t['Abreve'] = 722;
  51294. t['multiply'] = 570;
  51295. t['uacute'] = 556;
  51296. t['Tcaron'] = 667;
  51297. t['partialdiff'] = 494;
  51298. t['ydieresis'] = 500;
  51299. t['Nacute'] = 722;
  51300. t['icircumflex'] = 278;
  51301. t['Ecircumflex'] = 667;
  51302. t['adieresis'] = 500;
  51303. t['edieresis'] = 444;
  51304. t['cacute'] = 444;
  51305. t['nacute'] = 556;
  51306. t['umacron'] = 556;
  51307. t['Ncaron'] = 722;
  51308. t['Iacute'] = 389;
  51309. t['plusminus'] = 570;
  51310. t['brokenbar'] = 220;
  51311. t['registered'] = 747;
  51312. t['Gbreve'] = 778;
  51313. t['Idotaccent'] = 389;
  51314. t['summation'] = 600;
  51315. t['Egrave'] = 667;
  51316. t['racute'] = 444;
  51317. t['omacron'] = 500;
  51318. t['Zacute'] = 667;
  51319. t['Zcaron'] = 667;
  51320. t['greaterequal'] = 549;
  51321. t['Eth'] = 722;
  51322. t['Ccedilla'] = 722;
  51323. t['lcommaaccent'] = 278;
  51324. t['tcaron'] = 416;
  51325. t['eogonek'] = 444;
  51326. t['Uogonek'] = 722;
  51327. t['Aacute'] = 722;
  51328. t['Adieresis'] = 722;
  51329. t['egrave'] = 444;
  51330. t['zacute'] = 444;
  51331. t['iogonek'] = 278;
  51332. t['Oacute'] = 778;
  51333. t['oacute'] = 500;
  51334. t['amacron'] = 500;
  51335. t['sacute'] = 389;
  51336. t['idieresis'] = 278;
  51337. t['Ocircumflex'] = 778;
  51338. t['Ugrave'] = 722;
  51339. t['Delta'] = 612;
  51340. t['thorn'] = 556;
  51341. t['twosuperior'] = 300;
  51342. t['Odieresis'] = 778;
  51343. t['mu'] = 556;
  51344. t['igrave'] = 278;
  51345. t['ohungarumlaut'] = 500;
  51346. t['Eogonek'] = 667;
  51347. t['dcroat'] = 556;
  51348. t['threequarters'] = 750;
  51349. t['Scedilla'] = 556;
  51350. t['lcaron'] = 394;
  51351. t['Kcommaaccent'] = 778;
  51352. t['Lacute'] = 667;
  51353. t['trademark'] = 1000;
  51354. t['edotaccent'] = 444;
  51355. t['Igrave'] = 389;
  51356. t['Imacron'] = 389;
  51357. t['Lcaron'] = 667;
  51358. t['onehalf'] = 750;
  51359. t['lessequal'] = 549;
  51360. t['ocircumflex'] = 500;
  51361. t['ntilde'] = 556;
  51362. t['Uhungarumlaut'] = 722;
  51363. t['Eacute'] = 667;
  51364. t['emacron'] = 444;
  51365. t['gbreve'] = 500;
  51366. t['onequarter'] = 750;
  51367. t['Scaron'] = 556;
  51368. t['Scommaaccent'] = 556;
  51369. t['Ohungarumlaut'] = 778;
  51370. t['degree'] = 400;
  51371. t['ograve'] = 500;
  51372. t['Ccaron'] = 722;
  51373. t['ugrave'] = 556;
  51374. t['radical'] = 549;
  51375. t['Dcaron'] = 722;
  51376. t['rcommaaccent'] = 444;
  51377. t['Ntilde'] = 722;
  51378. t['otilde'] = 500;
  51379. t['Rcommaaccent'] = 722;
  51380. t['Lcommaaccent'] = 667;
  51381. t['Atilde'] = 722;
  51382. t['Aogonek'] = 722;
  51383. t['Aring'] = 722;
  51384. t['Otilde'] = 778;
  51385. t['zdotaccent'] = 444;
  51386. t['Ecaron'] = 667;
  51387. t['Iogonek'] = 389;
  51388. t['kcommaaccent'] = 556;
  51389. t['minus'] = 570;
  51390. t['Icircumflex'] = 389;
  51391. t['ncaron'] = 556;
  51392. t['tcommaaccent'] = 333;
  51393. t['logicalnot'] = 570;
  51394. t['odieresis'] = 500;
  51395. t['udieresis'] = 556;
  51396. t['notequal'] = 549;
  51397. t['gcommaaccent'] = 500;
  51398. t['eth'] = 500;
  51399. t['zcaron'] = 444;
  51400. t['ncommaaccent'] = 556;
  51401. t['onesuperior'] = 300;
  51402. t['imacron'] = 278;
  51403. t['Euro'] = 500;
  51404. });
  51405. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51406. t['space'] = 250;
  51407. t['exclam'] = 389;
  51408. t['quotedbl'] = 555;
  51409. t['numbersign'] = 500;
  51410. t['dollar'] = 500;
  51411. t['percent'] = 833;
  51412. t['ampersand'] = 778;
  51413. t['quoteright'] = 333;
  51414. t['parenleft'] = 333;
  51415. t['parenright'] = 333;
  51416. t['asterisk'] = 500;
  51417. t['plus'] = 570;
  51418. t['comma'] = 250;
  51419. t['hyphen'] = 333;
  51420. t['period'] = 250;
  51421. t['slash'] = 278;
  51422. t['zero'] = 500;
  51423. t['one'] = 500;
  51424. t['two'] = 500;
  51425. t['three'] = 500;
  51426. t['four'] = 500;
  51427. t['five'] = 500;
  51428. t['six'] = 500;
  51429. t['seven'] = 500;
  51430. t['eight'] = 500;
  51431. t['nine'] = 500;
  51432. t['colon'] = 333;
  51433. t['semicolon'] = 333;
  51434. t['less'] = 570;
  51435. t['equal'] = 570;
  51436. t['greater'] = 570;
  51437. t['question'] = 500;
  51438. t['at'] = 832;
  51439. t['A'] = 667;
  51440. t['B'] = 667;
  51441. t['C'] = 667;
  51442. t['D'] = 722;
  51443. t['E'] = 667;
  51444. t['F'] = 667;
  51445. t['G'] = 722;
  51446. t['H'] = 778;
  51447. t['I'] = 389;
  51448. t['J'] = 500;
  51449. t['K'] = 667;
  51450. t['L'] = 611;
  51451. t['M'] = 889;
  51452. t['N'] = 722;
  51453. t['O'] = 722;
  51454. t['P'] = 611;
  51455. t['Q'] = 722;
  51456. t['R'] = 667;
  51457. t['S'] = 556;
  51458. t['T'] = 611;
  51459. t['U'] = 722;
  51460. t['V'] = 667;
  51461. t['W'] = 889;
  51462. t['X'] = 667;
  51463. t['Y'] = 611;
  51464. t['Z'] = 611;
  51465. t['bracketleft'] = 333;
  51466. t['backslash'] = 278;
  51467. t['bracketright'] = 333;
  51468. t['asciicircum'] = 570;
  51469. t['underscore'] = 500;
  51470. t['quoteleft'] = 333;
  51471. t['a'] = 500;
  51472. t['b'] = 500;
  51473. t['c'] = 444;
  51474. t['d'] = 500;
  51475. t['e'] = 444;
  51476. t['f'] = 333;
  51477. t['g'] = 500;
  51478. t['h'] = 556;
  51479. t['i'] = 278;
  51480. t['j'] = 278;
  51481. t['k'] = 500;
  51482. t['l'] = 278;
  51483. t['m'] = 778;
  51484. t['n'] = 556;
  51485. t['o'] = 500;
  51486. t['p'] = 500;
  51487. t['q'] = 500;
  51488. t['r'] = 389;
  51489. t['s'] = 389;
  51490. t['t'] = 278;
  51491. t['u'] = 556;
  51492. t['v'] = 444;
  51493. t['w'] = 667;
  51494. t['x'] = 500;
  51495. t['y'] = 444;
  51496. t['z'] = 389;
  51497. t['braceleft'] = 348;
  51498. t['bar'] = 220;
  51499. t['braceright'] = 348;
  51500. t['asciitilde'] = 570;
  51501. t['exclamdown'] = 389;
  51502. t['cent'] = 500;
  51503. t['sterling'] = 500;
  51504. t['fraction'] = 167;
  51505. t['yen'] = 500;
  51506. t['florin'] = 500;
  51507. t['section'] = 500;
  51508. t['currency'] = 500;
  51509. t['quotesingle'] = 278;
  51510. t['quotedblleft'] = 500;
  51511. t['guillemotleft'] = 500;
  51512. t['guilsinglleft'] = 333;
  51513. t['guilsinglright'] = 333;
  51514. t['fi'] = 556;
  51515. t['fl'] = 556;
  51516. t['endash'] = 500;
  51517. t['dagger'] = 500;
  51518. t['daggerdbl'] = 500;
  51519. t['periodcentered'] = 250;
  51520. t['paragraph'] = 500;
  51521. t['bullet'] = 350;
  51522. t['quotesinglbase'] = 333;
  51523. t['quotedblbase'] = 500;
  51524. t['quotedblright'] = 500;
  51525. t['guillemotright'] = 500;
  51526. t['ellipsis'] = 1000;
  51527. t['perthousand'] = 1000;
  51528. t['questiondown'] = 500;
  51529. t['grave'] = 333;
  51530. t['acute'] = 333;
  51531. t['circumflex'] = 333;
  51532. t['tilde'] = 333;
  51533. t['macron'] = 333;
  51534. t['breve'] = 333;
  51535. t['dotaccent'] = 333;
  51536. t['dieresis'] = 333;
  51537. t['ring'] = 333;
  51538. t['cedilla'] = 333;
  51539. t['hungarumlaut'] = 333;
  51540. t['ogonek'] = 333;
  51541. t['caron'] = 333;
  51542. t['emdash'] = 1000;
  51543. t['AE'] = 944;
  51544. t['ordfeminine'] = 266;
  51545. t['Lslash'] = 611;
  51546. t['Oslash'] = 722;
  51547. t['OE'] = 944;
  51548. t['ordmasculine'] = 300;
  51549. t['ae'] = 722;
  51550. t['dotlessi'] = 278;
  51551. t['lslash'] = 278;
  51552. t['oslash'] = 500;
  51553. t['oe'] = 722;
  51554. t['germandbls'] = 500;
  51555. t['Idieresis'] = 389;
  51556. t['eacute'] = 444;
  51557. t['abreve'] = 500;
  51558. t['uhungarumlaut'] = 556;
  51559. t['ecaron'] = 444;
  51560. t['Ydieresis'] = 611;
  51561. t['divide'] = 570;
  51562. t['Yacute'] = 611;
  51563. t['Acircumflex'] = 667;
  51564. t['aacute'] = 500;
  51565. t['Ucircumflex'] = 722;
  51566. t['yacute'] = 444;
  51567. t['scommaaccent'] = 389;
  51568. t['ecircumflex'] = 444;
  51569. t['Uring'] = 722;
  51570. t['Udieresis'] = 722;
  51571. t['aogonek'] = 500;
  51572. t['Uacute'] = 722;
  51573. t['uogonek'] = 556;
  51574. t['Edieresis'] = 667;
  51575. t['Dcroat'] = 722;
  51576. t['commaaccent'] = 250;
  51577. t['copyright'] = 747;
  51578. t['Emacron'] = 667;
  51579. t['ccaron'] = 444;
  51580. t['aring'] = 500;
  51581. t['Ncommaaccent'] = 722;
  51582. t['lacute'] = 278;
  51583. t['agrave'] = 500;
  51584. t['Tcommaaccent'] = 611;
  51585. t['Cacute'] = 667;
  51586. t['atilde'] = 500;
  51587. t['Edotaccent'] = 667;
  51588. t['scaron'] = 389;
  51589. t['scedilla'] = 389;
  51590. t['iacute'] = 278;
  51591. t['lozenge'] = 494;
  51592. t['Rcaron'] = 667;
  51593. t['Gcommaaccent'] = 722;
  51594. t['ucircumflex'] = 556;
  51595. t['acircumflex'] = 500;
  51596. t['Amacron'] = 667;
  51597. t['rcaron'] = 389;
  51598. t['ccedilla'] = 444;
  51599. t['Zdotaccent'] = 611;
  51600. t['Thorn'] = 611;
  51601. t['Omacron'] = 722;
  51602. t['Racute'] = 667;
  51603. t['Sacute'] = 556;
  51604. t['dcaron'] = 608;
  51605. t['Umacron'] = 722;
  51606. t['uring'] = 556;
  51607. t['threesuperior'] = 300;
  51608. t['Ograve'] = 722;
  51609. t['Agrave'] = 667;
  51610. t['Abreve'] = 667;
  51611. t['multiply'] = 570;
  51612. t['uacute'] = 556;
  51613. t['Tcaron'] = 611;
  51614. t['partialdiff'] = 494;
  51615. t['ydieresis'] = 444;
  51616. t['Nacute'] = 722;
  51617. t['icircumflex'] = 278;
  51618. t['Ecircumflex'] = 667;
  51619. t['adieresis'] = 500;
  51620. t['edieresis'] = 444;
  51621. t['cacute'] = 444;
  51622. t['nacute'] = 556;
  51623. t['umacron'] = 556;
  51624. t['Ncaron'] = 722;
  51625. t['Iacute'] = 389;
  51626. t['plusminus'] = 570;
  51627. t['brokenbar'] = 220;
  51628. t['registered'] = 747;
  51629. t['Gbreve'] = 722;
  51630. t['Idotaccent'] = 389;
  51631. t['summation'] = 600;
  51632. t['Egrave'] = 667;
  51633. t['racute'] = 389;
  51634. t['omacron'] = 500;
  51635. t['Zacute'] = 611;
  51636. t['Zcaron'] = 611;
  51637. t['greaterequal'] = 549;
  51638. t['Eth'] = 722;
  51639. t['Ccedilla'] = 667;
  51640. t['lcommaaccent'] = 278;
  51641. t['tcaron'] = 366;
  51642. t['eogonek'] = 444;
  51643. t['Uogonek'] = 722;
  51644. t['Aacute'] = 667;
  51645. t['Adieresis'] = 667;
  51646. t['egrave'] = 444;
  51647. t['zacute'] = 389;
  51648. t['iogonek'] = 278;
  51649. t['Oacute'] = 722;
  51650. t['oacute'] = 500;
  51651. t['amacron'] = 500;
  51652. t['sacute'] = 389;
  51653. t['idieresis'] = 278;
  51654. t['Ocircumflex'] = 722;
  51655. t['Ugrave'] = 722;
  51656. t['Delta'] = 612;
  51657. t['thorn'] = 500;
  51658. t['twosuperior'] = 300;
  51659. t['Odieresis'] = 722;
  51660. t['mu'] = 576;
  51661. t['igrave'] = 278;
  51662. t['ohungarumlaut'] = 500;
  51663. t['Eogonek'] = 667;
  51664. t['dcroat'] = 500;
  51665. t['threequarters'] = 750;
  51666. t['Scedilla'] = 556;
  51667. t['lcaron'] = 382;
  51668. t['Kcommaaccent'] = 667;
  51669. t['Lacute'] = 611;
  51670. t['trademark'] = 1000;
  51671. t['edotaccent'] = 444;
  51672. t['Igrave'] = 389;
  51673. t['Imacron'] = 389;
  51674. t['Lcaron'] = 611;
  51675. t['onehalf'] = 750;
  51676. t['lessequal'] = 549;
  51677. t['ocircumflex'] = 500;
  51678. t['ntilde'] = 556;
  51679. t['Uhungarumlaut'] = 722;
  51680. t['Eacute'] = 667;
  51681. t['emacron'] = 444;
  51682. t['gbreve'] = 500;
  51683. t['onequarter'] = 750;
  51684. t['Scaron'] = 556;
  51685. t['Scommaaccent'] = 556;
  51686. t['Ohungarumlaut'] = 722;
  51687. t['degree'] = 400;
  51688. t['ograve'] = 500;
  51689. t['Ccaron'] = 667;
  51690. t['ugrave'] = 556;
  51691. t['radical'] = 549;
  51692. t['Dcaron'] = 722;
  51693. t['rcommaaccent'] = 389;
  51694. t['Ntilde'] = 722;
  51695. t['otilde'] = 500;
  51696. t['Rcommaaccent'] = 667;
  51697. t['Lcommaaccent'] = 611;
  51698. t['Atilde'] = 667;
  51699. t['Aogonek'] = 667;
  51700. t['Aring'] = 667;
  51701. t['Otilde'] = 722;
  51702. t['zdotaccent'] = 389;
  51703. t['Ecaron'] = 667;
  51704. t['Iogonek'] = 389;
  51705. t['kcommaaccent'] = 500;
  51706. t['minus'] = 606;
  51707. t['Icircumflex'] = 389;
  51708. t['ncaron'] = 556;
  51709. t['tcommaaccent'] = 278;
  51710. t['logicalnot'] = 606;
  51711. t['odieresis'] = 500;
  51712. t['udieresis'] = 556;
  51713. t['notequal'] = 549;
  51714. t['gcommaaccent'] = 500;
  51715. t['eth'] = 500;
  51716. t['zcaron'] = 389;
  51717. t['ncommaaccent'] = 556;
  51718. t['onesuperior'] = 300;
  51719. t['imacron'] = 278;
  51720. t['Euro'] = 500;
  51721. });
  51722. t['Times-Italic'] = getLookupTableFactory(function (t) {
  51723. t['space'] = 250;
  51724. t['exclam'] = 333;
  51725. t['quotedbl'] = 420;
  51726. t['numbersign'] = 500;
  51727. t['dollar'] = 500;
  51728. t['percent'] = 833;
  51729. t['ampersand'] = 778;
  51730. t['quoteright'] = 333;
  51731. t['parenleft'] = 333;
  51732. t['parenright'] = 333;
  51733. t['asterisk'] = 500;
  51734. t['plus'] = 675;
  51735. t['comma'] = 250;
  51736. t['hyphen'] = 333;
  51737. t['period'] = 250;
  51738. t['slash'] = 278;
  51739. t['zero'] = 500;
  51740. t['one'] = 500;
  51741. t['two'] = 500;
  51742. t['three'] = 500;
  51743. t['four'] = 500;
  51744. t['five'] = 500;
  51745. t['six'] = 500;
  51746. t['seven'] = 500;
  51747. t['eight'] = 500;
  51748. t['nine'] = 500;
  51749. t['colon'] = 333;
  51750. t['semicolon'] = 333;
  51751. t['less'] = 675;
  51752. t['equal'] = 675;
  51753. t['greater'] = 675;
  51754. t['question'] = 500;
  51755. t['at'] = 920;
  51756. t['A'] = 611;
  51757. t['B'] = 611;
  51758. t['C'] = 667;
  51759. t['D'] = 722;
  51760. t['E'] = 611;
  51761. t['F'] = 611;
  51762. t['G'] = 722;
  51763. t['H'] = 722;
  51764. t['I'] = 333;
  51765. t['J'] = 444;
  51766. t['K'] = 667;
  51767. t['L'] = 556;
  51768. t['M'] = 833;
  51769. t['N'] = 667;
  51770. t['O'] = 722;
  51771. t['P'] = 611;
  51772. t['Q'] = 722;
  51773. t['R'] = 611;
  51774. t['S'] = 500;
  51775. t['T'] = 556;
  51776. t['U'] = 722;
  51777. t['V'] = 611;
  51778. t['W'] = 833;
  51779. t['X'] = 611;
  51780. t['Y'] = 556;
  51781. t['Z'] = 556;
  51782. t['bracketleft'] = 389;
  51783. t['backslash'] = 278;
  51784. t['bracketright'] = 389;
  51785. t['asciicircum'] = 422;
  51786. t['underscore'] = 500;
  51787. t['quoteleft'] = 333;
  51788. t['a'] = 500;
  51789. t['b'] = 500;
  51790. t['c'] = 444;
  51791. t['d'] = 500;
  51792. t['e'] = 444;
  51793. t['f'] = 278;
  51794. t['g'] = 500;
  51795. t['h'] = 500;
  51796. t['i'] = 278;
  51797. t['j'] = 278;
  51798. t['k'] = 444;
  51799. t['l'] = 278;
  51800. t['m'] = 722;
  51801. t['n'] = 500;
  51802. t['o'] = 500;
  51803. t['p'] = 500;
  51804. t['q'] = 500;
  51805. t['r'] = 389;
  51806. t['s'] = 389;
  51807. t['t'] = 278;
  51808. t['u'] = 500;
  51809. t['v'] = 444;
  51810. t['w'] = 667;
  51811. t['x'] = 444;
  51812. t['y'] = 444;
  51813. t['z'] = 389;
  51814. t['braceleft'] = 400;
  51815. t['bar'] = 275;
  51816. t['braceright'] = 400;
  51817. t['asciitilde'] = 541;
  51818. t['exclamdown'] = 389;
  51819. t['cent'] = 500;
  51820. t['sterling'] = 500;
  51821. t['fraction'] = 167;
  51822. t['yen'] = 500;
  51823. t['florin'] = 500;
  51824. t['section'] = 500;
  51825. t['currency'] = 500;
  51826. t['quotesingle'] = 214;
  51827. t['quotedblleft'] = 556;
  51828. t['guillemotleft'] = 500;
  51829. t['guilsinglleft'] = 333;
  51830. t['guilsinglright'] = 333;
  51831. t['fi'] = 500;
  51832. t['fl'] = 500;
  51833. t['endash'] = 500;
  51834. t['dagger'] = 500;
  51835. t['daggerdbl'] = 500;
  51836. t['periodcentered'] = 250;
  51837. t['paragraph'] = 523;
  51838. t['bullet'] = 350;
  51839. t['quotesinglbase'] = 333;
  51840. t['quotedblbase'] = 556;
  51841. t['quotedblright'] = 556;
  51842. t['guillemotright'] = 500;
  51843. t['ellipsis'] = 889;
  51844. t['perthousand'] = 1000;
  51845. t['questiondown'] = 500;
  51846. t['grave'] = 333;
  51847. t['acute'] = 333;
  51848. t['circumflex'] = 333;
  51849. t['tilde'] = 333;
  51850. t['macron'] = 333;
  51851. t['breve'] = 333;
  51852. t['dotaccent'] = 333;
  51853. t['dieresis'] = 333;
  51854. t['ring'] = 333;
  51855. t['cedilla'] = 333;
  51856. t['hungarumlaut'] = 333;
  51857. t['ogonek'] = 333;
  51858. t['caron'] = 333;
  51859. t['emdash'] = 889;
  51860. t['AE'] = 889;
  51861. t['ordfeminine'] = 276;
  51862. t['Lslash'] = 556;
  51863. t['Oslash'] = 722;
  51864. t['OE'] = 944;
  51865. t['ordmasculine'] = 310;
  51866. t['ae'] = 667;
  51867. t['dotlessi'] = 278;
  51868. t['lslash'] = 278;
  51869. t['oslash'] = 500;
  51870. t['oe'] = 667;
  51871. t['germandbls'] = 500;
  51872. t['Idieresis'] = 333;
  51873. t['eacute'] = 444;
  51874. t['abreve'] = 500;
  51875. t['uhungarumlaut'] = 500;
  51876. t['ecaron'] = 444;
  51877. t['Ydieresis'] = 556;
  51878. t['divide'] = 675;
  51879. t['Yacute'] = 556;
  51880. t['Acircumflex'] = 611;
  51881. t['aacute'] = 500;
  51882. t['Ucircumflex'] = 722;
  51883. t['yacute'] = 444;
  51884. t['scommaaccent'] = 389;
  51885. t['ecircumflex'] = 444;
  51886. t['Uring'] = 722;
  51887. t['Udieresis'] = 722;
  51888. t['aogonek'] = 500;
  51889. t['Uacute'] = 722;
  51890. t['uogonek'] = 500;
  51891. t['Edieresis'] = 611;
  51892. t['Dcroat'] = 722;
  51893. t['commaaccent'] = 250;
  51894. t['copyright'] = 760;
  51895. t['Emacron'] = 611;
  51896. t['ccaron'] = 444;
  51897. t['aring'] = 500;
  51898. t['Ncommaaccent'] = 667;
  51899. t['lacute'] = 278;
  51900. t['agrave'] = 500;
  51901. t['Tcommaaccent'] = 556;
  51902. t['Cacute'] = 667;
  51903. t['atilde'] = 500;
  51904. t['Edotaccent'] = 611;
  51905. t['scaron'] = 389;
  51906. t['scedilla'] = 389;
  51907. t['iacute'] = 278;
  51908. t['lozenge'] = 471;
  51909. t['Rcaron'] = 611;
  51910. t['Gcommaaccent'] = 722;
  51911. t['ucircumflex'] = 500;
  51912. t['acircumflex'] = 500;
  51913. t['Amacron'] = 611;
  51914. t['rcaron'] = 389;
  51915. t['ccedilla'] = 444;
  51916. t['Zdotaccent'] = 556;
  51917. t['Thorn'] = 611;
  51918. t['Omacron'] = 722;
  51919. t['Racute'] = 611;
  51920. t['Sacute'] = 500;
  51921. t['dcaron'] = 544;
  51922. t['Umacron'] = 722;
  51923. t['uring'] = 500;
  51924. t['threesuperior'] = 300;
  51925. t['Ograve'] = 722;
  51926. t['Agrave'] = 611;
  51927. t['Abreve'] = 611;
  51928. t['multiply'] = 675;
  51929. t['uacute'] = 500;
  51930. t['Tcaron'] = 556;
  51931. t['partialdiff'] = 476;
  51932. t['ydieresis'] = 444;
  51933. t['Nacute'] = 667;
  51934. t['icircumflex'] = 278;
  51935. t['Ecircumflex'] = 611;
  51936. t['adieresis'] = 500;
  51937. t['edieresis'] = 444;
  51938. t['cacute'] = 444;
  51939. t['nacute'] = 500;
  51940. t['umacron'] = 500;
  51941. t['Ncaron'] = 667;
  51942. t['Iacute'] = 333;
  51943. t['plusminus'] = 675;
  51944. t['brokenbar'] = 275;
  51945. t['registered'] = 760;
  51946. t['Gbreve'] = 722;
  51947. t['Idotaccent'] = 333;
  51948. t['summation'] = 600;
  51949. t['Egrave'] = 611;
  51950. t['racute'] = 389;
  51951. t['omacron'] = 500;
  51952. t['Zacute'] = 556;
  51953. t['Zcaron'] = 556;
  51954. t['greaterequal'] = 549;
  51955. t['Eth'] = 722;
  51956. t['Ccedilla'] = 667;
  51957. t['lcommaaccent'] = 278;
  51958. t['tcaron'] = 300;
  51959. t['eogonek'] = 444;
  51960. t['Uogonek'] = 722;
  51961. t['Aacute'] = 611;
  51962. t['Adieresis'] = 611;
  51963. t['egrave'] = 444;
  51964. t['zacute'] = 389;
  51965. t['iogonek'] = 278;
  51966. t['Oacute'] = 722;
  51967. t['oacute'] = 500;
  51968. t['amacron'] = 500;
  51969. t['sacute'] = 389;
  51970. t['idieresis'] = 278;
  51971. t['Ocircumflex'] = 722;
  51972. t['Ugrave'] = 722;
  51973. t['Delta'] = 612;
  51974. t['thorn'] = 500;
  51975. t['twosuperior'] = 300;
  51976. t['Odieresis'] = 722;
  51977. t['mu'] = 500;
  51978. t['igrave'] = 278;
  51979. t['ohungarumlaut'] = 500;
  51980. t['Eogonek'] = 611;
  51981. t['dcroat'] = 500;
  51982. t['threequarters'] = 750;
  51983. t['Scedilla'] = 500;
  51984. t['lcaron'] = 300;
  51985. t['Kcommaaccent'] = 667;
  51986. t['Lacute'] = 556;
  51987. t['trademark'] = 980;
  51988. t['edotaccent'] = 444;
  51989. t['Igrave'] = 333;
  51990. t['Imacron'] = 333;
  51991. t['Lcaron'] = 611;
  51992. t['onehalf'] = 750;
  51993. t['lessequal'] = 549;
  51994. t['ocircumflex'] = 500;
  51995. t['ntilde'] = 500;
  51996. t['Uhungarumlaut'] = 722;
  51997. t['Eacute'] = 611;
  51998. t['emacron'] = 444;
  51999. t['gbreve'] = 500;
  52000. t['onequarter'] = 750;
  52001. t['Scaron'] = 500;
  52002. t['Scommaaccent'] = 500;
  52003. t['Ohungarumlaut'] = 722;
  52004. t['degree'] = 400;
  52005. t['ograve'] = 500;
  52006. t['Ccaron'] = 667;
  52007. t['ugrave'] = 500;
  52008. t['radical'] = 453;
  52009. t['Dcaron'] = 722;
  52010. t['rcommaaccent'] = 389;
  52011. t['Ntilde'] = 667;
  52012. t['otilde'] = 500;
  52013. t['Rcommaaccent'] = 611;
  52014. t['Lcommaaccent'] = 556;
  52015. t['Atilde'] = 611;
  52016. t['Aogonek'] = 611;
  52017. t['Aring'] = 611;
  52018. t['Otilde'] = 722;
  52019. t['zdotaccent'] = 389;
  52020. t['Ecaron'] = 611;
  52021. t['Iogonek'] = 333;
  52022. t['kcommaaccent'] = 444;
  52023. t['minus'] = 675;
  52024. t['Icircumflex'] = 333;
  52025. t['ncaron'] = 500;
  52026. t['tcommaaccent'] = 278;
  52027. t['logicalnot'] = 675;
  52028. t['odieresis'] = 500;
  52029. t['udieresis'] = 500;
  52030. t['notequal'] = 549;
  52031. t['gcommaaccent'] = 500;
  52032. t['eth'] = 500;
  52033. t['zcaron'] = 389;
  52034. t['ncommaaccent'] = 500;
  52035. t['onesuperior'] = 300;
  52036. t['imacron'] = 278;
  52037. t['Euro'] = 500;
  52038. });
  52039. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  52040. t['space'] = 278;
  52041. t['a1'] = 974;
  52042. t['a2'] = 961;
  52043. t['a202'] = 974;
  52044. t['a3'] = 980;
  52045. t['a4'] = 719;
  52046. t['a5'] = 789;
  52047. t['a119'] = 790;
  52048. t['a118'] = 791;
  52049. t['a117'] = 690;
  52050. t['a11'] = 960;
  52051. t['a12'] = 939;
  52052. t['a13'] = 549;
  52053. t['a14'] = 855;
  52054. t['a15'] = 911;
  52055. t['a16'] = 933;
  52056. t['a105'] = 911;
  52057. t['a17'] = 945;
  52058. t['a18'] = 974;
  52059. t['a19'] = 755;
  52060. t['a20'] = 846;
  52061. t['a21'] = 762;
  52062. t['a22'] = 761;
  52063. t['a23'] = 571;
  52064. t['a24'] = 677;
  52065. t['a25'] = 763;
  52066. t['a26'] = 760;
  52067. t['a27'] = 759;
  52068. t['a28'] = 754;
  52069. t['a6'] = 494;
  52070. t['a7'] = 552;
  52071. t['a8'] = 537;
  52072. t['a9'] = 577;
  52073. t['a10'] = 692;
  52074. t['a29'] = 786;
  52075. t['a30'] = 788;
  52076. t['a31'] = 788;
  52077. t['a32'] = 790;
  52078. t['a33'] = 793;
  52079. t['a34'] = 794;
  52080. t['a35'] = 816;
  52081. t['a36'] = 823;
  52082. t['a37'] = 789;
  52083. t['a38'] = 841;
  52084. t['a39'] = 823;
  52085. t['a40'] = 833;
  52086. t['a41'] = 816;
  52087. t['a42'] = 831;
  52088. t['a43'] = 923;
  52089. t['a44'] = 744;
  52090. t['a45'] = 723;
  52091. t['a46'] = 749;
  52092. t['a47'] = 790;
  52093. t['a48'] = 792;
  52094. t['a49'] = 695;
  52095. t['a50'] = 776;
  52096. t['a51'] = 768;
  52097. t['a52'] = 792;
  52098. t['a53'] = 759;
  52099. t['a54'] = 707;
  52100. t['a55'] = 708;
  52101. t['a56'] = 682;
  52102. t['a57'] = 701;
  52103. t['a58'] = 826;
  52104. t['a59'] = 815;
  52105. t['a60'] = 789;
  52106. t['a61'] = 789;
  52107. t['a62'] = 707;
  52108. t['a63'] = 687;
  52109. t['a64'] = 696;
  52110. t['a65'] = 689;
  52111. t['a66'] = 786;
  52112. t['a67'] = 787;
  52113. t['a68'] = 713;
  52114. t['a69'] = 791;
  52115. t['a70'] = 785;
  52116. t['a71'] = 791;
  52117. t['a72'] = 873;
  52118. t['a73'] = 761;
  52119. t['a74'] = 762;
  52120. t['a203'] = 762;
  52121. t['a75'] = 759;
  52122. t['a204'] = 759;
  52123. t['a76'] = 892;
  52124. t['a77'] = 892;
  52125. t['a78'] = 788;
  52126. t['a79'] = 784;
  52127. t['a81'] = 438;
  52128. t['a82'] = 138;
  52129. t['a83'] = 277;
  52130. t['a84'] = 415;
  52131. t['a97'] = 392;
  52132. t['a98'] = 392;
  52133. t['a99'] = 668;
  52134. t['a100'] = 668;
  52135. t['a89'] = 390;
  52136. t['a90'] = 390;
  52137. t['a93'] = 317;
  52138. t['a94'] = 317;
  52139. t['a91'] = 276;
  52140. t['a92'] = 276;
  52141. t['a205'] = 509;
  52142. t['a85'] = 509;
  52143. t['a206'] = 410;
  52144. t['a86'] = 410;
  52145. t['a87'] = 234;
  52146. t['a88'] = 234;
  52147. t['a95'] = 334;
  52148. t['a96'] = 334;
  52149. t['a101'] = 732;
  52150. t['a102'] = 544;
  52151. t['a103'] = 544;
  52152. t['a104'] = 910;
  52153. t['a106'] = 667;
  52154. t['a107'] = 760;
  52155. t['a108'] = 760;
  52156. t['a112'] = 776;
  52157. t['a111'] = 595;
  52158. t['a110'] = 694;
  52159. t['a109'] = 626;
  52160. t['a120'] = 788;
  52161. t['a121'] = 788;
  52162. t['a122'] = 788;
  52163. t['a123'] = 788;
  52164. t['a124'] = 788;
  52165. t['a125'] = 788;
  52166. t['a126'] = 788;
  52167. t['a127'] = 788;
  52168. t['a128'] = 788;
  52169. t['a129'] = 788;
  52170. t['a130'] = 788;
  52171. t['a131'] = 788;
  52172. t['a132'] = 788;
  52173. t['a133'] = 788;
  52174. t['a134'] = 788;
  52175. t['a135'] = 788;
  52176. t['a136'] = 788;
  52177. t['a137'] = 788;
  52178. t['a138'] = 788;
  52179. t['a139'] = 788;
  52180. t['a140'] = 788;
  52181. t['a141'] = 788;
  52182. t['a142'] = 788;
  52183. t['a143'] = 788;
  52184. t['a144'] = 788;
  52185. t['a145'] = 788;
  52186. t['a146'] = 788;
  52187. t['a147'] = 788;
  52188. t['a148'] = 788;
  52189. t['a149'] = 788;
  52190. t['a150'] = 788;
  52191. t['a151'] = 788;
  52192. t['a152'] = 788;
  52193. t['a153'] = 788;
  52194. t['a154'] = 788;
  52195. t['a155'] = 788;
  52196. t['a156'] = 788;
  52197. t['a157'] = 788;
  52198. t['a158'] = 788;
  52199. t['a159'] = 788;
  52200. t['a160'] = 894;
  52201. t['a161'] = 838;
  52202. t['a163'] = 1016;
  52203. t['a164'] = 458;
  52204. t['a196'] = 748;
  52205. t['a165'] = 924;
  52206. t['a192'] = 748;
  52207. t['a166'] = 918;
  52208. t['a167'] = 927;
  52209. t['a168'] = 928;
  52210. t['a169'] = 928;
  52211. t['a170'] = 834;
  52212. t['a171'] = 873;
  52213. t['a172'] = 828;
  52214. t['a173'] = 924;
  52215. t['a162'] = 924;
  52216. t['a174'] = 917;
  52217. t['a175'] = 930;
  52218. t['a176'] = 931;
  52219. t['a177'] = 463;
  52220. t['a178'] = 883;
  52221. t['a179'] = 836;
  52222. t['a193'] = 836;
  52223. t['a180'] = 867;
  52224. t['a199'] = 867;
  52225. t['a181'] = 696;
  52226. t['a200'] = 696;
  52227. t['a182'] = 874;
  52228. t['a201'] = 874;
  52229. t['a183'] = 760;
  52230. t['a184'] = 946;
  52231. t['a197'] = 771;
  52232. t['a185'] = 865;
  52233. t['a194'] = 771;
  52234. t['a198'] = 888;
  52235. t['a186'] = 967;
  52236. t['a195'] = 888;
  52237. t['a187'] = 831;
  52238. t['a188'] = 873;
  52239. t['a189'] = 927;
  52240. t['a190'] = 970;
  52241. t['a191'] = 918;
  52242. });
  52243. });
  52244. exports.getMetrics = getMetrics;
  52245. /***/ }),
  52246. /* 38 */
  52247. /***/ (function(module, exports, __w_pdfjs_require__) {
  52248. "use strict";
  52249. var sharedUtil = __w_pdfjs_require__(0);
  52250. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52251. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52252. var MASK_HIGH = 0xffff0000;
  52253. var MASK_LOW = 0xffff;
  52254. function MurmurHash3_64(seed) {
  52255. var SEED = 0xc3d2e1f0;
  52256. this.h1 = seed ? seed & 0xffffffff : SEED;
  52257. this.h2 = seed ? seed & 0xffffffff : SEED;
  52258. }
  52259. var alwaysUseUint32ArrayView = false;
  52260. try {
  52261. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52262. } catch (e) {
  52263. alwaysUseUint32ArrayView = true;
  52264. }
  52265. MurmurHash3_64.prototype = {
  52266. update: function MurmurHash3_64_update(input) {
  52267. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52268. var i;
  52269. if (typeof input === 'string') {
  52270. var data = new Uint8Array(input.length * 2);
  52271. var length = 0;
  52272. for (i = 0; i < input.length; i++) {
  52273. var code = input.charCodeAt(i);
  52274. if (code <= 0xff) {
  52275. data[length++] = code;
  52276. } else {
  52277. data[length++] = code >>> 8;
  52278. data[length++] = code & 0xff;
  52279. }
  52280. }
  52281. } else if (input instanceof Uint8Array) {
  52282. data = input;
  52283. length = data.length;
  52284. } else if (typeof input === 'object' && 'length' in input) {
  52285. data = input;
  52286. length = data.length;
  52287. useUint32ArrayView = true;
  52288. } else {
  52289. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52290. }
  52291. var blockCounts = length >> 2;
  52292. var tailLength = length - blockCounts * 4;
  52293. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52294. var k1 = 0;
  52295. var k2 = 0;
  52296. var h1 = this.h1;
  52297. var h2 = this.h2;
  52298. var C1 = 0xcc9e2d51;
  52299. var C2 = 0x1b873593;
  52300. var C1_LOW = C1 & MASK_LOW;
  52301. var C2_LOW = C2 & MASK_LOW;
  52302. for (i = 0; i < blockCounts; i++) {
  52303. if (i & 1) {
  52304. k1 = dataUint32[i];
  52305. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52306. k1 = k1 << 15 | k1 >>> 17;
  52307. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52308. h1 ^= k1;
  52309. h1 = h1 << 13 | h1 >>> 19;
  52310. h1 = h1 * 5 + 0xe6546b64;
  52311. } else {
  52312. k2 = dataUint32[i];
  52313. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52314. k2 = k2 << 15 | k2 >>> 17;
  52315. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52316. h2 ^= k2;
  52317. h2 = h2 << 13 | h2 >>> 19;
  52318. h2 = h2 * 5 + 0xe6546b64;
  52319. }
  52320. }
  52321. k1 = 0;
  52322. switch (tailLength) {
  52323. case 3:
  52324. k1 ^= data[blockCounts * 4 + 2] << 16;
  52325. case 2:
  52326. k1 ^= data[blockCounts * 4 + 1] << 8;
  52327. case 1:
  52328. k1 ^= data[blockCounts * 4];
  52329. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52330. k1 = k1 << 15 | k1 >>> 17;
  52331. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52332. if (blockCounts & 1) {
  52333. h1 ^= k1;
  52334. } else {
  52335. h2 ^= k1;
  52336. }
  52337. }
  52338. this.h1 = h1;
  52339. this.h2 = h2;
  52340. return this;
  52341. },
  52342. hexdigest: function MurmurHash3_64_hexdigest() {
  52343. var h1 = this.h1;
  52344. var h2 = this.h2;
  52345. h1 ^= h2 >>> 1;
  52346. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52347. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52348. h1 ^= h2 >>> 1;
  52349. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52350. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52351. h1 ^= h2 >>> 1;
  52352. for (var i = 0, arr = [
  52353. h1,
  52354. h2
  52355. ], str = ''; i < arr.length; i++) {
  52356. var hex = (arr[i] >>> 0).toString(16);
  52357. while (hex.length < 8) {
  52358. hex = '0' + hex;
  52359. }
  52360. str += hex;
  52361. }
  52362. return str;
  52363. }
  52364. };
  52365. return MurmurHash3_64;
  52366. }();
  52367. exports.MurmurHash3_64 = MurmurHash3_64;
  52368. /***/ }),
  52369. /* 39 */
  52370. /***/ (function(module, exports, __w_pdfjs_require__) {
  52371. "use strict";
  52372. var sharedUtil = __w_pdfjs_require__(0);
  52373. var coreWorker = __w_pdfjs_require__(22);
  52374. var OK_RESPONSE = 200;
  52375. var PARTIAL_CONTENT_RESPONSE = 206;
  52376. function NetworkManager(url, args) {
  52377. this.url = url;
  52378. args = args || {};
  52379. this.isHttp = /^https?:/i.test(url);
  52380. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  52381. this.withCredentials = args.withCredentials || false;
  52382. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  52383. return new XMLHttpRequest();
  52384. };
  52385. this.currXhrId = 0;
  52386. this.pendingRequests = Object.create(null);
  52387. this.loadedRequests = Object.create(null);
  52388. }
  52389. function getArrayBuffer(xhr) {
  52390. var data = xhr.response;
  52391. if (typeof data !== 'string') {
  52392. return data;
  52393. }
  52394. var length = data.length;
  52395. var array = new Uint8Array(length);
  52396. for (var i = 0; i < length; i++) {
  52397. array[i] = data.charCodeAt(i) & 0xFF;
  52398. }
  52399. return array.buffer;
  52400. }
  52401. var supportsMozChunked = function supportsMozChunkedClosure() {
  52402. try {
  52403. var x = new XMLHttpRequest();
  52404. x.open('GET', 'https://example.com');
  52405. x.responseType = 'moz-chunked-arraybuffer';
  52406. return x.responseType === 'moz-chunked-arraybuffer';
  52407. } catch (e) {
  52408. return false;
  52409. }
  52410. }();
  52411. NetworkManager.prototype = {
  52412. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  52413. var args = {
  52414. begin: begin,
  52415. end: end
  52416. };
  52417. for (var prop in listeners) {
  52418. args[prop] = listeners[prop];
  52419. }
  52420. return this.request(args);
  52421. },
  52422. requestFull: function NetworkManager_requestFull(listeners) {
  52423. return this.request(listeners);
  52424. },
  52425. request: function NetworkManager_request(args) {
  52426. var xhr = this.getXhr();
  52427. var xhrId = this.currXhrId++;
  52428. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  52429. xhr.open('GET', this.url);
  52430. xhr.withCredentials = this.withCredentials;
  52431. for (var property in this.httpHeaders) {
  52432. var value = this.httpHeaders[property];
  52433. if (typeof value === 'undefined') {
  52434. continue;
  52435. }
  52436. xhr.setRequestHeader(property, value);
  52437. }
  52438. if (this.isHttp && 'begin' in args && 'end' in args) {
  52439. var rangeStr = args.begin + '-' + (args.end - 1);
  52440. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  52441. pendingRequest.expectedStatus = 206;
  52442. } else {
  52443. pendingRequest.expectedStatus = 200;
  52444. }
  52445. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  52446. if (useMozChunkedLoading) {
  52447. xhr.responseType = 'moz-chunked-arraybuffer';
  52448. pendingRequest.onProgressiveData = args.onProgressiveData;
  52449. pendingRequest.mozChunked = true;
  52450. } else {
  52451. xhr.responseType = 'arraybuffer';
  52452. }
  52453. if (args.onError) {
  52454. xhr.onerror = function (evt) {
  52455. args.onError(xhr.status);
  52456. };
  52457. }
  52458. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  52459. xhr.onprogress = this.onProgress.bind(this, xhrId);
  52460. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  52461. pendingRequest.onDone = args.onDone;
  52462. pendingRequest.onError = args.onError;
  52463. pendingRequest.onProgress = args.onProgress;
  52464. xhr.send(null);
  52465. return xhrId;
  52466. },
  52467. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  52468. var pendingRequest = this.pendingRequests[xhrId];
  52469. if (!pendingRequest) {
  52470. return;
  52471. }
  52472. if (pendingRequest.mozChunked) {
  52473. var chunk = getArrayBuffer(pendingRequest.xhr);
  52474. pendingRequest.onProgressiveData(chunk);
  52475. }
  52476. var onProgress = pendingRequest.onProgress;
  52477. if (onProgress) {
  52478. onProgress(evt);
  52479. }
  52480. },
  52481. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  52482. var pendingRequest = this.pendingRequests[xhrId];
  52483. if (!pendingRequest) {
  52484. return;
  52485. }
  52486. var xhr = pendingRequest.xhr;
  52487. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  52488. pendingRequest.onHeadersReceived();
  52489. delete pendingRequest.onHeadersReceived;
  52490. }
  52491. if (xhr.readyState !== 4) {
  52492. return;
  52493. }
  52494. if (!(xhrId in this.pendingRequests)) {
  52495. return;
  52496. }
  52497. delete this.pendingRequests[xhrId];
  52498. if (xhr.status === 0 && this.isHttp) {
  52499. if (pendingRequest.onError) {
  52500. pendingRequest.onError(xhr.status);
  52501. }
  52502. return;
  52503. }
  52504. var xhrStatus = xhr.status || OK_RESPONSE;
  52505. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  52506. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  52507. if (pendingRequest.onError) {
  52508. pendingRequest.onError(xhr.status);
  52509. }
  52510. return;
  52511. }
  52512. this.loadedRequests[xhrId] = true;
  52513. var chunk = getArrayBuffer(xhr);
  52514. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  52515. var rangeHeader = xhr.getResponseHeader('Content-Range');
  52516. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  52517. var begin = parseInt(matches[1], 10);
  52518. pendingRequest.onDone({
  52519. begin: begin,
  52520. chunk: chunk
  52521. });
  52522. } else if (pendingRequest.onProgressiveData) {
  52523. pendingRequest.onDone(null);
  52524. } else if (chunk) {
  52525. pendingRequest.onDone({
  52526. begin: 0,
  52527. chunk: chunk
  52528. });
  52529. } else if (pendingRequest.onError) {
  52530. pendingRequest.onError(xhr.status);
  52531. }
  52532. },
  52533. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  52534. for (var xhrId in this.pendingRequests) {
  52535. return true;
  52536. }
  52537. return false;
  52538. },
  52539. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  52540. return this.pendingRequests[xhrId].xhr;
  52541. },
  52542. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  52543. return !!this.pendingRequests[xhrId].onProgressiveData;
  52544. },
  52545. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  52546. return xhrId in this.pendingRequests;
  52547. },
  52548. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  52549. return xhrId in this.loadedRequests;
  52550. },
  52551. abortAllRequests: function NetworkManager_abortAllRequests() {
  52552. for (var xhrId in this.pendingRequests) {
  52553. this.abortRequest(xhrId | 0);
  52554. }
  52555. },
  52556. abortRequest: function NetworkManager_abortRequest(xhrId) {
  52557. var xhr = this.pendingRequests[xhrId].xhr;
  52558. delete this.pendingRequests[xhrId];
  52559. xhr.abort();
  52560. }
  52561. };
  52562. var assert = sharedUtil.assert;
  52563. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52564. var isInt = sharedUtil.isInt;
  52565. var MissingPDFException = sharedUtil.MissingPDFException;
  52566. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  52567. function PDFNetworkStream(options) {
  52568. this._options = options;
  52569. var source = options.source;
  52570. this._manager = new NetworkManager(source.url, {
  52571. httpHeaders: source.httpHeaders,
  52572. withCredentials: source.withCredentials
  52573. });
  52574. this._rangeChunkSize = source.rangeChunkSize;
  52575. this._fullRequestReader = null;
  52576. this._rangeRequestReaders = [];
  52577. }
  52578. PDFNetworkStream.prototype = {
  52579. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  52580. var i = this._rangeRequestReaders.indexOf(reader);
  52581. if (i >= 0) {
  52582. this._rangeRequestReaders.splice(i, 1);
  52583. }
  52584. },
  52585. getFullReader: function PDFNetworkStream_getFullReader() {
  52586. assert(!this._fullRequestReader);
  52587. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  52588. return this._fullRequestReader;
  52589. },
  52590. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  52591. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  52592. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  52593. this._rangeRequestReaders.push(reader);
  52594. return reader;
  52595. },
  52596. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  52597. if (this._fullRequestReader) {
  52598. this._fullRequestReader.cancel(reason);
  52599. }
  52600. var readers = this._rangeRequestReaders.slice(0);
  52601. readers.forEach(function (reader) {
  52602. reader.cancel(reason);
  52603. });
  52604. }
  52605. };
  52606. function PDFNetworkStreamFullRequestReader(manager, options) {
  52607. this._manager = manager;
  52608. var source = options.source;
  52609. var args = {
  52610. onHeadersReceived: this._onHeadersReceived.bind(this),
  52611. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  52612. onDone: this._onDone.bind(this),
  52613. onError: this._onError.bind(this),
  52614. onProgress: this._onProgress.bind(this)
  52615. };
  52616. this._url = source.url;
  52617. this._fullRequestId = manager.requestFull(args);
  52618. this._headersReceivedCapability = createPromiseCapability();
  52619. this._disableRange = options.disableRange || false;
  52620. this._contentLength = source.length;
  52621. this._rangeChunkSize = source.rangeChunkSize;
  52622. if (!this._rangeChunkSize && !this._disableRange) {
  52623. this._disableRange = true;
  52624. }
  52625. this._isStreamingSupported = false;
  52626. this._isRangeSupported = false;
  52627. this._cachedChunks = [];
  52628. this._requests = [];
  52629. this._done = false;
  52630. this._storedError = undefined;
  52631. this.onProgress = null;
  52632. }
  52633. PDFNetworkStreamFullRequestReader.prototype = {
  52634. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  52635. if (this._disableRange) {
  52636. return false;
  52637. }
  52638. var networkManager = this._manager;
  52639. if (!networkManager.isHttp) {
  52640. return false;
  52641. }
  52642. var fullRequestXhrId = this._fullRequestId;
  52643. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  52644. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  52645. return false;
  52646. }
  52647. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  52648. if (contentEncoding !== 'identity') {
  52649. return false;
  52650. }
  52651. var length = fullRequestXhr.getResponseHeader('Content-Length');
  52652. length = parseInt(length, 10);
  52653. if (!isInt(length)) {
  52654. return false;
  52655. }
  52656. this._contentLength = length;
  52657. if (length <= 2 * this._rangeChunkSize) {
  52658. return false;
  52659. }
  52660. return true;
  52661. },
  52662. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  52663. if (this._validateRangeRequestCapabilities()) {
  52664. this._isRangeSupported = true;
  52665. }
  52666. var networkManager = this._manager;
  52667. var fullRequestXhrId = this._fullRequestId;
  52668. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  52669. this._isStreamingSupported = true;
  52670. } else if (this._isRangeSupported) {
  52671. networkManager.abortRequest(fullRequestXhrId);
  52672. }
  52673. this._headersReceivedCapability.resolve();
  52674. },
  52675. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  52676. if (this._requests.length > 0) {
  52677. var requestCapability = this._requests.shift();
  52678. requestCapability.resolve({
  52679. value: chunk,
  52680. done: false
  52681. });
  52682. } else {
  52683. this._cachedChunks.push(chunk);
  52684. }
  52685. },
  52686. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  52687. if (args) {
  52688. this._onProgressiveData(args.chunk);
  52689. }
  52690. this._done = true;
  52691. if (this._cachedChunks.length > 0) {
  52692. return;
  52693. }
  52694. this._requests.forEach(function (requestCapability) {
  52695. requestCapability.resolve({
  52696. value: undefined,
  52697. done: true
  52698. });
  52699. });
  52700. this._requests = [];
  52701. },
  52702. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  52703. var url = this._url;
  52704. var exception;
  52705. if (status === 404 || status === 0 && /^file:/.test(url)) {
  52706. exception = new MissingPDFException('Missing PDF "' + url + '".');
  52707. } else {
  52708. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  52709. }
  52710. this._storedError = exception;
  52711. this._headersReceivedCapability.reject(exception);
  52712. this._requests.forEach(function (requestCapability) {
  52713. requestCapability.reject(exception);
  52714. });
  52715. this._requests = [];
  52716. this._cachedChunks = [];
  52717. },
  52718. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  52719. if (this.onProgress) {
  52720. this.onProgress({
  52721. loaded: data.loaded,
  52722. total: data.lengthComputable ? data.total : this._contentLength
  52723. });
  52724. }
  52725. },
  52726. get isRangeSupported() {
  52727. return this._isRangeSupported;
  52728. },
  52729. get isStreamingSupported() {
  52730. return this._isStreamingSupported;
  52731. },
  52732. get contentLength() {
  52733. return this._contentLength;
  52734. },
  52735. get headersReady() {
  52736. return this._headersReceivedCapability.promise;
  52737. },
  52738. read: function PDFNetworkStreamFullRequestReader_read() {
  52739. if (this._storedError) {
  52740. return Promise.reject(this._storedError);
  52741. }
  52742. if (this._cachedChunks.length > 0) {
  52743. var chunk = this._cachedChunks.shift();
  52744. return Promise.resolve(chunk);
  52745. }
  52746. if (this._done) {
  52747. return Promise.resolve({
  52748. value: undefined,
  52749. done: true
  52750. });
  52751. }
  52752. var requestCapability = createPromiseCapability();
  52753. this._requests.push(requestCapability);
  52754. return requestCapability.promise;
  52755. },
  52756. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  52757. this._done = true;
  52758. this._headersReceivedCapability.reject(reason);
  52759. this._requests.forEach(function (requestCapability) {
  52760. requestCapability.resolve({
  52761. value: undefined,
  52762. done: true
  52763. });
  52764. });
  52765. this._requests = [];
  52766. if (this._manager.isPendingRequest(this._fullRequestId)) {
  52767. this._manager.abortRequest(this._fullRequestId);
  52768. }
  52769. this._fullRequestReader = null;
  52770. }
  52771. };
  52772. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  52773. this._manager = manager;
  52774. var args = {
  52775. onDone: this._onDone.bind(this),
  52776. onProgress: this._onProgress.bind(this)
  52777. };
  52778. this._requestId = manager.requestRange(begin, end, args);
  52779. this._requests = [];
  52780. this._queuedChunk = null;
  52781. this._done = false;
  52782. this.onProgress = null;
  52783. this.onClosed = null;
  52784. }
  52785. PDFNetworkStreamRangeRequestReader.prototype = {
  52786. _close: function PDFNetworkStreamRangeRequestReader_close() {
  52787. if (this.onClosed) {
  52788. this.onClosed(this);
  52789. }
  52790. },
  52791. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  52792. var chunk = data.chunk;
  52793. if (this._requests.length > 0) {
  52794. var requestCapability = this._requests.shift();
  52795. requestCapability.resolve({
  52796. value: chunk,
  52797. done: false
  52798. });
  52799. } else {
  52800. this._queuedChunk = chunk;
  52801. }
  52802. this._done = true;
  52803. this._requests.forEach(function (requestCapability) {
  52804. requestCapability.resolve({
  52805. value: undefined,
  52806. done: true
  52807. });
  52808. });
  52809. this._requests = [];
  52810. this._close();
  52811. },
  52812. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  52813. if (!this.isStreamingSupported && this.onProgress) {
  52814. this.onProgress({ loaded: evt.loaded });
  52815. }
  52816. },
  52817. get isStreamingSupported() {
  52818. return false;
  52819. },
  52820. read: function PDFNetworkStreamRangeRequestReader_read() {
  52821. if (this._queuedChunk !== null) {
  52822. var chunk = this._queuedChunk;
  52823. this._queuedChunk = null;
  52824. return Promise.resolve({
  52825. value: chunk,
  52826. done: false
  52827. });
  52828. }
  52829. if (this._done) {
  52830. return Promise.resolve({
  52831. value: undefined,
  52832. done: true
  52833. });
  52834. }
  52835. var requestCapability = createPromiseCapability();
  52836. this._requests.push(requestCapability);
  52837. return requestCapability.promise;
  52838. },
  52839. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52840. this._done = true;
  52841. this._requests.forEach(function (requestCapability) {
  52842. requestCapability.resolve({
  52843. value: undefined,
  52844. done: true
  52845. });
  52846. });
  52847. this._requests = [];
  52848. if (this._manager.isPendingRequest(this._requestId)) {
  52849. this._manager.abortRequest(this._requestId);
  52850. }
  52851. this._close();
  52852. }
  52853. };
  52854. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52855. exports.PDFNetworkStream = PDFNetworkStream;
  52856. exports.NetworkManager = NetworkManager;
  52857. /***/ }),
  52858. /* 40 */
  52859. /***/ (function(module, exports, __w_pdfjs_require__) {
  52860. "use strict";
  52861. var sharedUtil = __w_pdfjs_require__(0);
  52862. var corePrimitives = __w_pdfjs_require__(1);
  52863. var coreFunction = __w_pdfjs_require__(7);
  52864. var coreColorSpace = __w_pdfjs_require__(4);
  52865. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52866. var MissingDataException = sharedUtil.MissingDataException;
  52867. var Util = sharedUtil.Util;
  52868. var assert = sharedUtil.assert;
  52869. var error = sharedUtil.error;
  52870. var info = sharedUtil.info;
  52871. var warn = sharedUtil.warn;
  52872. var isStream = corePrimitives.isStream;
  52873. var PDFFunction = coreFunction.PDFFunction;
  52874. var ColorSpace = coreColorSpace.ColorSpace;
  52875. var ShadingType = {
  52876. FUNCTION_BASED: 1,
  52877. AXIAL: 2,
  52878. RADIAL: 3,
  52879. FREE_FORM_MESH: 4,
  52880. LATTICE_FORM_MESH: 5,
  52881. COONS_PATCH_MESH: 6,
  52882. TENSOR_PATCH_MESH: 7
  52883. };
  52884. var Pattern = function PatternClosure() {
  52885. function Pattern() {
  52886. error('should not call Pattern constructor');
  52887. }
  52888. Pattern.prototype = {
  52889. getPattern: function Pattern_getPattern(ctx) {
  52890. error('Should not call Pattern.getStyle: ' + ctx);
  52891. }
  52892. };
  52893. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52894. var dict = isStream(shading) ? shading.dict : shading;
  52895. var type = dict.get('ShadingType');
  52896. try {
  52897. switch (type) {
  52898. case ShadingType.AXIAL:
  52899. case ShadingType.RADIAL:
  52900. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52901. case ShadingType.FREE_FORM_MESH:
  52902. case ShadingType.LATTICE_FORM_MESH:
  52903. case ShadingType.COONS_PATCH_MESH:
  52904. case ShadingType.TENSOR_PATCH_MESH:
  52905. return new Shadings.Mesh(shading, matrix, xref, res);
  52906. default:
  52907. throw new Error('Unsupported ShadingType: ' + type);
  52908. }
  52909. } catch (ex) {
  52910. if (ex instanceof MissingDataException) {
  52911. throw ex;
  52912. }
  52913. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52914. warn(ex);
  52915. return new Shadings.Dummy();
  52916. }
  52917. };
  52918. return Pattern;
  52919. }();
  52920. var Shadings = {};
  52921. Shadings.SMALL_NUMBER = 1e-6;
  52922. Shadings.RadialAxial = function RadialAxialClosure() {
  52923. function RadialAxial(dict, matrix, xref, res) {
  52924. this.matrix = matrix;
  52925. this.coordsArr = dict.getArray('Coords');
  52926. this.shadingType = dict.get('ShadingType');
  52927. this.type = 'Pattern';
  52928. var cs = dict.get('ColorSpace', 'CS');
  52929. cs = ColorSpace.parse(cs, xref, res);
  52930. this.cs = cs;
  52931. var t0 = 0.0, t1 = 1.0;
  52932. if (dict.has('Domain')) {
  52933. var domainArr = dict.getArray('Domain');
  52934. t0 = domainArr[0];
  52935. t1 = domainArr[1];
  52936. }
  52937. var extendStart = false, extendEnd = false;
  52938. if (dict.has('Extend')) {
  52939. var extendArr = dict.getArray('Extend');
  52940. extendStart = extendArr[0];
  52941. extendEnd = extendArr[1];
  52942. }
  52943. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52944. var x1 = this.coordsArr[0];
  52945. var y1 = this.coordsArr[1];
  52946. var r1 = this.coordsArr[2];
  52947. var x2 = this.coordsArr[3];
  52948. var y2 = this.coordsArr[4];
  52949. var r2 = this.coordsArr[5];
  52950. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52951. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52952. warn('Unsupported radial gradient.');
  52953. }
  52954. }
  52955. this.extendStart = extendStart;
  52956. this.extendEnd = extendEnd;
  52957. var fnObj = dict.get('Function');
  52958. var fn = PDFFunction.parseArray(xref, fnObj);
  52959. var diff = t1 - t0;
  52960. var step = diff / 10;
  52961. var colorStops = this.colorStops = [];
  52962. if (t0 >= t1 || step <= 0) {
  52963. info('Bad shading domain.');
  52964. return;
  52965. }
  52966. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52967. var rgbColor;
  52968. for (var i = t0; i <= t1; i += step) {
  52969. ratio[0] = i;
  52970. fn(ratio, 0, color, 0);
  52971. rgbColor = cs.getRgb(color, 0);
  52972. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52973. colorStops.push([
  52974. (i - t0) / diff,
  52975. cssColor
  52976. ]);
  52977. }
  52978. var background = 'transparent';
  52979. if (dict.has('Background')) {
  52980. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52981. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52982. }
  52983. if (!extendStart) {
  52984. colorStops.unshift([
  52985. 0,
  52986. background
  52987. ]);
  52988. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52989. }
  52990. if (!extendEnd) {
  52991. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52992. colorStops.push([
  52993. 1,
  52994. background
  52995. ]);
  52996. }
  52997. this.colorStops = colorStops;
  52998. }
  52999. RadialAxial.prototype = {
  53000. getIR: function RadialAxial_getIR() {
  53001. var coordsArr = this.coordsArr;
  53002. var shadingType = this.shadingType;
  53003. var type, p0, p1, r0, r1;
  53004. if (shadingType === ShadingType.AXIAL) {
  53005. p0 = [
  53006. coordsArr[0],
  53007. coordsArr[1]
  53008. ];
  53009. p1 = [
  53010. coordsArr[2],
  53011. coordsArr[3]
  53012. ];
  53013. r0 = null;
  53014. r1 = null;
  53015. type = 'axial';
  53016. } else if (shadingType === ShadingType.RADIAL) {
  53017. p0 = [
  53018. coordsArr[0],
  53019. coordsArr[1]
  53020. ];
  53021. p1 = [
  53022. coordsArr[3],
  53023. coordsArr[4]
  53024. ];
  53025. r0 = coordsArr[2];
  53026. r1 = coordsArr[5];
  53027. type = 'radial';
  53028. } else {
  53029. error('getPattern type unknown: ' + shadingType);
  53030. }
  53031. var matrix = this.matrix;
  53032. if (matrix) {
  53033. p0 = Util.applyTransform(p0, matrix);
  53034. p1 = Util.applyTransform(p1, matrix);
  53035. if (shadingType === ShadingType.RADIAL) {
  53036. var scale = Util.singularValueDecompose2dScale(matrix);
  53037. r0 *= scale[0];
  53038. r1 *= scale[1];
  53039. }
  53040. }
  53041. return [
  53042. 'RadialAxial',
  53043. type,
  53044. this.colorStops,
  53045. p0,
  53046. p1,
  53047. r0,
  53048. r1
  53049. ];
  53050. }
  53051. };
  53052. return RadialAxial;
  53053. }();
  53054. Shadings.Mesh = function MeshClosure() {
  53055. function MeshStreamReader(stream, context) {
  53056. this.stream = stream;
  53057. this.context = context;
  53058. this.buffer = 0;
  53059. this.bufferLength = 0;
  53060. var numComps = context.numComps;
  53061. this.tmpCompsBuf = new Float32Array(numComps);
  53062. var csNumComps = context.colorSpace.numComps;
  53063. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53064. }
  53065. MeshStreamReader.prototype = {
  53066. get hasData() {
  53067. if (this.stream.end) {
  53068. return this.stream.pos < this.stream.end;
  53069. }
  53070. if (this.bufferLength > 0) {
  53071. return true;
  53072. }
  53073. var nextByte = this.stream.getByte();
  53074. if (nextByte < 0) {
  53075. return false;
  53076. }
  53077. this.buffer = nextByte;
  53078. this.bufferLength = 8;
  53079. return true;
  53080. },
  53081. readBits: function MeshStreamReader_readBits(n) {
  53082. var buffer = this.buffer;
  53083. var bufferLength = this.bufferLength;
  53084. if (n === 32) {
  53085. if (bufferLength === 0) {
  53086. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53087. }
  53088. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53089. var nextByte = this.stream.getByte();
  53090. this.buffer = nextByte & (1 << bufferLength) - 1;
  53091. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53092. }
  53093. if (n === 8 && bufferLength === 0) {
  53094. return this.stream.getByte();
  53095. }
  53096. while (bufferLength < n) {
  53097. buffer = buffer << 8 | this.stream.getByte();
  53098. bufferLength += 8;
  53099. }
  53100. bufferLength -= n;
  53101. this.bufferLength = bufferLength;
  53102. this.buffer = buffer & (1 << bufferLength) - 1;
  53103. return buffer >> bufferLength;
  53104. },
  53105. align: function MeshStreamReader_align() {
  53106. this.buffer = 0;
  53107. this.bufferLength = 0;
  53108. },
  53109. readFlag: function MeshStreamReader_readFlag() {
  53110. return this.readBits(this.context.bitsPerFlag);
  53111. },
  53112. readCoordinate: function MeshStreamReader_readCoordinate() {
  53113. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53114. var xi = this.readBits(bitsPerCoordinate);
  53115. var yi = this.readBits(bitsPerCoordinate);
  53116. var decode = this.context.decode;
  53117. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53118. return [
  53119. xi * scale * (decode[1] - decode[0]) + decode[0],
  53120. yi * scale * (decode[3] - decode[2]) + decode[2]
  53121. ];
  53122. },
  53123. readComponents: function MeshStreamReader_readComponents() {
  53124. var numComps = this.context.numComps;
  53125. var bitsPerComponent = this.context.bitsPerComponent;
  53126. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53127. var decode = this.context.decode;
  53128. var components = this.tmpCompsBuf;
  53129. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53130. var ci = this.readBits(bitsPerComponent);
  53131. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53132. }
  53133. var color = this.tmpCsCompsBuf;
  53134. if (this.context.colorFn) {
  53135. this.context.colorFn(components, 0, color, 0);
  53136. }
  53137. return this.context.colorSpace.getRgb(color, 0);
  53138. }
  53139. };
  53140. function decodeType4Shading(mesh, reader) {
  53141. var coords = mesh.coords;
  53142. var colors = mesh.colors;
  53143. var operators = [];
  53144. var ps = [];
  53145. var verticesLeft = 0;
  53146. while (reader.hasData) {
  53147. var f = reader.readFlag();
  53148. var coord = reader.readCoordinate();
  53149. var color = reader.readComponents();
  53150. if (verticesLeft === 0) {
  53151. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53152. switch (f) {
  53153. case 0:
  53154. verticesLeft = 3;
  53155. break;
  53156. case 1:
  53157. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53158. verticesLeft = 1;
  53159. break;
  53160. case 2:
  53161. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53162. verticesLeft = 1;
  53163. break;
  53164. }
  53165. operators.push(f);
  53166. }
  53167. ps.push(coords.length);
  53168. coords.push(coord);
  53169. colors.push(color);
  53170. verticesLeft--;
  53171. reader.align();
  53172. }
  53173. mesh.figures.push({
  53174. type: 'triangles',
  53175. coords: new Int32Array(ps),
  53176. colors: new Int32Array(ps)
  53177. });
  53178. }
  53179. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53180. var coords = mesh.coords;
  53181. var colors = mesh.colors;
  53182. var ps = [];
  53183. while (reader.hasData) {
  53184. var coord = reader.readCoordinate();
  53185. var color = reader.readComponents();
  53186. ps.push(coords.length);
  53187. coords.push(coord);
  53188. colors.push(color);
  53189. }
  53190. mesh.figures.push({
  53191. type: 'lattice',
  53192. coords: new Int32Array(ps),
  53193. colors: new Int32Array(ps),
  53194. verticesPerRow: verticesPerRow
  53195. });
  53196. }
  53197. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53198. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53199. var TRIANGLE_DENSITY = 20;
  53200. var getB = function getBClosure() {
  53201. function buildB(count) {
  53202. var lut = [];
  53203. for (var i = 0; i <= count; i++) {
  53204. var t = i / count, t_ = 1 - t;
  53205. lut.push(new Float32Array([
  53206. t_ * t_ * t_,
  53207. 3 * t * t_ * t_,
  53208. 3 * t * t * t_,
  53209. t * t * t
  53210. ]));
  53211. }
  53212. return lut;
  53213. }
  53214. var cache = [];
  53215. return function getB(count) {
  53216. if (!cache[count]) {
  53217. cache[count] = buildB(count);
  53218. }
  53219. return cache[count];
  53220. };
  53221. }();
  53222. function buildFigureFromPatch(mesh, index) {
  53223. var figure = mesh.figures[index];
  53224. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53225. var coords = mesh.coords, colors = mesh.colors;
  53226. var pi = figure.coords;
  53227. var ci = figure.colors;
  53228. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53229. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53230. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53231. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53232. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53233. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53234. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53235. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53236. var verticesPerRow = splitXBy + 1;
  53237. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53238. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53239. var k = 0;
  53240. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53241. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53242. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53243. for (var row = 0; row <= splitYBy; row++) {
  53244. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53245. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53246. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53247. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53248. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53249. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53250. for (var col = 0; col <= splitXBy; col++, k++) {
  53251. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53252. continue;
  53253. }
  53254. var x = 0, y = 0;
  53255. var q = 0;
  53256. for (var i = 0; i <= 3; i++) {
  53257. for (var j = 0; j <= 3; j++, q++) {
  53258. var m = bRow[row][i] * bCol[col][j];
  53259. x += coords[pi[q]][0] * m;
  53260. y += coords[pi[q]][1] * m;
  53261. }
  53262. }
  53263. figureCoords[k] = coords.length;
  53264. coords.push([
  53265. x,
  53266. y
  53267. ]);
  53268. figureColors[k] = colors.length;
  53269. var newColor = new Uint8Array(3);
  53270. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53271. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53272. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53273. colors.push(newColor);
  53274. }
  53275. }
  53276. figureCoords[0] = pi[0];
  53277. figureColors[0] = ci[0];
  53278. figureCoords[splitXBy] = pi[3];
  53279. figureColors[splitXBy] = ci[1];
  53280. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53281. figureColors[verticesPerRow * splitYBy] = ci[2];
  53282. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53283. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53284. mesh.figures[index] = {
  53285. type: 'lattice',
  53286. coords: figureCoords,
  53287. colors: figureColors,
  53288. verticesPerRow: verticesPerRow
  53289. };
  53290. }
  53291. function decodeType6Shading(mesh, reader) {
  53292. var coords = mesh.coords;
  53293. var colors = mesh.colors;
  53294. var ps = new Int32Array(16);
  53295. var cs = new Int32Array(4);
  53296. while (reader.hasData) {
  53297. var f = reader.readFlag();
  53298. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53299. var i, ii;
  53300. var pi = coords.length;
  53301. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53302. coords.push(reader.readCoordinate());
  53303. }
  53304. var ci = colors.length;
  53305. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53306. colors.push(reader.readComponents());
  53307. }
  53308. var tmp1, tmp2, tmp3, tmp4;
  53309. switch (f) {
  53310. case 0:
  53311. ps[12] = pi + 3;
  53312. ps[13] = pi + 4;
  53313. ps[14] = pi + 5;
  53314. ps[15] = pi + 6;
  53315. ps[8] = pi + 2;
  53316. ps[11] = pi + 7;
  53317. ps[4] = pi + 1;
  53318. ps[7] = pi + 8;
  53319. ps[0] = pi;
  53320. ps[1] = pi + 11;
  53321. ps[2] = pi + 10;
  53322. ps[3] = pi + 9;
  53323. cs[2] = ci + 1;
  53324. cs[3] = ci + 2;
  53325. cs[0] = ci;
  53326. cs[1] = ci + 3;
  53327. break;
  53328. case 1:
  53329. tmp1 = ps[12];
  53330. tmp2 = ps[13];
  53331. tmp3 = ps[14];
  53332. tmp4 = ps[15];
  53333. ps[12] = tmp4;
  53334. ps[13] = pi + 0;
  53335. ps[14] = pi + 1;
  53336. ps[15] = pi + 2;
  53337. ps[8] = tmp3;
  53338. ps[11] = pi + 3;
  53339. ps[4] = tmp2;
  53340. ps[7] = pi + 4;
  53341. ps[0] = tmp1;
  53342. ps[1] = pi + 7;
  53343. ps[2] = pi + 6;
  53344. ps[3] = pi + 5;
  53345. tmp1 = cs[2];
  53346. tmp2 = cs[3];
  53347. cs[2] = tmp2;
  53348. cs[3] = ci;
  53349. cs[0] = tmp1;
  53350. cs[1] = ci + 1;
  53351. break;
  53352. case 2:
  53353. tmp1 = ps[15];
  53354. tmp2 = ps[11];
  53355. ps[12] = ps[3];
  53356. ps[13] = pi + 0;
  53357. ps[14] = pi + 1;
  53358. ps[15] = pi + 2;
  53359. ps[8] = ps[7];
  53360. ps[11] = pi + 3;
  53361. ps[4] = tmp2;
  53362. ps[7] = pi + 4;
  53363. ps[0] = tmp1;
  53364. ps[1] = pi + 7;
  53365. ps[2] = pi + 6;
  53366. ps[3] = pi + 5;
  53367. tmp1 = cs[3];
  53368. cs[2] = cs[1];
  53369. cs[3] = ci;
  53370. cs[0] = tmp1;
  53371. cs[1] = ci + 1;
  53372. break;
  53373. case 3:
  53374. ps[12] = ps[0];
  53375. ps[13] = pi + 0;
  53376. ps[14] = pi + 1;
  53377. ps[15] = pi + 2;
  53378. ps[8] = ps[1];
  53379. ps[11] = pi + 3;
  53380. ps[4] = ps[2];
  53381. ps[7] = pi + 4;
  53382. ps[0] = ps[3];
  53383. ps[1] = pi + 7;
  53384. ps[2] = pi + 6;
  53385. ps[3] = pi + 5;
  53386. cs[2] = cs[0];
  53387. cs[3] = ci;
  53388. cs[0] = cs[1];
  53389. cs[1] = ci + 1;
  53390. break;
  53391. }
  53392. ps[5] = coords.length;
  53393. coords.push([
  53394. (-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,
  53395. (-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
  53396. ]);
  53397. ps[6] = coords.length;
  53398. coords.push([
  53399. (-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,
  53400. (-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
  53401. ]);
  53402. ps[9] = coords.length;
  53403. coords.push([
  53404. (-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,
  53405. (-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
  53406. ]);
  53407. ps[10] = coords.length;
  53408. coords.push([
  53409. (-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,
  53410. (-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
  53411. ]);
  53412. mesh.figures.push({
  53413. type: 'patch',
  53414. coords: new Int32Array(ps),
  53415. colors: new Int32Array(cs)
  53416. });
  53417. }
  53418. }
  53419. function decodeType7Shading(mesh, reader) {
  53420. var coords = mesh.coords;
  53421. var colors = mesh.colors;
  53422. var ps = new Int32Array(16);
  53423. var cs = new Int32Array(4);
  53424. while (reader.hasData) {
  53425. var f = reader.readFlag();
  53426. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53427. var i, ii;
  53428. var pi = coords.length;
  53429. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53430. coords.push(reader.readCoordinate());
  53431. }
  53432. var ci = colors.length;
  53433. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53434. colors.push(reader.readComponents());
  53435. }
  53436. var tmp1, tmp2, tmp3, tmp4;
  53437. switch (f) {
  53438. case 0:
  53439. ps[12] = pi + 3;
  53440. ps[13] = pi + 4;
  53441. ps[14] = pi + 5;
  53442. ps[15] = pi + 6;
  53443. ps[8] = pi + 2;
  53444. ps[9] = pi + 13;
  53445. ps[10] = pi + 14;
  53446. ps[11] = pi + 7;
  53447. ps[4] = pi + 1;
  53448. ps[5] = pi + 12;
  53449. ps[6] = pi + 15;
  53450. ps[7] = pi + 8;
  53451. ps[0] = pi;
  53452. ps[1] = pi + 11;
  53453. ps[2] = pi + 10;
  53454. ps[3] = pi + 9;
  53455. cs[2] = ci + 1;
  53456. cs[3] = ci + 2;
  53457. cs[0] = ci;
  53458. cs[1] = ci + 3;
  53459. break;
  53460. case 1:
  53461. tmp1 = ps[12];
  53462. tmp2 = ps[13];
  53463. tmp3 = ps[14];
  53464. tmp4 = ps[15];
  53465. ps[12] = tmp4;
  53466. ps[13] = pi + 0;
  53467. ps[14] = pi + 1;
  53468. ps[15] = pi + 2;
  53469. ps[8] = tmp3;
  53470. ps[9] = pi + 9;
  53471. ps[10] = pi + 10;
  53472. ps[11] = pi + 3;
  53473. ps[4] = tmp2;
  53474. ps[5] = pi + 8;
  53475. ps[6] = pi + 11;
  53476. ps[7] = pi + 4;
  53477. ps[0] = tmp1;
  53478. ps[1] = pi + 7;
  53479. ps[2] = pi + 6;
  53480. ps[3] = pi + 5;
  53481. tmp1 = cs[2];
  53482. tmp2 = cs[3];
  53483. cs[2] = tmp2;
  53484. cs[3] = ci;
  53485. cs[0] = tmp1;
  53486. cs[1] = ci + 1;
  53487. break;
  53488. case 2:
  53489. tmp1 = ps[15];
  53490. tmp2 = ps[11];
  53491. ps[12] = ps[3];
  53492. ps[13] = pi + 0;
  53493. ps[14] = pi + 1;
  53494. ps[15] = pi + 2;
  53495. ps[8] = ps[7];
  53496. ps[9] = pi + 9;
  53497. ps[10] = pi + 10;
  53498. ps[11] = pi + 3;
  53499. ps[4] = tmp2;
  53500. ps[5] = pi + 8;
  53501. ps[6] = pi + 11;
  53502. ps[7] = pi + 4;
  53503. ps[0] = tmp1;
  53504. ps[1] = pi + 7;
  53505. ps[2] = pi + 6;
  53506. ps[3] = pi + 5;
  53507. tmp1 = cs[3];
  53508. cs[2] = cs[1];
  53509. cs[3] = ci;
  53510. cs[0] = tmp1;
  53511. cs[1] = ci + 1;
  53512. break;
  53513. case 3:
  53514. ps[12] = ps[0];
  53515. ps[13] = pi + 0;
  53516. ps[14] = pi + 1;
  53517. ps[15] = pi + 2;
  53518. ps[8] = ps[1];
  53519. ps[9] = pi + 9;
  53520. ps[10] = pi + 10;
  53521. ps[11] = pi + 3;
  53522. ps[4] = ps[2];
  53523. ps[5] = pi + 8;
  53524. ps[6] = pi + 11;
  53525. ps[7] = pi + 4;
  53526. ps[0] = ps[3];
  53527. ps[1] = pi + 7;
  53528. ps[2] = pi + 6;
  53529. ps[3] = pi + 5;
  53530. cs[2] = cs[0];
  53531. cs[3] = ci;
  53532. cs[0] = cs[1];
  53533. cs[1] = ci + 1;
  53534. break;
  53535. }
  53536. mesh.figures.push({
  53537. type: 'patch',
  53538. coords: new Int32Array(ps),
  53539. colors: new Int32Array(cs)
  53540. });
  53541. }
  53542. }
  53543. function updateBounds(mesh) {
  53544. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53545. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53546. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53547. minX = minX > x ? x : minX;
  53548. minY = minY > y ? y : minY;
  53549. maxX = maxX < x ? x : maxX;
  53550. maxY = maxY < y ? y : maxY;
  53551. }
  53552. mesh.bounds = [
  53553. minX,
  53554. minY,
  53555. maxX,
  53556. maxY
  53557. ];
  53558. }
  53559. function packData(mesh) {
  53560. var i, ii, j, jj;
  53561. var coords = mesh.coords;
  53562. var coordsPacked = new Float32Array(coords.length * 2);
  53563. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53564. var xy = coords[i];
  53565. coordsPacked[j++] = xy[0];
  53566. coordsPacked[j++] = xy[1];
  53567. }
  53568. mesh.coords = coordsPacked;
  53569. var colors = mesh.colors;
  53570. var colorsPacked = new Uint8Array(colors.length * 3);
  53571. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53572. var c = colors[i];
  53573. colorsPacked[j++] = c[0];
  53574. colorsPacked[j++] = c[1];
  53575. colorsPacked[j++] = c[2];
  53576. }
  53577. mesh.colors = colorsPacked;
  53578. var figures = mesh.figures;
  53579. for (i = 0, ii = figures.length; i < ii; i++) {
  53580. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53581. for (j = 0, jj = ps.length; j < jj; j++) {
  53582. ps[j] *= 2;
  53583. cs[j] *= 3;
  53584. }
  53585. }
  53586. }
  53587. function Mesh(stream, matrix, xref, res) {
  53588. assert(isStream(stream), 'Mesh data is not a stream');
  53589. var dict = stream.dict;
  53590. this.matrix = matrix;
  53591. this.shadingType = dict.get('ShadingType');
  53592. this.type = 'Pattern';
  53593. this.bbox = dict.getArray('BBox');
  53594. var cs = dict.get('ColorSpace', 'CS');
  53595. cs = ColorSpace.parse(cs, xref, res);
  53596. this.cs = cs;
  53597. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53598. var fnObj = dict.get('Function');
  53599. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53600. this.coords = [];
  53601. this.colors = [];
  53602. this.figures = [];
  53603. var decodeContext = {
  53604. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53605. bitsPerComponent: dict.get('BitsPerComponent'),
  53606. bitsPerFlag: dict.get('BitsPerFlag'),
  53607. decode: dict.getArray('Decode'),
  53608. colorFn: fn,
  53609. colorSpace: cs,
  53610. numComps: fn ? 1 : cs.numComps
  53611. };
  53612. var reader = new MeshStreamReader(stream, decodeContext);
  53613. var patchMesh = false;
  53614. switch (this.shadingType) {
  53615. case ShadingType.FREE_FORM_MESH:
  53616. decodeType4Shading(this, reader);
  53617. break;
  53618. case ShadingType.LATTICE_FORM_MESH:
  53619. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53620. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53621. decodeType5Shading(this, reader, verticesPerRow);
  53622. break;
  53623. case ShadingType.COONS_PATCH_MESH:
  53624. decodeType6Shading(this, reader);
  53625. patchMesh = true;
  53626. break;
  53627. case ShadingType.TENSOR_PATCH_MESH:
  53628. decodeType7Shading(this, reader);
  53629. patchMesh = true;
  53630. break;
  53631. default:
  53632. error('Unsupported mesh type.');
  53633. break;
  53634. }
  53635. if (patchMesh) {
  53636. updateBounds(this);
  53637. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53638. buildFigureFromPatch(this, i);
  53639. }
  53640. }
  53641. updateBounds(this);
  53642. packData(this);
  53643. }
  53644. Mesh.prototype = {
  53645. getIR: function Mesh_getIR() {
  53646. return [
  53647. 'Mesh',
  53648. this.shadingType,
  53649. this.coords,
  53650. this.colors,
  53651. this.figures,
  53652. this.bounds,
  53653. this.matrix,
  53654. this.bbox,
  53655. this.background
  53656. ];
  53657. }
  53658. };
  53659. return Mesh;
  53660. }();
  53661. Shadings.Dummy = function DummyClosure() {
  53662. function Dummy() {
  53663. this.type = 'Pattern';
  53664. }
  53665. Dummy.prototype = {
  53666. getIR: function Dummy_getIR() {
  53667. return ['Dummy'];
  53668. }
  53669. };
  53670. return Dummy;
  53671. }();
  53672. function getTilingPatternIR(operatorList, dict, args) {
  53673. var matrix = dict.getArray('Matrix');
  53674. var bbox = dict.getArray('BBox');
  53675. var xstep = dict.get('XStep');
  53676. var ystep = dict.get('YStep');
  53677. var paintType = dict.get('PaintType');
  53678. var tilingType = dict.get('TilingType');
  53679. return [
  53680. 'TilingPattern',
  53681. args,
  53682. operatorList,
  53683. matrix,
  53684. bbox,
  53685. xstep,
  53686. ystep,
  53687. paintType,
  53688. tilingType
  53689. ];
  53690. }
  53691. exports.Pattern = Pattern;
  53692. exports.getTilingPatternIR = getTilingPatternIR;
  53693. /***/ }),
  53694. /* 41 */
  53695. /***/ (function(module, exports, __w_pdfjs_require__) {
  53696. "use strict";
  53697. var sharedUtil = __w_pdfjs_require__(0);
  53698. var coreStream = __w_pdfjs_require__(2);
  53699. var coreChunkedStream = __w_pdfjs_require__(15);
  53700. var coreDocument = __w_pdfjs_require__(31);
  53701. var warn = sharedUtil.warn;
  53702. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53703. var shadow = sharedUtil.shadow;
  53704. var NotImplementedException = sharedUtil.NotImplementedException;
  53705. var MissingDataException = sharedUtil.MissingDataException;
  53706. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53707. var Util = sharedUtil.Util;
  53708. var Stream = coreStream.Stream;
  53709. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53710. var PDFDocument = coreDocument.PDFDocument;
  53711. var BasePdfManager = function BasePdfManagerClosure() {
  53712. function BasePdfManager() {
  53713. throw new Error('Cannot initialize BaseManagerManager');
  53714. }
  53715. BasePdfManager.prototype = {
  53716. get docId() {
  53717. return this._docId;
  53718. },
  53719. get password() {
  53720. return this._password;
  53721. },
  53722. get docBaseUrl() {
  53723. var docBaseUrl = null;
  53724. if (this._docBaseUrl) {
  53725. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53726. if (absoluteUrl) {
  53727. docBaseUrl = absoluteUrl.href;
  53728. } else {
  53729. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53730. }
  53731. }
  53732. return shadow(this, 'docBaseUrl', docBaseUrl);
  53733. },
  53734. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53735. throw new NotImplementedException();
  53736. },
  53737. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53738. return this.ensure(this.pdfDocument, prop, args);
  53739. },
  53740. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53741. return this.ensure(this.pdfDocument.xref, prop, args);
  53742. },
  53743. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53744. return this.ensure(this.pdfDocument.catalog, prop, args);
  53745. },
  53746. getPage: function BasePdfManager_getPage(pageIndex) {
  53747. return this.pdfDocument.getPage(pageIndex);
  53748. },
  53749. cleanup: function BasePdfManager_cleanup() {
  53750. return this.pdfDocument.cleanup();
  53751. },
  53752. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53753. return new NotImplementedException();
  53754. },
  53755. requestRange: function BasePdfManager_requestRange(begin, end) {
  53756. return new NotImplementedException();
  53757. },
  53758. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53759. return new NotImplementedException();
  53760. },
  53761. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53762. return new NotImplementedException();
  53763. },
  53764. updatePassword: function BasePdfManager_updatePassword(password) {
  53765. this._password = password;
  53766. },
  53767. terminate: function BasePdfManager_terminate() {
  53768. return new NotImplementedException();
  53769. }
  53770. };
  53771. return BasePdfManager;
  53772. }();
  53773. var LocalPdfManager = function LocalPdfManagerClosure() {
  53774. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53775. this._docId = docId;
  53776. this._password = password;
  53777. this._docBaseUrl = docBaseUrl;
  53778. this.evaluatorOptions = evaluatorOptions;
  53779. var stream = new Stream(data);
  53780. this.pdfDocument = new PDFDocument(this, stream);
  53781. this._loadedStreamCapability = createPromiseCapability();
  53782. this._loadedStreamCapability.resolve(stream);
  53783. }
  53784. Util.inherit(LocalPdfManager, BasePdfManager, {
  53785. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53786. return new Promise(function (resolve, reject) {
  53787. try {
  53788. var value = obj[prop];
  53789. var result;
  53790. if (typeof value === 'function') {
  53791. result = value.apply(obj, args);
  53792. } else {
  53793. result = value;
  53794. }
  53795. resolve(result);
  53796. } catch (e) {
  53797. reject(e);
  53798. }
  53799. });
  53800. },
  53801. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53802. return Promise.resolve();
  53803. },
  53804. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53805. },
  53806. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53807. return this._loadedStreamCapability.promise;
  53808. },
  53809. terminate: function LocalPdfManager_terminate() {
  53810. }
  53811. });
  53812. return LocalPdfManager;
  53813. }();
  53814. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53815. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53816. this._docId = docId;
  53817. this._password = args.password;
  53818. this._docBaseUrl = docBaseUrl;
  53819. this.msgHandler = args.msgHandler;
  53820. this.evaluatorOptions = evaluatorOptions;
  53821. var params = {
  53822. msgHandler: args.msgHandler,
  53823. url: args.url,
  53824. length: args.length,
  53825. disableAutoFetch: args.disableAutoFetch,
  53826. rangeChunkSize: args.rangeChunkSize
  53827. };
  53828. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53829. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53830. }
  53831. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53832. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53833. var pdfManager = this;
  53834. return new Promise(function (resolve, reject) {
  53835. function ensureHelper() {
  53836. try {
  53837. var result;
  53838. var value = obj[prop];
  53839. if (typeof value === 'function') {
  53840. result = value.apply(obj, args);
  53841. } else {
  53842. result = value;
  53843. }
  53844. resolve(result);
  53845. } catch (e) {
  53846. if (!(e instanceof MissingDataException)) {
  53847. reject(e);
  53848. return;
  53849. }
  53850. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53851. }
  53852. }
  53853. ensureHelper();
  53854. });
  53855. },
  53856. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53857. return this.streamManager.requestRange(begin, end);
  53858. },
  53859. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53860. this.streamManager.requestAllChunks();
  53861. },
  53862. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53863. this.streamManager.onReceiveData({ chunk: chunk });
  53864. },
  53865. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53866. return this.streamManager.onLoadedStream();
  53867. },
  53868. terminate: function NetworkPdfManager_terminate() {
  53869. this.streamManager.abort();
  53870. }
  53871. });
  53872. return NetworkPdfManager;
  53873. }();
  53874. exports.LocalPdfManager = LocalPdfManager;
  53875. exports.NetworkPdfManager = NetworkPdfManager;
  53876. /***/ }),
  53877. /* 42 */
  53878. /***/ (function(module, exports, __w_pdfjs_require__) {
  53879. "use strict";
  53880. var sharedUtil = __w_pdfjs_require__(0);
  53881. var corePrimitives = __w_pdfjs_require__(1);
  53882. var error = sharedUtil.error;
  53883. var isSpace = sharedUtil.isSpace;
  53884. var EOF = corePrimitives.EOF;
  53885. var PostScriptParser = function PostScriptParserClosure() {
  53886. function PostScriptParser(lexer) {
  53887. this.lexer = lexer;
  53888. this.operators = [];
  53889. this.token = null;
  53890. this.prev = null;
  53891. }
  53892. PostScriptParser.prototype = {
  53893. nextToken: function PostScriptParser_nextToken() {
  53894. this.prev = this.token;
  53895. this.token = this.lexer.getToken();
  53896. },
  53897. accept: function PostScriptParser_accept(type) {
  53898. if (this.token.type === type) {
  53899. this.nextToken();
  53900. return true;
  53901. }
  53902. return false;
  53903. },
  53904. expect: function PostScriptParser_expect(type) {
  53905. if (this.accept(type)) {
  53906. return true;
  53907. }
  53908. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53909. },
  53910. parse: function PostScriptParser_parse() {
  53911. this.nextToken();
  53912. this.expect(PostScriptTokenTypes.LBRACE);
  53913. this.parseBlock();
  53914. this.expect(PostScriptTokenTypes.RBRACE);
  53915. return this.operators;
  53916. },
  53917. parseBlock: function PostScriptParser_parseBlock() {
  53918. while (true) {
  53919. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53920. this.operators.push(this.prev.value);
  53921. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53922. this.operators.push(this.prev.value);
  53923. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53924. this.parseCondition();
  53925. } else {
  53926. return;
  53927. }
  53928. }
  53929. },
  53930. parseCondition: function PostScriptParser_parseCondition() {
  53931. var conditionLocation = this.operators.length;
  53932. this.operators.push(null, null);
  53933. this.parseBlock();
  53934. this.expect(PostScriptTokenTypes.RBRACE);
  53935. if (this.accept(PostScriptTokenTypes.IF)) {
  53936. this.operators[conditionLocation] = this.operators.length;
  53937. this.operators[conditionLocation + 1] = 'jz';
  53938. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53939. var jumpLocation = this.operators.length;
  53940. this.operators.push(null, null);
  53941. var endOfTrue = this.operators.length;
  53942. this.parseBlock();
  53943. this.expect(PostScriptTokenTypes.RBRACE);
  53944. this.expect(PostScriptTokenTypes.IFELSE);
  53945. this.operators[jumpLocation] = this.operators.length;
  53946. this.operators[jumpLocation + 1] = 'j';
  53947. this.operators[conditionLocation] = endOfTrue;
  53948. this.operators[conditionLocation + 1] = 'jz';
  53949. } else {
  53950. error('PS Function: error parsing conditional.');
  53951. }
  53952. }
  53953. };
  53954. return PostScriptParser;
  53955. }();
  53956. var PostScriptTokenTypes = {
  53957. LBRACE: 0,
  53958. RBRACE: 1,
  53959. NUMBER: 2,
  53960. OPERATOR: 3,
  53961. IF: 4,
  53962. IFELSE: 5
  53963. };
  53964. var PostScriptToken = function PostScriptTokenClosure() {
  53965. function PostScriptToken(type, value) {
  53966. this.type = type;
  53967. this.value = value;
  53968. }
  53969. var opCache = Object.create(null);
  53970. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53971. var opValue = opCache[op];
  53972. if (opValue) {
  53973. return opValue;
  53974. }
  53975. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53976. };
  53977. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53978. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53979. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53980. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53981. return PostScriptToken;
  53982. }();
  53983. var PostScriptLexer = function PostScriptLexerClosure() {
  53984. function PostScriptLexer(stream) {
  53985. this.stream = stream;
  53986. this.nextChar();
  53987. this.strBuf = [];
  53988. }
  53989. PostScriptLexer.prototype = {
  53990. nextChar: function PostScriptLexer_nextChar() {
  53991. return this.currentChar = this.stream.getByte();
  53992. },
  53993. getToken: function PostScriptLexer_getToken() {
  53994. var comment = false;
  53995. var ch = this.currentChar;
  53996. while (true) {
  53997. if (ch < 0) {
  53998. return EOF;
  53999. }
  54000. if (comment) {
  54001. if (ch === 0x0A || ch === 0x0D) {
  54002. comment = false;
  54003. }
  54004. } else if (ch === 0x25) {
  54005. comment = true;
  54006. } else if (!isSpace(ch)) {
  54007. break;
  54008. }
  54009. ch = this.nextChar();
  54010. }
  54011. switch (ch | 0) {
  54012. case 0x30:
  54013. case 0x31:
  54014. case 0x32:
  54015. case 0x33:
  54016. case 0x34:
  54017. case 0x35:
  54018. case 0x36:
  54019. case 0x37:
  54020. case 0x38:
  54021. case 0x39:
  54022. case 0x2B:
  54023. case 0x2D:
  54024. case 0x2E:
  54025. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  54026. case 0x7B:
  54027. this.nextChar();
  54028. return PostScriptToken.LBRACE;
  54029. case 0x7D:
  54030. this.nextChar();
  54031. return PostScriptToken.RBRACE;
  54032. }
  54033. var strBuf = this.strBuf;
  54034. strBuf.length = 0;
  54035. strBuf[0] = String.fromCharCode(ch);
  54036. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  54037. strBuf.push(String.fromCharCode(ch));
  54038. }
  54039. var str = strBuf.join('');
  54040. switch (str.toLowerCase()) {
  54041. case 'if':
  54042. return PostScriptToken.IF;
  54043. case 'ifelse':
  54044. return PostScriptToken.IFELSE;
  54045. default:
  54046. return PostScriptToken.getOperator(str);
  54047. }
  54048. },
  54049. getNumber: function PostScriptLexer_getNumber() {
  54050. var ch = this.currentChar;
  54051. var strBuf = this.strBuf;
  54052. strBuf.length = 0;
  54053. strBuf[0] = String.fromCharCode(ch);
  54054. while ((ch = this.nextChar()) >= 0) {
  54055. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54056. strBuf.push(String.fromCharCode(ch));
  54057. } else {
  54058. break;
  54059. }
  54060. }
  54061. var value = parseFloat(strBuf.join(''));
  54062. if (isNaN(value)) {
  54063. error('Invalid floating point number: ' + value);
  54064. }
  54065. return value;
  54066. }
  54067. };
  54068. return PostScriptLexer;
  54069. }();
  54070. exports.PostScriptLexer = PostScriptLexer;
  54071. exports.PostScriptParser = PostScriptParser;
  54072. /***/ }),
  54073. /* 43 */
  54074. /***/ (function(module, exports, __w_pdfjs_require__) {
  54075. "use strict";
  54076. var sharedUtil = __w_pdfjs_require__(0);
  54077. var coreStream = __w_pdfjs_require__(2);
  54078. var coreEncodings = __w_pdfjs_require__(5);
  54079. var warn = sharedUtil.warn;
  54080. var isSpace = sharedUtil.isSpace;
  54081. var Stream = coreStream.Stream;
  54082. var getEncoding = coreEncodings.getEncoding;
  54083. var HINTING_ENABLED = false;
  54084. var Type1CharString = function Type1CharStringClosure() {
  54085. var COMMAND_MAP = {
  54086. 'hstem': [1],
  54087. 'vstem': [3],
  54088. 'vmoveto': [4],
  54089. 'rlineto': [5],
  54090. 'hlineto': [6],
  54091. 'vlineto': [7],
  54092. 'rrcurveto': [8],
  54093. 'callsubr': [10],
  54094. 'flex': [
  54095. 12,
  54096. 35
  54097. ],
  54098. 'drop': [
  54099. 12,
  54100. 18
  54101. ],
  54102. 'endchar': [14],
  54103. 'rmoveto': [21],
  54104. 'hmoveto': [22],
  54105. 'vhcurveto': [30],
  54106. 'hvcurveto': [31]
  54107. };
  54108. function Type1CharString() {
  54109. this.width = 0;
  54110. this.lsb = 0;
  54111. this.flexing = false;
  54112. this.output = [];
  54113. this.stack = [];
  54114. }
  54115. Type1CharString.prototype = {
  54116. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54117. var count = encoded.length;
  54118. var error = false;
  54119. var wx, sbx, subrNumber;
  54120. for (var i = 0; i < count; i++) {
  54121. var value = encoded[i];
  54122. if (value < 32) {
  54123. if (value === 12) {
  54124. value = (value << 8) + encoded[++i];
  54125. }
  54126. switch (value) {
  54127. case 1:
  54128. if (!HINTING_ENABLED) {
  54129. this.stack = [];
  54130. break;
  54131. }
  54132. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54133. break;
  54134. case 3:
  54135. if (!HINTING_ENABLED) {
  54136. this.stack = [];
  54137. break;
  54138. }
  54139. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54140. break;
  54141. case 4:
  54142. if (this.flexing) {
  54143. if (this.stack.length < 1) {
  54144. error = true;
  54145. break;
  54146. }
  54147. var dy = this.stack.pop();
  54148. this.stack.push(0, dy);
  54149. break;
  54150. }
  54151. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54152. break;
  54153. case 5:
  54154. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54155. break;
  54156. case 6:
  54157. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54158. break;
  54159. case 7:
  54160. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54161. break;
  54162. case 8:
  54163. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54164. break;
  54165. case 9:
  54166. this.stack = [];
  54167. break;
  54168. case 10:
  54169. if (this.stack.length < 1) {
  54170. error = true;
  54171. break;
  54172. }
  54173. subrNumber = this.stack.pop();
  54174. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54175. break;
  54176. case 11:
  54177. return error;
  54178. case 13:
  54179. if (this.stack.length < 2) {
  54180. error = true;
  54181. break;
  54182. }
  54183. wx = this.stack.pop();
  54184. sbx = this.stack.pop();
  54185. this.lsb = sbx;
  54186. this.width = wx;
  54187. this.stack.push(wx, sbx);
  54188. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54189. break;
  54190. case 14:
  54191. this.output.push(COMMAND_MAP.endchar[0]);
  54192. break;
  54193. case 21:
  54194. if (this.flexing) {
  54195. break;
  54196. }
  54197. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54198. break;
  54199. case 22:
  54200. if (this.flexing) {
  54201. this.stack.push(0);
  54202. break;
  54203. }
  54204. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54205. break;
  54206. case 30:
  54207. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54208. break;
  54209. case 31:
  54210. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54211. break;
  54212. case (12 << 8) + 0:
  54213. this.stack = [];
  54214. break;
  54215. case (12 << 8) + 1:
  54216. if (!HINTING_ENABLED) {
  54217. this.stack = [];
  54218. break;
  54219. }
  54220. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54221. break;
  54222. case (12 << 8) + 2:
  54223. if (!HINTING_ENABLED) {
  54224. this.stack = [];
  54225. break;
  54226. }
  54227. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54228. break;
  54229. case (12 << 8) + 6:
  54230. if (seacAnalysisEnabled) {
  54231. this.seac = this.stack.splice(-4, 4);
  54232. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54233. } else {
  54234. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54235. }
  54236. break;
  54237. case (12 << 8) + 7:
  54238. if (this.stack.length < 4) {
  54239. error = true;
  54240. break;
  54241. }
  54242. this.stack.pop();
  54243. wx = this.stack.pop();
  54244. var sby = this.stack.pop();
  54245. sbx = this.stack.pop();
  54246. this.lsb = sbx;
  54247. this.width = wx;
  54248. this.stack.push(wx, sbx, sby);
  54249. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54250. break;
  54251. case (12 << 8) + 12:
  54252. if (this.stack.length < 2) {
  54253. error = true;
  54254. break;
  54255. }
  54256. var num2 = this.stack.pop();
  54257. var num1 = this.stack.pop();
  54258. this.stack.push(num1 / num2);
  54259. break;
  54260. case (12 << 8) + 16:
  54261. if (this.stack.length < 2) {
  54262. error = true;
  54263. break;
  54264. }
  54265. subrNumber = this.stack.pop();
  54266. var numArgs = this.stack.pop();
  54267. if (subrNumber === 0 && numArgs === 3) {
  54268. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54269. 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]);
  54270. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54271. this.flexing = false;
  54272. this.stack.push(flexArgs[15], flexArgs[16]);
  54273. } else if (subrNumber === 1 && numArgs === 0) {
  54274. this.flexing = true;
  54275. }
  54276. break;
  54277. case (12 << 8) + 17:
  54278. break;
  54279. case (12 << 8) + 33:
  54280. this.stack = [];
  54281. break;
  54282. default:
  54283. warn('Unknown type 1 charstring command of "' + value + '"');
  54284. break;
  54285. }
  54286. if (error) {
  54287. break;
  54288. }
  54289. continue;
  54290. } else if (value <= 246) {
  54291. value = value - 139;
  54292. } else if (value <= 250) {
  54293. value = (value - 247) * 256 + encoded[++i] + 108;
  54294. } else if (value <= 254) {
  54295. value = -((value - 251) * 256) - encoded[++i] - 108;
  54296. } else {
  54297. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54298. }
  54299. this.stack.push(value);
  54300. }
  54301. return error;
  54302. },
  54303. executeCommand: function (howManyArgs, command, keepStack) {
  54304. var stackLength = this.stack.length;
  54305. if (howManyArgs > stackLength) {
  54306. return true;
  54307. }
  54308. var start = stackLength - howManyArgs;
  54309. for (var i = start; i < stackLength; i++) {
  54310. var value = this.stack[i];
  54311. if (value === (value | 0)) {
  54312. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54313. } else {
  54314. value = 65536 * value | 0;
  54315. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54316. }
  54317. }
  54318. this.output.push.apply(this.output, command);
  54319. if (keepStack) {
  54320. this.stack.splice(start, howManyArgs);
  54321. } else {
  54322. this.stack.length = 0;
  54323. }
  54324. return false;
  54325. }
  54326. };
  54327. return Type1CharString;
  54328. }();
  54329. var Type1Parser = function Type1ParserClosure() {
  54330. var EEXEC_ENCRYPT_KEY = 55665;
  54331. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54332. function isHexDigit(code) {
  54333. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54334. }
  54335. function decrypt(data, key, discardNumber) {
  54336. if (discardNumber >= data.length) {
  54337. return new Uint8Array(0);
  54338. }
  54339. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54340. for (i = 0; i < discardNumber; i++) {
  54341. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54342. }
  54343. var count = data.length - discardNumber;
  54344. var decrypted = new Uint8Array(count);
  54345. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54346. var value = data[i];
  54347. decrypted[j] = value ^ r >> 8;
  54348. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54349. }
  54350. return decrypted;
  54351. }
  54352. function decryptAscii(data, key, discardNumber) {
  54353. var r = key | 0, c1 = 52845, c2 = 22719;
  54354. var count = data.length, maybeLength = count >>> 1;
  54355. var decrypted = new Uint8Array(maybeLength);
  54356. var i, j;
  54357. for (i = 0, j = 0; i < count; i++) {
  54358. var digit1 = data[i];
  54359. if (!isHexDigit(digit1)) {
  54360. continue;
  54361. }
  54362. i++;
  54363. var digit2;
  54364. while (i < count && !isHexDigit(digit2 = data[i])) {
  54365. i++;
  54366. }
  54367. if (i < count) {
  54368. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54369. decrypted[j++] = value ^ r >> 8;
  54370. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54371. }
  54372. }
  54373. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54374. }
  54375. function isSpecial(c) {
  54376. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54377. }
  54378. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54379. if (encrypted) {
  54380. var data = stream.getBytes();
  54381. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54382. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54383. }
  54384. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54385. this.stream = stream;
  54386. this.nextChar();
  54387. }
  54388. Type1Parser.prototype = {
  54389. readNumberArray: function Type1Parser_readNumberArray() {
  54390. this.getToken();
  54391. var array = [];
  54392. while (true) {
  54393. var token = this.getToken();
  54394. if (token === null || token === ']' || token === '}') {
  54395. break;
  54396. }
  54397. array.push(parseFloat(token || 0));
  54398. }
  54399. return array;
  54400. },
  54401. readNumber: function Type1Parser_readNumber() {
  54402. var token = this.getToken();
  54403. return parseFloat(token || 0);
  54404. },
  54405. readInt: function Type1Parser_readInt() {
  54406. var token = this.getToken();
  54407. return parseInt(token || 0, 10) | 0;
  54408. },
  54409. readBoolean: function Type1Parser_readBoolean() {
  54410. var token = this.getToken();
  54411. return token === 'true' ? 1 : 0;
  54412. },
  54413. nextChar: function Type1_nextChar() {
  54414. return this.currentChar = this.stream.getByte();
  54415. },
  54416. getToken: function Type1Parser_getToken() {
  54417. var comment = false;
  54418. var ch = this.currentChar;
  54419. while (true) {
  54420. if (ch === -1) {
  54421. return null;
  54422. }
  54423. if (comment) {
  54424. if (ch === 0x0A || ch === 0x0D) {
  54425. comment = false;
  54426. }
  54427. } else if (ch === 0x25) {
  54428. comment = true;
  54429. } else if (!isSpace(ch)) {
  54430. break;
  54431. }
  54432. ch = this.nextChar();
  54433. }
  54434. if (isSpecial(ch)) {
  54435. this.nextChar();
  54436. return String.fromCharCode(ch);
  54437. }
  54438. var token = '';
  54439. do {
  54440. token += String.fromCharCode(ch);
  54441. ch = this.nextChar();
  54442. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54443. return token;
  54444. },
  54445. extractFontProgram: function Type1Parser_extractFontProgram() {
  54446. var stream = this.stream;
  54447. var subrs = [], charstrings = [];
  54448. var privateData = Object.create(null);
  54449. privateData['lenIV'] = 4;
  54450. var program = {
  54451. subrs: [],
  54452. charstrings: [],
  54453. properties: { 'privateData': privateData }
  54454. };
  54455. var token, length, data, lenIV, encoded;
  54456. while ((token = this.getToken()) !== null) {
  54457. if (token !== '/') {
  54458. continue;
  54459. }
  54460. token = this.getToken();
  54461. switch (token) {
  54462. case 'CharStrings':
  54463. this.getToken();
  54464. this.getToken();
  54465. this.getToken();
  54466. this.getToken();
  54467. while (true) {
  54468. token = this.getToken();
  54469. if (token === null || token === 'end') {
  54470. break;
  54471. }
  54472. if (token !== '/') {
  54473. continue;
  54474. }
  54475. var glyph = this.getToken();
  54476. length = this.readInt();
  54477. this.getToken();
  54478. data = stream.makeSubStream(stream.pos, length);
  54479. lenIV = program.properties.privateData['lenIV'];
  54480. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54481. stream.skip(length);
  54482. this.nextChar();
  54483. token = this.getToken();
  54484. if (token === 'noaccess') {
  54485. this.getToken();
  54486. }
  54487. charstrings.push({
  54488. glyph: glyph,
  54489. encoded: encoded
  54490. });
  54491. }
  54492. break;
  54493. case 'Subrs':
  54494. this.readInt();
  54495. this.getToken();
  54496. while ((token = this.getToken()) === 'dup') {
  54497. var index = this.readInt();
  54498. length = this.readInt();
  54499. this.getToken();
  54500. data = stream.makeSubStream(stream.pos, length);
  54501. lenIV = program.properties.privateData['lenIV'];
  54502. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54503. stream.skip(length);
  54504. this.nextChar();
  54505. token = this.getToken();
  54506. if (token === 'noaccess') {
  54507. this.getToken();
  54508. }
  54509. subrs[index] = encoded;
  54510. }
  54511. break;
  54512. case 'BlueValues':
  54513. case 'OtherBlues':
  54514. case 'FamilyBlues':
  54515. case 'FamilyOtherBlues':
  54516. var blueArray = this.readNumberArray();
  54517. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54518. program.properties.privateData[token] = blueArray;
  54519. }
  54520. break;
  54521. case 'StemSnapH':
  54522. case 'StemSnapV':
  54523. program.properties.privateData[token] = this.readNumberArray();
  54524. break;
  54525. case 'StdHW':
  54526. case 'StdVW':
  54527. program.properties.privateData[token] = this.readNumberArray()[0];
  54528. break;
  54529. case 'BlueShift':
  54530. case 'lenIV':
  54531. case 'BlueFuzz':
  54532. case 'BlueScale':
  54533. case 'LanguageGroup':
  54534. case 'ExpansionFactor':
  54535. program.properties.privateData[token] = this.readNumber();
  54536. break;
  54537. case 'ForceBold':
  54538. program.properties.privateData[token] = this.readBoolean();
  54539. break;
  54540. }
  54541. }
  54542. for (var i = 0; i < charstrings.length; i++) {
  54543. glyph = charstrings[i].glyph;
  54544. encoded = charstrings[i].encoded;
  54545. var charString = new Type1CharString();
  54546. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54547. var output = charString.output;
  54548. if (error) {
  54549. output = [14];
  54550. }
  54551. program.charstrings.push({
  54552. glyphName: glyph,
  54553. charstring: output,
  54554. width: charString.width,
  54555. lsb: charString.lsb,
  54556. seac: charString.seac
  54557. });
  54558. }
  54559. return program;
  54560. },
  54561. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54562. var token;
  54563. while ((token = this.getToken()) !== null) {
  54564. if (token !== '/') {
  54565. continue;
  54566. }
  54567. token = this.getToken();
  54568. switch (token) {
  54569. case 'FontMatrix':
  54570. var matrix = this.readNumberArray();
  54571. properties.fontMatrix = matrix;
  54572. break;
  54573. case 'Encoding':
  54574. var encodingArg = this.getToken();
  54575. var encoding;
  54576. if (!/^\d+$/.test(encodingArg)) {
  54577. encoding = getEncoding(encodingArg);
  54578. } else {
  54579. encoding = [];
  54580. var size = parseInt(encodingArg, 10) | 0;
  54581. this.getToken();
  54582. for (var j = 0; j < size; j++) {
  54583. token = this.getToken();
  54584. while (token !== 'dup' && token !== 'def') {
  54585. token = this.getToken();
  54586. if (token === null) {
  54587. return;
  54588. }
  54589. }
  54590. if (token === 'def') {
  54591. break;
  54592. }
  54593. var index = this.readInt();
  54594. this.getToken();
  54595. var glyph = this.getToken();
  54596. encoding[index] = glyph;
  54597. this.getToken();
  54598. }
  54599. }
  54600. properties.builtInEncoding = encoding;
  54601. break;
  54602. case 'FontBBox':
  54603. var fontBBox = this.readNumberArray();
  54604. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  54605. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  54606. properties.ascentScaled = true;
  54607. break;
  54608. }
  54609. }
  54610. }
  54611. };
  54612. return Type1Parser;
  54613. }();
  54614. exports.Type1Parser = Type1Parser;
  54615. /***/ }),
  54616. /* 44 */
  54617. /***/ (function(module, exports, __w_pdfjs_require__) {
  54618. "use strict";
  54619. var sharedUtil = __w_pdfjs_require__(0);
  54620. var displayDOMUtils = __w_pdfjs_require__(3);
  54621. var displayPatternHelper = __w_pdfjs_require__(46);
  54622. var displayWebGL = __w_pdfjs_require__(24);
  54623. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54624. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54625. var ImageKind = sharedUtil.ImageKind;
  54626. var OPS = sharedUtil.OPS;
  54627. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54628. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54629. var Util = sharedUtil.Util;
  54630. var assert = sharedUtil.assert;
  54631. var info = sharedUtil.info;
  54632. var isNum = sharedUtil.isNum;
  54633. var isArray = sharedUtil.isArray;
  54634. var isLittleEndian = sharedUtil.isLittleEndian;
  54635. var error = sharedUtil.error;
  54636. var shadow = sharedUtil.shadow;
  54637. var warn = sharedUtil.warn;
  54638. var TilingPattern = displayPatternHelper.TilingPattern;
  54639. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54640. var WebGLUtils = displayWebGL.WebGLUtils;
  54641. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54642. var MIN_FONT_SIZE = 16;
  54643. var MAX_FONT_SIZE = 100;
  54644. var MAX_GROUP_SIZE = 4096;
  54645. var MIN_WIDTH_FACTOR = 0.65;
  54646. var COMPILE_TYPE3_GLYPHS = true;
  54647. var MAX_SIZE_TO_COMPILE = 1000;
  54648. var FULL_CHUNK_HEIGHT = 16;
  54649. var HasCanvasTypedArraysCached = {
  54650. get value() {
  54651. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54652. }
  54653. };
  54654. var IsLittleEndianCached = {
  54655. get value() {
  54656. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54657. }
  54658. };
  54659. function addContextCurrentTransform(ctx) {
  54660. if (!ctx.mozCurrentTransform) {
  54661. ctx._originalSave = ctx.save;
  54662. ctx._originalRestore = ctx.restore;
  54663. ctx._originalRotate = ctx.rotate;
  54664. ctx._originalScale = ctx.scale;
  54665. ctx._originalTranslate = ctx.translate;
  54666. ctx._originalTransform = ctx.transform;
  54667. ctx._originalSetTransform = ctx.setTransform;
  54668. ctx._transformMatrix = ctx._transformMatrix || [
  54669. 1,
  54670. 0,
  54671. 0,
  54672. 1,
  54673. 0,
  54674. 0
  54675. ];
  54676. ctx._transformStack = [];
  54677. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54678. get: function getCurrentTransform() {
  54679. return this._transformMatrix;
  54680. }
  54681. });
  54682. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54683. get: function getCurrentTransformInverse() {
  54684. var m = this._transformMatrix;
  54685. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54686. var ad_bc = a * d - b * c;
  54687. var bc_ad = b * c - a * d;
  54688. return [
  54689. d / ad_bc,
  54690. b / bc_ad,
  54691. c / bc_ad,
  54692. a / ad_bc,
  54693. (d * e - c * f) / bc_ad,
  54694. (b * e - a * f) / ad_bc
  54695. ];
  54696. }
  54697. });
  54698. ctx.save = function ctxSave() {
  54699. var old = this._transformMatrix;
  54700. this._transformStack.push(old);
  54701. this._transformMatrix = old.slice(0, 6);
  54702. this._originalSave();
  54703. };
  54704. ctx.restore = function ctxRestore() {
  54705. var prev = this._transformStack.pop();
  54706. if (prev) {
  54707. this._transformMatrix = prev;
  54708. this._originalRestore();
  54709. }
  54710. };
  54711. ctx.translate = function ctxTranslate(x, y) {
  54712. var m = this._transformMatrix;
  54713. m[4] = m[0] * x + m[2] * y + m[4];
  54714. m[5] = m[1] * x + m[3] * y + m[5];
  54715. this._originalTranslate(x, y);
  54716. };
  54717. ctx.scale = function ctxScale(x, y) {
  54718. var m = this._transformMatrix;
  54719. m[0] = m[0] * x;
  54720. m[1] = m[1] * x;
  54721. m[2] = m[2] * y;
  54722. m[3] = m[3] * y;
  54723. this._originalScale(x, y);
  54724. };
  54725. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54726. var m = this._transformMatrix;
  54727. this._transformMatrix = [
  54728. m[0] * a + m[2] * b,
  54729. m[1] * a + m[3] * b,
  54730. m[0] * c + m[2] * d,
  54731. m[1] * c + m[3] * d,
  54732. m[0] * e + m[2] * f + m[4],
  54733. m[1] * e + m[3] * f + m[5]
  54734. ];
  54735. ctx._originalTransform(a, b, c, d, e, f);
  54736. };
  54737. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54738. this._transformMatrix = [
  54739. a,
  54740. b,
  54741. c,
  54742. d,
  54743. e,
  54744. f
  54745. ];
  54746. ctx._originalSetTransform(a, b, c, d, e, f);
  54747. };
  54748. ctx.rotate = function ctxRotate(angle) {
  54749. var cosValue = Math.cos(angle);
  54750. var sinValue = Math.sin(angle);
  54751. var m = this._transformMatrix;
  54752. this._transformMatrix = [
  54753. m[0] * cosValue + m[2] * sinValue,
  54754. m[1] * cosValue + m[3] * sinValue,
  54755. m[0] * -sinValue + m[2] * cosValue,
  54756. m[1] * -sinValue + m[3] * cosValue,
  54757. m[4],
  54758. m[5]
  54759. ];
  54760. this._originalRotate(angle);
  54761. };
  54762. }
  54763. }
  54764. var CachedCanvases = function CachedCanvasesClosure() {
  54765. function CachedCanvases(canvasFactory) {
  54766. this.canvasFactory = canvasFactory;
  54767. this.cache = Object.create(null);
  54768. }
  54769. CachedCanvases.prototype = {
  54770. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54771. var canvasEntry;
  54772. if (this.cache[id] !== undefined) {
  54773. canvasEntry = this.cache[id];
  54774. this.canvasFactory.reset(canvasEntry, width, height);
  54775. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54776. } else {
  54777. canvasEntry = this.canvasFactory.create(width, height);
  54778. this.cache[id] = canvasEntry;
  54779. }
  54780. if (trackTransform) {
  54781. addContextCurrentTransform(canvasEntry.context);
  54782. }
  54783. return canvasEntry;
  54784. },
  54785. clear: function () {
  54786. for (var id in this.cache) {
  54787. var canvasEntry = this.cache[id];
  54788. this.canvasFactory.destroy(canvasEntry);
  54789. delete this.cache[id];
  54790. }
  54791. }
  54792. };
  54793. return CachedCanvases;
  54794. }();
  54795. function compileType3Glyph(imgData) {
  54796. var POINT_TO_PROCESS_LIMIT = 1000;
  54797. var width = imgData.width, height = imgData.height;
  54798. var i, j, j0, width1 = width + 1;
  54799. var points = new Uint8Array(width1 * (height + 1));
  54800. var POINT_TYPES = new Uint8Array([
  54801. 0,
  54802. 2,
  54803. 4,
  54804. 0,
  54805. 1,
  54806. 0,
  54807. 5,
  54808. 4,
  54809. 8,
  54810. 10,
  54811. 0,
  54812. 8,
  54813. 0,
  54814. 2,
  54815. 1,
  54816. 0
  54817. ]);
  54818. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54819. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54820. for (i = 0, ii = data0.length; i < ii; i++) {
  54821. var mask = 128, elem = data0[i];
  54822. while (mask > 0) {
  54823. data[pos++] = elem & mask ? 0 : 255;
  54824. mask >>= 1;
  54825. }
  54826. }
  54827. var count = 0;
  54828. pos = 0;
  54829. if (data[pos] !== 0) {
  54830. points[0] = 1;
  54831. ++count;
  54832. }
  54833. for (j = 1; j < width; j++) {
  54834. if (data[pos] !== data[pos + 1]) {
  54835. points[j] = data[pos] ? 2 : 1;
  54836. ++count;
  54837. }
  54838. pos++;
  54839. }
  54840. if (data[pos] !== 0) {
  54841. points[j] = 2;
  54842. ++count;
  54843. }
  54844. for (i = 1; i < height; i++) {
  54845. pos = i * lineSize;
  54846. j0 = i * width1;
  54847. if (data[pos - lineSize] !== data[pos]) {
  54848. points[j0] = data[pos] ? 1 : 8;
  54849. ++count;
  54850. }
  54851. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54852. for (j = 1; j < width; j++) {
  54853. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54854. if (POINT_TYPES[sum]) {
  54855. points[j0 + j] = POINT_TYPES[sum];
  54856. ++count;
  54857. }
  54858. pos++;
  54859. }
  54860. if (data[pos - lineSize] !== data[pos]) {
  54861. points[j0 + j] = data[pos] ? 2 : 4;
  54862. ++count;
  54863. }
  54864. if (count > POINT_TO_PROCESS_LIMIT) {
  54865. return null;
  54866. }
  54867. }
  54868. pos = lineSize * (height - 1);
  54869. j0 = i * width1;
  54870. if (data[pos] !== 0) {
  54871. points[j0] = 8;
  54872. ++count;
  54873. }
  54874. for (j = 1; j < width; j++) {
  54875. if (data[pos] !== data[pos + 1]) {
  54876. points[j0 + j] = data[pos] ? 4 : 8;
  54877. ++count;
  54878. }
  54879. pos++;
  54880. }
  54881. if (data[pos] !== 0) {
  54882. points[j0 + j] = 4;
  54883. ++count;
  54884. }
  54885. if (count > POINT_TO_PROCESS_LIMIT) {
  54886. return null;
  54887. }
  54888. var steps = new Int32Array([
  54889. 0,
  54890. width1,
  54891. -1,
  54892. 0,
  54893. -width1,
  54894. 0,
  54895. 0,
  54896. 0,
  54897. 1
  54898. ]);
  54899. var outlines = [];
  54900. for (i = 0; count && i <= height; i++) {
  54901. var p = i * width1;
  54902. var end = p + width;
  54903. while (p < end && !points[p]) {
  54904. p++;
  54905. }
  54906. if (p === end) {
  54907. continue;
  54908. }
  54909. var coords = [
  54910. p % width1,
  54911. i
  54912. ];
  54913. var type = points[p], p0 = p, pp;
  54914. do {
  54915. var step = steps[type];
  54916. do {
  54917. p += step;
  54918. } while (!points[p]);
  54919. pp = points[p];
  54920. if (pp !== 5 && pp !== 10) {
  54921. type = pp;
  54922. points[p] = 0;
  54923. } else {
  54924. type = pp & 0x33 * type >> 4;
  54925. points[p] &= type >> 2 | type << 2;
  54926. }
  54927. coords.push(p % width1);
  54928. coords.push(p / width1 | 0);
  54929. --count;
  54930. } while (p0 !== p);
  54931. outlines.push(coords);
  54932. --i;
  54933. }
  54934. var drawOutline = function (c) {
  54935. c.save();
  54936. c.scale(1 / width, -1 / height);
  54937. c.translate(0, -height);
  54938. c.beginPath();
  54939. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54940. var o = outlines[i];
  54941. c.moveTo(o[0], o[1]);
  54942. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54943. c.lineTo(o[j], o[j + 1]);
  54944. }
  54945. }
  54946. c.fill();
  54947. c.beginPath();
  54948. c.restore();
  54949. };
  54950. return drawOutline;
  54951. }
  54952. var CanvasExtraState = function CanvasExtraStateClosure() {
  54953. function CanvasExtraState(old) {
  54954. this.alphaIsShape = false;
  54955. this.fontSize = 0;
  54956. this.fontSizeScale = 1;
  54957. this.textMatrix = IDENTITY_MATRIX;
  54958. this.textMatrixScale = 1;
  54959. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54960. this.leading = 0;
  54961. this.x = 0;
  54962. this.y = 0;
  54963. this.lineX = 0;
  54964. this.lineY = 0;
  54965. this.charSpacing = 0;
  54966. this.wordSpacing = 0;
  54967. this.textHScale = 1;
  54968. this.textRenderingMode = TextRenderingMode.FILL;
  54969. this.textRise = 0;
  54970. this.fillColor = '#000000';
  54971. this.strokeColor = '#000000';
  54972. this.patternFill = false;
  54973. this.fillAlpha = 1;
  54974. this.strokeAlpha = 1;
  54975. this.lineWidth = 1;
  54976. this.activeSMask = null;
  54977. this.resumeSMaskCtx = null;
  54978. this.old = old;
  54979. }
  54980. CanvasExtraState.prototype = {
  54981. clone: function CanvasExtraState_clone() {
  54982. return Object.create(this);
  54983. },
  54984. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54985. this.x = x;
  54986. this.y = y;
  54987. }
  54988. };
  54989. return CanvasExtraState;
  54990. }();
  54991. var CanvasGraphics = function CanvasGraphicsClosure() {
  54992. var EXECUTION_TIME = 15;
  54993. var EXECUTION_STEPS = 10;
  54994. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54995. this.ctx = canvasCtx;
  54996. this.current = new CanvasExtraState();
  54997. this.stateStack = [];
  54998. this.pendingClip = null;
  54999. this.pendingEOFill = false;
  55000. this.res = null;
  55001. this.xobjs = null;
  55002. this.commonObjs = commonObjs;
  55003. this.objs = objs;
  55004. this.canvasFactory = canvasFactory;
  55005. this.imageLayer = imageLayer;
  55006. this.groupStack = [];
  55007. this.processingType3 = null;
  55008. this.baseTransform = null;
  55009. this.baseTransformStack = [];
  55010. this.groupLevel = 0;
  55011. this.smaskStack = [];
  55012. this.smaskCounter = 0;
  55013. this.tempSMask = null;
  55014. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  55015. if (canvasCtx) {
  55016. addContextCurrentTransform(canvasCtx);
  55017. }
  55018. this.cachedGetSinglePixelWidth = null;
  55019. }
  55020. function putBinaryImageData(ctx, imgData) {
  55021. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  55022. ctx.putImageData(imgData, 0, 0);
  55023. return;
  55024. }
  55025. var height = imgData.height, width = imgData.width;
  55026. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55027. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55028. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55029. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55030. var srcPos = 0, destPos;
  55031. var src = imgData.data;
  55032. var dest = chunkImgData.data;
  55033. var i, j, thisChunkHeight, elemsInThisChunk;
  55034. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  55035. var srcLength = src.byteLength;
  55036. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  55037. var dest32DataLength = dest32.length;
  55038. var fullSrcDiff = width + 7 >> 3;
  55039. var white = 0xFFFFFFFF;
  55040. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  55041. for (i = 0; i < totalChunks; i++) {
  55042. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55043. destPos = 0;
  55044. for (j = 0; j < thisChunkHeight; j++) {
  55045. var srcDiff = srcLength - srcPos;
  55046. var k = 0;
  55047. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  55048. var kEndUnrolled = kEnd & ~7;
  55049. var mask = 0;
  55050. var srcByte = 0;
  55051. for (; k < kEndUnrolled; k += 8) {
  55052. srcByte = src[srcPos++];
  55053. dest32[destPos++] = srcByte & 128 ? white : black;
  55054. dest32[destPos++] = srcByte & 64 ? white : black;
  55055. dest32[destPos++] = srcByte & 32 ? white : black;
  55056. dest32[destPos++] = srcByte & 16 ? white : black;
  55057. dest32[destPos++] = srcByte & 8 ? white : black;
  55058. dest32[destPos++] = srcByte & 4 ? white : black;
  55059. dest32[destPos++] = srcByte & 2 ? white : black;
  55060. dest32[destPos++] = srcByte & 1 ? white : black;
  55061. }
  55062. for (; k < kEnd; k++) {
  55063. if (mask === 0) {
  55064. srcByte = src[srcPos++];
  55065. mask = 128;
  55066. }
  55067. dest32[destPos++] = srcByte & mask ? white : black;
  55068. mask >>= 1;
  55069. }
  55070. }
  55071. while (destPos < dest32DataLength) {
  55072. dest32[destPos++] = 0;
  55073. }
  55074. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55075. }
  55076. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55077. j = 0;
  55078. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55079. for (i = 0; i < fullChunks; i++) {
  55080. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55081. srcPos += elemsInThisChunk;
  55082. ctx.putImageData(chunkImgData, 0, j);
  55083. j += FULL_CHUNK_HEIGHT;
  55084. }
  55085. if (i < totalChunks) {
  55086. elemsInThisChunk = width * partialChunkHeight * 4;
  55087. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55088. ctx.putImageData(chunkImgData, 0, j);
  55089. }
  55090. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55091. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55092. elemsInThisChunk = width * thisChunkHeight;
  55093. for (i = 0; i < totalChunks; i++) {
  55094. if (i >= fullChunks) {
  55095. thisChunkHeight = partialChunkHeight;
  55096. elemsInThisChunk = width * thisChunkHeight;
  55097. }
  55098. destPos = 0;
  55099. for (j = elemsInThisChunk; j--;) {
  55100. dest[destPos++] = src[srcPos++];
  55101. dest[destPos++] = src[srcPos++];
  55102. dest[destPos++] = src[srcPos++];
  55103. dest[destPos++] = 255;
  55104. }
  55105. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55106. }
  55107. } else {
  55108. error('bad image kind: ' + imgData.kind);
  55109. }
  55110. }
  55111. function putBinaryImageMask(ctx, imgData) {
  55112. var height = imgData.height, width = imgData.width;
  55113. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55114. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55115. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55116. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55117. var srcPos = 0;
  55118. var src = imgData.data;
  55119. var dest = chunkImgData.data;
  55120. for (var i = 0; i < totalChunks; i++) {
  55121. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55122. var destPos = 3;
  55123. for (var j = 0; j < thisChunkHeight; j++) {
  55124. var mask = 0;
  55125. for (var k = 0; k < width; k++) {
  55126. if (!mask) {
  55127. var elem = src[srcPos++];
  55128. mask = 128;
  55129. }
  55130. dest[destPos] = elem & mask ? 0 : 255;
  55131. destPos += 4;
  55132. mask >>= 1;
  55133. }
  55134. }
  55135. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55136. }
  55137. }
  55138. function copyCtxState(sourceCtx, destCtx) {
  55139. var properties = [
  55140. 'strokeStyle',
  55141. 'fillStyle',
  55142. 'fillRule',
  55143. 'globalAlpha',
  55144. 'lineWidth',
  55145. 'lineCap',
  55146. 'lineJoin',
  55147. 'miterLimit',
  55148. 'globalCompositeOperation',
  55149. 'font'
  55150. ];
  55151. for (var i = 0, ii = properties.length; i < ii; i++) {
  55152. var property = properties[i];
  55153. if (sourceCtx[property] !== undefined) {
  55154. destCtx[property] = sourceCtx[property];
  55155. }
  55156. }
  55157. if (sourceCtx.setLineDash !== undefined) {
  55158. destCtx.setLineDash(sourceCtx.getLineDash());
  55159. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55160. }
  55161. }
  55162. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55163. var length = bytes.length;
  55164. for (var i = 3; i < length; i += 4) {
  55165. var alpha = bytes[i];
  55166. if (alpha === 0) {
  55167. bytes[i - 3] = r0;
  55168. bytes[i - 2] = g0;
  55169. bytes[i - 1] = b0;
  55170. } else if (alpha < 255) {
  55171. var alpha_ = 255 - alpha;
  55172. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55173. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55174. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55175. }
  55176. }
  55177. }
  55178. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55179. var length = maskData.length;
  55180. var scale = 1 / 255;
  55181. for (var i = 3; i < length; i += 4) {
  55182. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55183. layerData[i] = layerData[i] * alpha * scale | 0;
  55184. }
  55185. }
  55186. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55187. var length = maskData.length;
  55188. for (var i = 3; i < length; i += 4) {
  55189. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55190. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55191. }
  55192. }
  55193. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55194. var hasBackdrop = !!backdrop;
  55195. var r0 = hasBackdrop ? backdrop[0] : 0;
  55196. var g0 = hasBackdrop ? backdrop[1] : 0;
  55197. var b0 = hasBackdrop ? backdrop[2] : 0;
  55198. var composeFn;
  55199. if (subtype === 'Luminosity') {
  55200. composeFn = composeSMaskLuminosity;
  55201. } else {
  55202. composeFn = composeSMaskAlpha;
  55203. }
  55204. var PIXELS_TO_PROCESS = 1048576;
  55205. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55206. for (var row = 0; row < height; row += chunkSize) {
  55207. var chunkHeight = Math.min(chunkSize, height - row);
  55208. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55209. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55210. if (hasBackdrop) {
  55211. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55212. }
  55213. composeFn(maskData.data, layerData.data, transferMap);
  55214. maskCtx.putImageData(layerData, 0, row);
  55215. }
  55216. }
  55217. function composeSMask(ctx, smask, layerCtx) {
  55218. var mask = smask.canvas;
  55219. var maskCtx = smask.context;
  55220. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55221. var backdrop = smask.backdrop || null;
  55222. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55223. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55224. subtype: smask.subtype,
  55225. backdrop: backdrop
  55226. });
  55227. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55228. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55229. return;
  55230. }
  55231. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55232. ctx.drawImage(mask, 0, 0);
  55233. }
  55234. var LINE_CAP_STYLES = [
  55235. 'butt',
  55236. 'round',
  55237. 'square'
  55238. ];
  55239. var LINE_JOIN_STYLES = [
  55240. 'miter',
  55241. 'round',
  55242. 'bevel'
  55243. ];
  55244. var NORMAL_CLIP = {};
  55245. var EO_CLIP = {};
  55246. CanvasGraphics.prototype = {
  55247. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55248. var width = this.ctx.canvas.width;
  55249. var height = this.ctx.canvas.height;
  55250. this.ctx.save();
  55251. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55252. this.ctx.fillRect(0, 0, width, height);
  55253. this.ctx.restore();
  55254. if (transparency) {
  55255. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55256. this.compositeCtx = this.ctx;
  55257. this.transparentCanvas = transparentCanvas.canvas;
  55258. this.ctx = transparentCanvas.context;
  55259. this.ctx.save();
  55260. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55261. }
  55262. this.ctx.save();
  55263. if (transform) {
  55264. this.ctx.transform.apply(this.ctx, transform);
  55265. }
  55266. this.ctx.transform.apply(this.ctx, viewport.transform);
  55267. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55268. if (this.imageLayer) {
  55269. this.imageLayer.beginLayout();
  55270. }
  55271. },
  55272. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55273. var argsArray = operatorList.argsArray;
  55274. var fnArray = operatorList.fnArray;
  55275. var i = executionStartIdx || 0;
  55276. var argsArrayLen = argsArray.length;
  55277. if (argsArrayLen === i) {
  55278. return i;
  55279. }
  55280. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55281. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55282. var steps = 0;
  55283. var commonObjs = this.commonObjs;
  55284. var objs = this.objs;
  55285. var fnId;
  55286. while (true) {
  55287. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55288. stepper.breakIt(i, continueCallback);
  55289. return i;
  55290. }
  55291. fnId = fnArray[i];
  55292. if (fnId !== OPS.dependency) {
  55293. this[fnId].apply(this, argsArray[i]);
  55294. } else {
  55295. var deps = argsArray[i];
  55296. for (var n = 0, nn = deps.length; n < nn; n++) {
  55297. var depObjId = deps[n];
  55298. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55299. var objsPool = common ? commonObjs : objs;
  55300. if (!objsPool.isResolved(depObjId)) {
  55301. objsPool.get(depObjId, continueCallback);
  55302. return i;
  55303. }
  55304. }
  55305. }
  55306. i++;
  55307. if (i === argsArrayLen) {
  55308. return i;
  55309. }
  55310. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55311. if (Date.now() > endTime) {
  55312. continueCallback();
  55313. return i;
  55314. }
  55315. steps = 0;
  55316. }
  55317. }
  55318. },
  55319. endDrawing: function CanvasGraphics_endDrawing() {
  55320. if (this.current.activeSMask !== null) {
  55321. this.endSMaskGroup();
  55322. }
  55323. this.ctx.restore();
  55324. if (this.transparentCanvas) {
  55325. this.ctx = this.compositeCtx;
  55326. this.ctx.save();
  55327. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55328. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55329. this.ctx.restore();
  55330. this.transparentCanvas = null;
  55331. }
  55332. this.cachedCanvases.clear();
  55333. WebGLUtils.clear();
  55334. if (this.imageLayer) {
  55335. this.imageLayer.endLayout();
  55336. }
  55337. },
  55338. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55339. this.current.lineWidth = width;
  55340. this.ctx.lineWidth = width;
  55341. },
  55342. setLineCap: function CanvasGraphics_setLineCap(style) {
  55343. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55344. },
  55345. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55346. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55347. },
  55348. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55349. this.ctx.miterLimit = limit;
  55350. },
  55351. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55352. var ctx = this.ctx;
  55353. if (ctx.setLineDash !== undefined) {
  55354. ctx.setLineDash(dashArray);
  55355. ctx.lineDashOffset = dashPhase;
  55356. }
  55357. },
  55358. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55359. },
  55360. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55361. },
  55362. setGState: function CanvasGraphics_setGState(states) {
  55363. for (var i = 0, ii = states.length; i < ii; i++) {
  55364. var state = states[i];
  55365. var key = state[0];
  55366. var value = state[1];
  55367. switch (key) {
  55368. case 'LW':
  55369. this.setLineWidth(value);
  55370. break;
  55371. case 'LC':
  55372. this.setLineCap(value);
  55373. break;
  55374. case 'LJ':
  55375. this.setLineJoin(value);
  55376. break;
  55377. case 'ML':
  55378. this.setMiterLimit(value);
  55379. break;
  55380. case 'D':
  55381. this.setDash(value[0], value[1]);
  55382. break;
  55383. case 'RI':
  55384. this.setRenderingIntent(value);
  55385. break;
  55386. case 'FL':
  55387. this.setFlatness(value);
  55388. break;
  55389. case 'Font':
  55390. this.setFont(value[0], value[1]);
  55391. break;
  55392. case 'CA':
  55393. this.current.strokeAlpha = state[1];
  55394. break;
  55395. case 'ca':
  55396. this.current.fillAlpha = state[1];
  55397. this.ctx.globalAlpha = state[1];
  55398. break;
  55399. case 'BM':
  55400. if (value && value.name && value.name !== 'Normal') {
  55401. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55402. return '-' + c.toLowerCase();
  55403. }).substring(1);
  55404. this.ctx.globalCompositeOperation = mode;
  55405. if (this.ctx.globalCompositeOperation !== mode) {
  55406. warn('globalCompositeOperation "' + mode + '" is not supported');
  55407. }
  55408. } else {
  55409. this.ctx.globalCompositeOperation = 'source-over';
  55410. }
  55411. break;
  55412. case 'SMask':
  55413. if (this.current.activeSMask) {
  55414. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55415. this.suspendSMaskGroup();
  55416. } else {
  55417. this.endSMaskGroup();
  55418. }
  55419. }
  55420. this.current.activeSMask = value ? this.tempSMask : null;
  55421. if (this.current.activeSMask) {
  55422. this.beginSMaskGroup();
  55423. }
  55424. this.tempSMask = null;
  55425. break;
  55426. }
  55427. }
  55428. },
  55429. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55430. var activeSMask = this.current.activeSMask;
  55431. var drawnWidth = activeSMask.canvas.width;
  55432. var drawnHeight = activeSMask.canvas.height;
  55433. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55434. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55435. var currentCtx = this.ctx;
  55436. var currentTransform = currentCtx.mozCurrentTransform;
  55437. this.ctx.save();
  55438. var groupCtx = scratchCanvas.context;
  55439. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55440. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55441. groupCtx.transform.apply(groupCtx, currentTransform);
  55442. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55443. copyCtxState(currentCtx, groupCtx);
  55444. this.ctx = groupCtx;
  55445. this.setGState([
  55446. [
  55447. 'BM',
  55448. 'Normal'
  55449. ],
  55450. [
  55451. 'ca',
  55452. 1
  55453. ],
  55454. [
  55455. 'CA',
  55456. 1
  55457. ]
  55458. ]);
  55459. this.groupStack.push(currentCtx);
  55460. this.groupLevel++;
  55461. },
  55462. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55463. var groupCtx = this.ctx;
  55464. this.groupLevel--;
  55465. this.ctx = this.groupStack.pop();
  55466. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55467. this.ctx.restore();
  55468. this.ctx.save();
  55469. copyCtxState(groupCtx, this.ctx);
  55470. this.current.resumeSMaskCtx = groupCtx;
  55471. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55472. this.ctx.transform.apply(this.ctx, deltaTransform);
  55473. groupCtx.save();
  55474. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55475. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55476. groupCtx.restore();
  55477. },
  55478. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55479. var groupCtx = this.current.resumeSMaskCtx;
  55480. var currentCtx = this.ctx;
  55481. this.ctx = groupCtx;
  55482. this.groupStack.push(currentCtx);
  55483. this.groupLevel++;
  55484. },
  55485. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55486. var groupCtx = this.ctx;
  55487. this.groupLevel--;
  55488. this.ctx = this.groupStack.pop();
  55489. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55490. this.ctx.restore();
  55491. copyCtxState(groupCtx, this.ctx);
  55492. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55493. this.ctx.transform.apply(this.ctx, deltaTransform);
  55494. },
  55495. save: function CanvasGraphics_save() {
  55496. this.ctx.save();
  55497. var old = this.current;
  55498. this.stateStack.push(old);
  55499. this.current = old.clone();
  55500. this.current.resumeSMaskCtx = null;
  55501. },
  55502. restore: function CanvasGraphics_restore() {
  55503. if (this.current.resumeSMaskCtx) {
  55504. this.resumeSMaskGroup();
  55505. }
  55506. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55507. this.endSMaskGroup();
  55508. }
  55509. if (this.stateStack.length !== 0) {
  55510. this.current = this.stateStack.pop();
  55511. this.ctx.restore();
  55512. this.pendingClip = null;
  55513. this.cachedGetSinglePixelWidth = null;
  55514. }
  55515. },
  55516. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55517. this.ctx.transform(a, b, c, d, e, f);
  55518. this.cachedGetSinglePixelWidth = null;
  55519. },
  55520. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55521. var ctx = this.ctx;
  55522. var current = this.current;
  55523. var x = current.x, y = current.y;
  55524. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55525. switch (ops[i] | 0) {
  55526. case OPS.rectangle:
  55527. x = args[j++];
  55528. y = args[j++];
  55529. var width = args[j++];
  55530. var height = args[j++];
  55531. if (width === 0) {
  55532. width = this.getSinglePixelWidth();
  55533. }
  55534. if (height === 0) {
  55535. height = this.getSinglePixelWidth();
  55536. }
  55537. var xw = x + width;
  55538. var yh = y + height;
  55539. this.ctx.moveTo(x, y);
  55540. this.ctx.lineTo(xw, y);
  55541. this.ctx.lineTo(xw, yh);
  55542. this.ctx.lineTo(x, yh);
  55543. this.ctx.lineTo(x, y);
  55544. this.ctx.closePath();
  55545. break;
  55546. case OPS.moveTo:
  55547. x = args[j++];
  55548. y = args[j++];
  55549. ctx.moveTo(x, y);
  55550. break;
  55551. case OPS.lineTo:
  55552. x = args[j++];
  55553. y = args[j++];
  55554. ctx.lineTo(x, y);
  55555. break;
  55556. case OPS.curveTo:
  55557. x = args[j + 4];
  55558. y = args[j + 5];
  55559. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55560. j += 6;
  55561. break;
  55562. case OPS.curveTo2:
  55563. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55564. x = args[j + 2];
  55565. y = args[j + 3];
  55566. j += 4;
  55567. break;
  55568. case OPS.curveTo3:
  55569. x = args[j + 2];
  55570. y = args[j + 3];
  55571. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55572. j += 4;
  55573. break;
  55574. case OPS.closePath:
  55575. ctx.closePath();
  55576. break;
  55577. }
  55578. }
  55579. current.setCurrentPoint(x, y);
  55580. },
  55581. closePath: function CanvasGraphics_closePath() {
  55582. this.ctx.closePath();
  55583. },
  55584. stroke: function CanvasGraphics_stroke(consumePath) {
  55585. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55586. var ctx = this.ctx;
  55587. var strokeColor = this.current.strokeColor;
  55588. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55589. ctx.globalAlpha = this.current.strokeAlpha;
  55590. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55591. ctx.save();
  55592. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55593. ctx.stroke();
  55594. ctx.restore();
  55595. } else {
  55596. ctx.stroke();
  55597. }
  55598. if (consumePath) {
  55599. this.consumePath();
  55600. }
  55601. ctx.globalAlpha = this.current.fillAlpha;
  55602. },
  55603. closeStroke: function CanvasGraphics_closeStroke() {
  55604. this.closePath();
  55605. this.stroke();
  55606. },
  55607. fill: function CanvasGraphics_fill(consumePath) {
  55608. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55609. var ctx = this.ctx;
  55610. var fillColor = this.current.fillColor;
  55611. var isPatternFill = this.current.patternFill;
  55612. var needRestore = false;
  55613. if (isPatternFill) {
  55614. ctx.save();
  55615. if (this.baseTransform) {
  55616. ctx.setTransform.apply(ctx, this.baseTransform);
  55617. }
  55618. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55619. needRestore = true;
  55620. }
  55621. if (this.pendingEOFill) {
  55622. ctx.fill('evenodd');
  55623. this.pendingEOFill = false;
  55624. } else {
  55625. ctx.fill();
  55626. }
  55627. if (needRestore) {
  55628. ctx.restore();
  55629. }
  55630. if (consumePath) {
  55631. this.consumePath();
  55632. }
  55633. },
  55634. eoFill: function CanvasGraphics_eoFill() {
  55635. this.pendingEOFill = true;
  55636. this.fill();
  55637. },
  55638. fillStroke: function CanvasGraphics_fillStroke() {
  55639. this.fill(false);
  55640. this.stroke(false);
  55641. this.consumePath();
  55642. },
  55643. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55644. this.pendingEOFill = true;
  55645. this.fillStroke();
  55646. },
  55647. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55648. this.closePath();
  55649. this.fillStroke();
  55650. },
  55651. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55652. this.pendingEOFill = true;
  55653. this.closePath();
  55654. this.fillStroke();
  55655. },
  55656. endPath: function CanvasGraphics_endPath() {
  55657. this.consumePath();
  55658. },
  55659. clip: function CanvasGraphics_clip() {
  55660. this.pendingClip = NORMAL_CLIP;
  55661. },
  55662. eoClip: function CanvasGraphics_eoClip() {
  55663. this.pendingClip = EO_CLIP;
  55664. },
  55665. beginText: function CanvasGraphics_beginText() {
  55666. this.current.textMatrix = IDENTITY_MATRIX;
  55667. this.current.textMatrixScale = 1;
  55668. this.current.x = this.current.lineX = 0;
  55669. this.current.y = this.current.lineY = 0;
  55670. },
  55671. endText: function CanvasGraphics_endText() {
  55672. var paths = this.pendingTextPaths;
  55673. var ctx = this.ctx;
  55674. if (paths === undefined) {
  55675. ctx.beginPath();
  55676. return;
  55677. }
  55678. ctx.save();
  55679. ctx.beginPath();
  55680. for (var i = 0; i < paths.length; i++) {
  55681. var path = paths[i];
  55682. ctx.setTransform.apply(ctx, path.transform);
  55683. ctx.translate(path.x, path.y);
  55684. path.addToPath(ctx, path.fontSize);
  55685. }
  55686. ctx.restore();
  55687. ctx.clip();
  55688. ctx.beginPath();
  55689. delete this.pendingTextPaths;
  55690. },
  55691. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55692. this.current.charSpacing = spacing;
  55693. },
  55694. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55695. this.current.wordSpacing = spacing;
  55696. },
  55697. setHScale: function CanvasGraphics_setHScale(scale) {
  55698. this.current.textHScale = scale / 100;
  55699. },
  55700. setLeading: function CanvasGraphics_setLeading(leading) {
  55701. this.current.leading = -leading;
  55702. },
  55703. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55704. var fontObj = this.commonObjs.get(fontRefName);
  55705. var current = this.current;
  55706. if (!fontObj) {
  55707. error('Can\'t find font for ' + fontRefName);
  55708. }
  55709. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55710. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55711. warn('Invalid font matrix for font ' + fontRefName);
  55712. }
  55713. if (size < 0) {
  55714. size = -size;
  55715. current.fontDirection = -1;
  55716. } else {
  55717. current.fontDirection = 1;
  55718. }
  55719. this.current.font = fontObj;
  55720. this.current.fontSize = size;
  55721. if (fontObj.isType3Font) {
  55722. return;
  55723. }
  55724. var name = fontObj.loadedName || 'sans-serif';
  55725. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55726. var italic = fontObj.italic ? 'italic' : 'normal';
  55727. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55728. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55729. this.current.fontSizeScale = size / browserFontSize;
  55730. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55731. this.ctx.font = rule;
  55732. },
  55733. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55734. this.current.textRenderingMode = mode;
  55735. },
  55736. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55737. this.current.textRise = rise;
  55738. },
  55739. moveText: function CanvasGraphics_moveText(x, y) {
  55740. this.current.x = this.current.lineX += x;
  55741. this.current.y = this.current.lineY += y;
  55742. },
  55743. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55744. this.setLeading(-y);
  55745. this.moveText(x, y);
  55746. },
  55747. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55748. this.current.textMatrix = [
  55749. a,
  55750. b,
  55751. c,
  55752. d,
  55753. e,
  55754. f
  55755. ];
  55756. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55757. this.current.x = this.current.lineX = 0;
  55758. this.current.y = this.current.lineY = 0;
  55759. },
  55760. nextLine: function CanvasGraphics_nextLine() {
  55761. this.moveText(0, this.current.leading);
  55762. },
  55763. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55764. var ctx = this.ctx;
  55765. var current = this.current;
  55766. var font = current.font;
  55767. var textRenderingMode = current.textRenderingMode;
  55768. var fontSize = current.fontSize / current.fontSizeScale;
  55769. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55770. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55771. var addToPath;
  55772. if (font.disableFontFace || isAddToPathSet) {
  55773. addToPath = font.getPathGenerator(this.commonObjs, character);
  55774. }
  55775. if (font.disableFontFace) {
  55776. ctx.save();
  55777. ctx.translate(x, y);
  55778. ctx.beginPath();
  55779. addToPath(ctx, fontSize);
  55780. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55781. ctx.fill();
  55782. }
  55783. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55784. ctx.stroke();
  55785. }
  55786. ctx.restore();
  55787. } else {
  55788. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55789. ctx.fillText(character, x, y);
  55790. }
  55791. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55792. ctx.strokeText(character, x, y);
  55793. }
  55794. }
  55795. if (isAddToPathSet) {
  55796. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55797. paths.push({
  55798. transform: ctx.mozCurrentTransform,
  55799. x: x,
  55800. y: y,
  55801. fontSize: fontSize,
  55802. addToPath: addToPath
  55803. });
  55804. }
  55805. },
  55806. get isFontSubpixelAAEnabled() {
  55807. var ctx = this.canvasFactory.create(10, 10).context;
  55808. ctx.scale(1.5, 1);
  55809. ctx.fillText('I', 0, 10);
  55810. var data = ctx.getImageData(0, 0, 10, 10).data;
  55811. var enabled = false;
  55812. for (var i = 3; i < data.length; i += 4) {
  55813. if (data[i] > 0 && data[i] < 255) {
  55814. enabled = true;
  55815. break;
  55816. }
  55817. }
  55818. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55819. },
  55820. showText: function CanvasGraphics_showText(glyphs) {
  55821. var current = this.current;
  55822. var font = current.font;
  55823. if (font.isType3Font) {
  55824. return this.showType3Text(glyphs);
  55825. }
  55826. var fontSize = current.fontSize;
  55827. if (fontSize === 0) {
  55828. return;
  55829. }
  55830. var ctx = this.ctx;
  55831. var fontSizeScale = current.fontSizeScale;
  55832. var charSpacing = current.charSpacing;
  55833. var wordSpacing = current.wordSpacing;
  55834. var fontDirection = current.fontDirection;
  55835. var textHScale = current.textHScale * fontDirection;
  55836. var glyphsLength = glyphs.length;
  55837. var vertical = font.vertical;
  55838. var spacingDir = vertical ? 1 : -1;
  55839. var defaultVMetrics = font.defaultVMetrics;
  55840. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55841. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55842. ctx.save();
  55843. ctx.transform.apply(ctx, current.textMatrix);
  55844. ctx.translate(current.x, current.y + current.textRise);
  55845. if (current.patternFill) {
  55846. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55847. }
  55848. if (fontDirection > 0) {
  55849. ctx.scale(textHScale, -1);
  55850. } else {
  55851. ctx.scale(textHScale, 1);
  55852. }
  55853. var lineWidth = current.lineWidth;
  55854. var scale = current.textMatrixScale;
  55855. if (scale === 0 || lineWidth === 0) {
  55856. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55857. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55858. this.cachedGetSinglePixelWidth = null;
  55859. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55860. }
  55861. } else {
  55862. lineWidth /= scale;
  55863. }
  55864. if (fontSizeScale !== 1.0) {
  55865. ctx.scale(fontSizeScale, fontSizeScale);
  55866. lineWidth /= fontSizeScale;
  55867. }
  55868. ctx.lineWidth = lineWidth;
  55869. var x = 0, i;
  55870. for (i = 0; i < glyphsLength; ++i) {
  55871. var glyph = glyphs[i];
  55872. if (isNum(glyph)) {
  55873. x += spacingDir * glyph * fontSize / 1000;
  55874. continue;
  55875. }
  55876. var restoreNeeded = false;
  55877. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55878. var character = glyph.fontChar;
  55879. var accent = glyph.accent;
  55880. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55881. var width = glyph.width;
  55882. if (vertical) {
  55883. var vmetric, vx, vy;
  55884. vmetric = glyph.vmetric || defaultVMetrics;
  55885. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55886. vx = -vx * widthAdvanceScale;
  55887. vy = vmetric[2] * widthAdvanceScale;
  55888. width = vmetric ? -vmetric[0] : width;
  55889. scaledX = vx / fontSizeScale;
  55890. scaledY = (x + vy) / fontSizeScale;
  55891. } else {
  55892. scaledX = x / fontSizeScale;
  55893. scaledY = 0;
  55894. }
  55895. if (font.remeasure && width > 0) {
  55896. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55897. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55898. var characterScaleX = width / measuredWidth;
  55899. restoreNeeded = true;
  55900. ctx.save();
  55901. ctx.scale(characterScaleX, 1);
  55902. scaledX /= characterScaleX;
  55903. } else if (width !== measuredWidth) {
  55904. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55905. }
  55906. }
  55907. if (glyph.isInFont || font.missingFile) {
  55908. if (simpleFillText && !accent) {
  55909. ctx.fillText(character, scaledX, scaledY);
  55910. } else {
  55911. this.paintChar(character, scaledX, scaledY);
  55912. if (accent) {
  55913. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55914. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55915. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55916. }
  55917. }
  55918. }
  55919. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55920. x += charWidth;
  55921. if (restoreNeeded) {
  55922. ctx.restore();
  55923. }
  55924. }
  55925. if (vertical) {
  55926. current.y -= x * textHScale;
  55927. } else {
  55928. current.x += x * textHScale;
  55929. }
  55930. ctx.restore();
  55931. },
  55932. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55933. var ctx = this.ctx;
  55934. var current = this.current;
  55935. var font = current.font;
  55936. var fontSize = current.fontSize;
  55937. var fontDirection = current.fontDirection;
  55938. var spacingDir = font.vertical ? 1 : -1;
  55939. var charSpacing = current.charSpacing;
  55940. var wordSpacing = current.wordSpacing;
  55941. var textHScale = current.textHScale * fontDirection;
  55942. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55943. var glyphsLength = glyphs.length;
  55944. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55945. var i, glyph, width, spacingLength;
  55946. if (isTextInvisible || fontSize === 0) {
  55947. return;
  55948. }
  55949. this.cachedGetSinglePixelWidth = null;
  55950. ctx.save();
  55951. ctx.transform.apply(ctx, current.textMatrix);
  55952. ctx.translate(current.x, current.y);
  55953. ctx.scale(textHScale, fontDirection);
  55954. for (i = 0; i < glyphsLength; ++i) {
  55955. glyph = glyphs[i];
  55956. if (isNum(glyph)) {
  55957. spacingLength = spacingDir * glyph * fontSize / 1000;
  55958. this.ctx.translate(spacingLength, 0);
  55959. current.x += spacingLength * textHScale;
  55960. continue;
  55961. }
  55962. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55963. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55964. if (!operatorList) {
  55965. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55966. continue;
  55967. }
  55968. this.processingType3 = glyph;
  55969. this.save();
  55970. ctx.scale(fontSize, fontSize);
  55971. ctx.transform.apply(ctx, fontMatrix);
  55972. this.executeOperatorList(operatorList);
  55973. this.restore();
  55974. var transformed = Util.applyTransform([
  55975. glyph.width,
  55976. 0
  55977. ], fontMatrix);
  55978. width = transformed[0] * fontSize + spacing;
  55979. ctx.translate(width, 0);
  55980. current.x += width * textHScale;
  55981. }
  55982. ctx.restore();
  55983. this.processingType3 = null;
  55984. },
  55985. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55986. },
  55987. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55988. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55989. this.clip();
  55990. this.endPath();
  55991. },
  55992. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55993. var pattern;
  55994. if (IR[0] === 'TilingPattern') {
  55995. var color = IR[1];
  55996. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55997. var self = this;
  55998. var canvasGraphicsFactory = {
  55999. createCanvasGraphics: function (ctx) {
  56000. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  56001. }
  56002. };
  56003. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  56004. } else {
  56005. pattern = getShadingPatternFromIR(IR);
  56006. }
  56007. return pattern;
  56008. },
  56009. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  56010. this.current.strokeColor = this.getColorN_Pattern(arguments);
  56011. },
  56012. setFillColorN: function CanvasGraphics_setFillColorN() {
  56013. this.current.fillColor = this.getColorN_Pattern(arguments);
  56014. this.current.patternFill = true;
  56015. },
  56016. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  56017. var color = Util.makeCssRgb(r, g, b);
  56018. this.ctx.strokeStyle = color;
  56019. this.current.strokeColor = color;
  56020. },
  56021. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  56022. var color = Util.makeCssRgb(r, g, b);
  56023. this.ctx.fillStyle = color;
  56024. this.current.fillColor = color;
  56025. this.current.patternFill = false;
  56026. },
  56027. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  56028. var ctx = this.ctx;
  56029. this.save();
  56030. var pattern = getShadingPatternFromIR(patternIR);
  56031. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  56032. var inv = ctx.mozCurrentTransformInverse;
  56033. if (inv) {
  56034. var canvas = ctx.canvas;
  56035. var width = canvas.width;
  56036. var height = canvas.height;
  56037. var bl = Util.applyTransform([
  56038. 0,
  56039. 0
  56040. ], inv);
  56041. var br = Util.applyTransform([
  56042. 0,
  56043. height
  56044. ], inv);
  56045. var ul = Util.applyTransform([
  56046. width,
  56047. 0
  56048. ], inv);
  56049. var ur = Util.applyTransform([
  56050. width,
  56051. height
  56052. ], inv);
  56053. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  56054. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56055. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56056. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56057. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56058. } else {
  56059. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56060. }
  56061. this.restore();
  56062. },
  56063. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56064. error('Should not call beginInlineImage');
  56065. },
  56066. beginImageData: function CanvasGraphics_beginImageData() {
  56067. error('Should not call beginImageData');
  56068. },
  56069. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56070. this.save();
  56071. this.baseTransformStack.push(this.baseTransform);
  56072. if (isArray(matrix) && matrix.length === 6) {
  56073. this.transform.apply(this, matrix);
  56074. }
  56075. this.baseTransform = this.ctx.mozCurrentTransform;
  56076. if (isArray(bbox) && bbox.length === 4) {
  56077. var width = bbox[2] - bbox[0];
  56078. var height = bbox[3] - bbox[1];
  56079. this.ctx.rect(bbox[0], bbox[1], width, height);
  56080. this.clip();
  56081. this.endPath();
  56082. }
  56083. },
  56084. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56085. this.restore();
  56086. this.baseTransform = this.baseTransformStack.pop();
  56087. },
  56088. beginGroup: function CanvasGraphics_beginGroup(group) {
  56089. this.save();
  56090. var currentCtx = this.ctx;
  56091. if (!group.isolated) {
  56092. info('TODO: Support non-isolated groups.');
  56093. }
  56094. if (group.knockout) {
  56095. warn('Knockout groups not supported.');
  56096. }
  56097. var currentTransform = currentCtx.mozCurrentTransform;
  56098. if (group.matrix) {
  56099. currentCtx.transform.apply(currentCtx, group.matrix);
  56100. }
  56101. assert(group.bbox, 'Bounding box is required.');
  56102. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56103. var canvasBounds = [
  56104. 0,
  56105. 0,
  56106. currentCtx.canvas.width,
  56107. currentCtx.canvas.height
  56108. ];
  56109. bounds = Util.intersect(bounds, canvasBounds) || [
  56110. 0,
  56111. 0,
  56112. 0,
  56113. 0
  56114. ];
  56115. var offsetX = Math.floor(bounds[0]);
  56116. var offsetY = Math.floor(bounds[1]);
  56117. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56118. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56119. var scaleX = 1, scaleY = 1;
  56120. if (drawnWidth > MAX_GROUP_SIZE) {
  56121. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56122. drawnWidth = MAX_GROUP_SIZE;
  56123. }
  56124. if (drawnHeight > MAX_GROUP_SIZE) {
  56125. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56126. drawnHeight = MAX_GROUP_SIZE;
  56127. }
  56128. var cacheId = 'groupAt' + this.groupLevel;
  56129. if (group.smask) {
  56130. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56131. }
  56132. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56133. var groupCtx = scratchCanvas.context;
  56134. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56135. groupCtx.translate(-offsetX, -offsetY);
  56136. groupCtx.transform.apply(groupCtx, currentTransform);
  56137. if (group.smask) {
  56138. this.smaskStack.push({
  56139. canvas: scratchCanvas.canvas,
  56140. context: groupCtx,
  56141. offsetX: offsetX,
  56142. offsetY: offsetY,
  56143. scaleX: scaleX,
  56144. scaleY: scaleY,
  56145. subtype: group.smask.subtype,
  56146. backdrop: group.smask.backdrop,
  56147. transferMap: group.smask.transferMap || null,
  56148. startTransformInverse: null
  56149. });
  56150. } else {
  56151. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56152. currentCtx.translate(offsetX, offsetY);
  56153. currentCtx.scale(scaleX, scaleY);
  56154. }
  56155. copyCtxState(currentCtx, groupCtx);
  56156. this.ctx = groupCtx;
  56157. this.setGState([
  56158. [
  56159. 'BM',
  56160. 'Normal'
  56161. ],
  56162. [
  56163. 'ca',
  56164. 1
  56165. ],
  56166. [
  56167. 'CA',
  56168. 1
  56169. ]
  56170. ]);
  56171. this.groupStack.push(currentCtx);
  56172. this.groupLevel++;
  56173. this.current.activeSMask = null;
  56174. },
  56175. endGroup: function CanvasGraphics_endGroup(group) {
  56176. this.groupLevel--;
  56177. var groupCtx = this.ctx;
  56178. this.ctx = this.groupStack.pop();
  56179. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56180. this.ctx.imageSmoothingEnabled = false;
  56181. } else {
  56182. this.ctx.mozImageSmoothingEnabled = false;
  56183. }
  56184. if (group.smask) {
  56185. this.tempSMask = this.smaskStack.pop();
  56186. } else {
  56187. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56188. }
  56189. this.restore();
  56190. },
  56191. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56192. this.save();
  56193. this.current = new CanvasExtraState();
  56194. if (this.baseTransform) {
  56195. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56196. }
  56197. },
  56198. endAnnotations: function CanvasGraphics_endAnnotations() {
  56199. this.restore();
  56200. },
  56201. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56202. this.save();
  56203. if (isArray(rect) && rect.length === 4) {
  56204. var width = rect[2] - rect[0];
  56205. var height = rect[3] - rect[1];
  56206. this.ctx.rect(rect[0], rect[1], width, height);
  56207. this.clip();
  56208. this.endPath();
  56209. }
  56210. this.transform.apply(this, transform);
  56211. this.transform.apply(this, matrix);
  56212. },
  56213. endAnnotation: function CanvasGraphics_endAnnotation() {
  56214. this.restore();
  56215. },
  56216. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56217. var domImage = this.objs.get(objId);
  56218. if (!domImage) {
  56219. warn('Dependent image isn\'t ready yet');
  56220. return;
  56221. }
  56222. this.save();
  56223. var ctx = this.ctx;
  56224. ctx.scale(1 / w, -1 / h);
  56225. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56226. if (this.imageLayer) {
  56227. var currentTransform = ctx.mozCurrentTransformInverse;
  56228. var position = this.getCanvasPosition(0, 0);
  56229. this.imageLayer.appendImage({
  56230. objId: objId,
  56231. left: position[0],
  56232. top: position[1],
  56233. width: w / currentTransform[0],
  56234. height: h / currentTransform[3]
  56235. });
  56236. }
  56237. this.restore();
  56238. },
  56239. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56240. var ctx = this.ctx;
  56241. var width = img.width, height = img.height;
  56242. var fillColor = this.current.fillColor;
  56243. var isPatternFill = this.current.patternFill;
  56244. var glyph = this.processingType3;
  56245. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56246. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56247. glyph.compiled = compileType3Glyph({
  56248. data: img.data,
  56249. width: width,
  56250. height: height
  56251. });
  56252. } else {
  56253. glyph.compiled = null;
  56254. }
  56255. }
  56256. if (glyph && glyph.compiled) {
  56257. glyph.compiled(ctx);
  56258. return;
  56259. }
  56260. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56261. var maskCtx = maskCanvas.context;
  56262. maskCtx.save();
  56263. putBinaryImageMask(maskCtx, img);
  56264. maskCtx.globalCompositeOperation = 'source-in';
  56265. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56266. maskCtx.fillRect(0, 0, width, height);
  56267. maskCtx.restore();
  56268. this.paintInlineImageXObject(maskCanvas.canvas);
  56269. },
  56270. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56271. var width = imgData.width;
  56272. var height = imgData.height;
  56273. var fillColor = this.current.fillColor;
  56274. var isPatternFill = this.current.patternFill;
  56275. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56276. var maskCtx = maskCanvas.context;
  56277. maskCtx.save();
  56278. putBinaryImageMask(maskCtx, imgData);
  56279. maskCtx.globalCompositeOperation = 'source-in';
  56280. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56281. maskCtx.fillRect(0, 0, width, height);
  56282. maskCtx.restore();
  56283. var ctx = this.ctx;
  56284. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56285. ctx.save();
  56286. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56287. ctx.scale(1, -1);
  56288. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56289. ctx.restore();
  56290. }
  56291. },
  56292. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56293. var ctx = this.ctx;
  56294. var fillColor = this.current.fillColor;
  56295. var isPatternFill = this.current.patternFill;
  56296. for (var i = 0, ii = images.length; i < ii; i++) {
  56297. var image = images[i];
  56298. var width = image.width, height = image.height;
  56299. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56300. var maskCtx = maskCanvas.context;
  56301. maskCtx.save();
  56302. putBinaryImageMask(maskCtx, image);
  56303. maskCtx.globalCompositeOperation = 'source-in';
  56304. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56305. maskCtx.fillRect(0, 0, width, height);
  56306. maskCtx.restore();
  56307. ctx.save();
  56308. ctx.transform.apply(ctx, image.transform);
  56309. ctx.scale(1, -1);
  56310. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56311. ctx.restore();
  56312. }
  56313. },
  56314. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56315. var imgData = this.objs.get(objId);
  56316. if (!imgData) {
  56317. warn('Dependent image isn\'t ready yet');
  56318. return;
  56319. }
  56320. this.paintInlineImageXObject(imgData);
  56321. },
  56322. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56323. var imgData = this.objs.get(objId);
  56324. if (!imgData) {
  56325. warn('Dependent image isn\'t ready yet');
  56326. return;
  56327. }
  56328. var width = imgData.width;
  56329. var height = imgData.height;
  56330. var map = [];
  56331. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56332. map.push({
  56333. transform: [
  56334. scaleX,
  56335. 0,
  56336. 0,
  56337. scaleY,
  56338. positions[i],
  56339. positions[i + 1]
  56340. ],
  56341. x: 0,
  56342. y: 0,
  56343. w: width,
  56344. h: height
  56345. });
  56346. }
  56347. this.paintInlineImageXObjectGroup(imgData, map);
  56348. },
  56349. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56350. var width = imgData.width;
  56351. var height = imgData.height;
  56352. var ctx = this.ctx;
  56353. this.save();
  56354. ctx.scale(1 / width, -1 / height);
  56355. var currentTransform = ctx.mozCurrentTransformInverse;
  56356. var a = currentTransform[0], b = currentTransform[1];
  56357. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56358. var c = currentTransform[2], d = currentTransform[3];
  56359. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56360. var imgToPaint, tmpCanvas;
  56361. if (imgData instanceof HTMLElement || !imgData.data) {
  56362. imgToPaint = imgData;
  56363. } else {
  56364. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56365. var tmpCtx = tmpCanvas.context;
  56366. putBinaryImageData(tmpCtx, imgData);
  56367. imgToPaint = tmpCanvas.canvas;
  56368. }
  56369. var paintWidth = width, paintHeight = height;
  56370. var tmpCanvasId = 'prescale1';
  56371. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56372. var newWidth = paintWidth, newHeight = paintHeight;
  56373. if (widthScale > 2 && paintWidth > 1) {
  56374. newWidth = Math.ceil(paintWidth / 2);
  56375. widthScale /= paintWidth / newWidth;
  56376. }
  56377. if (heightScale > 2 && paintHeight > 1) {
  56378. newHeight = Math.ceil(paintHeight / 2);
  56379. heightScale /= paintHeight / newHeight;
  56380. }
  56381. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56382. tmpCtx = tmpCanvas.context;
  56383. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56384. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56385. imgToPaint = tmpCanvas.canvas;
  56386. paintWidth = newWidth;
  56387. paintHeight = newHeight;
  56388. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56389. }
  56390. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56391. if (this.imageLayer) {
  56392. var position = this.getCanvasPosition(0, -height);
  56393. this.imageLayer.appendImage({
  56394. imgData: imgData,
  56395. left: position[0],
  56396. top: position[1],
  56397. width: width / currentTransform[0],
  56398. height: height / currentTransform[3]
  56399. });
  56400. }
  56401. this.restore();
  56402. },
  56403. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56404. var ctx = this.ctx;
  56405. var w = imgData.width;
  56406. var h = imgData.height;
  56407. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56408. var tmpCtx = tmpCanvas.context;
  56409. putBinaryImageData(tmpCtx, imgData);
  56410. for (var i = 0, ii = map.length; i < ii; i++) {
  56411. var entry = map[i];
  56412. ctx.save();
  56413. ctx.transform.apply(ctx, entry.transform);
  56414. ctx.scale(1, -1);
  56415. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56416. if (this.imageLayer) {
  56417. var position = this.getCanvasPosition(entry.x, entry.y);
  56418. this.imageLayer.appendImage({
  56419. imgData: imgData,
  56420. left: position[0],
  56421. top: position[1],
  56422. width: w,
  56423. height: h
  56424. });
  56425. }
  56426. ctx.restore();
  56427. }
  56428. },
  56429. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56430. this.ctx.fillRect(0, 0, 1, 1);
  56431. },
  56432. paintXObject: function CanvasGraphics_paintXObject() {
  56433. warn('Unsupported \'paintXObject\' command.');
  56434. },
  56435. markPoint: function CanvasGraphics_markPoint(tag) {
  56436. },
  56437. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56438. },
  56439. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56440. },
  56441. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56442. },
  56443. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56444. },
  56445. beginCompat: function CanvasGraphics_beginCompat() {
  56446. },
  56447. endCompat: function CanvasGraphics_endCompat() {
  56448. },
  56449. consumePath: function CanvasGraphics_consumePath() {
  56450. var ctx = this.ctx;
  56451. if (this.pendingClip) {
  56452. if (this.pendingClip === EO_CLIP) {
  56453. ctx.clip('evenodd');
  56454. } else {
  56455. ctx.clip();
  56456. }
  56457. this.pendingClip = null;
  56458. }
  56459. ctx.beginPath();
  56460. },
  56461. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56462. if (this.cachedGetSinglePixelWidth === null) {
  56463. this.ctx.save();
  56464. var inverse = this.ctx.mozCurrentTransformInverse;
  56465. this.ctx.restore();
  56466. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56467. }
  56468. return this.cachedGetSinglePixelWidth;
  56469. },
  56470. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56471. var transform = this.ctx.mozCurrentTransform;
  56472. return [
  56473. transform[0] * x + transform[2] * y + transform[4],
  56474. transform[1] * x + transform[3] * y + transform[5]
  56475. ];
  56476. }
  56477. };
  56478. for (var op in OPS) {
  56479. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56480. }
  56481. return CanvasGraphics;
  56482. }();
  56483. exports.CanvasGraphics = CanvasGraphics;
  56484. /***/ }),
  56485. /* 45 */
  56486. /***/ (function(module, exports, __w_pdfjs_require__) {
  56487. "use strict";
  56488. var sharedUtil = __w_pdfjs_require__(0);
  56489. var assert = sharedUtil.assert;
  56490. var bytesToString = sharedUtil.bytesToString;
  56491. var string32 = sharedUtil.string32;
  56492. var shadow = sharedUtil.shadow;
  56493. var warn = sharedUtil.warn;
  56494. function FontLoader(docId) {
  56495. this.docId = docId;
  56496. this.styleElement = null;
  56497. this.nativeFontFaces = [];
  56498. this.loadTestFontId = 0;
  56499. this.loadingContext = {
  56500. requests: [],
  56501. nextRequestId: 0
  56502. };
  56503. }
  56504. FontLoader.prototype = {
  56505. insertRule: function fontLoaderInsertRule(rule) {
  56506. var styleElement = this.styleElement;
  56507. if (!styleElement) {
  56508. styleElement = this.styleElement = document.createElement('style');
  56509. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56510. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56511. }
  56512. var styleSheet = styleElement.sheet;
  56513. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56514. },
  56515. clear: function fontLoaderClear() {
  56516. if (this.styleElement) {
  56517. this.styleElement.remove();
  56518. this.styleElement = null;
  56519. }
  56520. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56521. document.fonts.delete(nativeFontFace);
  56522. });
  56523. this.nativeFontFaces.length = 0;
  56524. }
  56525. };
  56526. var getLoadTestFont = function () {
  56527. 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==');
  56528. };
  56529. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56530. get: function () {
  56531. return shadow(this, 'loadTestFont', getLoadTestFont());
  56532. },
  56533. configurable: true
  56534. });
  56535. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56536. this.nativeFontFaces.push(nativeFontFace);
  56537. document.fonts.add(nativeFontFace);
  56538. };
  56539. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56540. var rules = [];
  56541. var fontsToLoad = [];
  56542. var fontLoadPromises = [];
  56543. var getNativeFontPromise = function (nativeFontFace) {
  56544. return nativeFontFace.loaded.catch(function (e) {
  56545. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56546. });
  56547. };
  56548. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56549. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56550. var font = fonts[i];
  56551. if (font.attached || font.loading === false) {
  56552. continue;
  56553. }
  56554. font.attached = true;
  56555. if (isFontLoadingAPISupported) {
  56556. var nativeFontFace = font.createNativeFontFace();
  56557. if (nativeFontFace) {
  56558. this.addNativeFontFace(nativeFontFace);
  56559. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56560. }
  56561. } else {
  56562. var rule = font.createFontFaceRule();
  56563. if (rule) {
  56564. this.insertRule(rule);
  56565. rules.push(rule);
  56566. fontsToLoad.push(font);
  56567. }
  56568. }
  56569. }
  56570. var request = this.queueLoadingCallback(callback);
  56571. if (isFontLoadingAPISupported) {
  56572. Promise.all(fontLoadPromises).then(function () {
  56573. request.complete();
  56574. });
  56575. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56576. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56577. } else {
  56578. request.complete();
  56579. }
  56580. };
  56581. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56582. function LoadLoader_completeRequest() {
  56583. assert(!request.end, 'completeRequest() cannot be called twice');
  56584. request.end = Date.now();
  56585. while (context.requests.length > 0 && context.requests[0].end) {
  56586. var otherRequest = context.requests.shift();
  56587. setTimeout(otherRequest.callback, 0);
  56588. }
  56589. }
  56590. var context = this.loadingContext;
  56591. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56592. var request = {
  56593. id: requestId,
  56594. complete: LoadLoader_completeRequest,
  56595. callback: callback,
  56596. started: Date.now()
  56597. };
  56598. context.requests.push(request);
  56599. return request;
  56600. };
  56601. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56602. function int32(data, offset) {
  56603. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56604. }
  56605. function spliceString(s, offset, remove, insert) {
  56606. var chunk1 = s.substr(0, offset);
  56607. var chunk2 = s.substr(offset + remove);
  56608. return chunk1 + insert + chunk2;
  56609. }
  56610. var i, ii;
  56611. var canvas = document.createElement('canvas');
  56612. canvas.width = 1;
  56613. canvas.height = 1;
  56614. var ctx = canvas.getContext('2d');
  56615. var called = 0;
  56616. function isFontReady(name, callback) {
  56617. called++;
  56618. if (called > 30) {
  56619. warn('Load test font never loaded.');
  56620. callback();
  56621. return;
  56622. }
  56623. ctx.font = '30px ' + name;
  56624. ctx.fillText('.', 0, 20);
  56625. var imageData = ctx.getImageData(0, 0, 1, 1);
  56626. if (imageData.data[3] > 0) {
  56627. callback();
  56628. return;
  56629. }
  56630. setTimeout(isFontReady.bind(null, name, callback));
  56631. }
  56632. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56633. var data = this.loadTestFont;
  56634. var COMMENT_OFFSET = 976;
  56635. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56636. var CFF_CHECKSUM_OFFSET = 16;
  56637. var XXXX_VALUE = 0x58585858;
  56638. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56639. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56640. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56641. }
  56642. if (i < loadTestFontId.length) {
  56643. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56644. }
  56645. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56646. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56647. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56648. this.insertRule(rule);
  56649. var names = [];
  56650. for (i = 0, ii = fonts.length; i < ii; i++) {
  56651. names.push(fonts[i].loadedName);
  56652. }
  56653. names.push(loadTestFontId);
  56654. var div = document.createElement('div');
  56655. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56656. for (i = 0, ii = names.length; i < ii; ++i) {
  56657. var span = document.createElement('span');
  56658. span.textContent = 'Hi';
  56659. span.style.fontFamily = names[i];
  56660. div.appendChild(span);
  56661. }
  56662. document.body.appendChild(div);
  56663. isFontReady(loadTestFontId, function () {
  56664. document.body.removeChild(div);
  56665. request.complete();
  56666. });
  56667. };
  56668. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56669. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56670. if (typeof navigator === 'undefined') {
  56671. return true;
  56672. }
  56673. var supported = false;
  56674. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56675. if (m && m[1] >= 14) {
  56676. supported = true;
  56677. }
  56678. return supported;
  56679. };
  56680. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56681. get: function () {
  56682. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56683. },
  56684. enumerable: true,
  56685. configurable: true
  56686. });
  56687. var IsEvalSupportedCached = {
  56688. get value() {
  56689. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56690. }
  56691. };
  56692. var FontFaceObject = function FontFaceObjectClosure() {
  56693. function FontFaceObject(translatedData, options) {
  56694. this.compiledGlyphs = Object.create(null);
  56695. for (var i in translatedData) {
  56696. this[i] = translatedData[i];
  56697. }
  56698. this.options = options;
  56699. }
  56700. FontFaceObject.prototype = {
  56701. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56702. if (!this.data) {
  56703. return null;
  56704. }
  56705. if (this.options.disableFontFace) {
  56706. this.disableFontFace = true;
  56707. return null;
  56708. }
  56709. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56710. if (this.options.fontRegistry) {
  56711. this.options.fontRegistry.registerFont(this);
  56712. }
  56713. return nativeFontFace;
  56714. },
  56715. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56716. if (!this.data) {
  56717. return null;
  56718. }
  56719. if (this.options.disableFontFace) {
  56720. this.disableFontFace = true;
  56721. return null;
  56722. }
  56723. var data = bytesToString(new Uint8Array(this.data));
  56724. var fontName = this.loadedName;
  56725. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56726. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56727. if (this.options.fontRegistry) {
  56728. this.options.fontRegistry.registerFont(this, url);
  56729. }
  56730. return rule;
  56731. },
  56732. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56733. if (!(character in this.compiledGlyphs)) {
  56734. var cmds = objs.get(this.loadedName + '_path_' + character);
  56735. var current, i, len;
  56736. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56737. var args, js = '';
  56738. for (i = 0, len = cmds.length; i < len; i++) {
  56739. current = cmds[i];
  56740. if (current.args !== undefined) {
  56741. args = current.args.join(',');
  56742. } else {
  56743. args = '';
  56744. }
  56745. js += 'c.' + current.cmd + '(' + args + ');\n';
  56746. }
  56747. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56748. } else {
  56749. this.compiledGlyphs[character] = function (c, size) {
  56750. for (i = 0, len = cmds.length; i < len; i++) {
  56751. current = cmds[i];
  56752. if (current.cmd === 'scale') {
  56753. current.args = [
  56754. size,
  56755. -size
  56756. ];
  56757. }
  56758. c[current.cmd].apply(c, current.args);
  56759. }
  56760. };
  56761. }
  56762. }
  56763. return this.compiledGlyphs[character];
  56764. }
  56765. };
  56766. return FontFaceObject;
  56767. }();
  56768. exports.FontFaceObject = FontFaceObject;
  56769. exports.FontLoader = FontLoader;
  56770. /***/ }),
  56771. /* 46 */
  56772. /***/ (function(module, exports, __w_pdfjs_require__) {
  56773. "use strict";
  56774. var sharedUtil = __w_pdfjs_require__(0);
  56775. var displayWebGL = __w_pdfjs_require__(24);
  56776. var Util = sharedUtil.Util;
  56777. var info = sharedUtil.info;
  56778. var isArray = sharedUtil.isArray;
  56779. var error = sharedUtil.error;
  56780. var WebGLUtils = displayWebGL.WebGLUtils;
  56781. var ShadingIRs = {};
  56782. ShadingIRs.RadialAxial = {
  56783. fromIR: function RadialAxial_fromIR(raw) {
  56784. var type = raw[1];
  56785. var colorStops = raw[2];
  56786. var p0 = raw[3];
  56787. var p1 = raw[4];
  56788. var r0 = raw[5];
  56789. var r1 = raw[6];
  56790. return {
  56791. type: 'Pattern',
  56792. getPattern: function RadialAxial_getPattern(ctx) {
  56793. var grad;
  56794. if (type === 'axial') {
  56795. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56796. } else if (type === 'radial') {
  56797. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56798. }
  56799. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56800. var c = colorStops[i];
  56801. grad.addColorStop(c[0], c[1]);
  56802. }
  56803. return grad;
  56804. }
  56805. };
  56806. }
  56807. };
  56808. var createMeshCanvas = function createMeshCanvasClosure() {
  56809. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56810. var coords = context.coords, colors = context.colors;
  56811. var bytes = data.data, rowSize = data.width * 4;
  56812. var tmp;
  56813. if (coords[p1 + 1] > coords[p2 + 1]) {
  56814. tmp = p1;
  56815. p1 = p2;
  56816. p2 = tmp;
  56817. tmp = c1;
  56818. c1 = c2;
  56819. c2 = tmp;
  56820. }
  56821. if (coords[p2 + 1] > coords[p3 + 1]) {
  56822. tmp = p2;
  56823. p2 = p3;
  56824. p3 = tmp;
  56825. tmp = c2;
  56826. c2 = c3;
  56827. c3 = tmp;
  56828. }
  56829. if (coords[p1 + 1] > coords[p2 + 1]) {
  56830. tmp = p1;
  56831. p1 = p2;
  56832. p2 = tmp;
  56833. tmp = c1;
  56834. c1 = c2;
  56835. c2 = tmp;
  56836. }
  56837. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56838. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56839. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56840. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56841. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56842. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56843. if (y1 >= y3) {
  56844. return;
  56845. }
  56846. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56847. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56848. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56849. var minY = Math.round(y1), maxY = Math.round(y3);
  56850. var xa, car, cag, cab;
  56851. var xb, cbr, cbg, cbb;
  56852. var k;
  56853. for (var y = minY; y <= maxY; y++) {
  56854. if (y < y2) {
  56855. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56856. xa = x1 - (x1 - x2) * k;
  56857. car = c1r - (c1r - c2r) * k;
  56858. cag = c1g - (c1g - c2g) * k;
  56859. cab = c1b - (c1b - c2b) * k;
  56860. } else {
  56861. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56862. xa = x2 - (x2 - x3) * k;
  56863. car = c2r - (c2r - c3r) * k;
  56864. cag = c2g - (c2g - c3g) * k;
  56865. cab = c2b - (c2b - c3b) * k;
  56866. }
  56867. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56868. xb = x1 - (x1 - x3) * k;
  56869. cbr = c1r - (c1r - c3r) * k;
  56870. cbg = c1g - (c1g - c3g) * k;
  56871. cbb = c1b - (c1b - c3b) * k;
  56872. var x1_ = Math.round(Math.min(xa, xb));
  56873. var x2_ = Math.round(Math.max(xa, xb));
  56874. var j = rowSize * y + x1_ * 4;
  56875. for (var x = x1_; x <= x2_; x++) {
  56876. k = (xa - x) / (xa - xb);
  56877. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56878. bytes[j++] = car - (car - cbr) * k | 0;
  56879. bytes[j++] = cag - (cag - cbg) * k | 0;
  56880. bytes[j++] = cab - (cab - cbb) * k | 0;
  56881. bytes[j++] = 255;
  56882. }
  56883. }
  56884. }
  56885. function drawFigure(data, figure, context) {
  56886. var ps = figure.coords;
  56887. var cs = figure.colors;
  56888. var i, ii;
  56889. switch (figure.type) {
  56890. case 'lattice':
  56891. var verticesPerRow = figure.verticesPerRow;
  56892. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56893. var cols = verticesPerRow - 1;
  56894. for (i = 0; i < rows; i++) {
  56895. var q = i * verticesPerRow;
  56896. for (var j = 0; j < cols; j++, q++) {
  56897. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56898. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56899. }
  56900. }
  56901. break;
  56902. case 'triangles':
  56903. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56904. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56905. }
  56906. break;
  56907. default:
  56908. error('illigal figure');
  56909. break;
  56910. }
  56911. }
  56912. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56913. var EXPECTED_SCALE = 1.1;
  56914. var MAX_PATTERN_SIZE = 3000;
  56915. var BORDER_SIZE = 2;
  56916. var offsetX = Math.floor(bounds[0]);
  56917. var offsetY = Math.floor(bounds[1]);
  56918. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56919. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56920. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56921. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56922. var scaleX = boundsWidth / width;
  56923. var scaleY = boundsHeight / height;
  56924. var context = {
  56925. coords: coords,
  56926. colors: colors,
  56927. offsetX: -offsetX,
  56928. offsetY: -offsetY,
  56929. scaleX: 1 / scaleX,
  56930. scaleY: 1 / scaleY
  56931. };
  56932. var paddedWidth = width + BORDER_SIZE * 2;
  56933. var paddedHeight = height + BORDER_SIZE * 2;
  56934. var canvas, tmpCanvas, i, ii;
  56935. if (WebGLUtils.isEnabled) {
  56936. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56937. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56938. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56939. canvas = tmpCanvas.canvas;
  56940. } else {
  56941. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56942. var tmpCtx = tmpCanvas.context;
  56943. var data = tmpCtx.createImageData(width, height);
  56944. if (backgroundColor) {
  56945. var bytes = data.data;
  56946. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56947. bytes[i] = backgroundColor[0];
  56948. bytes[i + 1] = backgroundColor[1];
  56949. bytes[i + 2] = backgroundColor[2];
  56950. bytes[i + 3] = 255;
  56951. }
  56952. }
  56953. for (i = 0; i < figures.length; i++) {
  56954. drawFigure(data, figures[i], context);
  56955. }
  56956. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56957. canvas = tmpCanvas.canvas;
  56958. }
  56959. return {
  56960. canvas: canvas,
  56961. offsetX: offsetX - BORDER_SIZE * scaleX,
  56962. offsetY: offsetY - BORDER_SIZE * scaleY,
  56963. scaleX: scaleX,
  56964. scaleY: scaleY
  56965. };
  56966. }
  56967. return createMeshCanvas;
  56968. }();
  56969. ShadingIRs.Mesh = {
  56970. fromIR: function Mesh_fromIR(raw) {
  56971. var coords = raw[2];
  56972. var colors = raw[3];
  56973. var figures = raw[4];
  56974. var bounds = raw[5];
  56975. var matrix = raw[6];
  56976. var background = raw[8];
  56977. return {
  56978. type: 'Pattern',
  56979. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56980. var scale;
  56981. if (shadingFill) {
  56982. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56983. } else {
  56984. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56985. if (matrix) {
  56986. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56987. scale = [
  56988. scale[0] * matrixScale[0],
  56989. scale[1] * matrixScale[1]
  56990. ];
  56991. }
  56992. }
  56993. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56994. if (!shadingFill) {
  56995. ctx.setTransform.apply(ctx, owner.baseTransform);
  56996. if (matrix) {
  56997. ctx.transform.apply(ctx, matrix);
  56998. }
  56999. }
  57000. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  57001. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  57002. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  57003. }
  57004. };
  57005. }
  57006. };
  57007. ShadingIRs.Dummy = {
  57008. fromIR: function Dummy_fromIR() {
  57009. return {
  57010. type: 'Pattern',
  57011. getPattern: function Dummy_fromIR_getPattern() {
  57012. return 'hotpink';
  57013. }
  57014. };
  57015. }
  57016. };
  57017. function getShadingPatternFromIR(raw) {
  57018. var shadingIR = ShadingIRs[raw[0]];
  57019. if (!shadingIR) {
  57020. error('Unknown IR type: ' + raw[0]);
  57021. }
  57022. return shadingIR.fromIR(raw);
  57023. }
  57024. var TilingPattern = function TilingPatternClosure() {
  57025. var PaintType = {
  57026. COLORED: 1,
  57027. UNCOLORED: 2
  57028. };
  57029. var MAX_PATTERN_SIZE = 3000;
  57030. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  57031. this.operatorList = IR[2];
  57032. this.matrix = IR[3] || [
  57033. 1,
  57034. 0,
  57035. 0,
  57036. 1,
  57037. 0,
  57038. 0
  57039. ];
  57040. this.bbox = IR[4];
  57041. this.xstep = IR[5];
  57042. this.ystep = IR[6];
  57043. this.paintType = IR[7];
  57044. this.tilingType = IR[8];
  57045. this.color = color;
  57046. this.canvasGraphicsFactory = canvasGraphicsFactory;
  57047. this.baseTransform = baseTransform;
  57048. this.type = 'Pattern';
  57049. this.ctx = ctx;
  57050. }
  57051. TilingPattern.prototype = {
  57052. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  57053. var operatorList = this.operatorList;
  57054. var bbox = this.bbox;
  57055. var xstep = this.xstep;
  57056. var ystep = this.ystep;
  57057. var paintType = this.paintType;
  57058. var tilingType = this.tilingType;
  57059. var color = this.color;
  57060. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57061. info('TilingType: ' + tilingType);
  57062. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57063. var topLeft = [
  57064. x0,
  57065. y0
  57066. ];
  57067. var botRight = [
  57068. x0 + xstep,
  57069. y0 + ystep
  57070. ];
  57071. var width = botRight[0] - topLeft[0];
  57072. var height = botRight[1] - topLeft[1];
  57073. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57074. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57075. var combinedScale = [
  57076. matrixScale[0] * curMatrixScale[0],
  57077. matrixScale[1] * curMatrixScale[1]
  57078. ];
  57079. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57080. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57081. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57082. var tmpCtx = tmpCanvas.context;
  57083. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57084. graphics.groupLevel = owner.groupLevel;
  57085. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57086. this.setScale(width, height, xstep, ystep);
  57087. this.transformToScale(graphics);
  57088. var tmpTranslate = [
  57089. 1,
  57090. 0,
  57091. 0,
  57092. 1,
  57093. -topLeft[0],
  57094. -topLeft[1]
  57095. ];
  57096. graphics.transform.apply(graphics, tmpTranslate);
  57097. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57098. graphics.executeOperatorList(operatorList);
  57099. return tmpCanvas.canvas;
  57100. },
  57101. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57102. this.scale = [
  57103. width / xstep,
  57104. height / ystep
  57105. ];
  57106. },
  57107. transformToScale: function TilingPattern_transformToScale(graphics) {
  57108. var scale = this.scale;
  57109. var tmpScale = [
  57110. scale[0],
  57111. 0,
  57112. 0,
  57113. scale[1],
  57114. 0,
  57115. 0
  57116. ];
  57117. graphics.transform.apply(graphics, tmpScale);
  57118. },
  57119. scaleToContext: function TilingPattern_scaleToContext() {
  57120. var scale = this.scale;
  57121. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57122. },
  57123. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57124. if (bbox && isArray(bbox) && bbox.length === 4) {
  57125. var bboxWidth = x1 - x0;
  57126. var bboxHeight = y1 - y0;
  57127. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57128. graphics.clip();
  57129. graphics.endPath();
  57130. }
  57131. },
  57132. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57133. switch (paintType) {
  57134. case PaintType.COLORED:
  57135. var ctx = this.ctx;
  57136. context.fillStyle = ctx.fillStyle;
  57137. context.strokeStyle = ctx.strokeStyle;
  57138. break;
  57139. case PaintType.UNCOLORED:
  57140. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57141. context.fillStyle = cssColor;
  57142. context.strokeStyle = cssColor;
  57143. break;
  57144. default:
  57145. error('Unsupported paint type: ' + paintType);
  57146. }
  57147. },
  57148. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57149. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57150. ctx = this.ctx;
  57151. ctx.setTransform.apply(ctx, this.baseTransform);
  57152. ctx.transform.apply(ctx, this.matrix);
  57153. this.scaleToContext();
  57154. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57155. }
  57156. };
  57157. return TilingPattern;
  57158. }();
  57159. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57160. exports.TilingPattern = TilingPattern;
  57161. /***/ }),
  57162. /* 47 */
  57163. /***/ (function(module, exports, __w_pdfjs_require__) {
  57164. "use strict";
  57165. var pdfjsVersion = '1.7.300';
  57166. var pdfjsBuild = 'cfaa621a';
  57167. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57168. var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
  57169. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57170. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57171. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57172. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57173. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57174. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57175. exports.build = pdfjsDisplayAPI.build;
  57176. exports.version = pdfjsDisplayAPI.version;
  57177. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57178. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57179. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57180. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57181. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57182. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57183. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57184. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57185. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57186. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57187. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57188. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57189. exports.OPS = pdfjsSharedUtil.OPS;
  57190. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57191. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57192. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57193. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57194. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57195. exports.shadow = pdfjsSharedUtil.shadow;
  57196. exports.createBlob = pdfjsSharedUtil.createBlob;
  57197. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57198. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57199. /***/ })
  57200. /******/ ]);
  57201. });