pdf.combined.js 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938
  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. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId])
  34. /******/ return installedModules[moduleId].exports;
  35. /******/
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // identity function for calling harmony imports with the correct context
  61. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  62. /******/
  63. /******/ // define getter function for harmony exports
  64. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  65. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  66. /******/ Object.defineProperty(exports, name, {
  67. /******/ configurable: false,
  68. /******/ enumerable: true,
  69. /******/ get: getter
  70. /******/ });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // getDefaultExport function for compatibility with non-harmony modules
  75. /******/ __w_pdfjs_require__.n = function(module) {
  76. /******/ var getter = module && module.__esModule ?
  77. /******/ function getDefault() { return module['default']; } :
  78. /******/ function getModuleExports() { return module; };
  79. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  80. /******/ return getter;
  81. /******/ };
  82. /******/
  83. /******/ // Object.prototype.hasOwnProperty.call
  84. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  85. /******/
  86. /******/ // __webpack_public_path__
  87. /******/ __w_pdfjs_require__.p = "";
  88. /******/
  89. /******/ // Load entry module and return exports
  90. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 47);
  91. /******/ })
  92. /************************************************************************/
  93. /******/ ([
  94. /* 0 */
  95. /***/ (function(module, exports, __w_pdfjs_require__) {
  96. "use strict";
  97. /* WEBPACK VAR INJECTION */(function(global) {
  98. var compatibility = __w_pdfjs_require__(48);
  99. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  100. var FONT_IDENTITY_MATRIX = [
  101. 0.001,
  102. 0,
  103. 0,
  104. 0.001,
  105. 0,
  106. 0
  107. ];
  108. var TextRenderingMode = {
  109. FILL: 0,
  110. STROKE: 1,
  111. FILL_STROKE: 2,
  112. INVISIBLE: 3,
  113. FILL_ADD_TO_PATH: 4,
  114. STROKE_ADD_TO_PATH: 5,
  115. FILL_STROKE_ADD_TO_PATH: 6,
  116. ADD_TO_PATH: 7,
  117. FILL_STROKE_MASK: 3,
  118. ADD_TO_PATH_FLAG: 4
  119. };
  120. var ImageKind = {
  121. GRAYSCALE_1BPP: 1,
  122. RGB_24BPP: 2,
  123. RGBA_32BPP: 3
  124. };
  125. var AnnotationType = {
  126. TEXT: 1,
  127. LINK: 2,
  128. FREETEXT: 3,
  129. LINE: 4,
  130. SQUARE: 5,
  131. CIRCLE: 6,
  132. POLYGON: 7,
  133. POLYLINE: 8,
  134. HIGHLIGHT: 9,
  135. UNDERLINE: 10,
  136. SQUIGGLY: 11,
  137. STRIKEOUT: 12,
  138. STAMP: 13,
  139. CARET: 14,
  140. INK: 15,
  141. POPUP: 16,
  142. FILEATTACHMENT: 17,
  143. SOUND: 18,
  144. MOVIE: 19,
  145. WIDGET: 20,
  146. SCREEN: 21,
  147. PRINTERMARK: 22,
  148. TRAPNET: 23,
  149. WATERMARK: 24,
  150. THREED: 25,
  151. REDACT: 26
  152. };
  153. var AnnotationFlag = {
  154. INVISIBLE: 0x01,
  155. HIDDEN: 0x02,
  156. PRINT: 0x04,
  157. NOZOOM: 0x08,
  158. NOROTATE: 0x10,
  159. NOVIEW: 0x20,
  160. READONLY: 0x40,
  161. LOCKED: 0x80,
  162. TOGGLENOVIEW: 0x100,
  163. LOCKEDCONTENTS: 0x200
  164. };
  165. var AnnotationFieldFlag = {
  166. READONLY: 0x0000001,
  167. REQUIRED: 0x0000002,
  168. NOEXPORT: 0x0000004,
  169. MULTILINE: 0x0001000,
  170. PASSWORD: 0x0002000,
  171. NOTOGGLETOOFF: 0x0004000,
  172. RADIO: 0x0008000,
  173. PUSHBUTTON: 0x0010000,
  174. COMBO: 0x0020000,
  175. EDIT: 0x0040000,
  176. SORT: 0x0080000,
  177. FILESELECT: 0x0100000,
  178. MULTISELECT: 0x0200000,
  179. DONOTSPELLCHECK: 0x0400000,
  180. DONOTSCROLL: 0x0800000,
  181. COMB: 0x1000000,
  182. RICHTEXT: 0x2000000,
  183. RADIOSINUNISON: 0x2000000,
  184. COMMITONSELCHANGE: 0x4000000
  185. };
  186. var AnnotationBorderStyleType = {
  187. SOLID: 1,
  188. DASHED: 2,
  189. BEVELED: 3,
  190. INSET: 4,
  191. UNDERLINE: 5
  192. };
  193. var StreamType = {
  194. UNKNOWN: 0,
  195. FLATE: 1,
  196. LZW: 2,
  197. DCT: 3,
  198. JPX: 4,
  199. JBIG: 5,
  200. A85: 6,
  201. AHX: 7,
  202. CCF: 8,
  203. RL: 9
  204. };
  205. var FontType = {
  206. UNKNOWN: 0,
  207. TYPE1: 1,
  208. TYPE1C: 2,
  209. CIDFONTTYPE0: 3,
  210. CIDFONTTYPE0C: 4,
  211. TRUETYPE: 5,
  212. CIDFONTTYPE2: 6,
  213. TYPE3: 7,
  214. OPENTYPE: 8,
  215. TYPE0: 9,
  216. MMTYPE1: 10
  217. };
  218. var VERBOSITY_LEVELS = {
  219. errors: 0,
  220. warnings: 1,
  221. infos: 5
  222. };
  223. var CMapCompressionType = {
  224. NONE: 0,
  225. BINARY: 1,
  226. STREAM: 2
  227. };
  228. var OPS = {
  229. dependency: 1,
  230. setLineWidth: 2,
  231. setLineCap: 3,
  232. setLineJoin: 4,
  233. setMiterLimit: 5,
  234. setDash: 6,
  235. setRenderingIntent: 7,
  236. setFlatness: 8,
  237. setGState: 9,
  238. save: 10,
  239. restore: 11,
  240. transform: 12,
  241. moveTo: 13,
  242. lineTo: 14,
  243. curveTo: 15,
  244. curveTo2: 16,
  245. curveTo3: 17,
  246. closePath: 18,
  247. rectangle: 19,
  248. stroke: 20,
  249. closeStroke: 21,
  250. fill: 22,
  251. eoFill: 23,
  252. fillStroke: 24,
  253. eoFillStroke: 25,
  254. closeFillStroke: 26,
  255. closeEOFillStroke: 27,
  256. endPath: 28,
  257. clip: 29,
  258. eoClip: 30,
  259. beginText: 31,
  260. endText: 32,
  261. setCharSpacing: 33,
  262. setWordSpacing: 34,
  263. setHScale: 35,
  264. setLeading: 36,
  265. setFont: 37,
  266. setTextRenderingMode: 38,
  267. setTextRise: 39,
  268. moveText: 40,
  269. setLeadingMoveText: 41,
  270. setTextMatrix: 42,
  271. nextLine: 43,
  272. showText: 44,
  273. showSpacedText: 45,
  274. nextLineShowText: 46,
  275. nextLineSetSpacingShowText: 47,
  276. setCharWidth: 48,
  277. setCharWidthAndBounds: 49,
  278. setStrokeColorSpace: 50,
  279. setFillColorSpace: 51,
  280. setStrokeColor: 52,
  281. setStrokeColorN: 53,
  282. setFillColor: 54,
  283. setFillColorN: 55,
  284. setStrokeGray: 56,
  285. setFillGray: 57,
  286. setStrokeRGBColor: 58,
  287. setFillRGBColor: 59,
  288. setStrokeCMYKColor: 60,
  289. setFillCMYKColor: 61,
  290. shadingFill: 62,
  291. beginInlineImage: 63,
  292. beginImageData: 64,
  293. endInlineImage: 65,
  294. paintXObject: 66,
  295. markPoint: 67,
  296. markPointProps: 68,
  297. beginMarkedContent: 69,
  298. beginMarkedContentProps: 70,
  299. endMarkedContent: 71,
  300. beginCompat: 72,
  301. endCompat: 73,
  302. paintFormXObjectBegin: 74,
  303. paintFormXObjectEnd: 75,
  304. beginGroup: 76,
  305. endGroup: 77,
  306. beginAnnotations: 78,
  307. endAnnotations: 79,
  308. beginAnnotation: 80,
  309. endAnnotation: 81,
  310. paintJpegXObject: 82,
  311. paintImageMaskXObject: 83,
  312. paintImageMaskXObjectGroup: 84,
  313. paintImageXObject: 85,
  314. paintInlineImageXObject: 86,
  315. paintInlineImageXObjectGroup: 87,
  316. paintImageXObjectRepeat: 88,
  317. paintImageMaskXObjectRepeat: 89,
  318. paintSolidColorImageMask: 90,
  319. constructPath: 91
  320. };
  321. var verbosity = VERBOSITY_LEVELS.warnings;
  322. function setVerbosityLevel(level) {
  323. verbosity = level;
  324. }
  325. function getVerbosityLevel() {
  326. return verbosity;
  327. }
  328. function info(msg) {
  329. if (verbosity >= VERBOSITY_LEVELS.infos) {
  330. console.log('Info: ' + msg);
  331. }
  332. }
  333. function warn(msg) {
  334. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  335. console.log('Warning: ' + msg);
  336. }
  337. }
  338. function deprecated(details) {
  339. console.log('Deprecated API usage: ' + details);
  340. }
  341. function error(msg) {
  342. if (verbosity >= VERBOSITY_LEVELS.errors) {
  343. console.log('Error: ' + msg);
  344. console.log(backtrace());
  345. }
  346. throw new Error(msg);
  347. }
  348. function backtrace() {
  349. try {
  350. throw new Error();
  351. } catch (e) {
  352. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  353. }
  354. }
  355. function assert(cond, msg) {
  356. if (!cond) {
  357. error(msg);
  358. }
  359. }
  360. var UNSUPPORTED_FEATURES = {
  361. unknown: 'unknown',
  362. forms: 'forms',
  363. javaScript: 'javaScript',
  364. smask: 'smask',
  365. shadingPattern: 'shadingPattern',
  366. font: 'font'
  367. };
  368. function isSameOrigin(baseUrl, otherUrl) {
  369. try {
  370. var base = new URL(baseUrl);
  371. if (!base.origin || base.origin === 'null') {
  372. return false;
  373. }
  374. } catch (e) {
  375. return false;
  376. }
  377. var other = new URL(otherUrl, base);
  378. return base.origin === other.origin;
  379. }
  380. function isValidProtocol(url) {
  381. if (!url) {
  382. return false;
  383. }
  384. switch (url.protocol) {
  385. case 'http:':
  386. case 'https:':
  387. case 'ftp:':
  388. case 'mailto:':
  389. case 'tel:':
  390. return true;
  391. default:
  392. return false;
  393. }
  394. }
  395. function createValidAbsoluteUrl(url, baseUrl) {
  396. if (!url) {
  397. return null;
  398. }
  399. try {
  400. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  401. if (isValidProtocol(absoluteUrl)) {
  402. return absoluteUrl;
  403. }
  404. } catch (ex) {
  405. }
  406. return null;
  407. }
  408. function shadow(obj, prop, value) {
  409. Object.defineProperty(obj, prop, {
  410. value: value,
  411. enumerable: true,
  412. configurable: true,
  413. writable: false
  414. });
  415. return value;
  416. }
  417. function getLookupTableFactory(initializer) {
  418. var lookup;
  419. return function () {
  420. if (initializer) {
  421. lookup = Object.create(null);
  422. initializer(lookup);
  423. initializer = null;
  424. }
  425. return lookup;
  426. };
  427. }
  428. var PasswordResponses = {
  429. NEED_PASSWORD: 1,
  430. INCORRECT_PASSWORD: 2
  431. };
  432. var PasswordException = function PasswordExceptionClosure() {
  433. function PasswordException(msg, code) {
  434. this.name = 'PasswordException';
  435. this.message = msg;
  436. this.code = code;
  437. }
  438. PasswordException.prototype = new Error();
  439. PasswordException.constructor = PasswordException;
  440. return PasswordException;
  441. }();
  442. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  443. function UnknownErrorException(msg, details) {
  444. this.name = 'UnknownErrorException';
  445. this.message = msg;
  446. this.details = details;
  447. }
  448. UnknownErrorException.prototype = new Error();
  449. UnknownErrorException.constructor = UnknownErrorException;
  450. return UnknownErrorException;
  451. }();
  452. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  453. function InvalidPDFException(msg) {
  454. this.name = 'InvalidPDFException';
  455. this.message = msg;
  456. }
  457. InvalidPDFException.prototype = new Error();
  458. InvalidPDFException.constructor = InvalidPDFException;
  459. return InvalidPDFException;
  460. }();
  461. var MissingPDFException = function MissingPDFExceptionClosure() {
  462. function MissingPDFException(msg) {
  463. this.name = 'MissingPDFException';
  464. this.message = msg;
  465. }
  466. MissingPDFException.prototype = new Error();
  467. MissingPDFException.constructor = MissingPDFException;
  468. return MissingPDFException;
  469. }();
  470. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  471. function UnexpectedResponseException(msg, status) {
  472. this.name = 'UnexpectedResponseException';
  473. this.message = msg;
  474. this.status = status;
  475. }
  476. UnexpectedResponseException.prototype = new Error();
  477. UnexpectedResponseException.constructor = UnexpectedResponseException;
  478. return UnexpectedResponseException;
  479. }();
  480. var NotImplementedException = function NotImplementedExceptionClosure() {
  481. function NotImplementedException(msg) {
  482. this.message = msg;
  483. }
  484. NotImplementedException.prototype = new Error();
  485. NotImplementedException.prototype.name = 'NotImplementedException';
  486. NotImplementedException.constructor = NotImplementedException;
  487. return NotImplementedException;
  488. }();
  489. var MissingDataException = function MissingDataExceptionClosure() {
  490. function MissingDataException(begin, end) {
  491. this.begin = begin;
  492. this.end = end;
  493. this.message = 'Missing data [' + begin + ', ' + end + ')';
  494. }
  495. MissingDataException.prototype = new Error();
  496. MissingDataException.prototype.name = 'MissingDataException';
  497. MissingDataException.constructor = MissingDataException;
  498. return MissingDataException;
  499. }();
  500. var XRefParseException = function XRefParseExceptionClosure() {
  501. function XRefParseException(msg) {
  502. this.message = msg;
  503. }
  504. XRefParseException.prototype = new Error();
  505. XRefParseException.prototype.name = 'XRefParseException';
  506. XRefParseException.constructor = XRefParseException;
  507. return XRefParseException;
  508. }();
  509. var NullCharactersRegExp = /\x00/g;
  510. function removeNullCharacters(str) {
  511. if (typeof str !== 'string') {
  512. warn('The argument for removeNullCharacters must be a string.');
  513. return str;
  514. }
  515. return str.replace(NullCharactersRegExp, '');
  516. }
  517. function bytesToString(bytes) {
  518. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  519. var length = bytes.length;
  520. var MAX_ARGUMENT_COUNT = 8192;
  521. if (length < MAX_ARGUMENT_COUNT) {
  522. return String.fromCharCode.apply(null, bytes);
  523. }
  524. var strBuf = [];
  525. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  526. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  527. var chunk = bytes.subarray(i, chunkEnd);
  528. strBuf.push(String.fromCharCode.apply(null, chunk));
  529. }
  530. return strBuf.join('');
  531. }
  532. function stringToBytes(str) {
  533. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  534. var length = str.length;
  535. var bytes = new Uint8Array(length);
  536. for (var i = 0; i < length; ++i) {
  537. bytes[i] = str.charCodeAt(i) & 0xFF;
  538. }
  539. return bytes;
  540. }
  541. function arrayByteLength(arr) {
  542. if (arr.length !== undefined) {
  543. return arr.length;
  544. }
  545. assert(arr.byteLength !== undefined);
  546. return arr.byteLength;
  547. }
  548. function arraysToBytes(arr) {
  549. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  550. return arr[0];
  551. }
  552. var resultLength = 0;
  553. var i, ii = arr.length;
  554. var item, itemLength;
  555. for (i = 0; i < ii; i++) {
  556. item = arr[i];
  557. itemLength = arrayByteLength(item);
  558. resultLength += itemLength;
  559. }
  560. var pos = 0;
  561. var data = new Uint8Array(resultLength);
  562. for (i = 0; i < ii; i++) {
  563. item = arr[i];
  564. if (!(item instanceof Uint8Array)) {
  565. if (typeof item === 'string') {
  566. item = stringToBytes(item);
  567. } else {
  568. item = new Uint8Array(item);
  569. }
  570. }
  571. itemLength = item.byteLength;
  572. data.set(item, pos);
  573. pos += itemLength;
  574. }
  575. return data;
  576. }
  577. function string32(value) {
  578. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  579. }
  580. function log2(x) {
  581. var n = 1, i = 0;
  582. while (x > n) {
  583. n <<= 1;
  584. i++;
  585. }
  586. return i;
  587. }
  588. function readInt8(data, start) {
  589. return data[start] << 24 >> 24;
  590. }
  591. function readUint16(data, offset) {
  592. return data[offset] << 8 | data[offset + 1];
  593. }
  594. function readUint32(data, offset) {
  595. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  596. }
  597. function isLittleEndian() {
  598. var buffer8 = new Uint8Array(2);
  599. buffer8[0] = 1;
  600. var buffer16 = new Uint16Array(buffer8.buffer);
  601. return buffer16[0] === 1;
  602. }
  603. function isEvalSupported() {
  604. try {
  605. new Function('');
  606. return true;
  607. } catch (e) {
  608. return false;
  609. }
  610. }
  611. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  612. function Uint32ArrayView(buffer, length) {
  613. this.buffer = buffer;
  614. this.byteLength = buffer.length;
  615. this.length = length === undefined ? this.byteLength >> 2 : length;
  616. ensureUint32ArrayViewProps(this.length);
  617. }
  618. Uint32ArrayView.prototype = Object.create(null);
  619. var uint32ArrayViewSetters = 0;
  620. function createUint32ArrayProp(index) {
  621. return {
  622. get: function () {
  623. var buffer = this.buffer, offset = index << 2;
  624. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  625. },
  626. set: function (value) {
  627. var buffer = this.buffer, offset = index << 2;
  628. buffer[offset] = value & 255;
  629. buffer[offset + 1] = value >> 8 & 255;
  630. buffer[offset + 2] = value >> 16 & 255;
  631. buffer[offset + 3] = value >>> 24 & 255;
  632. }
  633. };
  634. }
  635. function ensureUint32ArrayViewProps(length) {
  636. while (uint32ArrayViewSetters < length) {
  637. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  638. uint32ArrayViewSetters++;
  639. }
  640. }
  641. return Uint32ArrayView;
  642. }();
  643. exports.Uint32ArrayView = Uint32ArrayView;
  644. var IDENTITY_MATRIX = [
  645. 1,
  646. 0,
  647. 0,
  648. 1,
  649. 0,
  650. 0
  651. ];
  652. var Util = function UtilClosure() {
  653. function Util() {
  654. }
  655. var rgbBuf = [
  656. 'rgb(',
  657. 0,
  658. ',',
  659. 0,
  660. ',',
  661. 0,
  662. ')'
  663. ];
  664. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  665. rgbBuf[1] = r;
  666. rgbBuf[3] = g;
  667. rgbBuf[5] = b;
  668. return rgbBuf.join('');
  669. };
  670. Util.transform = function Util_transform(m1, m2) {
  671. return [
  672. m1[0] * m2[0] + m1[2] * m2[1],
  673. m1[1] * m2[0] + m1[3] * m2[1],
  674. m1[0] * m2[2] + m1[2] * m2[3],
  675. m1[1] * m2[2] + m1[3] * m2[3],
  676. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  677. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  678. ];
  679. };
  680. Util.applyTransform = function Util_applyTransform(p, m) {
  681. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  682. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  683. return [
  684. xt,
  685. yt
  686. ];
  687. };
  688. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  689. var d = m[0] * m[3] - m[1] * m[2];
  690. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  691. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  692. return [
  693. xt,
  694. yt
  695. ];
  696. };
  697. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  698. var p1 = Util.applyTransform(r, m);
  699. var p2 = Util.applyTransform(r.slice(2, 4), m);
  700. var p3 = Util.applyTransform([
  701. r[0],
  702. r[3]
  703. ], m);
  704. var p4 = Util.applyTransform([
  705. r[2],
  706. r[1]
  707. ], m);
  708. return [
  709. Math.min(p1[0], p2[0], p3[0], p4[0]),
  710. Math.min(p1[1], p2[1], p3[1], p4[1]),
  711. Math.max(p1[0], p2[0], p3[0], p4[0]),
  712. Math.max(p1[1], p2[1], p3[1], p4[1])
  713. ];
  714. };
  715. Util.inverseTransform = function Util_inverseTransform(m) {
  716. var d = m[0] * m[3] - m[1] * m[2];
  717. return [
  718. m[3] / d,
  719. -m[1] / d,
  720. -m[2] / d,
  721. m[0] / d,
  722. (m[2] * m[5] - m[4] * m[3]) / d,
  723. (m[4] * m[1] - m[5] * m[0]) / d
  724. ];
  725. };
  726. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  727. return [
  728. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  729. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  730. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  731. ];
  732. };
  733. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  734. var transpose = [
  735. m[0],
  736. m[2],
  737. m[1],
  738. m[3]
  739. ];
  740. var a = m[0] * transpose[0] + m[1] * transpose[2];
  741. var b = m[0] * transpose[1] + m[1] * transpose[3];
  742. var c = m[2] * transpose[0] + m[3] * transpose[2];
  743. var d = m[2] * transpose[1] + m[3] * transpose[3];
  744. var first = (a + d) / 2;
  745. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  746. var sx = first + second || 1;
  747. var sy = first - second || 1;
  748. return [
  749. Math.sqrt(sx),
  750. Math.sqrt(sy)
  751. ];
  752. };
  753. Util.normalizeRect = function Util_normalizeRect(rect) {
  754. var r = rect.slice(0);
  755. if (rect[0] > rect[2]) {
  756. r[0] = rect[2];
  757. r[2] = rect[0];
  758. }
  759. if (rect[1] > rect[3]) {
  760. r[1] = rect[3];
  761. r[3] = rect[1];
  762. }
  763. return r;
  764. };
  765. Util.intersect = function Util_intersect(rect1, rect2) {
  766. function compare(a, b) {
  767. return a - b;
  768. }
  769. var orderedX = [
  770. rect1[0],
  771. rect1[2],
  772. rect2[0],
  773. rect2[2]
  774. ].sort(compare), orderedY = [
  775. rect1[1],
  776. rect1[3],
  777. rect2[1],
  778. rect2[3]
  779. ].sort(compare), result = [];
  780. rect1 = Util.normalizeRect(rect1);
  781. rect2 = Util.normalizeRect(rect2);
  782. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  783. result[0] = orderedX[1];
  784. result[2] = orderedX[2];
  785. } else {
  786. return false;
  787. }
  788. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  789. result[1] = orderedY[1];
  790. result[3] = orderedY[2];
  791. } else {
  792. return false;
  793. }
  794. return result;
  795. };
  796. Util.sign = function Util_sign(num) {
  797. return num < 0 ? -1 : 1;
  798. };
  799. var ROMAN_NUMBER_MAP = [
  800. '',
  801. 'C',
  802. 'CC',
  803. 'CCC',
  804. 'CD',
  805. 'D',
  806. 'DC',
  807. 'DCC',
  808. 'DCCC',
  809. 'CM',
  810. '',
  811. 'X',
  812. 'XX',
  813. 'XXX',
  814. 'XL',
  815. 'L',
  816. 'LX',
  817. 'LXX',
  818. 'LXXX',
  819. 'XC',
  820. '',
  821. 'I',
  822. 'II',
  823. 'III',
  824. 'IV',
  825. 'V',
  826. 'VI',
  827. 'VII',
  828. 'VIII',
  829. 'IX'
  830. ];
  831. Util.toRoman = function Util_toRoman(number, lowerCase) {
  832. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  833. var pos, romanBuf = [];
  834. while (number >= 1000) {
  835. number -= 1000;
  836. romanBuf.push('M');
  837. }
  838. pos = number / 100 | 0;
  839. number %= 100;
  840. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  841. pos = number / 10 | 0;
  842. number %= 10;
  843. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  844. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  845. var romanStr = romanBuf.join('');
  846. return lowerCase ? romanStr.toLowerCase() : romanStr;
  847. };
  848. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  849. Array.prototype.push.apply(arr1, arr2);
  850. };
  851. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  852. Array.prototype.unshift.apply(arr1, arr2);
  853. };
  854. Util.extendObj = function extendObj(obj1, obj2) {
  855. for (var key in obj2) {
  856. obj1[key] = obj2[key];
  857. }
  858. };
  859. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  860. while (dict && !dict.has(name)) {
  861. dict = dict.get('Parent');
  862. }
  863. if (!dict) {
  864. return null;
  865. }
  866. return getArray ? dict.getArray(name) : dict.get(name);
  867. };
  868. Util.inherit = function Util_inherit(sub, base, prototype) {
  869. sub.prototype = Object.create(base.prototype);
  870. sub.prototype.constructor = sub;
  871. for (var prop in prototype) {
  872. sub.prototype[prop] = prototype[prop];
  873. }
  874. };
  875. Util.loadScript = function Util_loadScript(src, callback) {
  876. var script = document.createElement('script');
  877. var loaded = false;
  878. script.setAttribute('src', src);
  879. if (callback) {
  880. script.onload = function () {
  881. if (!loaded) {
  882. callback();
  883. }
  884. loaded = true;
  885. };
  886. }
  887. document.getElementsByTagName('head')[0].appendChild(script);
  888. };
  889. return Util;
  890. }();
  891. var PageViewport = function PageViewportClosure() {
  892. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  893. this.viewBox = viewBox;
  894. this.scale = scale;
  895. this.rotation = rotation;
  896. this.offsetX = offsetX;
  897. this.offsetY = offsetY;
  898. var centerX = (viewBox[2] + viewBox[0]) / 2;
  899. var centerY = (viewBox[3] + viewBox[1]) / 2;
  900. var rotateA, rotateB, rotateC, rotateD;
  901. rotation = rotation % 360;
  902. rotation = rotation < 0 ? rotation + 360 : rotation;
  903. switch (rotation) {
  904. case 180:
  905. rotateA = -1;
  906. rotateB = 0;
  907. rotateC = 0;
  908. rotateD = 1;
  909. break;
  910. case 90:
  911. rotateA = 0;
  912. rotateB = 1;
  913. rotateC = 1;
  914. rotateD = 0;
  915. break;
  916. case 270:
  917. rotateA = 0;
  918. rotateB = -1;
  919. rotateC = -1;
  920. rotateD = 0;
  921. break;
  922. default:
  923. rotateA = 1;
  924. rotateB = 0;
  925. rotateC = 0;
  926. rotateD = -1;
  927. break;
  928. }
  929. if (dontFlip) {
  930. rotateC = -rotateC;
  931. rotateD = -rotateD;
  932. }
  933. var offsetCanvasX, offsetCanvasY;
  934. var width, height;
  935. if (rotateA === 0) {
  936. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  937. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  938. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  939. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  940. } else {
  941. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  942. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  943. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  944. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  945. }
  946. this.transform = [
  947. rotateA * scale,
  948. rotateB * scale,
  949. rotateC * scale,
  950. rotateD * scale,
  951. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  952. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  953. ];
  954. this.width = width;
  955. this.height = height;
  956. this.fontScale = scale;
  957. }
  958. PageViewport.prototype = {
  959. clone: function PageViewPort_clone(args) {
  960. args = args || {};
  961. var scale = 'scale' in args ? args.scale : this.scale;
  962. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  963. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  964. },
  965. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  966. return Util.applyTransform([
  967. x,
  968. y
  969. ], this.transform);
  970. },
  971. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  972. var tl = Util.applyTransform([
  973. rect[0],
  974. rect[1]
  975. ], this.transform);
  976. var br = Util.applyTransform([
  977. rect[2],
  978. rect[3]
  979. ], this.transform);
  980. return [
  981. tl[0],
  982. tl[1],
  983. br[0],
  984. br[1]
  985. ];
  986. },
  987. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  988. return Util.applyInverseTransform([
  989. x,
  990. y
  991. ], this.transform);
  992. }
  993. };
  994. return PageViewport;
  995. }();
  996. var PDFStringTranslateTable = [
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0,
  1007. 0,
  1008. 0,
  1009. 0,
  1010. 0,
  1011. 0,
  1012. 0,
  1013. 0,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0x2D8,
  1022. 0x2C7,
  1023. 0x2C6,
  1024. 0x2D9,
  1025. 0x2DD,
  1026. 0x2DB,
  1027. 0x2DA,
  1028. 0x2DC,
  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. 0,
  1110. 0,
  1111. 0,
  1112. 0,
  1113. 0,
  1114. 0,
  1115. 0,
  1116. 0,
  1117. 0,
  1118. 0,
  1119. 0,
  1120. 0,
  1121. 0,
  1122. 0,
  1123. 0,
  1124. 0,
  1125. 0x2022,
  1126. 0x2020,
  1127. 0x2021,
  1128. 0x2026,
  1129. 0x2014,
  1130. 0x2013,
  1131. 0x192,
  1132. 0x2044,
  1133. 0x2039,
  1134. 0x203A,
  1135. 0x2212,
  1136. 0x2030,
  1137. 0x201E,
  1138. 0x201C,
  1139. 0x201D,
  1140. 0x2018,
  1141. 0x2019,
  1142. 0x201A,
  1143. 0x2122,
  1144. 0xFB01,
  1145. 0xFB02,
  1146. 0x141,
  1147. 0x152,
  1148. 0x160,
  1149. 0x178,
  1150. 0x17D,
  1151. 0x131,
  1152. 0x142,
  1153. 0x153,
  1154. 0x161,
  1155. 0x17E,
  1156. 0,
  1157. 0x20AC
  1158. ];
  1159. function stringToPDFString(str) {
  1160. var i, n = str.length, strBuf = [];
  1161. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1162. for (i = 2; i < n; i += 2) {
  1163. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1164. }
  1165. } else {
  1166. for (i = 0; i < n; ++i) {
  1167. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1168. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1169. }
  1170. }
  1171. return strBuf.join('');
  1172. }
  1173. function stringToUTF8String(str) {
  1174. return decodeURIComponent(escape(str));
  1175. }
  1176. function utf8StringToString(str) {
  1177. return unescape(encodeURIComponent(str));
  1178. }
  1179. function isEmptyObj(obj) {
  1180. for (var key in obj) {
  1181. return false;
  1182. }
  1183. return true;
  1184. }
  1185. function isBool(v) {
  1186. return typeof v === 'boolean';
  1187. }
  1188. function isInt(v) {
  1189. return typeof v === 'number' && (v | 0) === v;
  1190. }
  1191. function isNum(v) {
  1192. return typeof v === 'number';
  1193. }
  1194. function isString(v) {
  1195. return typeof v === 'string';
  1196. }
  1197. function isArray(v) {
  1198. return v instanceof Array;
  1199. }
  1200. function isArrayBuffer(v) {
  1201. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1202. }
  1203. function isSpace(ch) {
  1204. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1205. }
  1206. function isNodeJS() {
  1207. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1208. return typeof process === 'object' && process + '' === '[object process]';
  1209. }
  1210. return false;
  1211. }
  1212. function createPromiseCapability() {
  1213. var capability = {};
  1214. capability.promise = new Promise(function (resolve, reject) {
  1215. capability.resolve = resolve;
  1216. capability.reject = reject;
  1217. });
  1218. return capability;
  1219. }
  1220. var StatTimer = function StatTimerClosure() {
  1221. function rpad(str, pad, length) {
  1222. while (str.length < length) {
  1223. str += pad;
  1224. }
  1225. return str;
  1226. }
  1227. function StatTimer() {
  1228. this.started = Object.create(null);
  1229. this.times = [];
  1230. this.enabled = true;
  1231. }
  1232. StatTimer.prototype = {
  1233. time: function StatTimer_time(name) {
  1234. if (!this.enabled) {
  1235. return;
  1236. }
  1237. if (name in this.started) {
  1238. warn('Timer is already running for ' + name);
  1239. }
  1240. this.started[name] = Date.now();
  1241. },
  1242. timeEnd: function StatTimer_timeEnd(name) {
  1243. if (!this.enabled) {
  1244. return;
  1245. }
  1246. if (!(name in this.started)) {
  1247. warn('Timer has not been started for ' + name);
  1248. }
  1249. this.times.push({
  1250. 'name': name,
  1251. 'start': this.started[name],
  1252. 'end': Date.now()
  1253. });
  1254. delete this.started[name];
  1255. },
  1256. toString: function StatTimer_toString() {
  1257. var i, ii;
  1258. var times = this.times;
  1259. var out = '';
  1260. var longest = 0;
  1261. for (i = 0, ii = times.length; i < ii; ++i) {
  1262. var name = times[i]['name'];
  1263. if (name.length > longest) {
  1264. longest = name.length;
  1265. }
  1266. }
  1267. for (i = 0, ii = times.length; i < ii; ++i) {
  1268. var span = times[i];
  1269. var duration = span.end - span.start;
  1270. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1271. }
  1272. return out;
  1273. }
  1274. };
  1275. return StatTimer;
  1276. }();
  1277. var createBlob = function createBlob(data, contentType) {
  1278. if (typeof Blob !== 'undefined') {
  1279. return new Blob([data], { type: contentType });
  1280. }
  1281. warn('The "Blob" constructor is not supported.');
  1282. };
  1283. var createObjectURL = function createObjectURLClosure() {
  1284. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1285. return function createObjectURL(data, contentType, forceDataSchema) {
  1286. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1287. var blob = createBlob(data, contentType);
  1288. return URL.createObjectURL(blob);
  1289. }
  1290. var buffer = 'data:' + contentType + ';base64,';
  1291. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1292. var b1 = data[i] & 0xFF;
  1293. var b2 = data[i + 1] & 0xFF;
  1294. var b3 = data[i + 2] & 0xFF;
  1295. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1296. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1297. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1298. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1299. }
  1300. return buffer;
  1301. };
  1302. }();
  1303. function MessageHandler(sourceName, targetName, comObj) {
  1304. this.sourceName = sourceName;
  1305. this.targetName = targetName;
  1306. this.comObj = comObj;
  1307. this.callbackIndex = 1;
  1308. this.postMessageTransfers = true;
  1309. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1310. var ah = this.actionHandler = Object.create(null);
  1311. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1312. var data = event.data;
  1313. if (data.targetName !== this.sourceName) {
  1314. return;
  1315. }
  1316. if (data.isReply) {
  1317. var callbackId = data.callbackId;
  1318. if (data.callbackId in callbacksCapabilities) {
  1319. var callback = callbacksCapabilities[callbackId];
  1320. delete callbacksCapabilities[callbackId];
  1321. if ('error' in data) {
  1322. callback.reject(data.error);
  1323. } else {
  1324. callback.resolve(data.data);
  1325. }
  1326. } else {
  1327. error('Cannot resolve callback ' + callbackId);
  1328. }
  1329. } else if (data.action in ah) {
  1330. var action = ah[data.action];
  1331. if (data.callbackId) {
  1332. var sourceName = this.sourceName;
  1333. var targetName = data.sourceName;
  1334. Promise.resolve().then(function () {
  1335. return action[0].call(action[1], data.data);
  1336. }).then(function (result) {
  1337. comObj.postMessage({
  1338. sourceName: sourceName,
  1339. targetName: targetName,
  1340. isReply: true,
  1341. callbackId: data.callbackId,
  1342. data: result
  1343. });
  1344. }, function (reason) {
  1345. if (reason instanceof Error) {
  1346. reason = reason + '';
  1347. }
  1348. comObj.postMessage({
  1349. sourceName: sourceName,
  1350. targetName: targetName,
  1351. isReply: true,
  1352. callbackId: data.callbackId,
  1353. error: reason
  1354. });
  1355. });
  1356. } else {
  1357. action[0].call(action[1], data.data);
  1358. }
  1359. } else {
  1360. error('Unknown action from worker: ' + data.action);
  1361. }
  1362. }.bind(this);
  1363. comObj.addEventListener('message', this._onComObjOnMessage);
  1364. }
  1365. MessageHandler.prototype = {
  1366. on: function messageHandlerOn(actionName, handler, scope) {
  1367. var ah = this.actionHandler;
  1368. if (ah[actionName]) {
  1369. error('There is already an actionName called "' + actionName + '"');
  1370. }
  1371. ah[actionName] = [
  1372. handler,
  1373. scope
  1374. ];
  1375. },
  1376. send: function messageHandlerSend(actionName, data, transfers) {
  1377. var message = {
  1378. sourceName: this.sourceName,
  1379. targetName: this.targetName,
  1380. action: actionName,
  1381. data: data
  1382. };
  1383. this.postMessage(message, transfers);
  1384. },
  1385. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1386. var callbackId = this.callbackIndex++;
  1387. var message = {
  1388. sourceName: this.sourceName,
  1389. targetName: this.targetName,
  1390. action: actionName,
  1391. data: data,
  1392. callbackId: callbackId
  1393. };
  1394. var capability = createPromiseCapability();
  1395. this.callbacksCapabilities[callbackId] = capability;
  1396. try {
  1397. this.postMessage(message, transfers);
  1398. } catch (e) {
  1399. capability.reject(e);
  1400. }
  1401. return capability.promise;
  1402. },
  1403. postMessage: function (message, transfers) {
  1404. if (transfers && this.postMessageTransfers) {
  1405. this.comObj.postMessage(message, transfers);
  1406. } else {
  1407. this.comObj.postMessage(message);
  1408. }
  1409. },
  1410. destroy: function () {
  1411. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1412. }
  1413. };
  1414. function loadJpegStream(id, imageUrl, objs) {
  1415. var img = new Image();
  1416. img.onload = function loadJpegStream_onloadClosure() {
  1417. objs.resolve(id, img);
  1418. };
  1419. img.onerror = function loadJpegStream_onerrorClosure() {
  1420. objs.resolve(id, null);
  1421. warn('Error during JPEG image loading');
  1422. };
  1423. img.src = imageUrl;
  1424. }
  1425. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1426. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1427. exports.OPS = OPS;
  1428. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1429. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1430. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1431. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1432. exports.AnnotationFlag = AnnotationFlag;
  1433. exports.AnnotationType = AnnotationType;
  1434. exports.FontType = FontType;
  1435. exports.ImageKind = ImageKind;
  1436. exports.CMapCompressionType = CMapCompressionType;
  1437. exports.InvalidPDFException = InvalidPDFException;
  1438. exports.MessageHandler = MessageHandler;
  1439. exports.MissingDataException = MissingDataException;
  1440. exports.MissingPDFException = MissingPDFException;
  1441. exports.NotImplementedException = NotImplementedException;
  1442. exports.PageViewport = PageViewport;
  1443. exports.PasswordException = PasswordException;
  1444. exports.PasswordResponses = PasswordResponses;
  1445. exports.StatTimer = StatTimer;
  1446. exports.StreamType = StreamType;
  1447. exports.TextRenderingMode = TextRenderingMode;
  1448. exports.UnexpectedResponseException = UnexpectedResponseException;
  1449. exports.UnknownErrorException = UnknownErrorException;
  1450. exports.Util = Util;
  1451. exports.XRefParseException = XRefParseException;
  1452. exports.arrayByteLength = arrayByteLength;
  1453. exports.arraysToBytes = arraysToBytes;
  1454. exports.assert = assert;
  1455. exports.bytesToString = bytesToString;
  1456. exports.createBlob = createBlob;
  1457. exports.createPromiseCapability = createPromiseCapability;
  1458. exports.createObjectURL = createObjectURL;
  1459. exports.deprecated = deprecated;
  1460. exports.error = error;
  1461. exports.getLookupTableFactory = getLookupTableFactory;
  1462. exports.getVerbosityLevel = getVerbosityLevel;
  1463. exports.globalScope = globalScope;
  1464. exports.info = info;
  1465. exports.isArray = isArray;
  1466. exports.isArrayBuffer = isArrayBuffer;
  1467. exports.isBool = isBool;
  1468. exports.isEmptyObj = isEmptyObj;
  1469. exports.isInt = isInt;
  1470. exports.isNum = isNum;
  1471. exports.isString = isString;
  1472. exports.isSpace = isSpace;
  1473. exports.isNodeJS = isNodeJS;
  1474. exports.isSameOrigin = isSameOrigin;
  1475. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1476. exports.isLittleEndian = isLittleEndian;
  1477. exports.isEvalSupported = isEvalSupported;
  1478. exports.loadJpegStream = loadJpegStream;
  1479. exports.log2 = log2;
  1480. exports.readInt8 = readInt8;
  1481. exports.readUint16 = readUint16;
  1482. exports.readUint32 = readUint32;
  1483. exports.removeNullCharacters = removeNullCharacters;
  1484. exports.setVerbosityLevel = setVerbosityLevel;
  1485. exports.shadow = shadow;
  1486. exports.string32 = string32;
  1487. exports.stringToBytes = stringToBytes;
  1488. exports.stringToPDFString = stringToPDFString;
  1489. exports.stringToUTF8String = stringToUTF8String;
  1490. exports.utf8StringToString = utf8StringToString;
  1491. exports.warn = warn;
  1492. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  1493. /***/ }),
  1494. /* 1 */
  1495. /***/ (function(module, exports, __w_pdfjs_require__) {
  1496. "use strict";
  1497. var sharedUtil = __w_pdfjs_require__(0);
  1498. var isArray = sharedUtil.isArray;
  1499. var EOF = {};
  1500. var Name = function NameClosure() {
  1501. function Name(name) {
  1502. this.name = name;
  1503. }
  1504. Name.prototype = {};
  1505. var nameCache = Object.create(null);
  1506. Name.get = function Name_get(name) {
  1507. var nameValue = nameCache[name];
  1508. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1509. };
  1510. return Name;
  1511. }();
  1512. var Cmd = function CmdClosure() {
  1513. function Cmd(cmd) {
  1514. this.cmd = cmd;
  1515. }
  1516. Cmd.prototype = {};
  1517. var cmdCache = Object.create(null);
  1518. Cmd.get = function Cmd_get(cmd) {
  1519. var cmdValue = cmdCache[cmd];
  1520. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1521. };
  1522. return Cmd;
  1523. }();
  1524. var Dict = function DictClosure() {
  1525. var nonSerializable = function nonSerializableClosure() {
  1526. return nonSerializable;
  1527. };
  1528. function Dict(xref) {
  1529. this.map = Object.create(null);
  1530. this.xref = xref;
  1531. this.objId = null;
  1532. this.suppressEncryption = false;
  1533. this.__nonSerializable__ = nonSerializable;
  1534. }
  1535. Dict.prototype = {
  1536. assignXref: function Dict_assignXref(newXref) {
  1537. this.xref = newXref;
  1538. },
  1539. get: function Dict_get(key1, key2, key3) {
  1540. var value;
  1541. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1542. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1543. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1544. }
  1545. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1546. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1547. }
  1548. value = this.map[key3] || null;
  1549. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1550. },
  1551. getAsync: function Dict_getAsync(key1, key2, key3) {
  1552. var value;
  1553. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1554. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1555. if (xref) {
  1556. return xref.fetchIfRefAsync(value, suppressEncryption);
  1557. }
  1558. return Promise.resolve(value);
  1559. }
  1560. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1561. if (xref) {
  1562. return xref.fetchIfRefAsync(value, suppressEncryption);
  1563. }
  1564. return Promise.resolve(value);
  1565. }
  1566. value = this.map[key3] || null;
  1567. if (xref) {
  1568. return xref.fetchIfRefAsync(value, suppressEncryption);
  1569. }
  1570. return Promise.resolve(value);
  1571. },
  1572. getArray: function Dict_getArray(key1, key2, key3) {
  1573. var value = this.get(key1, key2, key3);
  1574. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1575. if (!isArray(value) || !xref) {
  1576. return value;
  1577. }
  1578. value = value.slice();
  1579. for (var i = 0, ii = value.length; i < ii; i++) {
  1580. if (!isRef(value[i])) {
  1581. continue;
  1582. }
  1583. value[i] = xref.fetch(value[i], suppressEncryption);
  1584. }
  1585. return value;
  1586. },
  1587. getRaw: function Dict_getRaw(key) {
  1588. return this.map[key];
  1589. },
  1590. getKeys: function Dict_getKeys() {
  1591. return Object.keys(this.map);
  1592. },
  1593. set: function Dict_set(key, value) {
  1594. this.map[key] = value;
  1595. },
  1596. has: function Dict_has(key) {
  1597. return key in this.map;
  1598. },
  1599. forEach: function Dict_forEach(callback) {
  1600. for (var key in this.map) {
  1601. callback(key, this.get(key));
  1602. }
  1603. }
  1604. };
  1605. Dict.empty = new Dict(null);
  1606. Dict.merge = function Dict_merge(xref, dictArray) {
  1607. var mergedDict = new Dict(xref);
  1608. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1609. var dict = dictArray[i];
  1610. if (!isDict(dict)) {
  1611. continue;
  1612. }
  1613. for (var keyName in dict.map) {
  1614. if (mergedDict.map[keyName]) {
  1615. continue;
  1616. }
  1617. mergedDict.map[keyName] = dict.map[keyName];
  1618. }
  1619. }
  1620. return mergedDict;
  1621. };
  1622. return Dict;
  1623. }();
  1624. var Ref = function RefClosure() {
  1625. function Ref(num, gen) {
  1626. this.num = num;
  1627. this.gen = gen;
  1628. }
  1629. Ref.prototype = {
  1630. toString: function Ref_toString() {
  1631. var str = this.num + 'R';
  1632. if (this.gen !== 0) {
  1633. str += this.gen;
  1634. }
  1635. return str;
  1636. }
  1637. };
  1638. return Ref;
  1639. }();
  1640. var RefSet = function RefSetClosure() {
  1641. function RefSet() {
  1642. this.dict = Object.create(null);
  1643. }
  1644. RefSet.prototype = {
  1645. has: function RefSet_has(ref) {
  1646. return ref.toString() in this.dict;
  1647. },
  1648. put: function RefSet_put(ref) {
  1649. this.dict[ref.toString()] = true;
  1650. },
  1651. remove: function RefSet_remove(ref) {
  1652. delete this.dict[ref.toString()];
  1653. }
  1654. };
  1655. return RefSet;
  1656. }();
  1657. var RefSetCache = function RefSetCacheClosure() {
  1658. function RefSetCache() {
  1659. this.dict = Object.create(null);
  1660. }
  1661. RefSetCache.prototype = {
  1662. get: function RefSetCache_get(ref) {
  1663. return this.dict[ref.toString()];
  1664. },
  1665. has: function RefSetCache_has(ref) {
  1666. return ref.toString() in this.dict;
  1667. },
  1668. put: function RefSetCache_put(ref, obj) {
  1669. this.dict[ref.toString()] = obj;
  1670. },
  1671. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1672. this.dict[ref.toString()] = this.get(aliasRef);
  1673. },
  1674. forEach: function RefSetCache_forEach(fn, thisArg) {
  1675. for (var i in this.dict) {
  1676. fn.call(thisArg, this.dict[i]);
  1677. }
  1678. },
  1679. clear: function RefSetCache_clear() {
  1680. this.dict = Object.create(null);
  1681. }
  1682. };
  1683. return RefSetCache;
  1684. }();
  1685. function isEOF(v) {
  1686. return v === EOF;
  1687. }
  1688. function isName(v, name) {
  1689. return v instanceof Name && (name === undefined || v.name === name);
  1690. }
  1691. function isCmd(v, cmd) {
  1692. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1693. }
  1694. function isDict(v, type) {
  1695. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1696. }
  1697. function isRef(v) {
  1698. return v instanceof Ref;
  1699. }
  1700. function isRefsEqual(v1, v2) {
  1701. return v1.num === v2.num && v1.gen === v2.gen;
  1702. }
  1703. function isStream(v) {
  1704. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  1705. }
  1706. exports.EOF = EOF;
  1707. exports.Cmd = Cmd;
  1708. exports.Dict = Dict;
  1709. exports.Name = Name;
  1710. exports.Ref = Ref;
  1711. exports.RefSet = RefSet;
  1712. exports.RefSetCache = RefSetCache;
  1713. exports.isEOF = isEOF;
  1714. exports.isCmd = isCmd;
  1715. exports.isDict = isDict;
  1716. exports.isName = isName;
  1717. exports.isRef = isRef;
  1718. exports.isRefsEqual = isRefsEqual;
  1719. exports.isStream = isStream;
  1720. /***/ }),
  1721. /* 2 */
  1722. /***/ (function(module, exports, __w_pdfjs_require__) {
  1723. "use strict";
  1724. var sharedUtil = __w_pdfjs_require__(0);
  1725. var corePrimitives = __w_pdfjs_require__(1);
  1726. var coreJbig2 = __w_pdfjs_require__(35);
  1727. var coreJpg = __w_pdfjs_require__(36);
  1728. var coreJpx = __w_pdfjs_require__(19);
  1729. var Util = sharedUtil.Util;
  1730. var error = sharedUtil.error;
  1731. var info = sharedUtil.info;
  1732. var isInt = sharedUtil.isInt;
  1733. var isArray = sharedUtil.isArray;
  1734. var createObjectURL = sharedUtil.createObjectURL;
  1735. var shadow = sharedUtil.shadow;
  1736. var isSpace = sharedUtil.isSpace;
  1737. var Dict = corePrimitives.Dict;
  1738. var isDict = corePrimitives.isDict;
  1739. var isStream = corePrimitives.isStream;
  1740. var Jbig2Image = coreJbig2.Jbig2Image;
  1741. var JpegImage = coreJpg.JpegImage;
  1742. var JpxImage = coreJpx.JpxImage;
  1743. var Stream = function StreamClosure() {
  1744. function Stream(arrayBuffer, start, length, dict) {
  1745. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1746. this.start = start || 0;
  1747. this.pos = this.start;
  1748. this.end = start + length || this.bytes.length;
  1749. this.dict = dict;
  1750. }
  1751. Stream.prototype = {
  1752. get length() {
  1753. return this.end - this.start;
  1754. },
  1755. get isEmpty() {
  1756. return this.length === 0;
  1757. },
  1758. getByte: function Stream_getByte() {
  1759. if (this.pos >= this.end) {
  1760. return -1;
  1761. }
  1762. return this.bytes[this.pos++];
  1763. },
  1764. getUint16: function Stream_getUint16() {
  1765. var b0 = this.getByte();
  1766. var b1 = this.getByte();
  1767. if (b0 === -1 || b1 === -1) {
  1768. return -1;
  1769. }
  1770. return (b0 << 8) + b1;
  1771. },
  1772. getInt32: function Stream_getInt32() {
  1773. var b0 = this.getByte();
  1774. var b1 = this.getByte();
  1775. var b2 = this.getByte();
  1776. var b3 = this.getByte();
  1777. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1778. },
  1779. getBytes: function Stream_getBytes(length) {
  1780. var bytes = this.bytes;
  1781. var pos = this.pos;
  1782. var strEnd = this.end;
  1783. if (!length) {
  1784. return bytes.subarray(pos, strEnd);
  1785. }
  1786. var end = pos + length;
  1787. if (end > strEnd) {
  1788. end = strEnd;
  1789. }
  1790. this.pos = end;
  1791. return bytes.subarray(pos, end);
  1792. },
  1793. peekByte: function Stream_peekByte() {
  1794. var peekedByte = this.getByte();
  1795. this.pos--;
  1796. return peekedByte;
  1797. },
  1798. peekBytes: function Stream_peekBytes(length) {
  1799. var bytes = this.getBytes(length);
  1800. this.pos -= bytes.length;
  1801. return bytes;
  1802. },
  1803. skip: function Stream_skip(n) {
  1804. if (!n) {
  1805. n = 1;
  1806. }
  1807. this.pos += n;
  1808. },
  1809. reset: function Stream_reset() {
  1810. this.pos = this.start;
  1811. },
  1812. moveStart: function Stream_moveStart() {
  1813. this.start = this.pos;
  1814. },
  1815. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1816. return new Stream(this.bytes.buffer, start, length, dict);
  1817. }
  1818. };
  1819. return Stream;
  1820. }();
  1821. var StringStream = function StringStreamClosure() {
  1822. function StringStream(str) {
  1823. var length = str.length;
  1824. var bytes = new Uint8Array(length);
  1825. for (var n = 0; n < length; ++n) {
  1826. bytes[n] = str.charCodeAt(n);
  1827. }
  1828. Stream.call(this, bytes);
  1829. }
  1830. StringStream.prototype = Stream.prototype;
  1831. return StringStream;
  1832. }();
  1833. var DecodeStream = function DecodeStreamClosure() {
  1834. var emptyBuffer = new Uint8Array(0);
  1835. function DecodeStream(maybeMinBufferLength) {
  1836. this.pos = 0;
  1837. this.bufferLength = 0;
  1838. this.eof = false;
  1839. this.buffer = emptyBuffer;
  1840. this.minBufferLength = 512;
  1841. if (maybeMinBufferLength) {
  1842. while (this.minBufferLength < maybeMinBufferLength) {
  1843. this.minBufferLength *= 2;
  1844. }
  1845. }
  1846. }
  1847. DecodeStream.prototype = {
  1848. get isEmpty() {
  1849. while (!this.eof && this.bufferLength === 0) {
  1850. this.readBlock();
  1851. }
  1852. return this.bufferLength === 0;
  1853. },
  1854. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1855. var buffer = this.buffer;
  1856. if (requested <= buffer.byteLength) {
  1857. return buffer;
  1858. }
  1859. var size = this.minBufferLength;
  1860. while (size < requested) {
  1861. size *= 2;
  1862. }
  1863. var buffer2 = new Uint8Array(size);
  1864. buffer2.set(buffer);
  1865. return this.buffer = buffer2;
  1866. },
  1867. getByte: function DecodeStream_getByte() {
  1868. var pos = this.pos;
  1869. while (this.bufferLength <= pos) {
  1870. if (this.eof) {
  1871. return -1;
  1872. }
  1873. this.readBlock();
  1874. }
  1875. return this.buffer[this.pos++];
  1876. },
  1877. getUint16: function DecodeStream_getUint16() {
  1878. var b0 = this.getByte();
  1879. var b1 = this.getByte();
  1880. if (b0 === -1 || b1 === -1) {
  1881. return -1;
  1882. }
  1883. return (b0 << 8) + b1;
  1884. },
  1885. getInt32: function DecodeStream_getInt32() {
  1886. var b0 = this.getByte();
  1887. var b1 = this.getByte();
  1888. var b2 = this.getByte();
  1889. var b3 = this.getByte();
  1890. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1891. },
  1892. getBytes: function DecodeStream_getBytes(length) {
  1893. var end, pos = this.pos;
  1894. if (length) {
  1895. this.ensureBuffer(pos + length);
  1896. end = pos + length;
  1897. while (!this.eof && this.bufferLength < end) {
  1898. this.readBlock();
  1899. }
  1900. var bufEnd = this.bufferLength;
  1901. if (end > bufEnd) {
  1902. end = bufEnd;
  1903. }
  1904. } else {
  1905. while (!this.eof) {
  1906. this.readBlock();
  1907. }
  1908. end = this.bufferLength;
  1909. }
  1910. this.pos = end;
  1911. return this.buffer.subarray(pos, end);
  1912. },
  1913. peekByte: function DecodeStream_peekByte() {
  1914. var peekedByte = this.getByte();
  1915. this.pos--;
  1916. return peekedByte;
  1917. },
  1918. peekBytes: function DecodeStream_peekBytes(length) {
  1919. var bytes = this.getBytes(length);
  1920. this.pos -= bytes.length;
  1921. return bytes;
  1922. },
  1923. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1924. var end = start + length;
  1925. while (this.bufferLength <= end && !this.eof) {
  1926. this.readBlock();
  1927. }
  1928. return new Stream(this.buffer, start, length, dict);
  1929. },
  1930. skip: function DecodeStream_skip(n) {
  1931. if (!n) {
  1932. n = 1;
  1933. }
  1934. this.pos += n;
  1935. },
  1936. reset: function DecodeStream_reset() {
  1937. this.pos = 0;
  1938. },
  1939. getBaseStreams: function DecodeStream_getBaseStreams() {
  1940. if (this.str && this.str.getBaseStreams) {
  1941. return this.str.getBaseStreams();
  1942. }
  1943. return [];
  1944. }
  1945. };
  1946. return DecodeStream;
  1947. }();
  1948. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1949. function StreamsSequenceStream(streams) {
  1950. this.streams = streams;
  1951. DecodeStream.call(this, null);
  1952. }
  1953. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1954. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1955. var streams = this.streams;
  1956. if (streams.length === 0) {
  1957. this.eof = true;
  1958. return;
  1959. }
  1960. var stream = streams.shift();
  1961. var chunk = stream.getBytes();
  1962. var bufferLength = this.bufferLength;
  1963. var newLength = bufferLength + chunk.length;
  1964. var buffer = this.ensureBuffer(newLength);
  1965. buffer.set(chunk, bufferLength);
  1966. this.bufferLength = newLength;
  1967. };
  1968. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1969. var baseStreams = [];
  1970. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1971. var stream = this.streams[i];
  1972. if (stream.getBaseStreams) {
  1973. Util.appendToArray(baseStreams, stream.getBaseStreams());
  1974. }
  1975. }
  1976. return baseStreams;
  1977. };
  1978. return StreamsSequenceStream;
  1979. }();
  1980. var FlateStream = function FlateStreamClosure() {
  1981. var codeLenCodeMap = new Int32Array([
  1982. 16,
  1983. 17,
  1984. 18,
  1985. 0,
  1986. 8,
  1987. 7,
  1988. 9,
  1989. 6,
  1990. 10,
  1991. 5,
  1992. 11,
  1993. 4,
  1994. 12,
  1995. 3,
  1996. 13,
  1997. 2,
  1998. 14,
  1999. 1,
  2000. 15
  2001. ]);
  2002. var lengthDecode = new Int32Array([
  2003. 0x00003,
  2004. 0x00004,
  2005. 0x00005,
  2006. 0x00006,
  2007. 0x00007,
  2008. 0x00008,
  2009. 0x00009,
  2010. 0x0000a,
  2011. 0x1000b,
  2012. 0x1000d,
  2013. 0x1000f,
  2014. 0x10011,
  2015. 0x20013,
  2016. 0x20017,
  2017. 0x2001b,
  2018. 0x2001f,
  2019. 0x30023,
  2020. 0x3002b,
  2021. 0x30033,
  2022. 0x3003b,
  2023. 0x40043,
  2024. 0x40053,
  2025. 0x40063,
  2026. 0x40073,
  2027. 0x50083,
  2028. 0x500a3,
  2029. 0x500c3,
  2030. 0x500e3,
  2031. 0x00102,
  2032. 0x00102,
  2033. 0x00102
  2034. ]);
  2035. var distDecode = new Int32Array([
  2036. 0x00001,
  2037. 0x00002,
  2038. 0x00003,
  2039. 0x00004,
  2040. 0x10005,
  2041. 0x10007,
  2042. 0x20009,
  2043. 0x2000d,
  2044. 0x30011,
  2045. 0x30019,
  2046. 0x40021,
  2047. 0x40031,
  2048. 0x50041,
  2049. 0x50061,
  2050. 0x60081,
  2051. 0x600c1,
  2052. 0x70101,
  2053. 0x70181,
  2054. 0x80201,
  2055. 0x80301,
  2056. 0x90401,
  2057. 0x90601,
  2058. 0xa0801,
  2059. 0xa0c01,
  2060. 0xb1001,
  2061. 0xb1801,
  2062. 0xc2001,
  2063. 0xc3001,
  2064. 0xd4001,
  2065. 0xd6001
  2066. ]);
  2067. var fixedLitCodeTab = [
  2068. new Int32Array([
  2069. 0x70100,
  2070. 0x80050,
  2071. 0x80010,
  2072. 0x80118,
  2073. 0x70110,
  2074. 0x80070,
  2075. 0x80030,
  2076. 0x900c0,
  2077. 0x70108,
  2078. 0x80060,
  2079. 0x80020,
  2080. 0x900a0,
  2081. 0x80000,
  2082. 0x80080,
  2083. 0x80040,
  2084. 0x900e0,
  2085. 0x70104,
  2086. 0x80058,
  2087. 0x80018,
  2088. 0x90090,
  2089. 0x70114,
  2090. 0x80078,
  2091. 0x80038,
  2092. 0x900d0,
  2093. 0x7010c,
  2094. 0x80068,
  2095. 0x80028,
  2096. 0x900b0,
  2097. 0x80008,
  2098. 0x80088,
  2099. 0x80048,
  2100. 0x900f0,
  2101. 0x70102,
  2102. 0x80054,
  2103. 0x80014,
  2104. 0x8011c,
  2105. 0x70112,
  2106. 0x80074,
  2107. 0x80034,
  2108. 0x900c8,
  2109. 0x7010a,
  2110. 0x80064,
  2111. 0x80024,
  2112. 0x900a8,
  2113. 0x80004,
  2114. 0x80084,
  2115. 0x80044,
  2116. 0x900e8,
  2117. 0x70106,
  2118. 0x8005c,
  2119. 0x8001c,
  2120. 0x90098,
  2121. 0x70116,
  2122. 0x8007c,
  2123. 0x8003c,
  2124. 0x900d8,
  2125. 0x7010e,
  2126. 0x8006c,
  2127. 0x8002c,
  2128. 0x900b8,
  2129. 0x8000c,
  2130. 0x8008c,
  2131. 0x8004c,
  2132. 0x900f8,
  2133. 0x70101,
  2134. 0x80052,
  2135. 0x80012,
  2136. 0x8011a,
  2137. 0x70111,
  2138. 0x80072,
  2139. 0x80032,
  2140. 0x900c4,
  2141. 0x70109,
  2142. 0x80062,
  2143. 0x80022,
  2144. 0x900a4,
  2145. 0x80002,
  2146. 0x80082,
  2147. 0x80042,
  2148. 0x900e4,
  2149. 0x70105,
  2150. 0x8005a,
  2151. 0x8001a,
  2152. 0x90094,
  2153. 0x70115,
  2154. 0x8007a,
  2155. 0x8003a,
  2156. 0x900d4,
  2157. 0x7010d,
  2158. 0x8006a,
  2159. 0x8002a,
  2160. 0x900b4,
  2161. 0x8000a,
  2162. 0x8008a,
  2163. 0x8004a,
  2164. 0x900f4,
  2165. 0x70103,
  2166. 0x80056,
  2167. 0x80016,
  2168. 0x8011e,
  2169. 0x70113,
  2170. 0x80076,
  2171. 0x80036,
  2172. 0x900cc,
  2173. 0x7010b,
  2174. 0x80066,
  2175. 0x80026,
  2176. 0x900ac,
  2177. 0x80006,
  2178. 0x80086,
  2179. 0x80046,
  2180. 0x900ec,
  2181. 0x70107,
  2182. 0x8005e,
  2183. 0x8001e,
  2184. 0x9009c,
  2185. 0x70117,
  2186. 0x8007e,
  2187. 0x8003e,
  2188. 0x900dc,
  2189. 0x7010f,
  2190. 0x8006e,
  2191. 0x8002e,
  2192. 0x900bc,
  2193. 0x8000e,
  2194. 0x8008e,
  2195. 0x8004e,
  2196. 0x900fc,
  2197. 0x70100,
  2198. 0x80051,
  2199. 0x80011,
  2200. 0x80119,
  2201. 0x70110,
  2202. 0x80071,
  2203. 0x80031,
  2204. 0x900c2,
  2205. 0x70108,
  2206. 0x80061,
  2207. 0x80021,
  2208. 0x900a2,
  2209. 0x80001,
  2210. 0x80081,
  2211. 0x80041,
  2212. 0x900e2,
  2213. 0x70104,
  2214. 0x80059,
  2215. 0x80019,
  2216. 0x90092,
  2217. 0x70114,
  2218. 0x80079,
  2219. 0x80039,
  2220. 0x900d2,
  2221. 0x7010c,
  2222. 0x80069,
  2223. 0x80029,
  2224. 0x900b2,
  2225. 0x80009,
  2226. 0x80089,
  2227. 0x80049,
  2228. 0x900f2,
  2229. 0x70102,
  2230. 0x80055,
  2231. 0x80015,
  2232. 0x8011d,
  2233. 0x70112,
  2234. 0x80075,
  2235. 0x80035,
  2236. 0x900ca,
  2237. 0x7010a,
  2238. 0x80065,
  2239. 0x80025,
  2240. 0x900aa,
  2241. 0x80005,
  2242. 0x80085,
  2243. 0x80045,
  2244. 0x900ea,
  2245. 0x70106,
  2246. 0x8005d,
  2247. 0x8001d,
  2248. 0x9009a,
  2249. 0x70116,
  2250. 0x8007d,
  2251. 0x8003d,
  2252. 0x900da,
  2253. 0x7010e,
  2254. 0x8006d,
  2255. 0x8002d,
  2256. 0x900ba,
  2257. 0x8000d,
  2258. 0x8008d,
  2259. 0x8004d,
  2260. 0x900fa,
  2261. 0x70101,
  2262. 0x80053,
  2263. 0x80013,
  2264. 0x8011b,
  2265. 0x70111,
  2266. 0x80073,
  2267. 0x80033,
  2268. 0x900c6,
  2269. 0x70109,
  2270. 0x80063,
  2271. 0x80023,
  2272. 0x900a6,
  2273. 0x80003,
  2274. 0x80083,
  2275. 0x80043,
  2276. 0x900e6,
  2277. 0x70105,
  2278. 0x8005b,
  2279. 0x8001b,
  2280. 0x90096,
  2281. 0x70115,
  2282. 0x8007b,
  2283. 0x8003b,
  2284. 0x900d6,
  2285. 0x7010d,
  2286. 0x8006b,
  2287. 0x8002b,
  2288. 0x900b6,
  2289. 0x8000b,
  2290. 0x8008b,
  2291. 0x8004b,
  2292. 0x900f6,
  2293. 0x70103,
  2294. 0x80057,
  2295. 0x80017,
  2296. 0x8011f,
  2297. 0x70113,
  2298. 0x80077,
  2299. 0x80037,
  2300. 0x900ce,
  2301. 0x7010b,
  2302. 0x80067,
  2303. 0x80027,
  2304. 0x900ae,
  2305. 0x80007,
  2306. 0x80087,
  2307. 0x80047,
  2308. 0x900ee,
  2309. 0x70107,
  2310. 0x8005f,
  2311. 0x8001f,
  2312. 0x9009e,
  2313. 0x70117,
  2314. 0x8007f,
  2315. 0x8003f,
  2316. 0x900de,
  2317. 0x7010f,
  2318. 0x8006f,
  2319. 0x8002f,
  2320. 0x900be,
  2321. 0x8000f,
  2322. 0x8008f,
  2323. 0x8004f,
  2324. 0x900fe,
  2325. 0x70100,
  2326. 0x80050,
  2327. 0x80010,
  2328. 0x80118,
  2329. 0x70110,
  2330. 0x80070,
  2331. 0x80030,
  2332. 0x900c1,
  2333. 0x70108,
  2334. 0x80060,
  2335. 0x80020,
  2336. 0x900a1,
  2337. 0x80000,
  2338. 0x80080,
  2339. 0x80040,
  2340. 0x900e1,
  2341. 0x70104,
  2342. 0x80058,
  2343. 0x80018,
  2344. 0x90091,
  2345. 0x70114,
  2346. 0x80078,
  2347. 0x80038,
  2348. 0x900d1,
  2349. 0x7010c,
  2350. 0x80068,
  2351. 0x80028,
  2352. 0x900b1,
  2353. 0x80008,
  2354. 0x80088,
  2355. 0x80048,
  2356. 0x900f1,
  2357. 0x70102,
  2358. 0x80054,
  2359. 0x80014,
  2360. 0x8011c,
  2361. 0x70112,
  2362. 0x80074,
  2363. 0x80034,
  2364. 0x900c9,
  2365. 0x7010a,
  2366. 0x80064,
  2367. 0x80024,
  2368. 0x900a9,
  2369. 0x80004,
  2370. 0x80084,
  2371. 0x80044,
  2372. 0x900e9,
  2373. 0x70106,
  2374. 0x8005c,
  2375. 0x8001c,
  2376. 0x90099,
  2377. 0x70116,
  2378. 0x8007c,
  2379. 0x8003c,
  2380. 0x900d9,
  2381. 0x7010e,
  2382. 0x8006c,
  2383. 0x8002c,
  2384. 0x900b9,
  2385. 0x8000c,
  2386. 0x8008c,
  2387. 0x8004c,
  2388. 0x900f9,
  2389. 0x70101,
  2390. 0x80052,
  2391. 0x80012,
  2392. 0x8011a,
  2393. 0x70111,
  2394. 0x80072,
  2395. 0x80032,
  2396. 0x900c5,
  2397. 0x70109,
  2398. 0x80062,
  2399. 0x80022,
  2400. 0x900a5,
  2401. 0x80002,
  2402. 0x80082,
  2403. 0x80042,
  2404. 0x900e5,
  2405. 0x70105,
  2406. 0x8005a,
  2407. 0x8001a,
  2408. 0x90095,
  2409. 0x70115,
  2410. 0x8007a,
  2411. 0x8003a,
  2412. 0x900d5,
  2413. 0x7010d,
  2414. 0x8006a,
  2415. 0x8002a,
  2416. 0x900b5,
  2417. 0x8000a,
  2418. 0x8008a,
  2419. 0x8004a,
  2420. 0x900f5,
  2421. 0x70103,
  2422. 0x80056,
  2423. 0x80016,
  2424. 0x8011e,
  2425. 0x70113,
  2426. 0x80076,
  2427. 0x80036,
  2428. 0x900cd,
  2429. 0x7010b,
  2430. 0x80066,
  2431. 0x80026,
  2432. 0x900ad,
  2433. 0x80006,
  2434. 0x80086,
  2435. 0x80046,
  2436. 0x900ed,
  2437. 0x70107,
  2438. 0x8005e,
  2439. 0x8001e,
  2440. 0x9009d,
  2441. 0x70117,
  2442. 0x8007e,
  2443. 0x8003e,
  2444. 0x900dd,
  2445. 0x7010f,
  2446. 0x8006e,
  2447. 0x8002e,
  2448. 0x900bd,
  2449. 0x8000e,
  2450. 0x8008e,
  2451. 0x8004e,
  2452. 0x900fd,
  2453. 0x70100,
  2454. 0x80051,
  2455. 0x80011,
  2456. 0x80119,
  2457. 0x70110,
  2458. 0x80071,
  2459. 0x80031,
  2460. 0x900c3,
  2461. 0x70108,
  2462. 0x80061,
  2463. 0x80021,
  2464. 0x900a3,
  2465. 0x80001,
  2466. 0x80081,
  2467. 0x80041,
  2468. 0x900e3,
  2469. 0x70104,
  2470. 0x80059,
  2471. 0x80019,
  2472. 0x90093,
  2473. 0x70114,
  2474. 0x80079,
  2475. 0x80039,
  2476. 0x900d3,
  2477. 0x7010c,
  2478. 0x80069,
  2479. 0x80029,
  2480. 0x900b3,
  2481. 0x80009,
  2482. 0x80089,
  2483. 0x80049,
  2484. 0x900f3,
  2485. 0x70102,
  2486. 0x80055,
  2487. 0x80015,
  2488. 0x8011d,
  2489. 0x70112,
  2490. 0x80075,
  2491. 0x80035,
  2492. 0x900cb,
  2493. 0x7010a,
  2494. 0x80065,
  2495. 0x80025,
  2496. 0x900ab,
  2497. 0x80005,
  2498. 0x80085,
  2499. 0x80045,
  2500. 0x900eb,
  2501. 0x70106,
  2502. 0x8005d,
  2503. 0x8001d,
  2504. 0x9009b,
  2505. 0x70116,
  2506. 0x8007d,
  2507. 0x8003d,
  2508. 0x900db,
  2509. 0x7010e,
  2510. 0x8006d,
  2511. 0x8002d,
  2512. 0x900bb,
  2513. 0x8000d,
  2514. 0x8008d,
  2515. 0x8004d,
  2516. 0x900fb,
  2517. 0x70101,
  2518. 0x80053,
  2519. 0x80013,
  2520. 0x8011b,
  2521. 0x70111,
  2522. 0x80073,
  2523. 0x80033,
  2524. 0x900c7,
  2525. 0x70109,
  2526. 0x80063,
  2527. 0x80023,
  2528. 0x900a7,
  2529. 0x80003,
  2530. 0x80083,
  2531. 0x80043,
  2532. 0x900e7,
  2533. 0x70105,
  2534. 0x8005b,
  2535. 0x8001b,
  2536. 0x90097,
  2537. 0x70115,
  2538. 0x8007b,
  2539. 0x8003b,
  2540. 0x900d7,
  2541. 0x7010d,
  2542. 0x8006b,
  2543. 0x8002b,
  2544. 0x900b7,
  2545. 0x8000b,
  2546. 0x8008b,
  2547. 0x8004b,
  2548. 0x900f7,
  2549. 0x70103,
  2550. 0x80057,
  2551. 0x80017,
  2552. 0x8011f,
  2553. 0x70113,
  2554. 0x80077,
  2555. 0x80037,
  2556. 0x900cf,
  2557. 0x7010b,
  2558. 0x80067,
  2559. 0x80027,
  2560. 0x900af,
  2561. 0x80007,
  2562. 0x80087,
  2563. 0x80047,
  2564. 0x900ef,
  2565. 0x70107,
  2566. 0x8005f,
  2567. 0x8001f,
  2568. 0x9009f,
  2569. 0x70117,
  2570. 0x8007f,
  2571. 0x8003f,
  2572. 0x900df,
  2573. 0x7010f,
  2574. 0x8006f,
  2575. 0x8002f,
  2576. 0x900bf,
  2577. 0x8000f,
  2578. 0x8008f,
  2579. 0x8004f,
  2580. 0x900ff
  2581. ]),
  2582. 9
  2583. ];
  2584. var fixedDistCodeTab = [
  2585. new Int32Array([
  2586. 0x50000,
  2587. 0x50010,
  2588. 0x50008,
  2589. 0x50018,
  2590. 0x50004,
  2591. 0x50014,
  2592. 0x5000c,
  2593. 0x5001c,
  2594. 0x50002,
  2595. 0x50012,
  2596. 0x5000a,
  2597. 0x5001a,
  2598. 0x50006,
  2599. 0x50016,
  2600. 0x5000e,
  2601. 0x00000,
  2602. 0x50001,
  2603. 0x50011,
  2604. 0x50009,
  2605. 0x50019,
  2606. 0x50005,
  2607. 0x50015,
  2608. 0x5000d,
  2609. 0x5001d,
  2610. 0x50003,
  2611. 0x50013,
  2612. 0x5000b,
  2613. 0x5001b,
  2614. 0x50007,
  2615. 0x50017,
  2616. 0x5000f,
  2617. 0x00000
  2618. ]),
  2619. 5
  2620. ];
  2621. function FlateStream(str, maybeLength) {
  2622. this.str = str;
  2623. this.dict = str.dict;
  2624. var cmf = str.getByte();
  2625. var flg = str.getByte();
  2626. if (cmf === -1 || flg === -1) {
  2627. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  2628. }
  2629. if ((cmf & 0x0f) !== 0x08) {
  2630. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  2631. }
  2632. if (((cmf << 8) + flg) % 31 !== 0) {
  2633. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  2634. }
  2635. if (flg & 0x20) {
  2636. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  2637. }
  2638. this.codeSize = 0;
  2639. this.codeBuf = 0;
  2640. DecodeStream.call(this, maybeLength);
  2641. }
  2642. FlateStream.prototype = Object.create(DecodeStream.prototype);
  2643. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  2644. var str = this.str;
  2645. var codeSize = this.codeSize;
  2646. var codeBuf = this.codeBuf;
  2647. var b;
  2648. while (codeSize < bits) {
  2649. if ((b = str.getByte()) === -1) {
  2650. error('Bad encoding in flate stream');
  2651. }
  2652. codeBuf |= b << codeSize;
  2653. codeSize += 8;
  2654. }
  2655. b = codeBuf & (1 << bits) - 1;
  2656. this.codeBuf = codeBuf >> bits;
  2657. this.codeSize = codeSize -= bits;
  2658. return b;
  2659. };
  2660. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2661. var str = this.str;
  2662. var codes = table[0];
  2663. var maxLen = table[1];
  2664. var codeSize = this.codeSize;
  2665. var codeBuf = this.codeBuf;
  2666. var b;
  2667. while (codeSize < maxLen) {
  2668. if ((b = str.getByte()) === -1) {
  2669. break;
  2670. }
  2671. codeBuf |= b << codeSize;
  2672. codeSize += 8;
  2673. }
  2674. var code = codes[codeBuf & (1 << maxLen) - 1];
  2675. var codeLen = code >> 16;
  2676. var codeVal = code & 0xffff;
  2677. if (codeLen < 1 || codeSize < codeLen) {
  2678. error('Bad encoding in flate stream');
  2679. }
  2680. this.codeBuf = codeBuf >> codeLen;
  2681. this.codeSize = codeSize - codeLen;
  2682. return codeVal;
  2683. };
  2684. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2685. var n = lengths.length;
  2686. var maxLen = 0;
  2687. var i;
  2688. for (i = 0; i < n; ++i) {
  2689. if (lengths[i] > maxLen) {
  2690. maxLen = lengths[i];
  2691. }
  2692. }
  2693. var size = 1 << maxLen;
  2694. var codes = new Int32Array(size);
  2695. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2696. for (var val = 0; val < n; ++val) {
  2697. if (lengths[val] === len) {
  2698. var code2 = 0;
  2699. var t = code;
  2700. for (i = 0; i < len; ++i) {
  2701. code2 = code2 << 1 | t & 1;
  2702. t >>= 1;
  2703. }
  2704. for (i = code2; i < size; i += skip) {
  2705. codes[i] = len << 16 | val;
  2706. }
  2707. ++code;
  2708. }
  2709. }
  2710. }
  2711. return [
  2712. codes,
  2713. maxLen
  2714. ];
  2715. };
  2716. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2717. var buffer, len;
  2718. var str = this.str;
  2719. var hdr = this.getBits(3);
  2720. if (hdr & 1) {
  2721. this.eof = true;
  2722. }
  2723. hdr >>= 1;
  2724. if (hdr === 0) {
  2725. var b;
  2726. if ((b = str.getByte()) === -1) {
  2727. error('Bad block header in flate stream');
  2728. }
  2729. var blockLen = b;
  2730. if ((b = str.getByte()) === -1) {
  2731. error('Bad block header in flate stream');
  2732. }
  2733. blockLen |= b << 8;
  2734. if ((b = str.getByte()) === -1) {
  2735. error('Bad block header in flate stream');
  2736. }
  2737. var check = b;
  2738. if ((b = str.getByte()) === -1) {
  2739. error('Bad block header in flate stream');
  2740. }
  2741. check |= b << 8;
  2742. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2743. error('Bad uncompressed block length in flate stream');
  2744. }
  2745. this.codeBuf = 0;
  2746. this.codeSize = 0;
  2747. var bufferLength = this.bufferLength;
  2748. buffer = this.ensureBuffer(bufferLength + blockLen);
  2749. var end = bufferLength + blockLen;
  2750. this.bufferLength = end;
  2751. if (blockLen === 0) {
  2752. if (str.peekByte() === -1) {
  2753. this.eof = true;
  2754. }
  2755. } else {
  2756. for (var n = bufferLength; n < end; ++n) {
  2757. if ((b = str.getByte()) === -1) {
  2758. this.eof = true;
  2759. break;
  2760. }
  2761. buffer[n] = b;
  2762. }
  2763. }
  2764. return;
  2765. }
  2766. var litCodeTable;
  2767. var distCodeTable;
  2768. if (hdr === 1) {
  2769. litCodeTable = fixedLitCodeTab;
  2770. distCodeTable = fixedDistCodeTab;
  2771. } else if (hdr === 2) {
  2772. var numLitCodes = this.getBits(5) + 257;
  2773. var numDistCodes = this.getBits(5) + 1;
  2774. var numCodeLenCodes = this.getBits(4) + 4;
  2775. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2776. var i;
  2777. for (i = 0; i < numCodeLenCodes; ++i) {
  2778. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2779. }
  2780. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2781. len = 0;
  2782. i = 0;
  2783. var codes = numLitCodes + numDistCodes;
  2784. var codeLengths = new Uint8Array(codes);
  2785. var bitsLength, bitsOffset, what;
  2786. while (i < codes) {
  2787. var code = this.getCode(codeLenCodeTab);
  2788. if (code === 16) {
  2789. bitsLength = 2;
  2790. bitsOffset = 3;
  2791. what = len;
  2792. } else if (code === 17) {
  2793. bitsLength = 3;
  2794. bitsOffset = 3;
  2795. what = len = 0;
  2796. } else if (code === 18) {
  2797. bitsLength = 7;
  2798. bitsOffset = 11;
  2799. what = len = 0;
  2800. } else {
  2801. codeLengths[i++] = len = code;
  2802. continue;
  2803. }
  2804. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2805. while (repeatLength-- > 0) {
  2806. codeLengths[i++] = what;
  2807. }
  2808. }
  2809. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2810. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2811. } else {
  2812. error('Unknown block type in flate stream');
  2813. }
  2814. buffer = this.buffer;
  2815. var limit = buffer ? buffer.length : 0;
  2816. var pos = this.bufferLength;
  2817. while (true) {
  2818. var code1 = this.getCode(litCodeTable);
  2819. if (code1 < 256) {
  2820. if (pos + 1 >= limit) {
  2821. buffer = this.ensureBuffer(pos + 1);
  2822. limit = buffer.length;
  2823. }
  2824. buffer[pos++] = code1;
  2825. continue;
  2826. }
  2827. if (code1 === 256) {
  2828. this.bufferLength = pos;
  2829. return;
  2830. }
  2831. code1 -= 257;
  2832. code1 = lengthDecode[code1];
  2833. var code2 = code1 >> 16;
  2834. if (code2 > 0) {
  2835. code2 = this.getBits(code2);
  2836. }
  2837. len = (code1 & 0xffff) + code2;
  2838. code1 = this.getCode(distCodeTable);
  2839. code1 = distDecode[code1];
  2840. code2 = code1 >> 16;
  2841. if (code2 > 0) {
  2842. code2 = this.getBits(code2);
  2843. }
  2844. var dist = (code1 & 0xffff) + code2;
  2845. if (pos + len >= limit) {
  2846. buffer = this.ensureBuffer(pos + len);
  2847. limit = buffer.length;
  2848. }
  2849. for (var k = 0; k < len; ++k, ++pos) {
  2850. buffer[pos] = buffer[pos - dist];
  2851. }
  2852. }
  2853. };
  2854. return FlateStream;
  2855. }();
  2856. var PredictorStream = function PredictorStreamClosure() {
  2857. function PredictorStream(str, maybeLength, params) {
  2858. if (!isDict(params)) {
  2859. return str;
  2860. }
  2861. var predictor = this.predictor = params.get('Predictor') || 1;
  2862. if (predictor <= 1) {
  2863. return str;
  2864. }
  2865. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2866. error('Unsupported predictor: ' + predictor);
  2867. }
  2868. if (predictor === 2) {
  2869. this.readBlock = this.readBlockTiff;
  2870. } else {
  2871. this.readBlock = this.readBlockPng;
  2872. }
  2873. this.str = str;
  2874. this.dict = str.dict;
  2875. var colors = this.colors = params.get('Colors') || 1;
  2876. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2877. var columns = this.columns = params.get('Columns') || 1;
  2878. this.pixBytes = colors * bits + 7 >> 3;
  2879. this.rowBytes = columns * colors * bits + 7 >> 3;
  2880. DecodeStream.call(this, maybeLength);
  2881. return this;
  2882. }
  2883. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2884. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2885. var rowBytes = this.rowBytes;
  2886. var bufferLength = this.bufferLength;
  2887. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2888. var bits = this.bits;
  2889. var colors = this.colors;
  2890. var rawBytes = this.str.getBytes(rowBytes);
  2891. this.eof = !rawBytes.length;
  2892. if (this.eof) {
  2893. return;
  2894. }
  2895. var inbuf = 0, outbuf = 0;
  2896. var inbits = 0, outbits = 0;
  2897. var pos = bufferLength;
  2898. var i;
  2899. if (bits === 1 && colors === 1) {
  2900. for (i = 0; i < rowBytes; ++i) {
  2901. var c = rawBytes[i] ^ inbuf;
  2902. c ^= c >> 1;
  2903. c ^= c >> 2;
  2904. c ^= c >> 4;
  2905. inbuf = (c & 1) << 7;
  2906. buffer[pos++] = c;
  2907. }
  2908. } else if (bits === 8) {
  2909. for (i = 0; i < colors; ++i) {
  2910. buffer[pos++] = rawBytes[i];
  2911. }
  2912. for (; i < rowBytes; ++i) {
  2913. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2914. pos++;
  2915. }
  2916. } else {
  2917. var compArray = new Uint8Array(colors + 1);
  2918. var bitMask = (1 << bits) - 1;
  2919. var j = 0, k = bufferLength;
  2920. var columns = this.columns;
  2921. for (i = 0; i < columns; ++i) {
  2922. for (var kk = 0; kk < colors; ++kk) {
  2923. if (inbits < bits) {
  2924. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2925. inbits += 8;
  2926. }
  2927. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2928. inbits -= bits;
  2929. outbuf = outbuf << bits | compArray[kk];
  2930. outbits += bits;
  2931. if (outbits >= 8) {
  2932. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2933. outbits -= 8;
  2934. }
  2935. }
  2936. }
  2937. if (outbits > 0) {
  2938. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2939. }
  2940. }
  2941. this.bufferLength += rowBytes;
  2942. };
  2943. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2944. var rowBytes = this.rowBytes;
  2945. var pixBytes = this.pixBytes;
  2946. var predictor = this.str.getByte();
  2947. var rawBytes = this.str.getBytes(rowBytes);
  2948. this.eof = !rawBytes.length;
  2949. if (this.eof) {
  2950. return;
  2951. }
  2952. var bufferLength = this.bufferLength;
  2953. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2954. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2955. if (prevRow.length === 0) {
  2956. prevRow = new Uint8Array(rowBytes);
  2957. }
  2958. var i, j = bufferLength, up, c;
  2959. switch (predictor) {
  2960. case 0:
  2961. for (i = 0; i < rowBytes; ++i) {
  2962. buffer[j++] = rawBytes[i];
  2963. }
  2964. break;
  2965. case 1:
  2966. for (i = 0; i < pixBytes; ++i) {
  2967. buffer[j++] = rawBytes[i];
  2968. }
  2969. for (; i < rowBytes; ++i) {
  2970. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2971. j++;
  2972. }
  2973. break;
  2974. case 2:
  2975. for (i = 0; i < rowBytes; ++i) {
  2976. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2977. }
  2978. break;
  2979. case 3:
  2980. for (i = 0; i < pixBytes; ++i) {
  2981. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2982. }
  2983. for (; i < rowBytes; ++i) {
  2984. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2985. j++;
  2986. }
  2987. break;
  2988. case 4:
  2989. for (i = 0; i < pixBytes; ++i) {
  2990. up = prevRow[i];
  2991. c = rawBytes[i];
  2992. buffer[j++] = up + c;
  2993. }
  2994. for (; i < rowBytes; ++i) {
  2995. up = prevRow[i];
  2996. var upLeft = prevRow[i - pixBytes];
  2997. var left = buffer[j - pixBytes];
  2998. var p = left + up - upLeft;
  2999. var pa = p - left;
  3000. if (pa < 0) {
  3001. pa = -pa;
  3002. }
  3003. var pb = p - up;
  3004. if (pb < 0) {
  3005. pb = -pb;
  3006. }
  3007. var pc = p - upLeft;
  3008. if (pc < 0) {
  3009. pc = -pc;
  3010. }
  3011. c = rawBytes[i];
  3012. if (pa <= pb && pa <= pc) {
  3013. buffer[j++] = left + c;
  3014. } else if (pb <= pc) {
  3015. buffer[j++] = up + c;
  3016. } else {
  3017. buffer[j++] = upLeft + c;
  3018. }
  3019. }
  3020. break;
  3021. default:
  3022. error('Unsupported predictor: ' + predictor);
  3023. }
  3024. this.bufferLength += rowBytes;
  3025. };
  3026. return PredictorStream;
  3027. }();
  3028. var JpegStream = function JpegStreamClosure() {
  3029. function JpegStream(stream, maybeLength, dict, params) {
  3030. var ch;
  3031. while ((ch = stream.getByte()) !== -1) {
  3032. if (ch === 0xFF) {
  3033. stream.skip(-1);
  3034. break;
  3035. }
  3036. }
  3037. this.stream = stream;
  3038. this.maybeLength = maybeLength;
  3039. this.dict = dict;
  3040. this.params = params;
  3041. DecodeStream.call(this, maybeLength);
  3042. }
  3043. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3044. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3045. get: function JpegStream_bytes() {
  3046. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3047. },
  3048. configurable: true
  3049. });
  3050. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3051. if (this.bufferLength) {
  3052. return;
  3053. }
  3054. var jpegImage = new JpegImage();
  3055. var decodeArr = this.dict.getArray('Decode', 'D');
  3056. if (this.forceRGB && isArray(decodeArr)) {
  3057. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3058. var decodeArrLength = decodeArr.length;
  3059. var transform = new Int32Array(decodeArrLength);
  3060. var transformNeeded = false;
  3061. var maxValue = (1 << bitsPerComponent) - 1;
  3062. for (var i = 0; i < decodeArrLength; i += 2) {
  3063. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3064. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3065. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3066. transformNeeded = true;
  3067. }
  3068. }
  3069. if (transformNeeded) {
  3070. jpegImage.decodeTransform = transform;
  3071. }
  3072. }
  3073. if (isDict(this.params)) {
  3074. var colorTransform = this.params.get('ColorTransform');
  3075. if (isInt(colorTransform)) {
  3076. jpegImage.colorTransform = colorTransform;
  3077. }
  3078. }
  3079. jpegImage.parse(this.bytes);
  3080. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3081. this.buffer = data;
  3082. this.bufferLength = data.length;
  3083. this.eof = true;
  3084. };
  3085. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3086. this.ensureBuffer();
  3087. return this.buffer;
  3088. };
  3089. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3090. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3091. };
  3092. return JpegStream;
  3093. }();
  3094. var JpxStream = function JpxStreamClosure() {
  3095. function JpxStream(stream, maybeLength, dict, params) {
  3096. this.stream = stream;
  3097. this.maybeLength = maybeLength;
  3098. this.dict = dict;
  3099. this.params = params;
  3100. DecodeStream.call(this, maybeLength);
  3101. }
  3102. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3103. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3104. get: function JpxStream_bytes() {
  3105. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3106. },
  3107. configurable: true
  3108. });
  3109. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3110. if (this.bufferLength) {
  3111. return;
  3112. }
  3113. var jpxImage = new JpxImage();
  3114. jpxImage.parse(this.bytes);
  3115. var width = jpxImage.width;
  3116. var height = jpxImage.height;
  3117. var componentsCount = jpxImage.componentsCount;
  3118. var tileCount = jpxImage.tiles.length;
  3119. if (tileCount === 1) {
  3120. this.buffer = jpxImage.tiles[0].items;
  3121. } else {
  3122. var data = new Uint8Array(width * height * componentsCount);
  3123. for (var k = 0; k < tileCount; k++) {
  3124. var tileComponents = jpxImage.tiles[k];
  3125. var tileWidth = tileComponents.width;
  3126. var tileHeight = tileComponents.height;
  3127. var tileLeft = tileComponents.left;
  3128. var tileTop = tileComponents.top;
  3129. var src = tileComponents.items;
  3130. var srcPosition = 0;
  3131. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3132. var imgRowSize = width * componentsCount;
  3133. var tileRowSize = tileWidth * componentsCount;
  3134. for (var j = 0; j < tileHeight; j++) {
  3135. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3136. data.set(rowBytes, dataPosition);
  3137. srcPosition += tileRowSize;
  3138. dataPosition += imgRowSize;
  3139. }
  3140. }
  3141. this.buffer = data;
  3142. }
  3143. this.bufferLength = this.buffer.length;
  3144. this.eof = true;
  3145. };
  3146. return JpxStream;
  3147. }();
  3148. var Jbig2Stream = function Jbig2StreamClosure() {
  3149. function Jbig2Stream(stream, maybeLength, dict, params) {
  3150. this.stream = stream;
  3151. this.maybeLength = maybeLength;
  3152. this.dict = dict;
  3153. this.params = params;
  3154. DecodeStream.call(this, maybeLength);
  3155. }
  3156. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3157. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3158. get: function Jbig2Stream_bytes() {
  3159. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3160. },
  3161. configurable: true
  3162. });
  3163. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3164. if (this.bufferLength) {
  3165. return;
  3166. }
  3167. var jbig2Image = new Jbig2Image();
  3168. var chunks = [];
  3169. if (isDict(this.params)) {
  3170. var globalsStream = this.params.get('JBIG2Globals');
  3171. if (isStream(globalsStream)) {
  3172. var globals = globalsStream.getBytes();
  3173. chunks.push({
  3174. data: globals,
  3175. start: 0,
  3176. end: globals.length
  3177. });
  3178. }
  3179. }
  3180. chunks.push({
  3181. data: this.bytes,
  3182. start: 0,
  3183. end: this.bytes.length
  3184. });
  3185. var data = jbig2Image.parseChunks(chunks);
  3186. var dataLength = data.length;
  3187. for (var i = 0; i < dataLength; i++) {
  3188. data[i] ^= 0xFF;
  3189. }
  3190. this.buffer = data;
  3191. this.bufferLength = dataLength;
  3192. this.eof = true;
  3193. };
  3194. return Jbig2Stream;
  3195. }();
  3196. var DecryptStream = function DecryptStreamClosure() {
  3197. function DecryptStream(str, maybeLength, decrypt) {
  3198. this.str = str;
  3199. this.dict = str.dict;
  3200. this.decrypt = decrypt;
  3201. this.nextChunk = null;
  3202. this.initialized = false;
  3203. DecodeStream.call(this, maybeLength);
  3204. }
  3205. var chunkSize = 512;
  3206. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  3207. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  3208. var chunk;
  3209. if (this.initialized) {
  3210. chunk = this.nextChunk;
  3211. } else {
  3212. chunk = this.str.getBytes(chunkSize);
  3213. this.initialized = true;
  3214. }
  3215. if (!chunk || chunk.length === 0) {
  3216. this.eof = true;
  3217. return;
  3218. }
  3219. this.nextChunk = this.str.getBytes(chunkSize);
  3220. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  3221. var decrypt = this.decrypt;
  3222. chunk = decrypt(chunk, !hasMoreData);
  3223. var bufferLength = this.bufferLength;
  3224. var i, n = chunk.length;
  3225. var buffer = this.ensureBuffer(bufferLength + n);
  3226. for (i = 0; i < n; i++) {
  3227. buffer[bufferLength++] = chunk[i];
  3228. }
  3229. this.bufferLength = bufferLength;
  3230. };
  3231. return DecryptStream;
  3232. }();
  3233. var Ascii85Stream = function Ascii85StreamClosure() {
  3234. function Ascii85Stream(str, maybeLength) {
  3235. this.str = str;
  3236. this.dict = str.dict;
  3237. this.input = new Uint8Array(5);
  3238. if (maybeLength) {
  3239. maybeLength = 0.8 * maybeLength;
  3240. }
  3241. DecodeStream.call(this, maybeLength);
  3242. }
  3243. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  3244. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  3245. var TILDA_CHAR = 0x7E;
  3246. var Z_LOWER_CHAR = 0x7A;
  3247. var EOF = -1;
  3248. var str = this.str;
  3249. var c = str.getByte();
  3250. while (isSpace(c)) {
  3251. c = str.getByte();
  3252. }
  3253. if (c === EOF || c === TILDA_CHAR) {
  3254. this.eof = true;
  3255. return;
  3256. }
  3257. var bufferLength = this.bufferLength, buffer;
  3258. var i;
  3259. if (c === Z_LOWER_CHAR) {
  3260. buffer = this.ensureBuffer(bufferLength + 4);
  3261. for (i = 0; i < 4; ++i) {
  3262. buffer[bufferLength + i] = 0;
  3263. }
  3264. this.bufferLength += 4;
  3265. } else {
  3266. var input = this.input;
  3267. input[0] = c;
  3268. for (i = 1; i < 5; ++i) {
  3269. c = str.getByte();
  3270. while (isSpace(c)) {
  3271. c = str.getByte();
  3272. }
  3273. input[i] = c;
  3274. if (c === EOF || c === TILDA_CHAR) {
  3275. break;
  3276. }
  3277. }
  3278. buffer = this.ensureBuffer(bufferLength + i - 1);
  3279. this.bufferLength += i - 1;
  3280. if (i < 5) {
  3281. for (; i < 5; ++i) {
  3282. input[i] = 0x21 + 84;
  3283. }
  3284. this.eof = true;
  3285. }
  3286. var t = 0;
  3287. for (i = 0; i < 5; ++i) {
  3288. t = t * 85 + (input[i] - 0x21);
  3289. }
  3290. for (i = 3; i >= 0; --i) {
  3291. buffer[bufferLength + i] = t & 0xFF;
  3292. t >>= 8;
  3293. }
  3294. }
  3295. };
  3296. return Ascii85Stream;
  3297. }();
  3298. var AsciiHexStream = function AsciiHexStreamClosure() {
  3299. function AsciiHexStream(str, maybeLength) {
  3300. this.str = str;
  3301. this.dict = str.dict;
  3302. this.firstDigit = -1;
  3303. if (maybeLength) {
  3304. maybeLength = 0.5 * maybeLength;
  3305. }
  3306. DecodeStream.call(this, maybeLength);
  3307. }
  3308. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  3309. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  3310. var UPSTREAM_BLOCK_SIZE = 8000;
  3311. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  3312. if (!bytes.length) {
  3313. this.eof = true;
  3314. return;
  3315. }
  3316. var maxDecodeLength = bytes.length + 1 >> 1;
  3317. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  3318. var bufferLength = this.bufferLength;
  3319. var firstDigit = this.firstDigit;
  3320. for (var i = 0, ii = bytes.length; i < ii; i++) {
  3321. var ch = bytes[i], digit;
  3322. if (ch >= 0x30 && ch <= 0x39) {
  3323. digit = ch & 0x0F;
  3324. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  3325. digit = (ch & 0x0F) + 9;
  3326. } else if (ch === 0x3E) {
  3327. this.eof = true;
  3328. break;
  3329. } else {
  3330. continue;
  3331. }
  3332. if (firstDigit < 0) {
  3333. firstDigit = digit;
  3334. } else {
  3335. buffer[bufferLength++] = firstDigit << 4 | digit;
  3336. firstDigit = -1;
  3337. }
  3338. }
  3339. if (firstDigit >= 0 && this.eof) {
  3340. buffer[bufferLength++] = firstDigit << 4;
  3341. firstDigit = -1;
  3342. }
  3343. this.firstDigit = firstDigit;
  3344. this.bufferLength = bufferLength;
  3345. };
  3346. return AsciiHexStream;
  3347. }();
  3348. var RunLengthStream = function RunLengthStreamClosure() {
  3349. function RunLengthStream(str, maybeLength) {
  3350. this.str = str;
  3351. this.dict = str.dict;
  3352. DecodeStream.call(this, maybeLength);
  3353. }
  3354. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  3355. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  3356. var repeatHeader = this.str.getBytes(2);
  3357. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  3358. this.eof = true;
  3359. return;
  3360. }
  3361. var buffer;
  3362. var bufferLength = this.bufferLength;
  3363. var n = repeatHeader[0];
  3364. if (n < 128) {
  3365. buffer = this.ensureBuffer(bufferLength + n + 1);
  3366. buffer[bufferLength++] = repeatHeader[1];
  3367. if (n > 0) {
  3368. var source = this.str.getBytes(n);
  3369. buffer.set(source, bufferLength);
  3370. bufferLength += n;
  3371. }
  3372. } else {
  3373. n = 257 - n;
  3374. var b = repeatHeader[1];
  3375. buffer = this.ensureBuffer(bufferLength + n + 1);
  3376. for (var i = 0; i < n; i++) {
  3377. buffer[bufferLength++] = b;
  3378. }
  3379. }
  3380. this.bufferLength = bufferLength;
  3381. };
  3382. return RunLengthStream;
  3383. }();
  3384. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  3385. var ccittEOL = -2;
  3386. var ccittEOF = -1;
  3387. var twoDimPass = 0;
  3388. var twoDimHoriz = 1;
  3389. var twoDimVert0 = 2;
  3390. var twoDimVertR1 = 3;
  3391. var twoDimVertL1 = 4;
  3392. var twoDimVertR2 = 5;
  3393. var twoDimVertL2 = 6;
  3394. var twoDimVertR3 = 7;
  3395. var twoDimVertL3 = 8;
  3396. var twoDimTable = [
  3397. [
  3398. -1,
  3399. -1
  3400. ],
  3401. [
  3402. -1,
  3403. -1
  3404. ],
  3405. [
  3406. 7,
  3407. twoDimVertL3
  3408. ],
  3409. [
  3410. 7,
  3411. twoDimVertR3
  3412. ],
  3413. [
  3414. 6,
  3415. twoDimVertL2
  3416. ],
  3417. [
  3418. 6,
  3419. twoDimVertL2
  3420. ],
  3421. [
  3422. 6,
  3423. twoDimVertR2
  3424. ],
  3425. [
  3426. 6,
  3427. twoDimVertR2
  3428. ],
  3429. [
  3430. 4,
  3431. twoDimPass
  3432. ],
  3433. [
  3434. 4,
  3435. twoDimPass
  3436. ],
  3437. [
  3438. 4,
  3439. twoDimPass
  3440. ],
  3441. [
  3442. 4,
  3443. twoDimPass
  3444. ],
  3445. [
  3446. 4,
  3447. twoDimPass
  3448. ],
  3449. [
  3450. 4,
  3451. twoDimPass
  3452. ],
  3453. [
  3454. 4,
  3455. twoDimPass
  3456. ],
  3457. [
  3458. 4,
  3459. twoDimPass
  3460. ],
  3461. [
  3462. 3,
  3463. twoDimHoriz
  3464. ],
  3465. [
  3466. 3,
  3467. twoDimHoriz
  3468. ],
  3469. [
  3470. 3,
  3471. twoDimHoriz
  3472. ],
  3473. [
  3474. 3,
  3475. twoDimHoriz
  3476. ],
  3477. [
  3478. 3,
  3479. twoDimHoriz
  3480. ],
  3481. [
  3482. 3,
  3483. twoDimHoriz
  3484. ],
  3485. [
  3486. 3,
  3487. twoDimHoriz
  3488. ],
  3489. [
  3490. 3,
  3491. twoDimHoriz
  3492. ],
  3493. [
  3494. 3,
  3495. twoDimHoriz
  3496. ],
  3497. [
  3498. 3,
  3499. twoDimHoriz
  3500. ],
  3501. [
  3502. 3,
  3503. twoDimHoriz
  3504. ],
  3505. [
  3506. 3,
  3507. twoDimHoriz
  3508. ],
  3509. [
  3510. 3,
  3511. twoDimHoriz
  3512. ],
  3513. [
  3514. 3,
  3515. twoDimHoriz
  3516. ],
  3517. [
  3518. 3,
  3519. twoDimHoriz
  3520. ],
  3521. [
  3522. 3,
  3523. twoDimHoriz
  3524. ],
  3525. [
  3526. 3,
  3527. twoDimVertL1
  3528. ],
  3529. [
  3530. 3,
  3531. twoDimVertL1
  3532. ],
  3533. [
  3534. 3,
  3535. twoDimVertL1
  3536. ],
  3537. [
  3538. 3,
  3539. twoDimVertL1
  3540. ],
  3541. [
  3542. 3,
  3543. twoDimVertL1
  3544. ],
  3545. [
  3546. 3,
  3547. twoDimVertL1
  3548. ],
  3549. [
  3550. 3,
  3551. twoDimVertL1
  3552. ],
  3553. [
  3554. 3,
  3555. twoDimVertL1
  3556. ],
  3557. [
  3558. 3,
  3559. twoDimVertL1
  3560. ],
  3561. [
  3562. 3,
  3563. twoDimVertL1
  3564. ],
  3565. [
  3566. 3,
  3567. twoDimVertL1
  3568. ],
  3569. [
  3570. 3,
  3571. twoDimVertL1
  3572. ],
  3573. [
  3574. 3,
  3575. twoDimVertL1
  3576. ],
  3577. [
  3578. 3,
  3579. twoDimVertL1
  3580. ],
  3581. [
  3582. 3,
  3583. twoDimVertL1
  3584. ],
  3585. [
  3586. 3,
  3587. twoDimVertL1
  3588. ],
  3589. [
  3590. 3,
  3591. twoDimVertR1
  3592. ],
  3593. [
  3594. 3,
  3595. twoDimVertR1
  3596. ],
  3597. [
  3598. 3,
  3599. twoDimVertR1
  3600. ],
  3601. [
  3602. 3,
  3603. twoDimVertR1
  3604. ],
  3605. [
  3606. 3,
  3607. twoDimVertR1
  3608. ],
  3609. [
  3610. 3,
  3611. twoDimVertR1
  3612. ],
  3613. [
  3614. 3,
  3615. twoDimVertR1
  3616. ],
  3617. [
  3618. 3,
  3619. twoDimVertR1
  3620. ],
  3621. [
  3622. 3,
  3623. twoDimVertR1
  3624. ],
  3625. [
  3626. 3,
  3627. twoDimVertR1
  3628. ],
  3629. [
  3630. 3,
  3631. twoDimVertR1
  3632. ],
  3633. [
  3634. 3,
  3635. twoDimVertR1
  3636. ],
  3637. [
  3638. 3,
  3639. twoDimVertR1
  3640. ],
  3641. [
  3642. 3,
  3643. twoDimVertR1
  3644. ],
  3645. [
  3646. 3,
  3647. twoDimVertR1
  3648. ],
  3649. [
  3650. 3,
  3651. twoDimVertR1
  3652. ],
  3653. [
  3654. 1,
  3655. twoDimVert0
  3656. ],
  3657. [
  3658. 1,
  3659. twoDimVert0
  3660. ],
  3661. [
  3662. 1,
  3663. twoDimVert0
  3664. ],
  3665. [
  3666. 1,
  3667. twoDimVert0
  3668. ],
  3669. [
  3670. 1,
  3671. twoDimVert0
  3672. ],
  3673. [
  3674. 1,
  3675. twoDimVert0
  3676. ],
  3677. [
  3678. 1,
  3679. twoDimVert0
  3680. ],
  3681. [
  3682. 1,
  3683. twoDimVert0
  3684. ],
  3685. [
  3686. 1,
  3687. twoDimVert0
  3688. ],
  3689. [
  3690. 1,
  3691. twoDimVert0
  3692. ],
  3693. [
  3694. 1,
  3695. twoDimVert0
  3696. ],
  3697. [
  3698. 1,
  3699. twoDimVert0
  3700. ],
  3701. [
  3702. 1,
  3703. twoDimVert0
  3704. ],
  3705. [
  3706. 1,
  3707. twoDimVert0
  3708. ],
  3709. [
  3710. 1,
  3711. twoDimVert0
  3712. ],
  3713. [
  3714. 1,
  3715. twoDimVert0
  3716. ],
  3717. [
  3718. 1,
  3719. twoDimVert0
  3720. ],
  3721. [
  3722. 1,
  3723. twoDimVert0
  3724. ],
  3725. [
  3726. 1,
  3727. twoDimVert0
  3728. ],
  3729. [
  3730. 1,
  3731. twoDimVert0
  3732. ],
  3733. [
  3734. 1,
  3735. twoDimVert0
  3736. ],
  3737. [
  3738. 1,
  3739. twoDimVert0
  3740. ],
  3741. [
  3742. 1,
  3743. twoDimVert0
  3744. ],
  3745. [
  3746. 1,
  3747. twoDimVert0
  3748. ],
  3749. [
  3750. 1,
  3751. twoDimVert0
  3752. ],
  3753. [
  3754. 1,
  3755. twoDimVert0
  3756. ],
  3757. [
  3758. 1,
  3759. twoDimVert0
  3760. ],
  3761. [
  3762. 1,
  3763. twoDimVert0
  3764. ],
  3765. [
  3766. 1,
  3767. twoDimVert0
  3768. ],
  3769. [
  3770. 1,
  3771. twoDimVert0
  3772. ],
  3773. [
  3774. 1,
  3775. twoDimVert0
  3776. ],
  3777. [
  3778. 1,
  3779. twoDimVert0
  3780. ],
  3781. [
  3782. 1,
  3783. twoDimVert0
  3784. ],
  3785. [
  3786. 1,
  3787. twoDimVert0
  3788. ],
  3789. [
  3790. 1,
  3791. twoDimVert0
  3792. ],
  3793. [
  3794. 1,
  3795. twoDimVert0
  3796. ],
  3797. [
  3798. 1,
  3799. twoDimVert0
  3800. ],
  3801. [
  3802. 1,
  3803. twoDimVert0
  3804. ],
  3805. [
  3806. 1,
  3807. twoDimVert0
  3808. ],
  3809. [
  3810. 1,
  3811. twoDimVert0
  3812. ],
  3813. [
  3814. 1,
  3815. twoDimVert0
  3816. ],
  3817. [
  3818. 1,
  3819. twoDimVert0
  3820. ],
  3821. [
  3822. 1,
  3823. twoDimVert0
  3824. ],
  3825. [
  3826. 1,
  3827. twoDimVert0
  3828. ],
  3829. [
  3830. 1,
  3831. twoDimVert0
  3832. ],
  3833. [
  3834. 1,
  3835. twoDimVert0
  3836. ],
  3837. [
  3838. 1,
  3839. twoDimVert0
  3840. ],
  3841. [
  3842. 1,
  3843. twoDimVert0
  3844. ],
  3845. [
  3846. 1,
  3847. twoDimVert0
  3848. ],
  3849. [
  3850. 1,
  3851. twoDimVert0
  3852. ],
  3853. [
  3854. 1,
  3855. twoDimVert0
  3856. ],
  3857. [
  3858. 1,
  3859. twoDimVert0
  3860. ],
  3861. [
  3862. 1,
  3863. twoDimVert0
  3864. ],
  3865. [
  3866. 1,
  3867. twoDimVert0
  3868. ],
  3869. [
  3870. 1,
  3871. twoDimVert0
  3872. ],
  3873. [
  3874. 1,
  3875. twoDimVert0
  3876. ],
  3877. [
  3878. 1,
  3879. twoDimVert0
  3880. ],
  3881. [
  3882. 1,
  3883. twoDimVert0
  3884. ],
  3885. [
  3886. 1,
  3887. twoDimVert0
  3888. ],
  3889. [
  3890. 1,
  3891. twoDimVert0
  3892. ],
  3893. [
  3894. 1,
  3895. twoDimVert0
  3896. ],
  3897. [
  3898. 1,
  3899. twoDimVert0
  3900. ],
  3901. [
  3902. 1,
  3903. twoDimVert0
  3904. ],
  3905. [
  3906. 1,
  3907. twoDimVert0
  3908. ]
  3909. ];
  3910. var whiteTable1 = [
  3911. [
  3912. -1,
  3913. -1
  3914. ],
  3915. [
  3916. 12,
  3917. ccittEOL
  3918. ],
  3919. [
  3920. -1,
  3921. -1
  3922. ],
  3923. [
  3924. -1,
  3925. -1
  3926. ],
  3927. [
  3928. -1,
  3929. -1
  3930. ],
  3931. [
  3932. -1,
  3933. -1
  3934. ],
  3935. [
  3936. -1,
  3937. -1
  3938. ],
  3939. [
  3940. -1,
  3941. -1
  3942. ],
  3943. [
  3944. -1,
  3945. -1
  3946. ],
  3947. [
  3948. -1,
  3949. -1
  3950. ],
  3951. [
  3952. -1,
  3953. -1
  3954. ],
  3955. [
  3956. -1,
  3957. -1
  3958. ],
  3959. [
  3960. -1,
  3961. -1
  3962. ],
  3963. [
  3964. -1,
  3965. -1
  3966. ],
  3967. [
  3968. -1,
  3969. -1
  3970. ],
  3971. [
  3972. -1,
  3973. -1
  3974. ],
  3975. [
  3976. 11,
  3977. 1792
  3978. ],
  3979. [
  3980. 11,
  3981. 1792
  3982. ],
  3983. [
  3984. 12,
  3985. 1984
  3986. ],
  3987. [
  3988. 12,
  3989. 2048
  3990. ],
  3991. [
  3992. 12,
  3993. 2112
  3994. ],
  3995. [
  3996. 12,
  3997. 2176
  3998. ],
  3999. [
  4000. 12,
  4001. 2240
  4002. ],
  4003. [
  4004. 12,
  4005. 2304
  4006. ],
  4007. [
  4008. 11,
  4009. 1856
  4010. ],
  4011. [
  4012. 11,
  4013. 1856
  4014. ],
  4015. [
  4016. 11,
  4017. 1920
  4018. ],
  4019. [
  4020. 11,
  4021. 1920
  4022. ],
  4023. [
  4024. 12,
  4025. 2368
  4026. ],
  4027. [
  4028. 12,
  4029. 2432
  4030. ],
  4031. [
  4032. 12,
  4033. 2496
  4034. ],
  4035. [
  4036. 12,
  4037. 2560
  4038. ]
  4039. ];
  4040. var whiteTable2 = [
  4041. [
  4042. -1,
  4043. -1
  4044. ],
  4045. [
  4046. -1,
  4047. -1
  4048. ],
  4049. [
  4050. -1,
  4051. -1
  4052. ],
  4053. [
  4054. -1,
  4055. -1
  4056. ],
  4057. [
  4058. 8,
  4059. 29
  4060. ],
  4061. [
  4062. 8,
  4063. 29
  4064. ],
  4065. [
  4066. 8,
  4067. 30
  4068. ],
  4069. [
  4070. 8,
  4071. 30
  4072. ],
  4073. [
  4074. 8,
  4075. 45
  4076. ],
  4077. [
  4078. 8,
  4079. 45
  4080. ],
  4081. [
  4082. 8,
  4083. 46
  4084. ],
  4085. [
  4086. 8,
  4087. 46
  4088. ],
  4089. [
  4090. 7,
  4091. 22
  4092. ],
  4093. [
  4094. 7,
  4095. 22
  4096. ],
  4097. [
  4098. 7,
  4099. 22
  4100. ],
  4101. [
  4102. 7,
  4103. 22
  4104. ],
  4105. [
  4106. 7,
  4107. 23
  4108. ],
  4109. [
  4110. 7,
  4111. 23
  4112. ],
  4113. [
  4114. 7,
  4115. 23
  4116. ],
  4117. [
  4118. 7,
  4119. 23
  4120. ],
  4121. [
  4122. 8,
  4123. 47
  4124. ],
  4125. [
  4126. 8,
  4127. 47
  4128. ],
  4129. [
  4130. 8,
  4131. 48
  4132. ],
  4133. [
  4134. 8,
  4135. 48
  4136. ],
  4137. [
  4138. 6,
  4139. 13
  4140. ],
  4141. [
  4142. 6,
  4143. 13
  4144. ],
  4145. [
  4146. 6,
  4147. 13
  4148. ],
  4149. [
  4150. 6,
  4151. 13
  4152. ],
  4153. [
  4154. 6,
  4155. 13
  4156. ],
  4157. [
  4158. 6,
  4159. 13
  4160. ],
  4161. [
  4162. 6,
  4163. 13
  4164. ],
  4165. [
  4166. 6,
  4167. 13
  4168. ],
  4169. [
  4170. 7,
  4171. 20
  4172. ],
  4173. [
  4174. 7,
  4175. 20
  4176. ],
  4177. [
  4178. 7,
  4179. 20
  4180. ],
  4181. [
  4182. 7,
  4183. 20
  4184. ],
  4185. [
  4186. 8,
  4187. 33
  4188. ],
  4189. [
  4190. 8,
  4191. 33
  4192. ],
  4193. [
  4194. 8,
  4195. 34
  4196. ],
  4197. [
  4198. 8,
  4199. 34
  4200. ],
  4201. [
  4202. 8,
  4203. 35
  4204. ],
  4205. [
  4206. 8,
  4207. 35
  4208. ],
  4209. [
  4210. 8,
  4211. 36
  4212. ],
  4213. [
  4214. 8,
  4215. 36
  4216. ],
  4217. [
  4218. 8,
  4219. 37
  4220. ],
  4221. [
  4222. 8,
  4223. 37
  4224. ],
  4225. [
  4226. 8,
  4227. 38
  4228. ],
  4229. [
  4230. 8,
  4231. 38
  4232. ],
  4233. [
  4234. 7,
  4235. 19
  4236. ],
  4237. [
  4238. 7,
  4239. 19
  4240. ],
  4241. [
  4242. 7,
  4243. 19
  4244. ],
  4245. [
  4246. 7,
  4247. 19
  4248. ],
  4249. [
  4250. 8,
  4251. 31
  4252. ],
  4253. [
  4254. 8,
  4255. 31
  4256. ],
  4257. [
  4258. 8,
  4259. 32
  4260. ],
  4261. [
  4262. 8,
  4263. 32
  4264. ],
  4265. [
  4266. 6,
  4267. 1
  4268. ],
  4269. [
  4270. 6,
  4271. 1
  4272. ],
  4273. [
  4274. 6,
  4275. 1
  4276. ],
  4277. [
  4278. 6,
  4279. 1
  4280. ],
  4281. [
  4282. 6,
  4283. 1
  4284. ],
  4285. [
  4286. 6,
  4287. 1
  4288. ],
  4289. [
  4290. 6,
  4291. 1
  4292. ],
  4293. [
  4294. 6,
  4295. 1
  4296. ],
  4297. [
  4298. 6,
  4299. 12
  4300. ],
  4301. [
  4302. 6,
  4303. 12
  4304. ],
  4305. [
  4306. 6,
  4307. 12
  4308. ],
  4309. [
  4310. 6,
  4311. 12
  4312. ],
  4313. [
  4314. 6,
  4315. 12
  4316. ],
  4317. [
  4318. 6,
  4319. 12
  4320. ],
  4321. [
  4322. 6,
  4323. 12
  4324. ],
  4325. [
  4326. 6,
  4327. 12
  4328. ],
  4329. [
  4330. 8,
  4331. 53
  4332. ],
  4333. [
  4334. 8,
  4335. 53
  4336. ],
  4337. [
  4338. 8,
  4339. 54
  4340. ],
  4341. [
  4342. 8,
  4343. 54
  4344. ],
  4345. [
  4346. 7,
  4347. 26
  4348. ],
  4349. [
  4350. 7,
  4351. 26
  4352. ],
  4353. [
  4354. 7,
  4355. 26
  4356. ],
  4357. [
  4358. 7,
  4359. 26
  4360. ],
  4361. [
  4362. 8,
  4363. 39
  4364. ],
  4365. [
  4366. 8,
  4367. 39
  4368. ],
  4369. [
  4370. 8,
  4371. 40
  4372. ],
  4373. [
  4374. 8,
  4375. 40
  4376. ],
  4377. [
  4378. 8,
  4379. 41
  4380. ],
  4381. [
  4382. 8,
  4383. 41
  4384. ],
  4385. [
  4386. 8,
  4387. 42
  4388. ],
  4389. [
  4390. 8,
  4391. 42
  4392. ],
  4393. [
  4394. 8,
  4395. 43
  4396. ],
  4397. [
  4398. 8,
  4399. 43
  4400. ],
  4401. [
  4402. 8,
  4403. 44
  4404. ],
  4405. [
  4406. 8,
  4407. 44
  4408. ],
  4409. [
  4410. 7,
  4411. 21
  4412. ],
  4413. [
  4414. 7,
  4415. 21
  4416. ],
  4417. [
  4418. 7,
  4419. 21
  4420. ],
  4421. [
  4422. 7,
  4423. 21
  4424. ],
  4425. [
  4426. 7,
  4427. 28
  4428. ],
  4429. [
  4430. 7,
  4431. 28
  4432. ],
  4433. [
  4434. 7,
  4435. 28
  4436. ],
  4437. [
  4438. 7,
  4439. 28
  4440. ],
  4441. [
  4442. 8,
  4443. 61
  4444. ],
  4445. [
  4446. 8,
  4447. 61
  4448. ],
  4449. [
  4450. 8,
  4451. 62
  4452. ],
  4453. [
  4454. 8,
  4455. 62
  4456. ],
  4457. [
  4458. 8,
  4459. 63
  4460. ],
  4461. [
  4462. 8,
  4463. 63
  4464. ],
  4465. [
  4466. 8,
  4467. 0
  4468. ],
  4469. [
  4470. 8,
  4471. 0
  4472. ],
  4473. [
  4474. 8,
  4475. 320
  4476. ],
  4477. [
  4478. 8,
  4479. 320
  4480. ],
  4481. [
  4482. 8,
  4483. 384
  4484. ],
  4485. [
  4486. 8,
  4487. 384
  4488. ],
  4489. [
  4490. 5,
  4491. 10
  4492. ],
  4493. [
  4494. 5,
  4495. 10
  4496. ],
  4497. [
  4498. 5,
  4499. 10
  4500. ],
  4501. [
  4502. 5,
  4503. 10
  4504. ],
  4505. [
  4506. 5,
  4507. 10
  4508. ],
  4509. [
  4510. 5,
  4511. 10
  4512. ],
  4513. [
  4514. 5,
  4515. 10
  4516. ],
  4517. [
  4518. 5,
  4519. 10
  4520. ],
  4521. [
  4522. 5,
  4523. 10
  4524. ],
  4525. [
  4526. 5,
  4527. 10
  4528. ],
  4529. [
  4530. 5,
  4531. 10
  4532. ],
  4533. [
  4534. 5,
  4535. 10
  4536. ],
  4537. [
  4538. 5,
  4539. 10
  4540. ],
  4541. [
  4542. 5,
  4543. 10
  4544. ],
  4545. [
  4546. 5,
  4547. 10
  4548. ],
  4549. [
  4550. 5,
  4551. 10
  4552. ],
  4553. [
  4554. 5,
  4555. 11
  4556. ],
  4557. [
  4558. 5,
  4559. 11
  4560. ],
  4561. [
  4562. 5,
  4563. 11
  4564. ],
  4565. [
  4566. 5,
  4567. 11
  4568. ],
  4569. [
  4570. 5,
  4571. 11
  4572. ],
  4573. [
  4574. 5,
  4575. 11
  4576. ],
  4577. [
  4578. 5,
  4579. 11
  4580. ],
  4581. [
  4582. 5,
  4583. 11
  4584. ],
  4585. [
  4586. 5,
  4587. 11
  4588. ],
  4589. [
  4590. 5,
  4591. 11
  4592. ],
  4593. [
  4594. 5,
  4595. 11
  4596. ],
  4597. [
  4598. 5,
  4599. 11
  4600. ],
  4601. [
  4602. 5,
  4603. 11
  4604. ],
  4605. [
  4606. 5,
  4607. 11
  4608. ],
  4609. [
  4610. 5,
  4611. 11
  4612. ],
  4613. [
  4614. 5,
  4615. 11
  4616. ],
  4617. [
  4618. 7,
  4619. 27
  4620. ],
  4621. [
  4622. 7,
  4623. 27
  4624. ],
  4625. [
  4626. 7,
  4627. 27
  4628. ],
  4629. [
  4630. 7,
  4631. 27
  4632. ],
  4633. [
  4634. 8,
  4635. 59
  4636. ],
  4637. [
  4638. 8,
  4639. 59
  4640. ],
  4641. [
  4642. 8,
  4643. 60
  4644. ],
  4645. [
  4646. 8,
  4647. 60
  4648. ],
  4649. [
  4650. 9,
  4651. 1472
  4652. ],
  4653. [
  4654. 9,
  4655. 1536
  4656. ],
  4657. [
  4658. 9,
  4659. 1600
  4660. ],
  4661. [
  4662. 9,
  4663. 1728
  4664. ],
  4665. [
  4666. 7,
  4667. 18
  4668. ],
  4669. [
  4670. 7,
  4671. 18
  4672. ],
  4673. [
  4674. 7,
  4675. 18
  4676. ],
  4677. [
  4678. 7,
  4679. 18
  4680. ],
  4681. [
  4682. 7,
  4683. 24
  4684. ],
  4685. [
  4686. 7,
  4687. 24
  4688. ],
  4689. [
  4690. 7,
  4691. 24
  4692. ],
  4693. [
  4694. 7,
  4695. 24
  4696. ],
  4697. [
  4698. 8,
  4699. 49
  4700. ],
  4701. [
  4702. 8,
  4703. 49
  4704. ],
  4705. [
  4706. 8,
  4707. 50
  4708. ],
  4709. [
  4710. 8,
  4711. 50
  4712. ],
  4713. [
  4714. 8,
  4715. 51
  4716. ],
  4717. [
  4718. 8,
  4719. 51
  4720. ],
  4721. [
  4722. 8,
  4723. 52
  4724. ],
  4725. [
  4726. 8,
  4727. 52
  4728. ],
  4729. [
  4730. 7,
  4731. 25
  4732. ],
  4733. [
  4734. 7,
  4735. 25
  4736. ],
  4737. [
  4738. 7,
  4739. 25
  4740. ],
  4741. [
  4742. 7,
  4743. 25
  4744. ],
  4745. [
  4746. 8,
  4747. 55
  4748. ],
  4749. [
  4750. 8,
  4751. 55
  4752. ],
  4753. [
  4754. 8,
  4755. 56
  4756. ],
  4757. [
  4758. 8,
  4759. 56
  4760. ],
  4761. [
  4762. 8,
  4763. 57
  4764. ],
  4765. [
  4766. 8,
  4767. 57
  4768. ],
  4769. [
  4770. 8,
  4771. 58
  4772. ],
  4773. [
  4774. 8,
  4775. 58
  4776. ],
  4777. [
  4778. 6,
  4779. 192
  4780. ],
  4781. [
  4782. 6,
  4783. 192
  4784. ],
  4785. [
  4786. 6,
  4787. 192
  4788. ],
  4789. [
  4790. 6,
  4791. 192
  4792. ],
  4793. [
  4794. 6,
  4795. 192
  4796. ],
  4797. [
  4798. 6,
  4799. 192
  4800. ],
  4801. [
  4802. 6,
  4803. 192
  4804. ],
  4805. [
  4806. 6,
  4807. 192
  4808. ],
  4809. [
  4810. 6,
  4811. 1664
  4812. ],
  4813. [
  4814. 6,
  4815. 1664
  4816. ],
  4817. [
  4818. 6,
  4819. 1664
  4820. ],
  4821. [
  4822. 6,
  4823. 1664
  4824. ],
  4825. [
  4826. 6,
  4827. 1664
  4828. ],
  4829. [
  4830. 6,
  4831. 1664
  4832. ],
  4833. [
  4834. 6,
  4835. 1664
  4836. ],
  4837. [
  4838. 6,
  4839. 1664
  4840. ],
  4841. [
  4842. 8,
  4843. 448
  4844. ],
  4845. [
  4846. 8,
  4847. 448
  4848. ],
  4849. [
  4850. 8,
  4851. 512
  4852. ],
  4853. [
  4854. 8,
  4855. 512
  4856. ],
  4857. [
  4858. 9,
  4859. 704
  4860. ],
  4861. [
  4862. 9,
  4863. 768
  4864. ],
  4865. [
  4866. 8,
  4867. 640
  4868. ],
  4869. [
  4870. 8,
  4871. 640
  4872. ],
  4873. [
  4874. 8,
  4875. 576
  4876. ],
  4877. [
  4878. 8,
  4879. 576
  4880. ],
  4881. [
  4882. 9,
  4883. 832
  4884. ],
  4885. [
  4886. 9,
  4887. 896
  4888. ],
  4889. [
  4890. 9,
  4891. 960
  4892. ],
  4893. [
  4894. 9,
  4895. 1024
  4896. ],
  4897. [
  4898. 9,
  4899. 1088
  4900. ],
  4901. [
  4902. 9,
  4903. 1152
  4904. ],
  4905. [
  4906. 9,
  4907. 1216
  4908. ],
  4909. [
  4910. 9,
  4911. 1280
  4912. ],
  4913. [
  4914. 9,
  4915. 1344
  4916. ],
  4917. [
  4918. 9,
  4919. 1408
  4920. ],
  4921. [
  4922. 7,
  4923. 256
  4924. ],
  4925. [
  4926. 7,
  4927. 256
  4928. ],
  4929. [
  4930. 7,
  4931. 256
  4932. ],
  4933. [
  4934. 7,
  4935. 256
  4936. ],
  4937. [
  4938. 4,
  4939. 2
  4940. ],
  4941. [
  4942. 4,
  4943. 2
  4944. ],
  4945. [
  4946. 4,
  4947. 2
  4948. ],
  4949. [
  4950. 4,
  4951. 2
  4952. ],
  4953. [
  4954. 4,
  4955. 2
  4956. ],
  4957. [
  4958. 4,
  4959. 2
  4960. ],
  4961. [
  4962. 4,
  4963. 2
  4964. ],
  4965. [
  4966. 4,
  4967. 2
  4968. ],
  4969. [
  4970. 4,
  4971. 2
  4972. ],
  4973. [
  4974. 4,
  4975. 2
  4976. ],
  4977. [
  4978. 4,
  4979. 2
  4980. ],
  4981. [
  4982. 4,
  4983. 2
  4984. ],
  4985. [
  4986. 4,
  4987. 2
  4988. ],
  4989. [
  4990. 4,
  4991. 2
  4992. ],
  4993. [
  4994. 4,
  4995. 2
  4996. ],
  4997. [
  4998. 4,
  4999. 2
  5000. ],
  5001. [
  5002. 4,
  5003. 2
  5004. ],
  5005. [
  5006. 4,
  5007. 2
  5008. ],
  5009. [
  5010. 4,
  5011. 2
  5012. ],
  5013. [
  5014. 4,
  5015. 2
  5016. ],
  5017. [
  5018. 4,
  5019. 2
  5020. ],
  5021. [
  5022. 4,
  5023. 2
  5024. ],
  5025. [
  5026. 4,
  5027. 2
  5028. ],
  5029. [
  5030. 4,
  5031. 2
  5032. ],
  5033. [
  5034. 4,
  5035. 2
  5036. ],
  5037. [
  5038. 4,
  5039. 2
  5040. ],
  5041. [
  5042. 4,
  5043. 2
  5044. ],
  5045. [
  5046. 4,
  5047. 2
  5048. ],
  5049. [
  5050. 4,
  5051. 2
  5052. ],
  5053. [
  5054. 4,
  5055. 2
  5056. ],
  5057. [
  5058. 4,
  5059. 2
  5060. ],
  5061. [
  5062. 4,
  5063. 2
  5064. ],
  5065. [
  5066. 4,
  5067. 3
  5068. ],
  5069. [
  5070. 4,
  5071. 3
  5072. ],
  5073. [
  5074. 4,
  5075. 3
  5076. ],
  5077. [
  5078. 4,
  5079. 3
  5080. ],
  5081. [
  5082. 4,
  5083. 3
  5084. ],
  5085. [
  5086. 4,
  5087. 3
  5088. ],
  5089. [
  5090. 4,
  5091. 3
  5092. ],
  5093. [
  5094. 4,
  5095. 3
  5096. ],
  5097. [
  5098. 4,
  5099. 3
  5100. ],
  5101. [
  5102. 4,
  5103. 3
  5104. ],
  5105. [
  5106. 4,
  5107. 3
  5108. ],
  5109. [
  5110. 4,
  5111. 3
  5112. ],
  5113. [
  5114. 4,
  5115. 3
  5116. ],
  5117. [
  5118. 4,
  5119. 3
  5120. ],
  5121. [
  5122. 4,
  5123. 3
  5124. ],
  5125. [
  5126. 4,
  5127. 3
  5128. ],
  5129. [
  5130. 4,
  5131. 3
  5132. ],
  5133. [
  5134. 4,
  5135. 3
  5136. ],
  5137. [
  5138. 4,
  5139. 3
  5140. ],
  5141. [
  5142. 4,
  5143. 3
  5144. ],
  5145. [
  5146. 4,
  5147. 3
  5148. ],
  5149. [
  5150. 4,
  5151. 3
  5152. ],
  5153. [
  5154. 4,
  5155. 3
  5156. ],
  5157. [
  5158. 4,
  5159. 3
  5160. ],
  5161. [
  5162. 4,
  5163. 3
  5164. ],
  5165. [
  5166. 4,
  5167. 3
  5168. ],
  5169. [
  5170. 4,
  5171. 3
  5172. ],
  5173. [
  5174. 4,
  5175. 3
  5176. ],
  5177. [
  5178. 4,
  5179. 3
  5180. ],
  5181. [
  5182. 4,
  5183. 3
  5184. ],
  5185. [
  5186. 4,
  5187. 3
  5188. ],
  5189. [
  5190. 4,
  5191. 3
  5192. ],
  5193. [
  5194. 5,
  5195. 128
  5196. ],
  5197. [
  5198. 5,
  5199. 128
  5200. ],
  5201. [
  5202. 5,
  5203. 128
  5204. ],
  5205. [
  5206. 5,
  5207. 128
  5208. ],
  5209. [
  5210. 5,
  5211. 128
  5212. ],
  5213. [
  5214. 5,
  5215. 128
  5216. ],
  5217. [
  5218. 5,
  5219. 128
  5220. ],
  5221. [
  5222. 5,
  5223. 128
  5224. ],
  5225. [
  5226. 5,
  5227. 128
  5228. ],
  5229. [
  5230. 5,
  5231. 128
  5232. ],
  5233. [
  5234. 5,
  5235. 128
  5236. ],
  5237. [
  5238. 5,
  5239. 128
  5240. ],
  5241. [
  5242. 5,
  5243. 128
  5244. ],
  5245. [
  5246. 5,
  5247. 128
  5248. ],
  5249. [
  5250. 5,
  5251. 128
  5252. ],
  5253. [
  5254. 5,
  5255. 128
  5256. ],
  5257. [
  5258. 5,
  5259. 8
  5260. ],
  5261. [
  5262. 5,
  5263. 8
  5264. ],
  5265. [
  5266. 5,
  5267. 8
  5268. ],
  5269. [
  5270. 5,
  5271. 8
  5272. ],
  5273. [
  5274. 5,
  5275. 8
  5276. ],
  5277. [
  5278. 5,
  5279. 8
  5280. ],
  5281. [
  5282. 5,
  5283. 8
  5284. ],
  5285. [
  5286. 5,
  5287. 8
  5288. ],
  5289. [
  5290. 5,
  5291. 8
  5292. ],
  5293. [
  5294. 5,
  5295. 8
  5296. ],
  5297. [
  5298. 5,
  5299. 8
  5300. ],
  5301. [
  5302. 5,
  5303. 8
  5304. ],
  5305. [
  5306. 5,
  5307. 8
  5308. ],
  5309. [
  5310. 5,
  5311. 8
  5312. ],
  5313. [
  5314. 5,
  5315. 8
  5316. ],
  5317. [
  5318. 5,
  5319. 8
  5320. ],
  5321. [
  5322. 5,
  5323. 9
  5324. ],
  5325. [
  5326. 5,
  5327. 9
  5328. ],
  5329. [
  5330. 5,
  5331. 9
  5332. ],
  5333. [
  5334. 5,
  5335. 9
  5336. ],
  5337. [
  5338. 5,
  5339. 9
  5340. ],
  5341. [
  5342. 5,
  5343. 9
  5344. ],
  5345. [
  5346. 5,
  5347. 9
  5348. ],
  5349. [
  5350. 5,
  5351. 9
  5352. ],
  5353. [
  5354. 5,
  5355. 9
  5356. ],
  5357. [
  5358. 5,
  5359. 9
  5360. ],
  5361. [
  5362. 5,
  5363. 9
  5364. ],
  5365. [
  5366. 5,
  5367. 9
  5368. ],
  5369. [
  5370. 5,
  5371. 9
  5372. ],
  5373. [
  5374. 5,
  5375. 9
  5376. ],
  5377. [
  5378. 5,
  5379. 9
  5380. ],
  5381. [
  5382. 5,
  5383. 9
  5384. ],
  5385. [
  5386. 6,
  5387. 16
  5388. ],
  5389. [
  5390. 6,
  5391. 16
  5392. ],
  5393. [
  5394. 6,
  5395. 16
  5396. ],
  5397. [
  5398. 6,
  5399. 16
  5400. ],
  5401. [
  5402. 6,
  5403. 16
  5404. ],
  5405. [
  5406. 6,
  5407. 16
  5408. ],
  5409. [
  5410. 6,
  5411. 16
  5412. ],
  5413. [
  5414. 6,
  5415. 16
  5416. ],
  5417. [
  5418. 6,
  5419. 17
  5420. ],
  5421. [
  5422. 6,
  5423. 17
  5424. ],
  5425. [
  5426. 6,
  5427. 17
  5428. ],
  5429. [
  5430. 6,
  5431. 17
  5432. ],
  5433. [
  5434. 6,
  5435. 17
  5436. ],
  5437. [
  5438. 6,
  5439. 17
  5440. ],
  5441. [
  5442. 6,
  5443. 17
  5444. ],
  5445. [
  5446. 6,
  5447. 17
  5448. ],
  5449. [
  5450. 4,
  5451. 4
  5452. ],
  5453. [
  5454. 4,
  5455. 4
  5456. ],
  5457. [
  5458. 4,
  5459. 4
  5460. ],
  5461. [
  5462. 4,
  5463. 4
  5464. ],
  5465. [
  5466. 4,
  5467. 4
  5468. ],
  5469. [
  5470. 4,
  5471. 4
  5472. ],
  5473. [
  5474. 4,
  5475. 4
  5476. ],
  5477. [
  5478. 4,
  5479. 4
  5480. ],
  5481. [
  5482. 4,
  5483. 4
  5484. ],
  5485. [
  5486. 4,
  5487. 4
  5488. ],
  5489. [
  5490. 4,
  5491. 4
  5492. ],
  5493. [
  5494. 4,
  5495. 4
  5496. ],
  5497. [
  5498. 4,
  5499. 4
  5500. ],
  5501. [
  5502. 4,
  5503. 4
  5504. ],
  5505. [
  5506. 4,
  5507. 4
  5508. ],
  5509. [
  5510. 4,
  5511. 4
  5512. ],
  5513. [
  5514. 4,
  5515. 4
  5516. ],
  5517. [
  5518. 4,
  5519. 4
  5520. ],
  5521. [
  5522. 4,
  5523. 4
  5524. ],
  5525. [
  5526. 4,
  5527. 4
  5528. ],
  5529. [
  5530. 4,
  5531. 4
  5532. ],
  5533. [
  5534. 4,
  5535. 4
  5536. ],
  5537. [
  5538. 4,
  5539. 4
  5540. ],
  5541. [
  5542. 4,
  5543. 4
  5544. ],
  5545. [
  5546. 4,
  5547. 4
  5548. ],
  5549. [
  5550. 4,
  5551. 4
  5552. ],
  5553. [
  5554. 4,
  5555. 4
  5556. ],
  5557. [
  5558. 4,
  5559. 4
  5560. ],
  5561. [
  5562. 4,
  5563. 4
  5564. ],
  5565. [
  5566. 4,
  5567. 4
  5568. ],
  5569. [
  5570. 4,
  5571. 4
  5572. ],
  5573. [
  5574. 4,
  5575. 4
  5576. ],
  5577. [
  5578. 4,
  5579. 5
  5580. ],
  5581. [
  5582. 4,
  5583. 5
  5584. ],
  5585. [
  5586. 4,
  5587. 5
  5588. ],
  5589. [
  5590. 4,
  5591. 5
  5592. ],
  5593. [
  5594. 4,
  5595. 5
  5596. ],
  5597. [
  5598. 4,
  5599. 5
  5600. ],
  5601. [
  5602. 4,
  5603. 5
  5604. ],
  5605. [
  5606. 4,
  5607. 5
  5608. ],
  5609. [
  5610. 4,
  5611. 5
  5612. ],
  5613. [
  5614. 4,
  5615. 5
  5616. ],
  5617. [
  5618. 4,
  5619. 5
  5620. ],
  5621. [
  5622. 4,
  5623. 5
  5624. ],
  5625. [
  5626. 4,
  5627. 5
  5628. ],
  5629. [
  5630. 4,
  5631. 5
  5632. ],
  5633. [
  5634. 4,
  5635. 5
  5636. ],
  5637. [
  5638. 4,
  5639. 5
  5640. ],
  5641. [
  5642. 4,
  5643. 5
  5644. ],
  5645. [
  5646. 4,
  5647. 5
  5648. ],
  5649. [
  5650. 4,
  5651. 5
  5652. ],
  5653. [
  5654. 4,
  5655. 5
  5656. ],
  5657. [
  5658. 4,
  5659. 5
  5660. ],
  5661. [
  5662. 4,
  5663. 5
  5664. ],
  5665. [
  5666. 4,
  5667. 5
  5668. ],
  5669. [
  5670. 4,
  5671. 5
  5672. ],
  5673. [
  5674. 4,
  5675. 5
  5676. ],
  5677. [
  5678. 4,
  5679. 5
  5680. ],
  5681. [
  5682. 4,
  5683. 5
  5684. ],
  5685. [
  5686. 4,
  5687. 5
  5688. ],
  5689. [
  5690. 4,
  5691. 5
  5692. ],
  5693. [
  5694. 4,
  5695. 5
  5696. ],
  5697. [
  5698. 4,
  5699. 5
  5700. ],
  5701. [
  5702. 4,
  5703. 5
  5704. ],
  5705. [
  5706. 6,
  5707. 14
  5708. ],
  5709. [
  5710. 6,
  5711. 14
  5712. ],
  5713. [
  5714. 6,
  5715. 14
  5716. ],
  5717. [
  5718. 6,
  5719. 14
  5720. ],
  5721. [
  5722. 6,
  5723. 14
  5724. ],
  5725. [
  5726. 6,
  5727. 14
  5728. ],
  5729. [
  5730. 6,
  5731. 14
  5732. ],
  5733. [
  5734. 6,
  5735. 14
  5736. ],
  5737. [
  5738. 6,
  5739. 15
  5740. ],
  5741. [
  5742. 6,
  5743. 15
  5744. ],
  5745. [
  5746. 6,
  5747. 15
  5748. ],
  5749. [
  5750. 6,
  5751. 15
  5752. ],
  5753. [
  5754. 6,
  5755. 15
  5756. ],
  5757. [
  5758. 6,
  5759. 15
  5760. ],
  5761. [
  5762. 6,
  5763. 15
  5764. ],
  5765. [
  5766. 6,
  5767. 15
  5768. ],
  5769. [
  5770. 5,
  5771. 64
  5772. ],
  5773. [
  5774. 5,
  5775. 64
  5776. ],
  5777. [
  5778. 5,
  5779. 64
  5780. ],
  5781. [
  5782. 5,
  5783. 64
  5784. ],
  5785. [
  5786. 5,
  5787. 64
  5788. ],
  5789. [
  5790. 5,
  5791. 64
  5792. ],
  5793. [
  5794. 5,
  5795. 64
  5796. ],
  5797. [
  5798. 5,
  5799. 64
  5800. ],
  5801. [
  5802. 5,
  5803. 64
  5804. ],
  5805. [
  5806. 5,
  5807. 64
  5808. ],
  5809. [
  5810. 5,
  5811. 64
  5812. ],
  5813. [
  5814. 5,
  5815. 64
  5816. ],
  5817. [
  5818. 5,
  5819. 64
  5820. ],
  5821. [
  5822. 5,
  5823. 64
  5824. ],
  5825. [
  5826. 5,
  5827. 64
  5828. ],
  5829. [
  5830. 5,
  5831. 64
  5832. ],
  5833. [
  5834. 4,
  5835. 6
  5836. ],
  5837. [
  5838. 4,
  5839. 6
  5840. ],
  5841. [
  5842. 4,
  5843. 6
  5844. ],
  5845. [
  5846. 4,
  5847. 6
  5848. ],
  5849. [
  5850. 4,
  5851. 6
  5852. ],
  5853. [
  5854. 4,
  5855. 6
  5856. ],
  5857. [
  5858. 4,
  5859. 6
  5860. ],
  5861. [
  5862. 4,
  5863. 6
  5864. ],
  5865. [
  5866. 4,
  5867. 6
  5868. ],
  5869. [
  5870. 4,
  5871. 6
  5872. ],
  5873. [
  5874. 4,
  5875. 6
  5876. ],
  5877. [
  5878. 4,
  5879. 6
  5880. ],
  5881. [
  5882. 4,
  5883. 6
  5884. ],
  5885. [
  5886. 4,
  5887. 6
  5888. ],
  5889. [
  5890. 4,
  5891. 6
  5892. ],
  5893. [
  5894. 4,
  5895. 6
  5896. ],
  5897. [
  5898. 4,
  5899. 6
  5900. ],
  5901. [
  5902. 4,
  5903. 6
  5904. ],
  5905. [
  5906. 4,
  5907. 6
  5908. ],
  5909. [
  5910. 4,
  5911. 6
  5912. ],
  5913. [
  5914. 4,
  5915. 6
  5916. ],
  5917. [
  5918. 4,
  5919. 6
  5920. ],
  5921. [
  5922. 4,
  5923. 6
  5924. ],
  5925. [
  5926. 4,
  5927. 6
  5928. ],
  5929. [
  5930. 4,
  5931. 6
  5932. ],
  5933. [
  5934. 4,
  5935. 6
  5936. ],
  5937. [
  5938. 4,
  5939. 6
  5940. ],
  5941. [
  5942. 4,
  5943. 6
  5944. ],
  5945. [
  5946. 4,
  5947. 6
  5948. ],
  5949. [
  5950. 4,
  5951. 6
  5952. ],
  5953. [
  5954. 4,
  5955. 6
  5956. ],
  5957. [
  5958. 4,
  5959. 6
  5960. ],
  5961. [
  5962. 4,
  5963. 7
  5964. ],
  5965. [
  5966. 4,
  5967. 7
  5968. ],
  5969. [
  5970. 4,
  5971. 7
  5972. ],
  5973. [
  5974. 4,
  5975. 7
  5976. ],
  5977. [
  5978. 4,
  5979. 7
  5980. ],
  5981. [
  5982. 4,
  5983. 7
  5984. ],
  5985. [
  5986. 4,
  5987. 7
  5988. ],
  5989. [
  5990. 4,
  5991. 7
  5992. ],
  5993. [
  5994. 4,
  5995. 7
  5996. ],
  5997. [
  5998. 4,
  5999. 7
  6000. ],
  6001. [
  6002. 4,
  6003. 7
  6004. ],
  6005. [
  6006. 4,
  6007. 7
  6008. ],
  6009. [
  6010. 4,
  6011. 7
  6012. ],
  6013. [
  6014. 4,
  6015. 7
  6016. ],
  6017. [
  6018. 4,
  6019. 7
  6020. ],
  6021. [
  6022. 4,
  6023. 7
  6024. ],
  6025. [
  6026. 4,
  6027. 7
  6028. ],
  6029. [
  6030. 4,
  6031. 7
  6032. ],
  6033. [
  6034. 4,
  6035. 7
  6036. ],
  6037. [
  6038. 4,
  6039. 7
  6040. ],
  6041. [
  6042. 4,
  6043. 7
  6044. ],
  6045. [
  6046. 4,
  6047. 7
  6048. ],
  6049. [
  6050. 4,
  6051. 7
  6052. ],
  6053. [
  6054. 4,
  6055. 7
  6056. ],
  6057. [
  6058. 4,
  6059. 7
  6060. ],
  6061. [
  6062. 4,
  6063. 7
  6064. ],
  6065. [
  6066. 4,
  6067. 7
  6068. ],
  6069. [
  6070. 4,
  6071. 7
  6072. ],
  6073. [
  6074. 4,
  6075. 7
  6076. ],
  6077. [
  6078. 4,
  6079. 7
  6080. ],
  6081. [
  6082. 4,
  6083. 7
  6084. ],
  6085. [
  6086. 4,
  6087. 7
  6088. ]
  6089. ];
  6090. var blackTable1 = [
  6091. [
  6092. -1,
  6093. -1
  6094. ],
  6095. [
  6096. -1,
  6097. -1
  6098. ],
  6099. [
  6100. 12,
  6101. ccittEOL
  6102. ],
  6103. [
  6104. 12,
  6105. ccittEOL
  6106. ],
  6107. [
  6108. -1,
  6109. -1
  6110. ],
  6111. [
  6112. -1,
  6113. -1
  6114. ],
  6115. [
  6116. -1,
  6117. -1
  6118. ],
  6119. [
  6120. -1,
  6121. -1
  6122. ],
  6123. [
  6124. -1,
  6125. -1
  6126. ],
  6127. [
  6128. -1,
  6129. -1
  6130. ],
  6131. [
  6132. -1,
  6133. -1
  6134. ],
  6135. [
  6136. -1,
  6137. -1
  6138. ],
  6139. [
  6140. -1,
  6141. -1
  6142. ],
  6143. [
  6144. -1,
  6145. -1
  6146. ],
  6147. [
  6148. -1,
  6149. -1
  6150. ],
  6151. [
  6152. -1,
  6153. -1
  6154. ],
  6155. [
  6156. -1,
  6157. -1
  6158. ],
  6159. [
  6160. -1,
  6161. -1
  6162. ],
  6163. [
  6164. -1,
  6165. -1
  6166. ],
  6167. [
  6168. -1,
  6169. -1
  6170. ],
  6171. [
  6172. -1,
  6173. -1
  6174. ],
  6175. [
  6176. -1,
  6177. -1
  6178. ],
  6179. [
  6180. -1,
  6181. -1
  6182. ],
  6183. [
  6184. -1,
  6185. -1
  6186. ],
  6187. [
  6188. -1,
  6189. -1
  6190. ],
  6191. [
  6192. -1,
  6193. -1
  6194. ],
  6195. [
  6196. -1,
  6197. -1
  6198. ],
  6199. [
  6200. -1,
  6201. -1
  6202. ],
  6203. [
  6204. -1,
  6205. -1
  6206. ],
  6207. [
  6208. -1,
  6209. -1
  6210. ],
  6211. [
  6212. -1,
  6213. -1
  6214. ],
  6215. [
  6216. -1,
  6217. -1
  6218. ],
  6219. [
  6220. 11,
  6221. 1792
  6222. ],
  6223. [
  6224. 11,
  6225. 1792
  6226. ],
  6227. [
  6228. 11,
  6229. 1792
  6230. ],
  6231. [
  6232. 11,
  6233. 1792
  6234. ],
  6235. [
  6236. 12,
  6237. 1984
  6238. ],
  6239. [
  6240. 12,
  6241. 1984
  6242. ],
  6243. [
  6244. 12,
  6245. 2048
  6246. ],
  6247. [
  6248. 12,
  6249. 2048
  6250. ],
  6251. [
  6252. 12,
  6253. 2112
  6254. ],
  6255. [
  6256. 12,
  6257. 2112
  6258. ],
  6259. [
  6260. 12,
  6261. 2176
  6262. ],
  6263. [
  6264. 12,
  6265. 2176
  6266. ],
  6267. [
  6268. 12,
  6269. 2240
  6270. ],
  6271. [
  6272. 12,
  6273. 2240
  6274. ],
  6275. [
  6276. 12,
  6277. 2304
  6278. ],
  6279. [
  6280. 12,
  6281. 2304
  6282. ],
  6283. [
  6284. 11,
  6285. 1856
  6286. ],
  6287. [
  6288. 11,
  6289. 1856
  6290. ],
  6291. [
  6292. 11,
  6293. 1856
  6294. ],
  6295. [
  6296. 11,
  6297. 1856
  6298. ],
  6299. [
  6300. 11,
  6301. 1920
  6302. ],
  6303. [
  6304. 11,
  6305. 1920
  6306. ],
  6307. [
  6308. 11,
  6309. 1920
  6310. ],
  6311. [
  6312. 11,
  6313. 1920
  6314. ],
  6315. [
  6316. 12,
  6317. 2368
  6318. ],
  6319. [
  6320. 12,
  6321. 2368
  6322. ],
  6323. [
  6324. 12,
  6325. 2432
  6326. ],
  6327. [
  6328. 12,
  6329. 2432
  6330. ],
  6331. [
  6332. 12,
  6333. 2496
  6334. ],
  6335. [
  6336. 12,
  6337. 2496
  6338. ],
  6339. [
  6340. 12,
  6341. 2560
  6342. ],
  6343. [
  6344. 12,
  6345. 2560
  6346. ],
  6347. [
  6348. 10,
  6349. 18
  6350. ],
  6351. [
  6352. 10,
  6353. 18
  6354. ],
  6355. [
  6356. 10,
  6357. 18
  6358. ],
  6359. [
  6360. 10,
  6361. 18
  6362. ],
  6363. [
  6364. 10,
  6365. 18
  6366. ],
  6367. [
  6368. 10,
  6369. 18
  6370. ],
  6371. [
  6372. 10,
  6373. 18
  6374. ],
  6375. [
  6376. 10,
  6377. 18
  6378. ],
  6379. [
  6380. 12,
  6381. 52
  6382. ],
  6383. [
  6384. 12,
  6385. 52
  6386. ],
  6387. [
  6388. 13,
  6389. 640
  6390. ],
  6391. [
  6392. 13,
  6393. 704
  6394. ],
  6395. [
  6396. 13,
  6397. 768
  6398. ],
  6399. [
  6400. 13,
  6401. 832
  6402. ],
  6403. [
  6404. 12,
  6405. 55
  6406. ],
  6407. [
  6408. 12,
  6409. 55
  6410. ],
  6411. [
  6412. 12,
  6413. 56
  6414. ],
  6415. [
  6416. 12,
  6417. 56
  6418. ],
  6419. [
  6420. 13,
  6421. 1280
  6422. ],
  6423. [
  6424. 13,
  6425. 1344
  6426. ],
  6427. [
  6428. 13,
  6429. 1408
  6430. ],
  6431. [
  6432. 13,
  6433. 1472
  6434. ],
  6435. [
  6436. 12,
  6437. 59
  6438. ],
  6439. [
  6440. 12,
  6441. 59
  6442. ],
  6443. [
  6444. 12,
  6445. 60
  6446. ],
  6447. [
  6448. 12,
  6449. 60
  6450. ],
  6451. [
  6452. 13,
  6453. 1536
  6454. ],
  6455. [
  6456. 13,
  6457. 1600
  6458. ],
  6459. [
  6460. 11,
  6461. 24
  6462. ],
  6463. [
  6464. 11,
  6465. 24
  6466. ],
  6467. [
  6468. 11,
  6469. 24
  6470. ],
  6471. [
  6472. 11,
  6473. 24
  6474. ],
  6475. [
  6476. 11,
  6477. 25
  6478. ],
  6479. [
  6480. 11,
  6481. 25
  6482. ],
  6483. [
  6484. 11,
  6485. 25
  6486. ],
  6487. [
  6488. 11,
  6489. 25
  6490. ],
  6491. [
  6492. 13,
  6493. 1664
  6494. ],
  6495. [
  6496. 13,
  6497. 1728
  6498. ],
  6499. [
  6500. 12,
  6501. 320
  6502. ],
  6503. [
  6504. 12,
  6505. 320
  6506. ],
  6507. [
  6508. 12,
  6509. 384
  6510. ],
  6511. [
  6512. 12,
  6513. 384
  6514. ],
  6515. [
  6516. 12,
  6517. 448
  6518. ],
  6519. [
  6520. 12,
  6521. 448
  6522. ],
  6523. [
  6524. 13,
  6525. 512
  6526. ],
  6527. [
  6528. 13,
  6529. 576
  6530. ],
  6531. [
  6532. 12,
  6533. 53
  6534. ],
  6535. [
  6536. 12,
  6537. 53
  6538. ],
  6539. [
  6540. 12,
  6541. 54
  6542. ],
  6543. [
  6544. 12,
  6545. 54
  6546. ],
  6547. [
  6548. 13,
  6549. 896
  6550. ],
  6551. [
  6552. 13,
  6553. 960
  6554. ],
  6555. [
  6556. 13,
  6557. 1024
  6558. ],
  6559. [
  6560. 13,
  6561. 1088
  6562. ],
  6563. [
  6564. 13,
  6565. 1152
  6566. ],
  6567. [
  6568. 13,
  6569. 1216
  6570. ],
  6571. [
  6572. 10,
  6573. 64
  6574. ],
  6575. [
  6576. 10,
  6577. 64
  6578. ],
  6579. [
  6580. 10,
  6581. 64
  6582. ],
  6583. [
  6584. 10,
  6585. 64
  6586. ],
  6587. [
  6588. 10,
  6589. 64
  6590. ],
  6591. [
  6592. 10,
  6593. 64
  6594. ],
  6595. [
  6596. 10,
  6597. 64
  6598. ],
  6599. [
  6600. 10,
  6601. 64
  6602. ]
  6603. ];
  6604. var blackTable2 = [
  6605. [
  6606. 8,
  6607. 13
  6608. ],
  6609. [
  6610. 8,
  6611. 13
  6612. ],
  6613. [
  6614. 8,
  6615. 13
  6616. ],
  6617. [
  6618. 8,
  6619. 13
  6620. ],
  6621. [
  6622. 8,
  6623. 13
  6624. ],
  6625. [
  6626. 8,
  6627. 13
  6628. ],
  6629. [
  6630. 8,
  6631. 13
  6632. ],
  6633. [
  6634. 8,
  6635. 13
  6636. ],
  6637. [
  6638. 8,
  6639. 13
  6640. ],
  6641. [
  6642. 8,
  6643. 13
  6644. ],
  6645. [
  6646. 8,
  6647. 13
  6648. ],
  6649. [
  6650. 8,
  6651. 13
  6652. ],
  6653. [
  6654. 8,
  6655. 13
  6656. ],
  6657. [
  6658. 8,
  6659. 13
  6660. ],
  6661. [
  6662. 8,
  6663. 13
  6664. ],
  6665. [
  6666. 8,
  6667. 13
  6668. ],
  6669. [
  6670. 11,
  6671. 23
  6672. ],
  6673. [
  6674. 11,
  6675. 23
  6676. ],
  6677. [
  6678. 12,
  6679. 50
  6680. ],
  6681. [
  6682. 12,
  6683. 51
  6684. ],
  6685. [
  6686. 12,
  6687. 44
  6688. ],
  6689. [
  6690. 12,
  6691. 45
  6692. ],
  6693. [
  6694. 12,
  6695. 46
  6696. ],
  6697. [
  6698. 12,
  6699. 47
  6700. ],
  6701. [
  6702. 12,
  6703. 57
  6704. ],
  6705. [
  6706. 12,
  6707. 58
  6708. ],
  6709. [
  6710. 12,
  6711. 61
  6712. ],
  6713. [
  6714. 12,
  6715. 256
  6716. ],
  6717. [
  6718. 10,
  6719. 16
  6720. ],
  6721. [
  6722. 10,
  6723. 16
  6724. ],
  6725. [
  6726. 10,
  6727. 16
  6728. ],
  6729. [
  6730. 10,
  6731. 16
  6732. ],
  6733. [
  6734. 10,
  6735. 17
  6736. ],
  6737. [
  6738. 10,
  6739. 17
  6740. ],
  6741. [
  6742. 10,
  6743. 17
  6744. ],
  6745. [
  6746. 10,
  6747. 17
  6748. ],
  6749. [
  6750. 12,
  6751. 48
  6752. ],
  6753. [
  6754. 12,
  6755. 49
  6756. ],
  6757. [
  6758. 12,
  6759. 62
  6760. ],
  6761. [
  6762. 12,
  6763. 63
  6764. ],
  6765. [
  6766. 12,
  6767. 30
  6768. ],
  6769. [
  6770. 12,
  6771. 31
  6772. ],
  6773. [
  6774. 12,
  6775. 32
  6776. ],
  6777. [
  6778. 12,
  6779. 33
  6780. ],
  6781. [
  6782. 12,
  6783. 40
  6784. ],
  6785. [
  6786. 12,
  6787. 41
  6788. ],
  6789. [
  6790. 11,
  6791. 22
  6792. ],
  6793. [
  6794. 11,
  6795. 22
  6796. ],
  6797. [
  6798. 8,
  6799. 14
  6800. ],
  6801. [
  6802. 8,
  6803. 14
  6804. ],
  6805. [
  6806. 8,
  6807. 14
  6808. ],
  6809. [
  6810. 8,
  6811. 14
  6812. ],
  6813. [
  6814. 8,
  6815. 14
  6816. ],
  6817. [
  6818. 8,
  6819. 14
  6820. ],
  6821. [
  6822. 8,
  6823. 14
  6824. ],
  6825. [
  6826. 8,
  6827. 14
  6828. ],
  6829. [
  6830. 8,
  6831. 14
  6832. ],
  6833. [
  6834. 8,
  6835. 14
  6836. ],
  6837. [
  6838. 8,
  6839. 14
  6840. ],
  6841. [
  6842. 8,
  6843. 14
  6844. ],
  6845. [
  6846. 8,
  6847. 14
  6848. ],
  6849. [
  6850. 8,
  6851. 14
  6852. ],
  6853. [
  6854. 8,
  6855. 14
  6856. ],
  6857. [
  6858. 8,
  6859. 14
  6860. ],
  6861. [
  6862. 7,
  6863. 10
  6864. ],
  6865. [
  6866. 7,
  6867. 10
  6868. ],
  6869. [
  6870. 7,
  6871. 10
  6872. ],
  6873. [
  6874. 7,
  6875. 10
  6876. ],
  6877. [
  6878. 7,
  6879. 10
  6880. ],
  6881. [
  6882. 7,
  6883. 10
  6884. ],
  6885. [
  6886. 7,
  6887. 10
  6888. ],
  6889. [
  6890. 7,
  6891. 10
  6892. ],
  6893. [
  6894. 7,
  6895. 10
  6896. ],
  6897. [
  6898. 7,
  6899. 10
  6900. ],
  6901. [
  6902. 7,
  6903. 10
  6904. ],
  6905. [
  6906. 7,
  6907. 10
  6908. ],
  6909. [
  6910. 7,
  6911. 10
  6912. ],
  6913. [
  6914. 7,
  6915. 10
  6916. ],
  6917. [
  6918. 7,
  6919. 10
  6920. ],
  6921. [
  6922. 7,
  6923. 10
  6924. ],
  6925. [
  6926. 7,
  6927. 10
  6928. ],
  6929. [
  6930. 7,
  6931. 10
  6932. ],
  6933. [
  6934. 7,
  6935. 10
  6936. ],
  6937. [
  6938. 7,
  6939. 10
  6940. ],
  6941. [
  6942. 7,
  6943. 10
  6944. ],
  6945. [
  6946. 7,
  6947. 10
  6948. ],
  6949. [
  6950. 7,
  6951. 10
  6952. ],
  6953. [
  6954. 7,
  6955. 10
  6956. ],
  6957. [
  6958. 7,
  6959. 10
  6960. ],
  6961. [
  6962. 7,
  6963. 10
  6964. ],
  6965. [
  6966. 7,
  6967. 10
  6968. ],
  6969. [
  6970. 7,
  6971. 10
  6972. ],
  6973. [
  6974. 7,
  6975. 10
  6976. ],
  6977. [
  6978. 7,
  6979. 10
  6980. ],
  6981. [
  6982. 7,
  6983. 10
  6984. ],
  6985. [
  6986. 7,
  6987. 10
  6988. ],
  6989. [
  6990. 7,
  6991. 11
  6992. ],
  6993. [
  6994. 7,
  6995. 11
  6996. ],
  6997. [
  6998. 7,
  6999. 11
  7000. ],
  7001. [
  7002. 7,
  7003. 11
  7004. ],
  7005. [
  7006. 7,
  7007. 11
  7008. ],
  7009. [
  7010. 7,
  7011. 11
  7012. ],
  7013. [
  7014. 7,
  7015. 11
  7016. ],
  7017. [
  7018. 7,
  7019. 11
  7020. ],
  7021. [
  7022. 7,
  7023. 11
  7024. ],
  7025. [
  7026. 7,
  7027. 11
  7028. ],
  7029. [
  7030. 7,
  7031. 11
  7032. ],
  7033. [
  7034. 7,
  7035. 11
  7036. ],
  7037. [
  7038. 7,
  7039. 11
  7040. ],
  7041. [
  7042. 7,
  7043. 11
  7044. ],
  7045. [
  7046. 7,
  7047. 11
  7048. ],
  7049. [
  7050. 7,
  7051. 11
  7052. ],
  7053. [
  7054. 7,
  7055. 11
  7056. ],
  7057. [
  7058. 7,
  7059. 11
  7060. ],
  7061. [
  7062. 7,
  7063. 11
  7064. ],
  7065. [
  7066. 7,
  7067. 11
  7068. ],
  7069. [
  7070. 7,
  7071. 11
  7072. ],
  7073. [
  7074. 7,
  7075. 11
  7076. ],
  7077. [
  7078. 7,
  7079. 11
  7080. ],
  7081. [
  7082. 7,
  7083. 11
  7084. ],
  7085. [
  7086. 7,
  7087. 11
  7088. ],
  7089. [
  7090. 7,
  7091. 11
  7092. ],
  7093. [
  7094. 7,
  7095. 11
  7096. ],
  7097. [
  7098. 7,
  7099. 11
  7100. ],
  7101. [
  7102. 7,
  7103. 11
  7104. ],
  7105. [
  7106. 7,
  7107. 11
  7108. ],
  7109. [
  7110. 7,
  7111. 11
  7112. ],
  7113. [
  7114. 7,
  7115. 11
  7116. ],
  7117. [
  7118. 9,
  7119. 15
  7120. ],
  7121. [
  7122. 9,
  7123. 15
  7124. ],
  7125. [
  7126. 9,
  7127. 15
  7128. ],
  7129. [
  7130. 9,
  7131. 15
  7132. ],
  7133. [
  7134. 9,
  7135. 15
  7136. ],
  7137. [
  7138. 9,
  7139. 15
  7140. ],
  7141. [
  7142. 9,
  7143. 15
  7144. ],
  7145. [
  7146. 9,
  7147. 15
  7148. ],
  7149. [
  7150. 12,
  7151. 128
  7152. ],
  7153. [
  7154. 12,
  7155. 192
  7156. ],
  7157. [
  7158. 12,
  7159. 26
  7160. ],
  7161. [
  7162. 12,
  7163. 27
  7164. ],
  7165. [
  7166. 12,
  7167. 28
  7168. ],
  7169. [
  7170. 12,
  7171. 29
  7172. ],
  7173. [
  7174. 11,
  7175. 19
  7176. ],
  7177. [
  7178. 11,
  7179. 19
  7180. ],
  7181. [
  7182. 11,
  7183. 20
  7184. ],
  7185. [
  7186. 11,
  7187. 20
  7188. ],
  7189. [
  7190. 12,
  7191. 34
  7192. ],
  7193. [
  7194. 12,
  7195. 35
  7196. ],
  7197. [
  7198. 12,
  7199. 36
  7200. ],
  7201. [
  7202. 12,
  7203. 37
  7204. ],
  7205. [
  7206. 12,
  7207. 38
  7208. ],
  7209. [
  7210. 12,
  7211. 39
  7212. ],
  7213. [
  7214. 11,
  7215. 21
  7216. ],
  7217. [
  7218. 11,
  7219. 21
  7220. ],
  7221. [
  7222. 12,
  7223. 42
  7224. ],
  7225. [
  7226. 12,
  7227. 43
  7228. ],
  7229. [
  7230. 10,
  7231. 0
  7232. ],
  7233. [
  7234. 10,
  7235. 0
  7236. ],
  7237. [
  7238. 10,
  7239. 0
  7240. ],
  7241. [
  7242. 10,
  7243. 0
  7244. ],
  7245. [
  7246. 7,
  7247. 12
  7248. ],
  7249. [
  7250. 7,
  7251. 12
  7252. ],
  7253. [
  7254. 7,
  7255. 12
  7256. ],
  7257. [
  7258. 7,
  7259. 12
  7260. ],
  7261. [
  7262. 7,
  7263. 12
  7264. ],
  7265. [
  7266. 7,
  7267. 12
  7268. ],
  7269. [
  7270. 7,
  7271. 12
  7272. ],
  7273. [
  7274. 7,
  7275. 12
  7276. ],
  7277. [
  7278. 7,
  7279. 12
  7280. ],
  7281. [
  7282. 7,
  7283. 12
  7284. ],
  7285. [
  7286. 7,
  7287. 12
  7288. ],
  7289. [
  7290. 7,
  7291. 12
  7292. ],
  7293. [
  7294. 7,
  7295. 12
  7296. ],
  7297. [
  7298. 7,
  7299. 12
  7300. ],
  7301. [
  7302. 7,
  7303. 12
  7304. ],
  7305. [
  7306. 7,
  7307. 12
  7308. ],
  7309. [
  7310. 7,
  7311. 12
  7312. ],
  7313. [
  7314. 7,
  7315. 12
  7316. ],
  7317. [
  7318. 7,
  7319. 12
  7320. ],
  7321. [
  7322. 7,
  7323. 12
  7324. ],
  7325. [
  7326. 7,
  7327. 12
  7328. ],
  7329. [
  7330. 7,
  7331. 12
  7332. ],
  7333. [
  7334. 7,
  7335. 12
  7336. ],
  7337. [
  7338. 7,
  7339. 12
  7340. ],
  7341. [
  7342. 7,
  7343. 12
  7344. ],
  7345. [
  7346. 7,
  7347. 12
  7348. ],
  7349. [
  7350. 7,
  7351. 12
  7352. ],
  7353. [
  7354. 7,
  7355. 12
  7356. ],
  7357. [
  7358. 7,
  7359. 12
  7360. ],
  7361. [
  7362. 7,
  7363. 12
  7364. ],
  7365. [
  7366. 7,
  7367. 12
  7368. ],
  7369. [
  7370. 7,
  7371. 12
  7372. ]
  7373. ];
  7374. var blackTable3 = [
  7375. [
  7376. -1,
  7377. -1
  7378. ],
  7379. [
  7380. -1,
  7381. -1
  7382. ],
  7383. [
  7384. -1,
  7385. -1
  7386. ],
  7387. [
  7388. -1,
  7389. -1
  7390. ],
  7391. [
  7392. 6,
  7393. 9
  7394. ],
  7395. [
  7396. 6,
  7397. 8
  7398. ],
  7399. [
  7400. 5,
  7401. 7
  7402. ],
  7403. [
  7404. 5,
  7405. 7
  7406. ],
  7407. [
  7408. 4,
  7409. 6
  7410. ],
  7411. [
  7412. 4,
  7413. 6
  7414. ],
  7415. [
  7416. 4,
  7417. 6
  7418. ],
  7419. [
  7420. 4,
  7421. 6
  7422. ],
  7423. [
  7424. 4,
  7425. 5
  7426. ],
  7427. [
  7428. 4,
  7429. 5
  7430. ],
  7431. [
  7432. 4,
  7433. 5
  7434. ],
  7435. [
  7436. 4,
  7437. 5
  7438. ],
  7439. [
  7440. 3,
  7441. 1
  7442. ],
  7443. [
  7444. 3,
  7445. 1
  7446. ],
  7447. [
  7448. 3,
  7449. 1
  7450. ],
  7451. [
  7452. 3,
  7453. 1
  7454. ],
  7455. [
  7456. 3,
  7457. 1
  7458. ],
  7459. [
  7460. 3,
  7461. 1
  7462. ],
  7463. [
  7464. 3,
  7465. 1
  7466. ],
  7467. [
  7468. 3,
  7469. 1
  7470. ],
  7471. [
  7472. 3,
  7473. 4
  7474. ],
  7475. [
  7476. 3,
  7477. 4
  7478. ],
  7479. [
  7480. 3,
  7481. 4
  7482. ],
  7483. [
  7484. 3,
  7485. 4
  7486. ],
  7487. [
  7488. 3,
  7489. 4
  7490. ],
  7491. [
  7492. 3,
  7493. 4
  7494. ],
  7495. [
  7496. 3,
  7497. 4
  7498. ],
  7499. [
  7500. 3,
  7501. 4
  7502. ],
  7503. [
  7504. 2,
  7505. 3
  7506. ],
  7507. [
  7508. 2,
  7509. 3
  7510. ],
  7511. [
  7512. 2,
  7513. 3
  7514. ],
  7515. [
  7516. 2,
  7517. 3
  7518. ],
  7519. [
  7520. 2,
  7521. 3
  7522. ],
  7523. [
  7524. 2,
  7525. 3
  7526. ],
  7527. [
  7528. 2,
  7529. 3
  7530. ],
  7531. [
  7532. 2,
  7533. 3
  7534. ],
  7535. [
  7536. 2,
  7537. 3
  7538. ],
  7539. [
  7540. 2,
  7541. 3
  7542. ],
  7543. [
  7544. 2,
  7545. 3
  7546. ],
  7547. [
  7548. 2,
  7549. 3
  7550. ],
  7551. [
  7552. 2,
  7553. 3
  7554. ],
  7555. [
  7556. 2,
  7557. 3
  7558. ],
  7559. [
  7560. 2,
  7561. 3
  7562. ],
  7563. [
  7564. 2,
  7565. 3
  7566. ],
  7567. [
  7568. 2,
  7569. 2
  7570. ],
  7571. [
  7572. 2,
  7573. 2
  7574. ],
  7575. [
  7576. 2,
  7577. 2
  7578. ],
  7579. [
  7580. 2,
  7581. 2
  7582. ],
  7583. [
  7584. 2,
  7585. 2
  7586. ],
  7587. [
  7588. 2,
  7589. 2
  7590. ],
  7591. [
  7592. 2,
  7593. 2
  7594. ],
  7595. [
  7596. 2,
  7597. 2
  7598. ],
  7599. [
  7600. 2,
  7601. 2
  7602. ],
  7603. [
  7604. 2,
  7605. 2
  7606. ],
  7607. [
  7608. 2,
  7609. 2
  7610. ],
  7611. [
  7612. 2,
  7613. 2
  7614. ],
  7615. [
  7616. 2,
  7617. 2
  7618. ],
  7619. [
  7620. 2,
  7621. 2
  7622. ],
  7623. [
  7624. 2,
  7625. 2
  7626. ],
  7627. [
  7628. 2,
  7629. 2
  7630. ]
  7631. ];
  7632. function CCITTFaxStream(str, maybeLength, params) {
  7633. this.str = str;
  7634. this.dict = str.dict;
  7635. params = params || Dict.empty;
  7636. this.encoding = params.get('K') || 0;
  7637. this.eoline = params.get('EndOfLine') || false;
  7638. this.byteAlign = params.get('EncodedByteAlign') || false;
  7639. this.columns = params.get('Columns') || 1728;
  7640. this.rows = params.get('Rows') || 0;
  7641. var eoblock = params.get('EndOfBlock');
  7642. if (eoblock === null || eoblock === undefined) {
  7643. eoblock = true;
  7644. }
  7645. this.eoblock = eoblock;
  7646. this.black = params.get('BlackIs1') || false;
  7647. this.codingLine = new Uint32Array(this.columns + 1);
  7648. this.refLine = new Uint32Array(this.columns + 2);
  7649. this.codingLine[0] = this.columns;
  7650. this.codingPos = 0;
  7651. this.row = 0;
  7652. this.nextLine2D = this.encoding < 0;
  7653. this.inputBits = 0;
  7654. this.inputBuf = 0;
  7655. this.outputBits = 0;
  7656. var code1;
  7657. while ((code1 = this.lookBits(12)) === 0) {
  7658. this.eatBits(1);
  7659. }
  7660. if (code1 === 1) {
  7661. this.eatBits(12);
  7662. }
  7663. if (this.encoding > 0) {
  7664. this.nextLine2D = !this.lookBits(1);
  7665. this.eatBits(1);
  7666. }
  7667. DecodeStream.call(this, maybeLength);
  7668. }
  7669. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  7670. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  7671. while (!this.eof) {
  7672. var c = this.lookChar();
  7673. this.ensureBuffer(this.bufferLength + 1);
  7674. this.buffer[this.bufferLength++] = c;
  7675. }
  7676. };
  7677. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  7678. var codingLine = this.codingLine;
  7679. var codingPos = this.codingPos;
  7680. if (a1 > codingLine[codingPos]) {
  7681. if (a1 > this.columns) {
  7682. info('row is wrong length');
  7683. this.err = true;
  7684. a1 = this.columns;
  7685. }
  7686. if (codingPos & 1 ^ blackPixels) {
  7687. ++codingPos;
  7688. }
  7689. codingLine[codingPos] = a1;
  7690. }
  7691. this.codingPos = codingPos;
  7692. };
  7693. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  7694. var codingLine = this.codingLine;
  7695. var codingPos = this.codingPos;
  7696. if (a1 > codingLine[codingPos]) {
  7697. if (a1 > this.columns) {
  7698. info('row is wrong length');
  7699. this.err = true;
  7700. a1 = this.columns;
  7701. }
  7702. if (codingPos & 1 ^ blackPixels) {
  7703. ++codingPos;
  7704. }
  7705. codingLine[codingPos] = a1;
  7706. } else if (a1 < codingLine[codingPos]) {
  7707. if (a1 < 0) {
  7708. info('invalid code');
  7709. this.err = true;
  7710. a1 = 0;
  7711. }
  7712. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7713. --codingPos;
  7714. }
  7715. codingLine[codingPos] = a1;
  7716. }
  7717. this.codingPos = codingPos;
  7718. };
  7719. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  7720. var refLine = this.refLine;
  7721. var codingLine = this.codingLine;
  7722. var columns = this.columns;
  7723. var refPos, blackPixels, bits, i;
  7724. if (this.outputBits === 0) {
  7725. if (this.eof) {
  7726. return null;
  7727. }
  7728. this.err = false;
  7729. var code1, code2, code3;
  7730. if (this.nextLine2D) {
  7731. for (i = 0; codingLine[i] < columns; ++i) {
  7732. refLine[i] = codingLine[i];
  7733. }
  7734. refLine[i++] = columns;
  7735. refLine[i] = columns;
  7736. codingLine[0] = 0;
  7737. this.codingPos = 0;
  7738. refPos = 0;
  7739. blackPixels = 0;
  7740. while (codingLine[this.codingPos] < columns) {
  7741. code1 = this.getTwoDimCode();
  7742. switch (code1) {
  7743. case twoDimPass:
  7744. this.addPixels(refLine[refPos + 1], blackPixels);
  7745. if (refLine[refPos + 1] < columns) {
  7746. refPos += 2;
  7747. }
  7748. break;
  7749. case twoDimHoriz:
  7750. code1 = code2 = 0;
  7751. if (blackPixels) {
  7752. do {
  7753. code1 += code3 = this.getBlackCode();
  7754. } while (code3 >= 64);
  7755. do {
  7756. code2 += code3 = this.getWhiteCode();
  7757. } while (code3 >= 64);
  7758. } else {
  7759. do {
  7760. code1 += code3 = this.getWhiteCode();
  7761. } while (code3 >= 64);
  7762. do {
  7763. code2 += code3 = this.getBlackCode();
  7764. } while (code3 >= 64);
  7765. }
  7766. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7767. if (codingLine[this.codingPos] < columns) {
  7768. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7769. }
  7770. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7771. refPos += 2;
  7772. }
  7773. break;
  7774. case twoDimVertR3:
  7775. this.addPixels(refLine[refPos] + 3, blackPixels);
  7776. blackPixels ^= 1;
  7777. if (codingLine[this.codingPos] < columns) {
  7778. ++refPos;
  7779. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7780. refPos += 2;
  7781. }
  7782. }
  7783. break;
  7784. case twoDimVertR2:
  7785. this.addPixels(refLine[refPos] + 2, blackPixels);
  7786. blackPixels ^= 1;
  7787. if (codingLine[this.codingPos] < columns) {
  7788. ++refPos;
  7789. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7790. refPos += 2;
  7791. }
  7792. }
  7793. break;
  7794. case twoDimVertR1:
  7795. this.addPixels(refLine[refPos] + 1, blackPixels);
  7796. blackPixels ^= 1;
  7797. if (codingLine[this.codingPos] < columns) {
  7798. ++refPos;
  7799. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7800. refPos += 2;
  7801. }
  7802. }
  7803. break;
  7804. case twoDimVert0:
  7805. this.addPixels(refLine[refPos], blackPixels);
  7806. blackPixels ^= 1;
  7807. if (codingLine[this.codingPos] < columns) {
  7808. ++refPos;
  7809. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7810. refPos += 2;
  7811. }
  7812. }
  7813. break;
  7814. case twoDimVertL3:
  7815. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7816. blackPixels ^= 1;
  7817. if (codingLine[this.codingPos] < columns) {
  7818. if (refPos > 0) {
  7819. --refPos;
  7820. } else {
  7821. ++refPos;
  7822. }
  7823. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7824. refPos += 2;
  7825. }
  7826. }
  7827. break;
  7828. case twoDimVertL2:
  7829. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7830. blackPixels ^= 1;
  7831. if (codingLine[this.codingPos] < columns) {
  7832. if (refPos > 0) {
  7833. --refPos;
  7834. } else {
  7835. ++refPos;
  7836. }
  7837. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7838. refPos += 2;
  7839. }
  7840. }
  7841. break;
  7842. case twoDimVertL1:
  7843. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7844. blackPixels ^= 1;
  7845. if (codingLine[this.codingPos] < columns) {
  7846. if (refPos > 0) {
  7847. --refPos;
  7848. } else {
  7849. ++refPos;
  7850. }
  7851. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7852. refPos += 2;
  7853. }
  7854. }
  7855. break;
  7856. case ccittEOF:
  7857. this.addPixels(columns, 0);
  7858. this.eof = true;
  7859. break;
  7860. default:
  7861. info('bad 2d code');
  7862. this.addPixels(columns, 0);
  7863. this.err = true;
  7864. }
  7865. }
  7866. } else {
  7867. codingLine[0] = 0;
  7868. this.codingPos = 0;
  7869. blackPixels = 0;
  7870. while (codingLine[this.codingPos] < columns) {
  7871. code1 = 0;
  7872. if (blackPixels) {
  7873. do {
  7874. code1 += code3 = this.getBlackCode();
  7875. } while (code3 >= 64);
  7876. } else {
  7877. do {
  7878. code1 += code3 = this.getWhiteCode();
  7879. } while (code3 >= 64);
  7880. }
  7881. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7882. blackPixels ^= 1;
  7883. }
  7884. }
  7885. var gotEOL = false;
  7886. if (this.byteAlign) {
  7887. this.inputBits &= ~7;
  7888. }
  7889. if (!this.eoblock && this.row === this.rows - 1) {
  7890. this.eof = true;
  7891. } else {
  7892. code1 = this.lookBits(12);
  7893. if (this.eoline) {
  7894. while (code1 !== ccittEOF && code1 !== 1) {
  7895. this.eatBits(1);
  7896. code1 = this.lookBits(12);
  7897. }
  7898. } else {
  7899. while (code1 === 0) {
  7900. this.eatBits(1);
  7901. code1 = this.lookBits(12);
  7902. }
  7903. }
  7904. if (code1 === 1) {
  7905. this.eatBits(12);
  7906. gotEOL = true;
  7907. } else if (code1 === ccittEOF) {
  7908. this.eof = true;
  7909. }
  7910. }
  7911. if (!this.eof && this.encoding > 0) {
  7912. this.nextLine2D = !this.lookBits(1);
  7913. this.eatBits(1);
  7914. }
  7915. if (this.eoblock && gotEOL && this.byteAlign) {
  7916. code1 = this.lookBits(12);
  7917. if (code1 === 1) {
  7918. this.eatBits(12);
  7919. if (this.encoding > 0) {
  7920. this.lookBits(1);
  7921. this.eatBits(1);
  7922. }
  7923. if (this.encoding >= 0) {
  7924. for (i = 0; i < 4; ++i) {
  7925. code1 = this.lookBits(12);
  7926. if (code1 !== 1) {
  7927. info('bad rtc code: ' + code1);
  7928. }
  7929. this.eatBits(12);
  7930. if (this.encoding > 0) {
  7931. this.lookBits(1);
  7932. this.eatBits(1);
  7933. }
  7934. }
  7935. }
  7936. this.eof = true;
  7937. }
  7938. } else if (this.err && this.eoline) {
  7939. while (true) {
  7940. code1 = this.lookBits(13);
  7941. if (code1 === ccittEOF) {
  7942. this.eof = true;
  7943. return null;
  7944. }
  7945. if (code1 >> 1 === 1) {
  7946. break;
  7947. }
  7948. this.eatBits(1);
  7949. }
  7950. this.eatBits(12);
  7951. if (this.encoding > 0) {
  7952. this.eatBits(1);
  7953. this.nextLine2D = !(code1 & 1);
  7954. }
  7955. }
  7956. if (codingLine[0] > 0) {
  7957. this.outputBits = codingLine[this.codingPos = 0];
  7958. } else {
  7959. this.outputBits = codingLine[this.codingPos = 1];
  7960. }
  7961. this.row++;
  7962. }
  7963. var c;
  7964. if (this.outputBits >= 8) {
  7965. c = this.codingPos & 1 ? 0 : 0xFF;
  7966. this.outputBits -= 8;
  7967. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7968. this.codingPos++;
  7969. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7970. }
  7971. } else {
  7972. bits = 8;
  7973. c = 0;
  7974. do {
  7975. if (this.outputBits > bits) {
  7976. c <<= bits;
  7977. if (!(this.codingPos & 1)) {
  7978. c |= 0xFF >> 8 - bits;
  7979. }
  7980. this.outputBits -= bits;
  7981. bits = 0;
  7982. } else {
  7983. c <<= this.outputBits;
  7984. if (!(this.codingPos & 1)) {
  7985. c |= 0xFF >> 8 - this.outputBits;
  7986. }
  7987. bits -= this.outputBits;
  7988. this.outputBits = 0;
  7989. if (codingLine[this.codingPos] < columns) {
  7990. this.codingPos++;
  7991. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7992. } else if (bits > 0) {
  7993. c <<= bits;
  7994. bits = 0;
  7995. }
  7996. }
  7997. } while (bits);
  7998. }
  7999. if (this.black) {
  8000. c ^= 0xFF;
  8001. }
  8002. return c;
  8003. };
  8004. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8005. var limitValue = limit || 0;
  8006. for (var i = start; i <= end; ++i) {
  8007. var code = this.lookBits(i);
  8008. if (code === ccittEOF) {
  8009. return [
  8010. true,
  8011. 1,
  8012. false
  8013. ];
  8014. }
  8015. if (i < end) {
  8016. code <<= end - i;
  8017. }
  8018. if (!limitValue || code >= limitValue) {
  8019. var p = table[code - limitValue];
  8020. if (p[0] === i) {
  8021. this.eatBits(i);
  8022. return [
  8023. true,
  8024. p[1],
  8025. true
  8026. ];
  8027. }
  8028. }
  8029. }
  8030. return [
  8031. false,
  8032. 0,
  8033. false
  8034. ];
  8035. };
  8036. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8037. var code = 0;
  8038. var p;
  8039. if (this.eoblock) {
  8040. code = this.lookBits(7);
  8041. p = twoDimTable[code];
  8042. if (p && p[0] > 0) {
  8043. this.eatBits(p[0]);
  8044. return p[1];
  8045. }
  8046. } else {
  8047. var result = this.findTableCode(1, 7, twoDimTable);
  8048. if (result[0] && result[2]) {
  8049. return result[1];
  8050. }
  8051. }
  8052. info('Bad two dim code');
  8053. return ccittEOF;
  8054. };
  8055. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8056. var code = 0;
  8057. var p;
  8058. if (this.eoblock) {
  8059. code = this.lookBits(12);
  8060. if (code === ccittEOF) {
  8061. return 1;
  8062. }
  8063. if (code >> 5 === 0) {
  8064. p = whiteTable1[code];
  8065. } else {
  8066. p = whiteTable2[code >> 3];
  8067. }
  8068. if (p[0] > 0) {
  8069. this.eatBits(p[0]);
  8070. return p[1];
  8071. }
  8072. } else {
  8073. var result = this.findTableCode(1, 9, whiteTable2);
  8074. if (result[0]) {
  8075. return result[1];
  8076. }
  8077. result = this.findTableCode(11, 12, whiteTable1);
  8078. if (result[0]) {
  8079. return result[1];
  8080. }
  8081. }
  8082. info('bad white code');
  8083. this.eatBits(1);
  8084. return 1;
  8085. };
  8086. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8087. var code, p;
  8088. if (this.eoblock) {
  8089. code = this.lookBits(13);
  8090. if (code === ccittEOF) {
  8091. return 1;
  8092. }
  8093. if (code >> 7 === 0) {
  8094. p = blackTable1[code];
  8095. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8096. p = blackTable2[(code >> 1) - 64];
  8097. } else {
  8098. p = blackTable3[code >> 7];
  8099. }
  8100. if (p[0] > 0) {
  8101. this.eatBits(p[0]);
  8102. return p[1];
  8103. }
  8104. } else {
  8105. var result = this.findTableCode(2, 6, blackTable3);
  8106. if (result[0]) {
  8107. return result[1];
  8108. }
  8109. result = this.findTableCode(7, 12, blackTable2, 64);
  8110. if (result[0]) {
  8111. return result[1];
  8112. }
  8113. result = this.findTableCode(10, 13, blackTable1);
  8114. if (result[0]) {
  8115. return result[1];
  8116. }
  8117. }
  8118. info('bad black code');
  8119. this.eatBits(1);
  8120. return 1;
  8121. };
  8122. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8123. var c;
  8124. while (this.inputBits < n) {
  8125. if ((c = this.str.getByte()) === -1) {
  8126. if (this.inputBits === 0) {
  8127. return ccittEOF;
  8128. }
  8129. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8130. }
  8131. this.inputBuf = this.inputBuf << 8 | c;
  8132. this.inputBits += 8;
  8133. }
  8134. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8135. };
  8136. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8137. if ((this.inputBits -= n) < 0) {
  8138. this.inputBits = 0;
  8139. }
  8140. };
  8141. return CCITTFaxStream;
  8142. }();
  8143. var LZWStream = function LZWStreamClosure() {
  8144. function LZWStream(str, maybeLength, earlyChange) {
  8145. this.str = str;
  8146. this.dict = str.dict;
  8147. this.cachedData = 0;
  8148. this.bitsCached = 0;
  8149. var maxLzwDictionarySize = 4096;
  8150. var lzwState = {
  8151. earlyChange: earlyChange,
  8152. codeLength: 9,
  8153. nextCode: 258,
  8154. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8155. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8156. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8157. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8158. currentSequenceLength: 0
  8159. };
  8160. for (var i = 0; i < 256; ++i) {
  8161. lzwState.dictionaryValues[i] = i;
  8162. lzwState.dictionaryLengths[i] = 1;
  8163. }
  8164. this.lzwState = lzwState;
  8165. DecodeStream.call(this, maybeLength);
  8166. }
  8167. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8168. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8169. var bitsCached = this.bitsCached;
  8170. var cachedData = this.cachedData;
  8171. while (bitsCached < n) {
  8172. var c = this.str.getByte();
  8173. if (c === -1) {
  8174. this.eof = true;
  8175. return null;
  8176. }
  8177. cachedData = cachedData << 8 | c;
  8178. bitsCached += 8;
  8179. }
  8180. this.bitsCached = bitsCached -= n;
  8181. this.cachedData = cachedData;
  8182. this.lastCode = null;
  8183. return cachedData >>> bitsCached & (1 << n) - 1;
  8184. };
  8185. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8186. var blockSize = 512;
  8187. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8188. var i, j, q;
  8189. var lzwState = this.lzwState;
  8190. if (!lzwState) {
  8191. return;
  8192. }
  8193. var earlyChange = lzwState.earlyChange;
  8194. var nextCode = lzwState.nextCode;
  8195. var dictionaryValues = lzwState.dictionaryValues;
  8196. var dictionaryLengths = lzwState.dictionaryLengths;
  8197. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  8198. var codeLength = lzwState.codeLength;
  8199. var prevCode = lzwState.prevCode;
  8200. var currentSequence = lzwState.currentSequence;
  8201. var currentSequenceLength = lzwState.currentSequenceLength;
  8202. var decodedLength = 0;
  8203. var currentBufferLength = this.bufferLength;
  8204. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8205. for (i = 0; i < blockSize; i++) {
  8206. var code = this.readBits(codeLength);
  8207. var hasPrev = currentSequenceLength > 0;
  8208. if (code < 256) {
  8209. currentSequence[0] = code;
  8210. currentSequenceLength = 1;
  8211. } else if (code >= 258) {
  8212. if (code < nextCode) {
  8213. currentSequenceLength = dictionaryLengths[code];
  8214. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  8215. currentSequence[j] = dictionaryValues[q];
  8216. q = dictionaryPrevCodes[q];
  8217. }
  8218. } else {
  8219. currentSequence[currentSequenceLength++] = currentSequence[0];
  8220. }
  8221. } else if (code === 256) {
  8222. codeLength = 9;
  8223. nextCode = 258;
  8224. currentSequenceLength = 0;
  8225. continue;
  8226. } else {
  8227. this.eof = true;
  8228. delete this.lzwState;
  8229. break;
  8230. }
  8231. if (hasPrev) {
  8232. dictionaryPrevCodes[nextCode] = prevCode;
  8233. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  8234. dictionaryValues[nextCode] = currentSequence[0];
  8235. nextCode++;
  8236. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  8237. }
  8238. prevCode = code;
  8239. decodedLength += currentSequenceLength;
  8240. if (estimatedDecodedSize < decodedLength) {
  8241. do {
  8242. estimatedDecodedSize += decodedSizeDelta;
  8243. } while (estimatedDecodedSize < decodedLength);
  8244. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8245. }
  8246. for (j = 0; j < currentSequenceLength; j++) {
  8247. buffer[currentBufferLength++] = currentSequence[j];
  8248. }
  8249. }
  8250. lzwState.nextCode = nextCode;
  8251. lzwState.codeLength = codeLength;
  8252. lzwState.prevCode = prevCode;
  8253. lzwState.currentSequenceLength = currentSequenceLength;
  8254. this.bufferLength = currentBufferLength;
  8255. };
  8256. return LZWStream;
  8257. }();
  8258. var NullStream = function NullStreamClosure() {
  8259. function NullStream() {
  8260. Stream.call(this, new Uint8Array(0));
  8261. }
  8262. NullStream.prototype = Stream.prototype;
  8263. return NullStream;
  8264. }();
  8265. exports.Ascii85Stream = Ascii85Stream;
  8266. exports.AsciiHexStream = AsciiHexStream;
  8267. exports.CCITTFaxStream = CCITTFaxStream;
  8268. exports.DecryptStream = DecryptStream;
  8269. exports.DecodeStream = DecodeStream;
  8270. exports.FlateStream = FlateStream;
  8271. exports.Jbig2Stream = Jbig2Stream;
  8272. exports.JpegStream = JpegStream;
  8273. exports.JpxStream = JpxStream;
  8274. exports.NullStream = NullStream;
  8275. exports.PredictorStream = PredictorStream;
  8276. exports.RunLengthStream = RunLengthStream;
  8277. exports.Stream = Stream;
  8278. exports.StreamsSequenceStream = StreamsSequenceStream;
  8279. exports.StringStream = StringStream;
  8280. exports.LZWStream = LZWStream;
  8281. /***/ }),
  8282. /* 3 */
  8283. /***/ (function(module, exports, __w_pdfjs_require__) {
  8284. "use strict";
  8285. var sharedUtil = __w_pdfjs_require__(0);
  8286. var assert = sharedUtil.assert;
  8287. var removeNullCharacters = sharedUtil.removeNullCharacters;
  8288. var warn = sharedUtil.warn;
  8289. var deprecated = sharedUtil.deprecated;
  8290. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  8291. var stringToBytes = sharedUtil.stringToBytes;
  8292. var CMapCompressionType = sharedUtil.CMapCompressionType;
  8293. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  8294. function DOMCanvasFactory() {
  8295. }
  8296. DOMCanvasFactory.prototype = {
  8297. create: function DOMCanvasFactory_create(width, height) {
  8298. assert(width > 0 && height > 0, 'invalid canvas size');
  8299. var canvas = document.createElement('canvas');
  8300. var context = canvas.getContext('2d');
  8301. canvas.width = width;
  8302. canvas.height = height;
  8303. return {
  8304. canvas: canvas,
  8305. context: context
  8306. };
  8307. },
  8308. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  8309. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8310. assert(width > 0 && height > 0, 'invalid canvas size');
  8311. canvasAndContextPair.canvas.width = width;
  8312. canvasAndContextPair.canvas.height = height;
  8313. },
  8314. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  8315. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8316. canvasAndContextPair.canvas.width = 0;
  8317. canvasAndContextPair.canvas.height = 0;
  8318. canvasAndContextPair.canvas = null;
  8319. canvasAndContextPair.context = null;
  8320. }
  8321. };
  8322. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  8323. function DOMCMapReaderFactory(params) {
  8324. this.baseUrl = params.baseUrl || null;
  8325. this.isCompressed = params.isCompressed || false;
  8326. }
  8327. DOMCMapReaderFactory.prototype = {
  8328. fetch: function (params) {
  8329. var name = params.name;
  8330. if (!name) {
  8331. return Promise.reject(new Error('CMap name must be specified.'));
  8332. }
  8333. return new Promise(function (resolve, reject) {
  8334. var url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
  8335. var request = new XMLHttpRequest();
  8336. request.open('GET', url, true);
  8337. if (this.isCompressed) {
  8338. request.responseType = 'arraybuffer';
  8339. }
  8340. request.onreadystatechange = function () {
  8341. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  8342. var data;
  8343. if (this.isCompressed && request.response) {
  8344. data = new Uint8Array(request.response);
  8345. } else if (!this.isCompressed && request.responseText) {
  8346. data = stringToBytes(request.responseText);
  8347. }
  8348. if (data) {
  8349. resolve({
  8350. cMapData: data,
  8351. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  8352. });
  8353. return;
  8354. }
  8355. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
  8356. }
  8357. }.bind(this);
  8358. request.send(null);
  8359. }.bind(this));
  8360. }
  8361. };
  8362. return DOMCMapReaderFactory;
  8363. }();
  8364. var CustomStyle = function CustomStyleClosure() {
  8365. var prefixes = [
  8366. 'ms',
  8367. 'Moz',
  8368. 'Webkit',
  8369. 'O'
  8370. ];
  8371. var _cache = Object.create(null);
  8372. function CustomStyle() {
  8373. }
  8374. CustomStyle.getProp = function get(propName, element) {
  8375. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  8376. return _cache[propName];
  8377. }
  8378. element = element || document.documentElement;
  8379. var style = element.style, prefixed, uPropName;
  8380. if (typeof style[propName] === 'string') {
  8381. return _cache[propName] = propName;
  8382. }
  8383. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  8384. for (var i = 0, l = prefixes.length; i < l; i++) {
  8385. prefixed = prefixes[i] + uPropName;
  8386. if (typeof style[prefixed] === 'string') {
  8387. return _cache[propName] = prefixed;
  8388. }
  8389. }
  8390. return _cache[propName] = 'undefined';
  8391. };
  8392. CustomStyle.setProp = function set(propName, element, str) {
  8393. var prop = this.getProp(propName);
  8394. if (prop !== 'undefined') {
  8395. element.style[prop] = str;
  8396. }
  8397. };
  8398. return CustomStyle;
  8399. }();
  8400. var hasCanvasTypedArrays;
  8401. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  8402. var canvas = document.createElement('canvas');
  8403. canvas.width = canvas.height = 1;
  8404. var ctx = canvas.getContext('2d');
  8405. var imageData = ctx.createImageData(1, 1);
  8406. return typeof imageData.data.buffer !== 'undefined';
  8407. };
  8408. var LinkTarget = {
  8409. NONE: 0,
  8410. SELF: 1,
  8411. BLANK: 2,
  8412. PARENT: 3,
  8413. TOP: 4
  8414. };
  8415. var LinkTargetStringMap = [
  8416. '',
  8417. '_self',
  8418. '_blank',
  8419. '_parent',
  8420. '_top'
  8421. ];
  8422. function addLinkAttributes(link, params) {
  8423. var url = params && params.url;
  8424. link.href = link.title = url ? removeNullCharacters(url) : '';
  8425. if (url) {
  8426. var target = params.target;
  8427. if (typeof target === 'undefined') {
  8428. target = getDefaultSetting('externalLinkTarget');
  8429. }
  8430. link.target = LinkTargetStringMap[target];
  8431. var rel = params.rel;
  8432. if (typeof rel === 'undefined') {
  8433. rel = getDefaultSetting('externalLinkRel');
  8434. }
  8435. link.rel = rel;
  8436. }
  8437. }
  8438. function getFilenameFromUrl(url) {
  8439. var anchor = url.indexOf('#');
  8440. var query = url.indexOf('?');
  8441. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  8442. return url.substring(url.lastIndexOf('/', end) + 1, end);
  8443. }
  8444. function getDefaultSetting(id) {
  8445. var globalSettings = sharedUtil.globalScope.PDFJS;
  8446. switch (id) {
  8447. case 'pdfBug':
  8448. return globalSettings ? globalSettings.pdfBug : false;
  8449. case 'disableAutoFetch':
  8450. return globalSettings ? globalSettings.disableAutoFetch : false;
  8451. case 'disableStream':
  8452. return globalSettings ? globalSettings.disableStream : false;
  8453. case 'disableRange':
  8454. return globalSettings ? globalSettings.disableRange : false;
  8455. case 'disableFontFace':
  8456. return globalSettings ? globalSettings.disableFontFace : false;
  8457. case 'disableCreateObjectURL':
  8458. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  8459. case 'disableWebGL':
  8460. return globalSettings ? globalSettings.disableWebGL : true;
  8461. case 'cMapUrl':
  8462. return globalSettings ? globalSettings.cMapUrl : null;
  8463. case 'cMapPacked':
  8464. return globalSettings ? globalSettings.cMapPacked : false;
  8465. case 'postMessageTransfers':
  8466. return globalSettings ? globalSettings.postMessageTransfers : true;
  8467. case 'workerPort':
  8468. return globalSettings ? globalSettings.workerPort : null;
  8469. case 'workerSrc':
  8470. return globalSettings ? globalSettings.workerSrc : null;
  8471. case 'disableWorker':
  8472. return globalSettings ? globalSettings.disableWorker : false;
  8473. case 'maxImageSize':
  8474. return globalSettings ? globalSettings.maxImageSize : -1;
  8475. case 'imageResourcesPath':
  8476. return globalSettings ? globalSettings.imageResourcesPath : '';
  8477. case 'isEvalSupported':
  8478. return globalSettings ? globalSettings.isEvalSupported : true;
  8479. case 'externalLinkTarget':
  8480. if (!globalSettings) {
  8481. return LinkTarget.NONE;
  8482. }
  8483. switch (globalSettings.externalLinkTarget) {
  8484. case LinkTarget.NONE:
  8485. case LinkTarget.SELF:
  8486. case LinkTarget.BLANK:
  8487. case LinkTarget.PARENT:
  8488. case LinkTarget.TOP:
  8489. return globalSettings.externalLinkTarget;
  8490. }
  8491. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  8492. globalSettings.externalLinkTarget = LinkTarget.NONE;
  8493. return LinkTarget.NONE;
  8494. case 'externalLinkRel':
  8495. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  8496. case 'enableStats':
  8497. return !!(globalSettings && globalSettings.enableStats);
  8498. default:
  8499. throw new Error('Unknown default setting: ' + id);
  8500. }
  8501. }
  8502. function isExternalLinkTargetSet() {
  8503. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  8504. switch (externalLinkTarget) {
  8505. case LinkTarget.NONE:
  8506. return false;
  8507. case LinkTarget.SELF:
  8508. case LinkTarget.BLANK:
  8509. case LinkTarget.PARENT:
  8510. case LinkTarget.TOP:
  8511. return true;
  8512. }
  8513. }
  8514. function isValidUrl(url, allowRelative) {
  8515. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  8516. var baseUrl = allowRelative ? 'http://example.com' : null;
  8517. return createValidAbsoluteUrl(url, baseUrl) !== null;
  8518. }
  8519. exports.CustomStyle = CustomStyle;
  8520. exports.addLinkAttributes = addLinkAttributes;
  8521. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  8522. exports.isValidUrl = isValidUrl;
  8523. exports.getFilenameFromUrl = getFilenameFromUrl;
  8524. exports.LinkTarget = LinkTarget;
  8525. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  8526. exports.getDefaultSetting = getDefaultSetting;
  8527. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  8528. exports.DOMCanvasFactory = DOMCanvasFactory;
  8529. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  8530. /***/ }),
  8531. /* 4 */
  8532. /***/ (function(module, exports, __w_pdfjs_require__) {
  8533. "use strict";
  8534. var sharedUtil = __w_pdfjs_require__(0);
  8535. var corePrimitives = __w_pdfjs_require__(1);
  8536. var coreFunction = __w_pdfjs_require__(7);
  8537. var error = sharedUtil.error;
  8538. var info = sharedUtil.info;
  8539. var isArray = sharedUtil.isArray;
  8540. var isString = sharedUtil.isString;
  8541. var shadow = sharedUtil.shadow;
  8542. var warn = sharedUtil.warn;
  8543. var isDict = corePrimitives.isDict;
  8544. var isName = corePrimitives.isName;
  8545. var isStream = corePrimitives.isStream;
  8546. var PDFFunction = coreFunction.PDFFunction;
  8547. var ColorSpace = function ColorSpaceClosure() {
  8548. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  8549. var COMPONENTS = 3;
  8550. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  8551. var xRatio = w1 / w2;
  8552. var yRatio = h1 / h2;
  8553. var i, j, py, newIndex = 0, oldIndex;
  8554. var xScaled = new Uint16Array(w2);
  8555. var w1Scanline = w1 * COMPONENTS;
  8556. for (i = 0; i < w2; i++) {
  8557. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  8558. }
  8559. for (i = 0; i < h2; i++) {
  8560. py = Math.floor(i * yRatio) * w1Scanline;
  8561. for (j = 0; j < w2; j++) {
  8562. oldIndex = py + xScaled[j];
  8563. dest[newIndex++] = src[oldIndex++];
  8564. dest[newIndex++] = src[oldIndex++];
  8565. dest[newIndex++] = src[oldIndex++];
  8566. newIndex += alpha01;
  8567. }
  8568. }
  8569. }
  8570. function ColorSpace() {
  8571. error('should not call ColorSpace constructor');
  8572. }
  8573. ColorSpace.prototype = {
  8574. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  8575. var rgb = new Uint8Array(3);
  8576. this.getRgbItem(src, srcOffset, rgb, 0);
  8577. return rgb;
  8578. },
  8579. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  8580. error('Should not call ColorSpace.getRgbItem');
  8581. },
  8582. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8583. error('Should not call ColorSpace.getRgbBuffer');
  8584. },
  8585. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  8586. error('Should not call ColorSpace.getOutputLength');
  8587. },
  8588. isPassthrough: function ColorSpace_isPassthrough(bits) {
  8589. return false;
  8590. },
  8591. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  8592. var count = originalWidth * originalHeight;
  8593. var rgbBuf = null;
  8594. var numComponentColors = 1 << bpc;
  8595. var needsResizing = originalHeight !== height || originalWidth !== width;
  8596. var i, ii;
  8597. if (this.isPassthrough(bpc)) {
  8598. rgbBuf = comps;
  8599. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  8600. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  8601. var key;
  8602. for (i = 0; i < numComponentColors; i++) {
  8603. allColors[i] = i;
  8604. }
  8605. var colorMap = new Uint8Array(numComponentColors * 3);
  8606. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  8607. var destPos, rgbPos;
  8608. if (!needsResizing) {
  8609. destPos = 0;
  8610. for (i = 0; i < count; ++i) {
  8611. key = comps[i] * 3;
  8612. dest[destPos++] = colorMap[key];
  8613. dest[destPos++] = colorMap[key + 1];
  8614. dest[destPos++] = colorMap[key + 2];
  8615. destPos += alpha01;
  8616. }
  8617. } else {
  8618. rgbBuf = new Uint8Array(count * 3);
  8619. rgbPos = 0;
  8620. for (i = 0; i < count; ++i) {
  8621. key = comps[i] * 3;
  8622. rgbBuf[rgbPos++] = colorMap[key];
  8623. rgbBuf[rgbPos++] = colorMap[key + 1];
  8624. rgbBuf[rgbPos++] = colorMap[key + 2];
  8625. }
  8626. }
  8627. } else {
  8628. if (!needsResizing) {
  8629. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  8630. } else {
  8631. rgbBuf = new Uint8Array(count * 3);
  8632. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  8633. }
  8634. }
  8635. if (rgbBuf) {
  8636. if (needsResizing) {
  8637. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  8638. } else {
  8639. rgbPos = 0;
  8640. destPos = 0;
  8641. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  8642. dest[destPos++] = rgbBuf[rgbPos++];
  8643. dest[destPos++] = rgbBuf[rgbPos++];
  8644. dest[destPos++] = rgbBuf[rgbPos++];
  8645. destPos += alpha01;
  8646. }
  8647. }
  8648. }
  8649. },
  8650. usesZeroToOneRange: true
  8651. };
  8652. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  8653. var IR = ColorSpace.parseToIR(cs, xref, res);
  8654. if (IR instanceof AlternateCS) {
  8655. return IR;
  8656. }
  8657. return ColorSpace.fromIR(IR);
  8658. };
  8659. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  8660. var name = isArray(IR) ? IR[0] : IR;
  8661. var whitePoint, blackPoint, gamma;
  8662. switch (name) {
  8663. case 'DeviceGrayCS':
  8664. return this.singletons.gray;
  8665. case 'DeviceRgbCS':
  8666. return this.singletons.rgb;
  8667. case 'DeviceCmykCS':
  8668. return this.singletons.cmyk;
  8669. case 'CalGrayCS':
  8670. whitePoint = IR[1];
  8671. blackPoint = IR[2];
  8672. gamma = IR[3];
  8673. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8674. case 'CalRGBCS':
  8675. whitePoint = IR[1];
  8676. blackPoint = IR[2];
  8677. gamma = IR[3];
  8678. var matrix = IR[4];
  8679. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8680. case 'PatternCS':
  8681. var basePatternCS = IR[1];
  8682. if (basePatternCS) {
  8683. basePatternCS = ColorSpace.fromIR(basePatternCS);
  8684. }
  8685. return new PatternCS(basePatternCS);
  8686. case 'IndexedCS':
  8687. var baseIndexedCS = IR[1];
  8688. var hiVal = IR[2];
  8689. var lookup = IR[3];
  8690. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  8691. case 'AlternateCS':
  8692. var numComps = IR[1];
  8693. var alt = IR[2];
  8694. var tintFnIR = IR[3];
  8695. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  8696. case 'LabCS':
  8697. whitePoint = IR[1];
  8698. blackPoint = IR[2];
  8699. var range = IR[3];
  8700. return new LabCS(whitePoint, blackPoint, range);
  8701. default:
  8702. error('Unknown name ' + name);
  8703. }
  8704. return null;
  8705. };
  8706. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  8707. if (isName(cs)) {
  8708. var colorSpaces = res.get('ColorSpace');
  8709. if (isDict(colorSpaces)) {
  8710. var refcs = colorSpaces.get(cs.name);
  8711. if (refcs) {
  8712. cs = refcs;
  8713. }
  8714. }
  8715. }
  8716. cs = xref.fetchIfRef(cs);
  8717. if (isName(cs)) {
  8718. switch (cs.name) {
  8719. case 'DeviceGray':
  8720. case 'G':
  8721. return 'DeviceGrayCS';
  8722. case 'DeviceRGB':
  8723. case 'RGB':
  8724. return 'DeviceRgbCS';
  8725. case 'DeviceCMYK':
  8726. case 'CMYK':
  8727. return 'DeviceCmykCS';
  8728. case 'Pattern':
  8729. return [
  8730. 'PatternCS',
  8731. null
  8732. ];
  8733. default:
  8734. error('unrecognized colorspace ' + cs.name);
  8735. }
  8736. } else if (isArray(cs)) {
  8737. var mode = xref.fetchIfRef(cs[0]).name;
  8738. var numComps, params, alt, whitePoint, blackPoint, gamma;
  8739. switch (mode) {
  8740. case 'DeviceGray':
  8741. case 'G':
  8742. return 'DeviceGrayCS';
  8743. case 'DeviceRGB':
  8744. case 'RGB':
  8745. return 'DeviceRgbCS';
  8746. case 'DeviceCMYK':
  8747. case 'CMYK':
  8748. return 'DeviceCmykCS';
  8749. case 'CalGray':
  8750. params = xref.fetchIfRef(cs[1]);
  8751. whitePoint = params.getArray('WhitePoint');
  8752. blackPoint = params.getArray('BlackPoint');
  8753. gamma = params.get('Gamma');
  8754. return [
  8755. 'CalGrayCS',
  8756. whitePoint,
  8757. blackPoint,
  8758. gamma
  8759. ];
  8760. case 'CalRGB':
  8761. params = xref.fetchIfRef(cs[1]);
  8762. whitePoint = params.getArray('WhitePoint');
  8763. blackPoint = params.getArray('BlackPoint');
  8764. gamma = params.getArray('Gamma');
  8765. var matrix = params.getArray('Matrix');
  8766. return [
  8767. 'CalRGBCS',
  8768. whitePoint,
  8769. blackPoint,
  8770. gamma,
  8771. matrix
  8772. ];
  8773. case 'ICCBased':
  8774. var stream = xref.fetchIfRef(cs[1]);
  8775. var dict = stream.dict;
  8776. numComps = dict.get('N');
  8777. alt = dict.get('Alternate');
  8778. if (alt) {
  8779. var altIR = ColorSpace.parseToIR(alt, xref, res);
  8780. var altCS = ColorSpace.fromIR(altIR);
  8781. if (altCS.numComps === numComps) {
  8782. return altIR;
  8783. }
  8784. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  8785. }
  8786. if (numComps === 1) {
  8787. return 'DeviceGrayCS';
  8788. } else if (numComps === 3) {
  8789. return 'DeviceRgbCS';
  8790. } else if (numComps === 4) {
  8791. return 'DeviceCmykCS';
  8792. }
  8793. break;
  8794. case 'Pattern':
  8795. var basePatternCS = cs[1] || null;
  8796. if (basePatternCS) {
  8797. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  8798. }
  8799. return [
  8800. 'PatternCS',
  8801. basePatternCS
  8802. ];
  8803. case 'Indexed':
  8804. case 'I':
  8805. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  8806. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  8807. var lookup = xref.fetchIfRef(cs[3]);
  8808. if (isStream(lookup)) {
  8809. lookup = lookup.getBytes();
  8810. }
  8811. return [
  8812. 'IndexedCS',
  8813. baseIndexedCS,
  8814. hiVal,
  8815. lookup
  8816. ];
  8817. case 'Separation':
  8818. case 'DeviceN':
  8819. var name = xref.fetchIfRef(cs[1]);
  8820. numComps = isArray(name) ? name.length : 1;
  8821. alt = ColorSpace.parseToIR(cs[2], xref, res);
  8822. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  8823. return [
  8824. 'AlternateCS',
  8825. numComps,
  8826. alt,
  8827. tintFnIR
  8828. ];
  8829. case 'Lab':
  8830. params = xref.fetchIfRef(cs[1]);
  8831. whitePoint = params.getArray('WhitePoint');
  8832. blackPoint = params.getArray('BlackPoint');
  8833. var range = params.getArray('Range');
  8834. return [
  8835. 'LabCS',
  8836. whitePoint,
  8837. blackPoint,
  8838. range
  8839. ];
  8840. default:
  8841. error('unimplemented color space object "' + mode + '"');
  8842. }
  8843. } else {
  8844. error('unrecognized color space object: "' + cs + '"');
  8845. }
  8846. return null;
  8847. };
  8848. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  8849. if (!isArray(decode)) {
  8850. return true;
  8851. }
  8852. if (n * 2 !== decode.length) {
  8853. warn('The decode map is not the correct length');
  8854. return true;
  8855. }
  8856. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  8857. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8858. return false;
  8859. }
  8860. }
  8861. return true;
  8862. };
  8863. ColorSpace.singletons = {
  8864. get gray() {
  8865. return shadow(this, 'gray', new DeviceGrayCS());
  8866. },
  8867. get rgb() {
  8868. return shadow(this, 'rgb', new DeviceRgbCS());
  8869. },
  8870. get cmyk() {
  8871. return shadow(this, 'cmyk', new DeviceCmykCS());
  8872. }
  8873. };
  8874. return ColorSpace;
  8875. }();
  8876. var AlternateCS = function AlternateCSClosure() {
  8877. function AlternateCS(numComps, base, tintFn) {
  8878. this.name = 'Alternate';
  8879. this.numComps = numComps;
  8880. this.defaultColor = new Float32Array(numComps);
  8881. for (var i = 0; i < numComps; ++i) {
  8882. this.defaultColor[i] = 1;
  8883. }
  8884. this.base = base;
  8885. this.tintFn = tintFn;
  8886. this.tmpBuf = new Float32Array(base.numComps);
  8887. }
  8888. AlternateCS.prototype = {
  8889. getRgb: ColorSpace.prototype.getRgb,
  8890. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8891. var tmpBuf = this.tmpBuf;
  8892. this.tintFn(src, srcOffset, tmpBuf, 0);
  8893. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8894. },
  8895. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8896. var tintFn = this.tintFn;
  8897. var base = this.base;
  8898. var scale = 1 / ((1 << bits) - 1);
  8899. var baseNumComps = base.numComps;
  8900. var usesZeroToOneRange = base.usesZeroToOneRange;
  8901. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8902. var pos = isPassthrough ? destOffset : 0;
  8903. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  8904. var numComps = this.numComps;
  8905. var scaled = new Float32Array(numComps);
  8906. var tinted = new Float32Array(baseNumComps);
  8907. var i, j;
  8908. for (i = 0; i < count; i++) {
  8909. for (j = 0; j < numComps; j++) {
  8910. scaled[j] = src[srcOffset++] * scale;
  8911. }
  8912. tintFn(scaled, 0, tinted, 0);
  8913. if (usesZeroToOneRange) {
  8914. for (j = 0; j < baseNumComps; j++) {
  8915. baseBuf[pos++] = tinted[j] * 255;
  8916. }
  8917. } else {
  8918. base.getRgbItem(tinted, 0, baseBuf, pos);
  8919. pos += baseNumComps;
  8920. }
  8921. }
  8922. if (!isPassthrough) {
  8923. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8924. }
  8925. },
  8926. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  8927. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8928. },
  8929. isPassthrough: ColorSpace.prototype.isPassthrough,
  8930. fillRgb: ColorSpace.prototype.fillRgb,
  8931. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  8932. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8933. },
  8934. usesZeroToOneRange: true
  8935. };
  8936. return AlternateCS;
  8937. }();
  8938. var PatternCS = function PatternCSClosure() {
  8939. function PatternCS(baseCS) {
  8940. this.name = 'Pattern';
  8941. this.base = baseCS;
  8942. }
  8943. PatternCS.prototype = {};
  8944. return PatternCS;
  8945. }();
  8946. var IndexedCS = function IndexedCSClosure() {
  8947. function IndexedCS(base, highVal, lookup) {
  8948. this.name = 'Indexed';
  8949. this.numComps = 1;
  8950. this.defaultColor = new Uint8Array(this.numComps);
  8951. this.base = base;
  8952. this.highVal = highVal;
  8953. var baseNumComps = base.numComps;
  8954. var length = baseNumComps * highVal;
  8955. if (isStream(lookup)) {
  8956. this.lookup = new Uint8Array(length);
  8957. var bytes = lookup.getBytes(length);
  8958. this.lookup.set(bytes);
  8959. } else if (isString(lookup)) {
  8960. this.lookup = new Uint8Array(length);
  8961. for (var i = 0; i < length; ++i) {
  8962. this.lookup[i] = lookup.charCodeAt(i);
  8963. }
  8964. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  8965. this.lookup = lookup;
  8966. } else {
  8967. error('Unrecognized lookup table: ' + lookup);
  8968. }
  8969. }
  8970. IndexedCS.prototype = {
  8971. getRgb: ColorSpace.prototype.getRgb,
  8972. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8973. var numComps = this.base.numComps;
  8974. var start = src[srcOffset] * numComps;
  8975. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  8976. },
  8977. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8978. var base = this.base;
  8979. var numComps = base.numComps;
  8980. var outputDelta = base.getOutputLength(numComps, alpha01);
  8981. var lookup = this.lookup;
  8982. for (var i = 0; i < count; ++i) {
  8983. var lookupPos = src[srcOffset++] * numComps;
  8984. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8985. destOffset += outputDelta;
  8986. }
  8987. },
  8988. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  8989. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8990. },
  8991. isPassthrough: ColorSpace.prototype.isPassthrough,
  8992. fillRgb: ColorSpace.prototype.fillRgb,
  8993. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  8994. return true;
  8995. },
  8996. usesZeroToOneRange: true
  8997. };
  8998. return IndexedCS;
  8999. }();
  9000. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9001. function DeviceGrayCS() {
  9002. this.name = 'DeviceGray';
  9003. this.numComps = 1;
  9004. this.defaultColor = new Float32Array(this.numComps);
  9005. }
  9006. DeviceGrayCS.prototype = {
  9007. getRgb: ColorSpace.prototype.getRgb,
  9008. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9009. var c = src[srcOffset] * 255 | 0;
  9010. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9011. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9012. },
  9013. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9014. var scale = 255 / ((1 << bits) - 1);
  9015. var j = srcOffset, q = destOffset;
  9016. for (var i = 0; i < count; ++i) {
  9017. var c = scale * src[j++] | 0;
  9018. dest[q++] = c;
  9019. dest[q++] = c;
  9020. dest[q++] = c;
  9021. q += alpha01;
  9022. }
  9023. },
  9024. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9025. return inputLength * (3 + alpha01);
  9026. },
  9027. isPassthrough: ColorSpace.prototype.isPassthrough,
  9028. fillRgb: ColorSpace.prototype.fillRgb,
  9029. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9030. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9031. },
  9032. usesZeroToOneRange: true
  9033. };
  9034. return DeviceGrayCS;
  9035. }();
  9036. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9037. function DeviceRgbCS() {
  9038. this.name = 'DeviceRGB';
  9039. this.numComps = 3;
  9040. this.defaultColor = new Float32Array(this.numComps);
  9041. }
  9042. DeviceRgbCS.prototype = {
  9043. getRgb: ColorSpace.prototype.getRgb,
  9044. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9045. var r = src[srcOffset] * 255 | 0;
  9046. var g = src[srcOffset + 1] * 255 | 0;
  9047. var b = src[srcOffset + 2] * 255 | 0;
  9048. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9049. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9050. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9051. },
  9052. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9053. if (bits === 8 && alpha01 === 0) {
  9054. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9055. return;
  9056. }
  9057. var scale = 255 / ((1 << bits) - 1);
  9058. var j = srcOffset, q = destOffset;
  9059. for (var i = 0; i < count; ++i) {
  9060. dest[q++] = scale * src[j++] | 0;
  9061. dest[q++] = scale * src[j++] | 0;
  9062. dest[q++] = scale * src[j++] | 0;
  9063. q += alpha01;
  9064. }
  9065. },
  9066. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9067. return inputLength * (3 + alpha01) / 3 | 0;
  9068. },
  9069. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9070. return bits === 8;
  9071. },
  9072. fillRgb: ColorSpace.prototype.fillRgb,
  9073. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9074. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9075. },
  9076. usesZeroToOneRange: true
  9077. };
  9078. return DeviceRgbCS;
  9079. }();
  9080. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9081. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9082. var c = src[srcOffset + 0] * srcScale;
  9083. var m = src[srcOffset + 1] * srcScale;
  9084. var y = src[srcOffset + 2] * srcScale;
  9085. var k = src[srcOffset + 3] * srcScale;
  9086. 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;
  9087. 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;
  9088. 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;
  9089. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9090. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9091. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9092. }
  9093. function DeviceCmykCS() {
  9094. this.name = 'DeviceCMYK';
  9095. this.numComps = 4;
  9096. this.defaultColor = new Float32Array(this.numComps);
  9097. this.defaultColor[3] = 1;
  9098. }
  9099. DeviceCmykCS.prototype = {
  9100. getRgb: ColorSpace.prototype.getRgb,
  9101. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9102. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9103. },
  9104. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9105. var scale = 1 / ((1 << bits) - 1);
  9106. for (var i = 0; i < count; i++) {
  9107. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9108. srcOffset += 4;
  9109. destOffset += 3 + alpha01;
  9110. }
  9111. },
  9112. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9113. return inputLength / 4 * (3 + alpha01) | 0;
  9114. },
  9115. isPassthrough: ColorSpace.prototype.isPassthrough,
  9116. fillRgb: ColorSpace.prototype.fillRgb,
  9117. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9118. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9119. },
  9120. usesZeroToOneRange: true
  9121. };
  9122. return DeviceCmykCS;
  9123. }();
  9124. var CalGrayCS = function CalGrayCSClosure() {
  9125. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9126. this.name = 'CalGray';
  9127. this.numComps = 1;
  9128. this.defaultColor = new Float32Array(this.numComps);
  9129. if (!whitePoint) {
  9130. error('WhitePoint missing - required for color space CalGray');
  9131. }
  9132. blackPoint = blackPoint || [
  9133. 0,
  9134. 0,
  9135. 0
  9136. ];
  9137. gamma = gamma || 1;
  9138. this.XW = whitePoint[0];
  9139. this.YW = whitePoint[1];
  9140. this.ZW = whitePoint[2];
  9141. this.XB = blackPoint[0];
  9142. this.YB = blackPoint[1];
  9143. this.ZB = blackPoint[2];
  9144. this.G = gamma;
  9145. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9146. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9147. }
  9148. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9149. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9150. this.XB = this.YB = this.ZB = 0;
  9151. }
  9152. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9153. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9154. }
  9155. if (this.G < 1) {
  9156. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9157. this.G = 1;
  9158. }
  9159. }
  9160. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9161. var A = src[srcOffset] * scale;
  9162. var AG = Math.pow(A, cs.G);
  9163. var L = cs.YW * AG;
  9164. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9165. dest[destOffset] = val;
  9166. dest[destOffset + 1] = val;
  9167. dest[destOffset + 2] = val;
  9168. }
  9169. CalGrayCS.prototype = {
  9170. getRgb: ColorSpace.prototype.getRgb,
  9171. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9172. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9173. },
  9174. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9175. var scale = 1 / ((1 << bits) - 1);
  9176. for (var i = 0; i < count; ++i) {
  9177. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9178. srcOffset += 1;
  9179. destOffset += 3 + alpha01;
  9180. }
  9181. },
  9182. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9183. return inputLength * (3 + alpha01);
  9184. },
  9185. isPassthrough: ColorSpace.prototype.isPassthrough,
  9186. fillRgb: ColorSpace.prototype.fillRgb,
  9187. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9188. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9189. },
  9190. usesZeroToOneRange: true
  9191. };
  9192. return CalGrayCS;
  9193. }();
  9194. var CalRGBCS = function CalRGBCSClosure() {
  9195. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9196. 0.8951,
  9197. 0.2664,
  9198. -0.1614,
  9199. -0.7502,
  9200. 1.7135,
  9201. 0.0367,
  9202. 0.0389,
  9203. -0.0685,
  9204. 1.0296
  9205. ]);
  9206. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9207. 0.9869929,
  9208. -0.1470543,
  9209. 0.1599627,
  9210. 0.4323053,
  9211. 0.5183603,
  9212. 0.0492912,
  9213. -0.0085287,
  9214. 0.0400428,
  9215. 0.9684867
  9216. ]);
  9217. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9218. 3.2404542,
  9219. -1.5371385,
  9220. -0.4985314,
  9221. -0.9692660,
  9222. 1.8760108,
  9223. 0.0415560,
  9224. 0.0556434,
  9225. -0.2040259,
  9226. 1.0572252
  9227. ]);
  9228. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9229. 1,
  9230. 1,
  9231. 1
  9232. ]);
  9233. var tempNormalizeMatrix = new Float32Array(3);
  9234. var tempConvertMatrix1 = new Float32Array(3);
  9235. var tempConvertMatrix2 = new Float32Array(3);
  9236. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9237. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9238. this.name = 'CalRGB';
  9239. this.numComps = 3;
  9240. this.defaultColor = new Float32Array(this.numComps);
  9241. if (!whitePoint) {
  9242. error('WhitePoint missing - required for color space CalRGB');
  9243. }
  9244. blackPoint = blackPoint || new Float32Array(3);
  9245. gamma = gamma || new Float32Array([
  9246. 1,
  9247. 1,
  9248. 1
  9249. ]);
  9250. matrix = matrix || new Float32Array([
  9251. 1,
  9252. 0,
  9253. 0,
  9254. 0,
  9255. 1,
  9256. 0,
  9257. 0,
  9258. 0,
  9259. 1
  9260. ]);
  9261. var XW = whitePoint[0];
  9262. var YW = whitePoint[1];
  9263. var ZW = whitePoint[2];
  9264. this.whitePoint = whitePoint;
  9265. var XB = blackPoint[0];
  9266. var YB = blackPoint[1];
  9267. var ZB = blackPoint[2];
  9268. this.blackPoint = blackPoint;
  9269. this.GR = gamma[0];
  9270. this.GG = gamma[1];
  9271. this.GB = gamma[2];
  9272. this.MXA = matrix[0];
  9273. this.MYA = matrix[1];
  9274. this.MZA = matrix[2];
  9275. this.MXB = matrix[3];
  9276. this.MYB = matrix[4];
  9277. this.MZB = matrix[5];
  9278. this.MXC = matrix[6];
  9279. this.MYC = matrix[7];
  9280. this.MZC = matrix[8];
  9281. if (XW < 0 || ZW < 0 || YW !== 1) {
  9282. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9283. }
  9284. if (XB < 0 || YB < 0 || ZB < 0) {
  9285. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  9286. this.blackPoint = new Float32Array(3);
  9287. }
  9288. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  9289. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  9290. this.GR = this.GG = this.GB = 1;
  9291. }
  9292. 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) {
  9293. 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');
  9294. this.MXA = this.MYB = this.MZC = 1;
  9295. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  9296. }
  9297. }
  9298. function matrixProduct(a, b, result) {
  9299. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  9300. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  9301. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  9302. }
  9303. function convertToFlat(sourceWhitePoint, LMS, result) {
  9304. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  9305. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  9306. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  9307. }
  9308. function convertToD65(sourceWhitePoint, LMS, result) {
  9309. var D65X = 0.95047;
  9310. var D65Y = 1;
  9311. var D65Z = 1.08883;
  9312. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  9313. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  9314. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  9315. }
  9316. function sRGBTransferFunction(color) {
  9317. if (color <= 0.0031308) {
  9318. return adjustToRange(0, 1, 12.92 * color);
  9319. }
  9320. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  9321. }
  9322. function adjustToRange(min, max, value) {
  9323. return Math.max(min, Math.min(max, value));
  9324. }
  9325. function decodeL(L) {
  9326. if (L < 0) {
  9327. return -decodeL(-L);
  9328. }
  9329. if (L > 8.0) {
  9330. return Math.pow((L + 16) / 116, 3);
  9331. }
  9332. return L * DECODE_L_CONSTANT;
  9333. }
  9334. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  9335. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  9336. result[0] = XYZ_Flat[0];
  9337. result[1] = XYZ_Flat[1];
  9338. result[2] = XYZ_Flat[2];
  9339. return;
  9340. }
  9341. var zeroDecodeL = decodeL(0);
  9342. var X_DST = zeroDecodeL;
  9343. var X_SRC = decodeL(sourceBlackPoint[0]);
  9344. var Y_DST = zeroDecodeL;
  9345. var Y_SRC = decodeL(sourceBlackPoint[1]);
  9346. var Z_DST = zeroDecodeL;
  9347. var Z_SRC = decodeL(sourceBlackPoint[2]);
  9348. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  9349. var X_Offset = 1 - X_Scale;
  9350. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  9351. var Y_Offset = 1 - Y_Scale;
  9352. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  9353. var Z_Offset = 1 - Z_Scale;
  9354. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  9355. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  9356. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  9357. }
  9358. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  9359. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  9360. result[0] = XYZ_In[0];
  9361. result[1] = XYZ_In[1];
  9362. result[2] = XYZ_In[2];
  9363. return;
  9364. }
  9365. var LMS = result;
  9366. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9367. var LMS_Flat = tempNormalizeMatrix;
  9368. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  9369. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  9370. }
  9371. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  9372. var LMS = result;
  9373. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9374. var LMS_D65 = tempNormalizeMatrix;
  9375. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  9376. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  9377. }
  9378. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9379. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  9380. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  9381. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  9382. var AGR = Math.pow(A, cs.GR);
  9383. var BGG = Math.pow(B, cs.GG);
  9384. var CGB = Math.pow(C, cs.GB);
  9385. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  9386. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  9387. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  9388. var XYZ = tempConvertMatrix1;
  9389. XYZ[0] = X;
  9390. XYZ[1] = Y;
  9391. XYZ[2] = Z;
  9392. var XYZ_Flat = tempConvertMatrix2;
  9393. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  9394. var XYZ_Black = tempConvertMatrix1;
  9395. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  9396. var XYZ_D65 = tempConvertMatrix2;
  9397. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  9398. var SRGB = tempConvertMatrix1;
  9399. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  9400. var sR = sRGBTransferFunction(SRGB[0]);
  9401. var sG = sRGBTransferFunction(SRGB[1]);
  9402. var sB = sRGBTransferFunction(SRGB[2]);
  9403. dest[destOffset] = Math.round(sR * 255);
  9404. dest[destOffset + 1] = Math.round(sG * 255);
  9405. dest[destOffset + 2] = Math.round(sB * 255);
  9406. }
  9407. CalRGBCS.prototype = {
  9408. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  9409. var rgb = new Uint8Array(3);
  9410. this.getRgbItem(src, srcOffset, rgb, 0);
  9411. return rgb;
  9412. },
  9413. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9414. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9415. },
  9416. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9417. var scale = 1 / ((1 << bits) - 1);
  9418. for (var i = 0; i < count; ++i) {
  9419. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9420. srcOffset += 3;
  9421. destOffset += 3 + alpha01;
  9422. }
  9423. },
  9424. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  9425. return inputLength * (3 + alpha01) / 3 | 0;
  9426. },
  9427. isPassthrough: ColorSpace.prototype.isPassthrough,
  9428. fillRgb: ColorSpace.prototype.fillRgb,
  9429. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  9430. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9431. },
  9432. usesZeroToOneRange: true
  9433. };
  9434. return CalRGBCS;
  9435. }();
  9436. var LabCS = function LabCSClosure() {
  9437. function LabCS(whitePoint, blackPoint, range) {
  9438. this.name = 'Lab';
  9439. this.numComps = 3;
  9440. this.defaultColor = new Float32Array(this.numComps);
  9441. if (!whitePoint) {
  9442. error('WhitePoint missing - required for color space Lab');
  9443. }
  9444. blackPoint = blackPoint || [
  9445. 0,
  9446. 0,
  9447. 0
  9448. ];
  9449. range = range || [
  9450. -100,
  9451. 100,
  9452. -100,
  9453. 100
  9454. ];
  9455. this.XW = whitePoint[0];
  9456. this.YW = whitePoint[1];
  9457. this.ZW = whitePoint[2];
  9458. this.amin = range[0];
  9459. this.amax = range[1];
  9460. this.bmin = range[2];
  9461. this.bmax = range[3];
  9462. this.XB = blackPoint[0];
  9463. this.YB = blackPoint[1];
  9464. this.ZB = blackPoint[2];
  9465. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9466. error('Invalid WhitePoint components, no fallback available');
  9467. }
  9468. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9469. info('Invalid BlackPoint, falling back to default');
  9470. this.XB = this.YB = this.ZB = 0;
  9471. }
  9472. if (this.amin > this.amax || this.bmin > this.bmax) {
  9473. info('Invalid Range, falling back to defaults');
  9474. this.amin = -100;
  9475. this.amax = 100;
  9476. this.bmin = -100;
  9477. this.bmax = 100;
  9478. }
  9479. }
  9480. function fn_g(x) {
  9481. var result;
  9482. if (x >= 6 / 29) {
  9483. result = x * x * x;
  9484. } else {
  9485. result = 108 / 841 * (x - 4 / 29);
  9486. }
  9487. return result;
  9488. }
  9489. function decode(value, high1, low2, high2) {
  9490. return low2 + value * (high2 - low2) / high1;
  9491. }
  9492. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  9493. var Ls = src[srcOffset];
  9494. var as = src[srcOffset + 1];
  9495. var bs = src[srcOffset + 2];
  9496. if (maxVal !== false) {
  9497. Ls = decode(Ls, maxVal, 0, 100);
  9498. as = decode(as, maxVal, cs.amin, cs.amax);
  9499. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  9500. }
  9501. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  9502. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  9503. var M = (Ls + 16) / 116;
  9504. var L = M + as / 500;
  9505. var N = M - bs / 200;
  9506. var X = cs.XW * fn_g(L);
  9507. var Y = cs.YW * fn_g(M);
  9508. var Z = cs.ZW * fn_g(N);
  9509. var r, g, b;
  9510. if (cs.ZW < 1) {
  9511. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  9512. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  9513. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  9514. } else {
  9515. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  9516. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  9517. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  9518. }
  9519. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  9520. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  9521. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  9522. }
  9523. LabCS.prototype = {
  9524. getRgb: ColorSpace.prototype.getRgb,
  9525. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9526. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  9527. },
  9528. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9529. var maxVal = (1 << bits) - 1;
  9530. for (var i = 0; i < count; i++) {
  9531. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  9532. srcOffset += 3;
  9533. destOffset += 3 + alpha01;
  9534. }
  9535. },
  9536. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  9537. return inputLength * (3 + alpha01) / 3 | 0;
  9538. },
  9539. isPassthrough: ColorSpace.prototype.isPassthrough,
  9540. fillRgb: ColorSpace.prototype.fillRgb,
  9541. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  9542. return true;
  9543. },
  9544. usesZeroToOneRange: false
  9545. };
  9546. return LabCS;
  9547. }();
  9548. exports.ColorSpace = ColorSpace;
  9549. /***/ }),
  9550. /* 5 */
  9551. /***/ (function(module, exports, __w_pdfjs_require__) {
  9552. "use strict";
  9553. var ExpertEncoding = [
  9554. '',
  9555. '',
  9556. '',
  9557. '',
  9558. '',
  9559. '',
  9560. '',
  9561. '',
  9562. '',
  9563. '',
  9564. '',
  9565. '',
  9566. '',
  9567. '',
  9568. '',
  9569. '',
  9570. '',
  9571. '',
  9572. '',
  9573. '',
  9574. '',
  9575. '',
  9576. '',
  9577. '',
  9578. '',
  9579. '',
  9580. '',
  9581. '',
  9582. '',
  9583. '',
  9584. '',
  9585. '',
  9586. 'space',
  9587. 'exclamsmall',
  9588. 'Hungarumlautsmall',
  9589. '',
  9590. 'dollaroldstyle',
  9591. 'dollarsuperior',
  9592. 'ampersandsmall',
  9593. 'Acutesmall',
  9594. 'parenleftsuperior',
  9595. 'parenrightsuperior',
  9596. 'twodotenleader',
  9597. 'onedotenleader',
  9598. 'comma',
  9599. 'hyphen',
  9600. 'period',
  9601. 'fraction',
  9602. 'zerooldstyle',
  9603. 'oneoldstyle',
  9604. 'twooldstyle',
  9605. 'threeoldstyle',
  9606. 'fouroldstyle',
  9607. 'fiveoldstyle',
  9608. 'sixoldstyle',
  9609. 'sevenoldstyle',
  9610. 'eightoldstyle',
  9611. 'nineoldstyle',
  9612. 'colon',
  9613. 'semicolon',
  9614. 'commasuperior',
  9615. 'threequartersemdash',
  9616. 'periodsuperior',
  9617. 'questionsmall',
  9618. '',
  9619. 'asuperior',
  9620. 'bsuperior',
  9621. 'centsuperior',
  9622. 'dsuperior',
  9623. 'esuperior',
  9624. '',
  9625. '',
  9626. 'isuperior',
  9627. '',
  9628. '',
  9629. 'lsuperior',
  9630. 'msuperior',
  9631. 'nsuperior',
  9632. 'osuperior',
  9633. '',
  9634. '',
  9635. 'rsuperior',
  9636. 'ssuperior',
  9637. 'tsuperior',
  9638. '',
  9639. 'ff',
  9640. 'fi',
  9641. 'fl',
  9642. 'ffi',
  9643. 'ffl',
  9644. 'parenleftinferior',
  9645. '',
  9646. 'parenrightinferior',
  9647. 'Circumflexsmall',
  9648. 'hyphensuperior',
  9649. 'Gravesmall',
  9650. 'Asmall',
  9651. 'Bsmall',
  9652. 'Csmall',
  9653. 'Dsmall',
  9654. 'Esmall',
  9655. 'Fsmall',
  9656. 'Gsmall',
  9657. 'Hsmall',
  9658. 'Ismall',
  9659. 'Jsmall',
  9660. 'Ksmall',
  9661. 'Lsmall',
  9662. 'Msmall',
  9663. 'Nsmall',
  9664. 'Osmall',
  9665. 'Psmall',
  9666. 'Qsmall',
  9667. 'Rsmall',
  9668. 'Ssmall',
  9669. 'Tsmall',
  9670. 'Usmall',
  9671. 'Vsmall',
  9672. 'Wsmall',
  9673. 'Xsmall',
  9674. 'Ysmall',
  9675. 'Zsmall',
  9676. 'colonmonetary',
  9677. 'onefitted',
  9678. 'rupiah',
  9679. 'Tildesmall',
  9680. '',
  9681. '',
  9682. '',
  9683. '',
  9684. '',
  9685. '',
  9686. '',
  9687. '',
  9688. '',
  9689. '',
  9690. '',
  9691. '',
  9692. '',
  9693. '',
  9694. '',
  9695. '',
  9696. '',
  9697. '',
  9698. '',
  9699. '',
  9700. '',
  9701. '',
  9702. '',
  9703. '',
  9704. '',
  9705. '',
  9706. '',
  9707. '',
  9708. '',
  9709. '',
  9710. '',
  9711. '',
  9712. '',
  9713. '',
  9714. 'exclamdownsmall',
  9715. 'centoldstyle',
  9716. 'Lslashsmall',
  9717. '',
  9718. '',
  9719. 'Scaronsmall',
  9720. 'Zcaronsmall',
  9721. 'Dieresissmall',
  9722. 'Brevesmall',
  9723. 'Caronsmall',
  9724. '',
  9725. 'Dotaccentsmall',
  9726. '',
  9727. '',
  9728. 'Macronsmall',
  9729. '',
  9730. '',
  9731. 'figuredash',
  9732. 'hypheninferior',
  9733. '',
  9734. '',
  9735. 'Ogoneksmall',
  9736. 'Ringsmall',
  9737. 'Cedillasmall',
  9738. '',
  9739. '',
  9740. '',
  9741. 'onequarter',
  9742. 'onehalf',
  9743. 'threequarters',
  9744. 'questiondownsmall',
  9745. 'oneeighth',
  9746. 'threeeighths',
  9747. 'fiveeighths',
  9748. 'seveneighths',
  9749. 'onethird',
  9750. 'twothirds',
  9751. '',
  9752. '',
  9753. 'zerosuperior',
  9754. 'onesuperior',
  9755. 'twosuperior',
  9756. 'threesuperior',
  9757. 'foursuperior',
  9758. 'fivesuperior',
  9759. 'sixsuperior',
  9760. 'sevensuperior',
  9761. 'eightsuperior',
  9762. 'ninesuperior',
  9763. 'zeroinferior',
  9764. 'oneinferior',
  9765. 'twoinferior',
  9766. 'threeinferior',
  9767. 'fourinferior',
  9768. 'fiveinferior',
  9769. 'sixinferior',
  9770. 'seveninferior',
  9771. 'eightinferior',
  9772. 'nineinferior',
  9773. 'centinferior',
  9774. 'dollarinferior',
  9775. 'periodinferior',
  9776. 'commainferior',
  9777. 'Agravesmall',
  9778. 'Aacutesmall',
  9779. 'Acircumflexsmall',
  9780. 'Atildesmall',
  9781. 'Adieresissmall',
  9782. 'Aringsmall',
  9783. 'AEsmall',
  9784. 'Ccedillasmall',
  9785. 'Egravesmall',
  9786. 'Eacutesmall',
  9787. 'Ecircumflexsmall',
  9788. 'Edieresissmall',
  9789. 'Igravesmall',
  9790. 'Iacutesmall',
  9791. 'Icircumflexsmall',
  9792. 'Idieresissmall',
  9793. 'Ethsmall',
  9794. 'Ntildesmall',
  9795. 'Ogravesmall',
  9796. 'Oacutesmall',
  9797. 'Ocircumflexsmall',
  9798. 'Otildesmall',
  9799. 'Odieresissmall',
  9800. 'OEsmall',
  9801. 'Oslashsmall',
  9802. 'Ugravesmall',
  9803. 'Uacutesmall',
  9804. 'Ucircumflexsmall',
  9805. 'Udieresissmall',
  9806. 'Yacutesmall',
  9807. 'Thornsmall',
  9808. 'Ydieresissmall'
  9809. ];
  9810. var MacExpertEncoding = [
  9811. '',
  9812. '',
  9813. '',
  9814. '',
  9815. '',
  9816. '',
  9817. '',
  9818. '',
  9819. '',
  9820. '',
  9821. '',
  9822. '',
  9823. '',
  9824. '',
  9825. '',
  9826. '',
  9827. '',
  9828. '',
  9829. '',
  9830. '',
  9831. '',
  9832. '',
  9833. '',
  9834. '',
  9835. '',
  9836. '',
  9837. '',
  9838. '',
  9839. '',
  9840. '',
  9841. '',
  9842. '',
  9843. 'space',
  9844. 'exclamsmall',
  9845. 'Hungarumlautsmall',
  9846. 'centoldstyle',
  9847. 'dollaroldstyle',
  9848. 'dollarsuperior',
  9849. 'ampersandsmall',
  9850. 'Acutesmall',
  9851. 'parenleftsuperior',
  9852. 'parenrightsuperior',
  9853. 'twodotenleader',
  9854. 'onedotenleader',
  9855. 'comma',
  9856. 'hyphen',
  9857. 'period',
  9858. 'fraction',
  9859. 'zerooldstyle',
  9860. 'oneoldstyle',
  9861. 'twooldstyle',
  9862. 'threeoldstyle',
  9863. 'fouroldstyle',
  9864. 'fiveoldstyle',
  9865. 'sixoldstyle',
  9866. 'sevenoldstyle',
  9867. 'eightoldstyle',
  9868. 'nineoldstyle',
  9869. 'colon',
  9870. 'semicolon',
  9871. '',
  9872. 'threequartersemdash',
  9873. '',
  9874. 'questionsmall',
  9875. '',
  9876. '',
  9877. '',
  9878. '',
  9879. 'Ethsmall',
  9880. '',
  9881. '',
  9882. 'onequarter',
  9883. 'onehalf',
  9884. 'threequarters',
  9885. 'oneeighth',
  9886. 'threeeighths',
  9887. 'fiveeighths',
  9888. 'seveneighths',
  9889. 'onethird',
  9890. 'twothirds',
  9891. '',
  9892. '',
  9893. '',
  9894. '',
  9895. '',
  9896. '',
  9897. 'ff',
  9898. 'fi',
  9899. 'fl',
  9900. 'ffi',
  9901. 'ffl',
  9902. 'parenleftinferior',
  9903. '',
  9904. 'parenrightinferior',
  9905. 'Circumflexsmall',
  9906. 'hypheninferior',
  9907. 'Gravesmall',
  9908. 'Asmall',
  9909. 'Bsmall',
  9910. 'Csmall',
  9911. 'Dsmall',
  9912. 'Esmall',
  9913. 'Fsmall',
  9914. 'Gsmall',
  9915. 'Hsmall',
  9916. 'Ismall',
  9917. 'Jsmall',
  9918. 'Ksmall',
  9919. 'Lsmall',
  9920. 'Msmall',
  9921. 'Nsmall',
  9922. 'Osmall',
  9923. 'Psmall',
  9924. 'Qsmall',
  9925. 'Rsmall',
  9926. 'Ssmall',
  9927. 'Tsmall',
  9928. 'Usmall',
  9929. 'Vsmall',
  9930. 'Wsmall',
  9931. 'Xsmall',
  9932. 'Ysmall',
  9933. 'Zsmall',
  9934. 'colonmonetary',
  9935. 'onefitted',
  9936. 'rupiah',
  9937. 'Tildesmall',
  9938. '',
  9939. '',
  9940. 'asuperior',
  9941. 'centsuperior',
  9942. '',
  9943. '',
  9944. '',
  9945. '',
  9946. 'Aacutesmall',
  9947. 'Agravesmall',
  9948. 'Acircumflexsmall',
  9949. 'Adieresissmall',
  9950. 'Atildesmall',
  9951. 'Aringsmall',
  9952. 'Ccedillasmall',
  9953. 'Eacutesmall',
  9954. 'Egravesmall',
  9955. 'Ecircumflexsmall',
  9956. 'Edieresissmall',
  9957. 'Iacutesmall',
  9958. 'Igravesmall',
  9959. 'Icircumflexsmall',
  9960. 'Idieresissmall',
  9961. 'Ntildesmall',
  9962. 'Oacutesmall',
  9963. 'Ogravesmall',
  9964. 'Ocircumflexsmall',
  9965. 'Odieresissmall',
  9966. 'Otildesmall',
  9967. 'Uacutesmall',
  9968. 'Ugravesmall',
  9969. 'Ucircumflexsmall',
  9970. 'Udieresissmall',
  9971. '',
  9972. 'eightsuperior',
  9973. 'fourinferior',
  9974. 'threeinferior',
  9975. 'sixinferior',
  9976. 'eightinferior',
  9977. 'seveninferior',
  9978. 'Scaronsmall',
  9979. '',
  9980. 'centinferior',
  9981. 'twoinferior',
  9982. '',
  9983. 'Dieresissmall',
  9984. '',
  9985. 'Caronsmall',
  9986. 'osuperior',
  9987. 'fiveinferior',
  9988. '',
  9989. 'commainferior',
  9990. 'periodinferior',
  9991. 'Yacutesmall',
  9992. '',
  9993. 'dollarinferior',
  9994. '',
  9995. 'Thornsmall',
  9996. '',
  9997. 'nineinferior',
  9998. 'zeroinferior',
  9999. 'Zcaronsmall',
  10000. 'AEsmall',
  10001. 'Oslashsmall',
  10002. 'questiondownsmall',
  10003. 'oneinferior',
  10004. 'Lslashsmall',
  10005. '',
  10006. '',
  10007. '',
  10008. '',
  10009. '',
  10010. '',
  10011. 'Cedillasmall',
  10012. '',
  10013. '',
  10014. '',
  10015. '',
  10016. '',
  10017. 'OEsmall',
  10018. 'figuredash',
  10019. 'hyphensuperior',
  10020. '',
  10021. '',
  10022. '',
  10023. '',
  10024. 'exclamdownsmall',
  10025. '',
  10026. 'Ydieresissmall',
  10027. '',
  10028. 'onesuperior',
  10029. 'twosuperior',
  10030. 'threesuperior',
  10031. 'foursuperior',
  10032. 'fivesuperior',
  10033. 'sixsuperior',
  10034. 'sevensuperior',
  10035. 'ninesuperior',
  10036. 'zerosuperior',
  10037. '',
  10038. 'esuperior',
  10039. 'rsuperior',
  10040. 'tsuperior',
  10041. '',
  10042. '',
  10043. 'isuperior',
  10044. 'ssuperior',
  10045. 'dsuperior',
  10046. '',
  10047. '',
  10048. '',
  10049. '',
  10050. '',
  10051. 'lsuperior',
  10052. 'Ogoneksmall',
  10053. 'Brevesmall',
  10054. 'Macronsmall',
  10055. 'bsuperior',
  10056. 'nsuperior',
  10057. 'msuperior',
  10058. 'commasuperior',
  10059. 'periodsuperior',
  10060. 'Dotaccentsmall',
  10061. 'Ringsmall'
  10062. ];
  10063. var MacRomanEncoding = [
  10064. '',
  10065. '',
  10066. '',
  10067. '',
  10068. '',
  10069. '',
  10070. '',
  10071. '',
  10072. '',
  10073. '',
  10074. '',
  10075. '',
  10076. '',
  10077. '',
  10078. '',
  10079. '',
  10080. '',
  10081. '',
  10082. '',
  10083. '',
  10084. '',
  10085. '',
  10086. '',
  10087. '',
  10088. '',
  10089. '',
  10090. '',
  10091. '',
  10092. '',
  10093. '',
  10094. '',
  10095. '',
  10096. 'space',
  10097. 'exclam',
  10098. 'quotedbl',
  10099. 'numbersign',
  10100. 'dollar',
  10101. 'percent',
  10102. 'ampersand',
  10103. 'quotesingle',
  10104. 'parenleft',
  10105. 'parenright',
  10106. 'asterisk',
  10107. 'plus',
  10108. 'comma',
  10109. 'hyphen',
  10110. 'period',
  10111. 'slash',
  10112. 'zero',
  10113. 'one',
  10114. 'two',
  10115. 'three',
  10116. 'four',
  10117. 'five',
  10118. 'six',
  10119. 'seven',
  10120. 'eight',
  10121. 'nine',
  10122. 'colon',
  10123. 'semicolon',
  10124. 'less',
  10125. 'equal',
  10126. 'greater',
  10127. 'question',
  10128. 'at',
  10129. 'A',
  10130. 'B',
  10131. 'C',
  10132. 'D',
  10133. 'E',
  10134. 'F',
  10135. 'G',
  10136. 'H',
  10137. 'I',
  10138. 'J',
  10139. 'K',
  10140. 'L',
  10141. 'M',
  10142. 'N',
  10143. 'O',
  10144. 'P',
  10145. 'Q',
  10146. 'R',
  10147. 'S',
  10148. 'T',
  10149. 'U',
  10150. 'V',
  10151. 'W',
  10152. 'X',
  10153. 'Y',
  10154. 'Z',
  10155. 'bracketleft',
  10156. 'backslash',
  10157. 'bracketright',
  10158. 'asciicircum',
  10159. 'underscore',
  10160. 'grave',
  10161. 'a',
  10162. 'b',
  10163. 'c',
  10164. 'd',
  10165. 'e',
  10166. 'f',
  10167. 'g',
  10168. 'h',
  10169. 'i',
  10170. 'j',
  10171. 'k',
  10172. 'l',
  10173. 'm',
  10174. 'n',
  10175. 'o',
  10176. 'p',
  10177. 'q',
  10178. 'r',
  10179. 's',
  10180. 't',
  10181. 'u',
  10182. 'v',
  10183. 'w',
  10184. 'x',
  10185. 'y',
  10186. 'z',
  10187. 'braceleft',
  10188. 'bar',
  10189. 'braceright',
  10190. 'asciitilde',
  10191. '',
  10192. 'Adieresis',
  10193. 'Aring',
  10194. 'Ccedilla',
  10195. 'Eacute',
  10196. 'Ntilde',
  10197. 'Odieresis',
  10198. 'Udieresis',
  10199. 'aacute',
  10200. 'agrave',
  10201. 'acircumflex',
  10202. 'adieresis',
  10203. 'atilde',
  10204. 'aring',
  10205. 'ccedilla',
  10206. 'eacute',
  10207. 'egrave',
  10208. 'ecircumflex',
  10209. 'edieresis',
  10210. 'iacute',
  10211. 'igrave',
  10212. 'icircumflex',
  10213. 'idieresis',
  10214. 'ntilde',
  10215. 'oacute',
  10216. 'ograve',
  10217. 'ocircumflex',
  10218. 'odieresis',
  10219. 'otilde',
  10220. 'uacute',
  10221. 'ugrave',
  10222. 'ucircumflex',
  10223. 'udieresis',
  10224. 'dagger',
  10225. 'degree',
  10226. 'cent',
  10227. 'sterling',
  10228. 'section',
  10229. 'bullet',
  10230. 'paragraph',
  10231. 'germandbls',
  10232. 'registered',
  10233. 'copyright',
  10234. 'trademark',
  10235. 'acute',
  10236. 'dieresis',
  10237. 'notequal',
  10238. 'AE',
  10239. 'Oslash',
  10240. 'infinity',
  10241. 'plusminus',
  10242. 'lessequal',
  10243. 'greaterequal',
  10244. 'yen',
  10245. 'mu',
  10246. 'partialdiff',
  10247. 'summation',
  10248. 'product',
  10249. 'pi',
  10250. 'integral',
  10251. 'ordfeminine',
  10252. 'ordmasculine',
  10253. 'Omega',
  10254. 'ae',
  10255. 'oslash',
  10256. 'questiondown',
  10257. 'exclamdown',
  10258. 'logicalnot',
  10259. 'radical',
  10260. 'florin',
  10261. 'approxequal',
  10262. 'Delta',
  10263. 'guillemotleft',
  10264. 'guillemotright',
  10265. 'ellipsis',
  10266. 'space',
  10267. 'Agrave',
  10268. 'Atilde',
  10269. 'Otilde',
  10270. 'OE',
  10271. 'oe',
  10272. 'endash',
  10273. 'emdash',
  10274. 'quotedblleft',
  10275. 'quotedblright',
  10276. 'quoteleft',
  10277. 'quoteright',
  10278. 'divide',
  10279. 'lozenge',
  10280. 'ydieresis',
  10281. 'Ydieresis',
  10282. 'fraction',
  10283. 'currency',
  10284. 'guilsinglleft',
  10285. 'guilsinglright',
  10286. 'fi',
  10287. 'fl',
  10288. 'daggerdbl',
  10289. 'periodcentered',
  10290. 'quotesinglbase',
  10291. 'quotedblbase',
  10292. 'perthousand',
  10293. 'Acircumflex',
  10294. 'Ecircumflex',
  10295. 'Aacute',
  10296. 'Edieresis',
  10297. 'Egrave',
  10298. 'Iacute',
  10299. 'Icircumflex',
  10300. 'Idieresis',
  10301. 'Igrave',
  10302. 'Oacute',
  10303. 'Ocircumflex',
  10304. 'apple',
  10305. 'Ograve',
  10306. 'Uacute',
  10307. 'Ucircumflex',
  10308. 'Ugrave',
  10309. 'dotlessi',
  10310. 'circumflex',
  10311. 'tilde',
  10312. 'macron',
  10313. 'breve',
  10314. 'dotaccent',
  10315. 'ring',
  10316. 'cedilla',
  10317. 'hungarumlaut',
  10318. 'ogonek',
  10319. 'caron'
  10320. ];
  10321. var StandardEncoding = [
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. '',
  10338. '',
  10339. '',
  10340. '',
  10341. '',
  10342. '',
  10343. '',
  10344. '',
  10345. '',
  10346. '',
  10347. '',
  10348. '',
  10349. '',
  10350. '',
  10351. '',
  10352. '',
  10353. '',
  10354. 'space',
  10355. 'exclam',
  10356. 'quotedbl',
  10357. 'numbersign',
  10358. 'dollar',
  10359. 'percent',
  10360. 'ampersand',
  10361. 'quoteright',
  10362. 'parenleft',
  10363. 'parenright',
  10364. 'asterisk',
  10365. 'plus',
  10366. 'comma',
  10367. 'hyphen',
  10368. 'period',
  10369. 'slash',
  10370. 'zero',
  10371. 'one',
  10372. 'two',
  10373. 'three',
  10374. 'four',
  10375. 'five',
  10376. 'six',
  10377. 'seven',
  10378. 'eight',
  10379. 'nine',
  10380. 'colon',
  10381. 'semicolon',
  10382. 'less',
  10383. 'equal',
  10384. 'greater',
  10385. 'question',
  10386. 'at',
  10387. 'A',
  10388. 'B',
  10389. 'C',
  10390. 'D',
  10391. 'E',
  10392. 'F',
  10393. 'G',
  10394. 'H',
  10395. 'I',
  10396. 'J',
  10397. 'K',
  10398. 'L',
  10399. 'M',
  10400. 'N',
  10401. 'O',
  10402. 'P',
  10403. 'Q',
  10404. 'R',
  10405. 'S',
  10406. 'T',
  10407. 'U',
  10408. 'V',
  10409. 'W',
  10410. 'X',
  10411. 'Y',
  10412. 'Z',
  10413. 'bracketleft',
  10414. 'backslash',
  10415. 'bracketright',
  10416. 'asciicircum',
  10417. 'underscore',
  10418. 'quoteleft',
  10419. 'a',
  10420. 'b',
  10421. 'c',
  10422. 'd',
  10423. 'e',
  10424. 'f',
  10425. 'g',
  10426. 'h',
  10427. 'i',
  10428. 'j',
  10429. 'k',
  10430. 'l',
  10431. 'm',
  10432. 'n',
  10433. 'o',
  10434. 'p',
  10435. 'q',
  10436. 'r',
  10437. 's',
  10438. 't',
  10439. 'u',
  10440. 'v',
  10441. 'w',
  10442. 'x',
  10443. 'y',
  10444. 'z',
  10445. 'braceleft',
  10446. 'bar',
  10447. 'braceright',
  10448. 'asciitilde',
  10449. '',
  10450. '',
  10451. '',
  10452. '',
  10453. '',
  10454. '',
  10455. '',
  10456. '',
  10457. '',
  10458. '',
  10459. '',
  10460. '',
  10461. '',
  10462. '',
  10463. '',
  10464. '',
  10465. '',
  10466. '',
  10467. '',
  10468. '',
  10469. '',
  10470. '',
  10471. '',
  10472. '',
  10473. '',
  10474. '',
  10475. '',
  10476. '',
  10477. '',
  10478. '',
  10479. '',
  10480. '',
  10481. '',
  10482. '',
  10483. 'exclamdown',
  10484. 'cent',
  10485. 'sterling',
  10486. 'fraction',
  10487. 'yen',
  10488. 'florin',
  10489. 'section',
  10490. 'currency',
  10491. 'quotesingle',
  10492. 'quotedblleft',
  10493. 'guillemotleft',
  10494. 'guilsinglleft',
  10495. 'guilsinglright',
  10496. 'fi',
  10497. 'fl',
  10498. '',
  10499. 'endash',
  10500. 'dagger',
  10501. 'daggerdbl',
  10502. 'periodcentered',
  10503. '',
  10504. 'paragraph',
  10505. 'bullet',
  10506. 'quotesinglbase',
  10507. 'quotedblbase',
  10508. 'quotedblright',
  10509. 'guillemotright',
  10510. 'ellipsis',
  10511. 'perthousand',
  10512. '',
  10513. 'questiondown',
  10514. '',
  10515. 'grave',
  10516. 'acute',
  10517. 'circumflex',
  10518. 'tilde',
  10519. 'macron',
  10520. 'breve',
  10521. 'dotaccent',
  10522. 'dieresis',
  10523. '',
  10524. 'ring',
  10525. 'cedilla',
  10526. '',
  10527. 'hungarumlaut',
  10528. 'ogonek',
  10529. 'caron',
  10530. 'emdash',
  10531. '',
  10532. '',
  10533. '',
  10534. '',
  10535. '',
  10536. '',
  10537. '',
  10538. '',
  10539. '',
  10540. '',
  10541. '',
  10542. '',
  10543. '',
  10544. '',
  10545. '',
  10546. '',
  10547. 'AE',
  10548. '',
  10549. 'ordfeminine',
  10550. '',
  10551. '',
  10552. '',
  10553. '',
  10554. 'Lslash',
  10555. 'Oslash',
  10556. 'OE',
  10557. 'ordmasculine',
  10558. '',
  10559. '',
  10560. '',
  10561. '',
  10562. '',
  10563. 'ae',
  10564. '',
  10565. '',
  10566. '',
  10567. 'dotlessi',
  10568. '',
  10569. '',
  10570. 'lslash',
  10571. 'oslash',
  10572. 'oe',
  10573. 'germandbls'
  10574. ];
  10575. var WinAnsiEncoding = [
  10576. '',
  10577. '',
  10578. '',
  10579. '',
  10580. '',
  10581. '',
  10582. '',
  10583. '',
  10584. '',
  10585. '',
  10586. '',
  10587. '',
  10588. '',
  10589. '',
  10590. '',
  10591. '',
  10592. '',
  10593. '',
  10594. '',
  10595. '',
  10596. '',
  10597. '',
  10598. '',
  10599. '',
  10600. '',
  10601. '',
  10602. '',
  10603. '',
  10604. '',
  10605. '',
  10606. '',
  10607. '',
  10608. 'space',
  10609. 'exclam',
  10610. 'quotedbl',
  10611. 'numbersign',
  10612. 'dollar',
  10613. 'percent',
  10614. 'ampersand',
  10615. 'quotesingle',
  10616. 'parenleft',
  10617. 'parenright',
  10618. 'asterisk',
  10619. 'plus',
  10620. 'comma',
  10621. 'hyphen',
  10622. 'period',
  10623. 'slash',
  10624. 'zero',
  10625. 'one',
  10626. 'two',
  10627. 'three',
  10628. 'four',
  10629. 'five',
  10630. 'six',
  10631. 'seven',
  10632. 'eight',
  10633. 'nine',
  10634. 'colon',
  10635. 'semicolon',
  10636. 'less',
  10637. 'equal',
  10638. 'greater',
  10639. 'question',
  10640. 'at',
  10641. 'A',
  10642. 'B',
  10643. 'C',
  10644. 'D',
  10645. 'E',
  10646. 'F',
  10647. 'G',
  10648. 'H',
  10649. 'I',
  10650. 'J',
  10651. 'K',
  10652. 'L',
  10653. 'M',
  10654. 'N',
  10655. 'O',
  10656. 'P',
  10657. 'Q',
  10658. 'R',
  10659. 'S',
  10660. 'T',
  10661. 'U',
  10662. 'V',
  10663. 'W',
  10664. 'X',
  10665. 'Y',
  10666. 'Z',
  10667. 'bracketleft',
  10668. 'backslash',
  10669. 'bracketright',
  10670. 'asciicircum',
  10671. 'underscore',
  10672. 'grave',
  10673. 'a',
  10674. 'b',
  10675. 'c',
  10676. 'd',
  10677. 'e',
  10678. 'f',
  10679. 'g',
  10680. 'h',
  10681. 'i',
  10682. 'j',
  10683. 'k',
  10684. 'l',
  10685. 'm',
  10686. 'n',
  10687. 'o',
  10688. 'p',
  10689. 'q',
  10690. 'r',
  10691. 's',
  10692. 't',
  10693. 'u',
  10694. 'v',
  10695. 'w',
  10696. 'x',
  10697. 'y',
  10698. 'z',
  10699. 'braceleft',
  10700. 'bar',
  10701. 'braceright',
  10702. 'asciitilde',
  10703. 'bullet',
  10704. 'Euro',
  10705. 'bullet',
  10706. 'quotesinglbase',
  10707. 'florin',
  10708. 'quotedblbase',
  10709. 'ellipsis',
  10710. 'dagger',
  10711. 'daggerdbl',
  10712. 'circumflex',
  10713. 'perthousand',
  10714. 'Scaron',
  10715. 'guilsinglleft',
  10716. 'OE',
  10717. 'bullet',
  10718. 'Zcaron',
  10719. 'bullet',
  10720. 'bullet',
  10721. 'quoteleft',
  10722. 'quoteright',
  10723. 'quotedblleft',
  10724. 'quotedblright',
  10725. 'bullet',
  10726. 'endash',
  10727. 'emdash',
  10728. 'tilde',
  10729. 'trademark',
  10730. 'scaron',
  10731. 'guilsinglright',
  10732. 'oe',
  10733. 'bullet',
  10734. 'zcaron',
  10735. 'Ydieresis',
  10736. 'space',
  10737. 'exclamdown',
  10738. 'cent',
  10739. 'sterling',
  10740. 'currency',
  10741. 'yen',
  10742. 'brokenbar',
  10743. 'section',
  10744. 'dieresis',
  10745. 'copyright',
  10746. 'ordfeminine',
  10747. 'guillemotleft',
  10748. 'logicalnot',
  10749. 'hyphen',
  10750. 'registered',
  10751. 'macron',
  10752. 'degree',
  10753. 'plusminus',
  10754. 'twosuperior',
  10755. 'threesuperior',
  10756. 'acute',
  10757. 'mu',
  10758. 'paragraph',
  10759. 'periodcentered',
  10760. 'cedilla',
  10761. 'onesuperior',
  10762. 'ordmasculine',
  10763. 'guillemotright',
  10764. 'onequarter',
  10765. 'onehalf',
  10766. 'threequarters',
  10767. 'questiondown',
  10768. 'Agrave',
  10769. 'Aacute',
  10770. 'Acircumflex',
  10771. 'Atilde',
  10772. 'Adieresis',
  10773. 'Aring',
  10774. 'AE',
  10775. 'Ccedilla',
  10776. 'Egrave',
  10777. 'Eacute',
  10778. 'Ecircumflex',
  10779. 'Edieresis',
  10780. 'Igrave',
  10781. 'Iacute',
  10782. 'Icircumflex',
  10783. 'Idieresis',
  10784. 'Eth',
  10785. 'Ntilde',
  10786. 'Ograve',
  10787. 'Oacute',
  10788. 'Ocircumflex',
  10789. 'Otilde',
  10790. 'Odieresis',
  10791. 'multiply',
  10792. 'Oslash',
  10793. 'Ugrave',
  10794. 'Uacute',
  10795. 'Ucircumflex',
  10796. 'Udieresis',
  10797. 'Yacute',
  10798. 'Thorn',
  10799. 'germandbls',
  10800. 'agrave',
  10801. 'aacute',
  10802. 'acircumflex',
  10803. 'atilde',
  10804. 'adieresis',
  10805. 'aring',
  10806. 'ae',
  10807. 'ccedilla',
  10808. 'egrave',
  10809. 'eacute',
  10810. 'ecircumflex',
  10811. 'edieresis',
  10812. 'igrave',
  10813. 'iacute',
  10814. 'icircumflex',
  10815. 'idieresis',
  10816. 'eth',
  10817. 'ntilde',
  10818. 'ograve',
  10819. 'oacute',
  10820. 'ocircumflex',
  10821. 'otilde',
  10822. 'odieresis',
  10823. 'divide',
  10824. 'oslash',
  10825. 'ugrave',
  10826. 'uacute',
  10827. 'ucircumflex',
  10828. 'udieresis',
  10829. 'yacute',
  10830. 'thorn',
  10831. 'ydieresis'
  10832. ];
  10833. var SymbolSetEncoding = [
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. '',
  10850. '',
  10851. '',
  10852. '',
  10853. '',
  10854. '',
  10855. '',
  10856. '',
  10857. '',
  10858. '',
  10859. '',
  10860. '',
  10861. '',
  10862. '',
  10863. '',
  10864. '',
  10865. '',
  10866. 'space',
  10867. 'exclam',
  10868. 'universal',
  10869. 'numbersign',
  10870. 'existential',
  10871. 'percent',
  10872. 'ampersand',
  10873. 'suchthat',
  10874. 'parenleft',
  10875. 'parenright',
  10876. 'asteriskmath',
  10877. 'plus',
  10878. 'comma',
  10879. 'minus',
  10880. 'period',
  10881. 'slash',
  10882. 'zero',
  10883. 'one',
  10884. 'two',
  10885. 'three',
  10886. 'four',
  10887. 'five',
  10888. 'six',
  10889. 'seven',
  10890. 'eight',
  10891. 'nine',
  10892. 'colon',
  10893. 'semicolon',
  10894. 'less',
  10895. 'equal',
  10896. 'greater',
  10897. 'question',
  10898. 'congruent',
  10899. 'Alpha',
  10900. 'Beta',
  10901. 'Chi',
  10902. 'Delta',
  10903. 'Epsilon',
  10904. 'Phi',
  10905. 'Gamma',
  10906. 'Eta',
  10907. 'Iota',
  10908. 'theta1',
  10909. 'Kappa',
  10910. 'Lambda',
  10911. 'Mu',
  10912. 'Nu',
  10913. 'Omicron',
  10914. 'Pi',
  10915. 'Theta',
  10916. 'Rho',
  10917. 'Sigma',
  10918. 'Tau',
  10919. 'Upsilon',
  10920. 'sigma1',
  10921. 'Omega',
  10922. 'Xi',
  10923. 'Psi',
  10924. 'Zeta',
  10925. 'bracketleft',
  10926. 'therefore',
  10927. 'bracketright',
  10928. 'perpendicular',
  10929. 'underscore',
  10930. 'radicalex',
  10931. 'alpha',
  10932. 'beta',
  10933. 'chi',
  10934. 'delta',
  10935. 'epsilon',
  10936. 'phi',
  10937. 'gamma',
  10938. 'eta',
  10939. 'iota',
  10940. 'phi1',
  10941. 'kappa',
  10942. 'lambda',
  10943. 'mu',
  10944. 'nu',
  10945. 'omicron',
  10946. 'pi',
  10947. 'theta',
  10948. 'rho',
  10949. 'sigma',
  10950. 'tau',
  10951. 'upsilon',
  10952. 'omega1',
  10953. 'omega',
  10954. 'xi',
  10955. 'psi',
  10956. 'zeta',
  10957. 'braceleft',
  10958. 'bar',
  10959. 'braceright',
  10960. 'similar',
  10961. '',
  10962. '',
  10963. '',
  10964. '',
  10965. '',
  10966. '',
  10967. '',
  10968. '',
  10969. '',
  10970. '',
  10971. '',
  10972. '',
  10973. '',
  10974. '',
  10975. '',
  10976. '',
  10977. '',
  10978. '',
  10979. '',
  10980. '',
  10981. '',
  10982. '',
  10983. '',
  10984. '',
  10985. '',
  10986. '',
  10987. '',
  10988. '',
  10989. '',
  10990. '',
  10991. '',
  10992. '',
  10993. '',
  10994. 'Euro',
  10995. 'Upsilon1',
  10996. 'minute',
  10997. 'lessequal',
  10998. 'fraction',
  10999. 'infinity',
  11000. 'florin',
  11001. 'club',
  11002. 'diamond',
  11003. 'heart',
  11004. 'spade',
  11005. 'arrowboth',
  11006. 'arrowleft',
  11007. 'arrowup',
  11008. 'arrowright',
  11009. 'arrowdown',
  11010. 'degree',
  11011. 'plusminus',
  11012. 'second',
  11013. 'greaterequal',
  11014. 'multiply',
  11015. 'proportional',
  11016. 'partialdiff',
  11017. 'bullet',
  11018. 'divide',
  11019. 'notequal',
  11020. 'equivalence',
  11021. 'approxequal',
  11022. 'ellipsis',
  11023. 'arrowvertex',
  11024. 'arrowhorizex',
  11025. 'carriagereturn',
  11026. 'aleph',
  11027. 'Ifraktur',
  11028. 'Rfraktur',
  11029. 'weierstrass',
  11030. 'circlemultiply',
  11031. 'circleplus',
  11032. 'emptyset',
  11033. 'intersection',
  11034. 'union',
  11035. 'propersuperset',
  11036. 'reflexsuperset',
  11037. 'notsubset',
  11038. 'propersubset',
  11039. 'reflexsubset',
  11040. 'element',
  11041. 'notelement',
  11042. 'angle',
  11043. 'gradient',
  11044. 'registerserif',
  11045. 'copyrightserif',
  11046. 'trademarkserif',
  11047. 'product',
  11048. 'radical',
  11049. 'dotmath',
  11050. 'logicalnot',
  11051. 'logicaland',
  11052. 'logicalor',
  11053. 'arrowdblboth',
  11054. 'arrowdblleft',
  11055. 'arrowdblup',
  11056. 'arrowdblright',
  11057. 'arrowdbldown',
  11058. 'lozenge',
  11059. 'angleleft',
  11060. 'registersans',
  11061. 'copyrightsans',
  11062. 'trademarksans',
  11063. 'summation',
  11064. 'parenlefttp',
  11065. 'parenleftex',
  11066. 'parenleftbt',
  11067. 'bracketlefttp',
  11068. 'bracketleftex',
  11069. 'bracketleftbt',
  11070. 'bracelefttp',
  11071. 'braceleftmid',
  11072. 'braceleftbt',
  11073. 'braceex',
  11074. '',
  11075. 'angleright',
  11076. 'integral',
  11077. 'integraltp',
  11078. 'integralex',
  11079. 'integralbt',
  11080. 'parenrighttp',
  11081. 'parenrightex',
  11082. 'parenrightbt',
  11083. 'bracketrighttp',
  11084. 'bracketrightex',
  11085. 'bracketrightbt',
  11086. 'bracerighttp',
  11087. 'bracerightmid',
  11088. 'bracerightbt'
  11089. ];
  11090. var ZapfDingbatsEncoding = [
  11091. '',
  11092. '',
  11093. '',
  11094. '',
  11095. '',
  11096. '',
  11097. '',
  11098. '',
  11099. '',
  11100. '',
  11101. '',
  11102. '',
  11103. '',
  11104. '',
  11105. '',
  11106. '',
  11107. '',
  11108. '',
  11109. '',
  11110. '',
  11111. '',
  11112. '',
  11113. '',
  11114. '',
  11115. '',
  11116. '',
  11117. '',
  11118. '',
  11119. '',
  11120. '',
  11121. '',
  11122. '',
  11123. 'space',
  11124. 'a1',
  11125. 'a2',
  11126. 'a202',
  11127. 'a3',
  11128. 'a4',
  11129. 'a5',
  11130. 'a119',
  11131. 'a118',
  11132. 'a117',
  11133. 'a11',
  11134. 'a12',
  11135. 'a13',
  11136. 'a14',
  11137. 'a15',
  11138. 'a16',
  11139. 'a105',
  11140. 'a17',
  11141. 'a18',
  11142. 'a19',
  11143. 'a20',
  11144. 'a21',
  11145. 'a22',
  11146. 'a23',
  11147. 'a24',
  11148. 'a25',
  11149. 'a26',
  11150. 'a27',
  11151. 'a28',
  11152. 'a6',
  11153. 'a7',
  11154. 'a8',
  11155. 'a9',
  11156. 'a10',
  11157. 'a29',
  11158. 'a30',
  11159. 'a31',
  11160. 'a32',
  11161. 'a33',
  11162. 'a34',
  11163. 'a35',
  11164. 'a36',
  11165. 'a37',
  11166. 'a38',
  11167. 'a39',
  11168. 'a40',
  11169. 'a41',
  11170. 'a42',
  11171. 'a43',
  11172. 'a44',
  11173. 'a45',
  11174. 'a46',
  11175. 'a47',
  11176. 'a48',
  11177. 'a49',
  11178. 'a50',
  11179. 'a51',
  11180. 'a52',
  11181. 'a53',
  11182. 'a54',
  11183. 'a55',
  11184. 'a56',
  11185. 'a57',
  11186. 'a58',
  11187. 'a59',
  11188. 'a60',
  11189. 'a61',
  11190. 'a62',
  11191. 'a63',
  11192. 'a64',
  11193. 'a65',
  11194. 'a66',
  11195. 'a67',
  11196. 'a68',
  11197. 'a69',
  11198. 'a70',
  11199. 'a71',
  11200. 'a72',
  11201. 'a73',
  11202. 'a74',
  11203. 'a203',
  11204. 'a75',
  11205. 'a204',
  11206. 'a76',
  11207. 'a77',
  11208. 'a78',
  11209. 'a79',
  11210. 'a81',
  11211. 'a82',
  11212. 'a83',
  11213. 'a84',
  11214. 'a97',
  11215. 'a98',
  11216. 'a99',
  11217. 'a100',
  11218. '',
  11219. 'a89',
  11220. 'a90',
  11221. 'a93',
  11222. 'a94',
  11223. 'a91',
  11224. 'a92',
  11225. 'a205',
  11226. 'a85',
  11227. 'a206',
  11228. 'a86',
  11229. 'a87',
  11230. 'a88',
  11231. 'a95',
  11232. 'a96',
  11233. '',
  11234. '',
  11235. '',
  11236. '',
  11237. '',
  11238. '',
  11239. '',
  11240. '',
  11241. '',
  11242. '',
  11243. '',
  11244. '',
  11245. '',
  11246. '',
  11247. '',
  11248. '',
  11249. '',
  11250. '',
  11251. '',
  11252. 'a101',
  11253. 'a102',
  11254. 'a103',
  11255. 'a104',
  11256. 'a106',
  11257. 'a107',
  11258. 'a108',
  11259. 'a112',
  11260. 'a111',
  11261. 'a110',
  11262. 'a109',
  11263. 'a120',
  11264. 'a121',
  11265. 'a122',
  11266. 'a123',
  11267. 'a124',
  11268. 'a125',
  11269. 'a126',
  11270. 'a127',
  11271. 'a128',
  11272. 'a129',
  11273. 'a130',
  11274. 'a131',
  11275. 'a132',
  11276. 'a133',
  11277. 'a134',
  11278. 'a135',
  11279. 'a136',
  11280. 'a137',
  11281. 'a138',
  11282. 'a139',
  11283. 'a140',
  11284. 'a141',
  11285. 'a142',
  11286. 'a143',
  11287. 'a144',
  11288. 'a145',
  11289. 'a146',
  11290. 'a147',
  11291. 'a148',
  11292. 'a149',
  11293. 'a150',
  11294. 'a151',
  11295. 'a152',
  11296. 'a153',
  11297. 'a154',
  11298. 'a155',
  11299. 'a156',
  11300. 'a157',
  11301. 'a158',
  11302. 'a159',
  11303. 'a160',
  11304. 'a161',
  11305. 'a163',
  11306. 'a164',
  11307. 'a196',
  11308. 'a165',
  11309. 'a192',
  11310. 'a166',
  11311. 'a167',
  11312. 'a168',
  11313. 'a169',
  11314. 'a170',
  11315. 'a171',
  11316. 'a172',
  11317. 'a173',
  11318. 'a162',
  11319. 'a174',
  11320. 'a175',
  11321. 'a176',
  11322. 'a177',
  11323. 'a178',
  11324. 'a179',
  11325. 'a193',
  11326. 'a180',
  11327. 'a199',
  11328. 'a181',
  11329. 'a200',
  11330. 'a182',
  11331. '',
  11332. 'a201',
  11333. 'a183',
  11334. 'a184',
  11335. 'a197',
  11336. 'a185',
  11337. 'a194',
  11338. 'a198',
  11339. 'a186',
  11340. 'a195',
  11341. 'a187',
  11342. 'a188',
  11343. 'a189',
  11344. 'a190',
  11345. 'a191'
  11346. ];
  11347. function getEncoding(encodingName) {
  11348. switch (encodingName) {
  11349. case 'WinAnsiEncoding':
  11350. return WinAnsiEncoding;
  11351. case 'StandardEncoding':
  11352. return StandardEncoding;
  11353. case 'MacRomanEncoding':
  11354. return MacRomanEncoding;
  11355. case 'SymbolSetEncoding':
  11356. return SymbolSetEncoding;
  11357. case 'ZapfDingbatsEncoding':
  11358. return ZapfDingbatsEncoding;
  11359. case 'ExpertEncoding':
  11360. return ExpertEncoding;
  11361. case 'MacExpertEncoding':
  11362. return MacExpertEncoding;
  11363. default:
  11364. return null;
  11365. }
  11366. }
  11367. exports.WinAnsiEncoding = WinAnsiEncoding;
  11368. exports.StandardEncoding = StandardEncoding;
  11369. exports.MacRomanEncoding = MacRomanEncoding;
  11370. exports.SymbolSetEncoding = SymbolSetEncoding;
  11371. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  11372. exports.ExpertEncoding = ExpertEncoding;
  11373. exports.getEncoding = getEncoding;
  11374. /***/ }),
  11375. /* 6 */
  11376. /***/ (function(module, exports, __w_pdfjs_require__) {
  11377. "use strict";
  11378. var sharedUtil = __w_pdfjs_require__(0);
  11379. var corePrimitives = __w_pdfjs_require__(1);
  11380. var coreStream = __w_pdfjs_require__(2);
  11381. var MissingDataException = sharedUtil.MissingDataException;
  11382. var StreamType = sharedUtil.StreamType;
  11383. var assert = sharedUtil.assert;
  11384. var error = sharedUtil.error;
  11385. var info = sharedUtil.info;
  11386. var isArray = sharedUtil.isArray;
  11387. var isInt = sharedUtil.isInt;
  11388. var isNum = sharedUtil.isNum;
  11389. var isString = sharedUtil.isString;
  11390. var warn = sharedUtil.warn;
  11391. var EOF = corePrimitives.EOF;
  11392. var Cmd = corePrimitives.Cmd;
  11393. var Dict = corePrimitives.Dict;
  11394. var Name = corePrimitives.Name;
  11395. var Ref = corePrimitives.Ref;
  11396. var isEOF = corePrimitives.isEOF;
  11397. var isCmd = corePrimitives.isCmd;
  11398. var isDict = corePrimitives.isDict;
  11399. var isName = corePrimitives.isName;
  11400. var Ascii85Stream = coreStream.Ascii85Stream;
  11401. var AsciiHexStream = coreStream.AsciiHexStream;
  11402. var CCITTFaxStream = coreStream.CCITTFaxStream;
  11403. var FlateStream = coreStream.FlateStream;
  11404. var Jbig2Stream = coreStream.Jbig2Stream;
  11405. var JpegStream = coreStream.JpegStream;
  11406. var JpxStream = coreStream.JpxStream;
  11407. var LZWStream = coreStream.LZWStream;
  11408. var NullStream = coreStream.NullStream;
  11409. var PredictorStream = coreStream.PredictorStream;
  11410. var RunLengthStream = coreStream.RunLengthStream;
  11411. var MAX_LENGTH_TO_CACHE = 1000;
  11412. var Parser = function ParserClosure() {
  11413. function Parser(lexer, allowStreams, xref, recoveryMode) {
  11414. this.lexer = lexer;
  11415. this.allowStreams = allowStreams;
  11416. this.xref = xref;
  11417. this.recoveryMode = recoveryMode || false;
  11418. this.imageCache = Object.create(null);
  11419. this.refill();
  11420. }
  11421. Parser.prototype = {
  11422. refill: function Parser_refill() {
  11423. this.buf1 = this.lexer.getObj();
  11424. this.buf2 = this.lexer.getObj();
  11425. },
  11426. shift: function Parser_shift() {
  11427. if (isCmd(this.buf2, 'ID')) {
  11428. this.buf1 = this.buf2;
  11429. this.buf2 = null;
  11430. } else {
  11431. this.buf1 = this.buf2;
  11432. this.buf2 = this.lexer.getObj();
  11433. }
  11434. },
  11435. tryShift: function Parser_tryShift() {
  11436. try {
  11437. this.shift();
  11438. return true;
  11439. } catch (e) {
  11440. if (e instanceof MissingDataException) {
  11441. throw e;
  11442. }
  11443. return false;
  11444. }
  11445. },
  11446. getObj: function Parser_getObj(cipherTransform) {
  11447. var buf1 = this.buf1;
  11448. this.shift();
  11449. if (buf1 instanceof Cmd) {
  11450. switch (buf1.cmd) {
  11451. case 'BI':
  11452. return this.makeInlineImage(cipherTransform);
  11453. case '[':
  11454. var array = [];
  11455. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  11456. array.push(this.getObj(cipherTransform));
  11457. }
  11458. if (isEOF(this.buf1)) {
  11459. if (!this.recoveryMode) {
  11460. error('End of file inside array');
  11461. }
  11462. return array;
  11463. }
  11464. this.shift();
  11465. return array;
  11466. case '<<':
  11467. var dict = new Dict(this.xref);
  11468. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  11469. if (!isName(this.buf1)) {
  11470. info('Malformed dictionary: key must be a name object');
  11471. this.shift();
  11472. continue;
  11473. }
  11474. var key = this.buf1.name;
  11475. this.shift();
  11476. if (isEOF(this.buf1)) {
  11477. break;
  11478. }
  11479. dict.set(key, this.getObj(cipherTransform));
  11480. }
  11481. if (isEOF(this.buf1)) {
  11482. if (!this.recoveryMode) {
  11483. error('End of file inside dictionary');
  11484. }
  11485. return dict;
  11486. }
  11487. if (isCmd(this.buf2, 'stream')) {
  11488. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  11489. }
  11490. this.shift();
  11491. return dict;
  11492. default:
  11493. return buf1;
  11494. }
  11495. }
  11496. if (isInt(buf1)) {
  11497. var num = buf1;
  11498. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  11499. var ref = new Ref(num, this.buf1);
  11500. this.shift();
  11501. this.shift();
  11502. return ref;
  11503. }
  11504. return num;
  11505. }
  11506. if (isString(buf1)) {
  11507. var str = buf1;
  11508. if (cipherTransform) {
  11509. str = cipherTransform.decryptString(str);
  11510. }
  11511. return str;
  11512. }
  11513. return buf1;
  11514. },
  11515. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  11516. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  11517. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  11518. while ((ch = stream.getByte()) !== -1) {
  11519. if (state === 0) {
  11520. state = ch === E ? 1 : 0;
  11521. } else if (state === 1) {
  11522. state = ch === I ? 2 : 0;
  11523. } else {
  11524. assert(state === 2);
  11525. if (ch === SPACE || ch === LF || ch === CR) {
  11526. n = 5;
  11527. followingBytes = stream.peekBytes(n);
  11528. for (i = 0; i < n; i++) {
  11529. ch = followingBytes[i];
  11530. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  11531. state = 0;
  11532. break;
  11533. }
  11534. }
  11535. if (state === 2) {
  11536. break;
  11537. }
  11538. } else {
  11539. state = 0;
  11540. }
  11541. }
  11542. }
  11543. return stream.pos - 4 - startPos;
  11544. },
  11545. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  11546. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  11547. while ((b = stream.getByte()) !== -1) {
  11548. if (b !== 0xFF) {
  11549. continue;
  11550. }
  11551. switch (stream.getByte()) {
  11552. case 0x00:
  11553. break;
  11554. case 0xFF:
  11555. stream.skip(-1);
  11556. break;
  11557. case 0xD9:
  11558. foundEOI = true;
  11559. break;
  11560. case 0xC0:
  11561. case 0xC1:
  11562. case 0xC2:
  11563. case 0xC3:
  11564. case 0xC5:
  11565. case 0xC6:
  11566. case 0xC7:
  11567. case 0xC9:
  11568. case 0xCA:
  11569. case 0xCB:
  11570. case 0xCD:
  11571. case 0xCE:
  11572. case 0xCF:
  11573. case 0xC4:
  11574. case 0xCC:
  11575. case 0xDA:
  11576. case 0xDB:
  11577. case 0xDC:
  11578. case 0xDD:
  11579. case 0xDE:
  11580. case 0xDF:
  11581. case 0xE0:
  11582. case 0xE1:
  11583. case 0xE2:
  11584. case 0xE3:
  11585. case 0xE4:
  11586. case 0xE5:
  11587. case 0xE6:
  11588. case 0xE7:
  11589. case 0xE8:
  11590. case 0xE9:
  11591. case 0xEA:
  11592. case 0xEB:
  11593. case 0xEC:
  11594. case 0xED:
  11595. case 0xEE:
  11596. case 0xEF:
  11597. case 0xFE:
  11598. markerLength = stream.getUint16();
  11599. if (markerLength > 2) {
  11600. stream.skip(markerLength - 2);
  11601. } else {
  11602. stream.skip(-2);
  11603. }
  11604. break;
  11605. }
  11606. if (foundEOI) {
  11607. break;
  11608. }
  11609. }
  11610. length = stream.pos - startPos;
  11611. if (b === -1) {
  11612. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  11613. stream.skip(-length);
  11614. return this.findDefaultInlineStreamEnd(stream);
  11615. }
  11616. this.inlineStreamSkipEI(stream);
  11617. return length;
  11618. },
  11619. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  11620. var TILDE = 0x7E, GT = 0x3E;
  11621. var startPos = stream.pos, ch, length;
  11622. while ((ch = stream.getByte()) !== -1) {
  11623. if (ch === TILDE && stream.peekByte() === GT) {
  11624. stream.skip();
  11625. break;
  11626. }
  11627. }
  11628. length = stream.pos - startPos;
  11629. if (ch === -1) {
  11630. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11631. stream.skip(-length);
  11632. return this.findDefaultInlineStreamEnd(stream);
  11633. }
  11634. this.inlineStreamSkipEI(stream);
  11635. return length;
  11636. },
  11637. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  11638. var GT = 0x3E;
  11639. var startPos = stream.pos, ch, length;
  11640. while ((ch = stream.getByte()) !== -1) {
  11641. if (ch === GT) {
  11642. break;
  11643. }
  11644. }
  11645. length = stream.pos - startPos;
  11646. if (ch === -1) {
  11647. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11648. stream.skip(-length);
  11649. return this.findDefaultInlineStreamEnd(stream);
  11650. }
  11651. this.inlineStreamSkipEI(stream);
  11652. return length;
  11653. },
  11654. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  11655. var E = 0x45, I = 0x49;
  11656. var state = 0, ch;
  11657. while ((ch = stream.getByte()) !== -1) {
  11658. if (state === 0) {
  11659. state = ch === E ? 1 : 0;
  11660. } else if (state === 1) {
  11661. state = ch === I ? 2 : 0;
  11662. } else if (state === 2) {
  11663. break;
  11664. }
  11665. }
  11666. },
  11667. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  11668. var lexer = this.lexer;
  11669. var stream = lexer.stream;
  11670. var dict = new Dict(this.xref);
  11671. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  11672. if (!isName(this.buf1)) {
  11673. error('Dictionary key must be a name object');
  11674. }
  11675. var key = this.buf1.name;
  11676. this.shift();
  11677. if (isEOF(this.buf1)) {
  11678. break;
  11679. }
  11680. dict.set(key, this.getObj(cipherTransform));
  11681. }
  11682. var filter = dict.get('Filter', 'F'), filterName;
  11683. if (isName(filter)) {
  11684. filterName = filter.name;
  11685. } else if (isArray(filter)) {
  11686. var filterZero = this.xref.fetchIfRef(filter[0]);
  11687. if (isName(filterZero)) {
  11688. filterName = filterZero.name;
  11689. }
  11690. }
  11691. var startPos = stream.pos, length, i, ii;
  11692. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  11693. length = this.findDCTDecodeInlineStreamEnd(stream);
  11694. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  11695. length = this.findASCII85DecodeInlineStreamEnd(stream);
  11696. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  11697. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  11698. } else {
  11699. length = this.findDefaultInlineStreamEnd(stream);
  11700. }
  11701. var imageStream = stream.makeSubStream(startPos, length, dict);
  11702. var adler32;
  11703. if (length < MAX_LENGTH_TO_CACHE) {
  11704. var imageBytes = imageStream.getBytes();
  11705. imageStream.reset();
  11706. var a = 1;
  11707. var b = 0;
  11708. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  11709. a += imageBytes[i] & 0xff;
  11710. b += a;
  11711. }
  11712. adler32 = b % 65521 << 16 | a % 65521;
  11713. if (this.imageCache.adler32 === adler32) {
  11714. this.buf2 = Cmd.get('EI');
  11715. this.shift();
  11716. this.imageCache[adler32].reset();
  11717. return this.imageCache[adler32];
  11718. }
  11719. }
  11720. if (cipherTransform) {
  11721. imageStream = cipherTransform.createStream(imageStream, length);
  11722. }
  11723. imageStream = this.filter(imageStream, dict, length);
  11724. imageStream.dict = dict;
  11725. if (adler32 !== undefined) {
  11726. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  11727. this.imageCache[adler32] = imageStream;
  11728. }
  11729. this.buf2 = Cmd.get('EI');
  11730. this.shift();
  11731. return imageStream;
  11732. },
  11733. makeStream: function Parser_makeStream(dict, cipherTransform) {
  11734. var lexer = this.lexer;
  11735. var stream = lexer.stream;
  11736. lexer.skipToNextLine();
  11737. var pos = stream.pos - 1;
  11738. var length = dict.get('Length');
  11739. if (!isInt(length)) {
  11740. info('Bad ' + length + ' attribute in stream');
  11741. length = 0;
  11742. }
  11743. stream.pos = pos + length;
  11744. lexer.nextChar();
  11745. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  11746. this.shift();
  11747. } else {
  11748. stream.pos = pos;
  11749. var SCAN_BLOCK_SIZE = 2048;
  11750. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  11751. var ENDSTREAM_SIGNATURE = [
  11752. 0x65,
  11753. 0x6E,
  11754. 0x64,
  11755. 0x73,
  11756. 0x74,
  11757. 0x72,
  11758. 0x65,
  11759. 0x61,
  11760. 0x6D
  11761. ];
  11762. var skipped = 0, found = false, i, j;
  11763. while (stream.pos < stream.end) {
  11764. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  11765. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  11766. if (scanLength <= 0) {
  11767. break;
  11768. }
  11769. found = false;
  11770. i = 0;
  11771. while (i < scanLength) {
  11772. j = 0;
  11773. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  11774. j++;
  11775. }
  11776. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  11777. found = true;
  11778. break;
  11779. }
  11780. i++;
  11781. }
  11782. if (found) {
  11783. skipped += i;
  11784. stream.pos += i;
  11785. break;
  11786. }
  11787. skipped += scanLength;
  11788. stream.pos += scanLength;
  11789. }
  11790. if (!found) {
  11791. error('Missing endstream');
  11792. }
  11793. length = skipped;
  11794. lexer.nextChar();
  11795. this.shift();
  11796. this.shift();
  11797. }
  11798. this.shift();
  11799. stream = stream.makeSubStream(pos, length, dict);
  11800. if (cipherTransform) {
  11801. stream = cipherTransform.createStream(stream, length);
  11802. }
  11803. stream = this.filter(stream, dict, length);
  11804. stream.dict = dict;
  11805. return stream;
  11806. },
  11807. filter: function Parser_filter(stream, dict, length) {
  11808. var filter = dict.get('Filter', 'F');
  11809. var params = dict.get('DecodeParms', 'DP');
  11810. if (isName(filter)) {
  11811. if (isArray(params)) {
  11812. params = this.xref.fetchIfRef(params[0]);
  11813. }
  11814. return this.makeFilter(stream, filter.name, length, params);
  11815. }
  11816. var maybeLength = length;
  11817. if (isArray(filter)) {
  11818. var filterArray = filter;
  11819. var paramsArray = params;
  11820. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  11821. filter = this.xref.fetchIfRef(filterArray[i]);
  11822. if (!isName(filter)) {
  11823. error('Bad filter name: ' + filter);
  11824. }
  11825. params = null;
  11826. if (isArray(paramsArray) && i in paramsArray) {
  11827. params = this.xref.fetchIfRef(paramsArray[i]);
  11828. }
  11829. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  11830. maybeLength = null;
  11831. }
  11832. }
  11833. return stream;
  11834. },
  11835. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  11836. if (maybeLength === 0) {
  11837. warn('Empty "' + name + '" stream.');
  11838. return new NullStream(stream);
  11839. }
  11840. try {
  11841. var xrefStreamStats = this.xref.stats.streamTypes;
  11842. if (name === 'FlateDecode' || name === 'Fl') {
  11843. xrefStreamStats[StreamType.FLATE] = true;
  11844. if (params) {
  11845. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  11846. }
  11847. return new FlateStream(stream, maybeLength);
  11848. }
  11849. if (name === 'LZWDecode' || name === 'LZW') {
  11850. xrefStreamStats[StreamType.LZW] = true;
  11851. var earlyChange = 1;
  11852. if (params) {
  11853. if (params.has('EarlyChange')) {
  11854. earlyChange = params.get('EarlyChange');
  11855. }
  11856. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  11857. }
  11858. return new LZWStream(stream, maybeLength, earlyChange);
  11859. }
  11860. if (name === 'DCTDecode' || name === 'DCT') {
  11861. xrefStreamStats[StreamType.DCT] = true;
  11862. return new JpegStream(stream, maybeLength, stream.dict, params);
  11863. }
  11864. if (name === 'JPXDecode' || name === 'JPX') {
  11865. xrefStreamStats[StreamType.JPX] = true;
  11866. return new JpxStream(stream, maybeLength, stream.dict, params);
  11867. }
  11868. if (name === 'ASCII85Decode' || name === 'A85') {
  11869. xrefStreamStats[StreamType.A85] = true;
  11870. return new Ascii85Stream(stream, maybeLength);
  11871. }
  11872. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  11873. xrefStreamStats[StreamType.AHX] = true;
  11874. return new AsciiHexStream(stream, maybeLength);
  11875. }
  11876. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  11877. xrefStreamStats[StreamType.CCF] = true;
  11878. return new CCITTFaxStream(stream, maybeLength, params);
  11879. }
  11880. if (name === 'RunLengthDecode' || name === 'RL') {
  11881. xrefStreamStats[StreamType.RL] = true;
  11882. return new RunLengthStream(stream, maybeLength);
  11883. }
  11884. if (name === 'JBIG2Decode') {
  11885. xrefStreamStats[StreamType.JBIG] = true;
  11886. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  11887. }
  11888. warn('filter "' + name + '" not supported yet');
  11889. return stream;
  11890. } catch (ex) {
  11891. if (ex instanceof MissingDataException) {
  11892. throw ex;
  11893. }
  11894. warn('Invalid stream: \"' + ex + '\"');
  11895. return new NullStream(stream);
  11896. }
  11897. }
  11898. };
  11899. return Parser;
  11900. }();
  11901. var Lexer = function LexerClosure() {
  11902. function Lexer(stream, knownCommands) {
  11903. this.stream = stream;
  11904. this.nextChar();
  11905. this.strBuf = [];
  11906. this.knownCommands = knownCommands;
  11907. }
  11908. var specialChars = [
  11909. 1,
  11910. 0,
  11911. 0,
  11912. 0,
  11913. 0,
  11914. 0,
  11915. 0,
  11916. 0,
  11917. 0,
  11918. 1,
  11919. 1,
  11920. 0,
  11921. 1,
  11922. 1,
  11923. 0,
  11924. 0,
  11925. 0,
  11926. 0,
  11927. 0,
  11928. 0,
  11929. 0,
  11930. 0,
  11931. 0,
  11932. 0,
  11933. 0,
  11934. 0,
  11935. 0,
  11936. 0,
  11937. 0,
  11938. 0,
  11939. 0,
  11940. 0,
  11941. 1,
  11942. 0,
  11943. 0,
  11944. 0,
  11945. 0,
  11946. 2,
  11947. 0,
  11948. 0,
  11949. 2,
  11950. 2,
  11951. 0,
  11952. 0,
  11953. 0,
  11954. 0,
  11955. 0,
  11956. 2,
  11957. 0,
  11958. 0,
  11959. 0,
  11960. 0,
  11961. 0,
  11962. 0,
  11963. 0,
  11964. 0,
  11965. 0,
  11966. 0,
  11967. 0,
  11968. 0,
  11969. 2,
  11970. 0,
  11971. 2,
  11972. 0,
  11973. 0,
  11974. 0,
  11975. 0,
  11976. 0,
  11977. 0,
  11978. 0,
  11979. 0,
  11980. 0,
  11981. 0,
  11982. 0,
  11983. 0,
  11984. 0,
  11985. 0,
  11986. 0,
  11987. 0,
  11988. 0,
  11989. 0,
  11990. 0,
  11991. 0,
  11992. 0,
  11993. 0,
  11994. 0,
  11995. 0,
  11996. 0,
  11997. 0,
  11998. 0,
  11999. 0,
  12000. 2,
  12001. 0,
  12002. 2,
  12003. 0,
  12004. 0,
  12005. 0,
  12006. 0,
  12007. 0,
  12008. 0,
  12009. 0,
  12010. 0,
  12011. 0,
  12012. 0,
  12013. 0,
  12014. 0,
  12015. 0,
  12016. 0,
  12017. 0,
  12018. 0,
  12019. 0,
  12020. 0,
  12021. 0,
  12022. 0,
  12023. 0,
  12024. 0,
  12025. 0,
  12026. 0,
  12027. 0,
  12028. 0,
  12029. 0,
  12030. 0,
  12031. 0,
  12032. 2,
  12033. 0,
  12034. 2,
  12035. 0,
  12036. 0,
  12037. 0,
  12038. 0,
  12039. 0,
  12040. 0,
  12041. 0,
  12042. 0,
  12043. 0,
  12044. 0,
  12045. 0,
  12046. 0,
  12047. 0,
  12048. 0,
  12049. 0,
  12050. 0,
  12051. 0,
  12052. 0,
  12053. 0,
  12054. 0,
  12055. 0,
  12056. 0,
  12057. 0,
  12058. 0,
  12059. 0,
  12060. 0,
  12061. 0,
  12062. 0,
  12063. 0,
  12064. 0,
  12065. 0,
  12066. 0,
  12067. 0,
  12068. 0,
  12069. 0,
  12070. 0,
  12071. 0,
  12072. 0,
  12073. 0,
  12074. 0,
  12075. 0,
  12076. 0,
  12077. 0,
  12078. 0,
  12079. 0,
  12080. 0,
  12081. 0,
  12082. 0,
  12083. 0,
  12084. 0,
  12085. 0,
  12086. 0,
  12087. 0,
  12088. 0,
  12089. 0,
  12090. 0,
  12091. 0,
  12092. 0,
  12093. 0,
  12094. 0,
  12095. 0,
  12096. 0,
  12097. 0,
  12098. 0,
  12099. 0,
  12100. 0,
  12101. 0,
  12102. 0,
  12103. 0,
  12104. 0,
  12105. 0,
  12106. 0,
  12107. 0,
  12108. 0,
  12109. 0,
  12110. 0,
  12111. 0,
  12112. 0,
  12113. 0,
  12114. 0,
  12115. 0,
  12116. 0,
  12117. 0,
  12118. 0,
  12119. 0,
  12120. 0,
  12121. 0,
  12122. 0,
  12123. 0,
  12124. 0,
  12125. 0,
  12126. 0,
  12127. 0,
  12128. 0,
  12129. 0,
  12130. 0,
  12131. 0,
  12132. 0,
  12133. 0,
  12134. 0,
  12135. 0,
  12136. 0,
  12137. 0,
  12138. 0,
  12139. 0,
  12140. 0,
  12141. 0,
  12142. 0,
  12143. 0,
  12144. 0,
  12145. 0,
  12146. 0,
  12147. 0,
  12148. 0,
  12149. 0,
  12150. 0,
  12151. 0,
  12152. 0,
  12153. 0,
  12154. 0,
  12155. 0,
  12156. 0,
  12157. 0,
  12158. 0,
  12159. 0,
  12160. 0,
  12161. 0,
  12162. 0,
  12163. 0,
  12164. 0
  12165. ];
  12166. function toHexDigit(ch) {
  12167. if (ch >= 0x30 && ch <= 0x39) {
  12168. return ch & 0x0F;
  12169. }
  12170. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12171. return (ch & 0x0F) + 9;
  12172. }
  12173. return -1;
  12174. }
  12175. Lexer.prototype = {
  12176. nextChar: function Lexer_nextChar() {
  12177. return this.currentChar = this.stream.getByte();
  12178. },
  12179. peekChar: function Lexer_peekChar() {
  12180. return this.stream.peekByte();
  12181. },
  12182. getNumber: function Lexer_getNumber() {
  12183. var ch = this.currentChar;
  12184. var eNotation = false;
  12185. var divideBy = 0;
  12186. var sign = 1;
  12187. if (ch === 0x2D) {
  12188. sign = -1;
  12189. ch = this.nextChar();
  12190. if (ch === 0x2D) {
  12191. ch = this.nextChar();
  12192. }
  12193. } else if (ch === 0x2B) {
  12194. ch = this.nextChar();
  12195. }
  12196. if (ch === 0x2E) {
  12197. divideBy = 10;
  12198. ch = this.nextChar();
  12199. }
  12200. if (ch < 0x30 || ch > 0x39) {
  12201. error('Invalid number: ' + String.fromCharCode(ch));
  12202. return 0;
  12203. }
  12204. var baseValue = ch - 0x30;
  12205. var powerValue = 0;
  12206. var powerValueSign = 1;
  12207. while ((ch = this.nextChar()) >= 0) {
  12208. if (0x30 <= ch && ch <= 0x39) {
  12209. var currentDigit = ch - 0x30;
  12210. if (eNotation) {
  12211. powerValue = powerValue * 10 + currentDigit;
  12212. } else {
  12213. if (divideBy !== 0) {
  12214. divideBy *= 10;
  12215. }
  12216. baseValue = baseValue * 10 + currentDigit;
  12217. }
  12218. } else if (ch === 0x2E) {
  12219. if (divideBy === 0) {
  12220. divideBy = 1;
  12221. } else {
  12222. break;
  12223. }
  12224. } else if (ch === 0x2D) {
  12225. warn('Badly formatted number');
  12226. } else if (ch === 0x45 || ch === 0x65) {
  12227. ch = this.peekChar();
  12228. if (ch === 0x2B || ch === 0x2D) {
  12229. powerValueSign = ch === 0x2D ? -1 : 1;
  12230. this.nextChar();
  12231. } else if (ch < 0x30 || ch > 0x39) {
  12232. break;
  12233. }
  12234. eNotation = true;
  12235. } else {
  12236. break;
  12237. }
  12238. }
  12239. if (divideBy !== 0) {
  12240. baseValue /= divideBy;
  12241. }
  12242. if (eNotation) {
  12243. baseValue *= Math.pow(10, powerValueSign * powerValue);
  12244. }
  12245. return sign * baseValue;
  12246. },
  12247. getString: function Lexer_getString() {
  12248. var numParen = 1;
  12249. var done = false;
  12250. var strBuf = this.strBuf;
  12251. strBuf.length = 0;
  12252. var ch = this.nextChar();
  12253. while (true) {
  12254. var charBuffered = false;
  12255. switch (ch | 0) {
  12256. case -1:
  12257. warn('Unterminated string');
  12258. done = true;
  12259. break;
  12260. case 0x28:
  12261. ++numParen;
  12262. strBuf.push('(');
  12263. break;
  12264. case 0x29:
  12265. if (--numParen === 0) {
  12266. this.nextChar();
  12267. done = true;
  12268. } else {
  12269. strBuf.push(')');
  12270. }
  12271. break;
  12272. case 0x5C:
  12273. ch = this.nextChar();
  12274. switch (ch) {
  12275. case -1:
  12276. warn('Unterminated string');
  12277. done = true;
  12278. break;
  12279. case 0x6E:
  12280. strBuf.push('\n');
  12281. break;
  12282. case 0x72:
  12283. strBuf.push('\r');
  12284. break;
  12285. case 0x74:
  12286. strBuf.push('\t');
  12287. break;
  12288. case 0x62:
  12289. strBuf.push('\b');
  12290. break;
  12291. case 0x66:
  12292. strBuf.push('\f');
  12293. break;
  12294. case 0x5C:
  12295. case 0x28:
  12296. case 0x29:
  12297. strBuf.push(String.fromCharCode(ch));
  12298. break;
  12299. case 0x30:
  12300. case 0x31:
  12301. case 0x32:
  12302. case 0x33:
  12303. case 0x34:
  12304. case 0x35:
  12305. case 0x36:
  12306. case 0x37:
  12307. var x = ch & 0x0F;
  12308. ch = this.nextChar();
  12309. charBuffered = true;
  12310. if (ch >= 0x30 && ch <= 0x37) {
  12311. x = (x << 3) + (ch & 0x0F);
  12312. ch = this.nextChar();
  12313. if (ch >= 0x30 && ch <= 0x37) {
  12314. charBuffered = false;
  12315. x = (x << 3) + (ch & 0x0F);
  12316. }
  12317. }
  12318. strBuf.push(String.fromCharCode(x));
  12319. break;
  12320. case 0x0D:
  12321. if (this.peekChar() === 0x0A) {
  12322. this.nextChar();
  12323. }
  12324. break;
  12325. case 0x0A:
  12326. break;
  12327. default:
  12328. strBuf.push(String.fromCharCode(ch));
  12329. break;
  12330. }
  12331. break;
  12332. default:
  12333. strBuf.push(String.fromCharCode(ch));
  12334. break;
  12335. }
  12336. if (done) {
  12337. break;
  12338. }
  12339. if (!charBuffered) {
  12340. ch = this.nextChar();
  12341. }
  12342. }
  12343. return strBuf.join('');
  12344. },
  12345. getName: function Lexer_getName() {
  12346. var ch, previousCh;
  12347. var strBuf = this.strBuf;
  12348. strBuf.length = 0;
  12349. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12350. if (ch === 0x23) {
  12351. ch = this.nextChar();
  12352. if (specialChars[ch]) {
  12353. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  12354. strBuf.push('#');
  12355. break;
  12356. }
  12357. var x = toHexDigit(ch);
  12358. if (x !== -1) {
  12359. previousCh = ch;
  12360. ch = this.nextChar();
  12361. var x2 = toHexDigit(ch);
  12362. if (x2 === -1) {
  12363. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  12364. strBuf.push('#', String.fromCharCode(previousCh));
  12365. if (specialChars[ch]) {
  12366. break;
  12367. }
  12368. strBuf.push(String.fromCharCode(ch));
  12369. continue;
  12370. }
  12371. strBuf.push(String.fromCharCode(x << 4 | x2));
  12372. } else {
  12373. strBuf.push('#', String.fromCharCode(ch));
  12374. }
  12375. } else {
  12376. strBuf.push(String.fromCharCode(ch));
  12377. }
  12378. }
  12379. if (strBuf.length > 127) {
  12380. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  12381. }
  12382. return Name.get(strBuf.join(''));
  12383. },
  12384. getHexString: function Lexer_getHexString() {
  12385. var strBuf = this.strBuf;
  12386. strBuf.length = 0;
  12387. var ch = this.currentChar;
  12388. var isFirstHex = true;
  12389. var firstDigit;
  12390. var secondDigit;
  12391. while (true) {
  12392. if (ch < 0) {
  12393. warn('Unterminated hex string');
  12394. break;
  12395. } else if (ch === 0x3E) {
  12396. this.nextChar();
  12397. break;
  12398. } else if (specialChars[ch] === 1) {
  12399. ch = this.nextChar();
  12400. continue;
  12401. } else {
  12402. if (isFirstHex) {
  12403. firstDigit = toHexDigit(ch);
  12404. if (firstDigit === -1) {
  12405. warn('Ignoring invalid character "' + ch + '" in hex string');
  12406. ch = this.nextChar();
  12407. continue;
  12408. }
  12409. } else {
  12410. secondDigit = toHexDigit(ch);
  12411. if (secondDigit === -1) {
  12412. warn('Ignoring invalid character "' + ch + '" in hex string');
  12413. ch = this.nextChar();
  12414. continue;
  12415. }
  12416. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  12417. }
  12418. isFirstHex = !isFirstHex;
  12419. ch = this.nextChar();
  12420. }
  12421. }
  12422. return strBuf.join('');
  12423. },
  12424. getObj: function Lexer_getObj() {
  12425. var comment = false;
  12426. var ch = this.currentChar;
  12427. while (true) {
  12428. if (ch < 0) {
  12429. return EOF;
  12430. }
  12431. if (comment) {
  12432. if (ch === 0x0A || ch === 0x0D) {
  12433. comment = false;
  12434. }
  12435. } else if (ch === 0x25) {
  12436. comment = true;
  12437. } else if (specialChars[ch] !== 1) {
  12438. break;
  12439. }
  12440. ch = this.nextChar();
  12441. }
  12442. switch (ch | 0) {
  12443. case 0x30:
  12444. case 0x31:
  12445. case 0x32:
  12446. case 0x33:
  12447. case 0x34:
  12448. case 0x35:
  12449. case 0x36:
  12450. case 0x37:
  12451. case 0x38:
  12452. case 0x39:
  12453. case 0x2B:
  12454. case 0x2D:
  12455. case 0x2E:
  12456. return this.getNumber();
  12457. case 0x28:
  12458. return this.getString();
  12459. case 0x2F:
  12460. return this.getName();
  12461. case 0x5B:
  12462. this.nextChar();
  12463. return Cmd.get('[');
  12464. case 0x5D:
  12465. this.nextChar();
  12466. return Cmd.get(']');
  12467. case 0x3C:
  12468. ch = this.nextChar();
  12469. if (ch === 0x3C) {
  12470. this.nextChar();
  12471. return Cmd.get('<<');
  12472. }
  12473. return this.getHexString();
  12474. case 0x3E:
  12475. ch = this.nextChar();
  12476. if (ch === 0x3E) {
  12477. this.nextChar();
  12478. return Cmd.get('>>');
  12479. }
  12480. return Cmd.get('>');
  12481. case 0x7B:
  12482. this.nextChar();
  12483. return Cmd.get('{');
  12484. case 0x7D:
  12485. this.nextChar();
  12486. return Cmd.get('}');
  12487. case 0x29:
  12488. this.nextChar();
  12489. error('Illegal character: ' + ch);
  12490. break;
  12491. }
  12492. var str = String.fromCharCode(ch);
  12493. var knownCommands = this.knownCommands;
  12494. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12495. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12496. var possibleCommand = str + String.fromCharCode(ch);
  12497. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  12498. break;
  12499. }
  12500. if (str.length === 128) {
  12501. error('Command token too long: ' + str.length);
  12502. }
  12503. str = possibleCommand;
  12504. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12505. }
  12506. if (str === 'true') {
  12507. return true;
  12508. }
  12509. if (str === 'false') {
  12510. return false;
  12511. }
  12512. if (str === 'null') {
  12513. return null;
  12514. }
  12515. return Cmd.get(str);
  12516. },
  12517. skipToNextLine: function Lexer_skipToNextLine() {
  12518. var ch = this.currentChar;
  12519. while (ch >= 0) {
  12520. if (ch === 0x0D) {
  12521. ch = this.nextChar();
  12522. if (ch === 0x0A) {
  12523. this.nextChar();
  12524. }
  12525. break;
  12526. } else if (ch === 0x0A) {
  12527. this.nextChar();
  12528. break;
  12529. }
  12530. ch = this.nextChar();
  12531. }
  12532. }
  12533. };
  12534. return Lexer;
  12535. }();
  12536. var Linearization = {
  12537. create: function LinearizationCreate(stream) {
  12538. function getInt(name, allowZeroValue) {
  12539. var obj = linDict.get(name);
  12540. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  12541. return obj;
  12542. }
  12543. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  12544. }
  12545. function getHints() {
  12546. var hints = linDict.get('H'), hintsLength, item;
  12547. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  12548. for (var index = 0; index < hintsLength; index++) {
  12549. if (!(isInt(item = hints[index]) && item > 0)) {
  12550. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  12551. }
  12552. }
  12553. return hints;
  12554. }
  12555. throw new Error('Hint array in the linearization dictionary is invalid.');
  12556. }
  12557. var parser = new Parser(new Lexer(stream), false, null);
  12558. var obj1 = parser.getObj();
  12559. var obj2 = parser.getObj();
  12560. var obj3 = parser.getObj();
  12561. var linDict = parser.getObj();
  12562. var obj, length;
  12563. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  12564. return null;
  12565. } else if ((length = getInt('L')) !== stream.length) {
  12566. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  12567. }
  12568. return {
  12569. length: length,
  12570. hints: getHints(),
  12571. objectNumberFirst: getInt('O'),
  12572. endFirst: getInt('E'),
  12573. numPages: getInt('N'),
  12574. mainXRefEntriesOffset: getInt('T'),
  12575. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  12576. };
  12577. }
  12578. };
  12579. exports.Lexer = Lexer;
  12580. exports.Linearization = Linearization;
  12581. exports.Parser = Parser;
  12582. /***/ }),
  12583. /* 7 */
  12584. /***/ (function(module, exports, __w_pdfjs_require__) {
  12585. "use strict";
  12586. var sharedUtil = __w_pdfjs_require__(0);
  12587. var corePrimitives = __w_pdfjs_require__(1);
  12588. var corePsParser = __w_pdfjs_require__(42);
  12589. var error = sharedUtil.error;
  12590. var info = sharedUtil.info;
  12591. var isArray = sharedUtil.isArray;
  12592. var isBool = sharedUtil.isBool;
  12593. var isDict = corePrimitives.isDict;
  12594. var isStream = corePrimitives.isStream;
  12595. var PostScriptLexer = corePsParser.PostScriptLexer;
  12596. var PostScriptParser = corePsParser.PostScriptParser;
  12597. var PDFFunction = function PDFFunctionClosure() {
  12598. var CONSTRUCT_SAMPLED = 0;
  12599. var CONSTRUCT_INTERPOLATED = 2;
  12600. var CONSTRUCT_STICHED = 3;
  12601. var CONSTRUCT_POSTSCRIPT = 4;
  12602. return {
  12603. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  12604. var i, ii;
  12605. var length = 1;
  12606. for (i = 0, ii = size.length; i < ii; i++) {
  12607. length *= size[i];
  12608. }
  12609. length *= outputSize;
  12610. var array = new Array(length);
  12611. var codeSize = 0;
  12612. var codeBuf = 0;
  12613. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  12614. var strBytes = str.getBytes((length * bps + 7) / 8);
  12615. var strIdx = 0;
  12616. for (i = 0; i < length; i++) {
  12617. while (codeSize < bps) {
  12618. codeBuf <<= 8;
  12619. codeBuf |= strBytes[strIdx++];
  12620. codeSize += 8;
  12621. }
  12622. codeSize -= bps;
  12623. array[i] = (codeBuf >> codeSize) * sampleMul;
  12624. codeBuf &= (1 << codeSize) - 1;
  12625. }
  12626. return array;
  12627. },
  12628. getIR: function PDFFunction_getIR(xref, fn) {
  12629. var dict = fn.dict;
  12630. if (!dict) {
  12631. dict = fn;
  12632. }
  12633. var types = [
  12634. this.constructSampled,
  12635. null,
  12636. this.constructInterpolated,
  12637. this.constructStiched,
  12638. this.constructPostScript
  12639. ];
  12640. var typeNum = dict.get('FunctionType');
  12641. var typeFn = types[typeNum];
  12642. if (!typeFn) {
  12643. error('Unknown type of function');
  12644. }
  12645. return typeFn.call(this, fn, dict, xref);
  12646. },
  12647. fromIR: function PDFFunction_fromIR(IR) {
  12648. var type = IR[0];
  12649. switch (type) {
  12650. case CONSTRUCT_SAMPLED:
  12651. return this.constructSampledFromIR(IR);
  12652. case CONSTRUCT_INTERPOLATED:
  12653. return this.constructInterpolatedFromIR(IR);
  12654. case CONSTRUCT_STICHED:
  12655. return this.constructStichedFromIR(IR);
  12656. default:
  12657. return this.constructPostScriptFromIR(IR);
  12658. }
  12659. },
  12660. parse: function PDFFunction_parse(xref, fn) {
  12661. var IR = this.getIR(xref, fn);
  12662. return this.fromIR(IR);
  12663. },
  12664. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  12665. if (!isArray(fnObj)) {
  12666. return this.parse(xref, fnObj);
  12667. }
  12668. var fnArray = [];
  12669. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  12670. var obj = xref.fetchIfRef(fnObj[j]);
  12671. fnArray.push(PDFFunction.parse(xref, obj));
  12672. }
  12673. return function (src, srcOffset, dest, destOffset) {
  12674. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  12675. fnArray[i](src, srcOffset, dest, destOffset + i);
  12676. }
  12677. };
  12678. },
  12679. constructSampled: function PDFFunction_constructSampled(str, dict) {
  12680. function toMultiArray(arr) {
  12681. var inputLength = arr.length;
  12682. var out = [];
  12683. var index = 0;
  12684. for (var i = 0; i < inputLength; i += 2) {
  12685. out[index] = [
  12686. arr[i],
  12687. arr[i + 1]
  12688. ];
  12689. ++index;
  12690. }
  12691. return out;
  12692. }
  12693. var domain = dict.getArray('Domain');
  12694. var range = dict.getArray('Range');
  12695. if (!domain || !range) {
  12696. error('No domain or range');
  12697. }
  12698. var inputSize = domain.length / 2;
  12699. var outputSize = range.length / 2;
  12700. domain = toMultiArray(domain);
  12701. range = toMultiArray(range);
  12702. var size = dict.get('Size');
  12703. var bps = dict.get('BitsPerSample');
  12704. var order = dict.get('Order') || 1;
  12705. if (order !== 1) {
  12706. info('No support for cubic spline interpolation: ' + order);
  12707. }
  12708. var encode = dict.getArray('Encode');
  12709. if (!encode) {
  12710. encode = [];
  12711. for (var i = 0; i < inputSize; ++i) {
  12712. encode.push(0);
  12713. encode.push(size[i] - 1);
  12714. }
  12715. }
  12716. encode = toMultiArray(encode);
  12717. var decode = dict.getArray('Decode');
  12718. if (!decode) {
  12719. decode = range;
  12720. } else {
  12721. decode = toMultiArray(decode);
  12722. }
  12723. var samples = this.getSampleArray(size, outputSize, bps, str);
  12724. return [
  12725. CONSTRUCT_SAMPLED,
  12726. inputSize,
  12727. domain,
  12728. encode,
  12729. decode,
  12730. samples,
  12731. size,
  12732. outputSize,
  12733. Math.pow(2, bps) - 1,
  12734. range
  12735. ];
  12736. },
  12737. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  12738. function interpolate(x, xmin, xmax, ymin, ymax) {
  12739. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  12740. }
  12741. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  12742. var m = IR[1];
  12743. var domain = IR[2];
  12744. var encode = IR[3];
  12745. var decode = IR[4];
  12746. var samples = IR[5];
  12747. var size = IR[6];
  12748. var n = IR[7];
  12749. var range = IR[9];
  12750. var cubeVertices = 1 << m;
  12751. var cubeN = new Float64Array(cubeVertices);
  12752. var cubeVertex = new Uint32Array(cubeVertices);
  12753. var i, j;
  12754. for (j = 0; j < cubeVertices; j++) {
  12755. cubeN[j] = 1;
  12756. }
  12757. var k = n, pos = 1;
  12758. for (i = 0; i < m; ++i) {
  12759. var domain_2i = domain[i][0];
  12760. var domain_2i_1 = domain[i][1];
  12761. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  12762. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  12763. var size_i = size[i];
  12764. e = Math.min(Math.max(e, 0), size_i - 1);
  12765. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  12766. var n0 = e0 + 1 - e;
  12767. var n1 = e - e0;
  12768. var offset0 = e0 * k;
  12769. var offset1 = offset0 + k;
  12770. for (j = 0; j < cubeVertices; j++) {
  12771. if (j & pos) {
  12772. cubeN[j] *= n1;
  12773. cubeVertex[j] += offset1;
  12774. } else {
  12775. cubeN[j] *= n0;
  12776. cubeVertex[j] += offset0;
  12777. }
  12778. }
  12779. k *= size_i;
  12780. pos <<= 1;
  12781. }
  12782. for (j = 0; j < n; ++j) {
  12783. var rj = 0;
  12784. for (i = 0; i < cubeVertices; i++) {
  12785. rj += samples[cubeVertex[i] + j] * cubeN[i];
  12786. }
  12787. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  12788. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  12789. }
  12790. };
  12791. },
  12792. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  12793. var c0 = dict.getArray('C0') || [0];
  12794. var c1 = dict.getArray('C1') || [1];
  12795. var n = dict.get('N');
  12796. if (!isArray(c0) || !isArray(c1)) {
  12797. error('Illegal dictionary for interpolated function');
  12798. }
  12799. var length = c0.length;
  12800. var diff = [];
  12801. for (var i = 0; i < length; ++i) {
  12802. diff.push(c1[i] - c0[i]);
  12803. }
  12804. return [
  12805. CONSTRUCT_INTERPOLATED,
  12806. c0,
  12807. diff,
  12808. n
  12809. ];
  12810. },
  12811. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  12812. var c0 = IR[1];
  12813. var diff = IR[2];
  12814. var n = IR[3];
  12815. var length = diff.length;
  12816. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  12817. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  12818. for (var j = 0; j < length; ++j) {
  12819. dest[destOffset + j] = c0[j] + x * diff[j];
  12820. }
  12821. };
  12822. },
  12823. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  12824. var domain = dict.getArray('Domain');
  12825. if (!domain) {
  12826. error('No domain');
  12827. }
  12828. var inputSize = domain.length / 2;
  12829. if (inputSize !== 1) {
  12830. error('Bad domain for stiched function');
  12831. }
  12832. var fnRefs = dict.get('Functions');
  12833. var fns = [];
  12834. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  12835. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  12836. }
  12837. var bounds = dict.getArray('Bounds');
  12838. var encode = dict.getArray('Encode');
  12839. return [
  12840. CONSTRUCT_STICHED,
  12841. domain,
  12842. bounds,
  12843. encode,
  12844. fns
  12845. ];
  12846. },
  12847. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  12848. var domain = IR[1];
  12849. var bounds = IR[2];
  12850. var encode = IR[3];
  12851. var fnsIR = IR[4];
  12852. var fns = [];
  12853. var tmpBuf = new Float32Array(1);
  12854. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  12855. fns.push(PDFFunction.fromIR(fnsIR[i]));
  12856. }
  12857. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  12858. var clip = function constructStichedFromIRClip(v, min, max) {
  12859. if (v > max) {
  12860. v = max;
  12861. } else if (v < min) {
  12862. v = min;
  12863. }
  12864. return v;
  12865. };
  12866. var v = clip(src[srcOffset], domain[0], domain[1]);
  12867. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  12868. if (v < bounds[i]) {
  12869. break;
  12870. }
  12871. }
  12872. var dmin = domain[0];
  12873. if (i > 0) {
  12874. dmin = bounds[i - 1];
  12875. }
  12876. var dmax = domain[1];
  12877. if (i < bounds.length) {
  12878. dmax = bounds[i];
  12879. }
  12880. var rmin = encode[2 * i];
  12881. var rmax = encode[2 * i + 1];
  12882. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  12883. fns[i](tmpBuf, 0, dest, destOffset);
  12884. };
  12885. },
  12886. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  12887. var domain = dict.getArray('Domain');
  12888. var range = dict.getArray('Range');
  12889. if (!domain) {
  12890. error('No domain.');
  12891. }
  12892. if (!range) {
  12893. error('No range.');
  12894. }
  12895. var lexer = new PostScriptLexer(fn);
  12896. var parser = new PostScriptParser(lexer);
  12897. var code = parser.parse();
  12898. return [
  12899. CONSTRUCT_POSTSCRIPT,
  12900. domain,
  12901. range,
  12902. code
  12903. ];
  12904. },
  12905. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  12906. var domain = IR[1];
  12907. var range = IR[2];
  12908. var code = IR[3];
  12909. var compiled = new PostScriptCompiler().compile(code, domain, range);
  12910. if (compiled) {
  12911. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  12912. }
  12913. info('Unable to compile PS function');
  12914. var numOutputs = range.length >> 1;
  12915. var numInputs = domain.length >> 1;
  12916. var evaluator = new PostScriptEvaluator(code);
  12917. var cache = Object.create(null);
  12918. var MAX_CACHE_SIZE = 2048 * 4;
  12919. var cache_available = MAX_CACHE_SIZE;
  12920. var tmpBuf = new Float32Array(numInputs);
  12921. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  12922. var i, value;
  12923. var key = '';
  12924. var input = tmpBuf;
  12925. for (i = 0; i < numInputs; i++) {
  12926. value = src[srcOffset + i];
  12927. input[i] = value;
  12928. key += value + '_';
  12929. }
  12930. var cachedValue = cache[key];
  12931. if (cachedValue !== undefined) {
  12932. dest.set(cachedValue, destOffset);
  12933. return;
  12934. }
  12935. var output = new Float32Array(numOutputs);
  12936. var stack = evaluator.execute(input);
  12937. var stackIndex = stack.length - numOutputs;
  12938. for (i = 0; i < numOutputs; i++) {
  12939. value = stack[stackIndex + i];
  12940. var bound = range[i * 2];
  12941. if (value < bound) {
  12942. value = bound;
  12943. } else {
  12944. bound = range[i * 2 + 1];
  12945. if (value > bound) {
  12946. value = bound;
  12947. }
  12948. }
  12949. output[i] = value;
  12950. }
  12951. if (cache_available > 0) {
  12952. cache_available--;
  12953. cache[key] = output;
  12954. }
  12955. dest.set(output, destOffset);
  12956. };
  12957. }
  12958. };
  12959. }();
  12960. function isPDFFunction(v) {
  12961. var fnDict;
  12962. if (typeof v !== 'object') {
  12963. return false;
  12964. } else if (isDict(v)) {
  12965. fnDict = v;
  12966. } else if (isStream(v)) {
  12967. fnDict = v.dict;
  12968. } else {
  12969. return false;
  12970. }
  12971. return fnDict.has('FunctionType');
  12972. }
  12973. var PostScriptStack = function PostScriptStackClosure() {
  12974. var MAX_STACK_SIZE = 100;
  12975. function PostScriptStack(initialStack) {
  12976. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  12977. }
  12978. PostScriptStack.prototype = {
  12979. push: function PostScriptStack_push(value) {
  12980. if (this.stack.length >= MAX_STACK_SIZE) {
  12981. error('PostScript function stack overflow.');
  12982. }
  12983. this.stack.push(value);
  12984. },
  12985. pop: function PostScriptStack_pop() {
  12986. if (this.stack.length <= 0) {
  12987. error('PostScript function stack underflow.');
  12988. }
  12989. return this.stack.pop();
  12990. },
  12991. copy: function PostScriptStack_copy(n) {
  12992. if (this.stack.length + n >= MAX_STACK_SIZE) {
  12993. error('PostScript function stack overflow.');
  12994. }
  12995. var stack = this.stack;
  12996. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  12997. stack.push(stack[i]);
  12998. }
  12999. },
  13000. index: function PostScriptStack_index(n) {
  13001. this.push(this.stack[this.stack.length - n - 1]);
  13002. },
  13003. roll: function PostScriptStack_roll(n, p) {
  13004. var stack = this.stack;
  13005. var l = stack.length - n;
  13006. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13007. for (i = l, j = r; i < j; i++, j--) {
  13008. t = stack[i];
  13009. stack[i] = stack[j];
  13010. stack[j] = t;
  13011. }
  13012. for (i = l, j = c - 1; i < j; i++, j--) {
  13013. t = stack[i];
  13014. stack[i] = stack[j];
  13015. stack[j] = t;
  13016. }
  13017. for (i = c, j = r; i < j; i++, j--) {
  13018. t = stack[i];
  13019. stack[i] = stack[j];
  13020. stack[j] = t;
  13021. }
  13022. }
  13023. };
  13024. return PostScriptStack;
  13025. }();
  13026. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13027. function PostScriptEvaluator(operators) {
  13028. this.operators = operators;
  13029. }
  13030. PostScriptEvaluator.prototype = {
  13031. execute: function PostScriptEvaluator_execute(initialStack) {
  13032. var stack = new PostScriptStack(initialStack);
  13033. var counter = 0;
  13034. var operators = this.operators;
  13035. var length = operators.length;
  13036. var operator, a, b;
  13037. while (counter < length) {
  13038. operator = operators[counter++];
  13039. if (typeof operator === 'number') {
  13040. stack.push(operator);
  13041. continue;
  13042. }
  13043. switch (operator) {
  13044. case 'jz':
  13045. b = stack.pop();
  13046. a = stack.pop();
  13047. if (!a) {
  13048. counter = b;
  13049. }
  13050. break;
  13051. case 'j':
  13052. a = stack.pop();
  13053. counter = a;
  13054. break;
  13055. case 'abs':
  13056. a = stack.pop();
  13057. stack.push(Math.abs(a));
  13058. break;
  13059. case 'add':
  13060. b = stack.pop();
  13061. a = stack.pop();
  13062. stack.push(a + b);
  13063. break;
  13064. case 'and':
  13065. b = stack.pop();
  13066. a = stack.pop();
  13067. if (isBool(a) && isBool(b)) {
  13068. stack.push(a && b);
  13069. } else {
  13070. stack.push(a & b);
  13071. }
  13072. break;
  13073. case 'atan':
  13074. a = stack.pop();
  13075. stack.push(Math.atan(a));
  13076. break;
  13077. case 'bitshift':
  13078. b = stack.pop();
  13079. a = stack.pop();
  13080. if (a > 0) {
  13081. stack.push(a << b);
  13082. } else {
  13083. stack.push(a >> b);
  13084. }
  13085. break;
  13086. case 'ceiling':
  13087. a = stack.pop();
  13088. stack.push(Math.ceil(a));
  13089. break;
  13090. case 'copy':
  13091. a = stack.pop();
  13092. stack.copy(a);
  13093. break;
  13094. case 'cos':
  13095. a = stack.pop();
  13096. stack.push(Math.cos(a));
  13097. break;
  13098. case 'cvi':
  13099. a = stack.pop() | 0;
  13100. stack.push(a);
  13101. break;
  13102. case 'cvr':
  13103. break;
  13104. case 'div':
  13105. b = stack.pop();
  13106. a = stack.pop();
  13107. stack.push(a / b);
  13108. break;
  13109. case 'dup':
  13110. stack.copy(1);
  13111. break;
  13112. case 'eq':
  13113. b = stack.pop();
  13114. a = stack.pop();
  13115. stack.push(a === b);
  13116. break;
  13117. case 'exch':
  13118. stack.roll(2, 1);
  13119. break;
  13120. case 'exp':
  13121. b = stack.pop();
  13122. a = stack.pop();
  13123. stack.push(Math.pow(a, b));
  13124. break;
  13125. case 'false':
  13126. stack.push(false);
  13127. break;
  13128. case 'floor':
  13129. a = stack.pop();
  13130. stack.push(Math.floor(a));
  13131. break;
  13132. case 'ge':
  13133. b = stack.pop();
  13134. a = stack.pop();
  13135. stack.push(a >= b);
  13136. break;
  13137. case 'gt':
  13138. b = stack.pop();
  13139. a = stack.pop();
  13140. stack.push(a > b);
  13141. break;
  13142. case 'idiv':
  13143. b = stack.pop();
  13144. a = stack.pop();
  13145. stack.push(a / b | 0);
  13146. break;
  13147. case 'index':
  13148. a = stack.pop();
  13149. stack.index(a);
  13150. break;
  13151. case 'le':
  13152. b = stack.pop();
  13153. a = stack.pop();
  13154. stack.push(a <= b);
  13155. break;
  13156. case 'ln':
  13157. a = stack.pop();
  13158. stack.push(Math.log(a));
  13159. break;
  13160. case 'log':
  13161. a = stack.pop();
  13162. stack.push(Math.log(a) / Math.LN10);
  13163. break;
  13164. case 'lt':
  13165. b = stack.pop();
  13166. a = stack.pop();
  13167. stack.push(a < b);
  13168. break;
  13169. case 'mod':
  13170. b = stack.pop();
  13171. a = stack.pop();
  13172. stack.push(a % b);
  13173. break;
  13174. case 'mul':
  13175. b = stack.pop();
  13176. a = stack.pop();
  13177. stack.push(a * b);
  13178. break;
  13179. case 'ne':
  13180. b = stack.pop();
  13181. a = stack.pop();
  13182. stack.push(a !== b);
  13183. break;
  13184. case 'neg':
  13185. a = stack.pop();
  13186. stack.push(-a);
  13187. break;
  13188. case 'not':
  13189. a = stack.pop();
  13190. if (isBool(a)) {
  13191. stack.push(!a);
  13192. } else {
  13193. stack.push(~a);
  13194. }
  13195. break;
  13196. case 'or':
  13197. b = stack.pop();
  13198. a = stack.pop();
  13199. if (isBool(a) && isBool(b)) {
  13200. stack.push(a || b);
  13201. } else {
  13202. stack.push(a | b);
  13203. }
  13204. break;
  13205. case 'pop':
  13206. stack.pop();
  13207. break;
  13208. case 'roll':
  13209. b = stack.pop();
  13210. a = stack.pop();
  13211. stack.roll(a, b);
  13212. break;
  13213. case 'round':
  13214. a = stack.pop();
  13215. stack.push(Math.round(a));
  13216. break;
  13217. case 'sin':
  13218. a = stack.pop();
  13219. stack.push(Math.sin(a));
  13220. break;
  13221. case 'sqrt':
  13222. a = stack.pop();
  13223. stack.push(Math.sqrt(a));
  13224. break;
  13225. case 'sub':
  13226. b = stack.pop();
  13227. a = stack.pop();
  13228. stack.push(a - b);
  13229. break;
  13230. case 'true':
  13231. stack.push(true);
  13232. break;
  13233. case 'truncate':
  13234. a = stack.pop();
  13235. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13236. stack.push(a);
  13237. break;
  13238. case 'xor':
  13239. b = stack.pop();
  13240. a = stack.pop();
  13241. if (isBool(a) && isBool(b)) {
  13242. stack.push(a !== b);
  13243. } else {
  13244. stack.push(a ^ b);
  13245. }
  13246. break;
  13247. default:
  13248. error('Unknown operator ' + operator);
  13249. break;
  13250. }
  13251. }
  13252. return stack.stack;
  13253. }
  13254. };
  13255. return PostScriptEvaluator;
  13256. }();
  13257. var PostScriptCompiler = function PostScriptCompilerClosure() {
  13258. function AstNode(type) {
  13259. this.type = type;
  13260. }
  13261. AstNode.prototype.visit = function (visitor) {
  13262. throw new Error('abstract method');
  13263. };
  13264. function AstArgument(index, min, max) {
  13265. AstNode.call(this, 'args');
  13266. this.index = index;
  13267. this.min = min;
  13268. this.max = max;
  13269. }
  13270. AstArgument.prototype = Object.create(AstNode.prototype);
  13271. AstArgument.prototype.visit = function (visitor) {
  13272. visitor.visitArgument(this);
  13273. };
  13274. function AstLiteral(number) {
  13275. AstNode.call(this, 'literal');
  13276. this.number = number;
  13277. this.min = number;
  13278. this.max = number;
  13279. }
  13280. AstLiteral.prototype = Object.create(AstNode.prototype);
  13281. AstLiteral.prototype.visit = function (visitor) {
  13282. visitor.visitLiteral(this);
  13283. };
  13284. function AstBinaryOperation(op, arg1, arg2, min, max) {
  13285. AstNode.call(this, 'binary');
  13286. this.op = op;
  13287. this.arg1 = arg1;
  13288. this.arg2 = arg2;
  13289. this.min = min;
  13290. this.max = max;
  13291. }
  13292. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  13293. AstBinaryOperation.prototype.visit = function (visitor) {
  13294. visitor.visitBinaryOperation(this);
  13295. };
  13296. function AstMin(arg, max) {
  13297. AstNode.call(this, 'max');
  13298. this.arg = arg;
  13299. this.min = arg.min;
  13300. this.max = max;
  13301. }
  13302. AstMin.prototype = Object.create(AstNode.prototype);
  13303. AstMin.prototype.visit = function (visitor) {
  13304. visitor.visitMin(this);
  13305. };
  13306. function AstVariable(index, min, max) {
  13307. AstNode.call(this, 'var');
  13308. this.index = index;
  13309. this.min = min;
  13310. this.max = max;
  13311. }
  13312. AstVariable.prototype = Object.create(AstNode.prototype);
  13313. AstVariable.prototype.visit = function (visitor) {
  13314. visitor.visitVariable(this);
  13315. };
  13316. function AstVariableDefinition(variable, arg) {
  13317. AstNode.call(this, 'definition');
  13318. this.variable = variable;
  13319. this.arg = arg;
  13320. }
  13321. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  13322. AstVariableDefinition.prototype.visit = function (visitor) {
  13323. visitor.visitVariableDefinition(this);
  13324. };
  13325. function ExpressionBuilderVisitor() {
  13326. this.parts = [];
  13327. }
  13328. ExpressionBuilderVisitor.prototype = {
  13329. visitArgument: function (arg) {
  13330. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  13331. },
  13332. visitVariable: function (variable) {
  13333. this.parts.push('v', variable.index);
  13334. },
  13335. visitLiteral: function (literal) {
  13336. this.parts.push(literal.number);
  13337. },
  13338. visitBinaryOperation: function (operation) {
  13339. this.parts.push('(');
  13340. operation.arg1.visit(this);
  13341. this.parts.push(' ', operation.op, ' ');
  13342. operation.arg2.visit(this);
  13343. this.parts.push(')');
  13344. },
  13345. visitVariableDefinition: function (definition) {
  13346. this.parts.push('var ');
  13347. definition.variable.visit(this);
  13348. this.parts.push(' = ');
  13349. definition.arg.visit(this);
  13350. this.parts.push(';');
  13351. },
  13352. visitMin: function (max) {
  13353. this.parts.push('Math.min(');
  13354. max.arg.visit(this);
  13355. this.parts.push(', ', max.max, ')');
  13356. },
  13357. toString: function () {
  13358. return this.parts.join('');
  13359. }
  13360. };
  13361. function buildAddOperation(num1, num2) {
  13362. if (num2.type === 'literal' && num2.number === 0) {
  13363. return num1;
  13364. }
  13365. if (num1.type === 'literal' && num1.number === 0) {
  13366. return num2;
  13367. }
  13368. if (num2.type === 'literal' && num1.type === 'literal') {
  13369. return new AstLiteral(num1.number + num2.number);
  13370. }
  13371. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  13372. }
  13373. function buildMulOperation(num1, num2) {
  13374. if (num2.type === 'literal') {
  13375. if (num2.number === 0) {
  13376. return new AstLiteral(0);
  13377. } else if (num2.number === 1) {
  13378. return num1;
  13379. } else if (num1.type === 'literal') {
  13380. return new AstLiteral(num1.number * num2.number);
  13381. }
  13382. }
  13383. if (num1.type === 'literal') {
  13384. if (num1.number === 0) {
  13385. return new AstLiteral(0);
  13386. } else if (num1.number === 1) {
  13387. return num2;
  13388. }
  13389. }
  13390. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13391. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13392. return new AstBinaryOperation('*', num1, num2, min, max);
  13393. }
  13394. function buildSubOperation(num1, num2) {
  13395. if (num2.type === 'literal') {
  13396. if (num2.number === 0) {
  13397. return num1;
  13398. } else if (num1.type === 'literal') {
  13399. return new AstLiteral(num1.number - num2.number);
  13400. }
  13401. }
  13402. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  13403. return num2.arg2;
  13404. }
  13405. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  13406. }
  13407. function buildMinOperation(num1, max) {
  13408. if (num1.min >= max) {
  13409. return new AstLiteral(max);
  13410. } else if (num1.max <= max) {
  13411. return num1;
  13412. }
  13413. return new AstMin(num1, max);
  13414. }
  13415. function PostScriptCompiler() {
  13416. }
  13417. PostScriptCompiler.prototype = {
  13418. compile: function PostScriptCompiler_compile(code, domain, range) {
  13419. var stack = [];
  13420. var i, ii;
  13421. var instructions = [];
  13422. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  13423. var lastRegister = 0;
  13424. var n, j;
  13425. var num1, num2, ast1, ast2, tmpVar, item;
  13426. for (i = 0; i < inputSize; i++) {
  13427. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  13428. }
  13429. for (i = 0, ii = code.length; i < ii; i++) {
  13430. item = code[i];
  13431. if (typeof item === 'number') {
  13432. stack.push(new AstLiteral(item));
  13433. continue;
  13434. }
  13435. switch (item) {
  13436. case 'add':
  13437. if (stack.length < 2) {
  13438. return null;
  13439. }
  13440. num2 = stack.pop();
  13441. num1 = stack.pop();
  13442. stack.push(buildAddOperation(num1, num2));
  13443. break;
  13444. case 'cvr':
  13445. if (stack.length < 1) {
  13446. return null;
  13447. }
  13448. break;
  13449. case 'mul':
  13450. if (stack.length < 2) {
  13451. return null;
  13452. }
  13453. num2 = stack.pop();
  13454. num1 = stack.pop();
  13455. stack.push(buildMulOperation(num1, num2));
  13456. break;
  13457. case 'sub':
  13458. if (stack.length < 2) {
  13459. return null;
  13460. }
  13461. num2 = stack.pop();
  13462. num1 = stack.pop();
  13463. stack.push(buildSubOperation(num1, num2));
  13464. break;
  13465. case 'exch':
  13466. if (stack.length < 2) {
  13467. return null;
  13468. }
  13469. ast1 = stack.pop();
  13470. ast2 = stack.pop();
  13471. stack.push(ast1, ast2);
  13472. break;
  13473. case 'pop':
  13474. if (stack.length < 1) {
  13475. return null;
  13476. }
  13477. stack.pop();
  13478. break;
  13479. case 'index':
  13480. if (stack.length < 1) {
  13481. return null;
  13482. }
  13483. num1 = stack.pop();
  13484. if (num1.type !== 'literal') {
  13485. return null;
  13486. }
  13487. n = num1.number;
  13488. if (n < 0 || (n | 0) !== n || stack.length < n) {
  13489. return null;
  13490. }
  13491. ast1 = stack[stack.length - n - 1];
  13492. if (ast1.type === 'literal' || ast1.type === 'var') {
  13493. stack.push(ast1);
  13494. break;
  13495. }
  13496. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13497. stack[stack.length - n - 1] = tmpVar;
  13498. stack.push(tmpVar);
  13499. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13500. break;
  13501. case 'dup':
  13502. if (stack.length < 1) {
  13503. return null;
  13504. }
  13505. 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]) {
  13506. num1 = stack.pop();
  13507. stack.push(buildMinOperation(num1, code[i + 1]));
  13508. i += 6;
  13509. break;
  13510. }
  13511. ast1 = stack[stack.length - 1];
  13512. if (ast1.type === 'literal' || ast1.type === 'var') {
  13513. stack.push(ast1);
  13514. break;
  13515. }
  13516. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13517. stack[stack.length - 1] = tmpVar;
  13518. stack.push(tmpVar);
  13519. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13520. break;
  13521. case 'roll':
  13522. if (stack.length < 2) {
  13523. return null;
  13524. }
  13525. num2 = stack.pop();
  13526. num1 = stack.pop();
  13527. if (num2.type !== 'literal' || num1.type !== 'literal') {
  13528. return null;
  13529. }
  13530. j = num2.number;
  13531. n = num1.number;
  13532. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  13533. return null;
  13534. }
  13535. j = (j % n + n) % n;
  13536. if (j === 0) {
  13537. break;
  13538. }
  13539. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  13540. break;
  13541. default:
  13542. return null;
  13543. }
  13544. }
  13545. if (stack.length !== outputSize) {
  13546. return null;
  13547. }
  13548. var result = [];
  13549. instructions.forEach(function (instruction) {
  13550. var statementBuilder = new ExpressionBuilderVisitor();
  13551. instruction.visit(statementBuilder);
  13552. result.push(statementBuilder.toString());
  13553. });
  13554. stack.forEach(function (expr, i) {
  13555. var statementBuilder = new ExpressionBuilderVisitor();
  13556. expr.visit(statementBuilder);
  13557. var min = range[i * 2], max = range[i * 2 + 1];
  13558. var out = [statementBuilder.toString()];
  13559. if (min > expr.min) {
  13560. out.unshift('Math.max(', min, ', ');
  13561. out.push(')');
  13562. }
  13563. if (max < expr.max) {
  13564. out.unshift('Math.min(', max, ', ');
  13565. out.push(')');
  13566. }
  13567. out.unshift('dest[destOffset + ', i, '] = ');
  13568. out.push(';');
  13569. result.push(out.join(''));
  13570. });
  13571. return result.join('\n');
  13572. }
  13573. };
  13574. return PostScriptCompiler;
  13575. }();
  13576. exports.isPDFFunction = isPDFFunction;
  13577. exports.PDFFunction = PDFFunction;
  13578. exports.PostScriptEvaluator = PostScriptEvaluator;
  13579. exports.PostScriptCompiler = PostScriptCompiler;
  13580. /***/ }),
  13581. /* 8 */
  13582. /***/ (function(module, exports, __w_pdfjs_require__) {
  13583. "use strict";
  13584. var sharedUtil = __w_pdfjs_require__(0);
  13585. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  13586. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  13587. t['A'] = 0x0041;
  13588. t['AE'] = 0x00C6;
  13589. t['AEacute'] = 0x01FC;
  13590. t['AEmacron'] = 0x01E2;
  13591. t['AEsmall'] = 0xF7E6;
  13592. t['Aacute'] = 0x00C1;
  13593. t['Aacutesmall'] = 0xF7E1;
  13594. t['Abreve'] = 0x0102;
  13595. t['Abreveacute'] = 0x1EAE;
  13596. t['Abrevecyrillic'] = 0x04D0;
  13597. t['Abrevedotbelow'] = 0x1EB6;
  13598. t['Abrevegrave'] = 0x1EB0;
  13599. t['Abrevehookabove'] = 0x1EB2;
  13600. t['Abrevetilde'] = 0x1EB4;
  13601. t['Acaron'] = 0x01CD;
  13602. t['Acircle'] = 0x24B6;
  13603. t['Acircumflex'] = 0x00C2;
  13604. t['Acircumflexacute'] = 0x1EA4;
  13605. t['Acircumflexdotbelow'] = 0x1EAC;
  13606. t['Acircumflexgrave'] = 0x1EA6;
  13607. t['Acircumflexhookabove'] = 0x1EA8;
  13608. t['Acircumflexsmall'] = 0xF7E2;
  13609. t['Acircumflextilde'] = 0x1EAA;
  13610. t['Acute'] = 0xF6C9;
  13611. t['Acutesmall'] = 0xF7B4;
  13612. t['Acyrillic'] = 0x0410;
  13613. t['Adblgrave'] = 0x0200;
  13614. t['Adieresis'] = 0x00C4;
  13615. t['Adieresiscyrillic'] = 0x04D2;
  13616. t['Adieresismacron'] = 0x01DE;
  13617. t['Adieresissmall'] = 0xF7E4;
  13618. t['Adotbelow'] = 0x1EA0;
  13619. t['Adotmacron'] = 0x01E0;
  13620. t['Agrave'] = 0x00C0;
  13621. t['Agravesmall'] = 0xF7E0;
  13622. t['Ahookabove'] = 0x1EA2;
  13623. t['Aiecyrillic'] = 0x04D4;
  13624. t['Ainvertedbreve'] = 0x0202;
  13625. t['Alpha'] = 0x0391;
  13626. t['Alphatonos'] = 0x0386;
  13627. t['Amacron'] = 0x0100;
  13628. t['Amonospace'] = 0xFF21;
  13629. t['Aogonek'] = 0x0104;
  13630. t['Aring'] = 0x00C5;
  13631. t['Aringacute'] = 0x01FA;
  13632. t['Aringbelow'] = 0x1E00;
  13633. t['Aringsmall'] = 0xF7E5;
  13634. t['Asmall'] = 0xF761;
  13635. t['Atilde'] = 0x00C3;
  13636. t['Atildesmall'] = 0xF7E3;
  13637. t['Aybarmenian'] = 0x0531;
  13638. t['B'] = 0x0042;
  13639. t['Bcircle'] = 0x24B7;
  13640. t['Bdotaccent'] = 0x1E02;
  13641. t['Bdotbelow'] = 0x1E04;
  13642. t['Becyrillic'] = 0x0411;
  13643. t['Benarmenian'] = 0x0532;
  13644. t['Beta'] = 0x0392;
  13645. t['Bhook'] = 0x0181;
  13646. t['Blinebelow'] = 0x1E06;
  13647. t['Bmonospace'] = 0xFF22;
  13648. t['Brevesmall'] = 0xF6F4;
  13649. t['Bsmall'] = 0xF762;
  13650. t['Btopbar'] = 0x0182;
  13651. t['C'] = 0x0043;
  13652. t['Caarmenian'] = 0x053E;
  13653. t['Cacute'] = 0x0106;
  13654. t['Caron'] = 0xF6CA;
  13655. t['Caronsmall'] = 0xF6F5;
  13656. t['Ccaron'] = 0x010C;
  13657. t['Ccedilla'] = 0x00C7;
  13658. t['Ccedillaacute'] = 0x1E08;
  13659. t['Ccedillasmall'] = 0xF7E7;
  13660. t['Ccircle'] = 0x24B8;
  13661. t['Ccircumflex'] = 0x0108;
  13662. t['Cdot'] = 0x010A;
  13663. t['Cdotaccent'] = 0x010A;
  13664. t['Cedillasmall'] = 0xF7B8;
  13665. t['Chaarmenian'] = 0x0549;
  13666. t['Cheabkhasiancyrillic'] = 0x04BC;
  13667. t['Checyrillic'] = 0x0427;
  13668. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  13669. t['Chedescendercyrillic'] = 0x04B6;
  13670. t['Chedieresiscyrillic'] = 0x04F4;
  13671. t['Cheharmenian'] = 0x0543;
  13672. t['Chekhakassiancyrillic'] = 0x04CB;
  13673. t['Cheverticalstrokecyrillic'] = 0x04B8;
  13674. t['Chi'] = 0x03A7;
  13675. t['Chook'] = 0x0187;
  13676. t['Circumflexsmall'] = 0xF6F6;
  13677. t['Cmonospace'] = 0xFF23;
  13678. t['Coarmenian'] = 0x0551;
  13679. t['Csmall'] = 0xF763;
  13680. t['D'] = 0x0044;
  13681. t['DZ'] = 0x01F1;
  13682. t['DZcaron'] = 0x01C4;
  13683. t['Daarmenian'] = 0x0534;
  13684. t['Dafrican'] = 0x0189;
  13685. t['Dcaron'] = 0x010E;
  13686. t['Dcedilla'] = 0x1E10;
  13687. t['Dcircle'] = 0x24B9;
  13688. t['Dcircumflexbelow'] = 0x1E12;
  13689. t['Dcroat'] = 0x0110;
  13690. t['Ddotaccent'] = 0x1E0A;
  13691. t['Ddotbelow'] = 0x1E0C;
  13692. t['Decyrillic'] = 0x0414;
  13693. t['Deicoptic'] = 0x03EE;
  13694. t['Delta'] = 0x2206;
  13695. t['Deltagreek'] = 0x0394;
  13696. t['Dhook'] = 0x018A;
  13697. t['Dieresis'] = 0xF6CB;
  13698. t['DieresisAcute'] = 0xF6CC;
  13699. t['DieresisGrave'] = 0xF6CD;
  13700. t['Dieresissmall'] = 0xF7A8;
  13701. t['Digammagreek'] = 0x03DC;
  13702. t['Djecyrillic'] = 0x0402;
  13703. t['Dlinebelow'] = 0x1E0E;
  13704. t['Dmonospace'] = 0xFF24;
  13705. t['Dotaccentsmall'] = 0xF6F7;
  13706. t['Dslash'] = 0x0110;
  13707. t['Dsmall'] = 0xF764;
  13708. t['Dtopbar'] = 0x018B;
  13709. t['Dz'] = 0x01F2;
  13710. t['Dzcaron'] = 0x01C5;
  13711. t['Dzeabkhasiancyrillic'] = 0x04E0;
  13712. t['Dzecyrillic'] = 0x0405;
  13713. t['Dzhecyrillic'] = 0x040F;
  13714. t['E'] = 0x0045;
  13715. t['Eacute'] = 0x00C9;
  13716. t['Eacutesmall'] = 0xF7E9;
  13717. t['Ebreve'] = 0x0114;
  13718. t['Ecaron'] = 0x011A;
  13719. t['Ecedillabreve'] = 0x1E1C;
  13720. t['Echarmenian'] = 0x0535;
  13721. t['Ecircle'] = 0x24BA;
  13722. t['Ecircumflex'] = 0x00CA;
  13723. t['Ecircumflexacute'] = 0x1EBE;
  13724. t['Ecircumflexbelow'] = 0x1E18;
  13725. t['Ecircumflexdotbelow'] = 0x1EC6;
  13726. t['Ecircumflexgrave'] = 0x1EC0;
  13727. t['Ecircumflexhookabove'] = 0x1EC2;
  13728. t['Ecircumflexsmall'] = 0xF7EA;
  13729. t['Ecircumflextilde'] = 0x1EC4;
  13730. t['Ecyrillic'] = 0x0404;
  13731. t['Edblgrave'] = 0x0204;
  13732. t['Edieresis'] = 0x00CB;
  13733. t['Edieresissmall'] = 0xF7EB;
  13734. t['Edot'] = 0x0116;
  13735. t['Edotaccent'] = 0x0116;
  13736. t['Edotbelow'] = 0x1EB8;
  13737. t['Efcyrillic'] = 0x0424;
  13738. t['Egrave'] = 0x00C8;
  13739. t['Egravesmall'] = 0xF7E8;
  13740. t['Eharmenian'] = 0x0537;
  13741. t['Ehookabove'] = 0x1EBA;
  13742. t['Eightroman'] = 0x2167;
  13743. t['Einvertedbreve'] = 0x0206;
  13744. t['Eiotifiedcyrillic'] = 0x0464;
  13745. t['Elcyrillic'] = 0x041B;
  13746. t['Elevenroman'] = 0x216A;
  13747. t['Emacron'] = 0x0112;
  13748. t['Emacronacute'] = 0x1E16;
  13749. t['Emacrongrave'] = 0x1E14;
  13750. t['Emcyrillic'] = 0x041C;
  13751. t['Emonospace'] = 0xFF25;
  13752. t['Encyrillic'] = 0x041D;
  13753. t['Endescendercyrillic'] = 0x04A2;
  13754. t['Eng'] = 0x014A;
  13755. t['Enghecyrillic'] = 0x04A4;
  13756. t['Enhookcyrillic'] = 0x04C7;
  13757. t['Eogonek'] = 0x0118;
  13758. t['Eopen'] = 0x0190;
  13759. t['Epsilon'] = 0x0395;
  13760. t['Epsilontonos'] = 0x0388;
  13761. t['Ercyrillic'] = 0x0420;
  13762. t['Ereversed'] = 0x018E;
  13763. t['Ereversedcyrillic'] = 0x042D;
  13764. t['Escyrillic'] = 0x0421;
  13765. t['Esdescendercyrillic'] = 0x04AA;
  13766. t['Esh'] = 0x01A9;
  13767. t['Esmall'] = 0xF765;
  13768. t['Eta'] = 0x0397;
  13769. t['Etarmenian'] = 0x0538;
  13770. t['Etatonos'] = 0x0389;
  13771. t['Eth'] = 0x00D0;
  13772. t['Ethsmall'] = 0xF7F0;
  13773. t['Etilde'] = 0x1EBC;
  13774. t['Etildebelow'] = 0x1E1A;
  13775. t['Euro'] = 0x20AC;
  13776. t['Ezh'] = 0x01B7;
  13777. t['Ezhcaron'] = 0x01EE;
  13778. t['Ezhreversed'] = 0x01B8;
  13779. t['F'] = 0x0046;
  13780. t['Fcircle'] = 0x24BB;
  13781. t['Fdotaccent'] = 0x1E1E;
  13782. t['Feharmenian'] = 0x0556;
  13783. t['Feicoptic'] = 0x03E4;
  13784. t['Fhook'] = 0x0191;
  13785. t['Fitacyrillic'] = 0x0472;
  13786. t['Fiveroman'] = 0x2164;
  13787. t['Fmonospace'] = 0xFF26;
  13788. t['Fourroman'] = 0x2163;
  13789. t['Fsmall'] = 0xF766;
  13790. t['G'] = 0x0047;
  13791. t['GBsquare'] = 0x3387;
  13792. t['Gacute'] = 0x01F4;
  13793. t['Gamma'] = 0x0393;
  13794. t['Gammaafrican'] = 0x0194;
  13795. t['Gangiacoptic'] = 0x03EA;
  13796. t['Gbreve'] = 0x011E;
  13797. t['Gcaron'] = 0x01E6;
  13798. t['Gcedilla'] = 0x0122;
  13799. t['Gcircle'] = 0x24BC;
  13800. t['Gcircumflex'] = 0x011C;
  13801. t['Gcommaaccent'] = 0x0122;
  13802. t['Gdot'] = 0x0120;
  13803. t['Gdotaccent'] = 0x0120;
  13804. t['Gecyrillic'] = 0x0413;
  13805. t['Ghadarmenian'] = 0x0542;
  13806. t['Ghemiddlehookcyrillic'] = 0x0494;
  13807. t['Ghestrokecyrillic'] = 0x0492;
  13808. t['Gheupturncyrillic'] = 0x0490;
  13809. t['Ghook'] = 0x0193;
  13810. t['Gimarmenian'] = 0x0533;
  13811. t['Gjecyrillic'] = 0x0403;
  13812. t['Gmacron'] = 0x1E20;
  13813. t['Gmonospace'] = 0xFF27;
  13814. t['Grave'] = 0xF6CE;
  13815. t['Gravesmall'] = 0xF760;
  13816. t['Gsmall'] = 0xF767;
  13817. t['Gsmallhook'] = 0x029B;
  13818. t['Gstroke'] = 0x01E4;
  13819. t['H'] = 0x0048;
  13820. t['H18533'] = 0x25CF;
  13821. t['H18543'] = 0x25AA;
  13822. t['H18551'] = 0x25AB;
  13823. t['H22073'] = 0x25A1;
  13824. t['HPsquare'] = 0x33CB;
  13825. t['Haabkhasiancyrillic'] = 0x04A8;
  13826. t['Hadescendercyrillic'] = 0x04B2;
  13827. t['Hardsigncyrillic'] = 0x042A;
  13828. t['Hbar'] = 0x0126;
  13829. t['Hbrevebelow'] = 0x1E2A;
  13830. t['Hcedilla'] = 0x1E28;
  13831. t['Hcircle'] = 0x24BD;
  13832. t['Hcircumflex'] = 0x0124;
  13833. t['Hdieresis'] = 0x1E26;
  13834. t['Hdotaccent'] = 0x1E22;
  13835. t['Hdotbelow'] = 0x1E24;
  13836. t['Hmonospace'] = 0xFF28;
  13837. t['Hoarmenian'] = 0x0540;
  13838. t['Horicoptic'] = 0x03E8;
  13839. t['Hsmall'] = 0xF768;
  13840. t['Hungarumlaut'] = 0xF6CF;
  13841. t['Hungarumlautsmall'] = 0xF6F8;
  13842. t['Hzsquare'] = 0x3390;
  13843. t['I'] = 0x0049;
  13844. t['IAcyrillic'] = 0x042F;
  13845. t['IJ'] = 0x0132;
  13846. t['IUcyrillic'] = 0x042E;
  13847. t['Iacute'] = 0x00CD;
  13848. t['Iacutesmall'] = 0xF7ED;
  13849. t['Ibreve'] = 0x012C;
  13850. t['Icaron'] = 0x01CF;
  13851. t['Icircle'] = 0x24BE;
  13852. t['Icircumflex'] = 0x00CE;
  13853. t['Icircumflexsmall'] = 0xF7EE;
  13854. t['Icyrillic'] = 0x0406;
  13855. t['Idblgrave'] = 0x0208;
  13856. t['Idieresis'] = 0x00CF;
  13857. t['Idieresisacute'] = 0x1E2E;
  13858. t['Idieresiscyrillic'] = 0x04E4;
  13859. t['Idieresissmall'] = 0xF7EF;
  13860. t['Idot'] = 0x0130;
  13861. t['Idotaccent'] = 0x0130;
  13862. t['Idotbelow'] = 0x1ECA;
  13863. t['Iebrevecyrillic'] = 0x04D6;
  13864. t['Iecyrillic'] = 0x0415;
  13865. t['Ifraktur'] = 0x2111;
  13866. t['Igrave'] = 0x00CC;
  13867. t['Igravesmall'] = 0xF7EC;
  13868. t['Ihookabove'] = 0x1EC8;
  13869. t['Iicyrillic'] = 0x0418;
  13870. t['Iinvertedbreve'] = 0x020A;
  13871. t['Iishortcyrillic'] = 0x0419;
  13872. t['Imacron'] = 0x012A;
  13873. t['Imacroncyrillic'] = 0x04E2;
  13874. t['Imonospace'] = 0xFF29;
  13875. t['Iniarmenian'] = 0x053B;
  13876. t['Iocyrillic'] = 0x0401;
  13877. t['Iogonek'] = 0x012E;
  13878. t['Iota'] = 0x0399;
  13879. t['Iotaafrican'] = 0x0196;
  13880. t['Iotadieresis'] = 0x03AA;
  13881. t['Iotatonos'] = 0x038A;
  13882. t['Ismall'] = 0xF769;
  13883. t['Istroke'] = 0x0197;
  13884. t['Itilde'] = 0x0128;
  13885. t['Itildebelow'] = 0x1E2C;
  13886. t['Izhitsacyrillic'] = 0x0474;
  13887. t['Izhitsadblgravecyrillic'] = 0x0476;
  13888. t['J'] = 0x004A;
  13889. t['Jaarmenian'] = 0x0541;
  13890. t['Jcircle'] = 0x24BF;
  13891. t['Jcircumflex'] = 0x0134;
  13892. t['Jecyrillic'] = 0x0408;
  13893. t['Jheharmenian'] = 0x054B;
  13894. t['Jmonospace'] = 0xFF2A;
  13895. t['Jsmall'] = 0xF76A;
  13896. t['K'] = 0x004B;
  13897. t['KBsquare'] = 0x3385;
  13898. t['KKsquare'] = 0x33CD;
  13899. t['Kabashkircyrillic'] = 0x04A0;
  13900. t['Kacute'] = 0x1E30;
  13901. t['Kacyrillic'] = 0x041A;
  13902. t['Kadescendercyrillic'] = 0x049A;
  13903. t['Kahookcyrillic'] = 0x04C3;
  13904. t['Kappa'] = 0x039A;
  13905. t['Kastrokecyrillic'] = 0x049E;
  13906. t['Kaverticalstrokecyrillic'] = 0x049C;
  13907. t['Kcaron'] = 0x01E8;
  13908. t['Kcedilla'] = 0x0136;
  13909. t['Kcircle'] = 0x24C0;
  13910. t['Kcommaaccent'] = 0x0136;
  13911. t['Kdotbelow'] = 0x1E32;
  13912. t['Keharmenian'] = 0x0554;
  13913. t['Kenarmenian'] = 0x053F;
  13914. t['Khacyrillic'] = 0x0425;
  13915. t['Kheicoptic'] = 0x03E6;
  13916. t['Khook'] = 0x0198;
  13917. t['Kjecyrillic'] = 0x040C;
  13918. t['Klinebelow'] = 0x1E34;
  13919. t['Kmonospace'] = 0xFF2B;
  13920. t['Koppacyrillic'] = 0x0480;
  13921. t['Koppagreek'] = 0x03DE;
  13922. t['Ksicyrillic'] = 0x046E;
  13923. t['Ksmall'] = 0xF76B;
  13924. t['L'] = 0x004C;
  13925. t['LJ'] = 0x01C7;
  13926. t['LL'] = 0xF6BF;
  13927. t['Lacute'] = 0x0139;
  13928. t['Lambda'] = 0x039B;
  13929. t['Lcaron'] = 0x013D;
  13930. t['Lcedilla'] = 0x013B;
  13931. t['Lcircle'] = 0x24C1;
  13932. t['Lcircumflexbelow'] = 0x1E3C;
  13933. t['Lcommaaccent'] = 0x013B;
  13934. t['Ldot'] = 0x013F;
  13935. t['Ldotaccent'] = 0x013F;
  13936. t['Ldotbelow'] = 0x1E36;
  13937. t['Ldotbelowmacron'] = 0x1E38;
  13938. t['Liwnarmenian'] = 0x053C;
  13939. t['Lj'] = 0x01C8;
  13940. t['Ljecyrillic'] = 0x0409;
  13941. t['Llinebelow'] = 0x1E3A;
  13942. t['Lmonospace'] = 0xFF2C;
  13943. t['Lslash'] = 0x0141;
  13944. t['Lslashsmall'] = 0xF6F9;
  13945. t['Lsmall'] = 0xF76C;
  13946. t['M'] = 0x004D;
  13947. t['MBsquare'] = 0x3386;
  13948. t['Macron'] = 0xF6D0;
  13949. t['Macronsmall'] = 0xF7AF;
  13950. t['Macute'] = 0x1E3E;
  13951. t['Mcircle'] = 0x24C2;
  13952. t['Mdotaccent'] = 0x1E40;
  13953. t['Mdotbelow'] = 0x1E42;
  13954. t['Menarmenian'] = 0x0544;
  13955. t['Mmonospace'] = 0xFF2D;
  13956. t['Msmall'] = 0xF76D;
  13957. t['Mturned'] = 0x019C;
  13958. t['Mu'] = 0x039C;
  13959. t['N'] = 0x004E;
  13960. t['NJ'] = 0x01CA;
  13961. t['Nacute'] = 0x0143;
  13962. t['Ncaron'] = 0x0147;
  13963. t['Ncedilla'] = 0x0145;
  13964. t['Ncircle'] = 0x24C3;
  13965. t['Ncircumflexbelow'] = 0x1E4A;
  13966. t['Ncommaaccent'] = 0x0145;
  13967. t['Ndotaccent'] = 0x1E44;
  13968. t['Ndotbelow'] = 0x1E46;
  13969. t['Nhookleft'] = 0x019D;
  13970. t['Nineroman'] = 0x2168;
  13971. t['Nj'] = 0x01CB;
  13972. t['Njecyrillic'] = 0x040A;
  13973. t['Nlinebelow'] = 0x1E48;
  13974. t['Nmonospace'] = 0xFF2E;
  13975. t['Nowarmenian'] = 0x0546;
  13976. t['Nsmall'] = 0xF76E;
  13977. t['Ntilde'] = 0x00D1;
  13978. t['Ntildesmall'] = 0xF7F1;
  13979. t['Nu'] = 0x039D;
  13980. t['O'] = 0x004F;
  13981. t['OE'] = 0x0152;
  13982. t['OEsmall'] = 0xF6FA;
  13983. t['Oacute'] = 0x00D3;
  13984. t['Oacutesmall'] = 0xF7F3;
  13985. t['Obarredcyrillic'] = 0x04E8;
  13986. t['Obarreddieresiscyrillic'] = 0x04EA;
  13987. t['Obreve'] = 0x014E;
  13988. t['Ocaron'] = 0x01D1;
  13989. t['Ocenteredtilde'] = 0x019F;
  13990. t['Ocircle'] = 0x24C4;
  13991. t['Ocircumflex'] = 0x00D4;
  13992. t['Ocircumflexacute'] = 0x1ED0;
  13993. t['Ocircumflexdotbelow'] = 0x1ED8;
  13994. t['Ocircumflexgrave'] = 0x1ED2;
  13995. t['Ocircumflexhookabove'] = 0x1ED4;
  13996. t['Ocircumflexsmall'] = 0xF7F4;
  13997. t['Ocircumflextilde'] = 0x1ED6;
  13998. t['Ocyrillic'] = 0x041E;
  13999. t['Odblacute'] = 0x0150;
  14000. t['Odblgrave'] = 0x020C;
  14001. t['Odieresis'] = 0x00D6;
  14002. t['Odieresiscyrillic'] = 0x04E6;
  14003. t['Odieresissmall'] = 0xF7F6;
  14004. t['Odotbelow'] = 0x1ECC;
  14005. t['Ogoneksmall'] = 0xF6FB;
  14006. t['Ograve'] = 0x00D2;
  14007. t['Ogravesmall'] = 0xF7F2;
  14008. t['Oharmenian'] = 0x0555;
  14009. t['Ohm'] = 0x2126;
  14010. t['Ohookabove'] = 0x1ECE;
  14011. t['Ohorn'] = 0x01A0;
  14012. t['Ohornacute'] = 0x1EDA;
  14013. t['Ohorndotbelow'] = 0x1EE2;
  14014. t['Ohorngrave'] = 0x1EDC;
  14015. t['Ohornhookabove'] = 0x1EDE;
  14016. t['Ohorntilde'] = 0x1EE0;
  14017. t['Ohungarumlaut'] = 0x0150;
  14018. t['Oi'] = 0x01A2;
  14019. t['Oinvertedbreve'] = 0x020E;
  14020. t['Omacron'] = 0x014C;
  14021. t['Omacronacute'] = 0x1E52;
  14022. t['Omacrongrave'] = 0x1E50;
  14023. t['Omega'] = 0x2126;
  14024. t['Omegacyrillic'] = 0x0460;
  14025. t['Omegagreek'] = 0x03A9;
  14026. t['Omegaroundcyrillic'] = 0x047A;
  14027. t['Omegatitlocyrillic'] = 0x047C;
  14028. t['Omegatonos'] = 0x038F;
  14029. t['Omicron'] = 0x039F;
  14030. t['Omicrontonos'] = 0x038C;
  14031. t['Omonospace'] = 0xFF2F;
  14032. t['Oneroman'] = 0x2160;
  14033. t['Oogonek'] = 0x01EA;
  14034. t['Oogonekmacron'] = 0x01EC;
  14035. t['Oopen'] = 0x0186;
  14036. t['Oslash'] = 0x00D8;
  14037. t['Oslashacute'] = 0x01FE;
  14038. t['Oslashsmall'] = 0xF7F8;
  14039. t['Osmall'] = 0xF76F;
  14040. t['Ostrokeacute'] = 0x01FE;
  14041. t['Otcyrillic'] = 0x047E;
  14042. t['Otilde'] = 0x00D5;
  14043. t['Otildeacute'] = 0x1E4C;
  14044. t['Otildedieresis'] = 0x1E4E;
  14045. t['Otildesmall'] = 0xF7F5;
  14046. t['P'] = 0x0050;
  14047. t['Pacute'] = 0x1E54;
  14048. t['Pcircle'] = 0x24C5;
  14049. t['Pdotaccent'] = 0x1E56;
  14050. t['Pecyrillic'] = 0x041F;
  14051. t['Peharmenian'] = 0x054A;
  14052. t['Pemiddlehookcyrillic'] = 0x04A6;
  14053. t['Phi'] = 0x03A6;
  14054. t['Phook'] = 0x01A4;
  14055. t['Pi'] = 0x03A0;
  14056. t['Piwrarmenian'] = 0x0553;
  14057. t['Pmonospace'] = 0xFF30;
  14058. t['Psi'] = 0x03A8;
  14059. t['Psicyrillic'] = 0x0470;
  14060. t['Psmall'] = 0xF770;
  14061. t['Q'] = 0x0051;
  14062. t['Qcircle'] = 0x24C6;
  14063. t['Qmonospace'] = 0xFF31;
  14064. t['Qsmall'] = 0xF771;
  14065. t['R'] = 0x0052;
  14066. t['Raarmenian'] = 0x054C;
  14067. t['Racute'] = 0x0154;
  14068. t['Rcaron'] = 0x0158;
  14069. t['Rcedilla'] = 0x0156;
  14070. t['Rcircle'] = 0x24C7;
  14071. t['Rcommaaccent'] = 0x0156;
  14072. t['Rdblgrave'] = 0x0210;
  14073. t['Rdotaccent'] = 0x1E58;
  14074. t['Rdotbelow'] = 0x1E5A;
  14075. t['Rdotbelowmacron'] = 0x1E5C;
  14076. t['Reharmenian'] = 0x0550;
  14077. t['Rfraktur'] = 0x211C;
  14078. t['Rho'] = 0x03A1;
  14079. t['Ringsmall'] = 0xF6FC;
  14080. t['Rinvertedbreve'] = 0x0212;
  14081. t['Rlinebelow'] = 0x1E5E;
  14082. t['Rmonospace'] = 0xFF32;
  14083. t['Rsmall'] = 0xF772;
  14084. t['Rsmallinverted'] = 0x0281;
  14085. t['Rsmallinvertedsuperior'] = 0x02B6;
  14086. t['S'] = 0x0053;
  14087. t['SF010000'] = 0x250C;
  14088. t['SF020000'] = 0x2514;
  14089. t['SF030000'] = 0x2510;
  14090. t['SF040000'] = 0x2518;
  14091. t['SF050000'] = 0x253C;
  14092. t['SF060000'] = 0x252C;
  14093. t['SF070000'] = 0x2534;
  14094. t['SF080000'] = 0x251C;
  14095. t['SF090000'] = 0x2524;
  14096. t['SF100000'] = 0x2500;
  14097. t['SF110000'] = 0x2502;
  14098. t['SF190000'] = 0x2561;
  14099. t['SF200000'] = 0x2562;
  14100. t['SF210000'] = 0x2556;
  14101. t['SF220000'] = 0x2555;
  14102. t['SF230000'] = 0x2563;
  14103. t['SF240000'] = 0x2551;
  14104. t['SF250000'] = 0x2557;
  14105. t['SF260000'] = 0x255D;
  14106. t['SF270000'] = 0x255C;
  14107. t['SF280000'] = 0x255B;
  14108. t['SF360000'] = 0x255E;
  14109. t['SF370000'] = 0x255F;
  14110. t['SF380000'] = 0x255A;
  14111. t['SF390000'] = 0x2554;
  14112. t['SF400000'] = 0x2569;
  14113. t['SF410000'] = 0x2566;
  14114. t['SF420000'] = 0x2560;
  14115. t['SF430000'] = 0x2550;
  14116. t['SF440000'] = 0x256C;
  14117. t['SF450000'] = 0x2567;
  14118. t['SF460000'] = 0x2568;
  14119. t['SF470000'] = 0x2564;
  14120. t['SF480000'] = 0x2565;
  14121. t['SF490000'] = 0x2559;
  14122. t['SF500000'] = 0x2558;
  14123. t['SF510000'] = 0x2552;
  14124. t['SF520000'] = 0x2553;
  14125. t['SF530000'] = 0x256B;
  14126. t['SF540000'] = 0x256A;
  14127. t['Sacute'] = 0x015A;
  14128. t['Sacutedotaccent'] = 0x1E64;
  14129. t['Sampigreek'] = 0x03E0;
  14130. t['Scaron'] = 0x0160;
  14131. t['Scarondotaccent'] = 0x1E66;
  14132. t['Scaronsmall'] = 0xF6FD;
  14133. t['Scedilla'] = 0x015E;
  14134. t['Schwa'] = 0x018F;
  14135. t['Schwacyrillic'] = 0x04D8;
  14136. t['Schwadieresiscyrillic'] = 0x04DA;
  14137. t['Scircle'] = 0x24C8;
  14138. t['Scircumflex'] = 0x015C;
  14139. t['Scommaaccent'] = 0x0218;
  14140. t['Sdotaccent'] = 0x1E60;
  14141. t['Sdotbelow'] = 0x1E62;
  14142. t['Sdotbelowdotaccent'] = 0x1E68;
  14143. t['Seharmenian'] = 0x054D;
  14144. t['Sevenroman'] = 0x2166;
  14145. t['Shaarmenian'] = 0x0547;
  14146. t['Shacyrillic'] = 0x0428;
  14147. t['Shchacyrillic'] = 0x0429;
  14148. t['Sheicoptic'] = 0x03E2;
  14149. t['Shhacyrillic'] = 0x04BA;
  14150. t['Shimacoptic'] = 0x03EC;
  14151. t['Sigma'] = 0x03A3;
  14152. t['Sixroman'] = 0x2165;
  14153. t['Smonospace'] = 0xFF33;
  14154. t['Softsigncyrillic'] = 0x042C;
  14155. t['Ssmall'] = 0xF773;
  14156. t['Stigmagreek'] = 0x03DA;
  14157. t['T'] = 0x0054;
  14158. t['Tau'] = 0x03A4;
  14159. t['Tbar'] = 0x0166;
  14160. t['Tcaron'] = 0x0164;
  14161. t['Tcedilla'] = 0x0162;
  14162. t['Tcircle'] = 0x24C9;
  14163. t['Tcircumflexbelow'] = 0x1E70;
  14164. t['Tcommaaccent'] = 0x0162;
  14165. t['Tdotaccent'] = 0x1E6A;
  14166. t['Tdotbelow'] = 0x1E6C;
  14167. t['Tecyrillic'] = 0x0422;
  14168. t['Tedescendercyrillic'] = 0x04AC;
  14169. t['Tenroman'] = 0x2169;
  14170. t['Tetsecyrillic'] = 0x04B4;
  14171. t['Theta'] = 0x0398;
  14172. t['Thook'] = 0x01AC;
  14173. t['Thorn'] = 0x00DE;
  14174. t['Thornsmall'] = 0xF7FE;
  14175. t['Threeroman'] = 0x2162;
  14176. t['Tildesmall'] = 0xF6FE;
  14177. t['Tiwnarmenian'] = 0x054F;
  14178. t['Tlinebelow'] = 0x1E6E;
  14179. t['Tmonospace'] = 0xFF34;
  14180. t['Toarmenian'] = 0x0539;
  14181. t['Tonefive'] = 0x01BC;
  14182. t['Tonesix'] = 0x0184;
  14183. t['Tonetwo'] = 0x01A7;
  14184. t['Tretroflexhook'] = 0x01AE;
  14185. t['Tsecyrillic'] = 0x0426;
  14186. t['Tshecyrillic'] = 0x040B;
  14187. t['Tsmall'] = 0xF774;
  14188. t['Twelveroman'] = 0x216B;
  14189. t['Tworoman'] = 0x2161;
  14190. t['U'] = 0x0055;
  14191. t['Uacute'] = 0x00DA;
  14192. t['Uacutesmall'] = 0xF7FA;
  14193. t['Ubreve'] = 0x016C;
  14194. t['Ucaron'] = 0x01D3;
  14195. t['Ucircle'] = 0x24CA;
  14196. t['Ucircumflex'] = 0x00DB;
  14197. t['Ucircumflexbelow'] = 0x1E76;
  14198. t['Ucircumflexsmall'] = 0xF7FB;
  14199. t['Ucyrillic'] = 0x0423;
  14200. t['Udblacute'] = 0x0170;
  14201. t['Udblgrave'] = 0x0214;
  14202. t['Udieresis'] = 0x00DC;
  14203. t['Udieresisacute'] = 0x01D7;
  14204. t['Udieresisbelow'] = 0x1E72;
  14205. t['Udieresiscaron'] = 0x01D9;
  14206. t['Udieresiscyrillic'] = 0x04F0;
  14207. t['Udieresisgrave'] = 0x01DB;
  14208. t['Udieresismacron'] = 0x01D5;
  14209. t['Udieresissmall'] = 0xF7FC;
  14210. t['Udotbelow'] = 0x1EE4;
  14211. t['Ugrave'] = 0x00D9;
  14212. t['Ugravesmall'] = 0xF7F9;
  14213. t['Uhookabove'] = 0x1EE6;
  14214. t['Uhorn'] = 0x01AF;
  14215. t['Uhornacute'] = 0x1EE8;
  14216. t['Uhorndotbelow'] = 0x1EF0;
  14217. t['Uhorngrave'] = 0x1EEA;
  14218. t['Uhornhookabove'] = 0x1EEC;
  14219. t['Uhorntilde'] = 0x1EEE;
  14220. t['Uhungarumlaut'] = 0x0170;
  14221. t['Uhungarumlautcyrillic'] = 0x04F2;
  14222. t['Uinvertedbreve'] = 0x0216;
  14223. t['Ukcyrillic'] = 0x0478;
  14224. t['Umacron'] = 0x016A;
  14225. t['Umacroncyrillic'] = 0x04EE;
  14226. t['Umacrondieresis'] = 0x1E7A;
  14227. t['Umonospace'] = 0xFF35;
  14228. t['Uogonek'] = 0x0172;
  14229. t['Upsilon'] = 0x03A5;
  14230. t['Upsilon1'] = 0x03D2;
  14231. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14232. t['Upsilonafrican'] = 0x01B1;
  14233. t['Upsilondieresis'] = 0x03AB;
  14234. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14235. t['Upsilonhooksymbol'] = 0x03D2;
  14236. t['Upsilontonos'] = 0x038E;
  14237. t['Uring'] = 0x016E;
  14238. t['Ushortcyrillic'] = 0x040E;
  14239. t['Usmall'] = 0xF775;
  14240. t['Ustraightcyrillic'] = 0x04AE;
  14241. t['Ustraightstrokecyrillic'] = 0x04B0;
  14242. t['Utilde'] = 0x0168;
  14243. t['Utildeacute'] = 0x1E78;
  14244. t['Utildebelow'] = 0x1E74;
  14245. t['V'] = 0x0056;
  14246. t['Vcircle'] = 0x24CB;
  14247. t['Vdotbelow'] = 0x1E7E;
  14248. t['Vecyrillic'] = 0x0412;
  14249. t['Vewarmenian'] = 0x054E;
  14250. t['Vhook'] = 0x01B2;
  14251. t['Vmonospace'] = 0xFF36;
  14252. t['Voarmenian'] = 0x0548;
  14253. t['Vsmall'] = 0xF776;
  14254. t['Vtilde'] = 0x1E7C;
  14255. t['W'] = 0x0057;
  14256. t['Wacute'] = 0x1E82;
  14257. t['Wcircle'] = 0x24CC;
  14258. t['Wcircumflex'] = 0x0174;
  14259. t['Wdieresis'] = 0x1E84;
  14260. t['Wdotaccent'] = 0x1E86;
  14261. t['Wdotbelow'] = 0x1E88;
  14262. t['Wgrave'] = 0x1E80;
  14263. t['Wmonospace'] = 0xFF37;
  14264. t['Wsmall'] = 0xF777;
  14265. t['X'] = 0x0058;
  14266. t['Xcircle'] = 0x24CD;
  14267. t['Xdieresis'] = 0x1E8C;
  14268. t['Xdotaccent'] = 0x1E8A;
  14269. t['Xeharmenian'] = 0x053D;
  14270. t['Xi'] = 0x039E;
  14271. t['Xmonospace'] = 0xFF38;
  14272. t['Xsmall'] = 0xF778;
  14273. t['Y'] = 0x0059;
  14274. t['Yacute'] = 0x00DD;
  14275. t['Yacutesmall'] = 0xF7FD;
  14276. t['Yatcyrillic'] = 0x0462;
  14277. t['Ycircle'] = 0x24CE;
  14278. t['Ycircumflex'] = 0x0176;
  14279. t['Ydieresis'] = 0x0178;
  14280. t['Ydieresissmall'] = 0xF7FF;
  14281. t['Ydotaccent'] = 0x1E8E;
  14282. t['Ydotbelow'] = 0x1EF4;
  14283. t['Yericyrillic'] = 0x042B;
  14284. t['Yerudieresiscyrillic'] = 0x04F8;
  14285. t['Ygrave'] = 0x1EF2;
  14286. t['Yhook'] = 0x01B3;
  14287. t['Yhookabove'] = 0x1EF6;
  14288. t['Yiarmenian'] = 0x0545;
  14289. t['Yicyrillic'] = 0x0407;
  14290. t['Yiwnarmenian'] = 0x0552;
  14291. t['Ymonospace'] = 0xFF39;
  14292. t['Ysmall'] = 0xF779;
  14293. t['Ytilde'] = 0x1EF8;
  14294. t['Yusbigcyrillic'] = 0x046A;
  14295. t['Yusbigiotifiedcyrillic'] = 0x046C;
  14296. t['Yuslittlecyrillic'] = 0x0466;
  14297. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  14298. t['Z'] = 0x005A;
  14299. t['Zaarmenian'] = 0x0536;
  14300. t['Zacute'] = 0x0179;
  14301. t['Zcaron'] = 0x017D;
  14302. t['Zcaronsmall'] = 0xF6FF;
  14303. t['Zcircle'] = 0x24CF;
  14304. t['Zcircumflex'] = 0x1E90;
  14305. t['Zdot'] = 0x017B;
  14306. t['Zdotaccent'] = 0x017B;
  14307. t['Zdotbelow'] = 0x1E92;
  14308. t['Zecyrillic'] = 0x0417;
  14309. t['Zedescendercyrillic'] = 0x0498;
  14310. t['Zedieresiscyrillic'] = 0x04DE;
  14311. t['Zeta'] = 0x0396;
  14312. t['Zhearmenian'] = 0x053A;
  14313. t['Zhebrevecyrillic'] = 0x04C1;
  14314. t['Zhecyrillic'] = 0x0416;
  14315. t['Zhedescendercyrillic'] = 0x0496;
  14316. t['Zhedieresiscyrillic'] = 0x04DC;
  14317. t['Zlinebelow'] = 0x1E94;
  14318. t['Zmonospace'] = 0xFF3A;
  14319. t['Zsmall'] = 0xF77A;
  14320. t['Zstroke'] = 0x01B5;
  14321. t['a'] = 0x0061;
  14322. t['aabengali'] = 0x0986;
  14323. t['aacute'] = 0x00E1;
  14324. t['aadeva'] = 0x0906;
  14325. t['aagujarati'] = 0x0A86;
  14326. t['aagurmukhi'] = 0x0A06;
  14327. t['aamatragurmukhi'] = 0x0A3E;
  14328. t['aarusquare'] = 0x3303;
  14329. t['aavowelsignbengali'] = 0x09BE;
  14330. t['aavowelsigndeva'] = 0x093E;
  14331. t['aavowelsigngujarati'] = 0x0ABE;
  14332. t['abbreviationmarkarmenian'] = 0x055F;
  14333. t['abbreviationsigndeva'] = 0x0970;
  14334. t['abengali'] = 0x0985;
  14335. t['abopomofo'] = 0x311A;
  14336. t['abreve'] = 0x0103;
  14337. t['abreveacute'] = 0x1EAF;
  14338. t['abrevecyrillic'] = 0x04D1;
  14339. t['abrevedotbelow'] = 0x1EB7;
  14340. t['abrevegrave'] = 0x1EB1;
  14341. t['abrevehookabove'] = 0x1EB3;
  14342. t['abrevetilde'] = 0x1EB5;
  14343. t['acaron'] = 0x01CE;
  14344. t['acircle'] = 0x24D0;
  14345. t['acircumflex'] = 0x00E2;
  14346. t['acircumflexacute'] = 0x1EA5;
  14347. t['acircumflexdotbelow'] = 0x1EAD;
  14348. t['acircumflexgrave'] = 0x1EA7;
  14349. t['acircumflexhookabove'] = 0x1EA9;
  14350. t['acircumflextilde'] = 0x1EAB;
  14351. t['acute'] = 0x00B4;
  14352. t['acutebelowcmb'] = 0x0317;
  14353. t['acutecmb'] = 0x0301;
  14354. t['acutecomb'] = 0x0301;
  14355. t['acutedeva'] = 0x0954;
  14356. t['acutelowmod'] = 0x02CF;
  14357. t['acutetonecmb'] = 0x0341;
  14358. t['acyrillic'] = 0x0430;
  14359. t['adblgrave'] = 0x0201;
  14360. t['addakgurmukhi'] = 0x0A71;
  14361. t['adeva'] = 0x0905;
  14362. t['adieresis'] = 0x00E4;
  14363. t['adieresiscyrillic'] = 0x04D3;
  14364. t['adieresismacron'] = 0x01DF;
  14365. t['adotbelow'] = 0x1EA1;
  14366. t['adotmacron'] = 0x01E1;
  14367. t['ae'] = 0x00E6;
  14368. t['aeacute'] = 0x01FD;
  14369. t['aekorean'] = 0x3150;
  14370. t['aemacron'] = 0x01E3;
  14371. t['afii00208'] = 0x2015;
  14372. t['afii08941'] = 0x20A4;
  14373. t['afii10017'] = 0x0410;
  14374. t['afii10018'] = 0x0411;
  14375. t['afii10019'] = 0x0412;
  14376. t['afii10020'] = 0x0413;
  14377. t['afii10021'] = 0x0414;
  14378. t['afii10022'] = 0x0415;
  14379. t['afii10023'] = 0x0401;
  14380. t['afii10024'] = 0x0416;
  14381. t['afii10025'] = 0x0417;
  14382. t['afii10026'] = 0x0418;
  14383. t['afii10027'] = 0x0419;
  14384. t['afii10028'] = 0x041A;
  14385. t['afii10029'] = 0x041B;
  14386. t['afii10030'] = 0x041C;
  14387. t['afii10031'] = 0x041D;
  14388. t['afii10032'] = 0x041E;
  14389. t['afii10033'] = 0x041F;
  14390. t['afii10034'] = 0x0420;
  14391. t['afii10035'] = 0x0421;
  14392. t['afii10036'] = 0x0422;
  14393. t['afii10037'] = 0x0423;
  14394. t['afii10038'] = 0x0424;
  14395. t['afii10039'] = 0x0425;
  14396. t['afii10040'] = 0x0426;
  14397. t['afii10041'] = 0x0427;
  14398. t['afii10042'] = 0x0428;
  14399. t['afii10043'] = 0x0429;
  14400. t['afii10044'] = 0x042A;
  14401. t['afii10045'] = 0x042B;
  14402. t['afii10046'] = 0x042C;
  14403. t['afii10047'] = 0x042D;
  14404. t['afii10048'] = 0x042E;
  14405. t['afii10049'] = 0x042F;
  14406. t['afii10050'] = 0x0490;
  14407. t['afii10051'] = 0x0402;
  14408. t['afii10052'] = 0x0403;
  14409. t['afii10053'] = 0x0404;
  14410. t['afii10054'] = 0x0405;
  14411. t['afii10055'] = 0x0406;
  14412. t['afii10056'] = 0x0407;
  14413. t['afii10057'] = 0x0408;
  14414. t['afii10058'] = 0x0409;
  14415. t['afii10059'] = 0x040A;
  14416. t['afii10060'] = 0x040B;
  14417. t['afii10061'] = 0x040C;
  14418. t['afii10062'] = 0x040E;
  14419. t['afii10063'] = 0xF6C4;
  14420. t['afii10064'] = 0xF6C5;
  14421. t['afii10065'] = 0x0430;
  14422. t['afii10066'] = 0x0431;
  14423. t['afii10067'] = 0x0432;
  14424. t['afii10068'] = 0x0433;
  14425. t['afii10069'] = 0x0434;
  14426. t['afii10070'] = 0x0435;
  14427. t['afii10071'] = 0x0451;
  14428. t['afii10072'] = 0x0436;
  14429. t['afii10073'] = 0x0437;
  14430. t['afii10074'] = 0x0438;
  14431. t['afii10075'] = 0x0439;
  14432. t['afii10076'] = 0x043A;
  14433. t['afii10077'] = 0x043B;
  14434. t['afii10078'] = 0x043C;
  14435. t['afii10079'] = 0x043D;
  14436. t['afii10080'] = 0x043E;
  14437. t['afii10081'] = 0x043F;
  14438. t['afii10082'] = 0x0440;
  14439. t['afii10083'] = 0x0441;
  14440. t['afii10084'] = 0x0442;
  14441. t['afii10085'] = 0x0443;
  14442. t['afii10086'] = 0x0444;
  14443. t['afii10087'] = 0x0445;
  14444. t['afii10088'] = 0x0446;
  14445. t['afii10089'] = 0x0447;
  14446. t['afii10090'] = 0x0448;
  14447. t['afii10091'] = 0x0449;
  14448. t['afii10092'] = 0x044A;
  14449. t['afii10093'] = 0x044B;
  14450. t['afii10094'] = 0x044C;
  14451. t['afii10095'] = 0x044D;
  14452. t['afii10096'] = 0x044E;
  14453. t['afii10097'] = 0x044F;
  14454. t['afii10098'] = 0x0491;
  14455. t['afii10099'] = 0x0452;
  14456. t['afii10100'] = 0x0453;
  14457. t['afii10101'] = 0x0454;
  14458. t['afii10102'] = 0x0455;
  14459. t['afii10103'] = 0x0456;
  14460. t['afii10104'] = 0x0457;
  14461. t['afii10105'] = 0x0458;
  14462. t['afii10106'] = 0x0459;
  14463. t['afii10107'] = 0x045A;
  14464. t['afii10108'] = 0x045B;
  14465. t['afii10109'] = 0x045C;
  14466. t['afii10110'] = 0x045E;
  14467. t['afii10145'] = 0x040F;
  14468. t['afii10146'] = 0x0462;
  14469. t['afii10147'] = 0x0472;
  14470. t['afii10148'] = 0x0474;
  14471. t['afii10192'] = 0xF6C6;
  14472. t['afii10193'] = 0x045F;
  14473. t['afii10194'] = 0x0463;
  14474. t['afii10195'] = 0x0473;
  14475. t['afii10196'] = 0x0475;
  14476. t['afii10831'] = 0xF6C7;
  14477. t['afii10832'] = 0xF6C8;
  14478. t['afii10846'] = 0x04D9;
  14479. t['afii299'] = 0x200E;
  14480. t['afii300'] = 0x200F;
  14481. t['afii301'] = 0x200D;
  14482. t['afii57381'] = 0x066A;
  14483. t['afii57388'] = 0x060C;
  14484. t['afii57392'] = 0x0660;
  14485. t['afii57393'] = 0x0661;
  14486. t['afii57394'] = 0x0662;
  14487. t['afii57395'] = 0x0663;
  14488. t['afii57396'] = 0x0664;
  14489. t['afii57397'] = 0x0665;
  14490. t['afii57398'] = 0x0666;
  14491. t['afii57399'] = 0x0667;
  14492. t['afii57400'] = 0x0668;
  14493. t['afii57401'] = 0x0669;
  14494. t['afii57403'] = 0x061B;
  14495. t['afii57407'] = 0x061F;
  14496. t['afii57409'] = 0x0621;
  14497. t['afii57410'] = 0x0622;
  14498. t['afii57411'] = 0x0623;
  14499. t['afii57412'] = 0x0624;
  14500. t['afii57413'] = 0x0625;
  14501. t['afii57414'] = 0x0626;
  14502. t['afii57415'] = 0x0627;
  14503. t['afii57416'] = 0x0628;
  14504. t['afii57417'] = 0x0629;
  14505. t['afii57418'] = 0x062A;
  14506. t['afii57419'] = 0x062B;
  14507. t['afii57420'] = 0x062C;
  14508. t['afii57421'] = 0x062D;
  14509. t['afii57422'] = 0x062E;
  14510. t['afii57423'] = 0x062F;
  14511. t['afii57424'] = 0x0630;
  14512. t['afii57425'] = 0x0631;
  14513. t['afii57426'] = 0x0632;
  14514. t['afii57427'] = 0x0633;
  14515. t['afii57428'] = 0x0634;
  14516. t['afii57429'] = 0x0635;
  14517. t['afii57430'] = 0x0636;
  14518. t['afii57431'] = 0x0637;
  14519. t['afii57432'] = 0x0638;
  14520. t['afii57433'] = 0x0639;
  14521. t['afii57434'] = 0x063A;
  14522. t['afii57440'] = 0x0640;
  14523. t['afii57441'] = 0x0641;
  14524. t['afii57442'] = 0x0642;
  14525. t['afii57443'] = 0x0643;
  14526. t['afii57444'] = 0x0644;
  14527. t['afii57445'] = 0x0645;
  14528. t['afii57446'] = 0x0646;
  14529. t['afii57448'] = 0x0648;
  14530. t['afii57449'] = 0x0649;
  14531. t['afii57450'] = 0x064A;
  14532. t['afii57451'] = 0x064B;
  14533. t['afii57452'] = 0x064C;
  14534. t['afii57453'] = 0x064D;
  14535. t['afii57454'] = 0x064E;
  14536. t['afii57455'] = 0x064F;
  14537. t['afii57456'] = 0x0650;
  14538. t['afii57457'] = 0x0651;
  14539. t['afii57458'] = 0x0652;
  14540. t['afii57470'] = 0x0647;
  14541. t['afii57505'] = 0x06A4;
  14542. t['afii57506'] = 0x067E;
  14543. t['afii57507'] = 0x0686;
  14544. t['afii57508'] = 0x0698;
  14545. t['afii57509'] = 0x06AF;
  14546. t['afii57511'] = 0x0679;
  14547. t['afii57512'] = 0x0688;
  14548. t['afii57513'] = 0x0691;
  14549. t['afii57514'] = 0x06BA;
  14550. t['afii57519'] = 0x06D2;
  14551. t['afii57534'] = 0x06D5;
  14552. t['afii57636'] = 0x20AA;
  14553. t['afii57645'] = 0x05BE;
  14554. t['afii57658'] = 0x05C3;
  14555. t['afii57664'] = 0x05D0;
  14556. t['afii57665'] = 0x05D1;
  14557. t['afii57666'] = 0x05D2;
  14558. t['afii57667'] = 0x05D3;
  14559. t['afii57668'] = 0x05D4;
  14560. t['afii57669'] = 0x05D5;
  14561. t['afii57670'] = 0x05D6;
  14562. t['afii57671'] = 0x05D7;
  14563. t['afii57672'] = 0x05D8;
  14564. t['afii57673'] = 0x05D9;
  14565. t['afii57674'] = 0x05DA;
  14566. t['afii57675'] = 0x05DB;
  14567. t['afii57676'] = 0x05DC;
  14568. t['afii57677'] = 0x05DD;
  14569. t['afii57678'] = 0x05DE;
  14570. t['afii57679'] = 0x05DF;
  14571. t['afii57680'] = 0x05E0;
  14572. t['afii57681'] = 0x05E1;
  14573. t['afii57682'] = 0x05E2;
  14574. t['afii57683'] = 0x05E3;
  14575. t['afii57684'] = 0x05E4;
  14576. t['afii57685'] = 0x05E5;
  14577. t['afii57686'] = 0x05E6;
  14578. t['afii57687'] = 0x05E7;
  14579. t['afii57688'] = 0x05E8;
  14580. t['afii57689'] = 0x05E9;
  14581. t['afii57690'] = 0x05EA;
  14582. t['afii57694'] = 0xFB2A;
  14583. t['afii57695'] = 0xFB2B;
  14584. t['afii57700'] = 0xFB4B;
  14585. t['afii57705'] = 0xFB1F;
  14586. t['afii57716'] = 0x05F0;
  14587. t['afii57717'] = 0x05F1;
  14588. t['afii57718'] = 0x05F2;
  14589. t['afii57723'] = 0xFB35;
  14590. t['afii57793'] = 0x05B4;
  14591. t['afii57794'] = 0x05B5;
  14592. t['afii57795'] = 0x05B6;
  14593. t['afii57796'] = 0x05BB;
  14594. t['afii57797'] = 0x05B8;
  14595. t['afii57798'] = 0x05B7;
  14596. t['afii57799'] = 0x05B0;
  14597. t['afii57800'] = 0x05B2;
  14598. t['afii57801'] = 0x05B1;
  14599. t['afii57802'] = 0x05B3;
  14600. t['afii57803'] = 0x05C2;
  14601. t['afii57804'] = 0x05C1;
  14602. t['afii57806'] = 0x05B9;
  14603. t['afii57807'] = 0x05BC;
  14604. t['afii57839'] = 0x05BD;
  14605. t['afii57841'] = 0x05BF;
  14606. t['afii57842'] = 0x05C0;
  14607. t['afii57929'] = 0x02BC;
  14608. t['afii61248'] = 0x2105;
  14609. t['afii61289'] = 0x2113;
  14610. t['afii61352'] = 0x2116;
  14611. t['afii61573'] = 0x202C;
  14612. t['afii61574'] = 0x202D;
  14613. t['afii61575'] = 0x202E;
  14614. t['afii61664'] = 0x200C;
  14615. t['afii63167'] = 0x066D;
  14616. t['afii64937'] = 0x02BD;
  14617. t['agrave'] = 0x00E0;
  14618. t['agujarati'] = 0x0A85;
  14619. t['agurmukhi'] = 0x0A05;
  14620. t['ahiragana'] = 0x3042;
  14621. t['ahookabove'] = 0x1EA3;
  14622. t['aibengali'] = 0x0990;
  14623. t['aibopomofo'] = 0x311E;
  14624. t['aideva'] = 0x0910;
  14625. t['aiecyrillic'] = 0x04D5;
  14626. t['aigujarati'] = 0x0A90;
  14627. t['aigurmukhi'] = 0x0A10;
  14628. t['aimatragurmukhi'] = 0x0A48;
  14629. t['ainarabic'] = 0x0639;
  14630. t['ainfinalarabic'] = 0xFECA;
  14631. t['aininitialarabic'] = 0xFECB;
  14632. t['ainmedialarabic'] = 0xFECC;
  14633. t['ainvertedbreve'] = 0x0203;
  14634. t['aivowelsignbengali'] = 0x09C8;
  14635. t['aivowelsigndeva'] = 0x0948;
  14636. t['aivowelsigngujarati'] = 0x0AC8;
  14637. t['akatakana'] = 0x30A2;
  14638. t['akatakanahalfwidth'] = 0xFF71;
  14639. t['akorean'] = 0x314F;
  14640. t['alef'] = 0x05D0;
  14641. t['alefarabic'] = 0x0627;
  14642. t['alefdageshhebrew'] = 0xFB30;
  14643. t['aleffinalarabic'] = 0xFE8E;
  14644. t['alefhamzaabovearabic'] = 0x0623;
  14645. t['alefhamzaabovefinalarabic'] = 0xFE84;
  14646. t['alefhamzabelowarabic'] = 0x0625;
  14647. t['alefhamzabelowfinalarabic'] = 0xFE88;
  14648. t['alefhebrew'] = 0x05D0;
  14649. t['aleflamedhebrew'] = 0xFB4F;
  14650. t['alefmaddaabovearabic'] = 0x0622;
  14651. t['alefmaddaabovefinalarabic'] = 0xFE82;
  14652. t['alefmaksuraarabic'] = 0x0649;
  14653. t['alefmaksurafinalarabic'] = 0xFEF0;
  14654. t['alefmaksurainitialarabic'] = 0xFEF3;
  14655. t['alefmaksuramedialarabic'] = 0xFEF4;
  14656. t['alefpatahhebrew'] = 0xFB2E;
  14657. t['alefqamatshebrew'] = 0xFB2F;
  14658. t['aleph'] = 0x2135;
  14659. t['allequal'] = 0x224C;
  14660. t['alpha'] = 0x03B1;
  14661. t['alphatonos'] = 0x03AC;
  14662. t['amacron'] = 0x0101;
  14663. t['amonospace'] = 0xFF41;
  14664. t['ampersand'] = 0x0026;
  14665. t['ampersandmonospace'] = 0xFF06;
  14666. t['ampersandsmall'] = 0xF726;
  14667. t['amsquare'] = 0x33C2;
  14668. t['anbopomofo'] = 0x3122;
  14669. t['angbopomofo'] = 0x3124;
  14670. t['angbracketleft'] = 0x3008;
  14671. t['angbracketright'] = 0x3009;
  14672. t['angkhankhuthai'] = 0x0E5A;
  14673. t['angle'] = 0x2220;
  14674. t['anglebracketleft'] = 0x3008;
  14675. t['anglebracketleftvertical'] = 0xFE3F;
  14676. t['anglebracketright'] = 0x3009;
  14677. t['anglebracketrightvertical'] = 0xFE40;
  14678. t['angleleft'] = 0x2329;
  14679. t['angleright'] = 0x232A;
  14680. t['angstrom'] = 0x212B;
  14681. t['anoteleia'] = 0x0387;
  14682. t['anudattadeva'] = 0x0952;
  14683. t['anusvarabengali'] = 0x0982;
  14684. t['anusvaradeva'] = 0x0902;
  14685. t['anusvaragujarati'] = 0x0A82;
  14686. t['aogonek'] = 0x0105;
  14687. t['apaatosquare'] = 0x3300;
  14688. t['aparen'] = 0x249C;
  14689. t['apostrophearmenian'] = 0x055A;
  14690. t['apostrophemod'] = 0x02BC;
  14691. t['apple'] = 0xF8FF;
  14692. t['approaches'] = 0x2250;
  14693. t['approxequal'] = 0x2248;
  14694. t['approxequalorimage'] = 0x2252;
  14695. t['approximatelyequal'] = 0x2245;
  14696. t['araeaekorean'] = 0x318E;
  14697. t['araeakorean'] = 0x318D;
  14698. t['arc'] = 0x2312;
  14699. t['arighthalfring'] = 0x1E9A;
  14700. t['aring'] = 0x00E5;
  14701. t['aringacute'] = 0x01FB;
  14702. t['aringbelow'] = 0x1E01;
  14703. t['arrowboth'] = 0x2194;
  14704. t['arrowdashdown'] = 0x21E3;
  14705. t['arrowdashleft'] = 0x21E0;
  14706. t['arrowdashright'] = 0x21E2;
  14707. t['arrowdashup'] = 0x21E1;
  14708. t['arrowdblboth'] = 0x21D4;
  14709. t['arrowdbldown'] = 0x21D3;
  14710. t['arrowdblleft'] = 0x21D0;
  14711. t['arrowdblright'] = 0x21D2;
  14712. t['arrowdblup'] = 0x21D1;
  14713. t['arrowdown'] = 0x2193;
  14714. t['arrowdownleft'] = 0x2199;
  14715. t['arrowdownright'] = 0x2198;
  14716. t['arrowdownwhite'] = 0x21E9;
  14717. t['arrowheaddownmod'] = 0x02C5;
  14718. t['arrowheadleftmod'] = 0x02C2;
  14719. t['arrowheadrightmod'] = 0x02C3;
  14720. t['arrowheadupmod'] = 0x02C4;
  14721. t['arrowhorizex'] = 0xF8E7;
  14722. t['arrowleft'] = 0x2190;
  14723. t['arrowleftdbl'] = 0x21D0;
  14724. t['arrowleftdblstroke'] = 0x21CD;
  14725. t['arrowleftoverright'] = 0x21C6;
  14726. t['arrowleftwhite'] = 0x21E6;
  14727. t['arrowright'] = 0x2192;
  14728. t['arrowrightdblstroke'] = 0x21CF;
  14729. t['arrowrightheavy'] = 0x279E;
  14730. t['arrowrightoverleft'] = 0x21C4;
  14731. t['arrowrightwhite'] = 0x21E8;
  14732. t['arrowtableft'] = 0x21E4;
  14733. t['arrowtabright'] = 0x21E5;
  14734. t['arrowup'] = 0x2191;
  14735. t['arrowupdn'] = 0x2195;
  14736. t['arrowupdnbse'] = 0x21A8;
  14737. t['arrowupdownbase'] = 0x21A8;
  14738. t['arrowupleft'] = 0x2196;
  14739. t['arrowupleftofdown'] = 0x21C5;
  14740. t['arrowupright'] = 0x2197;
  14741. t['arrowupwhite'] = 0x21E7;
  14742. t['arrowvertex'] = 0xF8E6;
  14743. t['asciicircum'] = 0x005E;
  14744. t['asciicircummonospace'] = 0xFF3E;
  14745. t['asciitilde'] = 0x007E;
  14746. t['asciitildemonospace'] = 0xFF5E;
  14747. t['ascript'] = 0x0251;
  14748. t['ascriptturned'] = 0x0252;
  14749. t['asmallhiragana'] = 0x3041;
  14750. t['asmallkatakana'] = 0x30A1;
  14751. t['asmallkatakanahalfwidth'] = 0xFF67;
  14752. t['asterisk'] = 0x002A;
  14753. t['asteriskaltonearabic'] = 0x066D;
  14754. t['asteriskarabic'] = 0x066D;
  14755. t['asteriskmath'] = 0x2217;
  14756. t['asteriskmonospace'] = 0xFF0A;
  14757. t['asterisksmall'] = 0xFE61;
  14758. t['asterism'] = 0x2042;
  14759. t['asuperior'] = 0xF6E9;
  14760. t['asymptoticallyequal'] = 0x2243;
  14761. t['at'] = 0x0040;
  14762. t['atilde'] = 0x00E3;
  14763. t['atmonospace'] = 0xFF20;
  14764. t['atsmall'] = 0xFE6B;
  14765. t['aturned'] = 0x0250;
  14766. t['aubengali'] = 0x0994;
  14767. t['aubopomofo'] = 0x3120;
  14768. t['audeva'] = 0x0914;
  14769. t['augujarati'] = 0x0A94;
  14770. t['augurmukhi'] = 0x0A14;
  14771. t['aulengthmarkbengali'] = 0x09D7;
  14772. t['aumatragurmukhi'] = 0x0A4C;
  14773. t['auvowelsignbengali'] = 0x09CC;
  14774. t['auvowelsigndeva'] = 0x094C;
  14775. t['auvowelsigngujarati'] = 0x0ACC;
  14776. t['avagrahadeva'] = 0x093D;
  14777. t['aybarmenian'] = 0x0561;
  14778. t['ayin'] = 0x05E2;
  14779. t['ayinaltonehebrew'] = 0xFB20;
  14780. t['ayinhebrew'] = 0x05E2;
  14781. t['b'] = 0x0062;
  14782. t['babengali'] = 0x09AC;
  14783. t['backslash'] = 0x005C;
  14784. t['backslashmonospace'] = 0xFF3C;
  14785. t['badeva'] = 0x092C;
  14786. t['bagujarati'] = 0x0AAC;
  14787. t['bagurmukhi'] = 0x0A2C;
  14788. t['bahiragana'] = 0x3070;
  14789. t['bahtthai'] = 0x0E3F;
  14790. t['bakatakana'] = 0x30D0;
  14791. t['bar'] = 0x007C;
  14792. t['barmonospace'] = 0xFF5C;
  14793. t['bbopomofo'] = 0x3105;
  14794. t['bcircle'] = 0x24D1;
  14795. t['bdotaccent'] = 0x1E03;
  14796. t['bdotbelow'] = 0x1E05;
  14797. t['beamedsixteenthnotes'] = 0x266C;
  14798. t['because'] = 0x2235;
  14799. t['becyrillic'] = 0x0431;
  14800. t['beharabic'] = 0x0628;
  14801. t['behfinalarabic'] = 0xFE90;
  14802. t['behinitialarabic'] = 0xFE91;
  14803. t['behiragana'] = 0x3079;
  14804. t['behmedialarabic'] = 0xFE92;
  14805. t['behmeeminitialarabic'] = 0xFC9F;
  14806. t['behmeemisolatedarabic'] = 0xFC08;
  14807. t['behnoonfinalarabic'] = 0xFC6D;
  14808. t['bekatakana'] = 0x30D9;
  14809. t['benarmenian'] = 0x0562;
  14810. t['bet'] = 0x05D1;
  14811. t['beta'] = 0x03B2;
  14812. t['betasymbolgreek'] = 0x03D0;
  14813. t['betdagesh'] = 0xFB31;
  14814. t['betdageshhebrew'] = 0xFB31;
  14815. t['bethebrew'] = 0x05D1;
  14816. t['betrafehebrew'] = 0xFB4C;
  14817. t['bhabengali'] = 0x09AD;
  14818. t['bhadeva'] = 0x092D;
  14819. t['bhagujarati'] = 0x0AAD;
  14820. t['bhagurmukhi'] = 0x0A2D;
  14821. t['bhook'] = 0x0253;
  14822. t['bihiragana'] = 0x3073;
  14823. t['bikatakana'] = 0x30D3;
  14824. t['bilabialclick'] = 0x0298;
  14825. t['bindigurmukhi'] = 0x0A02;
  14826. t['birusquare'] = 0x3331;
  14827. t['blackcircle'] = 0x25CF;
  14828. t['blackdiamond'] = 0x25C6;
  14829. t['blackdownpointingtriangle'] = 0x25BC;
  14830. t['blackleftpointingpointer'] = 0x25C4;
  14831. t['blackleftpointingtriangle'] = 0x25C0;
  14832. t['blacklenticularbracketleft'] = 0x3010;
  14833. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  14834. t['blacklenticularbracketright'] = 0x3011;
  14835. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  14836. t['blacklowerlefttriangle'] = 0x25E3;
  14837. t['blacklowerrighttriangle'] = 0x25E2;
  14838. t['blackrectangle'] = 0x25AC;
  14839. t['blackrightpointingpointer'] = 0x25BA;
  14840. t['blackrightpointingtriangle'] = 0x25B6;
  14841. t['blacksmallsquare'] = 0x25AA;
  14842. t['blacksmilingface'] = 0x263B;
  14843. t['blacksquare'] = 0x25A0;
  14844. t['blackstar'] = 0x2605;
  14845. t['blackupperlefttriangle'] = 0x25E4;
  14846. t['blackupperrighttriangle'] = 0x25E5;
  14847. t['blackuppointingsmalltriangle'] = 0x25B4;
  14848. t['blackuppointingtriangle'] = 0x25B2;
  14849. t['blank'] = 0x2423;
  14850. t['blinebelow'] = 0x1E07;
  14851. t['block'] = 0x2588;
  14852. t['bmonospace'] = 0xFF42;
  14853. t['bobaimaithai'] = 0x0E1A;
  14854. t['bohiragana'] = 0x307C;
  14855. t['bokatakana'] = 0x30DC;
  14856. t['bparen'] = 0x249D;
  14857. t['bqsquare'] = 0x33C3;
  14858. t['braceex'] = 0xF8F4;
  14859. t['braceleft'] = 0x007B;
  14860. t['braceleftbt'] = 0xF8F3;
  14861. t['braceleftmid'] = 0xF8F2;
  14862. t['braceleftmonospace'] = 0xFF5B;
  14863. t['braceleftsmall'] = 0xFE5B;
  14864. t['bracelefttp'] = 0xF8F1;
  14865. t['braceleftvertical'] = 0xFE37;
  14866. t['braceright'] = 0x007D;
  14867. t['bracerightbt'] = 0xF8FE;
  14868. t['bracerightmid'] = 0xF8FD;
  14869. t['bracerightmonospace'] = 0xFF5D;
  14870. t['bracerightsmall'] = 0xFE5C;
  14871. t['bracerighttp'] = 0xF8FC;
  14872. t['bracerightvertical'] = 0xFE38;
  14873. t['bracketleft'] = 0x005B;
  14874. t['bracketleftbt'] = 0xF8F0;
  14875. t['bracketleftex'] = 0xF8EF;
  14876. t['bracketleftmonospace'] = 0xFF3B;
  14877. t['bracketlefttp'] = 0xF8EE;
  14878. t['bracketright'] = 0x005D;
  14879. t['bracketrightbt'] = 0xF8FB;
  14880. t['bracketrightex'] = 0xF8FA;
  14881. t['bracketrightmonospace'] = 0xFF3D;
  14882. t['bracketrighttp'] = 0xF8F9;
  14883. t['breve'] = 0x02D8;
  14884. t['brevebelowcmb'] = 0x032E;
  14885. t['brevecmb'] = 0x0306;
  14886. t['breveinvertedbelowcmb'] = 0x032F;
  14887. t['breveinvertedcmb'] = 0x0311;
  14888. t['breveinverteddoublecmb'] = 0x0361;
  14889. t['bridgebelowcmb'] = 0x032A;
  14890. t['bridgeinvertedbelowcmb'] = 0x033A;
  14891. t['brokenbar'] = 0x00A6;
  14892. t['bstroke'] = 0x0180;
  14893. t['bsuperior'] = 0xF6EA;
  14894. t['btopbar'] = 0x0183;
  14895. t['buhiragana'] = 0x3076;
  14896. t['bukatakana'] = 0x30D6;
  14897. t['bullet'] = 0x2022;
  14898. t['bulletinverse'] = 0x25D8;
  14899. t['bulletoperator'] = 0x2219;
  14900. t['bullseye'] = 0x25CE;
  14901. t['c'] = 0x0063;
  14902. t['caarmenian'] = 0x056E;
  14903. t['cabengali'] = 0x099A;
  14904. t['cacute'] = 0x0107;
  14905. t['cadeva'] = 0x091A;
  14906. t['cagujarati'] = 0x0A9A;
  14907. t['cagurmukhi'] = 0x0A1A;
  14908. t['calsquare'] = 0x3388;
  14909. t['candrabindubengali'] = 0x0981;
  14910. t['candrabinducmb'] = 0x0310;
  14911. t['candrabindudeva'] = 0x0901;
  14912. t['candrabindugujarati'] = 0x0A81;
  14913. t['capslock'] = 0x21EA;
  14914. t['careof'] = 0x2105;
  14915. t['caron'] = 0x02C7;
  14916. t['caronbelowcmb'] = 0x032C;
  14917. t['caroncmb'] = 0x030C;
  14918. t['carriagereturn'] = 0x21B5;
  14919. t['cbopomofo'] = 0x3118;
  14920. t['ccaron'] = 0x010D;
  14921. t['ccedilla'] = 0x00E7;
  14922. t['ccedillaacute'] = 0x1E09;
  14923. t['ccircle'] = 0x24D2;
  14924. t['ccircumflex'] = 0x0109;
  14925. t['ccurl'] = 0x0255;
  14926. t['cdot'] = 0x010B;
  14927. t['cdotaccent'] = 0x010B;
  14928. t['cdsquare'] = 0x33C5;
  14929. t['cedilla'] = 0x00B8;
  14930. t['cedillacmb'] = 0x0327;
  14931. t['cent'] = 0x00A2;
  14932. t['centigrade'] = 0x2103;
  14933. t['centinferior'] = 0xF6DF;
  14934. t['centmonospace'] = 0xFFE0;
  14935. t['centoldstyle'] = 0xF7A2;
  14936. t['centsuperior'] = 0xF6E0;
  14937. t['chaarmenian'] = 0x0579;
  14938. t['chabengali'] = 0x099B;
  14939. t['chadeva'] = 0x091B;
  14940. t['chagujarati'] = 0x0A9B;
  14941. t['chagurmukhi'] = 0x0A1B;
  14942. t['chbopomofo'] = 0x3114;
  14943. t['cheabkhasiancyrillic'] = 0x04BD;
  14944. t['checkmark'] = 0x2713;
  14945. t['checyrillic'] = 0x0447;
  14946. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  14947. t['chedescendercyrillic'] = 0x04B7;
  14948. t['chedieresiscyrillic'] = 0x04F5;
  14949. t['cheharmenian'] = 0x0573;
  14950. t['chekhakassiancyrillic'] = 0x04CC;
  14951. t['cheverticalstrokecyrillic'] = 0x04B9;
  14952. t['chi'] = 0x03C7;
  14953. t['chieuchacirclekorean'] = 0x3277;
  14954. t['chieuchaparenkorean'] = 0x3217;
  14955. t['chieuchcirclekorean'] = 0x3269;
  14956. t['chieuchkorean'] = 0x314A;
  14957. t['chieuchparenkorean'] = 0x3209;
  14958. t['chochangthai'] = 0x0E0A;
  14959. t['chochanthai'] = 0x0E08;
  14960. t['chochingthai'] = 0x0E09;
  14961. t['chochoethai'] = 0x0E0C;
  14962. t['chook'] = 0x0188;
  14963. t['cieucacirclekorean'] = 0x3276;
  14964. t['cieucaparenkorean'] = 0x3216;
  14965. t['cieuccirclekorean'] = 0x3268;
  14966. t['cieuckorean'] = 0x3148;
  14967. t['cieucparenkorean'] = 0x3208;
  14968. t['cieucuparenkorean'] = 0x321C;
  14969. t['circle'] = 0x25CB;
  14970. t['circlecopyrt'] = 0x00A9;
  14971. t['circlemultiply'] = 0x2297;
  14972. t['circleot'] = 0x2299;
  14973. t['circleplus'] = 0x2295;
  14974. t['circlepostalmark'] = 0x3036;
  14975. t['circlewithlefthalfblack'] = 0x25D0;
  14976. t['circlewithrighthalfblack'] = 0x25D1;
  14977. t['circumflex'] = 0x02C6;
  14978. t['circumflexbelowcmb'] = 0x032D;
  14979. t['circumflexcmb'] = 0x0302;
  14980. t['clear'] = 0x2327;
  14981. t['clickalveolar'] = 0x01C2;
  14982. t['clickdental'] = 0x01C0;
  14983. t['clicklateral'] = 0x01C1;
  14984. t['clickretroflex'] = 0x01C3;
  14985. t['club'] = 0x2663;
  14986. t['clubsuitblack'] = 0x2663;
  14987. t['clubsuitwhite'] = 0x2667;
  14988. t['cmcubedsquare'] = 0x33A4;
  14989. t['cmonospace'] = 0xFF43;
  14990. t['cmsquaredsquare'] = 0x33A0;
  14991. t['coarmenian'] = 0x0581;
  14992. t['colon'] = 0x003A;
  14993. t['colonmonetary'] = 0x20A1;
  14994. t['colonmonospace'] = 0xFF1A;
  14995. t['colonsign'] = 0x20A1;
  14996. t['colonsmall'] = 0xFE55;
  14997. t['colontriangularhalfmod'] = 0x02D1;
  14998. t['colontriangularmod'] = 0x02D0;
  14999. t['comma'] = 0x002C;
  15000. t['commaabovecmb'] = 0x0313;
  15001. t['commaaboverightcmb'] = 0x0315;
  15002. t['commaaccent'] = 0xF6C3;
  15003. t['commaarabic'] = 0x060C;
  15004. t['commaarmenian'] = 0x055D;
  15005. t['commainferior'] = 0xF6E1;
  15006. t['commamonospace'] = 0xFF0C;
  15007. t['commareversedabovecmb'] = 0x0314;
  15008. t['commareversedmod'] = 0x02BD;
  15009. t['commasmall'] = 0xFE50;
  15010. t['commasuperior'] = 0xF6E2;
  15011. t['commaturnedabovecmb'] = 0x0312;
  15012. t['commaturnedmod'] = 0x02BB;
  15013. t['compass'] = 0x263C;
  15014. t['congruent'] = 0x2245;
  15015. t['contourintegral'] = 0x222E;
  15016. t['control'] = 0x2303;
  15017. t['controlACK'] = 0x0006;
  15018. t['controlBEL'] = 0x0007;
  15019. t['controlBS'] = 0x0008;
  15020. t['controlCAN'] = 0x0018;
  15021. t['controlCR'] = 0x000D;
  15022. t['controlDC1'] = 0x0011;
  15023. t['controlDC2'] = 0x0012;
  15024. t['controlDC3'] = 0x0013;
  15025. t['controlDC4'] = 0x0014;
  15026. t['controlDEL'] = 0x007F;
  15027. t['controlDLE'] = 0x0010;
  15028. t['controlEM'] = 0x0019;
  15029. t['controlENQ'] = 0x0005;
  15030. t['controlEOT'] = 0x0004;
  15031. t['controlESC'] = 0x001B;
  15032. t['controlETB'] = 0x0017;
  15033. t['controlETX'] = 0x0003;
  15034. t['controlFF'] = 0x000C;
  15035. t['controlFS'] = 0x001C;
  15036. t['controlGS'] = 0x001D;
  15037. t['controlHT'] = 0x0009;
  15038. t['controlLF'] = 0x000A;
  15039. t['controlNAK'] = 0x0015;
  15040. t['controlNULL'] = 0x0000;
  15041. t['controlRS'] = 0x001E;
  15042. t['controlSI'] = 0x000F;
  15043. t['controlSO'] = 0x000E;
  15044. t['controlSOT'] = 0x0002;
  15045. t['controlSTX'] = 0x0001;
  15046. t['controlSUB'] = 0x001A;
  15047. t['controlSYN'] = 0x0016;
  15048. t['controlUS'] = 0x001F;
  15049. t['controlVT'] = 0x000B;
  15050. t['copyright'] = 0x00A9;
  15051. t['copyrightsans'] = 0xF8E9;
  15052. t['copyrightserif'] = 0xF6D9;
  15053. t['cornerbracketleft'] = 0x300C;
  15054. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15055. t['cornerbracketleftvertical'] = 0xFE41;
  15056. t['cornerbracketright'] = 0x300D;
  15057. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15058. t['cornerbracketrightvertical'] = 0xFE42;
  15059. t['corporationsquare'] = 0x337F;
  15060. t['cosquare'] = 0x33C7;
  15061. t['coverkgsquare'] = 0x33C6;
  15062. t['cparen'] = 0x249E;
  15063. t['cruzeiro'] = 0x20A2;
  15064. t['cstretched'] = 0x0297;
  15065. t['curlyand'] = 0x22CF;
  15066. t['curlyor'] = 0x22CE;
  15067. t['currency'] = 0x00A4;
  15068. t['cyrBreve'] = 0xF6D1;
  15069. t['cyrFlex'] = 0xF6D2;
  15070. t['cyrbreve'] = 0xF6D4;
  15071. t['cyrflex'] = 0xF6D5;
  15072. t['d'] = 0x0064;
  15073. t['daarmenian'] = 0x0564;
  15074. t['dabengali'] = 0x09A6;
  15075. t['dadarabic'] = 0x0636;
  15076. t['dadeva'] = 0x0926;
  15077. t['dadfinalarabic'] = 0xFEBE;
  15078. t['dadinitialarabic'] = 0xFEBF;
  15079. t['dadmedialarabic'] = 0xFEC0;
  15080. t['dagesh'] = 0x05BC;
  15081. t['dageshhebrew'] = 0x05BC;
  15082. t['dagger'] = 0x2020;
  15083. t['daggerdbl'] = 0x2021;
  15084. t['dagujarati'] = 0x0AA6;
  15085. t['dagurmukhi'] = 0x0A26;
  15086. t['dahiragana'] = 0x3060;
  15087. t['dakatakana'] = 0x30C0;
  15088. t['dalarabic'] = 0x062F;
  15089. t['dalet'] = 0x05D3;
  15090. t['daletdagesh'] = 0xFB33;
  15091. t['daletdageshhebrew'] = 0xFB33;
  15092. t['dalethebrew'] = 0x05D3;
  15093. t['dalfinalarabic'] = 0xFEAA;
  15094. t['dammaarabic'] = 0x064F;
  15095. t['dammalowarabic'] = 0x064F;
  15096. t['dammatanaltonearabic'] = 0x064C;
  15097. t['dammatanarabic'] = 0x064C;
  15098. t['danda'] = 0x0964;
  15099. t['dargahebrew'] = 0x05A7;
  15100. t['dargalefthebrew'] = 0x05A7;
  15101. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15102. t['dblGrave'] = 0xF6D3;
  15103. t['dblanglebracketleft'] = 0x300A;
  15104. t['dblanglebracketleftvertical'] = 0xFE3D;
  15105. t['dblanglebracketright'] = 0x300B;
  15106. t['dblanglebracketrightvertical'] = 0xFE3E;
  15107. t['dblarchinvertedbelowcmb'] = 0x032B;
  15108. t['dblarrowleft'] = 0x21D4;
  15109. t['dblarrowright'] = 0x21D2;
  15110. t['dbldanda'] = 0x0965;
  15111. t['dblgrave'] = 0xF6D6;
  15112. t['dblgravecmb'] = 0x030F;
  15113. t['dblintegral'] = 0x222C;
  15114. t['dbllowline'] = 0x2017;
  15115. t['dbllowlinecmb'] = 0x0333;
  15116. t['dbloverlinecmb'] = 0x033F;
  15117. t['dblprimemod'] = 0x02BA;
  15118. t['dblverticalbar'] = 0x2016;
  15119. t['dblverticallineabovecmb'] = 0x030E;
  15120. t['dbopomofo'] = 0x3109;
  15121. t['dbsquare'] = 0x33C8;
  15122. t['dcaron'] = 0x010F;
  15123. t['dcedilla'] = 0x1E11;
  15124. t['dcircle'] = 0x24D3;
  15125. t['dcircumflexbelow'] = 0x1E13;
  15126. t['dcroat'] = 0x0111;
  15127. t['ddabengali'] = 0x09A1;
  15128. t['ddadeva'] = 0x0921;
  15129. t['ddagujarati'] = 0x0AA1;
  15130. t['ddagurmukhi'] = 0x0A21;
  15131. t['ddalarabic'] = 0x0688;
  15132. t['ddalfinalarabic'] = 0xFB89;
  15133. t['dddhadeva'] = 0x095C;
  15134. t['ddhabengali'] = 0x09A2;
  15135. t['ddhadeva'] = 0x0922;
  15136. t['ddhagujarati'] = 0x0AA2;
  15137. t['ddhagurmukhi'] = 0x0A22;
  15138. t['ddotaccent'] = 0x1E0B;
  15139. t['ddotbelow'] = 0x1E0D;
  15140. t['decimalseparatorarabic'] = 0x066B;
  15141. t['decimalseparatorpersian'] = 0x066B;
  15142. t['decyrillic'] = 0x0434;
  15143. t['degree'] = 0x00B0;
  15144. t['dehihebrew'] = 0x05AD;
  15145. t['dehiragana'] = 0x3067;
  15146. t['deicoptic'] = 0x03EF;
  15147. t['dekatakana'] = 0x30C7;
  15148. t['deleteleft'] = 0x232B;
  15149. t['deleteright'] = 0x2326;
  15150. t['delta'] = 0x03B4;
  15151. t['deltaturned'] = 0x018D;
  15152. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15153. t['dezh'] = 0x02A4;
  15154. t['dhabengali'] = 0x09A7;
  15155. t['dhadeva'] = 0x0927;
  15156. t['dhagujarati'] = 0x0AA7;
  15157. t['dhagurmukhi'] = 0x0A27;
  15158. t['dhook'] = 0x0257;
  15159. t['dialytikatonos'] = 0x0385;
  15160. t['dialytikatonoscmb'] = 0x0344;
  15161. t['diamond'] = 0x2666;
  15162. t['diamondsuitwhite'] = 0x2662;
  15163. t['dieresis'] = 0x00A8;
  15164. t['dieresisacute'] = 0xF6D7;
  15165. t['dieresisbelowcmb'] = 0x0324;
  15166. t['dieresiscmb'] = 0x0308;
  15167. t['dieresisgrave'] = 0xF6D8;
  15168. t['dieresistonos'] = 0x0385;
  15169. t['dihiragana'] = 0x3062;
  15170. t['dikatakana'] = 0x30C2;
  15171. t['dittomark'] = 0x3003;
  15172. t['divide'] = 0x00F7;
  15173. t['divides'] = 0x2223;
  15174. t['divisionslash'] = 0x2215;
  15175. t['djecyrillic'] = 0x0452;
  15176. t['dkshade'] = 0x2593;
  15177. t['dlinebelow'] = 0x1E0F;
  15178. t['dlsquare'] = 0x3397;
  15179. t['dmacron'] = 0x0111;
  15180. t['dmonospace'] = 0xFF44;
  15181. t['dnblock'] = 0x2584;
  15182. t['dochadathai'] = 0x0E0E;
  15183. t['dodekthai'] = 0x0E14;
  15184. t['dohiragana'] = 0x3069;
  15185. t['dokatakana'] = 0x30C9;
  15186. t['dollar'] = 0x0024;
  15187. t['dollarinferior'] = 0xF6E3;
  15188. t['dollarmonospace'] = 0xFF04;
  15189. t['dollaroldstyle'] = 0xF724;
  15190. t['dollarsmall'] = 0xFE69;
  15191. t['dollarsuperior'] = 0xF6E4;
  15192. t['dong'] = 0x20AB;
  15193. t['dorusquare'] = 0x3326;
  15194. t['dotaccent'] = 0x02D9;
  15195. t['dotaccentcmb'] = 0x0307;
  15196. t['dotbelowcmb'] = 0x0323;
  15197. t['dotbelowcomb'] = 0x0323;
  15198. t['dotkatakana'] = 0x30FB;
  15199. t['dotlessi'] = 0x0131;
  15200. t['dotlessj'] = 0xF6BE;
  15201. t['dotlessjstrokehook'] = 0x0284;
  15202. t['dotmath'] = 0x22C5;
  15203. t['dottedcircle'] = 0x25CC;
  15204. t['doubleyodpatah'] = 0xFB1F;
  15205. t['doubleyodpatahhebrew'] = 0xFB1F;
  15206. t['downtackbelowcmb'] = 0x031E;
  15207. t['downtackmod'] = 0x02D5;
  15208. t['dparen'] = 0x249F;
  15209. t['dsuperior'] = 0xF6EB;
  15210. t['dtail'] = 0x0256;
  15211. t['dtopbar'] = 0x018C;
  15212. t['duhiragana'] = 0x3065;
  15213. t['dukatakana'] = 0x30C5;
  15214. t['dz'] = 0x01F3;
  15215. t['dzaltone'] = 0x02A3;
  15216. t['dzcaron'] = 0x01C6;
  15217. t['dzcurl'] = 0x02A5;
  15218. t['dzeabkhasiancyrillic'] = 0x04E1;
  15219. t['dzecyrillic'] = 0x0455;
  15220. t['dzhecyrillic'] = 0x045F;
  15221. t['e'] = 0x0065;
  15222. t['eacute'] = 0x00E9;
  15223. t['earth'] = 0x2641;
  15224. t['ebengali'] = 0x098F;
  15225. t['ebopomofo'] = 0x311C;
  15226. t['ebreve'] = 0x0115;
  15227. t['ecandradeva'] = 0x090D;
  15228. t['ecandragujarati'] = 0x0A8D;
  15229. t['ecandravowelsigndeva'] = 0x0945;
  15230. t['ecandravowelsigngujarati'] = 0x0AC5;
  15231. t['ecaron'] = 0x011B;
  15232. t['ecedillabreve'] = 0x1E1D;
  15233. t['echarmenian'] = 0x0565;
  15234. t['echyiwnarmenian'] = 0x0587;
  15235. t['ecircle'] = 0x24D4;
  15236. t['ecircumflex'] = 0x00EA;
  15237. t['ecircumflexacute'] = 0x1EBF;
  15238. t['ecircumflexbelow'] = 0x1E19;
  15239. t['ecircumflexdotbelow'] = 0x1EC7;
  15240. t['ecircumflexgrave'] = 0x1EC1;
  15241. t['ecircumflexhookabove'] = 0x1EC3;
  15242. t['ecircumflextilde'] = 0x1EC5;
  15243. t['ecyrillic'] = 0x0454;
  15244. t['edblgrave'] = 0x0205;
  15245. t['edeva'] = 0x090F;
  15246. t['edieresis'] = 0x00EB;
  15247. t['edot'] = 0x0117;
  15248. t['edotaccent'] = 0x0117;
  15249. t['edotbelow'] = 0x1EB9;
  15250. t['eegurmukhi'] = 0x0A0F;
  15251. t['eematragurmukhi'] = 0x0A47;
  15252. t['efcyrillic'] = 0x0444;
  15253. t['egrave'] = 0x00E8;
  15254. t['egujarati'] = 0x0A8F;
  15255. t['eharmenian'] = 0x0567;
  15256. t['ehbopomofo'] = 0x311D;
  15257. t['ehiragana'] = 0x3048;
  15258. t['ehookabove'] = 0x1EBB;
  15259. t['eibopomofo'] = 0x311F;
  15260. t['eight'] = 0x0038;
  15261. t['eightarabic'] = 0x0668;
  15262. t['eightbengali'] = 0x09EE;
  15263. t['eightcircle'] = 0x2467;
  15264. t['eightcircleinversesansserif'] = 0x2791;
  15265. t['eightdeva'] = 0x096E;
  15266. t['eighteencircle'] = 0x2471;
  15267. t['eighteenparen'] = 0x2485;
  15268. t['eighteenperiod'] = 0x2499;
  15269. t['eightgujarati'] = 0x0AEE;
  15270. t['eightgurmukhi'] = 0x0A6E;
  15271. t['eighthackarabic'] = 0x0668;
  15272. t['eighthangzhou'] = 0x3028;
  15273. t['eighthnotebeamed'] = 0x266B;
  15274. t['eightideographicparen'] = 0x3227;
  15275. t['eightinferior'] = 0x2088;
  15276. t['eightmonospace'] = 0xFF18;
  15277. t['eightoldstyle'] = 0xF738;
  15278. t['eightparen'] = 0x247B;
  15279. t['eightperiod'] = 0x248F;
  15280. t['eightpersian'] = 0x06F8;
  15281. t['eightroman'] = 0x2177;
  15282. t['eightsuperior'] = 0x2078;
  15283. t['eightthai'] = 0x0E58;
  15284. t['einvertedbreve'] = 0x0207;
  15285. t['eiotifiedcyrillic'] = 0x0465;
  15286. t['ekatakana'] = 0x30A8;
  15287. t['ekatakanahalfwidth'] = 0xFF74;
  15288. t['ekonkargurmukhi'] = 0x0A74;
  15289. t['ekorean'] = 0x3154;
  15290. t['elcyrillic'] = 0x043B;
  15291. t['element'] = 0x2208;
  15292. t['elevencircle'] = 0x246A;
  15293. t['elevenparen'] = 0x247E;
  15294. t['elevenperiod'] = 0x2492;
  15295. t['elevenroman'] = 0x217A;
  15296. t['ellipsis'] = 0x2026;
  15297. t['ellipsisvertical'] = 0x22EE;
  15298. t['emacron'] = 0x0113;
  15299. t['emacronacute'] = 0x1E17;
  15300. t['emacrongrave'] = 0x1E15;
  15301. t['emcyrillic'] = 0x043C;
  15302. t['emdash'] = 0x2014;
  15303. t['emdashvertical'] = 0xFE31;
  15304. t['emonospace'] = 0xFF45;
  15305. t['emphasismarkarmenian'] = 0x055B;
  15306. t['emptyset'] = 0x2205;
  15307. t['enbopomofo'] = 0x3123;
  15308. t['encyrillic'] = 0x043D;
  15309. t['endash'] = 0x2013;
  15310. t['endashvertical'] = 0xFE32;
  15311. t['endescendercyrillic'] = 0x04A3;
  15312. t['eng'] = 0x014B;
  15313. t['engbopomofo'] = 0x3125;
  15314. t['enghecyrillic'] = 0x04A5;
  15315. t['enhookcyrillic'] = 0x04C8;
  15316. t['enspace'] = 0x2002;
  15317. t['eogonek'] = 0x0119;
  15318. t['eokorean'] = 0x3153;
  15319. t['eopen'] = 0x025B;
  15320. t['eopenclosed'] = 0x029A;
  15321. t['eopenreversed'] = 0x025C;
  15322. t['eopenreversedclosed'] = 0x025E;
  15323. t['eopenreversedhook'] = 0x025D;
  15324. t['eparen'] = 0x24A0;
  15325. t['epsilon'] = 0x03B5;
  15326. t['epsilontonos'] = 0x03AD;
  15327. t['equal'] = 0x003D;
  15328. t['equalmonospace'] = 0xFF1D;
  15329. t['equalsmall'] = 0xFE66;
  15330. t['equalsuperior'] = 0x207C;
  15331. t['equivalence'] = 0x2261;
  15332. t['erbopomofo'] = 0x3126;
  15333. t['ercyrillic'] = 0x0440;
  15334. t['ereversed'] = 0x0258;
  15335. t['ereversedcyrillic'] = 0x044D;
  15336. t['escyrillic'] = 0x0441;
  15337. t['esdescendercyrillic'] = 0x04AB;
  15338. t['esh'] = 0x0283;
  15339. t['eshcurl'] = 0x0286;
  15340. t['eshortdeva'] = 0x090E;
  15341. t['eshortvowelsigndeva'] = 0x0946;
  15342. t['eshreversedloop'] = 0x01AA;
  15343. t['eshsquatreversed'] = 0x0285;
  15344. t['esmallhiragana'] = 0x3047;
  15345. t['esmallkatakana'] = 0x30A7;
  15346. t['esmallkatakanahalfwidth'] = 0xFF6A;
  15347. t['estimated'] = 0x212E;
  15348. t['esuperior'] = 0xF6EC;
  15349. t['eta'] = 0x03B7;
  15350. t['etarmenian'] = 0x0568;
  15351. t['etatonos'] = 0x03AE;
  15352. t['eth'] = 0x00F0;
  15353. t['etilde'] = 0x1EBD;
  15354. t['etildebelow'] = 0x1E1B;
  15355. t['etnahtafoukhhebrew'] = 0x0591;
  15356. t['etnahtafoukhlefthebrew'] = 0x0591;
  15357. t['etnahtahebrew'] = 0x0591;
  15358. t['etnahtalefthebrew'] = 0x0591;
  15359. t['eturned'] = 0x01DD;
  15360. t['eukorean'] = 0x3161;
  15361. t['euro'] = 0x20AC;
  15362. t['evowelsignbengali'] = 0x09C7;
  15363. t['evowelsigndeva'] = 0x0947;
  15364. t['evowelsigngujarati'] = 0x0AC7;
  15365. t['exclam'] = 0x0021;
  15366. t['exclamarmenian'] = 0x055C;
  15367. t['exclamdbl'] = 0x203C;
  15368. t['exclamdown'] = 0x00A1;
  15369. t['exclamdownsmall'] = 0xF7A1;
  15370. t['exclammonospace'] = 0xFF01;
  15371. t['exclamsmall'] = 0xF721;
  15372. t['existential'] = 0x2203;
  15373. t['ezh'] = 0x0292;
  15374. t['ezhcaron'] = 0x01EF;
  15375. t['ezhcurl'] = 0x0293;
  15376. t['ezhreversed'] = 0x01B9;
  15377. t['ezhtail'] = 0x01BA;
  15378. t['f'] = 0x0066;
  15379. t['fadeva'] = 0x095E;
  15380. t['fagurmukhi'] = 0x0A5E;
  15381. t['fahrenheit'] = 0x2109;
  15382. t['fathaarabic'] = 0x064E;
  15383. t['fathalowarabic'] = 0x064E;
  15384. t['fathatanarabic'] = 0x064B;
  15385. t['fbopomofo'] = 0x3108;
  15386. t['fcircle'] = 0x24D5;
  15387. t['fdotaccent'] = 0x1E1F;
  15388. t['feharabic'] = 0x0641;
  15389. t['feharmenian'] = 0x0586;
  15390. t['fehfinalarabic'] = 0xFED2;
  15391. t['fehinitialarabic'] = 0xFED3;
  15392. t['fehmedialarabic'] = 0xFED4;
  15393. t['feicoptic'] = 0x03E5;
  15394. t['female'] = 0x2640;
  15395. t['ff'] = 0xFB00;
  15396. t['ffi'] = 0xFB03;
  15397. t['ffl'] = 0xFB04;
  15398. t['fi'] = 0xFB01;
  15399. t['fifteencircle'] = 0x246E;
  15400. t['fifteenparen'] = 0x2482;
  15401. t['fifteenperiod'] = 0x2496;
  15402. t['figuredash'] = 0x2012;
  15403. t['filledbox'] = 0x25A0;
  15404. t['filledrect'] = 0x25AC;
  15405. t['finalkaf'] = 0x05DA;
  15406. t['finalkafdagesh'] = 0xFB3A;
  15407. t['finalkafdageshhebrew'] = 0xFB3A;
  15408. t['finalkafhebrew'] = 0x05DA;
  15409. t['finalmem'] = 0x05DD;
  15410. t['finalmemhebrew'] = 0x05DD;
  15411. t['finalnun'] = 0x05DF;
  15412. t['finalnunhebrew'] = 0x05DF;
  15413. t['finalpe'] = 0x05E3;
  15414. t['finalpehebrew'] = 0x05E3;
  15415. t['finaltsadi'] = 0x05E5;
  15416. t['finaltsadihebrew'] = 0x05E5;
  15417. t['firsttonechinese'] = 0x02C9;
  15418. t['fisheye'] = 0x25C9;
  15419. t['fitacyrillic'] = 0x0473;
  15420. t['five'] = 0x0035;
  15421. t['fivearabic'] = 0x0665;
  15422. t['fivebengali'] = 0x09EB;
  15423. t['fivecircle'] = 0x2464;
  15424. t['fivecircleinversesansserif'] = 0x278E;
  15425. t['fivedeva'] = 0x096B;
  15426. t['fiveeighths'] = 0x215D;
  15427. t['fivegujarati'] = 0x0AEB;
  15428. t['fivegurmukhi'] = 0x0A6B;
  15429. t['fivehackarabic'] = 0x0665;
  15430. t['fivehangzhou'] = 0x3025;
  15431. t['fiveideographicparen'] = 0x3224;
  15432. t['fiveinferior'] = 0x2085;
  15433. t['fivemonospace'] = 0xFF15;
  15434. t['fiveoldstyle'] = 0xF735;
  15435. t['fiveparen'] = 0x2478;
  15436. t['fiveperiod'] = 0x248C;
  15437. t['fivepersian'] = 0x06F5;
  15438. t['fiveroman'] = 0x2174;
  15439. t['fivesuperior'] = 0x2075;
  15440. t['fivethai'] = 0x0E55;
  15441. t['fl'] = 0xFB02;
  15442. t['florin'] = 0x0192;
  15443. t['fmonospace'] = 0xFF46;
  15444. t['fmsquare'] = 0x3399;
  15445. t['fofanthai'] = 0x0E1F;
  15446. t['fofathai'] = 0x0E1D;
  15447. t['fongmanthai'] = 0x0E4F;
  15448. t['forall'] = 0x2200;
  15449. t['four'] = 0x0034;
  15450. t['fourarabic'] = 0x0664;
  15451. t['fourbengali'] = 0x09EA;
  15452. t['fourcircle'] = 0x2463;
  15453. t['fourcircleinversesansserif'] = 0x278D;
  15454. t['fourdeva'] = 0x096A;
  15455. t['fourgujarati'] = 0x0AEA;
  15456. t['fourgurmukhi'] = 0x0A6A;
  15457. t['fourhackarabic'] = 0x0664;
  15458. t['fourhangzhou'] = 0x3024;
  15459. t['fourideographicparen'] = 0x3223;
  15460. t['fourinferior'] = 0x2084;
  15461. t['fourmonospace'] = 0xFF14;
  15462. t['fournumeratorbengali'] = 0x09F7;
  15463. t['fouroldstyle'] = 0xF734;
  15464. t['fourparen'] = 0x2477;
  15465. t['fourperiod'] = 0x248B;
  15466. t['fourpersian'] = 0x06F4;
  15467. t['fourroman'] = 0x2173;
  15468. t['foursuperior'] = 0x2074;
  15469. t['fourteencircle'] = 0x246D;
  15470. t['fourteenparen'] = 0x2481;
  15471. t['fourteenperiod'] = 0x2495;
  15472. t['fourthai'] = 0x0E54;
  15473. t['fourthtonechinese'] = 0x02CB;
  15474. t['fparen'] = 0x24A1;
  15475. t['fraction'] = 0x2044;
  15476. t['franc'] = 0x20A3;
  15477. t['g'] = 0x0067;
  15478. t['gabengali'] = 0x0997;
  15479. t['gacute'] = 0x01F5;
  15480. t['gadeva'] = 0x0917;
  15481. t['gafarabic'] = 0x06AF;
  15482. t['gaffinalarabic'] = 0xFB93;
  15483. t['gafinitialarabic'] = 0xFB94;
  15484. t['gafmedialarabic'] = 0xFB95;
  15485. t['gagujarati'] = 0x0A97;
  15486. t['gagurmukhi'] = 0x0A17;
  15487. t['gahiragana'] = 0x304C;
  15488. t['gakatakana'] = 0x30AC;
  15489. t['gamma'] = 0x03B3;
  15490. t['gammalatinsmall'] = 0x0263;
  15491. t['gammasuperior'] = 0x02E0;
  15492. t['gangiacoptic'] = 0x03EB;
  15493. t['gbopomofo'] = 0x310D;
  15494. t['gbreve'] = 0x011F;
  15495. t['gcaron'] = 0x01E7;
  15496. t['gcedilla'] = 0x0123;
  15497. t['gcircle'] = 0x24D6;
  15498. t['gcircumflex'] = 0x011D;
  15499. t['gcommaaccent'] = 0x0123;
  15500. t['gdot'] = 0x0121;
  15501. t['gdotaccent'] = 0x0121;
  15502. t['gecyrillic'] = 0x0433;
  15503. t['gehiragana'] = 0x3052;
  15504. t['gekatakana'] = 0x30B2;
  15505. t['geometricallyequal'] = 0x2251;
  15506. t['gereshaccenthebrew'] = 0x059C;
  15507. t['gereshhebrew'] = 0x05F3;
  15508. t['gereshmuqdamhebrew'] = 0x059D;
  15509. t['germandbls'] = 0x00DF;
  15510. t['gershayimaccenthebrew'] = 0x059E;
  15511. t['gershayimhebrew'] = 0x05F4;
  15512. t['getamark'] = 0x3013;
  15513. t['ghabengali'] = 0x0998;
  15514. t['ghadarmenian'] = 0x0572;
  15515. t['ghadeva'] = 0x0918;
  15516. t['ghagujarati'] = 0x0A98;
  15517. t['ghagurmukhi'] = 0x0A18;
  15518. t['ghainarabic'] = 0x063A;
  15519. t['ghainfinalarabic'] = 0xFECE;
  15520. t['ghaininitialarabic'] = 0xFECF;
  15521. t['ghainmedialarabic'] = 0xFED0;
  15522. t['ghemiddlehookcyrillic'] = 0x0495;
  15523. t['ghestrokecyrillic'] = 0x0493;
  15524. t['gheupturncyrillic'] = 0x0491;
  15525. t['ghhadeva'] = 0x095A;
  15526. t['ghhagurmukhi'] = 0x0A5A;
  15527. t['ghook'] = 0x0260;
  15528. t['ghzsquare'] = 0x3393;
  15529. t['gihiragana'] = 0x304E;
  15530. t['gikatakana'] = 0x30AE;
  15531. t['gimarmenian'] = 0x0563;
  15532. t['gimel'] = 0x05D2;
  15533. t['gimeldagesh'] = 0xFB32;
  15534. t['gimeldageshhebrew'] = 0xFB32;
  15535. t['gimelhebrew'] = 0x05D2;
  15536. t['gjecyrillic'] = 0x0453;
  15537. t['glottalinvertedstroke'] = 0x01BE;
  15538. t['glottalstop'] = 0x0294;
  15539. t['glottalstopinverted'] = 0x0296;
  15540. t['glottalstopmod'] = 0x02C0;
  15541. t['glottalstopreversed'] = 0x0295;
  15542. t['glottalstopreversedmod'] = 0x02C1;
  15543. t['glottalstopreversedsuperior'] = 0x02E4;
  15544. t['glottalstopstroke'] = 0x02A1;
  15545. t['glottalstopstrokereversed'] = 0x02A2;
  15546. t['gmacron'] = 0x1E21;
  15547. t['gmonospace'] = 0xFF47;
  15548. t['gohiragana'] = 0x3054;
  15549. t['gokatakana'] = 0x30B4;
  15550. t['gparen'] = 0x24A2;
  15551. t['gpasquare'] = 0x33AC;
  15552. t['gradient'] = 0x2207;
  15553. t['grave'] = 0x0060;
  15554. t['gravebelowcmb'] = 0x0316;
  15555. t['gravecmb'] = 0x0300;
  15556. t['gravecomb'] = 0x0300;
  15557. t['gravedeva'] = 0x0953;
  15558. t['gravelowmod'] = 0x02CE;
  15559. t['gravemonospace'] = 0xFF40;
  15560. t['gravetonecmb'] = 0x0340;
  15561. t['greater'] = 0x003E;
  15562. t['greaterequal'] = 0x2265;
  15563. t['greaterequalorless'] = 0x22DB;
  15564. t['greatermonospace'] = 0xFF1E;
  15565. t['greaterorequivalent'] = 0x2273;
  15566. t['greaterorless'] = 0x2277;
  15567. t['greateroverequal'] = 0x2267;
  15568. t['greatersmall'] = 0xFE65;
  15569. t['gscript'] = 0x0261;
  15570. t['gstroke'] = 0x01E5;
  15571. t['guhiragana'] = 0x3050;
  15572. t['guillemotleft'] = 0x00AB;
  15573. t['guillemotright'] = 0x00BB;
  15574. t['guilsinglleft'] = 0x2039;
  15575. t['guilsinglright'] = 0x203A;
  15576. t['gukatakana'] = 0x30B0;
  15577. t['guramusquare'] = 0x3318;
  15578. t['gysquare'] = 0x33C9;
  15579. t['h'] = 0x0068;
  15580. t['haabkhasiancyrillic'] = 0x04A9;
  15581. t['haaltonearabic'] = 0x06C1;
  15582. t['habengali'] = 0x09B9;
  15583. t['hadescendercyrillic'] = 0x04B3;
  15584. t['hadeva'] = 0x0939;
  15585. t['hagujarati'] = 0x0AB9;
  15586. t['hagurmukhi'] = 0x0A39;
  15587. t['haharabic'] = 0x062D;
  15588. t['hahfinalarabic'] = 0xFEA2;
  15589. t['hahinitialarabic'] = 0xFEA3;
  15590. t['hahiragana'] = 0x306F;
  15591. t['hahmedialarabic'] = 0xFEA4;
  15592. t['haitusquare'] = 0x332A;
  15593. t['hakatakana'] = 0x30CF;
  15594. t['hakatakanahalfwidth'] = 0xFF8A;
  15595. t['halantgurmukhi'] = 0x0A4D;
  15596. t['hamzaarabic'] = 0x0621;
  15597. t['hamzalowarabic'] = 0x0621;
  15598. t['hangulfiller'] = 0x3164;
  15599. t['hardsigncyrillic'] = 0x044A;
  15600. t['harpoonleftbarbup'] = 0x21BC;
  15601. t['harpoonrightbarbup'] = 0x21C0;
  15602. t['hasquare'] = 0x33CA;
  15603. t['hatafpatah'] = 0x05B2;
  15604. t['hatafpatah16'] = 0x05B2;
  15605. t['hatafpatah23'] = 0x05B2;
  15606. t['hatafpatah2f'] = 0x05B2;
  15607. t['hatafpatahhebrew'] = 0x05B2;
  15608. t['hatafpatahnarrowhebrew'] = 0x05B2;
  15609. t['hatafpatahquarterhebrew'] = 0x05B2;
  15610. t['hatafpatahwidehebrew'] = 0x05B2;
  15611. t['hatafqamats'] = 0x05B3;
  15612. t['hatafqamats1b'] = 0x05B3;
  15613. t['hatafqamats28'] = 0x05B3;
  15614. t['hatafqamats34'] = 0x05B3;
  15615. t['hatafqamatshebrew'] = 0x05B3;
  15616. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  15617. t['hatafqamatsquarterhebrew'] = 0x05B3;
  15618. t['hatafqamatswidehebrew'] = 0x05B3;
  15619. t['hatafsegol'] = 0x05B1;
  15620. t['hatafsegol17'] = 0x05B1;
  15621. t['hatafsegol24'] = 0x05B1;
  15622. t['hatafsegol30'] = 0x05B1;
  15623. t['hatafsegolhebrew'] = 0x05B1;
  15624. t['hatafsegolnarrowhebrew'] = 0x05B1;
  15625. t['hatafsegolquarterhebrew'] = 0x05B1;
  15626. t['hatafsegolwidehebrew'] = 0x05B1;
  15627. t['hbar'] = 0x0127;
  15628. t['hbopomofo'] = 0x310F;
  15629. t['hbrevebelow'] = 0x1E2B;
  15630. t['hcedilla'] = 0x1E29;
  15631. t['hcircle'] = 0x24D7;
  15632. t['hcircumflex'] = 0x0125;
  15633. t['hdieresis'] = 0x1E27;
  15634. t['hdotaccent'] = 0x1E23;
  15635. t['hdotbelow'] = 0x1E25;
  15636. t['he'] = 0x05D4;
  15637. t['heart'] = 0x2665;
  15638. t['heartsuitblack'] = 0x2665;
  15639. t['heartsuitwhite'] = 0x2661;
  15640. t['hedagesh'] = 0xFB34;
  15641. t['hedageshhebrew'] = 0xFB34;
  15642. t['hehaltonearabic'] = 0x06C1;
  15643. t['heharabic'] = 0x0647;
  15644. t['hehebrew'] = 0x05D4;
  15645. t['hehfinalaltonearabic'] = 0xFBA7;
  15646. t['hehfinalalttwoarabic'] = 0xFEEA;
  15647. t['hehfinalarabic'] = 0xFEEA;
  15648. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  15649. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  15650. t['hehinitialaltonearabic'] = 0xFBA8;
  15651. t['hehinitialarabic'] = 0xFEEB;
  15652. t['hehiragana'] = 0x3078;
  15653. t['hehmedialaltonearabic'] = 0xFBA9;
  15654. t['hehmedialarabic'] = 0xFEEC;
  15655. t['heiseierasquare'] = 0x337B;
  15656. t['hekatakana'] = 0x30D8;
  15657. t['hekatakanahalfwidth'] = 0xFF8D;
  15658. t['hekutaarusquare'] = 0x3336;
  15659. t['henghook'] = 0x0267;
  15660. t['herutusquare'] = 0x3339;
  15661. t['het'] = 0x05D7;
  15662. t['hethebrew'] = 0x05D7;
  15663. t['hhook'] = 0x0266;
  15664. t['hhooksuperior'] = 0x02B1;
  15665. t['hieuhacirclekorean'] = 0x327B;
  15666. t['hieuhaparenkorean'] = 0x321B;
  15667. t['hieuhcirclekorean'] = 0x326D;
  15668. t['hieuhkorean'] = 0x314E;
  15669. t['hieuhparenkorean'] = 0x320D;
  15670. t['hihiragana'] = 0x3072;
  15671. t['hikatakana'] = 0x30D2;
  15672. t['hikatakanahalfwidth'] = 0xFF8B;
  15673. t['hiriq'] = 0x05B4;
  15674. t['hiriq14'] = 0x05B4;
  15675. t['hiriq21'] = 0x05B4;
  15676. t['hiriq2d'] = 0x05B4;
  15677. t['hiriqhebrew'] = 0x05B4;
  15678. t['hiriqnarrowhebrew'] = 0x05B4;
  15679. t['hiriqquarterhebrew'] = 0x05B4;
  15680. t['hiriqwidehebrew'] = 0x05B4;
  15681. t['hlinebelow'] = 0x1E96;
  15682. t['hmonospace'] = 0xFF48;
  15683. t['hoarmenian'] = 0x0570;
  15684. t['hohipthai'] = 0x0E2B;
  15685. t['hohiragana'] = 0x307B;
  15686. t['hokatakana'] = 0x30DB;
  15687. t['hokatakanahalfwidth'] = 0xFF8E;
  15688. t['holam'] = 0x05B9;
  15689. t['holam19'] = 0x05B9;
  15690. t['holam26'] = 0x05B9;
  15691. t['holam32'] = 0x05B9;
  15692. t['holamhebrew'] = 0x05B9;
  15693. t['holamnarrowhebrew'] = 0x05B9;
  15694. t['holamquarterhebrew'] = 0x05B9;
  15695. t['holamwidehebrew'] = 0x05B9;
  15696. t['honokhukthai'] = 0x0E2E;
  15697. t['hookabovecomb'] = 0x0309;
  15698. t['hookcmb'] = 0x0309;
  15699. t['hookpalatalizedbelowcmb'] = 0x0321;
  15700. t['hookretroflexbelowcmb'] = 0x0322;
  15701. t['hoonsquare'] = 0x3342;
  15702. t['horicoptic'] = 0x03E9;
  15703. t['horizontalbar'] = 0x2015;
  15704. t['horncmb'] = 0x031B;
  15705. t['hotsprings'] = 0x2668;
  15706. t['house'] = 0x2302;
  15707. t['hparen'] = 0x24A3;
  15708. t['hsuperior'] = 0x02B0;
  15709. t['hturned'] = 0x0265;
  15710. t['huhiragana'] = 0x3075;
  15711. t['huiitosquare'] = 0x3333;
  15712. t['hukatakana'] = 0x30D5;
  15713. t['hukatakanahalfwidth'] = 0xFF8C;
  15714. t['hungarumlaut'] = 0x02DD;
  15715. t['hungarumlautcmb'] = 0x030B;
  15716. t['hv'] = 0x0195;
  15717. t['hyphen'] = 0x002D;
  15718. t['hypheninferior'] = 0xF6E5;
  15719. t['hyphenmonospace'] = 0xFF0D;
  15720. t['hyphensmall'] = 0xFE63;
  15721. t['hyphensuperior'] = 0xF6E6;
  15722. t['hyphentwo'] = 0x2010;
  15723. t['i'] = 0x0069;
  15724. t['iacute'] = 0x00ED;
  15725. t['iacyrillic'] = 0x044F;
  15726. t['ibengali'] = 0x0987;
  15727. t['ibopomofo'] = 0x3127;
  15728. t['ibreve'] = 0x012D;
  15729. t['icaron'] = 0x01D0;
  15730. t['icircle'] = 0x24D8;
  15731. t['icircumflex'] = 0x00EE;
  15732. t['icyrillic'] = 0x0456;
  15733. t['idblgrave'] = 0x0209;
  15734. t['ideographearthcircle'] = 0x328F;
  15735. t['ideographfirecircle'] = 0x328B;
  15736. t['ideographicallianceparen'] = 0x323F;
  15737. t['ideographiccallparen'] = 0x323A;
  15738. t['ideographiccentrecircle'] = 0x32A5;
  15739. t['ideographicclose'] = 0x3006;
  15740. t['ideographiccomma'] = 0x3001;
  15741. t['ideographiccommaleft'] = 0xFF64;
  15742. t['ideographiccongratulationparen'] = 0x3237;
  15743. t['ideographiccorrectcircle'] = 0x32A3;
  15744. t['ideographicearthparen'] = 0x322F;
  15745. t['ideographicenterpriseparen'] = 0x323D;
  15746. t['ideographicexcellentcircle'] = 0x329D;
  15747. t['ideographicfestivalparen'] = 0x3240;
  15748. t['ideographicfinancialcircle'] = 0x3296;
  15749. t['ideographicfinancialparen'] = 0x3236;
  15750. t['ideographicfireparen'] = 0x322B;
  15751. t['ideographichaveparen'] = 0x3232;
  15752. t['ideographichighcircle'] = 0x32A4;
  15753. t['ideographiciterationmark'] = 0x3005;
  15754. t['ideographiclaborcircle'] = 0x3298;
  15755. t['ideographiclaborparen'] = 0x3238;
  15756. t['ideographicleftcircle'] = 0x32A7;
  15757. t['ideographiclowcircle'] = 0x32A6;
  15758. t['ideographicmedicinecircle'] = 0x32A9;
  15759. t['ideographicmetalparen'] = 0x322E;
  15760. t['ideographicmoonparen'] = 0x322A;
  15761. t['ideographicnameparen'] = 0x3234;
  15762. t['ideographicperiod'] = 0x3002;
  15763. t['ideographicprintcircle'] = 0x329E;
  15764. t['ideographicreachparen'] = 0x3243;
  15765. t['ideographicrepresentparen'] = 0x3239;
  15766. t['ideographicresourceparen'] = 0x323E;
  15767. t['ideographicrightcircle'] = 0x32A8;
  15768. t['ideographicsecretcircle'] = 0x3299;
  15769. t['ideographicselfparen'] = 0x3242;
  15770. t['ideographicsocietyparen'] = 0x3233;
  15771. t['ideographicspace'] = 0x3000;
  15772. t['ideographicspecialparen'] = 0x3235;
  15773. t['ideographicstockparen'] = 0x3231;
  15774. t['ideographicstudyparen'] = 0x323B;
  15775. t['ideographicsunparen'] = 0x3230;
  15776. t['ideographicsuperviseparen'] = 0x323C;
  15777. t['ideographicwaterparen'] = 0x322C;
  15778. t['ideographicwoodparen'] = 0x322D;
  15779. t['ideographiczero'] = 0x3007;
  15780. t['ideographmetalcircle'] = 0x328E;
  15781. t['ideographmooncircle'] = 0x328A;
  15782. t['ideographnamecircle'] = 0x3294;
  15783. t['ideographsuncircle'] = 0x3290;
  15784. t['ideographwatercircle'] = 0x328C;
  15785. t['ideographwoodcircle'] = 0x328D;
  15786. t['ideva'] = 0x0907;
  15787. t['idieresis'] = 0x00EF;
  15788. t['idieresisacute'] = 0x1E2F;
  15789. t['idieresiscyrillic'] = 0x04E5;
  15790. t['idotbelow'] = 0x1ECB;
  15791. t['iebrevecyrillic'] = 0x04D7;
  15792. t['iecyrillic'] = 0x0435;
  15793. t['ieungacirclekorean'] = 0x3275;
  15794. t['ieungaparenkorean'] = 0x3215;
  15795. t['ieungcirclekorean'] = 0x3267;
  15796. t['ieungkorean'] = 0x3147;
  15797. t['ieungparenkorean'] = 0x3207;
  15798. t['igrave'] = 0x00EC;
  15799. t['igujarati'] = 0x0A87;
  15800. t['igurmukhi'] = 0x0A07;
  15801. t['ihiragana'] = 0x3044;
  15802. t['ihookabove'] = 0x1EC9;
  15803. t['iibengali'] = 0x0988;
  15804. t['iicyrillic'] = 0x0438;
  15805. t['iideva'] = 0x0908;
  15806. t['iigujarati'] = 0x0A88;
  15807. t['iigurmukhi'] = 0x0A08;
  15808. t['iimatragurmukhi'] = 0x0A40;
  15809. t['iinvertedbreve'] = 0x020B;
  15810. t['iishortcyrillic'] = 0x0439;
  15811. t['iivowelsignbengali'] = 0x09C0;
  15812. t['iivowelsigndeva'] = 0x0940;
  15813. t['iivowelsigngujarati'] = 0x0AC0;
  15814. t['ij'] = 0x0133;
  15815. t['ikatakana'] = 0x30A4;
  15816. t['ikatakanahalfwidth'] = 0xFF72;
  15817. t['ikorean'] = 0x3163;
  15818. t['ilde'] = 0x02DC;
  15819. t['iluyhebrew'] = 0x05AC;
  15820. t['imacron'] = 0x012B;
  15821. t['imacroncyrillic'] = 0x04E3;
  15822. t['imageorapproximatelyequal'] = 0x2253;
  15823. t['imatragurmukhi'] = 0x0A3F;
  15824. t['imonospace'] = 0xFF49;
  15825. t['increment'] = 0x2206;
  15826. t['infinity'] = 0x221E;
  15827. t['iniarmenian'] = 0x056B;
  15828. t['integral'] = 0x222B;
  15829. t['integralbottom'] = 0x2321;
  15830. t['integralbt'] = 0x2321;
  15831. t['integralex'] = 0xF8F5;
  15832. t['integraltop'] = 0x2320;
  15833. t['integraltp'] = 0x2320;
  15834. t['intersection'] = 0x2229;
  15835. t['intisquare'] = 0x3305;
  15836. t['invbullet'] = 0x25D8;
  15837. t['invcircle'] = 0x25D9;
  15838. t['invsmileface'] = 0x263B;
  15839. t['iocyrillic'] = 0x0451;
  15840. t['iogonek'] = 0x012F;
  15841. t['iota'] = 0x03B9;
  15842. t['iotadieresis'] = 0x03CA;
  15843. t['iotadieresistonos'] = 0x0390;
  15844. t['iotalatin'] = 0x0269;
  15845. t['iotatonos'] = 0x03AF;
  15846. t['iparen'] = 0x24A4;
  15847. t['irigurmukhi'] = 0x0A72;
  15848. t['ismallhiragana'] = 0x3043;
  15849. t['ismallkatakana'] = 0x30A3;
  15850. t['ismallkatakanahalfwidth'] = 0xFF68;
  15851. t['issharbengali'] = 0x09FA;
  15852. t['istroke'] = 0x0268;
  15853. t['isuperior'] = 0xF6ED;
  15854. t['iterationhiragana'] = 0x309D;
  15855. t['iterationkatakana'] = 0x30FD;
  15856. t['itilde'] = 0x0129;
  15857. t['itildebelow'] = 0x1E2D;
  15858. t['iubopomofo'] = 0x3129;
  15859. t['iucyrillic'] = 0x044E;
  15860. t['ivowelsignbengali'] = 0x09BF;
  15861. t['ivowelsigndeva'] = 0x093F;
  15862. t['ivowelsigngujarati'] = 0x0ABF;
  15863. t['izhitsacyrillic'] = 0x0475;
  15864. t['izhitsadblgravecyrillic'] = 0x0477;
  15865. t['j'] = 0x006A;
  15866. t['jaarmenian'] = 0x0571;
  15867. t['jabengali'] = 0x099C;
  15868. t['jadeva'] = 0x091C;
  15869. t['jagujarati'] = 0x0A9C;
  15870. t['jagurmukhi'] = 0x0A1C;
  15871. t['jbopomofo'] = 0x3110;
  15872. t['jcaron'] = 0x01F0;
  15873. t['jcircle'] = 0x24D9;
  15874. t['jcircumflex'] = 0x0135;
  15875. t['jcrossedtail'] = 0x029D;
  15876. t['jdotlessstroke'] = 0x025F;
  15877. t['jecyrillic'] = 0x0458;
  15878. t['jeemarabic'] = 0x062C;
  15879. t['jeemfinalarabic'] = 0xFE9E;
  15880. t['jeeminitialarabic'] = 0xFE9F;
  15881. t['jeemmedialarabic'] = 0xFEA0;
  15882. t['jeharabic'] = 0x0698;
  15883. t['jehfinalarabic'] = 0xFB8B;
  15884. t['jhabengali'] = 0x099D;
  15885. t['jhadeva'] = 0x091D;
  15886. t['jhagujarati'] = 0x0A9D;
  15887. t['jhagurmukhi'] = 0x0A1D;
  15888. t['jheharmenian'] = 0x057B;
  15889. t['jis'] = 0x3004;
  15890. t['jmonospace'] = 0xFF4A;
  15891. t['jparen'] = 0x24A5;
  15892. t['jsuperior'] = 0x02B2;
  15893. t['k'] = 0x006B;
  15894. t['kabashkircyrillic'] = 0x04A1;
  15895. t['kabengali'] = 0x0995;
  15896. t['kacute'] = 0x1E31;
  15897. t['kacyrillic'] = 0x043A;
  15898. t['kadescendercyrillic'] = 0x049B;
  15899. t['kadeva'] = 0x0915;
  15900. t['kaf'] = 0x05DB;
  15901. t['kafarabic'] = 0x0643;
  15902. t['kafdagesh'] = 0xFB3B;
  15903. t['kafdageshhebrew'] = 0xFB3B;
  15904. t['kaffinalarabic'] = 0xFEDA;
  15905. t['kafhebrew'] = 0x05DB;
  15906. t['kafinitialarabic'] = 0xFEDB;
  15907. t['kafmedialarabic'] = 0xFEDC;
  15908. t['kafrafehebrew'] = 0xFB4D;
  15909. t['kagujarati'] = 0x0A95;
  15910. t['kagurmukhi'] = 0x0A15;
  15911. t['kahiragana'] = 0x304B;
  15912. t['kahookcyrillic'] = 0x04C4;
  15913. t['kakatakana'] = 0x30AB;
  15914. t['kakatakanahalfwidth'] = 0xFF76;
  15915. t['kappa'] = 0x03BA;
  15916. t['kappasymbolgreek'] = 0x03F0;
  15917. t['kapyeounmieumkorean'] = 0x3171;
  15918. t['kapyeounphieuphkorean'] = 0x3184;
  15919. t['kapyeounpieupkorean'] = 0x3178;
  15920. t['kapyeounssangpieupkorean'] = 0x3179;
  15921. t['karoriisquare'] = 0x330D;
  15922. t['kashidaautoarabic'] = 0x0640;
  15923. t['kashidaautonosidebearingarabic'] = 0x0640;
  15924. t['kasmallkatakana'] = 0x30F5;
  15925. t['kasquare'] = 0x3384;
  15926. t['kasraarabic'] = 0x0650;
  15927. t['kasratanarabic'] = 0x064D;
  15928. t['kastrokecyrillic'] = 0x049F;
  15929. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  15930. t['kaverticalstrokecyrillic'] = 0x049D;
  15931. t['kbopomofo'] = 0x310E;
  15932. t['kcalsquare'] = 0x3389;
  15933. t['kcaron'] = 0x01E9;
  15934. t['kcedilla'] = 0x0137;
  15935. t['kcircle'] = 0x24DA;
  15936. t['kcommaaccent'] = 0x0137;
  15937. t['kdotbelow'] = 0x1E33;
  15938. t['keharmenian'] = 0x0584;
  15939. t['kehiragana'] = 0x3051;
  15940. t['kekatakana'] = 0x30B1;
  15941. t['kekatakanahalfwidth'] = 0xFF79;
  15942. t['kenarmenian'] = 0x056F;
  15943. t['kesmallkatakana'] = 0x30F6;
  15944. t['kgreenlandic'] = 0x0138;
  15945. t['khabengali'] = 0x0996;
  15946. t['khacyrillic'] = 0x0445;
  15947. t['khadeva'] = 0x0916;
  15948. t['khagujarati'] = 0x0A96;
  15949. t['khagurmukhi'] = 0x0A16;
  15950. t['khaharabic'] = 0x062E;
  15951. t['khahfinalarabic'] = 0xFEA6;
  15952. t['khahinitialarabic'] = 0xFEA7;
  15953. t['khahmedialarabic'] = 0xFEA8;
  15954. t['kheicoptic'] = 0x03E7;
  15955. t['khhadeva'] = 0x0959;
  15956. t['khhagurmukhi'] = 0x0A59;
  15957. t['khieukhacirclekorean'] = 0x3278;
  15958. t['khieukhaparenkorean'] = 0x3218;
  15959. t['khieukhcirclekorean'] = 0x326A;
  15960. t['khieukhkorean'] = 0x314B;
  15961. t['khieukhparenkorean'] = 0x320A;
  15962. t['khokhaithai'] = 0x0E02;
  15963. t['khokhonthai'] = 0x0E05;
  15964. t['khokhuatthai'] = 0x0E03;
  15965. t['khokhwaithai'] = 0x0E04;
  15966. t['khomutthai'] = 0x0E5B;
  15967. t['khook'] = 0x0199;
  15968. t['khorakhangthai'] = 0x0E06;
  15969. t['khzsquare'] = 0x3391;
  15970. t['kihiragana'] = 0x304D;
  15971. t['kikatakana'] = 0x30AD;
  15972. t['kikatakanahalfwidth'] = 0xFF77;
  15973. t['kiroguramusquare'] = 0x3315;
  15974. t['kiromeetorusquare'] = 0x3316;
  15975. t['kirosquare'] = 0x3314;
  15976. t['kiyeokacirclekorean'] = 0x326E;
  15977. t['kiyeokaparenkorean'] = 0x320E;
  15978. t['kiyeokcirclekorean'] = 0x3260;
  15979. t['kiyeokkorean'] = 0x3131;
  15980. t['kiyeokparenkorean'] = 0x3200;
  15981. t['kiyeoksioskorean'] = 0x3133;
  15982. t['kjecyrillic'] = 0x045C;
  15983. t['klinebelow'] = 0x1E35;
  15984. t['klsquare'] = 0x3398;
  15985. t['kmcubedsquare'] = 0x33A6;
  15986. t['kmonospace'] = 0xFF4B;
  15987. t['kmsquaredsquare'] = 0x33A2;
  15988. t['kohiragana'] = 0x3053;
  15989. t['kohmsquare'] = 0x33C0;
  15990. t['kokaithai'] = 0x0E01;
  15991. t['kokatakana'] = 0x30B3;
  15992. t['kokatakanahalfwidth'] = 0xFF7A;
  15993. t['kooposquare'] = 0x331E;
  15994. t['koppacyrillic'] = 0x0481;
  15995. t['koreanstandardsymbol'] = 0x327F;
  15996. t['koroniscmb'] = 0x0343;
  15997. t['kparen'] = 0x24A6;
  15998. t['kpasquare'] = 0x33AA;
  15999. t['ksicyrillic'] = 0x046F;
  16000. t['ktsquare'] = 0x33CF;
  16001. t['kturned'] = 0x029E;
  16002. t['kuhiragana'] = 0x304F;
  16003. t['kukatakana'] = 0x30AF;
  16004. t['kukatakanahalfwidth'] = 0xFF78;
  16005. t['kvsquare'] = 0x33B8;
  16006. t['kwsquare'] = 0x33BE;
  16007. t['l'] = 0x006C;
  16008. t['labengali'] = 0x09B2;
  16009. t['lacute'] = 0x013A;
  16010. t['ladeva'] = 0x0932;
  16011. t['lagujarati'] = 0x0AB2;
  16012. t['lagurmukhi'] = 0x0A32;
  16013. t['lakkhangyaothai'] = 0x0E45;
  16014. t['lamaleffinalarabic'] = 0xFEFC;
  16015. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16016. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16017. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16018. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16019. t['lamalefisolatedarabic'] = 0xFEFB;
  16020. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16021. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16022. t['lamarabic'] = 0x0644;
  16023. t['lambda'] = 0x03BB;
  16024. t['lambdastroke'] = 0x019B;
  16025. t['lamed'] = 0x05DC;
  16026. t['lameddagesh'] = 0xFB3C;
  16027. t['lameddageshhebrew'] = 0xFB3C;
  16028. t['lamedhebrew'] = 0x05DC;
  16029. t['lamfinalarabic'] = 0xFEDE;
  16030. t['lamhahinitialarabic'] = 0xFCCA;
  16031. t['laminitialarabic'] = 0xFEDF;
  16032. t['lamjeeminitialarabic'] = 0xFCC9;
  16033. t['lamkhahinitialarabic'] = 0xFCCB;
  16034. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16035. t['lammedialarabic'] = 0xFEE0;
  16036. t['lammeemhahinitialarabic'] = 0xFD88;
  16037. t['lammeeminitialarabic'] = 0xFCCC;
  16038. t['largecircle'] = 0x25EF;
  16039. t['lbar'] = 0x019A;
  16040. t['lbelt'] = 0x026C;
  16041. t['lbopomofo'] = 0x310C;
  16042. t['lcaron'] = 0x013E;
  16043. t['lcedilla'] = 0x013C;
  16044. t['lcircle'] = 0x24DB;
  16045. t['lcircumflexbelow'] = 0x1E3D;
  16046. t['lcommaaccent'] = 0x013C;
  16047. t['ldot'] = 0x0140;
  16048. t['ldotaccent'] = 0x0140;
  16049. t['ldotbelow'] = 0x1E37;
  16050. t['ldotbelowmacron'] = 0x1E39;
  16051. t['leftangleabovecmb'] = 0x031A;
  16052. t['lefttackbelowcmb'] = 0x0318;
  16053. t['less'] = 0x003C;
  16054. t['lessequal'] = 0x2264;
  16055. t['lessequalorgreater'] = 0x22DA;
  16056. t['lessmonospace'] = 0xFF1C;
  16057. t['lessorequivalent'] = 0x2272;
  16058. t['lessorgreater'] = 0x2276;
  16059. t['lessoverequal'] = 0x2266;
  16060. t['lesssmall'] = 0xFE64;
  16061. t['lezh'] = 0x026E;
  16062. t['lfblock'] = 0x258C;
  16063. t['lhookretroflex'] = 0x026D;
  16064. t['lira'] = 0x20A4;
  16065. t['liwnarmenian'] = 0x056C;
  16066. t['lj'] = 0x01C9;
  16067. t['ljecyrillic'] = 0x0459;
  16068. t['ll'] = 0xF6C0;
  16069. t['lladeva'] = 0x0933;
  16070. t['llagujarati'] = 0x0AB3;
  16071. t['llinebelow'] = 0x1E3B;
  16072. t['llladeva'] = 0x0934;
  16073. t['llvocalicbengali'] = 0x09E1;
  16074. t['llvocalicdeva'] = 0x0961;
  16075. t['llvocalicvowelsignbengali'] = 0x09E3;
  16076. t['llvocalicvowelsigndeva'] = 0x0963;
  16077. t['lmiddletilde'] = 0x026B;
  16078. t['lmonospace'] = 0xFF4C;
  16079. t['lmsquare'] = 0x33D0;
  16080. t['lochulathai'] = 0x0E2C;
  16081. t['logicaland'] = 0x2227;
  16082. t['logicalnot'] = 0x00AC;
  16083. t['logicalnotreversed'] = 0x2310;
  16084. t['logicalor'] = 0x2228;
  16085. t['lolingthai'] = 0x0E25;
  16086. t['longs'] = 0x017F;
  16087. t['lowlinecenterline'] = 0xFE4E;
  16088. t['lowlinecmb'] = 0x0332;
  16089. t['lowlinedashed'] = 0xFE4D;
  16090. t['lozenge'] = 0x25CA;
  16091. t['lparen'] = 0x24A7;
  16092. t['lslash'] = 0x0142;
  16093. t['lsquare'] = 0x2113;
  16094. t['lsuperior'] = 0xF6EE;
  16095. t['ltshade'] = 0x2591;
  16096. t['luthai'] = 0x0E26;
  16097. t['lvocalicbengali'] = 0x098C;
  16098. t['lvocalicdeva'] = 0x090C;
  16099. t['lvocalicvowelsignbengali'] = 0x09E2;
  16100. t['lvocalicvowelsigndeva'] = 0x0962;
  16101. t['lxsquare'] = 0x33D3;
  16102. t['m'] = 0x006D;
  16103. t['mabengali'] = 0x09AE;
  16104. t['macron'] = 0x00AF;
  16105. t['macronbelowcmb'] = 0x0331;
  16106. t['macroncmb'] = 0x0304;
  16107. t['macronlowmod'] = 0x02CD;
  16108. t['macronmonospace'] = 0xFFE3;
  16109. t['macute'] = 0x1E3F;
  16110. t['madeva'] = 0x092E;
  16111. t['magujarati'] = 0x0AAE;
  16112. t['magurmukhi'] = 0x0A2E;
  16113. t['mahapakhhebrew'] = 0x05A4;
  16114. t['mahapakhlefthebrew'] = 0x05A4;
  16115. t['mahiragana'] = 0x307E;
  16116. t['maichattawalowleftthai'] = 0xF895;
  16117. t['maichattawalowrightthai'] = 0xF894;
  16118. t['maichattawathai'] = 0x0E4B;
  16119. t['maichattawaupperleftthai'] = 0xF893;
  16120. t['maieklowleftthai'] = 0xF88C;
  16121. t['maieklowrightthai'] = 0xF88B;
  16122. t['maiekthai'] = 0x0E48;
  16123. t['maiekupperleftthai'] = 0xF88A;
  16124. t['maihanakatleftthai'] = 0xF884;
  16125. t['maihanakatthai'] = 0x0E31;
  16126. t['maitaikhuleftthai'] = 0xF889;
  16127. t['maitaikhuthai'] = 0x0E47;
  16128. t['maitholowleftthai'] = 0xF88F;
  16129. t['maitholowrightthai'] = 0xF88E;
  16130. t['maithothai'] = 0x0E49;
  16131. t['maithoupperleftthai'] = 0xF88D;
  16132. t['maitrilowleftthai'] = 0xF892;
  16133. t['maitrilowrightthai'] = 0xF891;
  16134. t['maitrithai'] = 0x0E4A;
  16135. t['maitriupperleftthai'] = 0xF890;
  16136. t['maiyamokthai'] = 0x0E46;
  16137. t['makatakana'] = 0x30DE;
  16138. t['makatakanahalfwidth'] = 0xFF8F;
  16139. t['male'] = 0x2642;
  16140. t['mansyonsquare'] = 0x3347;
  16141. t['maqafhebrew'] = 0x05BE;
  16142. t['mars'] = 0x2642;
  16143. t['masoracirclehebrew'] = 0x05AF;
  16144. t['masquare'] = 0x3383;
  16145. t['mbopomofo'] = 0x3107;
  16146. t['mbsquare'] = 0x33D4;
  16147. t['mcircle'] = 0x24DC;
  16148. t['mcubedsquare'] = 0x33A5;
  16149. t['mdotaccent'] = 0x1E41;
  16150. t['mdotbelow'] = 0x1E43;
  16151. t['meemarabic'] = 0x0645;
  16152. t['meemfinalarabic'] = 0xFEE2;
  16153. t['meeminitialarabic'] = 0xFEE3;
  16154. t['meemmedialarabic'] = 0xFEE4;
  16155. t['meemmeeminitialarabic'] = 0xFCD1;
  16156. t['meemmeemisolatedarabic'] = 0xFC48;
  16157. t['meetorusquare'] = 0x334D;
  16158. t['mehiragana'] = 0x3081;
  16159. t['meizierasquare'] = 0x337E;
  16160. t['mekatakana'] = 0x30E1;
  16161. t['mekatakanahalfwidth'] = 0xFF92;
  16162. t['mem'] = 0x05DE;
  16163. t['memdagesh'] = 0xFB3E;
  16164. t['memdageshhebrew'] = 0xFB3E;
  16165. t['memhebrew'] = 0x05DE;
  16166. t['menarmenian'] = 0x0574;
  16167. t['merkhahebrew'] = 0x05A5;
  16168. t['merkhakefulahebrew'] = 0x05A6;
  16169. t['merkhakefulalefthebrew'] = 0x05A6;
  16170. t['merkhalefthebrew'] = 0x05A5;
  16171. t['mhook'] = 0x0271;
  16172. t['mhzsquare'] = 0x3392;
  16173. t['middledotkatakanahalfwidth'] = 0xFF65;
  16174. t['middot'] = 0x00B7;
  16175. t['mieumacirclekorean'] = 0x3272;
  16176. t['mieumaparenkorean'] = 0x3212;
  16177. t['mieumcirclekorean'] = 0x3264;
  16178. t['mieumkorean'] = 0x3141;
  16179. t['mieumpansioskorean'] = 0x3170;
  16180. t['mieumparenkorean'] = 0x3204;
  16181. t['mieumpieupkorean'] = 0x316E;
  16182. t['mieumsioskorean'] = 0x316F;
  16183. t['mihiragana'] = 0x307F;
  16184. t['mikatakana'] = 0x30DF;
  16185. t['mikatakanahalfwidth'] = 0xFF90;
  16186. t['minus'] = 0x2212;
  16187. t['minusbelowcmb'] = 0x0320;
  16188. t['minuscircle'] = 0x2296;
  16189. t['minusmod'] = 0x02D7;
  16190. t['minusplus'] = 0x2213;
  16191. t['minute'] = 0x2032;
  16192. t['miribaarusquare'] = 0x334A;
  16193. t['mirisquare'] = 0x3349;
  16194. t['mlonglegturned'] = 0x0270;
  16195. t['mlsquare'] = 0x3396;
  16196. t['mmcubedsquare'] = 0x33A3;
  16197. t['mmonospace'] = 0xFF4D;
  16198. t['mmsquaredsquare'] = 0x339F;
  16199. t['mohiragana'] = 0x3082;
  16200. t['mohmsquare'] = 0x33C1;
  16201. t['mokatakana'] = 0x30E2;
  16202. t['mokatakanahalfwidth'] = 0xFF93;
  16203. t['molsquare'] = 0x33D6;
  16204. t['momathai'] = 0x0E21;
  16205. t['moverssquare'] = 0x33A7;
  16206. t['moverssquaredsquare'] = 0x33A8;
  16207. t['mparen'] = 0x24A8;
  16208. t['mpasquare'] = 0x33AB;
  16209. t['mssquare'] = 0x33B3;
  16210. t['msuperior'] = 0xF6EF;
  16211. t['mturned'] = 0x026F;
  16212. t['mu'] = 0x00B5;
  16213. t['mu1'] = 0x00B5;
  16214. t['muasquare'] = 0x3382;
  16215. t['muchgreater'] = 0x226B;
  16216. t['muchless'] = 0x226A;
  16217. t['mufsquare'] = 0x338C;
  16218. t['mugreek'] = 0x03BC;
  16219. t['mugsquare'] = 0x338D;
  16220. t['muhiragana'] = 0x3080;
  16221. t['mukatakana'] = 0x30E0;
  16222. t['mukatakanahalfwidth'] = 0xFF91;
  16223. t['mulsquare'] = 0x3395;
  16224. t['multiply'] = 0x00D7;
  16225. t['mumsquare'] = 0x339B;
  16226. t['munahhebrew'] = 0x05A3;
  16227. t['munahlefthebrew'] = 0x05A3;
  16228. t['musicalnote'] = 0x266A;
  16229. t['musicalnotedbl'] = 0x266B;
  16230. t['musicflatsign'] = 0x266D;
  16231. t['musicsharpsign'] = 0x266F;
  16232. t['mussquare'] = 0x33B2;
  16233. t['muvsquare'] = 0x33B6;
  16234. t['muwsquare'] = 0x33BC;
  16235. t['mvmegasquare'] = 0x33B9;
  16236. t['mvsquare'] = 0x33B7;
  16237. t['mwmegasquare'] = 0x33BF;
  16238. t['mwsquare'] = 0x33BD;
  16239. t['n'] = 0x006E;
  16240. t['nabengali'] = 0x09A8;
  16241. t['nabla'] = 0x2207;
  16242. t['nacute'] = 0x0144;
  16243. t['nadeva'] = 0x0928;
  16244. t['nagujarati'] = 0x0AA8;
  16245. t['nagurmukhi'] = 0x0A28;
  16246. t['nahiragana'] = 0x306A;
  16247. t['nakatakana'] = 0x30CA;
  16248. t['nakatakanahalfwidth'] = 0xFF85;
  16249. t['napostrophe'] = 0x0149;
  16250. t['nasquare'] = 0x3381;
  16251. t['nbopomofo'] = 0x310B;
  16252. t['nbspace'] = 0x00A0;
  16253. t['ncaron'] = 0x0148;
  16254. t['ncedilla'] = 0x0146;
  16255. t['ncircle'] = 0x24DD;
  16256. t['ncircumflexbelow'] = 0x1E4B;
  16257. t['ncommaaccent'] = 0x0146;
  16258. t['ndotaccent'] = 0x1E45;
  16259. t['ndotbelow'] = 0x1E47;
  16260. t['nehiragana'] = 0x306D;
  16261. t['nekatakana'] = 0x30CD;
  16262. t['nekatakanahalfwidth'] = 0xFF88;
  16263. t['newsheqelsign'] = 0x20AA;
  16264. t['nfsquare'] = 0x338B;
  16265. t['ngabengali'] = 0x0999;
  16266. t['ngadeva'] = 0x0919;
  16267. t['ngagujarati'] = 0x0A99;
  16268. t['ngagurmukhi'] = 0x0A19;
  16269. t['ngonguthai'] = 0x0E07;
  16270. t['nhiragana'] = 0x3093;
  16271. t['nhookleft'] = 0x0272;
  16272. t['nhookretroflex'] = 0x0273;
  16273. t['nieunacirclekorean'] = 0x326F;
  16274. t['nieunaparenkorean'] = 0x320F;
  16275. t['nieuncieuckorean'] = 0x3135;
  16276. t['nieuncirclekorean'] = 0x3261;
  16277. t['nieunhieuhkorean'] = 0x3136;
  16278. t['nieunkorean'] = 0x3134;
  16279. t['nieunpansioskorean'] = 0x3168;
  16280. t['nieunparenkorean'] = 0x3201;
  16281. t['nieunsioskorean'] = 0x3167;
  16282. t['nieuntikeutkorean'] = 0x3166;
  16283. t['nihiragana'] = 0x306B;
  16284. t['nikatakana'] = 0x30CB;
  16285. t['nikatakanahalfwidth'] = 0xFF86;
  16286. t['nikhahitleftthai'] = 0xF899;
  16287. t['nikhahitthai'] = 0x0E4D;
  16288. t['nine'] = 0x0039;
  16289. t['ninearabic'] = 0x0669;
  16290. t['ninebengali'] = 0x09EF;
  16291. t['ninecircle'] = 0x2468;
  16292. t['ninecircleinversesansserif'] = 0x2792;
  16293. t['ninedeva'] = 0x096F;
  16294. t['ninegujarati'] = 0x0AEF;
  16295. t['ninegurmukhi'] = 0x0A6F;
  16296. t['ninehackarabic'] = 0x0669;
  16297. t['ninehangzhou'] = 0x3029;
  16298. t['nineideographicparen'] = 0x3228;
  16299. t['nineinferior'] = 0x2089;
  16300. t['ninemonospace'] = 0xFF19;
  16301. t['nineoldstyle'] = 0xF739;
  16302. t['nineparen'] = 0x247C;
  16303. t['nineperiod'] = 0x2490;
  16304. t['ninepersian'] = 0x06F9;
  16305. t['nineroman'] = 0x2178;
  16306. t['ninesuperior'] = 0x2079;
  16307. t['nineteencircle'] = 0x2472;
  16308. t['nineteenparen'] = 0x2486;
  16309. t['nineteenperiod'] = 0x249A;
  16310. t['ninethai'] = 0x0E59;
  16311. t['nj'] = 0x01CC;
  16312. t['njecyrillic'] = 0x045A;
  16313. t['nkatakana'] = 0x30F3;
  16314. t['nkatakanahalfwidth'] = 0xFF9D;
  16315. t['nlegrightlong'] = 0x019E;
  16316. t['nlinebelow'] = 0x1E49;
  16317. t['nmonospace'] = 0xFF4E;
  16318. t['nmsquare'] = 0x339A;
  16319. t['nnabengali'] = 0x09A3;
  16320. t['nnadeva'] = 0x0923;
  16321. t['nnagujarati'] = 0x0AA3;
  16322. t['nnagurmukhi'] = 0x0A23;
  16323. t['nnnadeva'] = 0x0929;
  16324. t['nohiragana'] = 0x306E;
  16325. t['nokatakana'] = 0x30CE;
  16326. t['nokatakanahalfwidth'] = 0xFF89;
  16327. t['nonbreakingspace'] = 0x00A0;
  16328. t['nonenthai'] = 0x0E13;
  16329. t['nonuthai'] = 0x0E19;
  16330. t['noonarabic'] = 0x0646;
  16331. t['noonfinalarabic'] = 0xFEE6;
  16332. t['noonghunnaarabic'] = 0x06BA;
  16333. t['noonghunnafinalarabic'] = 0xFB9F;
  16334. t['nooninitialarabic'] = 0xFEE7;
  16335. t['noonjeeminitialarabic'] = 0xFCD2;
  16336. t['noonjeemisolatedarabic'] = 0xFC4B;
  16337. t['noonmedialarabic'] = 0xFEE8;
  16338. t['noonmeeminitialarabic'] = 0xFCD5;
  16339. t['noonmeemisolatedarabic'] = 0xFC4E;
  16340. t['noonnoonfinalarabic'] = 0xFC8D;
  16341. t['notcontains'] = 0x220C;
  16342. t['notelement'] = 0x2209;
  16343. t['notelementof'] = 0x2209;
  16344. t['notequal'] = 0x2260;
  16345. t['notgreater'] = 0x226F;
  16346. t['notgreaternorequal'] = 0x2271;
  16347. t['notgreaternorless'] = 0x2279;
  16348. t['notidentical'] = 0x2262;
  16349. t['notless'] = 0x226E;
  16350. t['notlessnorequal'] = 0x2270;
  16351. t['notparallel'] = 0x2226;
  16352. t['notprecedes'] = 0x2280;
  16353. t['notsubset'] = 0x2284;
  16354. t['notsucceeds'] = 0x2281;
  16355. t['notsuperset'] = 0x2285;
  16356. t['nowarmenian'] = 0x0576;
  16357. t['nparen'] = 0x24A9;
  16358. t['nssquare'] = 0x33B1;
  16359. t['nsuperior'] = 0x207F;
  16360. t['ntilde'] = 0x00F1;
  16361. t['nu'] = 0x03BD;
  16362. t['nuhiragana'] = 0x306C;
  16363. t['nukatakana'] = 0x30CC;
  16364. t['nukatakanahalfwidth'] = 0xFF87;
  16365. t['nuktabengali'] = 0x09BC;
  16366. t['nuktadeva'] = 0x093C;
  16367. t['nuktagujarati'] = 0x0ABC;
  16368. t['nuktagurmukhi'] = 0x0A3C;
  16369. t['numbersign'] = 0x0023;
  16370. t['numbersignmonospace'] = 0xFF03;
  16371. t['numbersignsmall'] = 0xFE5F;
  16372. t['numeralsigngreek'] = 0x0374;
  16373. t['numeralsignlowergreek'] = 0x0375;
  16374. t['numero'] = 0x2116;
  16375. t['nun'] = 0x05E0;
  16376. t['nundagesh'] = 0xFB40;
  16377. t['nundageshhebrew'] = 0xFB40;
  16378. t['nunhebrew'] = 0x05E0;
  16379. t['nvsquare'] = 0x33B5;
  16380. t['nwsquare'] = 0x33BB;
  16381. t['nyabengali'] = 0x099E;
  16382. t['nyadeva'] = 0x091E;
  16383. t['nyagujarati'] = 0x0A9E;
  16384. t['nyagurmukhi'] = 0x0A1E;
  16385. t['o'] = 0x006F;
  16386. t['oacute'] = 0x00F3;
  16387. t['oangthai'] = 0x0E2D;
  16388. t['obarred'] = 0x0275;
  16389. t['obarredcyrillic'] = 0x04E9;
  16390. t['obarreddieresiscyrillic'] = 0x04EB;
  16391. t['obengali'] = 0x0993;
  16392. t['obopomofo'] = 0x311B;
  16393. t['obreve'] = 0x014F;
  16394. t['ocandradeva'] = 0x0911;
  16395. t['ocandragujarati'] = 0x0A91;
  16396. t['ocandravowelsigndeva'] = 0x0949;
  16397. t['ocandravowelsigngujarati'] = 0x0AC9;
  16398. t['ocaron'] = 0x01D2;
  16399. t['ocircle'] = 0x24DE;
  16400. t['ocircumflex'] = 0x00F4;
  16401. t['ocircumflexacute'] = 0x1ED1;
  16402. t['ocircumflexdotbelow'] = 0x1ED9;
  16403. t['ocircumflexgrave'] = 0x1ED3;
  16404. t['ocircumflexhookabove'] = 0x1ED5;
  16405. t['ocircumflextilde'] = 0x1ED7;
  16406. t['ocyrillic'] = 0x043E;
  16407. t['odblacute'] = 0x0151;
  16408. t['odblgrave'] = 0x020D;
  16409. t['odeva'] = 0x0913;
  16410. t['odieresis'] = 0x00F6;
  16411. t['odieresiscyrillic'] = 0x04E7;
  16412. t['odotbelow'] = 0x1ECD;
  16413. t['oe'] = 0x0153;
  16414. t['oekorean'] = 0x315A;
  16415. t['ogonek'] = 0x02DB;
  16416. t['ogonekcmb'] = 0x0328;
  16417. t['ograve'] = 0x00F2;
  16418. t['ogujarati'] = 0x0A93;
  16419. t['oharmenian'] = 0x0585;
  16420. t['ohiragana'] = 0x304A;
  16421. t['ohookabove'] = 0x1ECF;
  16422. t['ohorn'] = 0x01A1;
  16423. t['ohornacute'] = 0x1EDB;
  16424. t['ohorndotbelow'] = 0x1EE3;
  16425. t['ohorngrave'] = 0x1EDD;
  16426. t['ohornhookabove'] = 0x1EDF;
  16427. t['ohorntilde'] = 0x1EE1;
  16428. t['ohungarumlaut'] = 0x0151;
  16429. t['oi'] = 0x01A3;
  16430. t['oinvertedbreve'] = 0x020F;
  16431. t['okatakana'] = 0x30AA;
  16432. t['okatakanahalfwidth'] = 0xFF75;
  16433. t['okorean'] = 0x3157;
  16434. t['olehebrew'] = 0x05AB;
  16435. t['omacron'] = 0x014D;
  16436. t['omacronacute'] = 0x1E53;
  16437. t['omacrongrave'] = 0x1E51;
  16438. t['omdeva'] = 0x0950;
  16439. t['omega'] = 0x03C9;
  16440. t['omega1'] = 0x03D6;
  16441. t['omegacyrillic'] = 0x0461;
  16442. t['omegalatinclosed'] = 0x0277;
  16443. t['omegaroundcyrillic'] = 0x047B;
  16444. t['omegatitlocyrillic'] = 0x047D;
  16445. t['omegatonos'] = 0x03CE;
  16446. t['omgujarati'] = 0x0AD0;
  16447. t['omicron'] = 0x03BF;
  16448. t['omicrontonos'] = 0x03CC;
  16449. t['omonospace'] = 0xFF4F;
  16450. t['one'] = 0x0031;
  16451. t['onearabic'] = 0x0661;
  16452. t['onebengali'] = 0x09E7;
  16453. t['onecircle'] = 0x2460;
  16454. t['onecircleinversesansserif'] = 0x278A;
  16455. t['onedeva'] = 0x0967;
  16456. t['onedotenleader'] = 0x2024;
  16457. t['oneeighth'] = 0x215B;
  16458. t['onefitted'] = 0xF6DC;
  16459. t['onegujarati'] = 0x0AE7;
  16460. t['onegurmukhi'] = 0x0A67;
  16461. t['onehackarabic'] = 0x0661;
  16462. t['onehalf'] = 0x00BD;
  16463. t['onehangzhou'] = 0x3021;
  16464. t['oneideographicparen'] = 0x3220;
  16465. t['oneinferior'] = 0x2081;
  16466. t['onemonospace'] = 0xFF11;
  16467. t['onenumeratorbengali'] = 0x09F4;
  16468. t['oneoldstyle'] = 0xF731;
  16469. t['oneparen'] = 0x2474;
  16470. t['oneperiod'] = 0x2488;
  16471. t['onepersian'] = 0x06F1;
  16472. t['onequarter'] = 0x00BC;
  16473. t['oneroman'] = 0x2170;
  16474. t['onesuperior'] = 0x00B9;
  16475. t['onethai'] = 0x0E51;
  16476. t['onethird'] = 0x2153;
  16477. t['oogonek'] = 0x01EB;
  16478. t['oogonekmacron'] = 0x01ED;
  16479. t['oogurmukhi'] = 0x0A13;
  16480. t['oomatragurmukhi'] = 0x0A4B;
  16481. t['oopen'] = 0x0254;
  16482. t['oparen'] = 0x24AA;
  16483. t['openbullet'] = 0x25E6;
  16484. t['option'] = 0x2325;
  16485. t['ordfeminine'] = 0x00AA;
  16486. t['ordmasculine'] = 0x00BA;
  16487. t['orthogonal'] = 0x221F;
  16488. t['oshortdeva'] = 0x0912;
  16489. t['oshortvowelsigndeva'] = 0x094A;
  16490. t['oslash'] = 0x00F8;
  16491. t['oslashacute'] = 0x01FF;
  16492. t['osmallhiragana'] = 0x3049;
  16493. t['osmallkatakana'] = 0x30A9;
  16494. t['osmallkatakanahalfwidth'] = 0xFF6B;
  16495. t['ostrokeacute'] = 0x01FF;
  16496. t['osuperior'] = 0xF6F0;
  16497. t['otcyrillic'] = 0x047F;
  16498. t['otilde'] = 0x00F5;
  16499. t['otildeacute'] = 0x1E4D;
  16500. t['otildedieresis'] = 0x1E4F;
  16501. t['oubopomofo'] = 0x3121;
  16502. t['overline'] = 0x203E;
  16503. t['overlinecenterline'] = 0xFE4A;
  16504. t['overlinecmb'] = 0x0305;
  16505. t['overlinedashed'] = 0xFE49;
  16506. t['overlinedblwavy'] = 0xFE4C;
  16507. t['overlinewavy'] = 0xFE4B;
  16508. t['overscore'] = 0x00AF;
  16509. t['ovowelsignbengali'] = 0x09CB;
  16510. t['ovowelsigndeva'] = 0x094B;
  16511. t['ovowelsigngujarati'] = 0x0ACB;
  16512. t['p'] = 0x0070;
  16513. t['paampssquare'] = 0x3380;
  16514. t['paasentosquare'] = 0x332B;
  16515. t['pabengali'] = 0x09AA;
  16516. t['pacute'] = 0x1E55;
  16517. t['padeva'] = 0x092A;
  16518. t['pagedown'] = 0x21DF;
  16519. t['pageup'] = 0x21DE;
  16520. t['pagujarati'] = 0x0AAA;
  16521. t['pagurmukhi'] = 0x0A2A;
  16522. t['pahiragana'] = 0x3071;
  16523. t['paiyannoithai'] = 0x0E2F;
  16524. t['pakatakana'] = 0x30D1;
  16525. t['palatalizationcyrilliccmb'] = 0x0484;
  16526. t['palochkacyrillic'] = 0x04C0;
  16527. t['pansioskorean'] = 0x317F;
  16528. t['paragraph'] = 0x00B6;
  16529. t['parallel'] = 0x2225;
  16530. t['parenleft'] = 0x0028;
  16531. t['parenleftaltonearabic'] = 0xFD3E;
  16532. t['parenleftbt'] = 0xF8ED;
  16533. t['parenleftex'] = 0xF8EC;
  16534. t['parenleftinferior'] = 0x208D;
  16535. t['parenleftmonospace'] = 0xFF08;
  16536. t['parenleftsmall'] = 0xFE59;
  16537. t['parenleftsuperior'] = 0x207D;
  16538. t['parenlefttp'] = 0xF8EB;
  16539. t['parenleftvertical'] = 0xFE35;
  16540. t['parenright'] = 0x0029;
  16541. t['parenrightaltonearabic'] = 0xFD3F;
  16542. t['parenrightbt'] = 0xF8F8;
  16543. t['parenrightex'] = 0xF8F7;
  16544. t['parenrightinferior'] = 0x208E;
  16545. t['parenrightmonospace'] = 0xFF09;
  16546. t['parenrightsmall'] = 0xFE5A;
  16547. t['parenrightsuperior'] = 0x207E;
  16548. t['parenrighttp'] = 0xF8F6;
  16549. t['parenrightvertical'] = 0xFE36;
  16550. t['partialdiff'] = 0x2202;
  16551. t['paseqhebrew'] = 0x05C0;
  16552. t['pashtahebrew'] = 0x0599;
  16553. t['pasquare'] = 0x33A9;
  16554. t['patah'] = 0x05B7;
  16555. t['patah11'] = 0x05B7;
  16556. t['patah1d'] = 0x05B7;
  16557. t['patah2a'] = 0x05B7;
  16558. t['patahhebrew'] = 0x05B7;
  16559. t['patahnarrowhebrew'] = 0x05B7;
  16560. t['patahquarterhebrew'] = 0x05B7;
  16561. t['patahwidehebrew'] = 0x05B7;
  16562. t['pazerhebrew'] = 0x05A1;
  16563. t['pbopomofo'] = 0x3106;
  16564. t['pcircle'] = 0x24DF;
  16565. t['pdotaccent'] = 0x1E57;
  16566. t['pe'] = 0x05E4;
  16567. t['pecyrillic'] = 0x043F;
  16568. t['pedagesh'] = 0xFB44;
  16569. t['pedageshhebrew'] = 0xFB44;
  16570. t['peezisquare'] = 0x333B;
  16571. t['pefinaldageshhebrew'] = 0xFB43;
  16572. t['peharabic'] = 0x067E;
  16573. t['peharmenian'] = 0x057A;
  16574. t['pehebrew'] = 0x05E4;
  16575. t['pehfinalarabic'] = 0xFB57;
  16576. t['pehinitialarabic'] = 0xFB58;
  16577. t['pehiragana'] = 0x307A;
  16578. t['pehmedialarabic'] = 0xFB59;
  16579. t['pekatakana'] = 0x30DA;
  16580. t['pemiddlehookcyrillic'] = 0x04A7;
  16581. t['perafehebrew'] = 0xFB4E;
  16582. t['percent'] = 0x0025;
  16583. t['percentarabic'] = 0x066A;
  16584. t['percentmonospace'] = 0xFF05;
  16585. t['percentsmall'] = 0xFE6A;
  16586. t['period'] = 0x002E;
  16587. t['periodarmenian'] = 0x0589;
  16588. t['periodcentered'] = 0x00B7;
  16589. t['periodhalfwidth'] = 0xFF61;
  16590. t['periodinferior'] = 0xF6E7;
  16591. t['periodmonospace'] = 0xFF0E;
  16592. t['periodsmall'] = 0xFE52;
  16593. t['periodsuperior'] = 0xF6E8;
  16594. t['perispomenigreekcmb'] = 0x0342;
  16595. t['perpendicular'] = 0x22A5;
  16596. t['perthousand'] = 0x2030;
  16597. t['peseta'] = 0x20A7;
  16598. t['pfsquare'] = 0x338A;
  16599. t['phabengali'] = 0x09AB;
  16600. t['phadeva'] = 0x092B;
  16601. t['phagujarati'] = 0x0AAB;
  16602. t['phagurmukhi'] = 0x0A2B;
  16603. t['phi'] = 0x03C6;
  16604. t['phi1'] = 0x03D5;
  16605. t['phieuphacirclekorean'] = 0x327A;
  16606. t['phieuphaparenkorean'] = 0x321A;
  16607. t['phieuphcirclekorean'] = 0x326C;
  16608. t['phieuphkorean'] = 0x314D;
  16609. t['phieuphparenkorean'] = 0x320C;
  16610. t['philatin'] = 0x0278;
  16611. t['phinthuthai'] = 0x0E3A;
  16612. t['phisymbolgreek'] = 0x03D5;
  16613. t['phook'] = 0x01A5;
  16614. t['phophanthai'] = 0x0E1E;
  16615. t['phophungthai'] = 0x0E1C;
  16616. t['phosamphaothai'] = 0x0E20;
  16617. t['pi'] = 0x03C0;
  16618. t['pieupacirclekorean'] = 0x3273;
  16619. t['pieupaparenkorean'] = 0x3213;
  16620. t['pieupcieuckorean'] = 0x3176;
  16621. t['pieupcirclekorean'] = 0x3265;
  16622. t['pieupkiyeokkorean'] = 0x3172;
  16623. t['pieupkorean'] = 0x3142;
  16624. t['pieupparenkorean'] = 0x3205;
  16625. t['pieupsioskiyeokkorean'] = 0x3174;
  16626. t['pieupsioskorean'] = 0x3144;
  16627. t['pieupsiostikeutkorean'] = 0x3175;
  16628. t['pieupthieuthkorean'] = 0x3177;
  16629. t['pieuptikeutkorean'] = 0x3173;
  16630. t['pihiragana'] = 0x3074;
  16631. t['pikatakana'] = 0x30D4;
  16632. t['pisymbolgreek'] = 0x03D6;
  16633. t['piwrarmenian'] = 0x0583;
  16634. t['plus'] = 0x002B;
  16635. t['plusbelowcmb'] = 0x031F;
  16636. t['pluscircle'] = 0x2295;
  16637. t['plusminus'] = 0x00B1;
  16638. t['plusmod'] = 0x02D6;
  16639. t['plusmonospace'] = 0xFF0B;
  16640. t['plussmall'] = 0xFE62;
  16641. t['plussuperior'] = 0x207A;
  16642. t['pmonospace'] = 0xFF50;
  16643. t['pmsquare'] = 0x33D8;
  16644. t['pohiragana'] = 0x307D;
  16645. t['pointingindexdownwhite'] = 0x261F;
  16646. t['pointingindexleftwhite'] = 0x261C;
  16647. t['pointingindexrightwhite'] = 0x261E;
  16648. t['pointingindexupwhite'] = 0x261D;
  16649. t['pokatakana'] = 0x30DD;
  16650. t['poplathai'] = 0x0E1B;
  16651. t['postalmark'] = 0x3012;
  16652. t['postalmarkface'] = 0x3020;
  16653. t['pparen'] = 0x24AB;
  16654. t['precedes'] = 0x227A;
  16655. t['prescription'] = 0x211E;
  16656. t['primemod'] = 0x02B9;
  16657. t['primereversed'] = 0x2035;
  16658. t['product'] = 0x220F;
  16659. t['projective'] = 0x2305;
  16660. t['prolongedkana'] = 0x30FC;
  16661. t['propellor'] = 0x2318;
  16662. t['propersubset'] = 0x2282;
  16663. t['propersuperset'] = 0x2283;
  16664. t['proportion'] = 0x2237;
  16665. t['proportional'] = 0x221D;
  16666. t['psi'] = 0x03C8;
  16667. t['psicyrillic'] = 0x0471;
  16668. t['psilipneumatacyrilliccmb'] = 0x0486;
  16669. t['pssquare'] = 0x33B0;
  16670. t['puhiragana'] = 0x3077;
  16671. t['pukatakana'] = 0x30D7;
  16672. t['pvsquare'] = 0x33B4;
  16673. t['pwsquare'] = 0x33BA;
  16674. t['q'] = 0x0071;
  16675. t['qadeva'] = 0x0958;
  16676. t['qadmahebrew'] = 0x05A8;
  16677. t['qafarabic'] = 0x0642;
  16678. t['qaffinalarabic'] = 0xFED6;
  16679. t['qafinitialarabic'] = 0xFED7;
  16680. t['qafmedialarabic'] = 0xFED8;
  16681. t['qamats'] = 0x05B8;
  16682. t['qamats10'] = 0x05B8;
  16683. t['qamats1a'] = 0x05B8;
  16684. t['qamats1c'] = 0x05B8;
  16685. t['qamats27'] = 0x05B8;
  16686. t['qamats29'] = 0x05B8;
  16687. t['qamats33'] = 0x05B8;
  16688. t['qamatsde'] = 0x05B8;
  16689. t['qamatshebrew'] = 0x05B8;
  16690. t['qamatsnarrowhebrew'] = 0x05B8;
  16691. t['qamatsqatanhebrew'] = 0x05B8;
  16692. t['qamatsqatannarrowhebrew'] = 0x05B8;
  16693. t['qamatsqatanquarterhebrew'] = 0x05B8;
  16694. t['qamatsqatanwidehebrew'] = 0x05B8;
  16695. t['qamatsquarterhebrew'] = 0x05B8;
  16696. t['qamatswidehebrew'] = 0x05B8;
  16697. t['qarneyparahebrew'] = 0x059F;
  16698. t['qbopomofo'] = 0x3111;
  16699. t['qcircle'] = 0x24E0;
  16700. t['qhook'] = 0x02A0;
  16701. t['qmonospace'] = 0xFF51;
  16702. t['qof'] = 0x05E7;
  16703. t['qofdagesh'] = 0xFB47;
  16704. t['qofdageshhebrew'] = 0xFB47;
  16705. t['qofhebrew'] = 0x05E7;
  16706. t['qparen'] = 0x24AC;
  16707. t['quarternote'] = 0x2669;
  16708. t['qubuts'] = 0x05BB;
  16709. t['qubuts18'] = 0x05BB;
  16710. t['qubuts25'] = 0x05BB;
  16711. t['qubuts31'] = 0x05BB;
  16712. t['qubutshebrew'] = 0x05BB;
  16713. t['qubutsnarrowhebrew'] = 0x05BB;
  16714. t['qubutsquarterhebrew'] = 0x05BB;
  16715. t['qubutswidehebrew'] = 0x05BB;
  16716. t['question'] = 0x003F;
  16717. t['questionarabic'] = 0x061F;
  16718. t['questionarmenian'] = 0x055E;
  16719. t['questiondown'] = 0x00BF;
  16720. t['questiondownsmall'] = 0xF7BF;
  16721. t['questiongreek'] = 0x037E;
  16722. t['questionmonospace'] = 0xFF1F;
  16723. t['questionsmall'] = 0xF73F;
  16724. t['quotedbl'] = 0x0022;
  16725. t['quotedblbase'] = 0x201E;
  16726. t['quotedblleft'] = 0x201C;
  16727. t['quotedblmonospace'] = 0xFF02;
  16728. t['quotedblprime'] = 0x301E;
  16729. t['quotedblprimereversed'] = 0x301D;
  16730. t['quotedblright'] = 0x201D;
  16731. t['quoteleft'] = 0x2018;
  16732. t['quoteleftreversed'] = 0x201B;
  16733. t['quotereversed'] = 0x201B;
  16734. t['quoteright'] = 0x2019;
  16735. t['quoterightn'] = 0x0149;
  16736. t['quotesinglbase'] = 0x201A;
  16737. t['quotesingle'] = 0x0027;
  16738. t['quotesinglemonospace'] = 0xFF07;
  16739. t['r'] = 0x0072;
  16740. t['raarmenian'] = 0x057C;
  16741. t['rabengali'] = 0x09B0;
  16742. t['racute'] = 0x0155;
  16743. t['radeva'] = 0x0930;
  16744. t['radical'] = 0x221A;
  16745. t['radicalex'] = 0xF8E5;
  16746. t['radoverssquare'] = 0x33AE;
  16747. t['radoverssquaredsquare'] = 0x33AF;
  16748. t['radsquare'] = 0x33AD;
  16749. t['rafe'] = 0x05BF;
  16750. t['rafehebrew'] = 0x05BF;
  16751. t['ragujarati'] = 0x0AB0;
  16752. t['ragurmukhi'] = 0x0A30;
  16753. t['rahiragana'] = 0x3089;
  16754. t['rakatakana'] = 0x30E9;
  16755. t['rakatakanahalfwidth'] = 0xFF97;
  16756. t['ralowerdiagonalbengali'] = 0x09F1;
  16757. t['ramiddlediagonalbengali'] = 0x09F0;
  16758. t['ramshorn'] = 0x0264;
  16759. t['ratio'] = 0x2236;
  16760. t['rbopomofo'] = 0x3116;
  16761. t['rcaron'] = 0x0159;
  16762. t['rcedilla'] = 0x0157;
  16763. t['rcircle'] = 0x24E1;
  16764. t['rcommaaccent'] = 0x0157;
  16765. t['rdblgrave'] = 0x0211;
  16766. t['rdotaccent'] = 0x1E59;
  16767. t['rdotbelow'] = 0x1E5B;
  16768. t['rdotbelowmacron'] = 0x1E5D;
  16769. t['referencemark'] = 0x203B;
  16770. t['reflexsubset'] = 0x2286;
  16771. t['reflexsuperset'] = 0x2287;
  16772. t['registered'] = 0x00AE;
  16773. t['registersans'] = 0xF8E8;
  16774. t['registerserif'] = 0xF6DA;
  16775. t['reharabic'] = 0x0631;
  16776. t['reharmenian'] = 0x0580;
  16777. t['rehfinalarabic'] = 0xFEAE;
  16778. t['rehiragana'] = 0x308C;
  16779. t['rekatakana'] = 0x30EC;
  16780. t['rekatakanahalfwidth'] = 0xFF9A;
  16781. t['resh'] = 0x05E8;
  16782. t['reshdageshhebrew'] = 0xFB48;
  16783. t['reshhebrew'] = 0x05E8;
  16784. t['reversedtilde'] = 0x223D;
  16785. t['reviahebrew'] = 0x0597;
  16786. t['reviamugrashhebrew'] = 0x0597;
  16787. t['revlogicalnot'] = 0x2310;
  16788. t['rfishhook'] = 0x027E;
  16789. t['rfishhookreversed'] = 0x027F;
  16790. t['rhabengali'] = 0x09DD;
  16791. t['rhadeva'] = 0x095D;
  16792. t['rho'] = 0x03C1;
  16793. t['rhook'] = 0x027D;
  16794. t['rhookturned'] = 0x027B;
  16795. t['rhookturnedsuperior'] = 0x02B5;
  16796. t['rhosymbolgreek'] = 0x03F1;
  16797. t['rhotichookmod'] = 0x02DE;
  16798. t['rieulacirclekorean'] = 0x3271;
  16799. t['rieulaparenkorean'] = 0x3211;
  16800. t['rieulcirclekorean'] = 0x3263;
  16801. t['rieulhieuhkorean'] = 0x3140;
  16802. t['rieulkiyeokkorean'] = 0x313A;
  16803. t['rieulkiyeoksioskorean'] = 0x3169;
  16804. t['rieulkorean'] = 0x3139;
  16805. t['rieulmieumkorean'] = 0x313B;
  16806. t['rieulpansioskorean'] = 0x316C;
  16807. t['rieulparenkorean'] = 0x3203;
  16808. t['rieulphieuphkorean'] = 0x313F;
  16809. t['rieulpieupkorean'] = 0x313C;
  16810. t['rieulpieupsioskorean'] = 0x316B;
  16811. t['rieulsioskorean'] = 0x313D;
  16812. t['rieulthieuthkorean'] = 0x313E;
  16813. t['rieultikeutkorean'] = 0x316A;
  16814. t['rieulyeorinhieuhkorean'] = 0x316D;
  16815. t['rightangle'] = 0x221F;
  16816. t['righttackbelowcmb'] = 0x0319;
  16817. t['righttriangle'] = 0x22BF;
  16818. t['rihiragana'] = 0x308A;
  16819. t['rikatakana'] = 0x30EA;
  16820. t['rikatakanahalfwidth'] = 0xFF98;
  16821. t['ring'] = 0x02DA;
  16822. t['ringbelowcmb'] = 0x0325;
  16823. t['ringcmb'] = 0x030A;
  16824. t['ringhalfleft'] = 0x02BF;
  16825. t['ringhalfleftarmenian'] = 0x0559;
  16826. t['ringhalfleftbelowcmb'] = 0x031C;
  16827. t['ringhalfleftcentered'] = 0x02D3;
  16828. t['ringhalfright'] = 0x02BE;
  16829. t['ringhalfrightbelowcmb'] = 0x0339;
  16830. t['ringhalfrightcentered'] = 0x02D2;
  16831. t['rinvertedbreve'] = 0x0213;
  16832. t['rittorusquare'] = 0x3351;
  16833. t['rlinebelow'] = 0x1E5F;
  16834. t['rlongleg'] = 0x027C;
  16835. t['rlonglegturned'] = 0x027A;
  16836. t['rmonospace'] = 0xFF52;
  16837. t['rohiragana'] = 0x308D;
  16838. t['rokatakana'] = 0x30ED;
  16839. t['rokatakanahalfwidth'] = 0xFF9B;
  16840. t['roruathai'] = 0x0E23;
  16841. t['rparen'] = 0x24AD;
  16842. t['rrabengali'] = 0x09DC;
  16843. t['rradeva'] = 0x0931;
  16844. t['rragurmukhi'] = 0x0A5C;
  16845. t['rreharabic'] = 0x0691;
  16846. t['rrehfinalarabic'] = 0xFB8D;
  16847. t['rrvocalicbengali'] = 0x09E0;
  16848. t['rrvocalicdeva'] = 0x0960;
  16849. t['rrvocalicgujarati'] = 0x0AE0;
  16850. t['rrvocalicvowelsignbengali'] = 0x09C4;
  16851. t['rrvocalicvowelsigndeva'] = 0x0944;
  16852. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  16853. t['rsuperior'] = 0xF6F1;
  16854. t['rtblock'] = 0x2590;
  16855. t['rturned'] = 0x0279;
  16856. t['rturnedsuperior'] = 0x02B4;
  16857. t['ruhiragana'] = 0x308B;
  16858. t['rukatakana'] = 0x30EB;
  16859. t['rukatakanahalfwidth'] = 0xFF99;
  16860. t['rupeemarkbengali'] = 0x09F2;
  16861. t['rupeesignbengali'] = 0x09F3;
  16862. t['rupiah'] = 0xF6DD;
  16863. t['ruthai'] = 0x0E24;
  16864. t['rvocalicbengali'] = 0x098B;
  16865. t['rvocalicdeva'] = 0x090B;
  16866. t['rvocalicgujarati'] = 0x0A8B;
  16867. t['rvocalicvowelsignbengali'] = 0x09C3;
  16868. t['rvocalicvowelsigndeva'] = 0x0943;
  16869. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  16870. t['s'] = 0x0073;
  16871. t['sabengali'] = 0x09B8;
  16872. t['sacute'] = 0x015B;
  16873. t['sacutedotaccent'] = 0x1E65;
  16874. t['sadarabic'] = 0x0635;
  16875. t['sadeva'] = 0x0938;
  16876. t['sadfinalarabic'] = 0xFEBA;
  16877. t['sadinitialarabic'] = 0xFEBB;
  16878. t['sadmedialarabic'] = 0xFEBC;
  16879. t['sagujarati'] = 0x0AB8;
  16880. t['sagurmukhi'] = 0x0A38;
  16881. t['sahiragana'] = 0x3055;
  16882. t['sakatakana'] = 0x30B5;
  16883. t['sakatakanahalfwidth'] = 0xFF7B;
  16884. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  16885. t['samekh'] = 0x05E1;
  16886. t['samekhdagesh'] = 0xFB41;
  16887. t['samekhdageshhebrew'] = 0xFB41;
  16888. t['samekhhebrew'] = 0x05E1;
  16889. t['saraaathai'] = 0x0E32;
  16890. t['saraaethai'] = 0x0E41;
  16891. t['saraaimaimalaithai'] = 0x0E44;
  16892. t['saraaimaimuanthai'] = 0x0E43;
  16893. t['saraamthai'] = 0x0E33;
  16894. t['saraathai'] = 0x0E30;
  16895. t['saraethai'] = 0x0E40;
  16896. t['saraiileftthai'] = 0xF886;
  16897. t['saraiithai'] = 0x0E35;
  16898. t['saraileftthai'] = 0xF885;
  16899. t['saraithai'] = 0x0E34;
  16900. t['saraothai'] = 0x0E42;
  16901. t['saraueeleftthai'] = 0xF888;
  16902. t['saraueethai'] = 0x0E37;
  16903. t['saraueleftthai'] = 0xF887;
  16904. t['sarauethai'] = 0x0E36;
  16905. t['sarauthai'] = 0x0E38;
  16906. t['sarauuthai'] = 0x0E39;
  16907. t['sbopomofo'] = 0x3119;
  16908. t['scaron'] = 0x0161;
  16909. t['scarondotaccent'] = 0x1E67;
  16910. t['scedilla'] = 0x015F;
  16911. t['schwa'] = 0x0259;
  16912. t['schwacyrillic'] = 0x04D9;
  16913. t['schwadieresiscyrillic'] = 0x04DB;
  16914. t['schwahook'] = 0x025A;
  16915. t['scircle'] = 0x24E2;
  16916. t['scircumflex'] = 0x015D;
  16917. t['scommaaccent'] = 0x0219;
  16918. t['sdotaccent'] = 0x1E61;
  16919. t['sdotbelow'] = 0x1E63;
  16920. t['sdotbelowdotaccent'] = 0x1E69;
  16921. t['seagullbelowcmb'] = 0x033C;
  16922. t['second'] = 0x2033;
  16923. t['secondtonechinese'] = 0x02CA;
  16924. t['section'] = 0x00A7;
  16925. t['seenarabic'] = 0x0633;
  16926. t['seenfinalarabic'] = 0xFEB2;
  16927. t['seeninitialarabic'] = 0xFEB3;
  16928. t['seenmedialarabic'] = 0xFEB4;
  16929. t['segol'] = 0x05B6;
  16930. t['segol13'] = 0x05B6;
  16931. t['segol1f'] = 0x05B6;
  16932. t['segol2c'] = 0x05B6;
  16933. t['segolhebrew'] = 0x05B6;
  16934. t['segolnarrowhebrew'] = 0x05B6;
  16935. t['segolquarterhebrew'] = 0x05B6;
  16936. t['segoltahebrew'] = 0x0592;
  16937. t['segolwidehebrew'] = 0x05B6;
  16938. t['seharmenian'] = 0x057D;
  16939. t['sehiragana'] = 0x305B;
  16940. t['sekatakana'] = 0x30BB;
  16941. t['sekatakanahalfwidth'] = 0xFF7E;
  16942. t['semicolon'] = 0x003B;
  16943. t['semicolonarabic'] = 0x061B;
  16944. t['semicolonmonospace'] = 0xFF1B;
  16945. t['semicolonsmall'] = 0xFE54;
  16946. t['semivoicedmarkkana'] = 0x309C;
  16947. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  16948. t['sentisquare'] = 0x3322;
  16949. t['sentosquare'] = 0x3323;
  16950. t['seven'] = 0x0037;
  16951. t['sevenarabic'] = 0x0667;
  16952. t['sevenbengali'] = 0x09ED;
  16953. t['sevencircle'] = 0x2466;
  16954. t['sevencircleinversesansserif'] = 0x2790;
  16955. t['sevendeva'] = 0x096D;
  16956. t['seveneighths'] = 0x215E;
  16957. t['sevengujarati'] = 0x0AED;
  16958. t['sevengurmukhi'] = 0x0A6D;
  16959. t['sevenhackarabic'] = 0x0667;
  16960. t['sevenhangzhou'] = 0x3027;
  16961. t['sevenideographicparen'] = 0x3226;
  16962. t['seveninferior'] = 0x2087;
  16963. t['sevenmonospace'] = 0xFF17;
  16964. t['sevenoldstyle'] = 0xF737;
  16965. t['sevenparen'] = 0x247A;
  16966. t['sevenperiod'] = 0x248E;
  16967. t['sevenpersian'] = 0x06F7;
  16968. t['sevenroman'] = 0x2176;
  16969. t['sevensuperior'] = 0x2077;
  16970. t['seventeencircle'] = 0x2470;
  16971. t['seventeenparen'] = 0x2484;
  16972. t['seventeenperiod'] = 0x2498;
  16973. t['seventhai'] = 0x0E57;
  16974. t['sfthyphen'] = 0x00AD;
  16975. t['shaarmenian'] = 0x0577;
  16976. t['shabengali'] = 0x09B6;
  16977. t['shacyrillic'] = 0x0448;
  16978. t['shaddaarabic'] = 0x0651;
  16979. t['shaddadammaarabic'] = 0xFC61;
  16980. t['shaddadammatanarabic'] = 0xFC5E;
  16981. t['shaddafathaarabic'] = 0xFC60;
  16982. t['shaddakasraarabic'] = 0xFC62;
  16983. t['shaddakasratanarabic'] = 0xFC5F;
  16984. t['shade'] = 0x2592;
  16985. t['shadedark'] = 0x2593;
  16986. t['shadelight'] = 0x2591;
  16987. t['shademedium'] = 0x2592;
  16988. t['shadeva'] = 0x0936;
  16989. t['shagujarati'] = 0x0AB6;
  16990. t['shagurmukhi'] = 0x0A36;
  16991. t['shalshelethebrew'] = 0x0593;
  16992. t['shbopomofo'] = 0x3115;
  16993. t['shchacyrillic'] = 0x0449;
  16994. t['sheenarabic'] = 0x0634;
  16995. t['sheenfinalarabic'] = 0xFEB6;
  16996. t['sheeninitialarabic'] = 0xFEB7;
  16997. t['sheenmedialarabic'] = 0xFEB8;
  16998. t['sheicoptic'] = 0x03E3;
  16999. t['sheqel'] = 0x20AA;
  17000. t['sheqelhebrew'] = 0x20AA;
  17001. t['sheva'] = 0x05B0;
  17002. t['sheva115'] = 0x05B0;
  17003. t['sheva15'] = 0x05B0;
  17004. t['sheva22'] = 0x05B0;
  17005. t['sheva2e'] = 0x05B0;
  17006. t['shevahebrew'] = 0x05B0;
  17007. t['shevanarrowhebrew'] = 0x05B0;
  17008. t['shevaquarterhebrew'] = 0x05B0;
  17009. t['shevawidehebrew'] = 0x05B0;
  17010. t['shhacyrillic'] = 0x04BB;
  17011. t['shimacoptic'] = 0x03ED;
  17012. t['shin'] = 0x05E9;
  17013. t['shindagesh'] = 0xFB49;
  17014. t['shindageshhebrew'] = 0xFB49;
  17015. t['shindageshshindot'] = 0xFB2C;
  17016. t['shindageshshindothebrew'] = 0xFB2C;
  17017. t['shindageshsindot'] = 0xFB2D;
  17018. t['shindageshsindothebrew'] = 0xFB2D;
  17019. t['shindothebrew'] = 0x05C1;
  17020. t['shinhebrew'] = 0x05E9;
  17021. t['shinshindot'] = 0xFB2A;
  17022. t['shinshindothebrew'] = 0xFB2A;
  17023. t['shinsindot'] = 0xFB2B;
  17024. t['shinsindothebrew'] = 0xFB2B;
  17025. t['shook'] = 0x0282;
  17026. t['sigma'] = 0x03C3;
  17027. t['sigma1'] = 0x03C2;
  17028. t['sigmafinal'] = 0x03C2;
  17029. t['sigmalunatesymbolgreek'] = 0x03F2;
  17030. t['sihiragana'] = 0x3057;
  17031. t['sikatakana'] = 0x30B7;
  17032. t['sikatakanahalfwidth'] = 0xFF7C;
  17033. t['siluqhebrew'] = 0x05BD;
  17034. t['siluqlefthebrew'] = 0x05BD;
  17035. t['similar'] = 0x223C;
  17036. t['sindothebrew'] = 0x05C2;
  17037. t['siosacirclekorean'] = 0x3274;
  17038. t['siosaparenkorean'] = 0x3214;
  17039. t['sioscieuckorean'] = 0x317E;
  17040. t['sioscirclekorean'] = 0x3266;
  17041. t['sioskiyeokkorean'] = 0x317A;
  17042. t['sioskorean'] = 0x3145;
  17043. t['siosnieunkorean'] = 0x317B;
  17044. t['siosparenkorean'] = 0x3206;
  17045. t['siospieupkorean'] = 0x317D;
  17046. t['siostikeutkorean'] = 0x317C;
  17047. t['six'] = 0x0036;
  17048. t['sixarabic'] = 0x0666;
  17049. t['sixbengali'] = 0x09EC;
  17050. t['sixcircle'] = 0x2465;
  17051. t['sixcircleinversesansserif'] = 0x278F;
  17052. t['sixdeva'] = 0x096C;
  17053. t['sixgujarati'] = 0x0AEC;
  17054. t['sixgurmukhi'] = 0x0A6C;
  17055. t['sixhackarabic'] = 0x0666;
  17056. t['sixhangzhou'] = 0x3026;
  17057. t['sixideographicparen'] = 0x3225;
  17058. t['sixinferior'] = 0x2086;
  17059. t['sixmonospace'] = 0xFF16;
  17060. t['sixoldstyle'] = 0xF736;
  17061. t['sixparen'] = 0x2479;
  17062. t['sixperiod'] = 0x248D;
  17063. t['sixpersian'] = 0x06F6;
  17064. t['sixroman'] = 0x2175;
  17065. t['sixsuperior'] = 0x2076;
  17066. t['sixteencircle'] = 0x246F;
  17067. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17068. t['sixteenparen'] = 0x2483;
  17069. t['sixteenperiod'] = 0x2497;
  17070. t['sixthai'] = 0x0E56;
  17071. t['slash'] = 0x002F;
  17072. t['slashmonospace'] = 0xFF0F;
  17073. t['slong'] = 0x017F;
  17074. t['slongdotaccent'] = 0x1E9B;
  17075. t['smileface'] = 0x263A;
  17076. t['smonospace'] = 0xFF53;
  17077. t['sofpasuqhebrew'] = 0x05C3;
  17078. t['softhyphen'] = 0x00AD;
  17079. t['softsigncyrillic'] = 0x044C;
  17080. t['sohiragana'] = 0x305D;
  17081. t['sokatakana'] = 0x30BD;
  17082. t['sokatakanahalfwidth'] = 0xFF7F;
  17083. t['soliduslongoverlaycmb'] = 0x0338;
  17084. t['solidusshortoverlaycmb'] = 0x0337;
  17085. t['sorusithai'] = 0x0E29;
  17086. t['sosalathai'] = 0x0E28;
  17087. t['sosothai'] = 0x0E0B;
  17088. t['sosuathai'] = 0x0E2A;
  17089. t['space'] = 0x0020;
  17090. t['spacehackarabic'] = 0x0020;
  17091. t['spade'] = 0x2660;
  17092. t['spadesuitblack'] = 0x2660;
  17093. t['spadesuitwhite'] = 0x2664;
  17094. t['sparen'] = 0x24AE;
  17095. t['squarebelowcmb'] = 0x033B;
  17096. t['squarecc'] = 0x33C4;
  17097. t['squarecm'] = 0x339D;
  17098. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17099. t['squarehorizontalfill'] = 0x25A4;
  17100. t['squarekg'] = 0x338F;
  17101. t['squarekm'] = 0x339E;
  17102. t['squarekmcapital'] = 0x33CE;
  17103. t['squareln'] = 0x33D1;
  17104. t['squarelog'] = 0x33D2;
  17105. t['squaremg'] = 0x338E;
  17106. t['squaremil'] = 0x33D5;
  17107. t['squaremm'] = 0x339C;
  17108. t['squaremsquared'] = 0x33A1;
  17109. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17110. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17111. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17112. t['squareverticalfill'] = 0x25A5;
  17113. t['squarewhitewithsmallblack'] = 0x25A3;
  17114. t['srsquare'] = 0x33DB;
  17115. t['ssabengali'] = 0x09B7;
  17116. t['ssadeva'] = 0x0937;
  17117. t['ssagujarati'] = 0x0AB7;
  17118. t['ssangcieuckorean'] = 0x3149;
  17119. t['ssanghieuhkorean'] = 0x3185;
  17120. t['ssangieungkorean'] = 0x3180;
  17121. t['ssangkiyeokkorean'] = 0x3132;
  17122. t['ssangnieunkorean'] = 0x3165;
  17123. t['ssangpieupkorean'] = 0x3143;
  17124. t['ssangsioskorean'] = 0x3146;
  17125. t['ssangtikeutkorean'] = 0x3138;
  17126. t['ssuperior'] = 0xF6F2;
  17127. t['sterling'] = 0x00A3;
  17128. t['sterlingmonospace'] = 0xFFE1;
  17129. t['strokelongoverlaycmb'] = 0x0336;
  17130. t['strokeshortoverlaycmb'] = 0x0335;
  17131. t['subset'] = 0x2282;
  17132. t['subsetnotequal'] = 0x228A;
  17133. t['subsetorequal'] = 0x2286;
  17134. t['succeeds'] = 0x227B;
  17135. t['suchthat'] = 0x220B;
  17136. t['suhiragana'] = 0x3059;
  17137. t['sukatakana'] = 0x30B9;
  17138. t['sukatakanahalfwidth'] = 0xFF7D;
  17139. t['sukunarabic'] = 0x0652;
  17140. t['summation'] = 0x2211;
  17141. t['sun'] = 0x263C;
  17142. t['superset'] = 0x2283;
  17143. t['supersetnotequal'] = 0x228B;
  17144. t['supersetorequal'] = 0x2287;
  17145. t['svsquare'] = 0x33DC;
  17146. t['syouwaerasquare'] = 0x337C;
  17147. t['t'] = 0x0074;
  17148. t['tabengali'] = 0x09A4;
  17149. t['tackdown'] = 0x22A4;
  17150. t['tackleft'] = 0x22A3;
  17151. t['tadeva'] = 0x0924;
  17152. t['tagujarati'] = 0x0AA4;
  17153. t['tagurmukhi'] = 0x0A24;
  17154. t['taharabic'] = 0x0637;
  17155. t['tahfinalarabic'] = 0xFEC2;
  17156. t['tahinitialarabic'] = 0xFEC3;
  17157. t['tahiragana'] = 0x305F;
  17158. t['tahmedialarabic'] = 0xFEC4;
  17159. t['taisyouerasquare'] = 0x337D;
  17160. t['takatakana'] = 0x30BF;
  17161. t['takatakanahalfwidth'] = 0xFF80;
  17162. t['tatweelarabic'] = 0x0640;
  17163. t['tau'] = 0x03C4;
  17164. t['tav'] = 0x05EA;
  17165. t['tavdages'] = 0xFB4A;
  17166. t['tavdagesh'] = 0xFB4A;
  17167. t['tavdageshhebrew'] = 0xFB4A;
  17168. t['tavhebrew'] = 0x05EA;
  17169. t['tbar'] = 0x0167;
  17170. t['tbopomofo'] = 0x310A;
  17171. t['tcaron'] = 0x0165;
  17172. t['tccurl'] = 0x02A8;
  17173. t['tcedilla'] = 0x0163;
  17174. t['tcheharabic'] = 0x0686;
  17175. t['tchehfinalarabic'] = 0xFB7B;
  17176. t['tchehinitialarabic'] = 0xFB7C;
  17177. t['tchehmedialarabic'] = 0xFB7D;
  17178. t['tcircle'] = 0x24E3;
  17179. t['tcircumflexbelow'] = 0x1E71;
  17180. t['tcommaaccent'] = 0x0163;
  17181. t['tdieresis'] = 0x1E97;
  17182. t['tdotaccent'] = 0x1E6B;
  17183. t['tdotbelow'] = 0x1E6D;
  17184. t['tecyrillic'] = 0x0442;
  17185. t['tedescendercyrillic'] = 0x04AD;
  17186. t['teharabic'] = 0x062A;
  17187. t['tehfinalarabic'] = 0xFE96;
  17188. t['tehhahinitialarabic'] = 0xFCA2;
  17189. t['tehhahisolatedarabic'] = 0xFC0C;
  17190. t['tehinitialarabic'] = 0xFE97;
  17191. t['tehiragana'] = 0x3066;
  17192. t['tehjeeminitialarabic'] = 0xFCA1;
  17193. t['tehjeemisolatedarabic'] = 0xFC0B;
  17194. t['tehmarbutaarabic'] = 0x0629;
  17195. t['tehmarbutafinalarabic'] = 0xFE94;
  17196. t['tehmedialarabic'] = 0xFE98;
  17197. t['tehmeeminitialarabic'] = 0xFCA4;
  17198. t['tehmeemisolatedarabic'] = 0xFC0E;
  17199. t['tehnoonfinalarabic'] = 0xFC73;
  17200. t['tekatakana'] = 0x30C6;
  17201. t['tekatakanahalfwidth'] = 0xFF83;
  17202. t['telephone'] = 0x2121;
  17203. t['telephoneblack'] = 0x260E;
  17204. t['telishagedolahebrew'] = 0x05A0;
  17205. t['telishaqetanahebrew'] = 0x05A9;
  17206. t['tencircle'] = 0x2469;
  17207. t['tenideographicparen'] = 0x3229;
  17208. t['tenparen'] = 0x247D;
  17209. t['tenperiod'] = 0x2491;
  17210. t['tenroman'] = 0x2179;
  17211. t['tesh'] = 0x02A7;
  17212. t['tet'] = 0x05D8;
  17213. t['tetdagesh'] = 0xFB38;
  17214. t['tetdageshhebrew'] = 0xFB38;
  17215. t['tethebrew'] = 0x05D8;
  17216. t['tetsecyrillic'] = 0x04B5;
  17217. t['tevirhebrew'] = 0x059B;
  17218. t['tevirlefthebrew'] = 0x059B;
  17219. t['thabengali'] = 0x09A5;
  17220. t['thadeva'] = 0x0925;
  17221. t['thagujarati'] = 0x0AA5;
  17222. t['thagurmukhi'] = 0x0A25;
  17223. t['thalarabic'] = 0x0630;
  17224. t['thalfinalarabic'] = 0xFEAC;
  17225. t['thanthakhatlowleftthai'] = 0xF898;
  17226. t['thanthakhatlowrightthai'] = 0xF897;
  17227. t['thanthakhatthai'] = 0x0E4C;
  17228. t['thanthakhatupperleftthai'] = 0xF896;
  17229. t['theharabic'] = 0x062B;
  17230. t['thehfinalarabic'] = 0xFE9A;
  17231. t['thehinitialarabic'] = 0xFE9B;
  17232. t['thehmedialarabic'] = 0xFE9C;
  17233. t['thereexists'] = 0x2203;
  17234. t['therefore'] = 0x2234;
  17235. t['theta'] = 0x03B8;
  17236. t['theta1'] = 0x03D1;
  17237. t['thetasymbolgreek'] = 0x03D1;
  17238. t['thieuthacirclekorean'] = 0x3279;
  17239. t['thieuthaparenkorean'] = 0x3219;
  17240. t['thieuthcirclekorean'] = 0x326B;
  17241. t['thieuthkorean'] = 0x314C;
  17242. t['thieuthparenkorean'] = 0x320B;
  17243. t['thirteencircle'] = 0x246C;
  17244. t['thirteenparen'] = 0x2480;
  17245. t['thirteenperiod'] = 0x2494;
  17246. t['thonangmonthothai'] = 0x0E11;
  17247. t['thook'] = 0x01AD;
  17248. t['thophuthaothai'] = 0x0E12;
  17249. t['thorn'] = 0x00FE;
  17250. t['thothahanthai'] = 0x0E17;
  17251. t['thothanthai'] = 0x0E10;
  17252. t['thothongthai'] = 0x0E18;
  17253. t['thothungthai'] = 0x0E16;
  17254. t['thousandcyrillic'] = 0x0482;
  17255. t['thousandsseparatorarabic'] = 0x066C;
  17256. t['thousandsseparatorpersian'] = 0x066C;
  17257. t['three'] = 0x0033;
  17258. t['threearabic'] = 0x0663;
  17259. t['threebengali'] = 0x09E9;
  17260. t['threecircle'] = 0x2462;
  17261. t['threecircleinversesansserif'] = 0x278C;
  17262. t['threedeva'] = 0x0969;
  17263. t['threeeighths'] = 0x215C;
  17264. t['threegujarati'] = 0x0AE9;
  17265. t['threegurmukhi'] = 0x0A69;
  17266. t['threehackarabic'] = 0x0663;
  17267. t['threehangzhou'] = 0x3023;
  17268. t['threeideographicparen'] = 0x3222;
  17269. t['threeinferior'] = 0x2083;
  17270. t['threemonospace'] = 0xFF13;
  17271. t['threenumeratorbengali'] = 0x09F6;
  17272. t['threeoldstyle'] = 0xF733;
  17273. t['threeparen'] = 0x2476;
  17274. t['threeperiod'] = 0x248A;
  17275. t['threepersian'] = 0x06F3;
  17276. t['threequarters'] = 0x00BE;
  17277. t['threequartersemdash'] = 0xF6DE;
  17278. t['threeroman'] = 0x2172;
  17279. t['threesuperior'] = 0x00B3;
  17280. t['threethai'] = 0x0E53;
  17281. t['thzsquare'] = 0x3394;
  17282. t['tihiragana'] = 0x3061;
  17283. t['tikatakana'] = 0x30C1;
  17284. t['tikatakanahalfwidth'] = 0xFF81;
  17285. t['tikeutacirclekorean'] = 0x3270;
  17286. t['tikeutaparenkorean'] = 0x3210;
  17287. t['tikeutcirclekorean'] = 0x3262;
  17288. t['tikeutkorean'] = 0x3137;
  17289. t['tikeutparenkorean'] = 0x3202;
  17290. t['tilde'] = 0x02DC;
  17291. t['tildebelowcmb'] = 0x0330;
  17292. t['tildecmb'] = 0x0303;
  17293. t['tildecomb'] = 0x0303;
  17294. t['tildedoublecmb'] = 0x0360;
  17295. t['tildeoperator'] = 0x223C;
  17296. t['tildeoverlaycmb'] = 0x0334;
  17297. t['tildeverticalcmb'] = 0x033E;
  17298. t['timescircle'] = 0x2297;
  17299. t['tipehahebrew'] = 0x0596;
  17300. t['tipehalefthebrew'] = 0x0596;
  17301. t['tippigurmukhi'] = 0x0A70;
  17302. t['titlocyrilliccmb'] = 0x0483;
  17303. t['tiwnarmenian'] = 0x057F;
  17304. t['tlinebelow'] = 0x1E6F;
  17305. t['tmonospace'] = 0xFF54;
  17306. t['toarmenian'] = 0x0569;
  17307. t['tohiragana'] = 0x3068;
  17308. t['tokatakana'] = 0x30C8;
  17309. t['tokatakanahalfwidth'] = 0xFF84;
  17310. t['tonebarextrahighmod'] = 0x02E5;
  17311. t['tonebarextralowmod'] = 0x02E9;
  17312. t['tonebarhighmod'] = 0x02E6;
  17313. t['tonebarlowmod'] = 0x02E8;
  17314. t['tonebarmidmod'] = 0x02E7;
  17315. t['tonefive'] = 0x01BD;
  17316. t['tonesix'] = 0x0185;
  17317. t['tonetwo'] = 0x01A8;
  17318. t['tonos'] = 0x0384;
  17319. t['tonsquare'] = 0x3327;
  17320. t['topatakthai'] = 0x0E0F;
  17321. t['tortoiseshellbracketleft'] = 0x3014;
  17322. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  17323. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  17324. t['tortoiseshellbracketright'] = 0x3015;
  17325. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  17326. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  17327. t['totaothai'] = 0x0E15;
  17328. t['tpalatalhook'] = 0x01AB;
  17329. t['tparen'] = 0x24AF;
  17330. t['trademark'] = 0x2122;
  17331. t['trademarksans'] = 0xF8EA;
  17332. t['trademarkserif'] = 0xF6DB;
  17333. t['tretroflexhook'] = 0x0288;
  17334. t['triagdn'] = 0x25BC;
  17335. t['triaglf'] = 0x25C4;
  17336. t['triagrt'] = 0x25BA;
  17337. t['triagup'] = 0x25B2;
  17338. t['ts'] = 0x02A6;
  17339. t['tsadi'] = 0x05E6;
  17340. t['tsadidagesh'] = 0xFB46;
  17341. t['tsadidageshhebrew'] = 0xFB46;
  17342. t['tsadihebrew'] = 0x05E6;
  17343. t['tsecyrillic'] = 0x0446;
  17344. t['tsere'] = 0x05B5;
  17345. t['tsere12'] = 0x05B5;
  17346. t['tsere1e'] = 0x05B5;
  17347. t['tsere2b'] = 0x05B5;
  17348. t['tserehebrew'] = 0x05B5;
  17349. t['tserenarrowhebrew'] = 0x05B5;
  17350. t['tserequarterhebrew'] = 0x05B5;
  17351. t['tserewidehebrew'] = 0x05B5;
  17352. t['tshecyrillic'] = 0x045B;
  17353. t['tsuperior'] = 0xF6F3;
  17354. t['ttabengali'] = 0x099F;
  17355. t['ttadeva'] = 0x091F;
  17356. t['ttagujarati'] = 0x0A9F;
  17357. t['ttagurmukhi'] = 0x0A1F;
  17358. t['tteharabic'] = 0x0679;
  17359. t['ttehfinalarabic'] = 0xFB67;
  17360. t['ttehinitialarabic'] = 0xFB68;
  17361. t['ttehmedialarabic'] = 0xFB69;
  17362. t['tthabengali'] = 0x09A0;
  17363. t['tthadeva'] = 0x0920;
  17364. t['tthagujarati'] = 0x0AA0;
  17365. t['tthagurmukhi'] = 0x0A20;
  17366. t['tturned'] = 0x0287;
  17367. t['tuhiragana'] = 0x3064;
  17368. t['tukatakana'] = 0x30C4;
  17369. t['tukatakanahalfwidth'] = 0xFF82;
  17370. t['tusmallhiragana'] = 0x3063;
  17371. t['tusmallkatakana'] = 0x30C3;
  17372. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  17373. t['twelvecircle'] = 0x246B;
  17374. t['twelveparen'] = 0x247F;
  17375. t['twelveperiod'] = 0x2493;
  17376. t['twelveroman'] = 0x217B;
  17377. t['twentycircle'] = 0x2473;
  17378. t['twentyhangzhou'] = 0x5344;
  17379. t['twentyparen'] = 0x2487;
  17380. t['twentyperiod'] = 0x249B;
  17381. t['two'] = 0x0032;
  17382. t['twoarabic'] = 0x0662;
  17383. t['twobengali'] = 0x09E8;
  17384. t['twocircle'] = 0x2461;
  17385. t['twocircleinversesansserif'] = 0x278B;
  17386. t['twodeva'] = 0x0968;
  17387. t['twodotenleader'] = 0x2025;
  17388. t['twodotleader'] = 0x2025;
  17389. t['twodotleadervertical'] = 0xFE30;
  17390. t['twogujarati'] = 0x0AE8;
  17391. t['twogurmukhi'] = 0x0A68;
  17392. t['twohackarabic'] = 0x0662;
  17393. t['twohangzhou'] = 0x3022;
  17394. t['twoideographicparen'] = 0x3221;
  17395. t['twoinferior'] = 0x2082;
  17396. t['twomonospace'] = 0xFF12;
  17397. t['twonumeratorbengali'] = 0x09F5;
  17398. t['twooldstyle'] = 0xF732;
  17399. t['twoparen'] = 0x2475;
  17400. t['twoperiod'] = 0x2489;
  17401. t['twopersian'] = 0x06F2;
  17402. t['tworoman'] = 0x2171;
  17403. t['twostroke'] = 0x01BB;
  17404. t['twosuperior'] = 0x00B2;
  17405. t['twothai'] = 0x0E52;
  17406. t['twothirds'] = 0x2154;
  17407. t['u'] = 0x0075;
  17408. t['uacute'] = 0x00FA;
  17409. t['ubar'] = 0x0289;
  17410. t['ubengali'] = 0x0989;
  17411. t['ubopomofo'] = 0x3128;
  17412. t['ubreve'] = 0x016D;
  17413. t['ucaron'] = 0x01D4;
  17414. t['ucircle'] = 0x24E4;
  17415. t['ucircumflex'] = 0x00FB;
  17416. t['ucircumflexbelow'] = 0x1E77;
  17417. t['ucyrillic'] = 0x0443;
  17418. t['udattadeva'] = 0x0951;
  17419. t['udblacute'] = 0x0171;
  17420. t['udblgrave'] = 0x0215;
  17421. t['udeva'] = 0x0909;
  17422. t['udieresis'] = 0x00FC;
  17423. t['udieresisacute'] = 0x01D8;
  17424. t['udieresisbelow'] = 0x1E73;
  17425. t['udieresiscaron'] = 0x01DA;
  17426. t['udieresiscyrillic'] = 0x04F1;
  17427. t['udieresisgrave'] = 0x01DC;
  17428. t['udieresismacron'] = 0x01D6;
  17429. t['udotbelow'] = 0x1EE5;
  17430. t['ugrave'] = 0x00F9;
  17431. t['ugujarati'] = 0x0A89;
  17432. t['ugurmukhi'] = 0x0A09;
  17433. t['uhiragana'] = 0x3046;
  17434. t['uhookabove'] = 0x1EE7;
  17435. t['uhorn'] = 0x01B0;
  17436. t['uhornacute'] = 0x1EE9;
  17437. t['uhorndotbelow'] = 0x1EF1;
  17438. t['uhorngrave'] = 0x1EEB;
  17439. t['uhornhookabove'] = 0x1EED;
  17440. t['uhorntilde'] = 0x1EEF;
  17441. t['uhungarumlaut'] = 0x0171;
  17442. t['uhungarumlautcyrillic'] = 0x04F3;
  17443. t['uinvertedbreve'] = 0x0217;
  17444. t['ukatakana'] = 0x30A6;
  17445. t['ukatakanahalfwidth'] = 0xFF73;
  17446. t['ukcyrillic'] = 0x0479;
  17447. t['ukorean'] = 0x315C;
  17448. t['umacron'] = 0x016B;
  17449. t['umacroncyrillic'] = 0x04EF;
  17450. t['umacrondieresis'] = 0x1E7B;
  17451. t['umatragurmukhi'] = 0x0A41;
  17452. t['umonospace'] = 0xFF55;
  17453. t['underscore'] = 0x005F;
  17454. t['underscoredbl'] = 0x2017;
  17455. t['underscoremonospace'] = 0xFF3F;
  17456. t['underscorevertical'] = 0xFE33;
  17457. t['underscorewavy'] = 0xFE4F;
  17458. t['union'] = 0x222A;
  17459. t['universal'] = 0x2200;
  17460. t['uogonek'] = 0x0173;
  17461. t['uparen'] = 0x24B0;
  17462. t['upblock'] = 0x2580;
  17463. t['upperdothebrew'] = 0x05C4;
  17464. t['upsilon'] = 0x03C5;
  17465. t['upsilondieresis'] = 0x03CB;
  17466. t['upsilondieresistonos'] = 0x03B0;
  17467. t['upsilonlatin'] = 0x028A;
  17468. t['upsilontonos'] = 0x03CD;
  17469. t['uptackbelowcmb'] = 0x031D;
  17470. t['uptackmod'] = 0x02D4;
  17471. t['uragurmukhi'] = 0x0A73;
  17472. t['uring'] = 0x016F;
  17473. t['ushortcyrillic'] = 0x045E;
  17474. t['usmallhiragana'] = 0x3045;
  17475. t['usmallkatakana'] = 0x30A5;
  17476. t['usmallkatakanahalfwidth'] = 0xFF69;
  17477. t['ustraightcyrillic'] = 0x04AF;
  17478. t['ustraightstrokecyrillic'] = 0x04B1;
  17479. t['utilde'] = 0x0169;
  17480. t['utildeacute'] = 0x1E79;
  17481. t['utildebelow'] = 0x1E75;
  17482. t['uubengali'] = 0x098A;
  17483. t['uudeva'] = 0x090A;
  17484. t['uugujarati'] = 0x0A8A;
  17485. t['uugurmukhi'] = 0x0A0A;
  17486. t['uumatragurmukhi'] = 0x0A42;
  17487. t['uuvowelsignbengali'] = 0x09C2;
  17488. t['uuvowelsigndeva'] = 0x0942;
  17489. t['uuvowelsigngujarati'] = 0x0AC2;
  17490. t['uvowelsignbengali'] = 0x09C1;
  17491. t['uvowelsigndeva'] = 0x0941;
  17492. t['uvowelsigngujarati'] = 0x0AC1;
  17493. t['v'] = 0x0076;
  17494. t['vadeva'] = 0x0935;
  17495. t['vagujarati'] = 0x0AB5;
  17496. t['vagurmukhi'] = 0x0A35;
  17497. t['vakatakana'] = 0x30F7;
  17498. t['vav'] = 0x05D5;
  17499. t['vavdagesh'] = 0xFB35;
  17500. t['vavdagesh65'] = 0xFB35;
  17501. t['vavdageshhebrew'] = 0xFB35;
  17502. t['vavhebrew'] = 0x05D5;
  17503. t['vavholam'] = 0xFB4B;
  17504. t['vavholamhebrew'] = 0xFB4B;
  17505. t['vavvavhebrew'] = 0x05F0;
  17506. t['vavyodhebrew'] = 0x05F1;
  17507. t['vcircle'] = 0x24E5;
  17508. t['vdotbelow'] = 0x1E7F;
  17509. t['vecyrillic'] = 0x0432;
  17510. t['veharabic'] = 0x06A4;
  17511. t['vehfinalarabic'] = 0xFB6B;
  17512. t['vehinitialarabic'] = 0xFB6C;
  17513. t['vehmedialarabic'] = 0xFB6D;
  17514. t['vekatakana'] = 0x30F9;
  17515. t['venus'] = 0x2640;
  17516. t['verticalbar'] = 0x007C;
  17517. t['verticallineabovecmb'] = 0x030D;
  17518. t['verticallinebelowcmb'] = 0x0329;
  17519. t['verticallinelowmod'] = 0x02CC;
  17520. t['verticallinemod'] = 0x02C8;
  17521. t['vewarmenian'] = 0x057E;
  17522. t['vhook'] = 0x028B;
  17523. t['vikatakana'] = 0x30F8;
  17524. t['viramabengali'] = 0x09CD;
  17525. t['viramadeva'] = 0x094D;
  17526. t['viramagujarati'] = 0x0ACD;
  17527. t['visargabengali'] = 0x0983;
  17528. t['visargadeva'] = 0x0903;
  17529. t['visargagujarati'] = 0x0A83;
  17530. t['vmonospace'] = 0xFF56;
  17531. t['voarmenian'] = 0x0578;
  17532. t['voicediterationhiragana'] = 0x309E;
  17533. t['voicediterationkatakana'] = 0x30FE;
  17534. t['voicedmarkkana'] = 0x309B;
  17535. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  17536. t['vokatakana'] = 0x30FA;
  17537. t['vparen'] = 0x24B1;
  17538. t['vtilde'] = 0x1E7D;
  17539. t['vturned'] = 0x028C;
  17540. t['vuhiragana'] = 0x3094;
  17541. t['vukatakana'] = 0x30F4;
  17542. t['w'] = 0x0077;
  17543. t['wacute'] = 0x1E83;
  17544. t['waekorean'] = 0x3159;
  17545. t['wahiragana'] = 0x308F;
  17546. t['wakatakana'] = 0x30EF;
  17547. t['wakatakanahalfwidth'] = 0xFF9C;
  17548. t['wakorean'] = 0x3158;
  17549. t['wasmallhiragana'] = 0x308E;
  17550. t['wasmallkatakana'] = 0x30EE;
  17551. t['wattosquare'] = 0x3357;
  17552. t['wavedash'] = 0x301C;
  17553. t['wavyunderscorevertical'] = 0xFE34;
  17554. t['wawarabic'] = 0x0648;
  17555. t['wawfinalarabic'] = 0xFEEE;
  17556. t['wawhamzaabovearabic'] = 0x0624;
  17557. t['wawhamzaabovefinalarabic'] = 0xFE86;
  17558. t['wbsquare'] = 0x33DD;
  17559. t['wcircle'] = 0x24E6;
  17560. t['wcircumflex'] = 0x0175;
  17561. t['wdieresis'] = 0x1E85;
  17562. t['wdotaccent'] = 0x1E87;
  17563. t['wdotbelow'] = 0x1E89;
  17564. t['wehiragana'] = 0x3091;
  17565. t['weierstrass'] = 0x2118;
  17566. t['wekatakana'] = 0x30F1;
  17567. t['wekorean'] = 0x315E;
  17568. t['weokorean'] = 0x315D;
  17569. t['wgrave'] = 0x1E81;
  17570. t['whitebullet'] = 0x25E6;
  17571. t['whitecircle'] = 0x25CB;
  17572. t['whitecircleinverse'] = 0x25D9;
  17573. t['whitecornerbracketleft'] = 0x300E;
  17574. t['whitecornerbracketleftvertical'] = 0xFE43;
  17575. t['whitecornerbracketright'] = 0x300F;
  17576. t['whitecornerbracketrightvertical'] = 0xFE44;
  17577. t['whitediamond'] = 0x25C7;
  17578. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  17579. t['whitedownpointingsmalltriangle'] = 0x25BF;
  17580. t['whitedownpointingtriangle'] = 0x25BD;
  17581. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  17582. t['whiteleftpointingtriangle'] = 0x25C1;
  17583. t['whitelenticularbracketleft'] = 0x3016;
  17584. t['whitelenticularbracketright'] = 0x3017;
  17585. t['whiterightpointingsmalltriangle'] = 0x25B9;
  17586. t['whiterightpointingtriangle'] = 0x25B7;
  17587. t['whitesmallsquare'] = 0x25AB;
  17588. t['whitesmilingface'] = 0x263A;
  17589. t['whitesquare'] = 0x25A1;
  17590. t['whitestar'] = 0x2606;
  17591. t['whitetelephone'] = 0x260F;
  17592. t['whitetortoiseshellbracketleft'] = 0x3018;
  17593. t['whitetortoiseshellbracketright'] = 0x3019;
  17594. t['whiteuppointingsmalltriangle'] = 0x25B5;
  17595. t['whiteuppointingtriangle'] = 0x25B3;
  17596. t['wihiragana'] = 0x3090;
  17597. t['wikatakana'] = 0x30F0;
  17598. t['wikorean'] = 0x315F;
  17599. t['wmonospace'] = 0xFF57;
  17600. t['wohiragana'] = 0x3092;
  17601. t['wokatakana'] = 0x30F2;
  17602. t['wokatakanahalfwidth'] = 0xFF66;
  17603. t['won'] = 0x20A9;
  17604. t['wonmonospace'] = 0xFFE6;
  17605. t['wowaenthai'] = 0x0E27;
  17606. t['wparen'] = 0x24B2;
  17607. t['wring'] = 0x1E98;
  17608. t['wsuperior'] = 0x02B7;
  17609. t['wturned'] = 0x028D;
  17610. t['wynn'] = 0x01BF;
  17611. t['x'] = 0x0078;
  17612. t['xabovecmb'] = 0x033D;
  17613. t['xbopomofo'] = 0x3112;
  17614. t['xcircle'] = 0x24E7;
  17615. t['xdieresis'] = 0x1E8D;
  17616. t['xdotaccent'] = 0x1E8B;
  17617. t['xeharmenian'] = 0x056D;
  17618. t['xi'] = 0x03BE;
  17619. t['xmonospace'] = 0xFF58;
  17620. t['xparen'] = 0x24B3;
  17621. t['xsuperior'] = 0x02E3;
  17622. t['y'] = 0x0079;
  17623. t['yaadosquare'] = 0x334E;
  17624. t['yabengali'] = 0x09AF;
  17625. t['yacute'] = 0x00FD;
  17626. t['yadeva'] = 0x092F;
  17627. t['yaekorean'] = 0x3152;
  17628. t['yagujarati'] = 0x0AAF;
  17629. t['yagurmukhi'] = 0x0A2F;
  17630. t['yahiragana'] = 0x3084;
  17631. t['yakatakana'] = 0x30E4;
  17632. t['yakatakanahalfwidth'] = 0xFF94;
  17633. t['yakorean'] = 0x3151;
  17634. t['yamakkanthai'] = 0x0E4E;
  17635. t['yasmallhiragana'] = 0x3083;
  17636. t['yasmallkatakana'] = 0x30E3;
  17637. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  17638. t['yatcyrillic'] = 0x0463;
  17639. t['ycircle'] = 0x24E8;
  17640. t['ycircumflex'] = 0x0177;
  17641. t['ydieresis'] = 0x00FF;
  17642. t['ydotaccent'] = 0x1E8F;
  17643. t['ydotbelow'] = 0x1EF5;
  17644. t['yeharabic'] = 0x064A;
  17645. t['yehbarreearabic'] = 0x06D2;
  17646. t['yehbarreefinalarabic'] = 0xFBAF;
  17647. t['yehfinalarabic'] = 0xFEF2;
  17648. t['yehhamzaabovearabic'] = 0x0626;
  17649. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  17650. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  17651. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  17652. t['yehinitialarabic'] = 0xFEF3;
  17653. t['yehmedialarabic'] = 0xFEF4;
  17654. t['yehmeeminitialarabic'] = 0xFCDD;
  17655. t['yehmeemisolatedarabic'] = 0xFC58;
  17656. t['yehnoonfinalarabic'] = 0xFC94;
  17657. t['yehthreedotsbelowarabic'] = 0x06D1;
  17658. t['yekorean'] = 0x3156;
  17659. t['yen'] = 0x00A5;
  17660. t['yenmonospace'] = 0xFFE5;
  17661. t['yeokorean'] = 0x3155;
  17662. t['yeorinhieuhkorean'] = 0x3186;
  17663. t['yerahbenyomohebrew'] = 0x05AA;
  17664. t['yerahbenyomolefthebrew'] = 0x05AA;
  17665. t['yericyrillic'] = 0x044B;
  17666. t['yerudieresiscyrillic'] = 0x04F9;
  17667. t['yesieungkorean'] = 0x3181;
  17668. t['yesieungpansioskorean'] = 0x3183;
  17669. t['yesieungsioskorean'] = 0x3182;
  17670. t['yetivhebrew'] = 0x059A;
  17671. t['ygrave'] = 0x1EF3;
  17672. t['yhook'] = 0x01B4;
  17673. t['yhookabove'] = 0x1EF7;
  17674. t['yiarmenian'] = 0x0575;
  17675. t['yicyrillic'] = 0x0457;
  17676. t['yikorean'] = 0x3162;
  17677. t['yinyang'] = 0x262F;
  17678. t['yiwnarmenian'] = 0x0582;
  17679. t['ymonospace'] = 0xFF59;
  17680. t['yod'] = 0x05D9;
  17681. t['yoddagesh'] = 0xFB39;
  17682. t['yoddageshhebrew'] = 0xFB39;
  17683. t['yodhebrew'] = 0x05D9;
  17684. t['yodyodhebrew'] = 0x05F2;
  17685. t['yodyodpatahhebrew'] = 0xFB1F;
  17686. t['yohiragana'] = 0x3088;
  17687. t['yoikorean'] = 0x3189;
  17688. t['yokatakana'] = 0x30E8;
  17689. t['yokatakanahalfwidth'] = 0xFF96;
  17690. t['yokorean'] = 0x315B;
  17691. t['yosmallhiragana'] = 0x3087;
  17692. t['yosmallkatakana'] = 0x30E7;
  17693. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  17694. t['yotgreek'] = 0x03F3;
  17695. t['yoyaekorean'] = 0x3188;
  17696. t['yoyakorean'] = 0x3187;
  17697. t['yoyakthai'] = 0x0E22;
  17698. t['yoyingthai'] = 0x0E0D;
  17699. t['yparen'] = 0x24B4;
  17700. t['ypogegrammeni'] = 0x037A;
  17701. t['ypogegrammenigreekcmb'] = 0x0345;
  17702. t['yr'] = 0x01A6;
  17703. t['yring'] = 0x1E99;
  17704. t['ysuperior'] = 0x02B8;
  17705. t['ytilde'] = 0x1EF9;
  17706. t['yturned'] = 0x028E;
  17707. t['yuhiragana'] = 0x3086;
  17708. t['yuikorean'] = 0x318C;
  17709. t['yukatakana'] = 0x30E6;
  17710. t['yukatakanahalfwidth'] = 0xFF95;
  17711. t['yukorean'] = 0x3160;
  17712. t['yusbigcyrillic'] = 0x046B;
  17713. t['yusbigiotifiedcyrillic'] = 0x046D;
  17714. t['yuslittlecyrillic'] = 0x0467;
  17715. t['yuslittleiotifiedcyrillic'] = 0x0469;
  17716. t['yusmallhiragana'] = 0x3085;
  17717. t['yusmallkatakana'] = 0x30E5;
  17718. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  17719. t['yuyekorean'] = 0x318B;
  17720. t['yuyeokorean'] = 0x318A;
  17721. t['yyabengali'] = 0x09DF;
  17722. t['yyadeva'] = 0x095F;
  17723. t['z'] = 0x007A;
  17724. t['zaarmenian'] = 0x0566;
  17725. t['zacute'] = 0x017A;
  17726. t['zadeva'] = 0x095B;
  17727. t['zagurmukhi'] = 0x0A5B;
  17728. t['zaharabic'] = 0x0638;
  17729. t['zahfinalarabic'] = 0xFEC6;
  17730. t['zahinitialarabic'] = 0xFEC7;
  17731. t['zahiragana'] = 0x3056;
  17732. t['zahmedialarabic'] = 0xFEC8;
  17733. t['zainarabic'] = 0x0632;
  17734. t['zainfinalarabic'] = 0xFEB0;
  17735. t['zakatakana'] = 0x30B6;
  17736. t['zaqefgadolhebrew'] = 0x0595;
  17737. t['zaqefqatanhebrew'] = 0x0594;
  17738. t['zarqahebrew'] = 0x0598;
  17739. t['zayin'] = 0x05D6;
  17740. t['zayindagesh'] = 0xFB36;
  17741. t['zayindageshhebrew'] = 0xFB36;
  17742. t['zayinhebrew'] = 0x05D6;
  17743. t['zbopomofo'] = 0x3117;
  17744. t['zcaron'] = 0x017E;
  17745. t['zcircle'] = 0x24E9;
  17746. t['zcircumflex'] = 0x1E91;
  17747. t['zcurl'] = 0x0291;
  17748. t['zdot'] = 0x017C;
  17749. t['zdotaccent'] = 0x017C;
  17750. t['zdotbelow'] = 0x1E93;
  17751. t['zecyrillic'] = 0x0437;
  17752. t['zedescendercyrillic'] = 0x0499;
  17753. t['zedieresiscyrillic'] = 0x04DF;
  17754. t['zehiragana'] = 0x305C;
  17755. t['zekatakana'] = 0x30BC;
  17756. t['zero'] = 0x0030;
  17757. t['zeroarabic'] = 0x0660;
  17758. t['zerobengali'] = 0x09E6;
  17759. t['zerodeva'] = 0x0966;
  17760. t['zerogujarati'] = 0x0AE6;
  17761. t['zerogurmukhi'] = 0x0A66;
  17762. t['zerohackarabic'] = 0x0660;
  17763. t['zeroinferior'] = 0x2080;
  17764. t['zeromonospace'] = 0xFF10;
  17765. t['zerooldstyle'] = 0xF730;
  17766. t['zeropersian'] = 0x06F0;
  17767. t['zerosuperior'] = 0x2070;
  17768. t['zerothai'] = 0x0E50;
  17769. t['zerowidthjoiner'] = 0xFEFF;
  17770. t['zerowidthnonjoiner'] = 0x200C;
  17771. t['zerowidthspace'] = 0x200B;
  17772. t['zeta'] = 0x03B6;
  17773. t['zhbopomofo'] = 0x3113;
  17774. t['zhearmenian'] = 0x056A;
  17775. t['zhebrevecyrillic'] = 0x04C2;
  17776. t['zhecyrillic'] = 0x0436;
  17777. t['zhedescendercyrillic'] = 0x0497;
  17778. t['zhedieresiscyrillic'] = 0x04DD;
  17779. t['zihiragana'] = 0x3058;
  17780. t['zikatakana'] = 0x30B8;
  17781. t['zinorhebrew'] = 0x05AE;
  17782. t['zlinebelow'] = 0x1E95;
  17783. t['zmonospace'] = 0xFF5A;
  17784. t['zohiragana'] = 0x305E;
  17785. t['zokatakana'] = 0x30BE;
  17786. t['zparen'] = 0x24B5;
  17787. t['zretroflexhook'] = 0x0290;
  17788. t['zstroke'] = 0x01B6;
  17789. t['zuhiragana'] = 0x305A;
  17790. t['zukatakana'] = 0x30BA;
  17791. t['.notdef'] = 0x0000;
  17792. t['angbracketleftbig'] = 0x2329;
  17793. t['angbracketleftBig'] = 0x2329;
  17794. t['angbracketleftbigg'] = 0x2329;
  17795. t['angbracketleftBigg'] = 0x2329;
  17796. t['angbracketrightBig'] = 0x232A;
  17797. t['angbracketrightbig'] = 0x232A;
  17798. t['angbracketrightBigg'] = 0x232A;
  17799. t['angbracketrightbigg'] = 0x232A;
  17800. t['arrowhookleft'] = 0x21AA;
  17801. t['arrowhookright'] = 0x21A9;
  17802. t['arrowlefttophalf'] = 0x21BC;
  17803. t['arrowleftbothalf'] = 0x21BD;
  17804. t['arrownortheast'] = 0x2197;
  17805. t['arrownorthwest'] = 0x2196;
  17806. t['arrowrighttophalf'] = 0x21C0;
  17807. t['arrowrightbothalf'] = 0x21C1;
  17808. t['arrowsoutheast'] = 0x2198;
  17809. t['arrowsouthwest'] = 0x2199;
  17810. t['backslashbig'] = 0x2216;
  17811. t['backslashBig'] = 0x2216;
  17812. t['backslashBigg'] = 0x2216;
  17813. t['backslashbigg'] = 0x2216;
  17814. t['bardbl'] = 0x2016;
  17815. t['bracehtipdownleft'] = 0xFE37;
  17816. t['bracehtipdownright'] = 0xFE37;
  17817. t['bracehtipupleft'] = 0xFE38;
  17818. t['bracehtipupright'] = 0xFE38;
  17819. t['braceleftBig'] = 0x007B;
  17820. t['braceleftbig'] = 0x007B;
  17821. t['braceleftbigg'] = 0x007B;
  17822. t['braceleftBigg'] = 0x007B;
  17823. t['bracerightBig'] = 0x007D;
  17824. t['bracerightbig'] = 0x007D;
  17825. t['bracerightbigg'] = 0x007D;
  17826. t['bracerightBigg'] = 0x007D;
  17827. t['bracketleftbig'] = 0x005B;
  17828. t['bracketleftBig'] = 0x005B;
  17829. t['bracketleftbigg'] = 0x005B;
  17830. t['bracketleftBigg'] = 0x005B;
  17831. t['bracketrightBig'] = 0x005D;
  17832. t['bracketrightbig'] = 0x005D;
  17833. t['bracketrightbigg'] = 0x005D;
  17834. t['bracketrightBigg'] = 0x005D;
  17835. t['ceilingleftbig'] = 0x2308;
  17836. t['ceilingleftBig'] = 0x2308;
  17837. t['ceilingleftBigg'] = 0x2308;
  17838. t['ceilingleftbigg'] = 0x2308;
  17839. t['ceilingrightbig'] = 0x2309;
  17840. t['ceilingrightBig'] = 0x2309;
  17841. t['ceilingrightbigg'] = 0x2309;
  17842. t['ceilingrightBigg'] = 0x2309;
  17843. t['circledotdisplay'] = 0x2299;
  17844. t['circledottext'] = 0x2299;
  17845. t['circlemultiplydisplay'] = 0x2297;
  17846. t['circlemultiplytext'] = 0x2297;
  17847. t['circleplusdisplay'] = 0x2295;
  17848. t['circleplustext'] = 0x2295;
  17849. t['contintegraldisplay'] = 0x222E;
  17850. t['contintegraltext'] = 0x222E;
  17851. t['coproductdisplay'] = 0x2210;
  17852. t['coproducttext'] = 0x2210;
  17853. t['floorleftBig'] = 0x230A;
  17854. t['floorleftbig'] = 0x230A;
  17855. t['floorleftbigg'] = 0x230A;
  17856. t['floorleftBigg'] = 0x230A;
  17857. t['floorrightbig'] = 0x230B;
  17858. t['floorrightBig'] = 0x230B;
  17859. t['floorrightBigg'] = 0x230B;
  17860. t['floorrightbigg'] = 0x230B;
  17861. t['hatwide'] = 0x0302;
  17862. t['hatwider'] = 0x0302;
  17863. t['hatwidest'] = 0x0302;
  17864. t['intercal'] = 0x1D40;
  17865. t['integraldisplay'] = 0x222B;
  17866. t['integraltext'] = 0x222B;
  17867. t['intersectiondisplay'] = 0x22C2;
  17868. t['intersectiontext'] = 0x22C2;
  17869. t['logicalanddisplay'] = 0x2227;
  17870. t['logicalandtext'] = 0x2227;
  17871. t['logicalordisplay'] = 0x2228;
  17872. t['logicalortext'] = 0x2228;
  17873. t['parenleftBig'] = 0x0028;
  17874. t['parenleftbig'] = 0x0028;
  17875. t['parenleftBigg'] = 0x0028;
  17876. t['parenleftbigg'] = 0x0028;
  17877. t['parenrightBig'] = 0x0029;
  17878. t['parenrightbig'] = 0x0029;
  17879. t['parenrightBigg'] = 0x0029;
  17880. t['parenrightbigg'] = 0x0029;
  17881. t['prime'] = 0x2032;
  17882. t['productdisplay'] = 0x220F;
  17883. t['producttext'] = 0x220F;
  17884. t['radicalbig'] = 0x221A;
  17885. t['radicalBig'] = 0x221A;
  17886. t['radicalBigg'] = 0x221A;
  17887. t['radicalbigg'] = 0x221A;
  17888. t['radicalbt'] = 0x221A;
  17889. t['radicaltp'] = 0x221A;
  17890. t['radicalvertex'] = 0x221A;
  17891. t['slashbig'] = 0x002F;
  17892. t['slashBig'] = 0x002F;
  17893. t['slashBigg'] = 0x002F;
  17894. t['slashbigg'] = 0x002F;
  17895. t['summationdisplay'] = 0x2211;
  17896. t['summationtext'] = 0x2211;
  17897. t['tildewide'] = 0x02DC;
  17898. t['tildewider'] = 0x02DC;
  17899. t['tildewidest'] = 0x02DC;
  17900. t['uniondisplay'] = 0x22C3;
  17901. t['unionmultidisplay'] = 0x228E;
  17902. t['unionmultitext'] = 0x228E;
  17903. t['unionsqdisplay'] = 0x2294;
  17904. t['unionsqtext'] = 0x2294;
  17905. t['uniontext'] = 0x22C3;
  17906. t['vextenddouble'] = 0x2225;
  17907. t['vextendsingle'] = 0x2223;
  17908. });
  17909. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  17910. t['space'] = 0x0020;
  17911. t['a1'] = 0x2701;
  17912. t['a2'] = 0x2702;
  17913. t['a202'] = 0x2703;
  17914. t['a3'] = 0x2704;
  17915. t['a4'] = 0x260E;
  17916. t['a5'] = 0x2706;
  17917. t['a119'] = 0x2707;
  17918. t['a118'] = 0x2708;
  17919. t['a117'] = 0x2709;
  17920. t['a11'] = 0x261B;
  17921. t['a12'] = 0x261E;
  17922. t['a13'] = 0x270C;
  17923. t['a14'] = 0x270D;
  17924. t['a15'] = 0x270E;
  17925. t['a16'] = 0x270F;
  17926. t['a105'] = 0x2710;
  17927. t['a17'] = 0x2711;
  17928. t['a18'] = 0x2712;
  17929. t['a19'] = 0x2713;
  17930. t['a20'] = 0x2714;
  17931. t['a21'] = 0x2715;
  17932. t['a22'] = 0x2716;
  17933. t['a23'] = 0x2717;
  17934. t['a24'] = 0x2718;
  17935. t['a25'] = 0x2719;
  17936. t['a26'] = 0x271A;
  17937. t['a27'] = 0x271B;
  17938. t['a28'] = 0x271C;
  17939. t['a6'] = 0x271D;
  17940. t['a7'] = 0x271E;
  17941. t['a8'] = 0x271F;
  17942. t['a9'] = 0x2720;
  17943. t['a10'] = 0x2721;
  17944. t['a29'] = 0x2722;
  17945. t['a30'] = 0x2723;
  17946. t['a31'] = 0x2724;
  17947. t['a32'] = 0x2725;
  17948. t['a33'] = 0x2726;
  17949. t['a34'] = 0x2727;
  17950. t['a35'] = 0x2605;
  17951. t['a36'] = 0x2729;
  17952. t['a37'] = 0x272A;
  17953. t['a38'] = 0x272B;
  17954. t['a39'] = 0x272C;
  17955. t['a40'] = 0x272D;
  17956. t['a41'] = 0x272E;
  17957. t['a42'] = 0x272F;
  17958. t['a43'] = 0x2730;
  17959. t['a44'] = 0x2731;
  17960. t['a45'] = 0x2732;
  17961. t['a46'] = 0x2733;
  17962. t['a47'] = 0x2734;
  17963. t['a48'] = 0x2735;
  17964. t['a49'] = 0x2736;
  17965. t['a50'] = 0x2737;
  17966. t['a51'] = 0x2738;
  17967. t['a52'] = 0x2739;
  17968. t['a53'] = 0x273A;
  17969. t['a54'] = 0x273B;
  17970. t['a55'] = 0x273C;
  17971. t['a56'] = 0x273D;
  17972. t['a57'] = 0x273E;
  17973. t['a58'] = 0x273F;
  17974. t['a59'] = 0x2740;
  17975. t['a60'] = 0x2741;
  17976. t['a61'] = 0x2742;
  17977. t['a62'] = 0x2743;
  17978. t['a63'] = 0x2744;
  17979. t['a64'] = 0x2745;
  17980. t['a65'] = 0x2746;
  17981. t['a66'] = 0x2747;
  17982. t['a67'] = 0x2748;
  17983. t['a68'] = 0x2749;
  17984. t['a69'] = 0x274A;
  17985. t['a70'] = 0x274B;
  17986. t['a71'] = 0x25CF;
  17987. t['a72'] = 0x274D;
  17988. t['a73'] = 0x25A0;
  17989. t['a74'] = 0x274F;
  17990. t['a203'] = 0x2750;
  17991. t['a75'] = 0x2751;
  17992. t['a204'] = 0x2752;
  17993. t['a76'] = 0x25B2;
  17994. t['a77'] = 0x25BC;
  17995. t['a78'] = 0x25C6;
  17996. t['a79'] = 0x2756;
  17997. t['a81'] = 0x25D7;
  17998. t['a82'] = 0x2758;
  17999. t['a83'] = 0x2759;
  18000. t['a84'] = 0x275A;
  18001. t['a97'] = 0x275B;
  18002. t['a98'] = 0x275C;
  18003. t['a99'] = 0x275D;
  18004. t['a100'] = 0x275E;
  18005. t['a101'] = 0x2761;
  18006. t['a102'] = 0x2762;
  18007. t['a103'] = 0x2763;
  18008. t['a104'] = 0x2764;
  18009. t['a106'] = 0x2765;
  18010. t['a107'] = 0x2766;
  18011. t['a108'] = 0x2767;
  18012. t['a112'] = 0x2663;
  18013. t['a111'] = 0x2666;
  18014. t['a110'] = 0x2665;
  18015. t['a109'] = 0x2660;
  18016. t['a120'] = 0x2460;
  18017. t['a121'] = 0x2461;
  18018. t['a122'] = 0x2462;
  18019. t['a123'] = 0x2463;
  18020. t['a124'] = 0x2464;
  18021. t['a125'] = 0x2465;
  18022. t['a126'] = 0x2466;
  18023. t['a127'] = 0x2467;
  18024. t['a128'] = 0x2468;
  18025. t['a129'] = 0x2469;
  18026. t['a130'] = 0x2776;
  18027. t['a131'] = 0x2777;
  18028. t['a132'] = 0x2778;
  18029. t['a133'] = 0x2779;
  18030. t['a134'] = 0x277A;
  18031. t['a135'] = 0x277B;
  18032. t['a136'] = 0x277C;
  18033. t['a137'] = 0x277D;
  18034. t['a138'] = 0x277E;
  18035. t['a139'] = 0x277F;
  18036. t['a140'] = 0x2780;
  18037. t['a141'] = 0x2781;
  18038. t['a142'] = 0x2782;
  18039. t['a143'] = 0x2783;
  18040. t['a144'] = 0x2784;
  18041. t['a145'] = 0x2785;
  18042. t['a146'] = 0x2786;
  18043. t['a147'] = 0x2787;
  18044. t['a148'] = 0x2788;
  18045. t['a149'] = 0x2789;
  18046. t['a150'] = 0x278A;
  18047. t['a151'] = 0x278B;
  18048. t['a152'] = 0x278C;
  18049. t['a153'] = 0x278D;
  18050. t['a154'] = 0x278E;
  18051. t['a155'] = 0x278F;
  18052. t['a156'] = 0x2790;
  18053. t['a157'] = 0x2791;
  18054. t['a158'] = 0x2792;
  18055. t['a159'] = 0x2793;
  18056. t['a160'] = 0x2794;
  18057. t['a161'] = 0x2192;
  18058. t['a163'] = 0x2194;
  18059. t['a164'] = 0x2195;
  18060. t['a196'] = 0x2798;
  18061. t['a165'] = 0x2799;
  18062. t['a192'] = 0x279A;
  18063. t['a166'] = 0x279B;
  18064. t['a167'] = 0x279C;
  18065. t['a168'] = 0x279D;
  18066. t['a169'] = 0x279E;
  18067. t['a170'] = 0x279F;
  18068. t['a171'] = 0x27A0;
  18069. t['a172'] = 0x27A1;
  18070. t['a173'] = 0x27A2;
  18071. t['a162'] = 0x27A3;
  18072. t['a174'] = 0x27A4;
  18073. t['a175'] = 0x27A5;
  18074. t['a176'] = 0x27A6;
  18075. t['a177'] = 0x27A7;
  18076. t['a178'] = 0x27A8;
  18077. t['a179'] = 0x27A9;
  18078. t['a193'] = 0x27AA;
  18079. t['a180'] = 0x27AB;
  18080. t['a199'] = 0x27AC;
  18081. t['a181'] = 0x27AD;
  18082. t['a200'] = 0x27AE;
  18083. t['a182'] = 0x27AF;
  18084. t['a201'] = 0x27B1;
  18085. t['a183'] = 0x27B2;
  18086. t['a184'] = 0x27B3;
  18087. t['a197'] = 0x27B4;
  18088. t['a185'] = 0x27B5;
  18089. t['a194'] = 0x27B6;
  18090. t['a198'] = 0x27B7;
  18091. t['a186'] = 0x27B8;
  18092. t['a195'] = 0x27B9;
  18093. t['a187'] = 0x27BA;
  18094. t['a188'] = 0x27BB;
  18095. t['a189'] = 0x27BC;
  18096. t['a190'] = 0x27BD;
  18097. t['a191'] = 0x27BE;
  18098. t['a89'] = 0x2768;
  18099. t['a90'] = 0x2769;
  18100. t['a93'] = 0x276A;
  18101. t['a94'] = 0x276B;
  18102. t['a91'] = 0x276C;
  18103. t['a92'] = 0x276D;
  18104. t['a205'] = 0x276E;
  18105. t['a85'] = 0x276F;
  18106. t['a206'] = 0x2770;
  18107. t['a86'] = 0x2771;
  18108. t['a87'] = 0x2772;
  18109. t['a88'] = 0x2773;
  18110. t['a95'] = 0x2774;
  18111. t['a96'] = 0x2775;
  18112. t['.notdef'] = 0x0000;
  18113. });
  18114. exports.getGlyphsUnicode = getGlyphsUnicode;
  18115. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18116. /***/ }),
  18117. /* 9 */
  18118. /***/ (function(module, exports, __w_pdfjs_require__) {
  18119. "use strict";
  18120. var sharedUtil = __w_pdfjs_require__(0);
  18121. var displayDOMUtils = __w_pdfjs_require__(3);
  18122. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18123. var AnnotationType = sharedUtil.AnnotationType;
  18124. var stringToPDFString = sharedUtil.stringToPDFString;
  18125. var Util = sharedUtil.Util;
  18126. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18127. var LinkTarget = displayDOMUtils.LinkTarget;
  18128. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18129. var warn = sharedUtil.warn;
  18130. var CustomStyle = displayDOMUtils.CustomStyle;
  18131. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18132. function AnnotationElementFactory() {
  18133. }
  18134. AnnotationElementFactory.prototype = {
  18135. create: function AnnotationElementFactory_create(parameters) {
  18136. var subtype = parameters.data.annotationType;
  18137. switch (subtype) {
  18138. case AnnotationType.LINK:
  18139. return new LinkAnnotationElement(parameters);
  18140. case AnnotationType.TEXT:
  18141. return new TextAnnotationElement(parameters);
  18142. case AnnotationType.WIDGET:
  18143. var fieldType = parameters.data.fieldType;
  18144. switch (fieldType) {
  18145. case 'Tx':
  18146. return new TextWidgetAnnotationElement(parameters);
  18147. case 'Btn':
  18148. if (parameters.data.radioButton) {
  18149. return new RadioButtonWidgetAnnotationElement(parameters);
  18150. } else if (parameters.data.checkBox) {
  18151. return new CheckboxWidgetAnnotationElement(parameters);
  18152. }
  18153. warn('Unimplemented button widget annotation: pushbutton');
  18154. break;
  18155. case 'Ch':
  18156. return new ChoiceWidgetAnnotationElement(parameters);
  18157. }
  18158. return new WidgetAnnotationElement(parameters);
  18159. case AnnotationType.POPUP:
  18160. return new PopupAnnotationElement(parameters);
  18161. case AnnotationType.HIGHLIGHT:
  18162. return new HighlightAnnotationElement(parameters);
  18163. case AnnotationType.UNDERLINE:
  18164. return new UnderlineAnnotationElement(parameters);
  18165. case AnnotationType.SQUIGGLY:
  18166. return new SquigglyAnnotationElement(parameters);
  18167. case AnnotationType.STRIKEOUT:
  18168. return new StrikeOutAnnotationElement(parameters);
  18169. case AnnotationType.FILEATTACHMENT:
  18170. return new FileAttachmentAnnotationElement(parameters);
  18171. default:
  18172. return new AnnotationElement(parameters);
  18173. }
  18174. }
  18175. };
  18176. var AnnotationElement = function AnnotationElementClosure() {
  18177. function AnnotationElement(parameters, isRenderable) {
  18178. this.isRenderable = isRenderable || false;
  18179. this.data = parameters.data;
  18180. this.layer = parameters.layer;
  18181. this.page = parameters.page;
  18182. this.viewport = parameters.viewport;
  18183. this.linkService = parameters.linkService;
  18184. this.downloadManager = parameters.downloadManager;
  18185. this.imageResourcesPath = parameters.imageResourcesPath;
  18186. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18187. if (isRenderable) {
  18188. this.container = this._createContainer();
  18189. }
  18190. }
  18191. AnnotationElement.prototype = {
  18192. _createContainer: function AnnotationElement_createContainer() {
  18193. var data = this.data, page = this.page, viewport = this.viewport;
  18194. var container = document.createElement('section');
  18195. var width = data.rect[2] - data.rect[0];
  18196. var height = data.rect[3] - data.rect[1];
  18197. container.setAttribute('data-annotation-id', data.id);
  18198. var rect = Util.normalizeRect([
  18199. data.rect[0],
  18200. page.view[3] - data.rect[1] + page.view[1],
  18201. data.rect[2],
  18202. page.view[3] - data.rect[3] + page.view[1]
  18203. ]);
  18204. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18205. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18206. if (data.borderStyle.width > 0) {
  18207. container.style.borderWidth = data.borderStyle.width + 'px';
  18208. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18209. width = width - 2 * data.borderStyle.width;
  18210. height = height - 2 * data.borderStyle.width;
  18211. }
  18212. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18213. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18214. if (horizontalRadius > 0 || verticalRadius > 0) {
  18215. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18216. CustomStyle.setProp('borderRadius', container, radius);
  18217. }
  18218. switch (data.borderStyle.style) {
  18219. case AnnotationBorderStyleType.SOLID:
  18220. container.style.borderStyle = 'solid';
  18221. break;
  18222. case AnnotationBorderStyleType.DASHED:
  18223. container.style.borderStyle = 'dashed';
  18224. break;
  18225. case AnnotationBorderStyleType.BEVELED:
  18226. warn('Unimplemented border style: beveled');
  18227. break;
  18228. case AnnotationBorderStyleType.INSET:
  18229. warn('Unimplemented border style: inset');
  18230. break;
  18231. case AnnotationBorderStyleType.UNDERLINE:
  18232. container.style.borderBottomStyle = 'solid';
  18233. break;
  18234. default:
  18235. break;
  18236. }
  18237. if (data.color) {
  18238. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18239. } else {
  18240. container.style.borderWidth = 0;
  18241. }
  18242. }
  18243. container.style.left = rect[0] + 'px';
  18244. container.style.top = rect[1] + 'px';
  18245. container.style.width = width + 'px';
  18246. container.style.height = height + 'px';
  18247. return container;
  18248. },
  18249. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  18250. if (!trigger) {
  18251. trigger = document.createElement('div');
  18252. trigger.style.height = container.style.height;
  18253. trigger.style.width = container.style.width;
  18254. container.appendChild(trigger);
  18255. }
  18256. var popupElement = new PopupElement({
  18257. container: container,
  18258. trigger: trigger,
  18259. color: data.color,
  18260. title: data.title,
  18261. contents: data.contents,
  18262. hideWrapper: true
  18263. });
  18264. var popup = popupElement.render();
  18265. popup.style.left = container.style.width;
  18266. container.appendChild(popup);
  18267. },
  18268. render: function AnnotationElement_render() {
  18269. throw new Error('Abstract method AnnotationElement.render called');
  18270. }
  18271. };
  18272. return AnnotationElement;
  18273. }();
  18274. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  18275. function LinkAnnotationElement(parameters) {
  18276. AnnotationElement.call(this, parameters, true);
  18277. }
  18278. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  18279. render: function LinkAnnotationElement_render() {
  18280. this.container.className = 'linkAnnotation';
  18281. var link = document.createElement('a');
  18282. addLinkAttributes(link, {
  18283. url: this.data.url,
  18284. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  18285. });
  18286. if (!this.data.url) {
  18287. if (this.data.action) {
  18288. this._bindNamedAction(link, this.data.action);
  18289. } else {
  18290. this._bindLink(link, this.data.dest);
  18291. }
  18292. }
  18293. this.container.appendChild(link);
  18294. return this.container;
  18295. },
  18296. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  18297. var self = this;
  18298. link.href = this.linkService.getDestinationHash(destination);
  18299. link.onclick = function () {
  18300. if (destination) {
  18301. self.linkService.navigateTo(destination);
  18302. }
  18303. return false;
  18304. };
  18305. if (destination) {
  18306. link.className = 'internalLink';
  18307. }
  18308. },
  18309. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  18310. var self = this;
  18311. link.href = this.linkService.getAnchorUrl('');
  18312. link.onclick = function () {
  18313. self.linkService.executeNamedAction(action);
  18314. return false;
  18315. };
  18316. link.className = 'internalLink';
  18317. }
  18318. });
  18319. return LinkAnnotationElement;
  18320. }();
  18321. var TextAnnotationElement = function TextAnnotationElementClosure() {
  18322. function TextAnnotationElement(parameters) {
  18323. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18324. AnnotationElement.call(this, parameters, isRenderable);
  18325. }
  18326. Util.inherit(TextAnnotationElement, AnnotationElement, {
  18327. render: function TextAnnotationElement_render() {
  18328. this.container.className = 'textAnnotation';
  18329. var image = document.createElement('img');
  18330. image.style.height = this.container.style.height;
  18331. image.style.width = this.container.style.width;
  18332. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  18333. image.alt = '[{{type}} Annotation]';
  18334. image.dataset.l10nId = 'text_annotation_type';
  18335. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  18336. if (!this.data.hasPopup) {
  18337. this._createPopup(this.container, image, this.data);
  18338. }
  18339. this.container.appendChild(image);
  18340. return this.container;
  18341. }
  18342. });
  18343. return TextAnnotationElement;
  18344. }();
  18345. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  18346. function WidgetAnnotationElement(parameters, isRenderable) {
  18347. AnnotationElement.call(this, parameters, isRenderable);
  18348. }
  18349. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  18350. render: function WidgetAnnotationElement_render() {
  18351. return this.container;
  18352. }
  18353. });
  18354. return WidgetAnnotationElement;
  18355. }();
  18356. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  18357. var TEXT_ALIGNMENT = [
  18358. 'left',
  18359. 'center',
  18360. 'right'
  18361. ];
  18362. function TextWidgetAnnotationElement(parameters) {
  18363. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18364. WidgetAnnotationElement.call(this, parameters, isRenderable);
  18365. }
  18366. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  18367. render: function TextWidgetAnnotationElement_render() {
  18368. this.container.className = 'textWidgetAnnotation';
  18369. var element = null;
  18370. if (this.renderInteractiveForms) {
  18371. if (this.data.multiLine) {
  18372. element = document.createElement('textarea');
  18373. element.textContent = this.data.fieldValue;
  18374. } else {
  18375. element = document.createElement('input');
  18376. element.type = 'text';
  18377. element.setAttribute('value', this.data.fieldValue);
  18378. }
  18379. element.disabled = this.data.readOnly;
  18380. if (this.data.maxLen !== null) {
  18381. element.maxLength = this.data.maxLen;
  18382. }
  18383. if (this.data.comb) {
  18384. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18385. var combWidth = fieldWidth / this.data.maxLen;
  18386. element.classList.add('comb');
  18387. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  18388. }
  18389. } else {
  18390. element = document.createElement('div');
  18391. element.textContent = this.data.fieldValue;
  18392. element.style.verticalAlign = 'middle';
  18393. element.style.display = 'table-cell';
  18394. var font = null;
  18395. if (this.data.fontRefName) {
  18396. font = this.page.commonObjs.getData(this.data.fontRefName);
  18397. }
  18398. this._setTextStyle(element, font);
  18399. }
  18400. if (this.data.textAlignment !== null) {
  18401. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18402. }
  18403. this.container.appendChild(element);
  18404. return this.container;
  18405. },
  18406. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  18407. var style = element.style;
  18408. style.fontSize = this.data.fontSize + 'px';
  18409. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  18410. if (!font) {
  18411. return;
  18412. }
  18413. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  18414. style.fontStyle = font.italic ? 'italic' : 'normal';
  18415. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  18416. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  18417. style.fontFamily = fontFamily + fallbackName;
  18418. }
  18419. });
  18420. return TextWidgetAnnotationElement;
  18421. }();
  18422. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  18423. function CheckboxWidgetAnnotationElement(parameters) {
  18424. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18425. }
  18426. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  18427. render: function CheckboxWidgetAnnotationElement_render() {
  18428. this.container.className = 'buttonWidgetAnnotation checkBox';
  18429. var element = document.createElement('input');
  18430. element.disabled = this.data.readOnly;
  18431. element.type = 'checkbox';
  18432. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  18433. element.setAttribute('checked', true);
  18434. }
  18435. this.container.appendChild(element);
  18436. return this.container;
  18437. }
  18438. });
  18439. return CheckboxWidgetAnnotationElement;
  18440. }();
  18441. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  18442. function RadioButtonWidgetAnnotationElement(parameters) {
  18443. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18444. }
  18445. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  18446. render: function RadioButtonWidgetAnnotationElement_render() {
  18447. this.container.className = 'buttonWidgetAnnotation radioButton';
  18448. var element = document.createElement('input');
  18449. element.disabled = this.data.readOnly;
  18450. element.type = 'radio';
  18451. element.name = this.data.fieldName;
  18452. if (this.data.fieldValue === this.data.buttonValue) {
  18453. element.setAttribute('checked', true);
  18454. }
  18455. this.container.appendChild(element);
  18456. return this.container;
  18457. }
  18458. });
  18459. return RadioButtonWidgetAnnotationElement;
  18460. }();
  18461. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  18462. function ChoiceWidgetAnnotationElement(parameters) {
  18463. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18464. }
  18465. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  18466. render: function ChoiceWidgetAnnotationElement_render() {
  18467. this.container.className = 'choiceWidgetAnnotation';
  18468. var selectElement = document.createElement('select');
  18469. selectElement.disabled = this.data.readOnly;
  18470. if (!this.data.combo) {
  18471. selectElement.size = this.data.options.length;
  18472. if (this.data.multiSelect) {
  18473. selectElement.multiple = true;
  18474. }
  18475. }
  18476. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  18477. var option = this.data.options[i];
  18478. var optionElement = document.createElement('option');
  18479. optionElement.textContent = option.displayValue;
  18480. optionElement.value = option.exportValue;
  18481. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  18482. optionElement.setAttribute('selected', true);
  18483. }
  18484. selectElement.appendChild(optionElement);
  18485. }
  18486. this.container.appendChild(selectElement);
  18487. return this.container;
  18488. }
  18489. });
  18490. return ChoiceWidgetAnnotationElement;
  18491. }();
  18492. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  18493. function PopupAnnotationElement(parameters) {
  18494. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18495. AnnotationElement.call(this, parameters, isRenderable);
  18496. }
  18497. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  18498. render: function PopupAnnotationElement_render() {
  18499. this.container.className = 'popupAnnotation';
  18500. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  18501. var parentElement = this.layer.querySelector(selector);
  18502. if (!parentElement) {
  18503. return this.container;
  18504. }
  18505. var popup = new PopupElement({
  18506. container: this.container,
  18507. trigger: parentElement,
  18508. color: this.data.color,
  18509. title: this.data.title,
  18510. contents: this.data.contents
  18511. });
  18512. var parentLeft = parseFloat(parentElement.style.left);
  18513. var parentWidth = parseFloat(parentElement.style.width);
  18514. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  18515. this.container.style.left = parentLeft + parentWidth + 'px';
  18516. this.container.appendChild(popup.render());
  18517. return this.container;
  18518. }
  18519. });
  18520. return PopupAnnotationElement;
  18521. }();
  18522. var PopupElement = function PopupElementClosure() {
  18523. var BACKGROUND_ENLIGHT = 0.7;
  18524. function PopupElement(parameters) {
  18525. this.container = parameters.container;
  18526. this.trigger = parameters.trigger;
  18527. this.color = parameters.color;
  18528. this.title = parameters.title;
  18529. this.contents = parameters.contents;
  18530. this.hideWrapper = parameters.hideWrapper || false;
  18531. this.pinned = false;
  18532. }
  18533. PopupElement.prototype = {
  18534. render: function PopupElement_render() {
  18535. var wrapper = document.createElement('div');
  18536. wrapper.className = 'popupWrapper';
  18537. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18538. this.hideElement.setAttribute('hidden', true);
  18539. var popup = document.createElement('div');
  18540. popup.className = 'popup';
  18541. var color = this.color;
  18542. if (color) {
  18543. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18544. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18545. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18546. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  18547. }
  18548. var contents = this._formatContents(this.contents);
  18549. var title = document.createElement('h1');
  18550. title.textContent = this.title;
  18551. this.trigger.addEventListener('click', this._toggle.bind(this));
  18552. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  18553. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  18554. popup.addEventListener('click', this._hide.bind(this, true));
  18555. popup.appendChild(title);
  18556. popup.appendChild(contents);
  18557. wrapper.appendChild(popup);
  18558. return wrapper;
  18559. },
  18560. _formatContents: function PopupElement_formatContents(contents) {
  18561. var p = document.createElement('p');
  18562. var lines = contents.split(/(?:\r\n?|\n)/);
  18563. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18564. var line = lines[i];
  18565. p.appendChild(document.createTextNode(line));
  18566. if (i < ii - 1) {
  18567. p.appendChild(document.createElement('br'));
  18568. }
  18569. }
  18570. return p;
  18571. },
  18572. _toggle: function PopupElement_toggle() {
  18573. if (this.pinned) {
  18574. this._hide(true);
  18575. } else {
  18576. this._show(true);
  18577. }
  18578. },
  18579. _show: function PopupElement_show(pin) {
  18580. if (pin) {
  18581. this.pinned = true;
  18582. }
  18583. if (this.hideElement.hasAttribute('hidden')) {
  18584. this.hideElement.removeAttribute('hidden');
  18585. this.container.style.zIndex += 1;
  18586. }
  18587. },
  18588. _hide: function PopupElement_hide(unpin) {
  18589. if (unpin) {
  18590. this.pinned = false;
  18591. }
  18592. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  18593. this.hideElement.setAttribute('hidden', true);
  18594. this.container.style.zIndex -= 1;
  18595. }
  18596. }
  18597. };
  18598. return PopupElement;
  18599. }();
  18600. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  18601. function HighlightAnnotationElement(parameters) {
  18602. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18603. AnnotationElement.call(this, parameters, isRenderable);
  18604. }
  18605. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  18606. render: function HighlightAnnotationElement_render() {
  18607. this.container.className = 'highlightAnnotation';
  18608. if (!this.data.hasPopup) {
  18609. this._createPopup(this.container, null, this.data);
  18610. }
  18611. return this.container;
  18612. }
  18613. });
  18614. return HighlightAnnotationElement;
  18615. }();
  18616. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  18617. function UnderlineAnnotationElement(parameters) {
  18618. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18619. AnnotationElement.call(this, parameters, isRenderable);
  18620. }
  18621. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  18622. render: function UnderlineAnnotationElement_render() {
  18623. this.container.className = 'underlineAnnotation';
  18624. if (!this.data.hasPopup) {
  18625. this._createPopup(this.container, null, this.data);
  18626. }
  18627. return this.container;
  18628. }
  18629. });
  18630. return UnderlineAnnotationElement;
  18631. }();
  18632. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  18633. function SquigglyAnnotationElement(parameters) {
  18634. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18635. AnnotationElement.call(this, parameters, isRenderable);
  18636. }
  18637. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  18638. render: function SquigglyAnnotationElement_render() {
  18639. this.container.className = 'squigglyAnnotation';
  18640. if (!this.data.hasPopup) {
  18641. this._createPopup(this.container, null, this.data);
  18642. }
  18643. return this.container;
  18644. }
  18645. });
  18646. return SquigglyAnnotationElement;
  18647. }();
  18648. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  18649. function StrikeOutAnnotationElement(parameters) {
  18650. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18651. AnnotationElement.call(this, parameters, isRenderable);
  18652. }
  18653. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  18654. render: function StrikeOutAnnotationElement_render() {
  18655. this.container.className = 'strikeoutAnnotation';
  18656. if (!this.data.hasPopup) {
  18657. this._createPopup(this.container, null, this.data);
  18658. }
  18659. return this.container;
  18660. }
  18661. });
  18662. return StrikeOutAnnotationElement;
  18663. }();
  18664. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  18665. function FileAttachmentAnnotationElement(parameters) {
  18666. AnnotationElement.call(this, parameters, true);
  18667. var file = this.data.file;
  18668. this.filename = getFilenameFromUrl(file.filename);
  18669. this.content = file.content;
  18670. this.linkService.onFileAttachmentAnnotation({
  18671. id: stringToPDFString(file.filename),
  18672. filename: file.filename,
  18673. content: file.content
  18674. });
  18675. }
  18676. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  18677. render: function FileAttachmentAnnotationElement_render() {
  18678. this.container.className = 'fileAttachmentAnnotation';
  18679. var trigger = document.createElement('div');
  18680. trigger.style.height = this.container.style.height;
  18681. trigger.style.width = this.container.style.width;
  18682. trigger.addEventListener('dblclick', this._download.bind(this));
  18683. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  18684. this._createPopup(this.container, trigger, this.data);
  18685. }
  18686. this.container.appendChild(trigger);
  18687. return this.container;
  18688. },
  18689. _download: function FileAttachmentAnnotationElement_download() {
  18690. if (!this.downloadManager) {
  18691. warn('Download cannot be started due to unavailable download manager');
  18692. return;
  18693. }
  18694. this.downloadManager.downloadData(this.content, this.filename, '');
  18695. }
  18696. });
  18697. return FileAttachmentAnnotationElement;
  18698. }();
  18699. var AnnotationLayer = function AnnotationLayerClosure() {
  18700. return {
  18701. render: function AnnotationLayer_render(parameters) {
  18702. var annotationElementFactory = new AnnotationElementFactory();
  18703. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18704. var data = parameters.annotations[i];
  18705. if (!data) {
  18706. continue;
  18707. }
  18708. var element = annotationElementFactory.create({
  18709. data: data,
  18710. layer: parameters.div,
  18711. page: parameters.page,
  18712. viewport: parameters.viewport,
  18713. linkService: parameters.linkService,
  18714. downloadManager: parameters.downloadManager,
  18715. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  18716. renderInteractiveForms: parameters.renderInteractiveForms || false
  18717. });
  18718. if (element.isRenderable) {
  18719. parameters.div.appendChild(element.render());
  18720. }
  18721. }
  18722. },
  18723. update: function AnnotationLayer_update(parameters) {
  18724. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18725. var data = parameters.annotations[i];
  18726. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  18727. if (element) {
  18728. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  18729. }
  18730. }
  18731. parameters.div.removeAttribute('hidden');
  18732. }
  18733. };
  18734. }();
  18735. exports.AnnotationLayer = AnnotationLayer;
  18736. /***/ }),
  18737. /* 10 */
  18738. /***/ (function(module, exports, __w_pdfjs_require__) {
  18739. "use strict";
  18740. var sharedUtil = __w_pdfjs_require__(0);
  18741. var displayFontLoader = __w_pdfjs_require__(45);
  18742. var displayCanvas = __w_pdfjs_require__(44);
  18743. var displayMetadata = __w_pdfjs_require__(24);
  18744. var displayDOMUtils = __w_pdfjs_require__(3);
  18745. var amdRequire;
  18746. var InvalidPDFException = sharedUtil.InvalidPDFException;
  18747. var MessageHandler = sharedUtil.MessageHandler;
  18748. var MissingPDFException = sharedUtil.MissingPDFException;
  18749. var PageViewport = sharedUtil.PageViewport;
  18750. var PasswordException = sharedUtil.PasswordException;
  18751. var StatTimer = sharedUtil.StatTimer;
  18752. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  18753. var UnknownErrorException = sharedUtil.UnknownErrorException;
  18754. var Util = sharedUtil.Util;
  18755. var createPromiseCapability = sharedUtil.createPromiseCapability;
  18756. var error = sharedUtil.error;
  18757. var deprecated = sharedUtil.deprecated;
  18758. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  18759. var info = sharedUtil.info;
  18760. var isInt = sharedUtil.isInt;
  18761. var isArray = sharedUtil.isArray;
  18762. var isArrayBuffer = sharedUtil.isArrayBuffer;
  18763. var isSameOrigin = sharedUtil.isSameOrigin;
  18764. var loadJpegStream = sharedUtil.loadJpegStream;
  18765. var stringToBytes = sharedUtil.stringToBytes;
  18766. var globalScope = sharedUtil.globalScope;
  18767. var warn = sharedUtil.warn;
  18768. var FontFaceObject = displayFontLoader.FontFaceObject;
  18769. var FontLoader = displayFontLoader.FontLoader;
  18770. var CanvasGraphics = displayCanvas.CanvasGraphics;
  18771. var Metadata = displayMetadata.Metadata;
  18772. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18773. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  18774. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  18775. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  18776. var isWorkerDisabled = false;
  18777. var workerSrc;
  18778. var isPostMessageTransfersDisabled = false;
  18779. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  18780. var fakeWorkerFilesLoader = null;
  18781. var useRequireEnsure = false;
  18782. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  18783. var task = new PDFDocumentLoadingTask();
  18784. if (arguments.length > 1) {
  18785. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  18786. }
  18787. if (pdfDataRangeTransport) {
  18788. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  18789. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  18790. pdfDataRangeTransport.length = src.length;
  18791. pdfDataRangeTransport.initialData = src.initialData;
  18792. if (!pdfDataRangeTransport.abort) {
  18793. pdfDataRangeTransport.abort = function () {
  18794. };
  18795. }
  18796. }
  18797. src = Object.create(src);
  18798. src.range = pdfDataRangeTransport;
  18799. }
  18800. task.onPassword = passwordCallback || null;
  18801. task.onProgress = progressCallback || null;
  18802. var source;
  18803. if (typeof src === 'string') {
  18804. source = { url: src };
  18805. } else if (isArrayBuffer(src)) {
  18806. source = { data: src };
  18807. } else if (src instanceof PDFDataRangeTransport) {
  18808. source = { range: src };
  18809. } else {
  18810. if (typeof src !== 'object') {
  18811. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  18812. }
  18813. if (!src.url && !src.data && !src.range) {
  18814. error('Invalid parameter object: need either .data, .range or .url');
  18815. }
  18816. source = src;
  18817. }
  18818. var params = {};
  18819. var rangeTransport = null;
  18820. var worker = null;
  18821. for (var key in source) {
  18822. if (key === 'url' && typeof window !== 'undefined') {
  18823. params[key] = new URL(source[key], window.location).href;
  18824. continue;
  18825. } else if (key === 'range') {
  18826. rangeTransport = source[key];
  18827. continue;
  18828. } else if (key === 'worker') {
  18829. worker = source[key];
  18830. continue;
  18831. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  18832. var pdfBytes = source[key];
  18833. if (typeof pdfBytes === 'string') {
  18834. params[key] = stringToBytes(pdfBytes);
  18835. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  18836. params[key] = new Uint8Array(pdfBytes);
  18837. } else if (isArrayBuffer(pdfBytes)) {
  18838. params[key] = new Uint8Array(pdfBytes);
  18839. } else {
  18840. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  18841. }
  18842. continue;
  18843. }
  18844. params[key] = source[key];
  18845. }
  18846. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  18847. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  18848. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  18849. if (!worker) {
  18850. var workerPort = getDefaultSetting('workerPort');
  18851. worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
  18852. task._worker = worker;
  18853. }
  18854. var docId = task.docId;
  18855. worker.promise.then(function () {
  18856. if (task.destroyed) {
  18857. throw new Error('Loading aborted');
  18858. }
  18859. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  18860. if (task.destroyed) {
  18861. throw new Error('Loading aborted');
  18862. }
  18863. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  18864. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  18865. task._transport = transport;
  18866. messageHandler.send('Ready', null);
  18867. });
  18868. }).catch(task._capability.reject);
  18869. return task;
  18870. }
  18871. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  18872. if (worker.destroyed) {
  18873. return Promise.reject(new Error('Worker was destroyed'));
  18874. }
  18875. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  18876. source.disableStream = getDefaultSetting('disableStream');
  18877. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  18878. if (pdfDataRangeTransport) {
  18879. source.length = pdfDataRangeTransport.length;
  18880. source.initialData = pdfDataRangeTransport.initialData;
  18881. }
  18882. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  18883. docId: docId,
  18884. source: source,
  18885. disableRange: getDefaultSetting('disableRange'),
  18886. maxImageSize: getDefaultSetting('maxImageSize'),
  18887. disableFontFace: getDefaultSetting('disableFontFace'),
  18888. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  18889. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  18890. docBaseUrl: source.docBaseUrl,
  18891. disableNativeImageDecoder: source.disableNativeImageDecoder
  18892. }).then(function (workerId) {
  18893. if (worker.destroyed) {
  18894. throw new Error('Worker was destroyed');
  18895. }
  18896. return workerId;
  18897. });
  18898. }
  18899. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  18900. var nextDocumentId = 0;
  18901. function PDFDocumentLoadingTask() {
  18902. this._capability = createPromiseCapability();
  18903. this._transport = null;
  18904. this._worker = null;
  18905. this.docId = 'd' + nextDocumentId++;
  18906. this.destroyed = false;
  18907. this.onPassword = null;
  18908. this.onProgress = null;
  18909. this.onUnsupportedFeature = null;
  18910. }
  18911. PDFDocumentLoadingTask.prototype = {
  18912. get promise() {
  18913. return this._capability.promise;
  18914. },
  18915. destroy: function () {
  18916. this.destroyed = true;
  18917. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  18918. return transportDestroyed.then(function () {
  18919. this._transport = null;
  18920. if (this._worker) {
  18921. this._worker.destroy();
  18922. this._worker = null;
  18923. }
  18924. }.bind(this));
  18925. },
  18926. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  18927. return this.promise.then.apply(this.promise, arguments);
  18928. }
  18929. };
  18930. return PDFDocumentLoadingTask;
  18931. }();
  18932. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  18933. function PDFDataRangeTransport(length, initialData) {
  18934. this.length = length;
  18935. this.initialData = initialData;
  18936. this._rangeListeners = [];
  18937. this._progressListeners = [];
  18938. this._progressiveReadListeners = [];
  18939. this._readyCapability = createPromiseCapability();
  18940. }
  18941. PDFDataRangeTransport.prototype = {
  18942. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  18943. this._rangeListeners.push(listener);
  18944. },
  18945. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  18946. this._progressListeners.push(listener);
  18947. },
  18948. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  18949. this._progressiveReadListeners.push(listener);
  18950. },
  18951. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  18952. var listeners = this._rangeListeners;
  18953. for (var i = 0, n = listeners.length; i < n; ++i) {
  18954. listeners[i](begin, chunk);
  18955. }
  18956. },
  18957. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  18958. this._readyCapability.promise.then(function () {
  18959. var listeners = this._progressListeners;
  18960. for (var i = 0, n = listeners.length; i < n; ++i) {
  18961. listeners[i](loaded);
  18962. }
  18963. }.bind(this));
  18964. },
  18965. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  18966. this._readyCapability.promise.then(function () {
  18967. var listeners = this._progressiveReadListeners;
  18968. for (var i = 0, n = listeners.length; i < n; ++i) {
  18969. listeners[i](chunk);
  18970. }
  18971. }.bind(this));
  18972. },
  18973. transportReady: function PDFDataRangeTransport_transportReady() {
  18974. this._readyCapability.resolve();
  18975. },
  18976. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  18977. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  18978. },
  18979. abort: function PDFDataRangeTransport_abort() {
  18980. }
  18981. };
  18982. return PDFDataRangeTransport;
  18983. }();
  18984. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  18985. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  18986. this.pdfInfo = pdfInfo;
  18987. this.transport = transport;
  18988. this.loadingTask = loadingTask;
  18989. }
  18990. PDFDocumentProxy.prototype = {
  18991. get numPages() {
  18992. return this.pdfInfo.numPages;
  18993. },
  18994. get fingerprint() {
  18995. return this.pdfInfo.fingerprint;
  18996. },
  18997. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  18998. return this.transport.getPage(pageNumber);
  18999. },
  19000. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19001. return this.transport.getPageIndex(ref);
  19002. },
  19003. getDestinations: function PDFDocumentProxy_getDestinations() {
  19004. return this.transport.getDestinations();
  19005. },
  19006. getDestination: function PDFDocumentProxy_getDestination(id) {
  19007. return this.transport.getDestination(id);
  19008. },
  19009. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19010. return this.transport.getPageLabels();
  19011. },
  19012. getAttachments: function PDFDocumentProxy_getAttachments() {
  19013. return this.transport.getAttachments();
  19014. },
  19015. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19016. return this.transport.getJavaScript();
  19017. },
  19018. getOutline: function PDFDocumentProxy_getOutline() {
  19019. return this.transport.getOutline();
  19020. },
  19021. getMetadata: function PDFDocumentProxy_getMetadata() {
  19022. return this.transport.getMetadata();
  19023. },
  19024. getData: function PDFDocumentProxy_getData() {
  19025. return this.transport.getData();
  19026. },
  19027. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19028. return this.transport.downloadInfoCapability.promise;
  19029. },
  19030. getStats: function PDFDocumentProxy_getStats() {
  19031. return this.transport.getStats();
  19032. },
  19033. cleanup: function PDFDocumentProxy_cleanup() {
  19034. this.transport.startCleanup();
  19035. },
  19036. destroy: function PDFDocumentProxy_destroy() {
  19037. return this.loadingTask.destroy();
  19038. }
  19039. };
  19040. return PDFDocumentProxy;
  19041. }();
  19042. var PDFPageProxy = function PDFPageProxyClosure() {
  19043. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19044. this.pageIndex = pageIndex;
  19045. this.pageInfo = pageInfo;
  19046. this.transport = transport;
  19047. this.stats = new StatTimer();
  19048. this.stats.enabled = getDefaultSetting('enableStats');
  19049. this.commonObjs = transport.commonObjs;
  19050. this.objs = new PDFObjects();
  19051. this.cleanupAfterRender = false;
  19052. this.pendingCleanup = false;
  19053. this.intentStates = Object.create(null);
  19054. this.destroyed = false;
  19055. }
  19056. PDFPageProxy.prototype = {
  19057. get pageNumber() {
  19058. return this.pageIndex + 1;
  19059. },
  19060. get rotate() {
  19061. return this.pageInfo.rotate;
  19062. },
  19063. get ref() {
  19064. return this.pageInfo.ref;
  19065. },
  19066. get userUnit() {
  19067. return this.pageInfo.userUnit;
  19068. },
  19069. get view() {
  19070. return this.pageInfo.view;
  19071. },
  19072. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19073. if (arguments.length < 2) {
  19074. rotate = this.rotate;
  19075. }
  19076. return new PageViewport(this.view, scale, rotate, 0, 0);
  19077. },
  19078. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19079. var intent = params && params.intent || null;
  19080. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19081. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19082. this.annotationsIntent = intent;
  19083. }
  19084. return this.annotationsPromise;
  19085. },
  19086. render: function PDFPageProxy_render(params) {
  19087. var stats = this.stats;
  19088. stats.time('Overall');
  19089. this.pendingCleanup = false;
  19090. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19091. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19092. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19093. if (!this.intentStates[renderingIntent]) {
  19094. this.intentStates[renderingIntent] = Object.create(null);
  19095. }
  19096. var intentState = this.intentStates[renderingIntent];
  19097. if (!intentState.displayReadyCapability) {
  19098. intentState.receivingOperatorList = true;
  19099. intentState.displayReadyCapability = createPromiseCapability();
  19100. intentState.operatorList = {
  19101. fnArray: [],
  19102. argsArray: [],
  19103. lastChunk: false
  19104. };
  19105. this.stats.time('Page Request');
  19106. this.transport.messageHandler.send('RenderPageRequest', {
  19107. pageIndex: this.pageNumber - 1,
  19108. intent: renderingIntent,
  19109. renderInteractiveForms: renderInteractiveForms
  19110. });
  19111. }
  19112. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19113. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19114. if (!intentState.renderTasks) {
  19115. intentState.renderTasks = [];
  19116. }
  19117. intentState.renderTasks.push(internalRenderTask);
  19118. var renderTask = internalRenderTask.task;
  19119. if (params.continueCallback) {
  19120. deprecated('render is used with continueCallback parameter');
  19121. renderTask.onContinue = params.continueCallback;
  19122. }
  19123. var self = this;
  19124. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19125. if (self.pendingCleanup) {
  19126. complete();
  19127. return;
  19128. }
  19129. stats.time('Rendering');
  19130. internalRenderTask.initializeGraphics(transparency);
  19131. internalRenderTask.operatorListChanged();
  19132. }, function pageDisplayReadPromiseError(reason) {
  19133. complete(reason);
  19134. });
  19135. function complete(error) {
  19136. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19137. if (i >= 0) {
  19138. intentState.renderTasks.splice(i, 1);
  19139. }
  19140. if (self.cleanupAfterRender) {
  19141. self.pendingCleanup = true;
  19142. }
  19143. self._tryCleanup();
  19144. if (error) {
  19145. internalRenderTask.capability.reject(error);
  19146. } else {
  19147. internalRenderTask.capability.resolve();
  19148. }
  19149. stats.timeEnd('Rendering');
  19150. stats.timeEnd('Overall');
  19151. }
  19152. return renderTask;
  19153. },
  19154. getOperatorList: function PDFPageProxy_getOperatorList() {
  19155. function operatorListChanged() {
  19156. if (intentState.operatorList.lastChunk) {
  19157. intentState.opListReadCapability.resolve(intentState.operatorList);
  19158. var i = intentState.renderTasks.indexOf(opListTask);
  19159. if (i >= 0) {
  19160. intentState.renderTasks.splice(i, 1);
  19161. }
  19162. }
  19163. }
  19164. var renderingIntent = 'oplist';
  19165. if (!this.intentStates[renderingIntent]) {
  19166. this.intentStates[renderingIntent] = Object.create(null);
  19167. }
  19168. var intentState = this.intentStates[renderingIntent];
  19169. var opListTask;
  19170. if (!intentState.opListReadCapability) {
  19171. opListTask = {};
  19172. opListTask.operatorListChanged = operatorListChanged;
  19173. intentState.receivingOperatorList = true;
  19174. intentState.opListReadCapability = createPromiseCapability();
  19175. intentState.renderTasks = [];
  19176. intentState.renderTasks.push(opListTask);
  19177. intentState.operatorList = {
  19178. fnArray: [],
  19179. argsArray: [],
  19180. lastChunk: false
  19181. };
  19182. this.transport.messageHandler.send('RenderPageRequest', {
  19183. pageIndex: this.pageIndex,
  19184. intent: renderingIntent
  19185. });
  19186. }
  19187. return intentState.opListReadCapability.promise;
  19188. },
  19189. getTextContent: function PDFPageProxy_getTextContent(params) {
  19190. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19191. pageIndex: this.pageNumber - 1,
  19192. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19193. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19194. });
  19195. },
  19196. _destroy: function PDFPageProxy_destroy() {
  19197. this.destroyed = true;
  19198. this.transport.pageCache[this.pageIndex] = null;
  19199. var waitOn = [];
  19200. Object.keys(this.intentStates).forEach(function (intent) {
  19201. if (intent === 'oplist') {
  19202. return;
  19203. }
  19204. var intentState = this.intentStates[intent];
  19205. intentState.renderTasks.forEach(function (renderTask) {
  19206. var renderCompleted = renderTask.capability.promise.catch(function () {
  19207. });
  19208. waitOn.push(renderCompleted);
  19209. renderTask.cancel();
  19210. });
  19211. }, this);
  19212. this.objs.clear();
  19213. this.annotationsPromise = null;
  19214. this.pendingCleanup = false;
  19215. return Promise.all(waitOn);
  19216. },
  19217. destroy: function () {
  19218. deprecated('page destroy method, use cleanup() instead');
  19219. this.cleanup();
  19220. },
  19221. cleanup: function PDFPageProxy_cleanup() {
  19222. this.pendingCleanup = true;
  19223. this._tryCleanup();
  19224. },
  19225. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19226. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19227. var intentState = this.intentStates[intent];
  19228. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19229. }, this)) {
  19230. return;
  19231. }
  19232. Object.keys(this.intentStates).forEach(function (intent) {
  19233. delete this.intentStates[intent];
  19234. }, this);
  19235. this.objs.clear();
  19236. this.annotationsPromise = null;
  19237. this.pendingCleanup = false;
  19238. },
  19239. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19240. var intentState = this.intentStates[intent];
  19241. if (intentState.displayReadyCapability) {
  19242. intentState.displayReadyCapability.resolve(transparency);
  19243. }
  19244. },
  19245. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  19246. var intentState = this.intentStates[intent];
  19247. var i, ii;
  19248. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  19249. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  19250. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  19251. }
  19252. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  19253. for (i = 0; i < intentState.renderTasks.length; i++) {
  19254. intentState.renderTasks[i].operatorListChanged();
  19255. }
  19256. if (operatorListChunk.lastChunk) {
  19257. intentState.receivingOperatorList = false;
  19258. this._tryCleanup();
  19259. }
  19260. }
  19261. };
  19262. return PDFPageProxy;
  19263. }();
  19264. var PDFWorker = function PDFWorkerClosure() {
  19265. var nextFakeWorkerId = 0;
  19266. function getWorkerSrc() {
  19267. if (typeof workerSrc !== 'undefined') {
  19268. return workerSrc;
  19269. }
  19270. if (getDefaultSetting('workerSrc')) {
  19271. return getDefaultSetting('workerSrc');
  19272. }
  19273. if (pdfjsFilePath) {
  19274. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  19275. }
  19276. error('No PDFJS.workerSrc specified');
  19277. }
  19278. var fakeWorkerFilesLoadedCapability;
  19279. function setupFakeWorkerGlobal() {
  19280. var WorkerMessageHandler;
  19281. if (fakeWorkerFilesLoadedCapability) {
  19282. return fakeWorkerFilesLoadedCapability.promise;
  19283. }
  19284. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  19285. var pdfjsCoreWorker = __w_pdfjs_require__(23);
  19286. __w_pdfjs_require__(39);
  19287. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  19288. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  19289. return fakeWorkerFilesLoadedCapability.promise;
  19290. }
  19291. function FakeWorkerPort(defer) {
  19292. this._listeners = [];
  19293. this._defer = defer;
  19294. this._deferred = Promise.resolve(undefined);
  19295. }
  19296. FakeWorkerPort.prototype = {
  19297. postMessage: function (obj, transfers) {
  19298. function cloneValue(value) {
  19299. if (typeof value !== 'object' || value === null) {
  19300. return value;
  19301. }
  19302. if (cloned.has(value)) {
  19303. return cloned.get(value);
  19304. }
  19305. var result;
  19306. var buffer;
  19307. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  19308. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  19309. if (value === buffer) {
  19310. result = value;
  19311. } else if (transferable) {
  19312. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  19313. } else {
  19314. result = new value.constructor(value);
  19315. }
  19316. cloned.set(value, result);
  19317. return result;
  19318. }
  19319. result = isArray(value) ? [] : {};
  19320. cloned.set(value, result);
  19321. for (var i in value) {
  19322. var desc, p = value;
  19323. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  19324. p = Object.getPrototypeOf(p);
  19325. }
  19326. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  19327. continue;
  19328. }
  19329. result[i] = cloneValue(desc.value);
  19330. }
  19331. return result;
  19332. }
  19333. if (!this._defer) {
  19334. this._listeners.forEach(function (listener) {
  19335. listener.call(this, { data: obj });
  19336. }, this);
  19337. return;
  19338. }
  19339. var cloned = new WeakMap();
  19340. var e = { data: cloneValue(obj) };
  19341. this._deferred.then(function () {
  19342. this._listeners.forEach(function (listener) {
  19343. listener.call(this, e);
  19344. }, this);
  19345. }.bind(this));
  19346. },
  19347. addEventListener: function (name, listener) {
  19348. this._listeners.push(listener);
  19349. },
  19350. removeEventListener: function (name, listener) {
  19351. var i = this._listeners.indexOf(listener);
  19352. this._listeners.splice(i, 1);
  19353. },
  19354. terminate: function () {
  19355. this._listeners = [];
  19356. }
  19357. };
  19358. function createCDNWrapper(url) {
  19359. var wrapper = 'importScripts(\'' + url + '\');';
  19360. return URL.createObjectURL(new Blob([wrapper]));
  19361. }
  19362. function PDFWorker(name, port) {
  19363. this.name = name;
  19364. this.destroyed = false;
  19365. this._readyCapability = createPromiseCapability();
  19366. this._port = null;
  19367. this._webWorker = null;
  19368. this._messageHandler = null;
  19369. if (port) {
  19370. this._initializeFromPort(port);
  19371. return;
  19372. }
  19373. this._initialize();
  19374. }
  19375. PDFWorker.prototype = {
  19376. get promise() {
  19377. return this._readyCapability.promise;
  19378. },
  19379. get port() {
  19380. return this._port;
  19381. },
  19382. get messageHandler() {
  19383. return this._messageHandler;
  19384. },
  19385. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  19386. this._port = port;
  19387. this._messageHandler = new MessageHandler('main', 'worker', port);
  19388. this._messageHandler.on('ready', function () {
  19389. });
  19390. this._readyCapability.resolve();
  19391. },
  19392. _initialize: function PDFWorker_initialize() {
  19393. this._setupFakeWorker();
  19394. },
  19395. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  19396. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  19397. warn('Setting up fake worker.');
  19398. isWorkerDisabled = true;
  19399. }
  19400. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  19401. if (this.destroyed) {
  19402. this._readyCapability.reject(new Error('Worker was destroyed'));
  19403. return;
  19404. }
  19405. var isTypedArraysPresent = Uint8Array !== Float32Array;
  19406. var port = new FakeWorkerPort(isTypedArraysPresent);
  19407. this._port = port;
  19408. var id = 'fake' + nextFakeWorkerId++;
  19409. var workerHandler = new MessageHandler(id + '_worker', id, port);
  19410. WorkerMessageHandler.setup(workerHandler, port);
  19411. var messageHandler = new MessageHandler(id, id + '_worker', port);
  19412. this._messageHandler = messageHandler;
  19413. this._readyCapability.resolve();
  19414. }.bind(this));
  19415. },
  19416. destroy: function PDFWorker_destroy() {
  19417. this.destroyed = true;
  19418. if (this._webWorker) {
  19419. this._webWorker.terminate();
  19420. this._webWorker = null;
  19421. }
  19422. this._port = null;
  19423. if (this._messageHandler) {
  19424. this._messageHandler.destroy();
  19425. this._messageHandler = null;
  19426. }
  19427. }
  19428. };
  19429. return PDFWorker;
  19430. }();
  19431. var WorkerTransport = function WorkerTransportClosure() {
  19432. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  19433. this.messageHandler = messageHandler;
  19434. this.loadingTask = loadingTask;
  19435. this.pdfDataRangeTransport = pdfDataRangeTransport;
  19436. this.commonObjs = new PDFObjects();
  19437. this.fontLoader = new FontLoader(loadingTask.docId);
  19438. this.CMapReaderFactory = new CMapReaderFactory({
  19439. baseUrl: getDefaultSetting('cMapUrl'),
  19440. isCompressed: getDefaultSetting('cMapPacked')
  19441. });
  19442. this.destroyed = false;
  19443. this.destroyCapability = null;
  19444. this._passwordCapability = null;
  19445. this.pageCache = [];
  19446. this.pagePromises = [];
  19447. this.downloadInfoCapability = createPromiseCapability();
  19448. this.setupMessageHandler();
  19449. }
  19450. WorkerTransport.prototype = {
  19451. destroy: function WorkerTransport_destroy() {
  19452. if (this.destroyCapability) {
  19453. return this.destroyCapability.promise;
  19454. }
  19455. this.destroyed = true;
  19456. this.destroyCapability = createPromiseCapability();
  19457. if (this._passwordCapability) {
  19458. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  19459. }
  19460. var waitOn = [];
  19461. this.pageCache.forEach(function (page) {
  19462. if (page) {
  19463. waitOn.push(page._destroy());
  19464. }
  19465. });
  19466. this.pageCache = [];
  19467. this.pagePromises = [];
  19468. var self = this;
  19469. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  19470. waitOn.push(terminated);
  19471. Promise.all(waitOn).then(function () {
  19472. self.fontLoader.clear();
  19473. if (self.pdfDataRangeTransport) {
  19474. self.pdfDataRangeTransport.abort();
  19475. self.pdfDataRangeTransport = null;
  19476. }
  19477. if (self.messageHandler) {
  19478. self.messageHandler.destroy();
  19479. self.messageHandler = null;
  19480. }
  19481. self.destroyCapability.resolve();
  19482. }, this.destroyCapability.reject);
  19483. return this.destroyCapability.promise;
  19484. },
  19485. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  19486. var messageHandler = this.messageHandler;
  19487. var loadingTask = this.loadingTask;
  19488. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  19489. if (pdfDataRangeTransport) {
  19490. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  19491. messageHandler.send('OnDataRange', {
  19492. begin: begin,
  19493. chunk: chunk
  19494. });
  19495. });
  19496. pdfDataRangeTransport.addProgressListener(function (loaded) {
  19497. messageHandler.send('OnDataProgress', { loaded: loaded });
  19498. });
  19499. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  19500. messageHandler.send('OnDataRange', { chunk: chunk });
  19501. });
  19502. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  19503. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  19504. }, this);
  19505. }
  19506. messageHandler.on('GetDoc', function transportDoc(data) {
  19507. var pdfInfo = data.pdfInfo;
  19508. this.numPages = data.pdfInfo.numPages;
  19509. var loadingTask = this.loadingTask;
  19510. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  19511. this.pdfDocument = pdfDocument;
  19512. loadingTask._capability.resolve(pdfDocument);
  19513. }, this);
  19514. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  19515. this._passwordCapability = createPromiseCapability();
  19516. if (loadingTask.onPassword) {
  19517. var updatePassword = function (password) {
  19518. this._passwordCapability.resolve({ password: password });
  19519. }.bind(this);
  19520. loadingTask.onPassword(updatePassword, exception.code);
  19521. } else {
  19522. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  19523. }
  19524. return this._passwordCapability.promise;
  19525. }, this);
  19526. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  19527. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  19528. }, this);
  19529. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  19530. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  19531. }, this);
  19532. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  19533. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  19534. }, this);
  19535. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  19536. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  19537. }, this);
  19538. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  19539. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  19540. }, this);
  19541. messageHandler.on('DataLoaded', function transportPage(data) {
  19542. this.downloadInfoCapability.resolve(data);
  19543. }, this);
  19544. messageHandler.on('PDFManagerReady', function transportPage(data) {
  19545. if (this.pdfDataRangeTransport) {
  19546. this.pdfDataRangeTransport.transportReady();
  19547. }
  19548. }, this);
  19549. messageHandler.on('StartRenderPage', function transportRender(data) {
  19550. if (this.destroyed) {
  19551. return;
  19552. }
  19553. var page = this.pageCache[data.pageIndex];
  19554. page.stats.timeEnd('Page Request');
  19555. page._startRenderPage(data.transparency, data.intent);
  19556. }, this);
  19557. messageHandler.on('RenderPageChunk', function transportRender(data) {
  19558. if (this.destroyed) {
  19559. return;
  19560. }
  19561. var page = this.pageCache[data.pageIndex];
  19562. page._renderPageChunk(data.operatorList, data.intent);
  19563. }, this);
  19564. messageHandler.on('commonobj', function transportObj(data) {
  19565. if (this.destroyed) {
  19566. return;
  19567. }
  19568. var id = data[0];
  19569. var type = data[1];
  19570. if (this.commonObjs.hasData(id)) {
  19571. return;
  19572. }
  19573. switch (type) {
  19574. case 'Font':
  19575. var exportedData = data[2];
  19576. if ('error' in exportedData) {
  19577. var exportedError = exportedData.error;
  19578. warn('Error during font loading: ' + exportedError);
  19579. this.commonObjs.resolve(id, exportedError);
  19580. break;
  19581. }
  19582. var fontRegistry = null;
  19583. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  19584. fontRegistry = {
  19585. registerFont: function (font, url) {
  19586. globalScope['FontInspector'].fontAdded(font, url);
  19587. }
  19588. };
  19589. }
  19590. var font = new FontFaceObject(exportedData, {
  19591. isEvalSuported: getDefaultSetting('isEvalSupported'),
  19592. disableFontFace: getDefaultSetting('disableFontFace'),
  19593. fontRegistry: fontRegistry
  19594. });
  19595. this.fontLoader.bind([font], function fontReady(fontObjs) {
  19596. this.commonObjs.resolve(id, font);
  19597. }.bind(this));
  19598. break;
  19599. case 'FontPath':
  19600. this.commonObjs.resolve(id, data[2]);
  19601. break;
  19602. default:
  19603. error('Got unknown common object type ' + type);
  19604. }
  19605. }, this);
  19606. messageHandler.on('obj', function transportObj(data) {
  19607. if (this.destroyed) {
  19608. return;
  19609. }
  19610. var id = data[0];
  19611. var pageIndex = data[1];
  19612. var type = data[2];
  19613. var pageProxy = this.pageCache[pageIndex];
  19614. var imageData;
  19615. if (pageProxy.objs.hasData(id)) {
  19616. return;
  19617. }
  19618. switch (type) {
  19619. case 'JpegStream':
  19620. imageData = data[3];
  19621. loadJpegStream(id, imageData, pageProxy.objs);
  19622. break;
  19623. case 'Image':
  19624. imageData = data[3];
  19625. pageProxy.objs.resolve(id, imageData);
  19626. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  19627. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  19628. pageProxy.cleanupAfterRender = true;
  19629. }
  19630. break;
  19631. default:
  19632. error('Got unknown object type ' + type);
  19633. }
  19634. }, this);
  19635. messageHandler.on('DocProgress', function transportDocProgress(data) {
  19636. if (this.destroyed) {
  19637. return;
  19638. }
  19639. var loadingTask = this.loadingTask;
  19640. if (loadingTask.onProgress) {
  19641. loadingTask.onProgress({
  19642. loaded: data.loaded,
  19643. total: data.total
  19644. });
  19645. }
  19646. }, this);
  19647. messageHandler.on('PageError', function transportError(data) {
  19648. if (this.destroyed) {
  19649. return;
  19650. }
  19651. var page = this.pageCache[data.pageNum - 1];
  19652. var intentState = page.intentStates[data.intent];
  19653. if (intentState.displayReadyCapability) {
  19654. intentState.displayReadyCapability.reject(data.error);
  19655. } else {
  19656. error(data.error);
  19657. }
  19658. if (intentState.operatorList) {
  19659. intentState.operatorList.lastChunk = true;
  19660. for (var i = 0; i < intentState.renderTasks.length; i++) {
  19661. intentState.renderTasks[i].operatorListChanged();
  19662. }
  19663. }
  19664. }, this);
  19665. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  19666. if (this.destroyed) {
  19667. return;
  19668. }
  19669. var featureId = data.featureId;
  19670. var loadingTask = this.loadingTask;
  19671. if (loadingTask.onUnsupportedFeature) {
  19672. loadingTask.onUnsupportedFeature(featureId);
  19673. }
  19674. _UnsupportedManager.notify(featureId);
  19675. }, this);
  19676. messageHandler.on('JpegDecode', function (data) {
  19677. if (this.destroyed) {
  19678. return Promise.reject(new Error('Worker was destroyed'));
  19679. }
  19680. if (typeof document === 'undefined') {
  19681. return Promise.reject(new Error('"document" is not defined.'));
  19682. }
  19683. var imageUrl = data[0];
  19684. var components = data[1];
  19685. if (components !== 3 && components !== 1) {
  19686. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  19687. }
  19688. return new Promise(function (resolve, reject) {
  19689. var img = new Image();
  19690. img.onload = function () {
  19691. var width = img.width;
  19692. var height = img.height;
  19693. var size = width * height;
  19694. var rgbaLength = size * 4;
  19695. var buf = new Uint8Array(size * components);
  19696. var tmpCanvas = document.createElement('canvas');
  19697. tmpCanvas.width = width;
  19698. tmpCanvas.height = height;
  19699. var tmpCtx = tmpCanvas.getContext('2d');
  19700. tmpCtx.drawImage(img, 0, 0);
  19701. var data = tmpCtx.getImageData(0, 0, width, height).data;
  19702. var i, j;
  19703. if (components === 3) {
  19704. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  19705. buf[j] = data[i];
  19706. buf[j + 1] = data[i + 1];
  19707. buf[j + 2] = data[i + 2];
  19708. }
  19709. } else if (components === 1) {
  19710. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  19711. buf[j] = data[i];
  19712. }
  19713. }
  19714. resolve({
  19715. data: buf,
  19716. width: width,
  19717. height: height
  19718. });
  19719. };
  19720. img.onerror = function () {
  19721. reject(new Error('JpegDecode failed to load image'));
  19722. };
  19723. img.src = imageUrl;
  19724. });
  19725. }, this);
  19726. messageHandler.on('FetchBuiltInCMap', function (data) {
  19727. if (this.destroyed) {
  19728. return Promise.reject(new Error('Worker was destroyed'));
  19729. }
  19730. return this.CMapReaderFactory.fetch({ name: data.name });
  19731. }, this);
  19732. },
  19733. getData: function WorkerTransport_getData() {
  19734. return this.messageHandler.sendWithPromise('GetData', null);
  19735. },
  19736. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  19737. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  19738. return Promise.reject(new Error('Invalid page request'));
  19739. }
  19740. var pageIndex = pageNumber - 1;
  19741. if (pageIndex in this.pagePromises) {
  19742. return this.pagePromises[pageIndex];
  19743. }
  19744. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  19745. if (this.destroyed) {
  19746. throw new Error('Transport destroyed');
  19747. }
  19748. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  19749. this.pageCache[pageIndex] = page;
  19750. return page;
  19751. }.bind(this));
  19752. this.pagePromises[pageIndex] = promise;
  19753. return promise;
  19754. },
  19755. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  19756. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  19757. return Promise.reject(new Error(reason));
  19758. });
  19759. },
  19760. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  19761. return this.messageHandler.sendWithPromise('GetAnnotations', {
  19762. pageIndex: pageIndex,
  19763. intent: intent
  19764. });
  19765. },
  19766. getDestinations: function WorkerTransport_getDestinations() {
  19767. return this.messageHandler.sendWithPromise('GetDestinations', null);
  19768. },
  19769. getDestination: function WorkerTransport_getDestination(id) {
  19770. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  19771. },
  19772. getPageLabels: function WorkerTransport_getPageLabels() {
  19773. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  19774. },
  19775. getAttachments: function WorkerTransport_getAttachments() {
  19776. return this.messageHandler.sendWithPromise('GetAttachments', null);
  19777. },
  19778. getJavaScript: function WorkerTransport_getJavaScript() {
  19779. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  19780. },
  19781. getOutline: function WorkerTransport_getOutline() {
  19782. return this.messageHandler.sendWithPromise('GetOutline', null);
  19783. },
  19784. getMetadata: function WorkerTransport_getMetadata() {
  19785. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  19786. return {
  19787. info: results[0],
  19788. metadata: results[1] ? new Metadata(results[1]) : null
  19789. };
  19790. });
  19791. },
  19792. getStats: function WorkerTransport_getStats() {
  19793. return this.messageHandler.sendWithPromise('GetStats', null);
  19794. },
  19795. startCleanup: function WorkerTransport_startCleanup() {
  19796. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  19797. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  19798. var page = this.pageCache[i];
  19799. if (page) {
  19800. page.cleanup();
  19801. }
  19802. }
  19803. this.commonObjs.clear();
  19804. this.fontLoader.clear();
  19805. }.bind(this));
  19806. }
  19807. };
  19808. return WorkerTransport;
  19809. }();
  19810. var PDFObjects = function PDFObjectsClosure() {
  19811. function PDFObjects() {
  19812. this.objs = Object.create(null);
  19813. }
  19814. PDFObjects.prototype = {
  19815. ensureObj: function PDFObjects_ensureObj(objId) {
  19816. if (this.objs[objId]) {
  19817. return this.objs[objId];
  19818. }
  19819. var obj = {
  19820. capability: createPromiseCapability(),
  19821. data: null,
  19822. resolved: false
  19823. };
  19824. this.objs[objId] = obj;
  19825. return obj;
  19826. },
  19827. get: function PDFObjects_get(objId, callback) {
  19828. if (callback) {
  19829. this.ensureObj(objId).capability.promise.then(callback);
  19830. return null;
  19831. }
  19832. var obj = this.objs[objId];
  19833. if (!obj || !obj.resolved) {
  19834. error('Requesting object that isn\'t resolved yet ' + objId);
  19835. }
  19836. return obj.data;
  19837. },
  19838. resolve: function PDFObjects_resolve(objId, data) {
  19839. var obj = this.ensureObj(objId);
  19840. obj.resolved = true;
  19841. obj.data = data;
  19842. obj.capability.resolve(data);
  19843. },
  19844. isResolved: function PDFObjects_isResolved(objId) {
  19845. var objs = this.objs;
  19846. if (!objs[objId]) {
  19847. return false;
  19848. }
  19849. return objs[objId].resolved;
  19850. },
  19851. hasData: function PDFObjects_hasData(objId) {
  19852. return this.isResolved(objId);
  19853. },
  19854. getData: function PDFObjects_getData(objId) {
  19855. var objs = this.objs;
  19856. if (!objs[objId] || !objs[objId].resolved) {
  19857. return null;
  19858. }
  19859. return objs[objId].data;
  19860. },
  19861. clear: function PDFObjects_clear() {
  19862. this.objs = Object.create(null);
  19863. }
  19864. };
  19865. return PDFObjects;
  19866. }();
  19867. var RenderTask = function RenderTaskClosure() {
  19868. function RenderTask(internalRenderTask) {
  19869. this._internalRenderTask = internalRenderTask;
  19870. this.onContinue = null;
  19871. }
  19872. RenderTask.prototype = {
  19873. get promise() {
  19874. return this._internalRenderTask.capability.promise;
  19875. },
  19876. cancel: function RenderTask_cancel() {
  19877. this._internalRenderTask.cancel();
  19878. },
  19879. then: function RenderTask_then(onFulfilled, onRejected) {
  19880. return this.promise.then.apply(this.promise, arguments);
  19881. }
  19882. };
  19883. return RenderTask;
  19884. }();
  19885. var InternalRenderTask = function InternalRenderTaskClosure() {
  19886. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  19887. this.callback = callback;
  19888. this.params = params;
  19889. this.objs = objs;
  19890. this.commonObjs = commonObjs;
  19891. this.operatorListIdx = null;
  19892. this.operatorList = operatorList;
  19893. this.pageNumber = pageNumber;
  19894. this.canvasFactory = canvasFactory;
  19895. this.running = false;
  19896. this.graphicsReadyCallback = null;
  19897. this.graphicsReady = false;
  19898. this.useRequestAnimationFrame = false;
  19899. this.cancelled = false;
  19900. this.capability = createPromiseCapability();
  19901. this.task = new RenderTask(this);
  19902. this._continueBound = this._continue.bind(this);
  19903. this._scheduleNextBound = this._scheduleNext.bind(this);
  19904. this._nextBound = this._next.bind(this);
  19905. }
  19906. InternalRenderTask.prototype = {
  19907. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  19908. if (this.cancelled) {
  19909. return;
  19910. }
  19911. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  19912. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  19913. this.stepper.init(this.operatorList);
  19914. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  19915. }
  19916. var params = this.params;
  19917. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  19918. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  19919. this.operatorListIdx = 0;
  19920. this.graphicsReady = true;
  19921. if (this.graphicsReadyCallback) {
  19922. this.graphicsReadyCallback();
  19923. }
  19924. },
  19925. cancel: function InternalRenderTask_cancel() {
  19926. this.running = false;
  19927. this.cancelled = true;
  19928. this.callback('cancelled');
  19929. },
  19930. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  19931. if (!this.graphicsReady) {
  19932. if (!this.graphicsReadyCallback) {
  19933. this.graphicsReadyCallback = this._continueBound;
  19934. }
  19935. return;
  19936. }
  19937. if (this.stepper) {
  19938. this.stepper.updateOperatorList(this.operatorList);
  19939. }
  19940. if (this.running) {
  19941. return;
  19942. }
  19943. this._continue();
  19944. },
  19945. _continue: function InternalRenderTask__continue() {
  19946. this.running = true;
  19947. if (this.cancelled) {
  19948. return;
  19949. }
  19950. if (this.task.onContinue) {
  19951. this.task.onContinue(this._scheduleNextBound);
  19952. } else {
  19953. this._scheduleNext();
  19954. }
  19955. },
  19956. _scheduleNext: function InternalRenderTask__scheduleNext() {
  19957. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  19958. window.requestAnimationFrame(this._nextBound);
  19959. } else {
  19960. Promise.resolve(undefined).then(this._nextBound);
  19961. }
  19962. },
  19963. _next: function InternalRenderTask__next() {
  19964. if (this.cancelled) {
  19965. return;
  19966. }
  19967. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  19968. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  19969. this.running = false;
  19970. if (this.operatorList.lastChunk) {
  19971. this.gfx.endDrawing();
  19972. this.callback();
  19973. }
  19974. }
  19975. }
  19976. };
  19977. return InternalRenderTask;
  19978. }();
  19979. var _UnsupportedManager = function UnsupportedManagerClosure() {
  19980. var listeners = [];
  19981. return {
  19982. listen: function (cb) {
  19983. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  19984. listeners.push(cb);
  19985. },
  19986. notify: function (featureId) {
  19987. for (var i = 0, ii = listeners.length; i < ii; i++) {
  19988. listeners[i](featureId);
  19989. }
  19990. }
  19991. };
  19992. }();
  19993. exports.version = '1.7.387';
  19994. exports.build = 'b6bf1a3e';
  19995. exports.getDocument = getDocument;
  19996. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  19997. exports.PDFWorker = PDFWorker;
  19998. exports.PDFDocumentProxy = PDFDocumentProxy;
  19999. exports.PDFPageProxy = PDFPageProxy;
  20000. exports._UnsupportedManager = _UnsupportedManager;
  20001. /***/ }),
  20002. /* 11 */
  20003. /***/ (function(module, exports, __w_pdfjs_require__) {
  20004. "use strict";
  20005. var sharedUtil = __w_pdfjs_require__(0);
  20006. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20007. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20008. var ImageKind = sharedUtil.ImageKind;
  20009. var OPS = sharedUtil.OPS;
  20010. var Util = sharedUtil.Util;
  20011. var isNum = sharedUtil.isNum;
  20012. var isArray = sharedUtil.isArray;
  20013. var warn = sharedUtil.warn;
  20014. var createObjectURL = sharedUtil.createObjectURL;
  20015. var SVG_DEFAULTS = {
  20016. fontStyle: 'normal',
  20017. fontWeight: 'normal',
  20018. fillColor: '#000000'
  20019. };
  20020. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20021. var PNG_HEADER = new Uint8Array([
  20022. 0x89,
  20023. 0x50,
  20024. 0x4e,
  20025. 0x47,
  20026. 0x0d,
  20027. 0x0a,
  20028. 0x1a,
  20029. 0x0a
  20030. ]);
  20031. var CHUNK_WRAPPER_SIZE = 12;
  20032. var crcTable = new Int32Array(256);
  20033. for (var i = 0; i < 256; i++) {
  20034. var c = i;
  20035. for (var h = 0; h < 8; h++) {
  20036. if (c & 1) {
  20037. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20038. } else {
  20039. c = c >> 1 & 0x7fffffff;
  20040. }
  20041. }
  20042. crcTable[i] = c;
  20043. }
  20044. function crc32(data, start, end) {
  20045. var crc = -1;
  20046. for (var i = start; i < end; i++) {
  20047. var a = (crc ^ data[i]) & 0xff;
  20048. var b = crcTable[a];
  20049. crc = crc >>> 8 ^ b;
  20050. }
  20051. return crc ^ -1;
  20052. }
  20053. function writePngChunk(type, body, data, offset) {
  20054. var p = offset;
  20055. var len = body.length;
  20056. data[p] = len >> 24 & 0xff;
  20057. data[p + 1] = len >> 16 & 0xff;
  20058. data[p + 2] = len >> 8 & 0xff;
  20059. data[p + 3] = len & 0xff;
  20060. p += 4;
  20061. data[p] = type.charCodeAt(0) & 0xff;
  20062. data[p + 1] = type.charCodeAt(1) & 0xff;
  20063. data[p + 2] = type.charCodeAt(2) & 0xff;
  20064. data[p + 3] = type.charCodeAt(3) & 0xff;
  20065. p += 4;
  20066. data.set(body, p);
  20067. p += body.length;
  20068. var crc = crc32(data, offset + 4, p);
  20069. data[p] = crc >> 24 & 0xff;
  20070. data[p + 1] = crc >> 16 & 0xff;
  20071. data[p + 2] = crc >> 8 & 0xff;
  20072. data[p + 3] = crc & 0xff;
  20073. }
  20074. function adler32(data, start, end) {
  20075. var a = 1;
  20076. var b = 0;
  20077. for (var i = start; i < end; ++i) {
  20078. a = (a + (data[i] & 0xff)) % 65521;
  20079. b = (b + a) % 65521;
  20080. }
  20081. return b << 16 | a;
  20082. }
  20083. function encode(imgData, kind, forceDataSchema) {
  20084. var width = imgData.width;
  20085. var height = imgData.height;
  20086. var bitDepth, colorType, lineSize;
  20087. var bytes = imgData.data;
  20088. switch (kind) {
  20089. case ImageKind.GRAYSCALE_1BPP:
  20090. colorType = 0;
  20091. bitDepth = 1;
  20092. lineSize = width + 7 >> 3;
  20093. break;
  20094. case ImageKind.RGB_24BPP:
  20095. colorType = 2;
  20096. bitDepth = 8;
  20097. lineSize = width * 3;
  20098. break;
  20099. case ImageKind.RGBA_32BPP:
  20100. colorType = 6;
  20101. bitDepth = 8;
  20102. lineSize = width * 4;
  20103. break;
  20104. default:
  20105. throw new Error('invalid format');
  20106. }
  20107. var literals = new Uint8Array((1 + lineSize) * height);
  20108. var offsetLiterals = 0, offsetBytes = 0;
  20109. var y, i;
  20110. for (y = 0; y < height; ++y) {
  20111. literals[offsetLiterals++] = 0;
  20112. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20113. offsetBytes += lineSize;
  20114. offsetLiterals += lineSize;
  20115. }
  20116. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20117. offsetLiterals = 0;
  20118. for (y = 0; y < height; y++) {
  20119. offsetLiterals++;
  20120. for (i = 0; i < lineSize; i++) {
  20121. literals[offsetLiterals++] ^= 0xFF;
  20122. }
  20123. }
  20124. }
  20125. var ihdr = new Uint8Array([
  20126. width >> 24 & 0xff,
  20127. width >> 16 & 0xff,
  20128. width >> 8 & 0xff,
  20129. width & 0xff,
  20130. height >> 24 & 0xff,
  20131. height >> 16 & 0xff,
  20132. height >> 8 & 0xff,
  20133. height & 0xff,
  20134. bitDepth,
  20135. colorType,
  20136. 0x00,
  20137. 0x00,
  20138. 0x00
  20139. ]);
  20140. var len = literals.length;
  20141. var maxBlockLength = 0xFFFF;
  20142. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20143. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20144. var pi = 0;
  20145. idat[pi++] = 0x78;
  20146. idat[pi++] = 0x9c;
  20147. var pos = 0;
  20148. while (len > maxBlockLength) {
  20149. idat[pi++] = 0x00;
  20150. idat[pi++] = 0xff;
  20151. idat[pi++] = 0xff;
  20152. idat[pi++] = 0x00;
  20153. idat[pi++] = 0x00;
  20154. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20155. pi += maxBlockLength;
  20156. pos += maxBlockLength;
  20157. len -= maxBlockLength;
  20158. }
  20159. idat[pi++] = 0x01;
  20160. idat[pi++] = len & 0xff;
  20161. idat[pi++] = len >> 8 & 0xff;
  20162. idat[pi++] = ~len & 0xffff & 0xff;
  20163. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20164. idat.set(literals.subarray(pos), pi);
  20165. pi += literals.length - pos;
  20166. var adler = adler32(literals, 0, literals.length);
  20167. idat[pi++] = adler >> 24 & 0xff;
  20168. idat[pi++] = adler >> 16 & 0xff;
  20169. idat[pi++] = adler >> 8 & 0xff;
  20170. idat[pi++] = adler & 0xff;
  20171. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20172. var data = new Uint8Array(pngLength);
  20173. var offset = 0;
  20174. data.set(PNG_HEADER, offset);
  20175. offset += PNG_HEADER.length;
  20176. writePngChunk('IHDR', ihdr, data, offset);
  20177. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20178. writePngChunk('IDATA', idat, data, offset);
  20179. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20180. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20181. return createObjectURL(data, 'image/png', forceDataSchema);
  20182. }
  20183. return function convertImgDataToPng(imgData, forceDataSchema) {
  20184. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20185. return encode(imgData, kind, forceDataSchema);
  20186. };
  20187. }();
  20188. var SVGExtraState = function SVGExtraStateClosure() {
  20189. function SVGExtraState() {
  20190. this.fontSizeScale = 1;
  20191. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20192. this.fontSize = 0;
  20193. this.textMatrix = IDENTITY_MATRIX;
  20194. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20195. this.leading = 0;
  20196. this.x = 0;
  20197. this.y = 0;
  20198. this.lineX = 0;
  20199. this.lineY = 0;
  20200. this.charSpacing = 0;
  20201. this.wordSpacing = 0;
  20202. this.textHScale = 1;
  20203. this.textRise = 0;
  20204. this.fillColor = SVG_DEFAULTS.fillColor;
  20205. this.strokeColor = '#000000';
  20206. this.fillAlpha = 1;
  20207. this.strokeAlpha = 1;
  20208. this.lineWidth = 1;
  20209. this.lineJoin = '';
  20210. this.lineCap = '';
  20211. this.miterLimit = 0;
  20212. this.dashArray = [];
  20213. this.dashPhase = 0;
  20214. this.dependencies = [];
  20215. this.activeClipUrl = null;
  20216. this.clipGroup = null;
  20217. this.maskId = '';
  20218. }
  20219. SVGExtraState.prototype = {
  20220. clone: function SVGExtraState_clone() {
  20221. return Object.create(this);
  20222. },
  20223. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20224. this.x = x;
  20225. this.y = y;
  20226. }
  20227. };
  20228. return SVGExtraState;
  20229. }();
  20230. var SVGGraphics = function SVGGraphicsClosure() {
  20231. function opListToTree(opList) {
  20232. var opTree = [];
  20233. var tmp = [];
  20234. var opListLen = opList.length;
  20235. for (var x = 0; x < opListLen; x++) {
  20236. if (opList[x].fn === 'save') {
  20237. opTree.push({
  20238. 'fnId': 92,
  20239. 'fn': 'group',
  20240. 'items': []
  20241. });
  20242. tmp.push(opTree);
  20243. opTree = opTree[opTree.length - 1].items;
  20244. continue;
  20245. }
  20246. if (opList[x].fn === 'restore') {
  20247. opTree = tmp.pop();
  20248. } else {
  20249. opTree.push(opList[x]);
  20250. }
  20251. }
  20252. return opTree;
  20253. }
  20254. function pf(value) {
  20255. if (value === (value | 0)) {
  20256. return value.toString();
  20257. }
  20258. var s = value.toFixed(10);
  20259. var i = s.length - 1;
  20260. if (s[i] !== '0') {
  20261. return s;
  20262. }
  20263. do {
  20264. i--;
  20265. } while (s[i] === '0');
  20266. return s.substr(0, s[i] === '.' ? i : i + 1);
  20267. }
  20268. function pm(m) {
  20269. if (m[4] === 0 && m[5] === 0) {
  20270. if (m[1] === 0 && m[2] === 0) {
  20271. if (m[0] === 1 && m[3] === 1) {
  20272. return '';
  20273. }
  20274. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  20275. }
  20276. if (m[0] === m[3] && m[1] === -m[2]) {
  20277. var a = Math.acos(m[0]) * 180 / Math.PI;
  20278. return 'rotate(' + pf(a) + ')';
  20279. }
  20280. } else {
  20281. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20282. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20283. }
  20284. }
  20285. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20286. }
  20287. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  20288. this.current = new SVGExtraState();
  20289. this.transformMatrix = IDENTITY_MATRIX;
  20290. this.transformStack = [];
  20291. this.extraStack = [];
  20292. this.commonObjs = commonObjs;
  20293. this.objs = objs;
  20294. this.pendingEOFill = false;
  20295. this.embedFonts = false;
  20296. this.embeddedFonts = Object.create(null);
  20297. this.cssStyle = null;
  20298. this.forceDataSchema = !!forceDataSchema;
  20299. }
  20300. var NS = 'http://www.w3.org/2000/svg';
  20301. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  20302. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  20303. var LINE_CAP_STYLES = [
  20304. 'butt',
  20305. 'round',
  20306. 'square'
  20307. ];
  20308. var LINE_JOIN_STYLES = [
  20309. 'miter',
  20310. 'round',
  20311. 'bevel'
  20312. ];
  20313. var clipCount = 0;
  20314. var maskCount = 0;
  20315. SVGGraphics.prototype = {
  20316. save: function SVGGraphics_save() {
  20317. this.transformStack.push(this.transformMatrix);
  20318. var old = this.current;
  20319. this.extraStack.push(old);
  20320. this.current = old.clone();
  20321. },
  20322. restore: function SVGGraphics_restore() {
  20323. this.transformMatrix = this.transformStack.pop();
  20324. this.current = this.extraStack.pop();
  20325. this.tgrp = null;
  20326. },
  20327. group: function SVGGraphics_group(items) {
  20328. this.save();
  20329. this.executeOpTree(items);
  20330. this.restore();
  20331. },
  20332. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  20333. var fnArray = operatorList.fnArray;
  20334. var fnArrayLen = fnArray.length;
  20335. var argsArray = operatorList.argsArray;
  20336. var self = this;
  20337. for (var i = 0; i < fnArrayLen; i++) {
  20338. if (OPS.dependency === fnArray[i]) {
  20339. var deps = argsArray[i];
  20340. for (var n = 0, nn = deps.length; n < nn; n++) {
  20341. var obj = deps[n];
  20342. var common = obj.substring(0, 2) === 'g_';
  20343. var promise;
  20344. if (common) {
  20345. promise = new Promise(function (resolve) {
  20346. self.commonObjs.get(obj, resolve);
  20347. });
  20348. } else {
  20349. promise = new Promise(function (resolve) {
  20350. self.objs.get(obj, resolve);
  20351. });
  20352. }
  20353. this.current.dependencies.push(promise);
  20354. }
  20355. }
  20356. }
  20357. return Promise.all(this.current.dependencies);
  20358. },
  20359. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  20360. var transformMatrix = [
  20361. a,
  20362. b,
  20363. c,
  20364. d,
  20365. e,
  20366. f
  20367. ];
  20368. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  20369. this.tgrp = null;
  20370. },
  20371. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  20372. this.viewport = viewport;
  20373. var svgElement = this._initialize(viewport);
  20374. return this.loadDependencies(operatorList).then(function () {
  20375. this.transformMatrix = IDENTITY_MATRIX;
  20376. var opTree = this.convertOpList(operatorList);
  20377. this.executeOpTree(opTree);
  20378. return svgElement;
  20379. }.bind(this));
  20380. },
  20381. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  20382. var argsArray = operatorList.argsArray;
  20383. var fnArray = operatorList.fnArray;
  20384. var fnArrayLen = fnArray.length;
  20385. var REVOPS = [];
  20386. var opList = [];
  20387. for (var op in OPS) {
  20388. REVOPS[OPS[op]] = op;
  20389. }
  20390. for (var x = 0; x < fnArrayLen; x++) {
  20391. var fnId = fnArray[x];
  20392. opList.push({
  20393. 'fnId': fnId,
  20394. 'fn': REVOPS[fnId],
  20395. 'args': argsArray[x]
  20396. });
  20397. }
  20398. return opListToTree(opList);
  20399. },
  20400. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  20401. var opTreeLen = opTree.length;
  20402. for (var x = 0; x < opTreeLen; x++) {
  20403. var fn = opTree[x].fn;
  20404. var fnId = opTree[x].fnId;
  20405. var args = opTree[x].args;
  20406. switch (fnId | 0) {
  20407. case OPS.beginText:
  20408. this.beginText();
  20409. break;
  20410. case OPS.setLeading:
  20411. this.setLeading(args);
  20412. break;
  20413. case OPS.setLeadingMoveText:
  20414. this.setLeadingMoveText(args[0], args[1]);
  20415. break;
  20416. case OPS.setFont:
  20417. this.setFont(args);
  20418. break;
  20419. case OPS.showText:
  20420. this.showText(args[0]);
  20421. break;
  20422. case OPS.showSpacedText:
  20423. this.showText(args[0]);
  20424. break;
  20425. case OPS.endText:
  20426. this.endText();
  20427. break;
  20428. case OPS.moveText:
  20429. this.moveText(args[0], args[1]);
  20430. break;
  20431. case OPS.setCharSpacing:
  20432. this.setCharSpacing(args[0]);
  20433. break;
  20434. case OPS.setWordSpacing:
  20435. this.setWordSpacing(args[0]);
  20436. break;
  20437. case OPS.setHScale:
  20438. this.setHScale(args[0]);
  20439. break;
  20440. case OPS.setTextMatrix:
  20441. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20442. break;
  20443. case OPS.setLineWidth:
  20444. this.setLineWidth(args[0]);
  20445. break;
  20446. case OPS.setLineJoin:
  20447. this.setLineJoin(args[0]);
  20448. break;
  20449. case OPS.setLineCap:
  20450. this.setLineCap(args[0]);
  20451. break;
  20452. case OPS.setMiterLimit:
  20453. this.setMiterLimit(args[0]);
  20454. break;
  20455. case OPS.setFillRGBColor:
  20456. this.setFillRGBColor(args[0], args[1], args[2]);
  20457. break;
  20458. case OPS.setStrokeRGBColor:
  20459. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20460. break;
  20461. case OPS.setDash:
  20462. this.setDash(args[0], args[1]);
  20463. break;
  20464. case OPS.setGState:
  20465. this.setGState(args[0]);
  20466. break;
  20467. case OPS.fill:
  20468. this.fill();
  20469. break;
  20470. case OPS.eoFill:
  20471. this.eoFill();
  20472. break;
  20473. case OPS.stroke:
  20474. this.stroke();
  20475. break;
  20476. case OPS.fillStroke:
  20477. this.fillStroke();
  20478. break;
  20479. case OPS.eoFillStroke:
  20480. this.eoFillStroke();
  20481. break;
  20482. case OPS.clip:
  20483. this.clip('nonzero');
  20484. break;
  20485. case OPS.eoClip:
  20486. this.clip('evenodd');
  20487. break;
  20488. case OPS.paintSolidColorImageMask:
  20489. this.paintSolidColorImageMask();
  20490. break;
  20491. case OPS.paintJpegXObject:
  20492. this.paintJpegXObject(args[0], args[1], args[2]);
  20493. break;
  20494. case OPS.paintImageXObject:
  20495. this.paintImageXObject(args[0]);
  20496. break;
  20497. case OPS.paintInlineImageXObject:
  20498. this.paintInlineImageXObject(args[0]);
  20499. break;
  20500. case OPS.paintImageMaskXObject:
  20501. this.paintImageMaskXObject(args[0]);
  20502. break;
  20503. case OPS.paintFormXObjectBegin:
  20504. this.paintFormXObjectBegin(args[0], args[1]);
  20505. break;
  20506. case OPS.paintFormXObjectEnd:
  20507. this.paintFormXObjectEnd();
  20508. break;
  20509. case OPS.closePath:
  20510. this.closePath();
  20511. break;
  20512. case OPS.closeStroke:
  20513. this.closeStroke();
  20514. break;
  20515. case OPS.closeFillStroke:
  20516. this.closeFillStroke();
  20517. break;
  20518. case OPS.nextLine:
  20519. this.nextLine();
  20520. break;
  20521. case OPS.transform:
  20522. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20523. break;
  20524. case OPS.constructPath:
  20525. this.constructPath(args[0], args[1]);
  20526. break;
  20527. case OPS.endPath:
  20528. this.endPath();
  20529. break;
  20530. case 92:
  20531. this.group(opTree[x].items);
  20532. break;
  20533. default:
  20534. warn('Unimplemented operator ' + fn);
  20535. break;
  20536. }
  20537. }
  20538. },
  20539. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  20540. this.current.wordSpacing = wordSpacing;
  20541. },
  20542. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  20543. this.current.charSpacing = charSpacing;
  20544. },
  20545. nextLine: function SVGGraphics_nextLine() {
  20546. this.moveText(0, this.current.leading);
  20547. },
  20548. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  20549. var current = this.current;
  20550. this.current.textMatrix = this.current.lineMatrix = [
  20551. a,
  20552. b,
  20553. c,
  20554. d,
  20555. e,
  20556. f
  20557. ];
  20558. this.current.x = this.current.lineX = 0;
  20559. this.current.y = this.current.lineY = 0;
  20560. current.xcoords = [];
  20561. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20562. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20563. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20564. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20565. current.txtElement = document.createElementNS(NS, 'svg:text');
  20566. current.txtElement.appendChild(current.tspan);
  20567. },
  20568. beginText: function SVGGraphics_beginText() {
  20569. this.current.x = this.current.lineX = 0;
  20570. this.current.y = this.current.lineY = 0;
  20571. this.current.textMatrix = IDENTITY_MATRIX;
  20572. this.current.lineMatrix = IDENTITY_MATRIX;
  20573. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20574. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  20575. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  20576. this.current.xcoords = [];
  20577. },
  20578. moveText: function SVGGraphics_moveText(x, y) {
  20579. var current = this.current;
  20580. this.current.x = this.current.lineX += x;
  20581. this.current.y = this.current.lineY += y;
  20582. current.xcoords = [];
  20583. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20584. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20585. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20586. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20587. },
  20588. showText: function SVGGraphics_showText(glyphs) {
  20589. var current = this.current;
  20590. var font = current.font;
  20591. var fontSize = current.fontSize;
  20592. if (fontSize === 0) {
  20593. return;
  20594. }
  20595. var charSpacing = current.charSpacing;
  20596. var wordSpacing = current.wordSpacing;
  20597. var fontDirection = current.fontDirection;
  20598. var textHScale = current.textHScale * fontDirection;
  20599. var glyphsLength = glyphs.length;
  20600. var vertical = font.vertical;
  20601. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20602. var x = 0, i;
  20603. for (i = 0; i < glyphsLength; ++i) {
  20604. var glyph = glyphs[i];
  20605. if (glyph === null) {
  20606. x += fontDirection * wordSpacing;
  20607. continue;
  20608. } else if (isNum(glyph)) {
  20609. x += -glyph * fontSize * 0.001;
  20610. continue;
  20611. }
  20612. current.xcoords.push(current.x + x * textHScale);
  20613. var width = glyph.width;
  20614. var character = glyph.fontChar;
  20615. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  20616. x += charWidth;
  20617. current.tspan.textContent += character;
  20618. }
  20619. if (vertical) {
  20620. current.y -= x * textHScale;
  20621. } else {
  20622. current.x += x * textHScale;
  20623. }
  20624. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  20625. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20626. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20627. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20628. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20629. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  20630. }
  20631. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20632. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  20633. }
  20634. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20635. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  20636. }
  20637. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  20638. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  20639. current.txtElement.appendChild(current.tspan);
  20640. current.txtgrp.appendChild(current.txtElement);
  20641. this._ensureTransformGroup().appendChild(current.txtElement);
  20642. },
  20643. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  20644. this.setLeading(-y);
  20645. this.moveText(x, y);
  20646. },
  20647. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  20648. if (!this.cssStyle) {
  20649. this.cssStyle = document.createElementNS(NS, 'svg:style');
  20650. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  20651. this.defs.appendChild(this.cssStyle);
  20652. }
  20653. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20654. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  20655. },
  20656. setFont: function SVGGraphics_setFont(details) {
  20657. var current = this.current;
  20658. var fontObj = this.commonObjs.get(details[0]);
  20659. var size = details[1];
  20660. this.current.font = fontObj;
  20661. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  20662. this.addFontStyle(fontObj);
  20663. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20664. }
  20665. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  20666. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  20667. var italic = fontObj.italic ? 'italic' : 'normal';
  20668. if (size < 0) {
  20669. size = -size;
  20670. current.fontDirection = -1;
  20671. } else {
  20672. current.fontDirection = 1;
  20673. }
  20674. current.fontSize = size;
  20675. current.fontFamily = fontObj.loadedName;
  20676. current.fontWeight = bold;
  20677. current.fontStyle = italic;
  20678. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20679. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20680. current.xcoords = [];
  20681. },
  20682. endText: function SVGGraphics_endText() {
  20683. },
  20684. setLineWidth: function SVGGraphics_setLineWidth(width) {
  20685. this.current.lineWidth = width;
  20686. },
  20687. setLineCap: function SVGGraphics_setLineCap(style) {
  20688. this.current.lineCap = LINE_CAP_STYLES[style];
  20689. },
  20690. setLineJoin: function SVGGraphics_setLineJoin(style) {
  20691. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20692. },
  20693. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  20694. this.current.miterLimit = limit;
  20695. },
  20696. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  20697. var color = Util.makeCssRgb(r, g, b);
  20698. this.current.strokeColor = color;
  20699. },
  20700. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  20701. var color = Util.makeCssRgb(r, g, b);
  20702. this.current.fillColor = color;
  20703. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20704. this.current.xcoords = [];
  20705. },
  20706. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  20707. this.current.dashArray = dashArray;
  20708. this.current.dashPhase = dashPhase;
  20709. },
  20710. constructPath: function SVGGraphics_constructPath(ops, args) {
  20711. var current = this.current;
  20712. var x = current.x, y = current.y;
  20713. current.path = document.createElementNS(NS, 'svg:path');
  20714. var d = [];
  20715. var opLength = ops.length;
  20716. for (var i = 0, j = 0; i < opLength; i++) {
  20717. switch (ops[i] | 0) {
  20718. case OPS.rectangle:
  20719. x = args[j++];
  20720. y = args[j++];
  20721. var width = args[j++];
  20722. var height = args[j++];
  20723. var xw = x + width;
  20724. var yh = y + height;
  20725. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  20726. break;
  20727. case OPS.moveTo:
  20728. x = args[j++];
  20729. y = args[j++];
  20730. d.push('M', pf(x), pf(y));
  20731. break;
  20732. case OPS.lineTo:
  20733. x = args[j++];
  20734. y = args[j++];
  20735. d.push('L', pf(x), pf(y));
  20736. break;
  20737. case OPS.curveTo:
  20738. x = args[j + 4];
  20739. y = args[j + 5];
  20740. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  20741. j += 6;
  20742. break;
  20743. case OPS.curveTo2:
  20744. x = args[j + 2];
  20745. y = args[j + 3];
  20746. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  20747. j += 4;
  20748. break;
  20749. case OPS.curveTo3:
  20750. x = args[j + 2];
  20751. y = args[j + 3];
  20752. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  20753. j += 4;
  20754. break;
  20755. case OPS.closePath:
  20756. d.push('Z');
  20757. break;
  20758. }
  20759. }
  20760. current.path.setAttributeNS(null, 'd', d.join(' '));
  20761. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  20762. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  20763. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  20764. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  20765. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  20766. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  20767. current.path.setAttributeNS(null, 'fill', 'none');
  20768. this._ensureTransformGroup().appendChild(current.path);
  20769. current.element = current.path;
  20770. current.setCurrentPoint(x, y);
  20771. },
  20772. endPath: function SVGGraphics_endPath() {
  20773. },
  20774. clip: function SVGGraphics_clip(type) {
  20775. var current = this.current;
  20776. var clipId = 'clippath' + clipCount;
  20777. clipCount++;
  20778. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  20779. clipPath.setAttributeNS(null, 'id', clipId);
  20780. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20781. var clipElement = current.element.cloneNode();
  20782. if (type === 'evenodd') {
  20783. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  20784. } else {
  20785. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  20786. }
  20787. clipPath.appendChild(clipElement);
  20788. this.defs.appendChild(clipPath);
  20789. if (current.activeClipUrl) {
  20790. current.clipGroup = null;
  20791. this.extraStack.forEach(function (prev) {
  20792. prev.clipGroup = null;
  20793. });
  20794. }
  20795. current.activeClipUrl = 'url(#' + clipId + ')';
  20796. this.tgrp = null;
  20797. },
  20798. closePath: function SVGGraphics_closePath() {
  20799. var current = this.current;
  20800. var d = current.path.getAttributeNS(null, 'd');
  20801. d += 'Z';
  20802. current.path.setAttributeNS(null, 'd', d);
  20803. },
  20804. setLeading: function SVGGraphics_setLeading(leading) {
  20805. this.current.leading = -leading;
  20806. },
  20807. setTextRise: function SVGGraphics_setTextRise(textRise) {
  20808. this.current.textRise = textRise;
  20809. },
  20810. setHScale: function SVGGraphics_setHScale(scale) {
  20811. this.current.textHScale = scale / 100;
  20812. },
  20813. setGState: function SVGGraphics_setGState(states) {
  20814. for (var i = 0, ii = states.length; i < ii; i++) {
  20815. var state = states[i];
  20816. var key = state[0];
  20817. var value = state[1];
  20818. switch (key) {
  20819. case 'LW':
  20820. this.setLineWidth(value);
  20821. break;
  20822. case 'LC':
  20823. this.setLineCap(value);
  20824. break;
  20825. case 'LJ':
  20826. this.setLineJoin(value);
  20827. break;
  20828. case 'ML':
  20829. this.setMiterLimit(value);
  20830. break;
  20831. case 'D':
  20832. this.setDash(value[0], value[1]);
  20833. break;
  20834. case 'Font':
  20835. this.setFont(value);
  20836. break;
  20837. default:
  20838. warn('Unimplemented graphic state ' + key);
  20839. break;
  20840. }
  20841. }
  20842. },
  20843. fill: function SVGGraphics_fill() {
  20844. var current = this.current;
  20845. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20846. },
  20847. stroke: function SVGGraphics_stroke() {
  20848. var current = this.current;
  20849. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  20850. current.element.setAttributeNS(null, 'fill', 'none');
  20851. },
  20852. eoFill: function SVGGraphics_eoFill() {
  20853. var current = this.current;
  20854. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20855. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20856. },
  20857. fillStroke: function SVGGraphics_fillStroke() {
  20858. this.stroke();
  20859. this.fill();
  20860. },
  20861. eoFillStroke: function SVGGraphics_eoFillStroke() {
  20862. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20863. this.fillStroke();
  20864. },
  20865. closeStroke: function SVGGraphics_closeStroke() {
  20866. this.closePath();
  20867. this.stroke();
  20868. },
  20869. closeFillStroke: function SVGGraphics_closeFillStroke() {
  20870. this.closePath();
  20871. this.fillStroke();
  20872. },
  20873. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  20874. var current = this.current;
  20875. var rect = document.createElementNS(NS, 'svg:rect');
  20876. rect.setAttributeNS(null, 'x', '0');
  20877. rect.setAttributeNS(null, 'y', '0');
  20878. rect.setAttributeNS(null, 'width', '1px');
  20879. rect.setAttributeNS(null, 'height', '1px');
  20880. rect.setAttributeNS(null, 'fill', current.fillColor);
  20881. this._ensureTransformGroup().appendChild(rect);
  20882. },
  20883. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  20884. var imgObj = this.objs.get(objId);
  20885. var imgEl = document.createElementNS(NS, 'svg:image');
  20886. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  20887. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  20888. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  20889. imgEl.setAttributeNS(null, 'x', '0');
  20890. imgEl.setAttributeNS(null, 'y', pf(-h));
  20891. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  20892. this._ensureTransformGroup().appendChild(imgEl);
  20893. },
  20894. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  20895. var imgData = this.objs.get(objId);
  20896. if (!imgData) {
  20897. warn('Dependent image isn\'t ready yet');
  20898. return;
  20899. }
  20900. this.paintInlineImageXObject(imgData);
  20901. },
  20902. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  20903. var width = imgData.width;
  20904. var height = imgData.height;
  20905. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  20906. var cliprect = document.createElementNS(NS, 'svg:rect');
  20907. cliprect.setAttributeNS(null, 'x', '0');
  20908. cliprect.setAttributeNS(null, 'y', '0');
  20909. cliprect.setAttributeNS(null, 'width', pf(width));
  20910. cliprect.setAttributeNS(null, 'height', pf(height));
  20911. this.current.element = cliprect;
  20912. this.clip('nonzero');
  20913. var imgEl = document.createElementNS(NS, 'svg:image');
  20914. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  20915. imgEl.setAttributeNS(null, 'x', '0');
  20916. imgEl.setAttributeNS(null, 'y', pf(-height));
  20917. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  20918. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  20919. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  20920. if (mask) {
  20921. mask.appendChild(imgEl);
  20922. } else {
  20923. this._ensureTransformGroup().appendChild(imgEl);
  20924. }
  20925. },
  20926. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  20927. var current = this.current;
  20928. var width = imgData.width;
  20929. var height = imgData.height;
  20930. var fillColor = current.fillColor;
  20931. current.maskId = 'mask' + maskCount++;
  20932. var mask = document.createElementNS(NS, 'svg:mask');
  20933. mask.setAttributeNS(null, 'id', current.maskId);
  20934. var rect = document.createElementNS(NS, 'svg:rect');
  20935. rect.setAttributeNS(null, 'x', '0');
  20936. rect.setAttributeNS(null, 'y', '0');
  20937. rect.setAttributeNS(null, 'width', pf(width));
  20938. rect.setAttributeNS(null, 'height', pf(height));
  20939. rect.setAttributeNS(null, 'fill', fillColor);
  20940. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  20941. this.defs.appendChild(mask);
  20942. this._ensureTransformGroup().appendChild(rect);
  20943. this.paintInlineImageXObject(imgData, mask);
  20944. },
  20945. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  20946. if (isArray(matrix) && matrix.length === 6) {
  20947. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  20948. }
  20949. if (isArray(bbox) && bbox.length === 4) {
  20950. var width = bbox[2] - bbox[0];
  20951. var height = bbox[3] - bbox[1];
  20952. var cliprect = document.createElementNS(NS, 'svg:rect');
  20953. cliprect.setAttributeNS(null, 'x', bbox[0]);
  20954. cliprect.setAttributeNS(null, 'y', bbox[1]);
  20955. cliprect.setAttributeNS(null, 'width', pf(width));
  20956. cliprect.setAttributeNS(null, 'height', pf(height));
  20957. this.current.element = cliprect;
  20958. this.clip('nonzero');
  20959. this.endPath();
  20960. }
  20961. },
  20962. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  20963. },
  20964. _initialize: function SVGGraphics_initialize(viewport) {
  20965. var svg = document.createElementNS(NS, 'svg:svg');
  20966. svg.setAttributeNS(null, 'version', '1.1');
  20967. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  20968. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  20969. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  20970. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  20971. var definitions = document.createElementNS(NS, 'svg:defs');
  20972. svg.appendChild(definitions);
  20973. this.defs = definitions;
  20974. var rootGroup = document.createElementNS(NS, 'svg:g');
  20975. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  20976. svg.appendChild(rootGroup);
  20977. this.svg = rootGroup;
  20978. return svg;
  20979. },
  20980. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  20981. if (!this.current.clipGroup) {
  20982. var clipGroup = document.createElementNS(NS, 'svg:g');
  20983. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  20984. this.svg.appendChild(clipGroup);
  20985. this.current.clipGroup = clipGroup;
  20986. }
  20987. return this.current.clipGroup;
  20988. },
  20989. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  20990. if (!this.tgrp) {
  20991. this.tgrp = document.createElementNS(NS, 'svg:g');
  20992. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20993. if (this.current.activeClipUrl) {
  20994. this._ensureClipGroup().appendChild(this.tgrp);
  20995. } else {
  20996. this.svg.appendChild(this.tgrp);
  20997. }
  20998. }
  20999. return this.tgrp;
  21000. }
  21001. };
  21002. return SVGGraphics;
  21003. }();
  21004. exports.SVGGraphics = SVGGraphics;
  21005. /***/ }),
  21006. /* 12 */
  21007. /***/ (function(module, exports, __w_pdfjs_require__) {
  21008. "use strict";
  21009. var sharedUtil = __w_pdfjs_require__(0);
  21010. var displayDOMUtils = __w_pdfjs_require__(3);
  21011. var Util = sharedUtil.Util;
  21012. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21013. var CustomStyle = displayDOMUtils.CustomStyle;
  21014. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21015. var renderTextLayer = function renderTextLayerClosure() {
  21016. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21017. var NonWhitespaceRegexp = /\S/;
  21018. function isAllWhitespace(str) {
  21019. return !NonWhitespaceRegexp.test(str);
  21020. }
  21021. var styleBuf = [
  21022. 'left: ',
  21023. 0,
  21024. 'px; top: ',
  21025. 0,
  21026. 'px; font-size: ',
  21027. 0,
  21028. 'px; font-family: ',
  21029. '',
  21030. ';'
  21031. ];
  21032. function appendText(task, geom, styles) {
  21033. var textDiv = document.createElement('div');
  21034. var textDivProperties = {
  21035. style: null,
  21036. angle: 0,
  21037. canvasWidth: 0,
  21038. isWhitespace: false,
  21039. originalTransform: null,
  21040. paddingBottom: 0,
  21041. paddingLeft: 0,
  21042. paddingRight: 0,
  21043. paddingTop: 0,
  21044. scale: 1
  21045. };
  21046. task._textDivs.push(textDiv);
  21047. if (isAllWhitespace(geom.str)) {
  21048. textDivProperties.isWhitespace = true;
  21049. task._textDivProperties.set(textDiv, textDivProperties);
  21050. return;
  21051. }
  21052. var tx = Util.transform(task._viewport.transform, geom.transform);
  21053. var angle = Math.atan2(tx[1], tx[0]);
  21054. var style = styles[geom.fontName];
  21055. if (style.vertical) {
  21056. angle += Math.PI / 2;
  21057. }
  21058. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21059. var fontAscent = fontHeight;
  21060. if (style.ascent) {
  21061. fontAscent = style.ascent * fontAscent;
  21062. } else if (style.descent) {
  21063. fontAscent = (1 + style.descent) * fontAscent;
  21064. }
  21065. var left;
  21066. var top;
  21067. if (angle === 0) {
  21068. left = tx[4];
  21069. top = tx[5] - fontAscent;
  21070. } else {
  21071. left = tx[4] + fontAscent * Math.sin(angle);
  21072. top = tx[5] - fontAscent * Math.cos(angle);
  21073. }
  21074. styleBuf[1] = left;
  21075. styleBuf[3] = top;
  21076. styleBuf[5] = fontHeight;
  21077. styleBuf[7] = style.fontFamily;
  21078. textDivProperties.style = styleBuf.join('');
  21079. textDiv.setAttribute('style', textDivProperties.style);
  21080. textDiv.textContent = geom.str;
  21081. if (getDefaultSetting('pdfBug')) {
  21082. textDiv.dataset.fontName = geom.fontName;
  21083. }
  21084. if (angle !== 0) {
  21085. textDivProperties.angle = angle * (180 / Math.PI);
  21086. }
  21087. if (geom.str.length > 1) {
  21088. if (style.vertical) {
  21089. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21090. } else {
  21091. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21092. }
  21093. }
  21094. task._textDivProperties.set(textDiv, textDivProperties);
  21095. if (task._enhanceTextSelection) {
  21096. var angleCos = 1, angleSin = 0;
  21097. if (angle !== 0) {
  21098. angleCos = Math.cos(angle);
  21099. angleSin = Math.sin(angle);
  21100. }
  21101. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21102. var divHeight = fontHeight;
  21103. var m, b;
  21104. if (angle !== 0) {
  21105. m = [
  21106. angleCos,
  21107. angleSin,
  21108. -angleSin,
  21109. angleCos,
  21110. left,
  21111. top
  21112. ];
  21113. b = Util.getAxialAlignedBoundingBox([
  21114. 0,
  21115. 0,
  21116. divWidth,
  21117. divHeight
  21118. ], m);
  21119. } else {
  21120. b = [
  21121. left,
  21122. top,
  21123. left + divWidth,
  21124. top + divHeight
  21125. ];
  21126. }
  21127. task._bounds.push({
  21128. left: b[0],
  21129. top: b[1],
  21130. right: b[2],
  21131. bottom: b[3],
  21132. div: textDiv,
  21133. size: [
  21134. divWidth,
  21135. divHeight
  21136. ],
  21137. m: m
  21138. });
  21139. }
  21140. }
  21141. function render(task) {
  21142. if (task._canceled) {
  21143. return;
  21144. }
  21145. var textLayerFrag = task._container;
  21146. var textDivs = task._textDivs;
  21147. var capability = task._capability;
  21148. var textDivsLength = textDivs.length;
  21149. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21150. task._renderingDone = true;
  21151. capability.resolve();
  21152. return;
  21153. }
  21154. var canvas = document.createElement('canvas');
  21155. var ctx = canvas.getContext('2d', { alpha: false });
  21156. var lastFontSize;
  21157. var lastFontFamily;
  21158. for (var i = 0; i < textDivsLength; i++) {
  21159. var textDiv = textDivs[i];
  21160. var textDivProperties = task._textDivProperties.get(textDiv);
  21161. if (textDivProperties.isWhitespace) {
  21162. continue;
  21163. }
  21164. var fontSize = textDiv.style.fontSize;
  21165. var fontFamily = textDiv.style.fontFamily;
  21166. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21167. ctx.font = fontSize + ' ' + fontFamily;
  21168. lastFontSize = fontSize;
  21169. lastFontFamily = fontFamily;
  21170. }
  21171. var width = ctx.measureText(textDiv.textContent).width;
  21172. textLayerFrag.appendChild(textDiv);
  21173. var transform = '';
  21174. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21175. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21176. transform = 'scaleX(' + textDivProperties.scale + ')';
  21177. }
  21178. if (textDivProperties.angle !== 0) {
  21179. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21180. }
  21181. if (transform !== '') {
  21182. textDivProperties.originalTransform = transform;
  21183. CustomStyle.setProp('transform', textDiv, transform);
  21184. }
  21185. task._textDivProperties.set(textDiv, textDivProperties);
  21186. }
  21187. task._renderingDone = true;
  21188. capability.resolve();
  21189. }
  21190. function expand(task) {
  21191. var bounds = task._bounds;
  21192. var viewport = task._viewport;
  21193. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21194. for (var i = 0; i < expanded.length; i++) {
  21195. var div = bounds[i].div;
  21196. var divProperties = task._textDivProperties.get(div);
  21197. if (divProperties.angle === 0) {
  21198. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21199. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21200. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21201. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21202. task._textDivProperties.set(div, divProperties);
  21203. continue;
  21204. }
  21205. var e = expanded[i], b = bounds[i];
  21206. var m = b.m, c = m[0], s = m[1];
  21207. var points = [
  21208. [
  21209. 0,
  21210. 0
  21211. ],
  21212. [
  21213. 0,
  21214. b.size[1]
  21215. ],
  21216. [
  21217. b.size[0],
  21218. 0
  21219. ],
  21220. b.size
  21221. ];
  21222. var ts = new Float64Array(64);
  21223. points.forEach(function (p, i) {
  21224. var t = Util.applyTransform(p, m);
  21225. ts[i + 0] = c && (e.left - t[0]) / c;
  21226. ts[i + 4] = s && (e.top - t[1]) / s;
  21227. ts[i + 8] = c && (e.right - t[0]) / c;
  21228. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21229. ts[i + 16] = s && (e.left - t[0]) / -s;
  21230. ts[i + 20] = c && (e.top - t[1]) / c;
  21231. ts[i + 24] = s && (e.right - t[0]) / -s;
  21232. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21233. ts[i + 32] = c && (e.left - t[0]) / -c;
  21234. ts[i + 36] = s && (e.top - t[1]) / -s;
  21235. ts[i + 40] = c && (e.right - t[0]) / -c;
  21236. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21237. ts[i + 48] = s && (e.left - t[0]) / s;
  21238. ts[i + 52] = c && (e.top - t[1]) / -c;
  21239. ts[i + 56] = s && (e.right - t[0]) / s;
  21240. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21241. });
  21242. var findPositiveMin = function (ts, offset, count) {
  21243. var result = 0;
  21244. for (var i = 0; i < count; i++) {
  21245. var t = ts[offset++];
  21246. if (t > 0) {
  21247. result = result ? Math.min(t, result) : t;
  21248. }
  21249. }
  21250. return result;
  21251. };
  21252. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21253. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21254. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21255. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21256. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21257. task._textDivProperties.set(div, divProperties);
  21258. }
  21259. }
  21260. function expandBounds(width, height, boxes) {
  21261. var bounds = boxes.map(function (box, i) {
  21262. return {
  21263. x1: box.left,
  21264. y1: box.top,
  21265. x2: box.right,
  21266. y2: box.bottom,
  21267. index: i,
  21268. x1New: undefined,
  21269. x2New: undefined
  21270. };
  21271. });
  21272. expandBoundsLTR(width, bounds);
  21273. var expanded = new Array(boxes.length);
  21274. bounds.forEach(function (b) {
  21275. var i = b.index;
  21276. expanded[i] = {
  21277. left: b.x1New,
  21278. top: 0,
  21279. right: b.x2New,
  21280. bottom: 0
  21281. };
  21282. });
  21283. boxes.map(function (box, i) {
  21284. var e = expanded[i], b = bounds[i];
  21285. b.x1 = box.top;
  21286. b.y1 = width - e.right;
  21287. b.x2 = box.bottom;
  21288. b.y2 = width - e.left;
  21289. b.index = i;
  21290. b.x1New = undefined;
  21291. b.x2New = undefined;
  21292. });
  21293. expandBoundsLTR(height, bounds);
  21294. bounds.forEach(function (b) {
  21295. var i = b.index;
  21296. expanded[i].top = b.x1New;
  21297. expanded[i].bottom = b.x2New;
  21298. });
  21299. return expanded;
  21300. }
  21301. function expandBoundsLTR(width, bounds) {
  21302. bounds.sort(function (a, b) {
  21303. return a.x1 - b.x1 || a.index - b.index;
  21304. });
  21305. var fakeBoundary = {
  21306. x1: -Infinity,
  21307. y1: -Infinity,
  21308. x2: 0,
  21309. y2: Infinity,
  21310. index: -1,
  21311. x1New: 0,
  21312. x2New: 0
  21313. };
  21314. var horizon = [{
  21315. start: -Infinity,
  21316. end: Infinity,
  21317. boundary: fakeBoundary
  21318. }];
  21319. bounds.forEach(function (boundary) {
  21320. var i = 0;
  21321. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  21322. i++;
  21323. }
  21324. var j = horizon.length - 1;
  21325. while (j >= 0 && horizon[j].start >= boundary.y2) {
  21326. j--;
  21327. }
  21328. var horizonPart, affectedBoundary;
  21329. var q, k, maxXNew = -Infinity;
  21330. for (q = i; q <= j; q++) {
  21331. horizonPart = horizon[q];
  21332. affectedBoundary = horizonPart.boundary;
  21333. var xNew;
  21334. if (affectedBoundary.x2 > boundary.x1) {
  21335. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  21336. } else if (affectedBoundary.x2New === undefined) {
  21337. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  21338. } else {
  21339. xNew = affectedBoundary.x2New;
  21340. }
  21341. if (xNew > maxXNew) {
  21342. maxXNew = xNew;
  21343. }
  21344. }
  21345. boundary.x1New = maxXNew;
  21346. for (q = i; q <= j; q++) {
  21347. horizonPart = horizon[q];
  21348. affectedBoundary = horizonPart.boundary;
  21349. if (affectedBoundary.x2New === undefined) {
  21350. if (affectedBoundary.x2 > boundary.x1) {
  21351. if (affectedBoundary.index > boundary.index) {
  21352. affectedBoundary.x2New = affectedBoundary.x2;
  21353. }
  21354. } else {
  21355. affectedBoundary.x2New = maxXNew;
  21356. }
  21357. } else if (affectedBoundary.x2New > maxXNew) {
  21358. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  21359. }
  21360. }
  21361. var changedHorizon = [], lastBoundary = null;
  21362. for (q = i; q <= j; q++) {
  21363. horizonPart = horizon[q];
  21364. affectedBoundary = horizonPart.boundary;
  21365. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  21366. if (lastBoundary === useBoundary) {
  21367. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  21368. } else {
  21369. changedHorizon.push({
  21370. start: horizonPart.start,
  21371. end: horizonPart.end,
  21372. boundary: useBoundary
  21373. });
  21374. lastBoundary = useBoundary;
  21375. }
  21376. }
  21377. if (horizon[i].start < boundary.y1) {
  21378. changedHorizon[0].start = boundary.y1;
  21379. changedHorizon.unshift({
  21380. start: horizon[i].start,
  21381. end: boundary.y1,
  21382. boundary: horizon[i].boundary
  21383. });
  21384. }
  21385. if (boundary.y2 < horizon[j].end) {
  21386. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  21387. changedHorizon.push({
  21388. start: boundary.y2,
  21389. end: horizon[j].end,
  21390. boundary: horizon[j].boundary
  21391. });
  21392. }
  21393. for (q = i; q <= j; q++) {
  21394. horizonPart = horizon[q];
  21395. affectedBoundary = horizonPart.boundary;
  21396. if (affectedBoundary.x2New !== undefined) {
  21397. continue;
  21398. }
  21399. var used = false;
  21400. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  21401. used = horizon[k].boundary === affectedBoundary;
  21402. }
  21403. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  21404. used = horizon[k].boundary === affectedBoundary;
  21405. }
  21406. for (k = 0; !used && k < changedHorizon.length; k++) {
  21407. used = changedHorizon[k].boundary === affectedBoundary;
  21408. }
  21409. if (!used) {
  21410. affectedBoundary.x2New = maxXNew;
  21411. }
  21412. }
  21413. Array.prototype.splice.apply(horizon, [
  21414. i,
  21415. j - i + 1
  21416. ].concat(changedHorizon));
  21417. });
  21418. horizon.forEach(function (horizonPart) {
  21419. var affectedBoundary = horizonPart.boundary;
  21420. if (affectedBoundary.x2New === undefined) {
  21421. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  21422. }
  21423. });
  21424. }
  21425. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  21426. this._textContent = textContent;
  21427. this._container = container;
  21428. this._viewport = viewport;
  21429. this._textDivs = textDivs || [];
  21430. this._textDivProperties = new WeakMap();
  21431. this._renderingDone = false;
  21432. this._canceled = false;
  21433. this._capability = createPromiseCapability();
  21434. this._renderTimer = null;
  21435. this._bounds = [];
  21436. this._enhanceTextSelection = !!enhanceTextSelection;
  21437. }
  21438. TextLayerRenderTask.prototype = {
  21439. get promise() {
  21440. return this._capability.promise;
  21441. },
  21442. cancel: function TextLayer_cancel() {
  21443. this._canceled = true;
  21444. if (this._renderTimer !== null) {
  21445. clearTimeout(this._renderTimer);
  21446. this._renderTimer = null;
  21447. }
  21448. this._capability.reject('canceled');
  21449. },
  21450. _render: function TextLayer_render(timeout) {
  21451. var textItems = this._textContent.items;
  21452. var textStyles = this._textContent.styles;
  21453. for (var i = 0, len = textItems.length; i < len; i++) {
  21454. appendText(this, textItems[i], textStyles);
  21455. }
  21456. if (!timeout) {
  21457. render(this);
  21458. } else {
  21459. var self = this;
  21460. this._renderTimer = setTimeout(function () {
  21461. render(self);
  21462. self._renderTimer = null;
  21463. }, timeout);
  21464. }
  21465. },
  21466. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  21467. if (!this._enhanceTextSelection || !this._renderingDone) {
  21468. return;
  21469. }
  21470. if (this._bounds !== null) {
  21471. expand(this);
  21472. this._bounds = null;
  21473. }
  21474. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  21475. var div = this._textDivs[i];
  21476. var divProperties = this._textDivProperties.get(div);
  21477. if (divProperties.isWhitespace) {
  21478. continue;
  21479. }
  21480. if (expandDivs) {
  21481. var transform = '', padding = '';
  21482. if (divProperties.scale !== 1) {
  21483. transform = 'scaleX(' + divProperties.scale + ')';
  21484. }
  21485. if (divProperties.angle !== 0) {
  21486. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  21487. }
  21488. if (divProperties.paddingLeft !== 0) {
  21489. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  21490. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  21491. }
  21492. if (divProperties.paddingTop !== 0) {
  21493. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  21494. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  21495. }
  21496. if (divProperties.paddingRight !== 0) {
  21497. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  21498. }
  21499. if (divProperties.paddingBottom !== 0) {
  21500. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  21501. }
  21502. if (padding !== '') {
  21503. div.setAttribute('style', divProperties.style + padding);
  21504. }
  21505. if (transform !== '') {
  21506. CustomStyle.setProp('transform', div, transform);
  21507. }
  21508. } else {
  21509. div.style.padding = 0;
  21510. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  21511. }
  21512. }
  21513. }
  21514. };
  21515. function renderTextLayer(renderParameters) {
  21516. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  21517. task._render(renderParameters.timeout);
  21518. return task;
  21519. }
  21520. return renderTextLayer;
  21521. }();
  21522. exports.renderTextLayer = renderTextLayer;
  21523. /***/ }),
  21524. /* 13 */
  21525. /***/ (function(module, exports) {
  21526. var g;
  21527. g = function () {
  21528. return this;
  21529. }();
  21530. try {
  21531. g = g || Function("return this")() || (1, eval)("this");
  21532. } catch (e) {
  21533. if (typeof window === "object")
  21534. g = window;
  21535. }
  21536. module.exports = g;
  21537. /***/ }),
  21538. /* 14 */
  21539. /***/ (function(module, exports, __w_pdfjs_require__) {
  21540. "use strict";
  21541. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  21542. var QeTable = [
  21543. {
  21544. qe: 0x5601,
  21545. nmps: 1,
  21546. nlps: 1,
  21547. switchFlag: 1
  21548. },
  21549. {
  21550. qe: 0x3401,
  21551. nmps: 2,
  21552. nlps: 6,
  21553. switchFlag: 0
  21554. },
  21555. {
  21556. qe: 0x1801,
  21557. nmps: 3,
  21558. nlps: 9,
  21559. switchFlag: 0
  21560. },
  21561. {
  21562. qe: 0x0AC1,
  21563. nmps: 4,
  21564. nlps: 12,
  21565. switchFlag: 0
  21566. },
  21567. {
  21568. qe: 0x0521,
  21569. nmps: 5,
  21570. nlps: 29,
  21571. switchFlag: 0
  21572. },
  21573. {
  21574. qe: 0x0221,
  21575. nmps: 38,
  21576. nlps: 33,
  21577. switchFlag: 0
  21578. },
  21579. {
  21580. qe: 0x5601,
  21581. nmps: 7,
  21582. nlps: 6,
  21583. switchFlag: 1
  21584. },
  21585. {
  21586. qe: 0x5401,
  21587. nmps: 8,
  21588. nlps: 14,
  21589. switchFlag: 0
  21590. },
  21591. {
  21592. qe: 0x4801,
  21593. nmps: 9,
  21594. nlps: 14,
  21595. switchFlag: 0
  21596. },
  21597. {
  21598. qe: 0x3801,
  21599. nmps: 10,
  21600. nlps: 14,
  21601. switchFlag: 0
  21602. },
  21603. {
  21604. qe: 0x3001,
  21605. nmps: 11,
  21606. nlps: 17,
  21607. switchFlag: 0
  21608. },
  21609. {
  21610. qe: 0x2401,
  21611. nmps: 12,
  21612. nlps: 18,
  21613. switchFlag: 0
  21614. },
  21615. {
  21616. qe: 0x1C01,
  21617. nmps: 13,
  21618. nlps: 20,
  21619. switchFlag: 0
  21620. },
  21621. {
  21622. qe: 0x1601,
  21623. nmps: 29,
  21624. nlps: 21,
  21625. switchFlag: 0
  21626. },
  21627. {
  21628. qe: 0x5601,
  21629. nmps: 15,
  21630. nlps: 14,
  21631. switchFlag: 1
  21632. },
  21633. {
  21634. qe: 0x5401,
  21635. nmps: 16,
  21636. nlps: 14,
  21637. switchFlag: 0
  21638. },
  21639. {
  21640. qe: 0x5101,
  21641. nmps: 17,
  21642. nlps: 15,
  21643. switchFlag: 0
  21644. },
  21645. {
  21646. qe: 0x4801,
  21647. nmps: 18,
  21648. nlps: 16,
  21649. switchFlag: 0
  21650. },
  21651. {
  21652. qe: 0x3801,
  21653. nmps: 19,
  21654. nlps: 17,
  21655. switchFlag: 0
  21656. },
  21657. {
  21658. qe: 0x3401,
  21659. nmps: 20,
  21660. nlps: 18,
  21661. switchFlag: 0
  21662. },
  21663. {
  21664. qe: 0x3001,
  21665. nmps: 21,
  21666. nlps: 19,
  21667. switchFlag: 0
  21668. },
  21669. {
  21670. qe: 0x2801,
  21671. nmps: 22,
  21672. nlps: 19,
  21673. switchFlag: 0
  21674. },
  21675. {
  21676. qe: 0x2401,
  21677. nmps: 23,
  21678. nlps: 20,
  21679. switchFlag: 0
  21680. },
  21681. {
  21682. qe: 0x2201,
  21683. nmps: 24,
  21684. nlps: 21,
  21685. switchFlag: 0
  21686. },
  21687. {
  21688. qe: 0x1C01,
  21689. nmps: 25,
  21690. nlps: 22,
  21691. switchFlag: 0
  21692. },
  21693. {
  21694. qe: 0x1801,
  21695. nmps: 26,
  21696. nlps: 23,
  21697. switchFlag: 0
  21698. },
  21699. {
  21700. qe: 0x1601,
  21701. nmps: 27,
  21702. nlps: 24,
  21703. switchFlag: 0
  21704. },
  21705. {
  21706. qe: 0x1401,
  21707. nmps: 28,
  21708. nlps: 25,
  21709. switchFlag: 0
  21710. },
  21711. {
  21712. qe: 0x1201,
  21713. nmps: 29,
  21714. nlps: 26,
  21715. switchFlag: 0
  21716. },
  21717. {
  21718. qe: 0x1101,
  21719. nmps: 30,
  21720. nlps: 27,
  21721. switchFlag: 0
  21722. },
  21723. {
  21724. qe: 0x0AC1,
  21725. nmps: 31,
  21726. nlps: 28,
  21727. switchFlag: 0
  21728. },
  21729. {
  21730. qe: 0x09C1,
  21731. nmps: 32,
  21732. nlps: 29,
  21733. switchFlag: 0
  21734. },
  21735. {
  21736. qe: 0x08A1,
  21737. nmps: 33,
  21738. nlps: 30,
  21739. switchFlag: 0
  21740. },
  21741. {
  21742. qe: 0x0521,
  21743. nmps: 34,
  21744. nlps: 31,
  21745. switchFlag: 0
  21746. },
  21747. {
  21748. qe: 0x0441,
  21749. nmps: 35,
  21750. nlps: 32,
  21751. switchFlag: 0
  21752. },
  21753. {
  21754. qe: 0x02A1,
  21755. nmps: 36,
  21756. nlps: 33,
  21757. switchFlag: 0
  21758. },
  21759. {
  21760. qe: 0x0221,
  21761. nmps: 37,
  21762. nlps: 34,
  21763. switchFlag: 0
  21764. },
  21765. {
  21766. qe: 0x0141,
  21767. nmps: 38,
  21768. nlps: 35,
  21769. switchFlag: 0
  21770. },
  21771. {
  21772. qe: 0x0111,
  21773. nmps: 39,
  21774. nlps: 36,
  21775. switchFlag: 0
  21776. },
  21777. {
  21778. qe: 0x0085,
  21779. nmps: 40,
  21780. nlps: 37,
  21781. switchFlag: 0
  21782. },
  21783. {
  21784. qe: 0x0049,
  21785. nmps: 41,
  21786. nlps: 38,
  21787. switchFlag: 0
  21788. },
  21789. {
  21790. qe: 0x0025,
  21791. nmps: 42,
  21792. nlps: 39,
  21793. switchFlag: 0
  21794. },
  21795. {
  21796. qe: 0x0015,
  21797. nmps: 43,
  21798. nlps: 40,
  21799. switchFlag: 0
  21800. },
  21801. {
  21802. qe: 0x0009,
  21803. nmps: 44,
  21804. nlps: 41,
  21805. switchFlag: 0
  21806. },
  21807. {
  21808. qe: 0x0005,
  21809. nmps: 45,
  21810. nlps: 42,
  21811. switchFlag: 0
  21812. },
  21813. {
  21814. qe: 0x0001,
  21815. nmps: 45,
  21816. nlps: 43,
  21817. switchFlag: 0
  21818. },
  21819. {
  21820. qe: 0x5601,
  21821. nmps: 46,
  21822. nlps: 46,
  21823. switchFlag: 0
  21824. }
  21825. ];
  21826. function ArithmeticDecoder(data, start, end) {
  21827. this.data = data;
  21828. this.bp = start;
  21829. this.dataEnd = end;
  21830. this.chigh = data[start];
  21831. this.clow = 0;
  21832. this.byteIn();
  21833. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  21834. this.clow = this.clow << 7 & 0xFFFF;
  21835. this.ct -= 7;
  21836. this.a = 0x8000;
  21837. }
  21838. ArithmeticDecoder.prototype = {
  21839. byteIn: function ArithmeticDecoder_byteIn() {
  21840. var data = this.data;
  21841. var bp = this.bp;
  21842. if (data[bp] === 0xFF) {
  21843. var b1 = data[bp + 1];
  21844. if (b1 > 0x8F) {
  21845. this.clow += 0xFF00;
  21846. this.ct = 8;
  21847. } else {
  21848. bp++;
  21849. this.clow += data[bp] << 9;
  21850. this.ct = 7;
  21851. this.bp = bp;
  21852. }
  21853. } else {
  21854. bp++;
  21855. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  21856. this.ct = 8;
  21857. this.bp = bp;
  21858. }
  21859. if (this.clow > 0xFFFF) {
  21860. this.chigh += this.clow >> 16;
  21861. this.clow &= 0xFFFF;
  21862. }
  21863. },
  21864. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  21865. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  21866. var qeTableIcx = QeTable[cx_index];
  21867. var qeIcx = qeTableIcx.qe;
  21868. var d;
  21869. var a = this.a - qeIcx;
  21870. if (this.chigh < qeIcx) {
  21871. if (a < qeIcx) {
  21872. a = qeIcx;
  21873. d = cx_mps;
  21874. cx_index = qeTableIcx.nmps;
  21875. } else {
  21876. a = qeIcx;
  21877. d = 1 ^ cx_mps;
  21878. if (qeTableIcx.switchFlag === 1) {
  21879. cx_mps = d;
  21880. }
  21881. cx_index = qeTableIcx.nlps;
  21882. }
  21883. } else {
  21884. this.chigh -= qeIcx;
  21885. if ((a & 0x8000) !== 0) {
  21886. this.a = a;
  21887. return cx_mps;
  21888. }
  21889. if (a < qeIcx) {
  21890. d = 1 ^ cx_mps;
  21891. if (qeTableIcx.switchFlag === 1) {
  21892. cx_mps = d;
  21893. }
  21894. cx_index = qeTableIcx.nlps;
  21895. } else {
  21896. d = cx_mps;
  21897. cx_index = qeTableIcx.nmps;
  21898. }
  21899. }
  21900. do {
  21901. if (this.ct === 0) {
  21902. this.byteIn();
  21903. }
  21904. a <<= 1;
  21905. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  21906. this.clow = this.clow << 1 & 0xFFFF;
  21907. this.ct--;
  21908. } while ((a & 0x8000) === 0);
  21909. this.a = a;
  21910. contexts[pos] = cx_index << 1 | cx_mps;
  21911. return d;
  21912. }
  21913. };
  21914. return ArithmeticDecoder;
  21915. }();
  21916. exports.ArithmeticDecoder = ArithmeticDecoder;
  21917. /***/ }),
  21918. /* 15 */
  21919. /***/ (function(module, exports, __w_pdfjs_require__) {
  21920. "use strict";
  21921. var sharedUtil = __w_pdfjs_require__(0);
  21922. var coreCharsets = __w_pdfjs_require__(29);
  21923. var coreEncodings = __w_pdfjs_require__(5);
  21924. var error = sharedUtil.error;
  21925. var info = sharedUtil.info;
  21926. var bytesToString = sharedUtil.bytesToString;
  21927. var warn = sharedUtil.warn;
  21928. var isArray = sharedUtil.isArray;
  21929. var Util = sharedUtil.Util;
  21930. var stringToBytes = sharedUtil.stringToBytes;
  21931. var assert = sharedUtil.assert;
  21932. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  21933. var ExpertCharset = coreCharsets.ExpertCharset;
  21934. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  21935. var StandardEncoding = coreEncodings.StandardEncoding;
  21936. var ExpertEncoding = coreEncodings.ExpertEncoding;
  21937. var MAX_SUBR_NESTING = 10;
  21938. var CFFStandardStrings = [
  21939. '.notdef',
  21940. 'space',
  21941. 'exclam',
  21942. 'quotedbl',
  21943. 'numbersign',
  21944. 'dollar',
  21945. 'percent',
  21946. 'ampersand',
  21947. 'quoteright',
  21948. 'parenleft',
  21949. 'parenright',
  21950. 'asterisk',
  21951. 'plus',
  21952. 'comma',
  21953. 'hyphen',
  21954. 'period',
  21955. 'slash',
  21956. 'zero',
  21957. 'one',
  21958. 'two',
  21959. 'three',
  21960. 'four',
  21961. 'five',
  21962. 'six',
  21963. 'seven',
  21964. 'eight',
  21965. 'nine',
  21966. 'colon',
  21967. 'semicolon',
  21968. 'less',
  21969. 'equal',
  21970. 'greater',
  21971. 'question',
  21972. 'at',
  21973. 'A',
  21974. 'B',
  21975. 'C',
  21976. 'D',
  21977. 'E',
  21978. 'F',
  21979. 'G',
  21980. 'H',
  21981. 'I',
  21982. 'J',
  21983. 'K',
  21984. 'L',
  21985. 'M',
  21986. 'N',
  21987. 'O',
  21988. 'P',
  21989. 'Q',
  21990. 'R',
  21991. 'S',
  21992. 'T',
  21993. 'U',
  21994. 'V',
  21995. 'W',
  21996. 'X',
  21997. 'Y',
  21998. 'Z',
  21999. 'bracketleft',
  22000. 'backslash',
  22001. 'bracketright',
  22002. 'asciicircum',
  22003. 'underscore',
  22004. 'quoteleft',
  22005. 'a',
  22006. 'b',
  22007. 'c',
  22008. 'd',
  22009. 'e',
  22010. 'f',
  22011. 'g',
  22012. 'h',
  22013. 'i',
  22014. 'j',
  22015. 'k',
  22016. 'l',
  22017. 'm',
  22018. 'n',
  22019. 'o',
  22020. 'p',
  22021. 'q',
  22022. 'r',
  22023. 's',
  22024. 't',
  22025. 'u',
  22026. 'v',
  22027. 'w',
  22028. 'x',
  22029. 'y',
  22030. 'z',
  22031. 'braceleft',
  22032. 'bar',
  22033. 'braceright',
  22034. 'asciitilde',
  22035. 'exclamdown',
  22036. 'cent',
  22037. 'sterling',
  22038. 'fraction',
  22039. 'yen',
  22040. 'florin',
  22041. 'section',
  22042. 'currency',
  22043. 'quotesingle',
  22044. 'quotedblleft',
  22045. 'guillemotleft',
  22046. 'guilsinglleft',
  22047. 'guilsinglright',
  22048. 'fi',
  22049. 'fl',
  22050. 'endash',
  22051. 'dagger',
  22052. 'daggerdbl',
  22053. 'periodcentered',
  22054. 'paragraph',
  22055. 'bullet',
  22056. 'quotesinglbase',
  22057. 'quotedblbase',
  22058. 'quotedblright',
  22059. 'guillemotright',
  22060. 'ellipsis',
  22061. 'perthousand',
  22062. 'questiondown',
  22063. 'grave',
  22064. 'acute',
  22065. 'circumflex',
  22066. 'tilde',
  22067. 'macron',
  22068. 'breve',
  22069. 'dotaccent',
  22070. 'dieresis',
  22071. 'ring',
  22072. 'cedilla',
  22073. 'hungarumlaut',
  22074. 'ogonek',
  22075. 'caron',
  22076. 'emdash',
  22077. 'AE',
  22078. 'ordfeminine',
  22079. 'Lslash',
  22080. 'Oslash',
  22081. 'OE',
  22082. 'ordmasculine',
  22083. 'ae',
  22084. 'dotlessi',
  22085. 'lslash',
  22086. 'oslash',
  22087. 'oe',
  22088. 'germandbls',
  22089. 'onesuperior',
  22090. 'logicalnot',
  22091. 'mu',
  22092. 'trademark',
  22093. 'Eth',
  22094. 'onehalf',
  22095. 'plusminus',
  22096. 'Thorn',
  22097. 'onequarter',
  22098. 'divide',
  22099. 'brokenbar',
  22100. 'degree',
  22101. 'thorn',
  22102. 'threequarters',
  22103. 'twosuperior',
  22104. 'registered',
  22105. 'minus',
  22106. 'eth',
  22107. 'multiply',
  22108. 'threesuperior',
  22109. 'copyright',
  22110. 'Aacute',
  22111. 'Acircumflex',
  22112. 'Adieresis',
  22113. 'Agrave',
  22114. 'Aring',
  22115. 'Atilde',
  22116. 'Ccedilla',
  22117. 'Eacute',
  22118. 'Ecircumflex',
  22119. 'Edieresis',
  22120. 'Egrave',
  22121. 'Iacute',
  22122. 'Icircumflex',
  22123. 'Idieresis',
  22124. 'Igrave',
  22125. 'Ntilde',
  22126. 'Oacute',
  22127. 'Ocircumflex',
  22128. 'Odieresis',
  22129. 'Ograve',
  22130. 'Otilde',
  22131. 'Scaron',
  22132. 'Uacute',
  22133. 'Ucircumflex',
  22134. 'Udieresis',
  22135. 'Ugrave',
  22136. 'Yacute',
  22137. 'Ydieresis',
  22138. 'Zcaron',
  22139. 'aacute',
  22140. 'acircumflex',
  22141. 'adieresis',
  22142. 'agrave',
  22143. 'aring',
  22144. 'atilde',
  22145. 'ccedilla',
  22146. 'eacute',
  22147. 'ecircumflex',
  22148. 'edieresis',
  22149. 'egrave',
  22150. 'iacute',
  22151. 'icircumflex',
  22152. 'idieresis',
  22153. 'igrave',
  22154. 'ntilde',
  22155. 'oacute',
  22156. 'ocircumflex',
  22157. 'odieresis',
  22158. 'ograve',
  22159. 'otilde',
  22160. 'scaron',
  22161. 'uacute',
  22162. 'ucircumflex',
  22163. 'udieresis',
  22164. 'ugrave',
  22165. 'yacute',
  22166. 'ydieresis',
  22167. 'zcaron',
  22168. 'exclamsmall',
  22169. 'Hungarumlautsmall',
  22170. 'dollaroldstyle',
  22171. 'dollarsuperior',
  22172. 'ampersandsmall',
  22173. 'Acutesmall',
  22174. 'parenleftsuperior',
  22175. 'parenrightsuperior',
  22176. 'twodotenleader',
  22177. 'onedotenleader',
  22178. 'zerooldstyle',
  22179. 'oneoldstyle',
  22180. 'twooldstyle',
  22181. 'threeoldstyle',
  22182. 'fouroldstyle',
  22183. 'fiveoldstyle',
  22184. 'sixoldstyle',
  22185. 'sevenoldstyle',
  22186. 'eightoldstyle',
  22187. 'nineoldstyle',
  22188. 'commasuperior',
  22189. 'threequartersemdash',
  22190. 'periodsuperior',
  22191. 'questionsmall',
  22192. 'asuperior',
  22193. 'bsuperior',
  22194. 'centsuperior',
  22195. 'dsuperior',
  22196. 'esuperior',
  22197. 'isuperior',
  22198. 'lsuperior',
  22199. 'msuperior',
  22200. 'nsuperior',
  22201. 'osuperior',
  22202. 'rsuperior',
  22203. 'ssuperior',
  22204. 'tsuperior',
  22205. 'ff',
  22206. 'ffi',
  22207. 'ffl',
  22208. 'parenleftinferior',
  22209. 'parenrightinferior',
  22210. 'Circumflexsmall',
  22211. 'hyphensuperior',
  22212. 'Gravesmall',
  22213. 'Asmall',
  22214. 'Bsmall',
  22215. 'Csmall',
  22216. 'Dsmall',
  22217. 'Esmall',
  22218. 'Fsmall',
  22219. 'Gsmall',
  22220. 'Hsmall',
  22221. 'Ismall',
  22222. 'Jsmall',
  22223. 'Ksmall',
  22224. 'Lsmall',
  22225. 'Msmall',
  22226. 'Nsmall',
  22227. 'Osmall',
  22228. 'Psmall',
  22229. 'Qsmall',
  22230. 'Rsmall',
  22231. 'Ssmall',
  22232. 'Tsmall',
  22233. 'Usmall',
  22234. 'Vsmall',
  22235. 'Wsmall',
  22236. 'Xsmall',
  22237. 'Ysmall',
  22238. 'Zsmall',
  22239. 'colonmonetary',
  22240. 'onefitted',
  22241. 'rupiah',
  22242. 'Tildesmall',
  22243. 'exclamdownsmall',
  22244. 'centoldstyle',
  22245. 'Lslashsmall',
  22246. 'Scaronsmall',
  22247. 'Zcaronsmall',
  22248. 'Dieresissmall',
  22249. 'Brevesmall',
  22250. 'Caronsmall',
  22251. 'Dotaccentsmall',
  22252. 'Macronsmall',
  22253. 'figuredash',
  22254. 'hypheninferior',
  22255. 'Ogoneksmall',
  22256. 'Ringsmall',
  22257. 'Cedillasmall',
  22258. 'questiondownsmall',
  22259. 'oneeighth',
  22260. 'threeeighths',
  22261. 'fiveeighths',
  22262. 'seveneighths',
  22263. 'onethird',
  22264. 'twothirds',
  22265. 'zerosuperior',
  22266. 'foursuperior',
  22267. 'fivesuperior',
  22268. 'sixsuperior',
  22269. 'sevensuperior',
  22270. 'eightsuperior',
  22271. 'ninesuperior',
  22272. 'zeroinferior',
  22273. 'oneinferior',
  22274. 'twoinferior',
  22275. 'threeinferior',
  22276. 'fourinferior',
  22277. 'fiveinferior',
  22278. 'sixinferior',
  22279. 'seveninferior',
  22280. 'eightinferior',
  22281. 'nineinferior',
  22282. 'centinferior',
  22283. 'dollarinferior',
  22284. 'periodinferior',
  22285. 'commainferior',
  22286. 'Agravesmall',
  22287. 'Aacutesmall',
  22288. 'Acircumflexsmall',
  22289. 'Atildesmall',
  22290. 'Adieresissmall',
  22291. 'Aringsmall',
  22292. 'AEsmall',
  22293. 'Ccedillasmall',
  22294. 'Egravesmall',
  22295. 'Eacutesmall',
  22296. 'Ecircumflexsmall',
  22297. 'Edieresissmall',
  22298. 'Igravesmall',
  22299. 'Iacutesmall',
  22300. 'Icircumflexsmall',
  22301. 'Idieresissmall',
  22302. 'Ethsmall',
  22303. 'Ntildesmall',
  22304. 'Ogravesmall',
  22305. 'Oacutesmall',
  22306. 'Ocircumflexsmall',
  22307. 'Otildesmall',
  22308. 'Odieresissmall',
  22309. 'OEsmall',
  22310. 'Oslashsmall',
  22311. 'Ugravesmall',
  22312. 'Uacutesmall',
  22313. 'Ucircumflexsmall',
  22314. 'Udieresissmall',
  22315. 'Yacutesmall',
  22316. 'Thornsmall',
  22317. 'Ydieresissmall',
  22318. '001.000',
  22319. '001.001',
  22320. '001.002',
  22321. '001.003',
  22322. 'Black',
  22323. 'Bold',
  22324. 'Book',
  22325. 'Light',
  22326. 'Medium',
  22327. 'Regular',
  22328. 'Roman',
  22329. 'Semibold'
  22330. ];
  22331. var CFFParser = function CFFParserClosure() {
  22332. var CharstringValidationData = [
  22333. null,
  22334. {
  22335. id: 'hstem',
  22336. min: 2,
  22337. stackClearing: true,
  22338. stem: true
  22339. },
  22340. null,
  22341. {
  22342. id: 'vstem',
  22343. min: 2,
  22344. stackClearing: true,
  22345. stem: true
  22346. },
  22347. {
  22348. id: 'vmoveto',
  22349. min: 1,
  22350. stackClearing: true
  22351. },
  22352. {
  22353. id: 'rlineto',
  22354. min: 2,
  22355. resetStack: true
  22356. },
  22357. {
  22358. id: 'hlineto',
  22359. min: 1,
  22360. resetStack: true
  22361. },
  22362. {
  22363. id: 'vlineto',
  22364. min: 1,
  22365. resetStack: true
  22366. },
  22367. {
  22368. id: 'rrcurveto',
  22369. min: 6,
  22370. resetStack: true
  22371. },
  22372. null,
  22373. {
  22374. id: 'callsubr',
  22375. min: 1,
  22376. undefStack: true
  22377. },
  22378. {
  22379. id: 'return',
  22380. min: 0,
  22381. undefStack: true
  22382. },
  22383. null,
  22384. null,
  22385. {
  22386. id: 'endchar',
  22387. min: 0,
  22388. stackClearing: true
  22389. },
  22390. null,
  22391. null,
  22392. null,
  22393. {
  22394. id: 'hstemhm',
  22395. min: 2,
  22396. stackClearing: true,
  22397. stem: true
  22398. },
  22399. {
  22400. id: 'hintmask',
  22401. min: 0,
  22402. stackClearing: true
  22403. },
  22404. {
  22405. id: 'cntrmask',
  22406. min: 0,
  22407. stackClearing: true
  22408. },
  22409. {
  22410. id: 'rmoveto',
  22411. min: 2,
  22412. stackClearing: true
  22413. },
  22414. {
  22415. id: 'hmoveto',
  22416. min: 1,
  22417. stackClearing: true
  22418. },
  22419. {
  22420. id: 'vstemhm',
  22421. min: 2,
  22422. stackClearing: true,
  22423. stem: true
  22424. },
  22425. {
  22426. id: 'rcurveline',
  22427. min: 8,
  22428. resetStack: true
  22429. },
  22430. {
  22431. id: 'rlinecurve',
  22432. min: 8,
  22433. resetStack: true
  22434. },
  22435. {
  22436. id: 'vvcurveto',
  22437. min: 4,
  22438. resetStack: true
  22439. },
  22440. {
  22441. id: 'hhcurveto',
  22442. min: 4,
  22443. resetStack: true
  22444. },
  22445. null,
  22446. {
  22447. id: 'callgsubr',
  22448. min: 1,
  22449. undefStack: true
  22450. },
  22451. {
  22452. id: 'vhcurveto',
  22453. min: 4,
  22454. resetStack: true
  22455. },
  22456. {
  22457. id: 'hvcurveto',
  22458. min: 4,
  22459. resetStack: true
  22460. }
  22461. ];
  22462. var CharstringValidationData12 = [
  22463. null,
  22464. null,
  22465. null,
  22466. {
  22467. id: 'and',
  22468. min: 2,
  22469. stackDelta: -1
  22470. },
  22471. {
  22472. id: 'or',
  22473. min: 2,
  22474. stackDelta: -1
  22475. },
  22476. {
  22477. id: 'not',
  22478. min: 1,
  22479. stackDelta: 0
  22480. },
  22481. null,
  22482. null,
  22483. null,
  22484. {
  22485. id: 'abs',
  22486. min: 1,
  22487. stackDelta: 0
  22488. },
  22489. {
  22490. id: 'add',
  22491. min: 2,
  22492. stackDelta: -1,
  22493. stackFn: function stack_div(stack, index) {
  22494. stack[index - 2] = stack[index - 2] + stack[index - 1];
  22495. }
  22496. },
  22497. {
  22498. id: 'sub',
  22499. min: 2,
  22500. stackDelta: -1,
  22501. stackFn: function stack_div(stack, index) {
  22502. stack[index - 2] = stack[index - 2] - stack[index - 1];
  22503. }
  22504. },
  22505. {
  22506. id: 'div',
  22507. min: 2,
  22508. stackDelta: -1,
  22509. stackFn: function stack_div(stack, index) {
  22510. stack[index - 2] = stack[index - 2] / stack[index - 1];
  22511. }
  22512. },
  22513. null,
  22514. {
  22515. id: 'neg',
  22516. min: 1,
  22517. stackDelta: 0,
  22518. stackFn: function stack_div(stack, index) {
  22519. stack[index - 1] = -stack[index - 1];
  22520. }
  22521. },
  22522. {
  22523. id: 'eq',
  22524. min: 2,
  22525. stackDelta: -1
  22526. },
  22527. null,
  22528. null,
  22529. {
  22530. id: 'drop',
  22531. min: 1,
  22532. stackDelta: -1
  22533. },
  22534. null,
  22535. {
  22536. id: 'put',
  22537. min: 2,
  22538. stackDelta: -2
  22539. },
  22540. {
  22541. id: 'get',
  22542. min: 1,
  22543. stackDelta: 0
  22544. },
  22545. {
  22546. id: 'ifelse',
  22547. min: 4,
  22548. stackDelta: -3
  22549. },
  22550. {
  22551. id: 'random',
  22552. min: 0,
  22553. stackDelta: 1
  22554. },
  22555. {
  22556. id: 'mul',
  22557. min: 2,
  22558. stackDelta: -1,
  22559. stackFn: function stack_div(stack, index) {
  22560. stack[index - 2] = stack[index - 2] * stack[index - 1];
  22561. }
  22562. },
  22563. null,
  22564. {
  22565. id: 'sqrt',
  22566. min: 1,
  22567. stackDelta: 0
  22568. },
  22569. {
  22570. id: 'dup',
  22571. min: 1,
  22572. stackDelta: 1
  22573. },
  22574. {
  22575. id: 'exch',
  22576. min: 2,
  22577. stackDelta: 0
  22578. },
  22579. {
  22580. id: 'index',
  22581. min: 2,
  22582. stackDelta: 0
  22583. },
  22584. {
  22585. id: 'roll',
  22586. min: 3,
  22587. stackDelta: -2
  22588. },
  22589. null,
  22590. null,
  22591. null,
  22592. {
  22593. id: 'hflex',
  22594. min: 7,
  22595. resetStack: true
  22596. },
  22597. {
  22598. id: 'flex',
  22599. min: 13,
  22600. resetStack: true
  22601. },
  22602. {
  22603. id: 'hflex1',
  22604. min: 9,
  22605. resetStack: true
  22606. },
  22607. {
  22608. id: 'flex1',
  22609. min: 11,
  22610. resetStack: true
  22611. }
  22612. ];
  22613. function CFFParser(file, properties, seacAnalysisEnabled) {
  22614. this.bytes = file.getBytes();
  22615. this.properties = properties;
  22616. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  22617. }
  22618. CFFParser.prototype = {
  22619. parse: function CFFParser_parse() {
  22620. var properties = this.properties;
  22621. var cff = new CFF();
  22622. this.cff = cff;
  22623. var header = this.parseHeader();
  22624. var nameIndex = this.parseIndex(header.endPos);
  22625. var topDictIndex = this.parseIndex(nameIndex.endPos);
  22626. var stringIndex = this.parseIndex(topDictIndex.endPos);
  22627. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  22628. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  22629. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  22630. cff.header = header.obj;
  22631. cff.names = this.parseNameIndex(nameIndex.obj);
  22632. cff.strings = this.parseStringIndex(stringIndex.obj);
  22633. cff.topDict = topDict;
  22634. cff.globalSubrIndex = globalSubrIndex.obj;
  22635. this.parsePrivateDict(cff.topDict);
  22636. cff.isCIDFont = topDict.hasName('ROS');
  22637. var charStringOffset = topDict.getByName('CharStrings');
  22638. var charStringIndex = this.parseIndex(charStringOffset).obj;
  22639. var fontMatrix = topDict.getByName('FontMatrix');
  22640. if (fontMatrix) {
  22641. properties.fontMatrix = fontMatrix;
  22642. }
  22643. var fontBBox = topDict.getByName('FontBBox');
  22644. if (fontBBox) {
  22645. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  22646. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  22647. properties.ascentScaled = true;
  22648. }
  22649. var charset, encoding;
  22650. if (cff.isCIDFont) {
  22651. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  22652. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  22653. var dictRaw = fdArrayIndex.get(i);
  22654. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  22655. this.parsePrivateDict(fontDict);
  22656. cff.fdArray.push(fontDict);
  22657. }
  22658. encoding = null;
  22659. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  22660. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  22661. } else {
  22662. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  22663. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  22664. }
  22665. cff.charset = charset;
  22666. cff.encoding = encoding;
  22667. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  22668. cff.charStrings = charStringsAndSeacs.charStrings;
  22669. cff.seacs = charStringsAndSeacs.seacs;
  22670. cff.widths = charStringsAndSeacs.widths;
  22671. return cff;
  22672. },
  22673. parseHeader: function CFFParser_parseHeader() {
  22674. var bytes = this.bytes;
  22675. var bytesLength = bytes.length;
  22676. var offset = 0;
  22677. while (offset < bytesLength && bytes[offset] !== 1) {
  22678. ++offset;
  22679. }
  22680. if (offset >= bytesLength) {
  22681. error('Invalid CFF header');
  22682. } else if (offset !== 0) {
  22683. info('cff data is shifted');
  22684. bytes = bytes.subarray(offset);
  22685. this.bytes = bytes;
  22686. }
  22687. var major = bytes[0];
  22688. var minor = bytes[1];
  22689. var hdrSize = bytes[2];
  22690. var offSize = bytes[3];
  22691. var header = new CFFHeader(major, minor, hdrSize, offSize);
  22692. return {
  22693. obj: header,
  22694. endPos: hdrSize
  22695. };
  22696. },
  22697. parseDict: function CFFParser_parseDict(dict) {
  22698. var pos = 0;
  22699. function parseOperand() {
  22700. var value = dict[pos++];
  22701. if (value === 30) {
  22702. return parseFloatOperand();
  22703. } else if (value === 28) {
  22704. value = dict[pos++];
  22705. value = (value << 24 | dict[pos++] << 16) >> 16;
  22706. return value;
  22707. } else if (value === 29) {
  22708. value = dict[pos++];
  22709. value = value << 8 | dict[pos++];
  22710. value = value << 8 | dict[pos++];
  22711. value = value << 8 | dict[pos++];
  22712. return value;
  22713. } else if (value >= 32 && value <= 246) {
  22714. return value - 139;
  22715. } else if (value >= 247 && value <= 250) {
  22716. return (value - 247) * 256 + dict[pos++] + 108;
  22717. } else if (value >= 251 && value <= 254) {
  22718. return -((value - 251) * 256) - dict[pos++] - 108;
  22719. }
  22720. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  22721. return NaN;
  22722. }
  22723. function parseFloatOperand() {
  22724. var str = '';
  22725. var eof = 15;
  22726. var lookup = [
  22727. '0',
  22728. '1',
  22729. '2',
  22730. '3',
  22731. '4',
  22732. '5',
  22733. '6',
  22734. '7',
  22735. '8',
  22736. '9',
  22737. '.',
  22738. 'E',
  22739. 'E-',
  22740. null,
  22741. '-'
  22742. ];
  22743. var length = dict.length;
  22744. while (pos < length) {
  22745. var b = dict[pos++];
  22746. var b1 = b >> 4;
  22747. var b2 = b & 15;
  22748. if (b1 === eof) {
  22749. break;
  22750. }
  22751. str += lookup[b1];
  22752. if (b2 === eof) {
  22753. break;
  22754. }
  22755. str += lookup[b2];
  22756. }
  22757. return parseFloat(str);
  22758. }
  22759. var operands = [];
  22760. var entries = [];
  22761. pos = 0;
  22762. var end = dict.length;
  22763. while (pos < end) {
  22764. var b = dict[pos];
  22765. if (b <= 21) {
  22766. if (b === 12) {
  22767. b = b << 8 | dict[++pos];
  22768. }
  22769. entries.push([
  22770. b,
  22771. operands
  22772. ]);
  22773. operands = [];
  22774. ++pos;
  22775. } else {
  22776. operands.push(parseOperand());
  22777. }
  22778. }
  22779. return entries;
  22780. },
  22781. parseIndex: function CFFParser_parseIndex(pos) {
  22782. var cffIndex = new CFFIndex();
  22783. var bytes = this.bytes;
  22784. var count = bytes[pos++] << 8 | bytes[pos++];
  22785. var offsets = [];
  22786. var end = pos;
  22787. var i, ii;
  22788. if (count !== 0) {
  22789. var offsetSize = bytes[pos++];
  22790. var startPos = pos + (count + 1) * offsetSize - 1;
  22791. for (i = 0, ii = count + 1; i < ii; ++i) {
  22792. var offset = 0;
  22793. for (var j = 0; j < offsetSize; ++j) {
  22794. offset <<= 8;
  22795. offset += bytes[pos++];
  22796. }
  22797. offsets.push(startPos + offset);
  22798. }
  22799. end = offsets[count];
  22800. }
  22801. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  22802. var offsetStart = offsets[i];
  22803. var offsetEnd = offsets[i + 1];
  22804. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  22805. }
  22806. return {
  22807. obj: cffIndex,
  22808. endPos: end
  22809. };
  22810. },
  22811. parseNameIndex: function CFFParser_parseNameIndex(index) {
  22812. var names = [];
  22813. for (var i = 0, ii = index.count; i < ii; ++i) {
  22814. var name = index.get(i);
  22815. var length = Math.min(name.length, 127);
  22816. var data = [];
  22817. for (var j = 0; j < length; ++j) {
  22818. var c = name[j];
  22819. if (j === 0 && c === 0) {
  22820. data[j] = c;
  22821. continue;
  22822. }
  22823. 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) {
  22824. data[j] = 95;
  22825. continue;
  22826. }
  22827. data[j] = c;
  22828. }
  22829. names.push(bytesToString(data));
  22830. }
  22831. return names;
  22832. },
  22833. parseStringIndex: function CFFParser_parseStringIndex(index) {
  22834. var strings = new CFFStrings();
  22835. for (var i = 0, ii = index.count; i < ii; ++i) {
  22836. var data = index.get(i);
  22837. strings.add(bytesToString(data));
  22838. }
  22839. return strings;
  22840. },
  22841. createDict: function CFFParser_createDict(Type, dict, strings) {
  22842. var cffDict = new Type(strings);
  22843. for (var i = 0, ii = dict.length; i < ii; ++i) {
  22844. var pair = dict[i];
  22845. var key = pair[0];
  22846. var value = pair[1];
  22847. cffDict.setByKey(key, value);
  22848. }
  22849. return cffDict;
  22850. },
  22851. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  22852. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  22853. return false;
  22854. }
  22855. var stackSize = state.stackSize;
  22856. var stack = state.stack;
  22857. var length = data.length;
  22858. for (var j = 0; j < length;) {
  22859. var value = data[j++];
  22860. var validationCommand = null;
  22861. if (value === 12) {
  22862. var q = data[j++];
  22863. if (q === 0) {
  22864. data[j - 2] = 139;
  22865. data[j - 1] = 22;
  22866. stackSize = 0;
  22867. } else {
  22868. validationCommand = CharstringValidationData12[q];
  22869. }
  22870. } else if (value === 28) {
  22871. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  22872. j += 2;
  22873. stackSize++;
  22874. } else if (value === 14) {
  22875. if (stackSize >= 4) {
  22876. stackSize -= 4;
  22877. if (this.seacAnalysisEnabled) {
  22878. state.seac = stack.slice(stackSize, stackSize + 4);
  22879. return false;
  22880. }
  22881. }
  22882. validationCommand = CharstringValidationData[value];
  22883. } else if (value >= 32 && value <= 246) {
  22884. stack[stackSize] = value - 139;
  22885. stackSize++;
  22886. } else if (value >= 247 && value <= 254) {
  22887. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  22888. j++;
  22889. stackSize++;
  22890. } else if (value === 255) {
  22891. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  22892. j += 4;
  22893. stackSize++;
  22894. } else if (value === 19 || value === 20) {
  22895. state.hints += stackSize >> 1;
  22896. j += state.hints + 7 >> 3;
  22897. stackSize %= 2;
  22898. validationCommand = CharstringValidationData[value];
  22899. } else if (value === 10 || value === 29) {
  22900. var subrsIndex;
  22901. if (value === 10) {
  22902. subrsIndex = localSubrIndex;
  22903. } else {
  22904. subrsIndex = globalSubrIndex;
  22905. }
  22906. if (!subrsIndex) {
  22907. validationCommand = CharstringValidationData[value];
  22908. warn('Missing subrsIndex for ' + validationCommand.id);
  22909. return false;
  22910. }
  22911. var bias = 32768;
  22912. if (subrsIndex.count < 1240) {
  22913. bias = 107;
  22914. } else if (subrsIndex.count < 33900) {
  22915. bias = 1131;
  22916. }
  22917. var subrNumber = stack[--stackSize] + bias;
  22918. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  22919. validationCommand = CharstringValidationData[value];
  22920. warn('Out of bounds subrIndex for ' + validationCommand.id);
  22921. return false;
  22922. }
  22923. state.stackSize = stackSize;
  22924. state.callDepth++;
  22925. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  22926. if (!valid) {
  22927. return false;
  22928. }
  22929. state.callDepth--;
  22930. stackSize = state.stackSize;
  22931. continue;
  22932. } else if (value === 11) {
  22933. state.stackSize = stackSize;
  22934. return true;
  22935. } else {
  22936. validationCommand = CharstringValidationData[value];
  22937. }
  22938. if (validationCommand) {
  22939. if (validationCommand.stem) {
  22940. state.hints += stackSize >> 1;
  22941. }
  22942. if ('min' in validationCommand) {
  22943. if (!state.undefStack && stackSize < validationCommand.min) {
  22944. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  22945. return false;
  22946. }
  22947. }
  22948. if (state.firstStackClearing && validationCommand.stackClearing) {
  22949. state.firstStackClearing = false;
  22950. stackSize -= validationCommand.min;
  22951. if (stackSize >= 2 && validationCommand.stem) {
  22952. stackSize %= 2;
  22953. } else if (stackSize > 1) {
  22954. warn('Found too many parameters for stack-clearing command');
  22955. }
  22956. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  22957. state.width = stack[stackSize - 1];
  22958. }
  22959. }
  22960. if ('stackDelta' in validationCommand) {
  22961. if ('stackFn' in validationCommand) {
  22962. validationCommand.stackFn(stack, stackSize);
  22963. }
  22964. stackSize += validationCommand.stackDelta;
  22965. } else if (validationCommand.stackClearing) {
  22966. stackSize = 0;
  22967. } else if (validationCommand.resetStack) {
  22968. stackSize = 0;
  22969. state.undefStack = false;
  22970. } else if (validationCommand.undefStack) {
  22971. stackSize = 0;
  22972. state.undefStack = true;
  22973. state.firstStackClearing = false;
  22974. }
  22975. }
  22976. }
  22977. state.stackSize = stackSize;
  22978. return true;
  22979. },
  22980. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  22981. var seacs = [];
  22982. var widths = [];
  22983. var count = charStrings.count;
  22984. for (var i = 0; i < count; i++) {
  22985. var charstring = charStrings.get(i);
  22986. var state = {
  22987. callDepth: 0,
  22988. stackSize: 0,
  22989. stack: [],
  22990. undefStack: true,
  22991. hints: 0,
  22992. firstStackClearing: true,
  22993. seac: null,
  22994. width: null
  22995. };
  22996. var valid = true;
  22997. var localSubrToUse = null;
  22998. if (fdSelect && fdArray.length) {
  22999. var fdIndex = fdSelect.getFDIndex(i);
  23000. if (fdIndex === -1) {
  23001. warn('Glyph index is not in fd select.');
  23002. valid = false;
  23003. }
  23004. if (fdIndex >= fdArray.length) {
  23005. warn('Invalid fd index for glyph index.');
  23006. valid = false;
  23007. }
  23008. if (valid) {
  23009. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23010. }
  23011. } else if (localSubrIndex) {
  23012. localSubrToUse = localSubrIndex;
  23013. }
  23014. if (valid) {
  23015. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23016. }
  23017. if (state.width !== null) {
  23018. widths[i] = state.width;
  23019. }
  23020. if (state.seac !== null) {
  23021. seacs[i] = state.seac;
  23022. }
  23023. if (!valid) {
  23024. charStrings.set(i, new Uint8Array([14]));
  23025. }
  23026. }
  23027. return {
  23028. charStrings: charStrings,
  23029. seacs: seacs,
  23030. widths: widths
  23031. };
  23032. },
  23033. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23034. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23035. parentDict.setByKey(18, [
  23036. 0,
  23037. 0
  23038. ]);
  23039. parentDict.privateDict = privateDict;
  23040. },
  23041. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23042. if (!parentDict.hasName('Private')) {
  23043. this.emptyPrivateDictionary(parentDict);
  23044. return;
  23045. }
  23046. var privateOffset = parentDict.getByName('Private');
  23047. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23048. parentDict.removeByName('Private');
  23049. return;
  23050. }
  23051. var size = privateOffset[0];
  23052. var offset = privateOffset[1];
  23053. if (size === 0 || offset >= this.bytes.length) {
  23054. this.emptyPrivateDictionary(parentDict);
  23055. return;
  23056. }
  23057. var privateDictEnd = offset + size;
  23058. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23059. var dict = this.parseDict(dictData);
  23060. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23061. parentDict.privateDict = privateDict;
  23062. if (!privateDict.getByName('Subrs')) {
  23063. return;
  23064. }
  23065. var subrsOffset = privateDict.getByName('Subrs');
  23066. var relativeOffset = offset + subrsOffset;
  23067. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23068. this.emptyPrivateDictionary(parentDict);
  23069. return;
  23070. }
  23071. var subrsIndex = this.parseIndex(relativeOffset);
  23072. privateDict.subrsIndex = subrsIndex.obj;
  23073. },
  23074. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23075. if (pos === 0) {
  23076. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23077. } else if (pos === 1) {
  23078. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23079. } else if (pos === 2) {
  23080. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23081. }
  23082. var bytes = this.bytes;
  23083. var start = pos;
  23084. var format = bytes[pos++];
  23085. var charset = ['.notdef'];
  23086. var id, count, i;
  23087. length -= 1;
  23088. switch (format) {
  23089. case 0:
  23090. for (i = 0; i < length; i++) {
  23091. id = bytes[pos++] << 8 | bytes[pos++];
  23092. charset.push(cid ? id : strings.get(id));
  23093. }
  23094. break;
  23095. case 1:
  23096. while (charset.length <= length) {
  23097. id = bytes[pos++] << 8 | bytes[pos++];
  23098. count = bytes[pos++];
  23099. for (i = 0; i <= count; i++) {
  23100. charset.push(cid ? id++ : strings.get(id++));
  23101. }
  23102. }
  23103. break;
  23104. case 2:
  23105. while (charset.length <= length) {
  23106. id = bytes[pos++] << 8 | bytes[pos++];
  23107. count = bytes[pos++] << 8 | bytes[pos++];
  23108. for (i = 0; i <= count; i++) {
  23109. charset.push(cid ? id++ : strings.get(id++));
  23110. }
  23111. }
  23112. break;
  23113. default:
  23114. error('Unknown charset format');
  23115. }
  23116. var end = pos;
  23117. var raw = bytes.subarray(start, end);
  23118. return new CFFCharset(false, format, charset, raw);
  23119. },
  23120. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23121. var encoding = Object.create(null);
  23122. var bytes = this.bytes;
  23123. var predefined = false;
  23124. var format, i, ii;
  23125. var raw = null;
  23126. function readSupplement() {
  23127. var supplementsCount = bytes[pos++];
  23128. for (i = 0; i < supplementsCount; i++) {
  23129. var code = bytes[pos++];
  23130. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23131. encoding[code] = charset.indexOf(strings.get(sid));
  23132. }
  23133. }
  23134. if (pos === 0 || pos === 1) {
  23135. predefined = true;
  23136. format = pos;
  23137. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23138. for (i = 0, ii = charset.length; i < ii; i++) {
  23139. var index = baseEncoding.indexOf(charset[i]);
  23140. if (index !== -1) {
  23141. encoding[index] = i;
  23142. }
  23143. }
  23144. } else {
  23145. var dataStart = pos;
  23146. format = bytes[pos++];
  23147. switch (format & 0x7f) {
  23148. case 0:
  23149. var glyphsCount = bytes[pos++];
  23150. for (i = 1; i <= glyphsCount; i++) {
  23151. encoding[bytes[pos++]] = i;
  23152. }
  23153. break;
  23154. case 1:
  23155. var rangesCount = bytes[pos++];
  23156. var gid = 1;
  23157. for (i = 0; i < rangesCount; i++) {
  23158. var start = bytes[pos++];
  23159. var left = bytes[pos++];
  23160. for (var j = start; j <= start + left; j++) {
  23161. encoding[j] = gid++;
  23162. }
  23163. }
  23164. break;
  23165. default:
  23166. error('Unknown encoding format: ' + format + ' in CFF');
  23167. break;
  23168. }
  23169. var dataEnd = pos;
  23170. if (format & 0x80) {
  23171. bytes[dataStart] &= 0x7f;
  23172. readSupplement();
  23173. }
  23174. raw = bytes.subarray(dataStart, dataEnd);
  23175. }
  23176. format = format & 0x7f;
  23177. return new CFFEncoding(predefined, format, encoding, raw);
  23178. },
  23179. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23180. var start = pos;
  23181. var bytes = this.bytes;
  23182. var format = bytes[pos++];
  23183. var fdSelect = [], rawBytes;
  23184. var i, invalidFirstGID = false;
  23185. switch (format) {
  23186. case 0:
  23187. for (i = 0; i < length; ++i) {
  23188. var id = bytes[pos++];
  23189. fdSelect.push(id);
  23190. }
  23191. rawBytes = bytes.subarray(start, pos);
  23192. break;
  23193. case 3:
  23194. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23195. for (i = 0; i < rangesCount; ++i) {
  23196. var first = bytes[pos++] << 8 | bytes[pos++];
  23197. if (i === 0 && first !== 0) {
  23198. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23199. invalidFirstGID = true;
  23200. first = 0;
  23201. }
  23202. var fdIndex = bytes[pos++];
  23203. var next = bytes[pos] << 8 | bytes[pos + 1];
  23204. for (var j = first; j < next; ++j) {
  23205. fdSelect.push(fdIndex);
  23206. }
  23207. }
  23208. pos += 2;
  23209. rawBytes = bytes.subarray(start, pos);
  23210. if (invalidFirstGID) {
  23211. rawBytes[3] = rawBytes[4] = 0;
  23212. }
  23213. break;
  23214. default:
  23215. error('parseFDSelect: Unknown format "' + format + '".');
  23216. break;
  23217. }
  23218. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23219. return new CFFFDSelect(fdSelect, rawBytes);
  23220. }
  23221. };
  23222. return CFFParser;
  23223. }();
  23224. var CFF = function CFFClosure() {
  23225. function CFF() {
  23226. this.header = null;
  23227. this.names = [];
  23228. this.topDict = null;
  23229. this.strings = new CFFStrings();
  23230. this.globalSubrIndex = null;
  23231. this.encoding = null;
  23232. this.charset = null;
  23233. this.charStrings = null;
  23234. this.fdArray = [];
  23235. this.fdSelect = null;
  23236. this.isCIDFont = false;
  23237. }
  23238. return CFF;
  23239. }();
  23240. var CFFHeader = function CFFHeaderClosure() {
  23241. function CFFHeader(major, minor, hdrSize, offSize) {
  23242. this.major = major;
  23243. this.minor = minor;
  23244. this.hdrSize = hdrSize;
  23245. this.offSize = offSize;
  23246. }
  23247. return CFFHeader;
  23248. }();
  23249. var CFFStrings = function CFFStringsClosure() {
  23250. function CFFStrings() {
  23251. this.strings = [];
  23252. }
  23253. CFFStrings.prototype = {
  23254. get: function CFFStrings_get(index) {
  23255. if (index >= 0 && index <= 390) {
  23256. return CFFStandardStrings[index];
  23257. }
  23258. if (index - 391 <= this.strings.length) {
  23259. return this.strings[index - 391];
  23260. }
  23261. return CFFStandardStrings[0];
  23262. },
  23263. add: function CFFStrings_add(value) {
  23264. this.strings.push(value);
  23265. },
  23266. get count() {
  23267. return this.strings.length;
  23268. }
  23269. };
  23270. return CFFStrings;
  23271. }();
  23272. var CFFIndex = function CFFIndexClosure() {
  23273. function CFFIndex() {
  23274. this.objects = [];
  23275. this.length = 0;
  23276. }
  23277. CFFIndex.prototype = {
  23278. add: function CFFIndex_add(data) {
  23279. this.length += data.length;
  23280. this.objects.push(data);
  23281. },
  23282. set: function CFFIndex_set(index, data) {
  23283. this.length += data.length - this.objects[index].length;
  23284. this.objects[index] = data;
  23285. },
  23286. get: function CFFIndex_get(index) {
  23287. return this.objects[index];
  23288. },
  23289. get count() {
  23290. return this.objects.length;
  23291. }
  23292. };
  23293. return CFFIndex;
  23294. }();
  23295. var CFFDict = function CFFDictClosure() {
  23296. function CFFDict(tables, strings) {
  23297. this.keyToNameMap = tables.keyToNameMap;
  23298. this.nameToKeyMap = tables.nameToKeyMap;
  23299. this.defaults = tables.defaults;
  23300. this.types = tables.types;
  23301. this.opcodes = tables.opcodes;
  23302. this.order = tables.order;
  23303. this.strings = strings;
  23304. this.values = Object.create(null);
  23305. }
  23306. CFFDict.prototype = {
  23307. setByKey: function CFFDict_setByKey(key, value) {
  23308. if (!(key in this.keyToNameMap)) {
  23309. return false;
  23310. }
  23311. var valueLength = value.length;
  23312. if (valueLength === 0) {
  23313. return true;
  23314. }
  23315. for (var i = 0; i < valueLength; i++) {
  23316. if (isNaN(value[i])) {
  23317. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  23318. return true;
  23319. }
  23320. }
  23321. var type = this.types[key];
  23322. if (type === 'num' || type === 'sid' || type === 'offset') {
  23323. value = value[0];
  23324. }
  23325. this.values[key] = value;
  23326. return true;
  23327. },
  23328. setByName: function CFFDict_setByName(name, value) {
  23329. if (!(name in this.nameToKeyMap)) {
  23330. error('Invalid dictionary name "' + name + '"');
  23331. }
  23332. this.values[this.nameToKeyMap[name]] = value;
  23333. },
  23334. hasName: function CFFDict_hasName(name) {
  23335. return this.nameToKeyMap[name] in this.values;
  23336. },
  23337. getByName: function CFFDict_getByName(name) {
  23338. if (!(name in this.nameToKeyMap)) {
  23339. error('Invalid dictionary name "' + name + '"');
  23340. }
  23341. var key = this.nameToKeyMap[name];
  23342. if (!(key in this.values)) {
  23343. return this.defaults[key];
  23344. }
  23345. return this.values[key];
  23346. },
  23347. removeByName: function CFFDict_removeByName(name) {
  23348. delete this.values[this.nameToKeyMap[name]];
  23349. }
  23350. };
  23351. CFFDict.createTables = function CFFDict_createTables(layout) {
  23352. var tables = {
  23353. keyToNameMap: {},
  23354. nameToKeyMap: {},
  23355. defaults: {},
  23356. types: {},
  23357. opcodes: {},
  23358. order: []
  23359. };
  23360. for (var i = 0, ii = layout.length; i < ii; ++i) {
  23361. var entry = layout[i];
  23362. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  23363. tables.keyToNameMap[key] = entry[1];
  23364. tables.nameToKeyMap[entry[1]] = key;
  23365. tables.types[key] = entry[2];
  23366. tables.defaults[key] = entry[3];
  23367. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  23368. tables.order.push(key);
  23369. }
  23370. return tables;
  23371. };
  23372. return CFFDict;
  23373. }();
  23374. var CFFTopDict = function CFFTopDictClosure() {
  23375. var layout = [
  23376. [
  23377. [
  23378. 12,
  23379. 30
  23380. ],
  23381. 'ROS',
  23382. [
  23383. 'sid',
  23384. 'sid',
  23385. 'num'
  23386. ],
  23387. null
  23388. ],
  23389. [
  23390. [
  23391. 12,
  23392. 20
  23393. ],
  23394. 'SyntheticBase',
  23395. 'num',
  23396. null
  23397. ],
  23398. [
  23399. 0,
  23400. 'version',
  23401. 'sid',
  23402. null
  23403. ],
  23404. [
  23405. 1,
  23406. 'Notice',
  23407. 'sid',
  23408. null
  23409. ],
  23410. [
  23411. [
  23412. 12,
  23413. 0
  23414. ],
  23415. 'Copyright',
  23416. 'sid',
  23417. null
  23418. ],
  23419. [
  23420. 2,
  23421. 'FullName',
  23422. 'sid',
  23423. null
  23424. ],
  23425. [
  23426. 3,
  23427. 'FamilyName',
  23428. 'sid',
  23429. null
  23430. ],
  23431. [
  23432. 4,
  23433. 'Weight',
  23434. 'sid',
  23435. null
  23436. ],
  23437. [
  23438. [
  23439. 12,
  23440. 1
  23441. ],
  23442. 'isFixedPitch',
  23443. 'num',
  23444. 0
  23445. ],
  23446. [
  23447. [
  23448. 12,
  23449. 2
  23450. ],
  23451. 'ItalicAngle',
  23452. 'num',
  23453. 0
  23454. ],
  23455. [
  23456. [
  23457. 12,
  23458. 3
  23459. ],
  23460. 'UnderlinePosition',
  23461. 'num',
  23462. -100
  23463. ],
  23464. [
  23465. [
  23466. 12,
  23467. 4
  23468. ],
  23469. 'UnderlineThickness',
  23470. 'num',
  23471. 50
  23472. ],
  23473. [
  23474. [
  23475. 12,
  23476. 5
  23477. ],
  23478. 'PaintType',
  23479. 'num',
  23480. 0
  23481. ],
  23482. [
  23483. [
  23484. 12,
  23485. 6
  23486. ],
  23487. 'CharstringType',
  23488. 'num',
  23489. 2
  23490. ],
  23491. [
  23492. [
  23493. 12,
  23494. 7
  23495. ],
  23496. 'FontMatrix',
  23497. [
  23498. 'num',
  23499. 'num',
  23500. 'num',
  23501. 'num',
  23502. 'num',
  23503. 'num'
  23504. ],
  23505. [
  23506. 0.001,
  23507. 0,
  23508. 0,
  23509. 0.001,
  23510. 0,
  23511. 0
  23512. ]
  23513. ],
  23514. [
  23515. 13,
  23516. 'UniqueID',
  23517. 'num',
  23518. null
  23519. ],
  23520. [
  23521. 5,
  23522. 'FontBBox',
  23523. [
  23524. 'num',
  23525. 'num',
  23526. 'num',
  23527. 'num'
  23528. ],
  23529. [
  23530. 0,
  23531. 0,
  23532. 0,
  23533. 0
  23534. ]
  23535. ],
  23536. [
  23537. [
  23538. 12,
  23539. 8
  23540. ],
  23541. 'StrokeWidth',
  23542. 'num',
  23543. 0
  23544. ],
  23545. [
  23546. 14,
  23547. 'XUID',
  23548. 'array',
  23549. null
  23550. ],
  23551. [
  23552. 15,
  23553. 'charset',
  23554. 'offset',
  23555. 0
  23556. ],
  23557. [
  23558. 16,
  23559. 'Encoding',
  23560. 'offset',
  23561. 0
  23562. ],
  23563. [
  23564. 17,
  23565. 'CharStrings',
  23566. 'offset',
  23567. 0
  23568. ],
  23569. [
  23570. 18,
  23571. 'Private',
  23572. [
  23573. 'offset',
  23574. 'offset'
  23575. ],
  23576. null
  23577. ],
  23578. [
  23579. [
  23580. 12,
  23581. 21
  23582. ],
  23583. 'PostScript',
  23584. 'sid',
  23585. null
  23586. ],
  23587. [
  23588. [
  23589. 12,
  23590. 22
  23591. ],
  23592. 'BaseFontName',
  23593. 'sid',
  23594. null
  23595. ],
  23596. [
  23597. [
  23598. 12,
  23599. 23
  23600. ],
  23601. 'BaseFontBlend',
  23602. 'delta',
  23603. null
  23604. ],
  23605. [
  23606. [
  23607. 12,
  23608. 31
  23609. ],
  23610. 'CIDFontVersion',
  23611. 'num',
  23612. 0
  23613. ],
  23614. [
  23615. [
  23616. 12,
  23617. 32
  23618. ],
  23619. 'CIDFontRevision',
  23620. 'num',
  23621. 0
  23622. ],
  23623. [
  23624. [
  23625. 12,
  23626. 33
  23627. ],
  23628. 'CIDFontType',
  23629. 'num',
  23630. 0
  23631. ],
  23632. [
  23633. [
  23634. 12,
  23635. 34
  23636. ],
  23637. 'CIDCount',
  23638. 'num',
  23639. 8720
  23640. ],
  23641. [
  23642. [
  23643. 12,
  23644. 35
  23645. ],
  23646. 'UIDBase',
  23647. 'num',
  23648. null
  23649. ],
  23650. [
  23651. [
  23652. 12,
  23653. 37
  23654. ],
  23655. 'FDSelect',
  23656. 'offset',
  23657. null
  23658. ],
  23659. [
  23660. [
  23661. 12,
  23662. 36
  23663. ],
  23664. 'FDArray',
  23665. 'offset',
  23666. null
  23667. ],
  23668. [
  23669. [
  23670. 12,
  23671. 38
  23672. ],
  23673. 'FontName',
  23674. 'sid',
  23675. null
  23676. ]
  23677. ];
  23678. var tables = null;
  23679. function CFFTopDict(strings) {
  23680. if (tables === null) {
  23681. tables = CFFDict.createTables(layout);
  23682. }
  23683. CFFDict.call(this, tables, strings);
  23684. this.privateDict = null;
  23685. }
  23686. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  23687. return CFFTopDict;
  23688. }();
  23689. var CFFPrivateDict = function CFFPrivateDictClosure() {
  23690. var layout = [
  23691. [
  23692. 6,
  23693. 'BlueValues',
  23694. 'delta',
  23695. null
  23696. ],
  23697. [
  23698. 7,
  23699. 'OtherBlues',
  23700. 'delta',
  23701. null
  23702. ],
  23703. [
  23704. 8,
  23705. 'FamilyBlues',
  23706. 'delta',
  23707. null
  23708. ],
  23709. [
  23710. 9,
  23711. 'FamilyOtherBlues',
  23712. 'delta',
  23713. null
  23714. ],
  23715. [
  23716. [
  23717. 12,
  23718. 9
  23719. ],
  23720. 'BlueScale',
  23721. 'num',
  23722. 0.039625
  23723. ],
  23724. [
  23725. [
  23726. 12,
  23727. 10
  23728. ],
  23729. 'BlueShift',
  23730. 'num',
  23731. 7
  23732. ],
  23733. [
  23734. [
  23735. 12,
  23736. 11
  23737. ],
  23738. 'BlueFuzz',
  23739. 'num',
  23740. 1
  23741. ],
  23742. [
  23743. 10,
  23744. 'StdHW',
  23745. 'num',
  23746. null
  23747. ],
  23748. [
  23749. 11,
  23750. 'StdVW',
  23751. 'num',
  23752. null
  23753. ],
  23754. [
  23755. [
  23756. 12,
  23757. 12
  23758. ],
  23759. 'StemSnapH',
  23760. 'delta',
  23761. null
  23762. ],
  23763. [
  23764. [
  23765. 12,
  23766. 13
  23767. ],
  23768. 'StemSnapV',
  23769. 'delta',
  23770. null
  23771. ],
  23772. [
  23773. [
  23774. 12,
  23775. 14
  23776. ],
  23777. 'ForceBold',
  23778. 'num',
  23779. 0
  23780. ],
  23781. [
  23782. [
  23783. 12,
  23784. 17
  23785. ],
  23786. 'LanguageGroup',
  23787. 'num',
  23788. 0
  23789. ],
  23790. [
  23791. [
  23792. 12,
  23793. 18
  23794. ],
  23795. 'ExpansionFactor',
  23796. 'num',
  23797. 0.06
  23798. ],
  23799. [
  23800. [
  23801. 12,
  23802. 19
  23803. ],
  23804. 'initialRandomSeed',
  23805. 'num',
  23806. 0
  23807. ],
  23808. [
  23809. 20,
  23810. 'defaultWidthX',
  23811. 'num',
  23812. 0
  23813. ],
  23814. [
  23815. 21,
  23816. 'nominalWidthX',
  23817. 'num',
  23818. 0
  23819. ],
  23820. [
  23821. 19,
  23822. 'Subrs',
  23823. 'offset',
  23824. null
  23825. ]
  23826. ];
  23827. var tables = null;
  23828. function CFFPrivateDict(strings) {
  23829. if (tables === null) {
  23830. tables = CFFDict.createTables(layout);
  23831. }
  23832. CFFDict.call(this, tables, strings);
  23833. this.subrsIndex = null;
  23834. }
  23835. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  23836. return CFFPrivateDict;
  23837. }();
  23838. var CFFCharsetPredefinedTypes = {
  23839. ISO_ADOBE: 0,
  23840. EXPERT: 1,
  23841. EXPERT_SUBSET: 2
  23842. };
  23843. var CFFCharset = function CFFCharsetClosure() {
  23844. function CFFCharset(predefined, format, charset, raw) {
  23845. this.predefined = predefined;
  23846. this.format = format;
  23847. this.charset = charset;
  23848. this.raw = raw;
  23849. }
  23850. return CFFCharset;
  23851. }();
  23852. var CFFEncoding = function CFFEncodingClosure() {
  23853. function CFFEncoding(predefined, format, encoding, raw) {
  23854. this.predefined = predefined;
  23855. this.format = format;
  23856. this.encoding = encoding;
  23857. this.raw = raw;
  23858. }
  23859. return CFFEncoding;
  23860. }();
  23861. var CFFFDSelect = function CFFFDSelectClosure() {
  23862. function CFFFDSelect(fdSelect, raw) {
  23863. this.fdSelect = fdSelect;
  23864. this.raw = raw;
  23865. }
  23866. CFFFDSelect.prototype = {
  23867. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  23868. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  23869. return -1;
  23870. }
  23871. return this.fdSelect[glyphIndex];
  23872. }
  23873. };
  23874. return CFFFDSelect;
  23875. }();
  23876. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  23877. function CFFOffsetTracker() {
  23878. this.offsets = Object.create(null);
  23879. }
  23880. CFFOffsetTracker.prototype = {
  23881. isTracking: function CFFOffsetTracker_isTracking(key) {
  23882. return key in this.offsets;
  23883. },
  23884. track: function CFFOffsetTracker_track(key, location) {
  23885. if (key in this.offsets) {
  23886. error('Already tracking location of ' + key);
  23887. }
  23888. this.offsets[key] = location;
  23889. },
  23890. offset: function CFFOffsetTracker_offset(value) {
  23891. for (var key in this.offsets) {
  23892. this.offsets[key] += value;
  23893. }
  23894. },
  23895. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  23896. if (!(key in this.offsets)) {
  23897. error('Not tracking location of ' + key);
  23898. }
  23899. var data = output.data;
  23900. var dataOffset = this.offsets[key];
  23901. var size = 5;
  23902. for (var i = 0, ii = values.length; i < ii; ++i) {
  23903. var offset0 = i * size + dataOffset;
  23904. var offset1 = offset0 + 1;
  23905. var offset2 = offset0 + 2;
  23906. var offset3 = offset0 + 3;
  23907. var offset4 = offset0 + 4;
  23908. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  23909. error('writing to an offset that is not empty');
  23910. }
  23911. var value = values[i];
  23912. data[offset0] = 0x1d;
  23913. data[offset1] = value >> 24 & 0xFF;
  23914. data[offset2] = value >> 16 & 0xFF;
  23915. data[offset3] = value >> 8 & 0xFF;
  23916. data[offset4] = value & 0xFF;
  23917. }
  23918. }
  23919. };
  23920. return CFFOffsetTracker;
  23921. }();
  23922. var CFFCompiler = function CFFCompilerClosure() {
  23923. function CFFCompiler(cff) {
  23924. this.cff = cff;
  23925. }
  23926. CFFCompiler.prototype = {
  23927. compile: function CFFCompiler_compile() {
  23928. var cff = this.cff;
  23929. var output = {
  23930. data: [],
  23931. length: 0,
  23932. add: function CFFCompiler_add(data) {
  23933. this.data = this.data.concat(data);
  23934. this.length = this.data.length;
  23935. }
  23936. };
  23937. var header = this.compileHeader(cff.header);
  23938. output.add(header);
  23939. var nameIndex = this.compileNameIndex(cff.names);
  23940. output.add(nameIndex);
  23941. if (cff.isCIDFont) {
  23942. if (cff.topDict.hasName('FontMatrix')) {
  23943. var base = cff.topDict.getByName('FontMatrix');
  23944. cff.topDict.removeByName('FontMatrix');
  23945. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  23946. var subDict = cff.fdArray[i];
  23947. var matrix = base.slice(0);
  23948. if (subDict.hasName('FontMatrix')) {
  23949. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  23950. }
  23951. subDict.setByName('FontMatrix', matrix);
  23952. }
  23953. }
  23954. }
  23955. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  23956. output.add(compiled.output);
  23957. var topDictTracker = compiled.trackers[0];
  23958. var stringIndex = this.compileStringIndex(cff.strings.strings);
  23959. output.add(stringIndex);
  23960. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  23961. output.add(globalSubrIndex);
  23962. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  23963. if (cff.encoding.predefined) {
  23964. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  23965. } else {
  23966. var encoding = this.compileEncoding(cff.encoding);
  23967. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  23968. output.add(encoding);
  23969. }
  23970. }
  23971. if (cff.charset && cff.topDict.hasName('charset')) {
  23972. if (cff.charset.predefined) {
  23973. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  23974. } else {
  23975. var charset = this.compileCharset(cff.charset);
  23976. topDictTracker.setEntryLocation('charset', [output.length], output);
  23977. output.add(charset);
  23978. }
  23979. }
  23980. var charStrings = this.compileCharStrings(cff.charStrings);
  23981. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  23982. output.add(charStrings);
  23983. if (cff.isCIDFont) {
  23984. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  23985. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  23986. output.add(fdSelect);
  23987. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  23988. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  23989. output.add(compiled.output);
  23990. var fontDictTrackers = compiled.trackers;
  23991. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  23992. }
  23993. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  23994. output.add([0]);
  23995. return output.data;
  23996. },
  23997. encodeNumber: function CFFCompiler_encodeNumber(value) {
  23998. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  23999. return this.encodeInteger(value);
  24000. }
  24001. return this.encodeFloat(value);
  24002. },
  24003. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24004. var value = num.toString();
  24005. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24006. if (m) {
  24007. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24008. value = (Math.round(num * epsilon) / epsilon).toString();
  24009. }
  24010. var nibbles = '';
  24011. var i, ii;
  24012. for (i = 0, ii = value.length; i < ii; ++i) {
  24013. var a = value[i];
  24014. if (a === 'e') {
  24015. nibbles += value[++i] === '-' ? 'c' : 'b';
  24016. } else if (a === '.') {
  24017. nibbles += 'a';
  24018. } else if (a === '-') {
  24019. nibbles += 'e';
  24020. } else {
  24021. nibbles += a;
  24022. }
  24023. }
  24024. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24025. var out = [30];
  24026. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24027. out.push(parseInt(nibbles.substr(i, 2), 16));
  24028. }
  24029. return out;
  24030. },
  24031. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24032. var code;
  24033. if (value >= -107 && value <= 107) {
  24034. code = [value + 139];
  24035. } else if (value >= 108 && value <= 1131) {
  24036. value = value - 108;
  24037. code = [
  24038. (value >> 8) + 247,
  24039. value & 0xFF
  24040. ];
  24041. } else if (value >= -1131 && value <= -108) {
  24042. value = -value - 108;
  24043. code = [
  24044. (value >> 8) + 251,
  24045. value & 0xFF
  24046. ];
  24047. } else if (value >= -32768 && value <= 32767) {
  24048. code = [
  24049. 0x1c,
  24050. value >> 8 & 0xFF,
  24051. value & 0xFF
  24052. ];
  24053. } else {
  24054. code = [
  24055. 0x1d,
  24056. value >> 24 & 0xFF,
  24057. value >> 16 & 0xFF,
  24058. value >> 8 & 0xFF,
  24059. value & 0xFF
  24060. ];
  24061. }
  24062. return code;
  24063. },
  24064. compileHeader: function CFFCompiler_compileHeader(header) {
  24065. return [
  24066. header.major,
  24067. header.minor,
  24068. header.hdrSize,
  24069. header.offSize
  24070. ];
  24071. },
  24072. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24073. var nameIndex = new CFFIndex();
  24074. for (var i = 0, ii = names.length; i < ii; ++i) {
  24075. nameIndex.add(stringToBytes(names[i]));
  24076. }
  24077. return this.compileIndex(nameIndex);
  24078. },
  24079. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24080. var fontDictTrackers = [];
  24081. var fdArrayIndex = new CFFIndex();
  24082. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24083. var fontDict = dicts[i];
  24084. if (removeCidKeys) {
  24085. fontDict.removeByName('CIDFontVersion');
  24086. fontDict.removeByName('CIDFontRevision');
  24087. fontDict.removeByName('CIDFontType');
  24088. fontDict.removeByName('CIDCount');
  24089. fontDict.removeByName('UIDBase');
  24090. }
  24091. var fontDictTracker = new CFFOffsetTracker();
  24092. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24093. fontDictTrackers.push(fontDictTracker);
  24094. fdArrayIndex.add(fontDictData);
  24095. fontDictTracker.offset(length);
  24096. }
  24097. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24098. return {
  24099. trackers: fontDictTrackers,
  24100. output: fdArrayIndex
  24101. };
  24102. },
  24103. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24104. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24105. var fontDict = dicts[i];
  24106. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24107. var privateDict = fontDict.privateDict;
  24108. var privateDictTracker = new CFFOffsetTracker();
  24109. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24110. var outputLength = output.length;
  24111. privateDictTracker.offset(outputLength);
  24112. if (!privateDictData.length) {
  24113. outputLength = 0;
  24114. }
  24115. trackers[i].setEntryLocation('Private', [
  24116. privateDictData.length,
  24117. outputLength
  24118. ], output);
  24119. output.add(privateDictData);
  24120. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24121. var subrs = this.compileIndex(privateDict.subrsIndex);
  24122. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24123. output.add(subrs);
  24124. }
  24125. }
  24126. },
  24127. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24128. var out = [];
  24129. var order = dict.order;
  24130. for (var i = 0; i < order.length; ++i) {
  24131. var key = order[i];
  24132. if (!(key in dict.values)) {
  24133. continue;
  24134. }
  24135. var values = dict.values[key];
  24136. var types = dict.types[key];
  24137. if (!isArray(types)) {
  24138. types = [types];
  24139. }
  24140. if (!isArray(values)) {
  24141. values = [values];
  24142. }
  24143. if (values.length === 0) {
  24144. continue;
  24145. }
  24146. for (var j = 0, jj = types.length; j < jj; ++j) {
  24147. var type = types[j];
  24148. var value = values[j];
  24149. switch (type) {
  24150. case 'num':
  24151. case 'sid':
  24152. out = out.concat(this.encodeNumber(value));
  24153. break;
  24154. case 'offset':
  24155. var name = dict.keyToNameMap[key];
  24156. if (!offsetTracker.isTracking(name)) {
  24157. offsetTracker.track(name, out.length);
  24158. }
  24159. out = out.concat([
  24160. 0x1d,
  24161. 0,
  24162. 0,
  24163. 0,
  24164. 0
  24165. ]);
  24166. break;
  24167. case 'array':
  24168. case 'delta':
  24169. out = out.concat(this.encodeNumber(value));
  24170. for (var k = 1, kk = values.length; k < kk; ++k) {
  24171. out = out.concat(this.encodeNumber(values[k]));
  24172. }
  24173. break;
  24174. default:
  24175. error('Unknown data type of ' + type);
  24176. break;
  24177. }
  24178. }
  24179. out = out.concat(dict.opcodes[key]);
  24180. }
  24181. return out;
  24182. },
  24183. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24184. var stringIndex = new CFFIndex();
  24185. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24186. stringIndex.add(stringToBytes(strings[i]));
  24187. }
  24188. return this.compileIndex(stringIndex);
  24189. },
  24190. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24191. var globalSubrIndex = this.cff.globalSubrIndex;
  24192. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24193. },
  24194. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24195. return this.compileIndex(charStrings);
  24196. },
  24197. compileCharset: function CFFCompiler_compileCharset(charset) {
  24198. return this.compileTypedArray(charset.raw);
  24199. },
  24200. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24201. return this.compileTypedArray(encoding.raw);
  24202. },
  24203. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24204. return this.compileTypedArray(fdSelect);
  24205. },
  24206. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24207. var out = [];
  24208. for (var i = 0, ii = data.length; i < ii; ++i) {
  24209. out[i] = data[i];
  24210. }
  24211. return out;
  24212. },
  24213. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24214. trackers = trackers || [];
  24215. var objects = index.objects;
  24216. var count = objects.length;
  24217. if (count === 0) {
  24218. return [
  24219. 0,
  24220. 0,
  24221. 0
  24222. ];
  24223. }
  24224. var data = [
  24225. count >> 8 & 0xFF,
  24226. count & 0xff
  24227. ];
  24228. var lastOffset = 1, i;
  24229. for (i = 0; i < count; ++i) {
  24230. lastOffset += objects[i].length;
  24231. }
  24232. var offsetSize;
  24233. if (lastOffset < 0x100) {
  24234. offsetSize = 1;
  24235. } else if (lastOffset < 0x10000) {
  24236. offsetSize = 2;
  24237. } else if (lastOffset < 0x1000000) {
  24238. offsetSize = 3;
  24239. } else {
  24240. offsetSize = 4;
  24241. }
  24242. data.push(offsetSize);
  24243. var relativeOffset = 1;
  24244. for (i = 0; i < count + 1; i++) {
  24245. if (offsetSize === 1) {
  24246. data.push(relativeOffset & 0xFF);
  24247. } else if (offsetSize === 2) {
  24248. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24249. } else if (offsetSize === 3) {
  24250. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24251. } else {
  24252. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24253. }
  24254. if (objects[i]) {
  24255. relativeOffset += objects[i].length;
  24256. }
  24257. }
  24258. for (i = 0; i < count; i++) {
  24259. if (trackers[i]) {
  24260. trackers[i].offset(data.length);
  24261. }
  24262. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24263. data.push(objects[i][j]);
  24264. }
  24265. }
  24266. return data;
  24267. }
  24268. };
  24269. return CFFCompiler;
  24270. }();
  24271. exports.CFFStandardStrings = CFFStandardStrings;
  24272. exports.CFFParser = CFFParser;
  24273. exports.CFF = CFF;
  24274. exports.CFFHeader = CFFHeader;
  24275. exports.CFFStrings = CFFStrings;
  24276. exports.CFFIndex = CFFIndex;
  24277. exports.CFFCharset = CFFCharset;
  24278. exports.CFFTopDict = CFFTopDict;
  24279. exports.CFFPrivateDict = CFFPrivateDict;
  24280. exports.CFFCompiler = CFFCompiler;
  24281. /***/ }),
  24282. /* 16 */
  24283. /***/ (function(module, exports, __w_pdfjs_require__) {
  24284. "use strict";
  24285. var sharedUtil = __w_pdfjs_require__(0);
  24286. var MissingDataException = sharedUtil.MissingDataException;
  24287. var arrayByteLength = sharedUtil.arrayByteLength;
  24288. var arraysToBytes = sharedUtil.arraysToBytes;
  24289. var assert = sharedUtil.assert;
  24290. var createPromiseCapability = sharedUtil.createPromiseCapability;
  24291. var isInt = sharedUtil.isInt;
  24292. var isEmptyObj = sharedUtil.isEmptyObj;
  24293. var ChunkedStream = function ChunkedStreamClosure() {
  24294. function ChunkedStream(length, chunkSize, manager) {
  24295. this.bytes = new Uint8Array(length);
  24296. this.start = 0;
  24297. this.pos = 0;
  24298. this.end = length;
  24299. this.chunkSize = chunkSize;
  24300. this.loadedChunks = [];
  24301. this.numChunksLoaded = 0;
  24302. this.numChunks = Math.ceil(length / chunkSize);
  24303. this.manager = manager;
  24304. this.progressiveDataLength = 0;
  24305. this.lastSuccessfulEnsureByteChunk = -1;
  24306. }
  24307. ChunkedStream.prototype = {
  24308. getMissingChunks: function ChunkedStream_getMissingChunks() {
  24309. var chunks = [];
  24310. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  24311. if (!this.loadedChunks[chunk]) {
  24312. chunks.push(chunk);
  24313. }
  24314. }
  24315. return chunks;
  24316. },
  24317. getBaseStreams: function ChunkedStream_getBaseStreams() {
  24318. return [this];
  24319. },
  24320. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  24321. return this.numChunksLoaded === this.numChunks;
  24322. },
  24323. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  24324. var end = begin + chunk.byteLength;
  24325. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  24326. var length = this.bytes.length;
  24327. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  24328. this.bytes.set(new Uint8Array(chunk), begin);
  24329. var chunkSize = this.chunkSize;
  24330. var beginChunk = Math.floor(begin / chunkSize);
  24331. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24332. var curChunk;
  24333. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24334. if (!this.loadedChunks[curChunk]) {
  24335. this.loadedChunks[curChunk] = true;
  24336. ++this.numChunksLoaded;
  24337. }
  24338. }
  24339. },
  24340. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  24341. var position = this.progressiveDataLength;
  24342. var beginChunk = Math.floor(position / this.chunkSize);
  24343. this.bytes.set(new Uint8Array(data), position);
  24344. position += data.byteLength;
  24345. this.progressiveDataLength = position;
  24346. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  24347. var curChunk;
  24348. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24349. if (!this.loadedChunks[curChunk]) {
  24350. this.loadedChunks[curChunk] = true;
  24351. ++this.numChunksLoaded;
  24352. }
  24353. }
  24354. },
  24355. ensureByte: function ChunkedStream_ensureByte(pos) {
  24356. var chunk = Math.floor(pos / this.chunkSize);
  24357. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  24358. return;
  24359. }
  24360. if (!this.loadedChunks[chunk]) {
  24361. throw new MissingDataException(pos, pos + 1);
  24362. }
  24363. this.lastSuccessfulEnsureByteChunk = chunk;
  24364. },
  24365. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  24366. if (begin >= end) {
  24367. return;
  24368. }
  24369. if (end <= this.progressiveDataLength) {
  24370. return;
  24371. }
  24372. var chunkSize = this.chunkSize;
  24373. var beginChunk = Math.floor(begin / chunkSize);
  24374. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24375. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24376. if (!this.loadedChunks[chunk]) {
  24377. throw new MissingDataException(begin, end);
  24378. }
  24379. }
  24380. },
  24381. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  24382. var chunk, numChunks = this.numChunks;
  24383. for (var i = 0; i < numChunks; ++i) {
  24384. chunk = (beginChunk + i) % numChunks;
  24385. if (!this.loadedChunks[chunk]) {
  24386. return chunk;
  24387. }
  24388. }
  24389. return null;
  24390. },
  24391. hasChunk: function ChunkedStream_hasChunk(chunk) {
  24392. return !!this.loadedChunks[chunk];
  24393. },
  24394. get length() {
  24395. return this.end - this.start;
  24396. },
  24397. get isEmpty() {
  24398. return this.length === 0;
  24399. },
  24400. getByte: function ChunkedStream_getByte() {
  24401. var pos = this.pos;
  24402. if (pos >= this.end) {
  24403. return -1;
  24404. }
  24405. this.ensureByte(pos);
  24406. return this.bytes[this.pos++];
  24407. },
  24408. getUint16: function ChunkedStream_getUint16() {
  24409. var b0 = this.getByte();
  24410. var b1 = this.getByte();
  24411. if (b0 === -1 || b1 === -1) {
  24412. return -1;
  24413. }
  24414. return (b0 << 8) + b1;
  24415. },
  24416. getInt32: function ChunkedStream_getInt32() {
  24417. var b0 = this.getByte();
  24418. var b1 = this.getByte();
  24419. var b2 = this.getByte();
  24420. var b3 = this.getByte();
  24421. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24422. },
  24423. getBytes: function ChunkedStream_getBytes(length) {
  24424. var bytes = this.bytes;
  24425. var pos = this.pos;
  24426. var strEnd = this.end;
  24427. if (!length) {
  24428. this.ensureRange(pos, strEnd);
  24429. return bytes.subarray(pos, strEnd);
  24430. }
  24431. var end = pos + length;
  24432. if (end > strEnd) {
  24433. end = strEnd;
  24434. }
  24435. this.ensureRange(pos, end);
  24436. this.pos = end;
  24437. return bytes.subarray(pos, end);
  24438. },
  24439. peekByte: function ChunkedStream_peekByte() {
  24440. var peekedByte = this.getByte();
  24441. this.pos--;
  24442. return peekedByte;
  24443. },
  24444. peekBytes: function ChunkedStream_peekBytes(length) {
  24445. var bytes = this.getBytes(length);
  24446. this.pos -= bytes.length;
  24447. return bytes;
  24448. },
  24449. getByteRange: function ChunkedStream_getBytes(begin, end) {
  24450. this.ensureRange(begin, end);
  24451. return this.bytes.subarray(begin, end);
  24452. },
  24453. skip: function ChunkedStream_skip(n) {
  24454. if (!n) {
  24455. n = 1;
  24456. }
  24457. this.pos += n;
  24458. },
  24459. reset: function ChunkedStream_reset() {
  24460. this.pos = this.start;
  24461. },
  24462. moveStart: function ChunkedStream_moveStart() {
  24463. this.start = this.pos;
  24464. },
  24465. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  24466. this.ensureRange(start, start + length);
  24467. function ChunkedStreamSubstream() {
  24468. }
  24469. ChunkedStreamSubstream.prototype = Object.create(this);
  24470. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  24471. var chunkSize = this.chunkSize;
  24472. var beginChunk = Math.floor(this.start / chunkSize);
  24473. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  24474. var missingChunks = [];
  24475. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24476. if (!this.loadedChunks[chunk]) {
  24477. missingChunks.push(chunk);
  24478. }
  24479. }
  24480. return missingChunks;
  24481. };
  24482. var subStream = new ChunkedStreamSubstream();
  24483. subStream.pos = subStream.start = start;
  24484. subStream.end = start + length || this.end;
  24485. subStream.dict = dict;
  24486. return subStream;
  24487. }
  24488. };
  24489. return ChunkedStream;
  24490. }();
  24491. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  24492. function ChunkedStreamManager(pdfNetworkStream, args) {
  24493. var chunkSize = args.rangeChunkSize;
  24494. var length = args.length;
  24495. this.stream = new ChunkedStream(length, chunkSize, this);
  24496. this.length = length;
  24497. this.chunkSize = chunkSize;
  24498. this.pdfNetworkStream = pdfNetworkStream;
  24499. this.url = args.url;
  24500. this.disableAutoFetch = args.disableAutoFetch;
  24501. this.msgHandler = args.msgHandler;
  24502. this.currRequestId = 0;
  24503. this.chunksNeededByRequest = Object.create(null);
  24504. this.requestsByChunk = Object.create(null);
  24505. this.promisesByRequest = Object.create(null);
  24506. this.progressiveDataLength = 0;
  24507. this.aborted = false;
  24508. this._loadedStreamCapability = createPromiseCapability();
  24509. }
  24510. ChunkedStreamManager.prototype = {
  24511. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  24512. return this._loadedStreamCapability.promise;
  24513. },
  24514. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  24515. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  24516. if (!rangeReader.isStreamingSupported) {
  24517. rangeReader.onProgress = this.onProgress.bind(this);
  24518. }
  24519. var chunks = [], loaded = 0;
  24520. var manager = this;
  24521. var promise = new Promise(function (resolve, reject) {
  24522. var readChunk = function (chunk) {
  24523. try {
  24524. if (!chunk.done) {
  24525. var data = chunk.value;
  24526. chunks.push(data);
  24527. loaded += arrayByteLength(data);
  24528. if (rangeReader.isStreamingSupported) {
  24529. manager.onProgress({ loaded: loaded });
  24530. }
  24531. rangeReader.read().then(readChunk, reject);
  24532. return;
  24533. }
  24534. var chunkData = arraysToBytes(chunks);
  24535. chunks = null;
  24536. resolve(chunkData);
  24537. } catch (e) {
  24538. reject(e);
  24539. }
  24540. };
  24541. rangeReader.read().then(readChunk, reject);
  24542. });
  24543. promise.then(function (data) {
  24544. if (this.aborted) {
  24545. return;
  24546. }
  24547. this.onReceiveData({
  24548. chunk: data,
  24549. begin: begin
  24550. });
  24551. }.bind(this));
  24552. },
  24553. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  24554. var missingChunks = this.stream.getMissingChunks();
  24555. this._requestChunks(missingChunks);
  24556. return this._loadedStreamCapability.promise;
  24557. },
  24558. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  24559. var requestId = this.currRequestId++;
  24560. var i, ii;
  24561. var chunksNeeded = Object.create(null);
  24562. this.chunksNeededByRequest[requestId] = chunksNeeded;
  24563. for (i = 0, ii = chunks.length; i < ii; i++) {
  24564. if (!this.stream.hasChunk(chunks[i])) {
  24565. chunksNeeded[chunks[i]] = true;
  24566. }
  24567. }
  24568. if (isEmptyObj(chunksNeeded)) {
  24569. return Promise.resolve();
  24570. }
  24571. var capability = createPromiseCapability();
  24572. this.promisesByRequest[requestId] = capability;
  24573. var chunksToRequest = [];
  24574. for (var chunk in chunksNeeded) {
  24575. chunk = chunk | 0;
  24576. if (!(chunk in this.requestsByChunk)) {
  24577. this.requestsByChunk[chunk] = [];
  24578. chunksToRequest.push(chunk);
  24579. }
  24580. this.requestsByChunk[chunk].push(requestId);
  24581. }
  24582. if (!chunksToRequest.length) {
  24583. return capability.promise;
  24584. }
  24585. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  24586. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  24587. var groupedChunk = groupedChunksToRequest[i];
  24588. var begin = groupedChunk.beginChunk * this.chunkSize;
  24589. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  24590. this.sendRequest(begin, end);
  24591. }
  24592. return capability.promise;
  24593. },
  24594. getStream: function ChunkedStreamManager_getStream() {
  24595. return this.stream;
  24596. },
  24597. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  24598. end = Math.min(end, this.length);
  24599. var beginChunk = this.getBeginChunk(begin);
  24600. var endChunk = this.getEndChunk(end);
  24601. var chunks = [];
  24602. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24603. chunks.push(chunk);
  24604. }
  24605. return this._requestChunks(chunks);
  24606. },
  24607. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  24608. ranges = ranges || [];
  24609. var chunksToRequest = [];
  24610. for (var i = 0; i < ranges.length; i++) {
  24611. var beginChunk = this.getBeginChunk(ranges[i].begin);
  24612. var endChunk = this.getEndChunk(ranges[i].end);
  24613. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24614. if (chunksToRequest.indexOf(chunk) < 0) {
  24615. chunksToRequest.push(chunk);
  24616. }
  24617. }
  24618. }
  24619. chunksToRequest.sort(function (a, b) {
  24620. return a - b;
  24621. });
  24622. return this._requestChunks(chunksToRequest);
  24623. },
  24624. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  24625. var groupedChunks = [];
  24626. var beginChunk = -1;
  24627. var prevChunk = -1;
  24628. for (var i = 0; i < chunks.length; ++i) {
  24629. var chunk = chunks[i];
  24630. if (beginChunk < 0) {
  24631. beginChunk = chunk;
  24632. }
  24633. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  24634. groupedChunks.push({
  24635. beginChunk: beginChunk,
  24636. endChunk: prevChunk + 1
  24637. });
  24638. beginChunk = chunk;
  24639. }
  24640. if (i + 1 === chunks.length) {
  24641. groupedChunks.push({
  24642. beginChunk: beginChunk,
  24643. endChunk: chunk + 1
  24644. });
  24645. }
  24646. prevChunk = chunk;
  24647. }
  24648. return groupedChunks;
  24649. },
  24650. onProgress: function ChunkedStreamManager_onProgress(args) {
  24651. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  24652. this.msgHandler.send('DocProgress', {
  24653. loaded: bytesLoaded,
  24654. total: this.length
  24655. });
  24656. },
  24657. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  24658. var chunk = args.chunk;
  24659. var isProgressive = args.begin === undefined;
  24660. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  24661. var end = begin + chunk.byteLength;
  24662. var beginChunk = Math.floor(begin / this.chunkSize);
  24663. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  24664. if (isProgressive) {
  24665. this.stream.onReceiveProgressiveData(chunk);
  24666. this.progressiveDataLength = end;
  24667. } else {
  24668. this.stream.onReceiveData(begin, chunk);
  24669. }
  24670. if (this.stream.allChunksLoaded()) {
  24671. this._loadedStreamCapability.resolve(this.stream);
  24672. }
  24673. var loadedRequests = [];
  24674. var i, requestId;
  24675. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  24676. var requestIds = this.requestsByChunk[chunk] || [];
  24677. delete this.requestsByChunk[chunk];
  24678. for (i = 0; i < requestIds.length; ++i) {
  24679. requestId = requestIds[i];
  24680. var chunksNeeded = this.chunksNeededByRequest[requestId];
  24681. if (chunk in chunksNeeded) {
  24682. delete chunksNeeded[chunk];
  24683. }
  24684. if (!isEmptyObj(chunksNeeded)) {
  24685. continue;
  24686. }
  24687. loadedRequests.push(requestId);
  24688. }
  24689. }
  24690. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  24691. var nextEmptyChunk;
  24692. if (this.stream.numChunksLoaded === 1) {
  24693. var lastChunk = this.stream.numChunks - 1;
  24694. if (!this.stream.hasChunk(lastChunk)) {
  24695. nextEmptyChunk = lastChunk;
  24696. }
  24697. } else {
  24698. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  24699. }
  24700. if (isInt(nextEmptyChunk)) {
  24701. this._requestChunks([nextEmptyChunk]);
  24702. }
  24703. }
  24704. for (i = 0; i < loadedRequests.length; ++i) {
  24705. requestId = loadedRequests[i];
  24706. var capability = this.promisesByRequest[requestId];
  24707. delete this.promisesByRequest[requestId];
  24708. capability.resolve();
  24709. }
  24710. this.msgHandler.send('DocProgress', {
  24711. loaded: this.stream.numChunksLoaded * this.chunkSize,
  24712. total: this.length
  24713. });
  24714. },
  24715. onError: function ChunkedStreamManager_onError(err) {
  24716. this._loadedStreamCapability.reject(err);
  24717. },
  24718. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  24719. var chunk = Math.floor(begin / this.chunkSize);
  24720. return chunk;
  24721. },
  24722. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  24723. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  24724. return chunk;
  24725. },
  24726. abort: function ChunkedStreamManager_abort() {
  24727. this.aborted = true;
  24728. if (this.pdfNetworkStream) {
  24729. this.pdfNetworkStream.cancelAllRequests('abort');
  24730. }
  24731. for (var requestId in this.promisesByRequest) {
  24732. var capability = this.promisesByRequest[requestId];
  24733. capability.reject(new Error('Request was aborted'));
  24734. }
  24735. }
  24736. };
  24737. return ChunkedStreamManager;
  24738. }();
  24739. exports.ChunkedStream = ChunkedStream;
  24740. exports.ChunkedStreamManager = ChunkedStreamManager;
  24741. /***/ }),
  24742. /* 17 */
  24743. /***/ (function(module, exports, __w_pdfjs_require__) {
  24744. "use strict";
  24745. var sharedUtil = __w_pdfjs_require__(0);
  24746. var corePrimitives = __w_pdfjs_require__(1);
  24747. var coreStream = __w_pdfjs_require__(2);
  24748. var PasswordException = sharedUtil.PasswordException;
  24749. var PasswordResponses = sharedUtil.PasswordResponses;
  24750. var bytesToString = sharedUtil.bytesToString;
  24751. var warn = sharedUtil.warn;
  24752. var error = sharedUtil.error;
  24753. var assert = sharedUtil.assert;
  24754. var isInt = sharedUtil.isInt;
  24755. var stringToBytes = sharedUtil.stringToBytes;
  24756. var utf8StringToString = sharedUtil.utf8StringToString;
  24757. var Name = corePrimitives.Name;
  24758. var isName = corePrimitives.isName;
  24759. var isDict = corePrimitives.isDict;
  24760. var DecryptStream = coreStream.DecryptStream;
  24761. var ARCFourCipher = function ARCFourCipherClosure() {
  24762. function ARCFourCipher(key) {
  24763. this.a = 0;
  24764. this.b = 0;
  24765. var s = new Uint8Array(256);
  24766. var i, j = 0, tmp, keyLength = key.length;
  24767. for (i = 0; i < 256; ++i) {
  24768. s[i] = i;
  24769. }
  24770. for (i = 0; i < 256; ++i) {
  24771. tmp = s[i];
  24772. j = j + tmp + key[i % keyLength] & 0xFF;
  24773. s[i] = s[j];
  24774. s[j] = tmp;
  24775. }
  24776. this.s = s;
  24777. }
  24778. ARCFourCipher.prototype = {
  24779. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  24780. var i, n = data.length, tmp, tmp2;
  24781. var a = this.a, b = this.b, s = this.s;
  24782. var output = new Uint8Array(n);
  24783. for (i = 0; i < n; ++i) {
  24784. a = a + 1 & 0xFF;
  24785. tmp = s[a];
  24786. b = b + tmp & 0xFF;
  24787. tmp2 = s[b];
  24788. s[a] = tmp2;
  24789. s[b] = tmp;
  24790. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  24791. }
  24792. this.a = a;
  24793. this.b = b;
  24794. return output;
  24795. }
  24796. };
  24797. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  24798. return ARCFourCipher;
  24799. }();
  24800. var calculateMD5 = function calculateMD5Closure() {
  24801. var r = new Uint8Array([
  24802. 7,
  24803. 12,
  24804. 17,
  24805. 22,
  24806. 7,
  24807. 12,
  24808. 17,
  24809. 22,
  24810. 7,
  24811. 12,
  24812. 17,
  24813. 22,
  24814. 7,
  24815. 12,
  24816. 17,
  24817. 22,
  24818. 5,
  24819. 9,
  24820. 14,
  24821. 20,
  24822. 5,
  24823. 9,
  24824. 14,
  24825. 20,
  24826. 5,
  24827. 9,
  24828. 14,
  24829. 20,
  24830. 5,
  24831. 9,
  24832. 14,
  24833. 20,
  24834. 4,
  24835. 11,
  24836. 16,
  24837. 23,
  24838. 4,
  24839. 11,
  24840. 16,
  24841. 23,
  24842. 4,
  24843. 11,
  24844. 16,
  24845. 23,
  24846. 4,
  24847. 11,
  24848. 16,
  24849. 23,
  24850. 6,
  24851. 10,
  24852. 15,
  24853. 21,
  24854. 6,
  24855. 10,
  24856. 15,
  24857. 21,
  24858. 6,
  24859. 10,
  24860. 15,
  24861. 21,
  24862. 6,
  24863. 10,
  24864. 15,
  24865. 21
  24866. ]);
  24867. var k = new Int32Array([
  24868. -680876936,
  24869. -389564586,
  24870. 606105819,
  24871. -1044525330,
  24872. -176418897,
  24873. 1200080426,
  24874. -1473231341,
  24875. -45705983,
  24876. 1770035416,
  24877. -1958414417,
  24878. -42063,
  24879. -1990404162,
  24880. 1804603682,
  24881. -40341101,
  24882. -1502002290,
  24883. 1236535329,
  24884. -165796510,
  24885. -1069501632,
  24886. 643717713,
  24887. -373897302,
  24888. -701558691,
  24889. 38016083,
  24890. -660478335,
  24891. -405537848,
  24892. 568446438,
  24893. -1019803690,
  24894. -187363961,
  24895. 1163531501,
  24896. -1444681467,
  24897. -51403784,
  24898. 1735328473,
  24899. -1926607734,
  24900. -378558,
  24901. -2022574463,
  24902. 1839030562,
  24903. -35309556,
  24904. -1530992060,
  24905. 1272893353,
  24906. -155497632,
  24907. -1094730640,
  24908. 681279174,
  24909. -358537222,
  24910. -722521979,
  24911. 76029189,
  24912. -640364487,
  24913. -421815835,
  24914. 530742520,
  24915. -995338651,
  24916. -198630844,
  24917. 1126891415,
  24918. -1416354905,
  24919. -57434055,
  24920. 1700485571,
  24921. -1894986606,
  24922. -1051523,
  24923. -2054922799,
  24924. 1873313359,
  24925. -30611744,
  24926. -1560198380,
  24927. 1309151649,
  24928. -145523070,
  24929. -1120210379,
  24930. 718787259,
  24931. -343485551
  24932. ]);
  24933. function hash(data, offset, length) {
  24934. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  24935. var paddedLength = length + 72 & ~63;
  24936. var padded = new Uint8Array(paddedLength);
  24937. var i, j, n;
  24938. for (i = 0; i < length; ++i) {
  24939. padded[i] = data[offset++];
  24940. }
  24941. padded[i++] = 0x80;
  24942. n = paddedLength - 8;
  24943. while (i < n) {
  24944. padded[i++] = 0;
  24945. }
  24946. padded[i++] = length << 3 & 0xFF;
  24947. padded[i++] = length >> 5 & 0xFF;
  24948. padded[i++] = length >> 13 & 0xFF;
  24949. padded[i++] = length >> 21 & 0xFF;
  24950. padded[i++] = length >>> 29 & 0xFF;
  24951. padded[i++] = 0;
  24952. padded[i++] = 0;
  24953. padded[i++] = 0;
  24954. var w = new Int32Array(16);
  24955. for (i = 0; i < paddedLength;) {
  24956. for (j = 0; j < 16; ++j, i += 4) {
  24957. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  24958. }
  24959. var a = h0, b = h1, c = h2, d = h3, f, g;
  24960. for (j = 0; j < 64; ++j) {
  24961. if (j < 16) {
  24962. f = b & c | ~b & d;
  24963. g = j;
  24964. } else if (j < 32) {
  24965. f = d & b | ~d & c;
  24966. g = 5 * j + 1 & 15;
  24967. } else if (j < 48) {
  24968. f = b ^ c ^ d;
  24969. g = 3 * j + 5 & 15;
  24970. } else {
  24971. f = c ^ (b | ~d);
  24972. g = 7 * j & 15;
  24973. }
  24974. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  24975. d = c;
  24976. c = b;
  24977. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  24978. a = tmp;
  24979. }
  24980. h0 = h0 + a | 0;
  24981. h1 = h1 + b | 0;
  24982. h2 = h2 + c | 0;
  24983. h3 = h3 + d | 0;
  24984. }
  24985. return new Uint8Array([
  24986. h0 & 0xFF,
  24987. h0 >> 8 & 0xFF,
  24988. h0 >> 16 & 0xFF,
  24989. h0 >>> 24 & 0xFF,
  24990. h1 & 0xFF,
  24991. h1 >> 8 & 0xFF,
  24992. h1 >> 16 & 0xFF,
  24993. h1 >>> 24 & 0xFF,
  24994. h2 & 0xFF,
  24995. h2 >> 8 & 0xFF,
  24996. h2 >> 16 & 0xFF,
  24997. h2 >>> 24 & 0xFF,
  24998. h3 & 0xFF,
  24999. h3 >> 8 & 0xFF,
  25000. h3 >> 16 & 0xFF,
  25001. h3 >>> 24 & 0xFF
  25002. ]);
  25003. }
  25004. return hash;
  25005. }();
  25006. var Word64 = function Word64Closure() {
  25007. function Word64(highInteger, lowInteger) {
  25008. this.high = highInteger | 0;
  25009. this.low = lowInteger | 0;
  25010. }
  25011. Word64.prototype = {
  25012. and: function Word64_and(word) {
  25013. this.high &= word.high;
  25014. this.low &= word.low;
  25015. },
  25016. xor: function Word64_xor(word) {
  25017. this.high ^= word.high;
  25018. this.low ^= word.low;
  25019. },
  25020. or: function Word64_or(word) {
  25021. this.high |= word.high;
  25022. this.low |= word.low;
  25023. },
  25024. shiftRight: function Word64_shiftRight(places) {
  25025. if (places >= 32) {
  25026. this.low = this.high >>> places - 32 | 0;
  25027. this.high = 0;
  25028. } else {
  25029. this.low = this.low >>> places | this.high << 32 - places;
  25030. this.high = this.high >>> places | 0;
  25031. }
  25032. },
  25033. shiftLeft: function Word64_shiftLeft(places) {
  25034. if (places >= 32) {
  25035. this.high = this.low << places - 32;
  25036. this.low = 0;
  25037. } else {
  25038. this.high = this.high << places | this.low >>> 32 - places;
  25039. this.low = this.low << places;
  25040. }
  25041. },
  25042. rotateRight: function Word64_rotateRight(places) {
  25043. var low, high;
  25044. if (places & 32) {
  25045. high = this.low;
  25046. low = this.high;
  25047. } else {
  25048. low = this.low;
  25049. high = this.high;
  25050. }
  25051. places &= 31;
  25052. this.low = low >>> places | high << 32 - places;
  25053. this.high = high >>> places | low << 32 - places;
  25054. },
  25055. not: function Word64_not() {
  25056. this.high = ~this.high;
  25057. this.low = ~this.low;
  25058. },
  25059. add: function Word64_add(word) {
  25060. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25061. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25062. if (lowAdd > 0xFFFFFFFF) {
  25063. highAdd += 1;
  25064. }
  25065. this.low = lowAdd | 0;
  25066. this.high = highAdd | 0;
  25067. },
  25068. copyTo: function Word64_copyTo(bytes, offset) {
  25069. bytes[offset] = this.high >>> 24 & 0xFF;
  25070. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25071. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25072. bytes[offset + 3] = this.high & 0xFF;
  25073. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25074. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25075. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25076. bytes[offset + 7] = this.low & 0xFF;
  25077. },
  25078. assign: function Word64_assign(word) {
  25079. this.high = word.high;
  25080. this.low = word.low;
  25081. }
  25082. };
  25083. return Word64;
  25084. }();
  25085. var calculateSHA256 = function calculateSHA256Closure() {
  25086. function rotr(x, n) {
  25087. return x >>> n | x << 32 - n;
  25088. }
  25089. function ch(x, y, z) {
  25090. return x & y ^ ~x & z;
  25091. }
  25092. function maj(x, y, z) {
  25093. return x & y ^ x & z ^ y & z;
  25094. }
  25095. function sigma(x) {
  25096. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25097. }
  25098. function sigmaPrime(x) {
  25099. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25100. }
  25101. function littleSigma(x) {
  25102. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25103. }
  25104. function littleSigmaPrime(x) {
  25105. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25106. }
  25107. var k = [
  25108. 0x428a2f98,
  25109. 0x71374491,
  25110. 0xb5c0fbcf,
  25111. 0xe9b5dba5,
  25112. 0x3956c25b,
  25113. 0x59f111f1,
  25114. 0x923f82a4,
  25115. 0xab1c5ed5,
  25116. 0xd807aa98,
  25117. 0x12835b01,
  25118. 0x243185be,
  25119. 0x550c7dc3,
  25120. 0x72be5d74,
  25121. 0x80deb1fe,
  25122. 0x9bdc06a7,
  25123. 0xc19bf174,
  25124. 0xe49b69c1,
  25125. 0xefbe4786,
  25126. 0x0fc19dc6,
  25127. 0x240ca1cc,
  25128. 0x2de92c6f,
  25129. 0x4a7484aa,
  25130. 0x5cb0a9dc,
  25131. 0x76f988da,
  25132. 0x983e5152,
  25133. 0xa831c66d,
  25134. 0xb00327c8,
  25135. 0xbf597fc7,
  25136. 0xc6e00bf3,
  25137. 0xd5a79147,
  25138. 0x06ca6351,
  25139. 0x14292967,
  25140. 0x27b70a85,
  25141. 0x2e1b2138,
  25142. 0x4d2c6dfc,
  25143. 0x53380d13,
  25144. 0x650a7354,
  25145. 0x766a0abb,
  25146. 0x81c2c92e,
  25147. 0x92722c85,
  25148. 0xa2bfe8a1,
  25149. 0xa81a664b,
  25150. 0xc24b8b70,
  25151. 0xc76c51a3,
  25152. 0xd192e819,
  25153. 0xd6990624,
  25154. 0xf40e3585,
  25155. 0x106aa070,
  25156. 0x19a4c116,
  25157. 0x1e376c08,
  25158. 0x2748774c,
  25159. 0x34b0bcb5,
  25160. 0x391c0cb3,
  25161. 0x4ed8aa4a,
  25162. 0x5b9cca4f,
  25163. 0x682e6ff3,
  25164. 0x748f82ee,
  25165. 0x78a5636f,
  25166. 0x84c87814,
  25167. 0x8cc70208,
  25168. 0x90befffa,
  25169. 0xa4506ceb,
  25170. 0xbef9a3f7,
  25171. 0xc67178f2
  25172. ];
  25173. function hash(data, offset, length) {
  25174. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25175. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25176. var padded = new Uint8Array(paddedLength);
  25177. var i, j, n;
  25178. for (i = 0; i < length; ++i) {
  25179. padded[i] = data[offset++];
  25180. }
  25181. padded[i++] = 0x80;
  25182. n = paddedLength - 8;
  25183. while (i < n) {
  25184. padded[i++] = 0;
  25185. }
  25186. padded[i++] = 0;
  25187. padded[i++] = 0;
  25188. padded[i++] = 0;
  25189. padded[i++] = length >>> 29 & 0xFF;
  25190. padded[i++] = length >> 21 & 0xFF;
  25191. padded[i++] = length >> 13 & 0xFF;
  25192. padded[i++] = length >> 5 & 0xFF;
  25193. padded[i++] = length << 3 & 0xFF;
  25194. var w = new Uint32Array(64);
  25195. for (i = 0; i < paddedLength;) {
  25196. for (j = 0; j < 16; ++j) {
  25197. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25198. i += 4;
  25199. }
  25200. for (j = 16; j < 64; ++j) {
  25201. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25202. }
  25203. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25204. for (j = 0; j < 64; ++j) {
  25205. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25206. t2 = sigma(a) + maj(a, b, c);
  25207. h = g;
  25208. g = f;
  25209. f = e;
  25210. e = d + t1 | 0;
  25211. d = c;
  25212. c = b;
  25213. b = a;
  25214. a = t1 + t2 | 0;
  25215. }
  25216. h0 = h0 + a | 0;
  25217. h1 = h1 + b | 0;
  25218. h2 = h2 + c | 0;
  25219. h3 = h3 + d | 0;
  25220. h4 = h4 + e | 0;
  25221. h5 = h5 + f | 0;
  25222. h6 = h6 + g | 0;
  25223. h7 = h7 + h | 0;
  25224. }
  25225. return new Uint8Array([
  25226. h0 >> 24 & 0xFF,
  25227. h0 >> 16 & 0xFF,
  25228. h0 >> 8 & 0xFF,
  25229. h0 & 0xFF,
  25230. h1 >> 24 & 0xFF,
  25231. h1 >> 16 & 0xFF,
  25232. h1 >> 8 & 0xFF,
  25233. h1 & 0xFF,
  25234. h2 >> 24 & 0xFF,
  25235. h2 >> 16 & 0xFF,
  25236. h2 >> 8 & 0xFF,
  25237. h2 & 0xFF,
  25238. h3 >> 24 & 0xFF,
  25239. h3 >> 16 & 0xFF,
  25240. h3 >> 8 & 0xFF,
  25241. h3 & 0xFF,
  25242. h4 >> 24 & 0xFF,
  25243. h4 >> 16 & 0xFF,
  25244. h4 >> 8 & 0xFF,
  25245. h4 & 0xFF,
  25246. h5 >> 24 & 0xFF,
  25247. h5 >> 16 & 0xFF,
  25248. h5 >> 8 & 0xFF,
  25249. h5 & 0xFF,
  25250. h6 >> 24 & 0xFF,
  25251. h6 >> 16 & 0xFF,
  25252. h6 >> 8 & 0xFF,
  25253. h6 & 0xFF,
  25254. h7 >> 24 & 0xFF,
  25255. h7 >> 16 & 0xFF,
  25256. h7 >> 8 & 0xFF,
  25257. h7 & 0xFF
  25258. ]);
  25259. }
  25260. return hash;
  25261. }();
  25262. var calculateSHA512 = function calculateSHA512Closure() {
  25263. function ch(result, x, y, z, tmp) {
  25264. result.assign(x);
  25265. result.and(y);
  25266. tmp.assign(x);
  25267. tmp.not();
  25268. tmp.and(z);
  25269. result.xor(tmp);
  25270. }
  25271. function maj(result, x, y, z, tmp) {
  25272. result.assign(x);
  25273. result.and(y);
  25274. tmp.assign(x);
  25275. tmp.and(z);
  25276. result.xor(tmp);
  25277. tmp.assign(y);
  25278. tmp.and(z);
  25279. result.xor(tmp);
  25280. }
  25281. function sigma(result, x, tmp) {
  25282. result.assign(x);
  25283. result.rotateRight(28);
  25284. tmp.assign(x);
  25285. tmp.rotateRight(34);
  25286. result.xor(tmp);
  25287. tmp.assign(x);
  25288. tmp.rotateRight(39);
  25289. result.xor(tmp);
  25290. }
  25291. function sigmaPrime(result, x, tmp) {
  25292. result.assign(x);
  25293. result.rotateRight(14);
  25294. tmp.assign(x);
  25295. tmp.rotateRight(18);
  25296. result.xor(tmp);
  25297. tmp.assign(x);
  25298. tmp.rotateRight(41);
  25299. result.xor(tmp);
  25300. }
  25301. function littleSigma(result, x, tmp) {
  25302. result.assign(x);
  25303. result.rotateRight(1);
  25304. tmp.assign(x);
  25305. tmp.rotateRight(8);
  25306. result.xor(tmp);
  25307. tmp.assign(x);
  25308. tmp.shiftRight(7);
  25309. result.xor(tmp);
  25310. }
  25311. function littleSigmaPrime(result, x, tmp) {
  25312. result.assign(x);
  25313. result.rotateRight(19);
  25314. tmp.assign(x);
  25315. tmp.rotateRight(61);
  25316. result.xor(tmp);
  25317. tmp.assign(x);
  25318. tmp.shiftRight(6);
  25319. result.xor(tmp);
  25320. }
  25321. var k = [
  25322. new Word64(0x428a2f98, 0xd728ae22),
  25323. new Word64(0x71374491, 0x23ef65cd),
  25324. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  25325. new Word64(0xe9b5dba5, 0x8189dbbc),
  25326. new Word64(0x3956c25b, 0xf348b538),
  25327. new Word64(0x59f111f1, 0xb605d019),
  25328. new Word64(0x923f82a4, 0xaf194f9b),
  25329. new Word64(0xab1c5ed5, 0xda6d8118),
  25330. new Word64(0xd807aa98, 0xa3030242),
  25331. new Word64(0x12835b01, 0x45706fbe),
  25332. new Word64(0x243185be, 0x4ee4b28c),
  25333. new Word64(0x550c7dc3, 0xd5ffb4e2),
  25334. new Word64(0x72be5d74, 0xf27b896f),
  25335. new Word64(0x80deb1fe, 0x3b1696b1),
  25336. new Word64(0x9bdc06a7, 0x25c71235),
  25337. new Word64(0xc19bf174, 0xcf692694),
  25338. new Word64(0xe49b69c1, 0x9ef14ad2),
  25339. new Word64(0xefbe4786, 0x384f25e3),
  25340. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  25341. new Word64(0x240ca1cc, 0x77ac9c65),
  25342. new Word64(0x2de92c6f, 0x592b0275),
  25343. new Word64(0x4a7484aa, 0x6ea6e483),
  25344. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  25345. new Word64(0x76f988da, 0x831153b5),
  25346. new Word64(0x983e5152, 0xee66dfab),
  25347. new Word64(0xa831c66d, 0x2db43210),
  25348. new Word64(0xb00327c8, 0x98fb213f),
  25349. new Word64(0xbf597fc7, 0xbeef0ee4),
  25350. new Word64(0xc6e00bf3, 0x3da88fc2),
  25351. new Word64(0xd5a79147, 0x930aa725),
  25352. new Word64(0x06ca6351, 0xe003826f),
  25353. new Word64(0x14292967, 0x0a0e6e70),
  25354. new Word64(0x27b70a85, 0x46d22ffc),
  25355. new Word64(0x2e1b2138, 0x5c26c926),
  25356. new Word64(0x4d2c6dfc, 0x5ac42aed),
  25357. new Word64(0x53380d13, 0x9d95b3df),
  25358. new Word64(0x650a7354, 0x8baf63de),
  25359. new Word64(0x766a0abb, 0x3c77b2a8),
  25360. new Word64(0x81c2c92e, 0x47edaee6),
  25361. new Word64(0x92722c85, 0x1482353b),
  25362. new Word64(0xa2bfe8a1, 0x4cf10364),
  25363. new Word64(0xa81a664b, 0xbc423001),
  25364. new Word64(0xc24b8b70, 0xd0f89791),
  25365. new Word64(0xc76c51a3, 0x0654be30),
  25366. new Word64(0xd192e819, 0xd6ef5218),
  25367. new Word64(0xd6990624, 0x5565a910),
  25368. new Word64(0xf40e3585, 0x5771202a),
  25369. new Word64(0x106aa070, 0x32bbd1b8),
  25370. new Word64(0x19a4c116, 0xb8d2d0c8),
  25371. new Word64(0x1e376c08, 0x5141ab53),
  25372. new Word64(0x2748774c, 0xdf8eeb99),
  25373. new Word64(0x34b0bcb5, 0xe19b48a8),
  25374. new Word64(0x391c0cb3, 0xc5c95a63),
  25375. new Word64(0x4ed8aa4a, 0xe3418acb),
  25376. new Word64(0x5b9cca4f, 0x7763e373),
  25377. new Word64(0x682e6ff3, 0xd6b2b8a3),
  25378. new Word64(0x748f82ee, 0x5defb2fc),
  25379. new Word64(0x78a5636f, 0x43172f60),
  25380. new Word64(0x84c87814, 0xa1f0ab72),
  25381. new Word64(0x8cc70208, 0x1a6439ec),
  25382. new Word64(0x90befffa, 0x23631e28),
  25383. new Word64(0xa4506ceb, 0xde82bde9),
  25384. new Word64(0xbef9a3f7, 0xb2c67915),
  25385. new Word64(0xc67178f2, 0xe372532b),
  25386. new Word64(0xca273ece, 0xea26619c),
  25387. new Word64(0xd186b8c7, 0x21c0c207),
  25388. new Word64(0xeada7dd6, 0xcde0eb1e),
  25389. new Word64(0xf57d4f7f, 0xee6ed178),
  25390. new Word64(0x06f067aa, 0x72176fba),
  25391. new Word64(0x0a637dc5, 0xa2c898a6),
  25392. new Word64(0x113f9804, 0xbef90dae),
  25393. new Word64(0x1b710b35, 0x131c471b),
  25394. new Word64(0x28db77f5, 0x23047d84),
  25395. new Word64(0x32caab7b, 0x40c72493),
  25396. new Word64(0x3c9ebe0a, 0x15c9bebc),
  25397. new Word64(0x431d67c4, 0x9c100d4c),
  25398. new Word64(0x4cc5d4be, 0xcb3e42b6),
  25399. new Word64(0x597f299c, 0xfc657e2a),
  25400. new Word64(0x5fcb6fab, 0x3ad6faec),
  25401. new Word64(0x6c44198c, 0x4a475817)
  25402. ];
  25403. function hash(data, offset, length, mode384) {
  25404. mode384 = !!mode384;
  25405. var h0, h1, h2, h3, h4, h5, h6, h7;
  25406. if (!mode384) {
  25407. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  25408. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  25409. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  25410. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  25411. h4 = new Word64(0x510e527f, 0xade682d1);
  25412. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  25413. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  25414. h7 = new Word64(0x5be0cd19, 0x137e2179);
  25415. } else {
  25416. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  25417. h1 = new Word64(0x629a292a, 0x367cd507);
  25418. h2 = new Word64(0x9159015a, 0x3070dd17);
  25419. h3 = new Word64(0x152fecd8, 0xf70e5939);
  25420. h4 = new Word64(0x67332667, 0xffc00b31);
  25421. h5 = new Word64(0x8eb44a87, 0x68581511);
  25422. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  25423. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  25424. }
  25425. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  25426. var padded = new Uint8Array(paddedLength);
  25427. var i, j, n;
  25428. for (i = 0; i < length; ++i) {
  25429. padded[i] = data[offset++];
  25430. }
  25431. padded[i++] = 0x80;
  25432. n = paddedLength - 16;
  25433. while (i < n) {
  25434. padded[i++] = 0;
  25435. }
  25436. padded[i++] = 0;
  25437. padded[i++] = 0;
  25438. padded[i++] = 0;
  25439. padded[i++] = 0;
  25440. padded[i++] = 0;
  25441. padded[i++] = 0;
  25442. padded[i++] = 0;
  25443. padded[i++] = 0;
  25444. padded[i++] = 0;
  25445. padded[i++] = 0;
  25446. padded[i++] = 0;
  25447. padded[i++] = length >>> 29 & 0xFF;
  25448. padded[i++] = length >> 21 & 0xFF;
  25449. padded[i++] = length >> 13 & 0xFF;
  25450. padded[i++] = length >> 5 & 0xFF;
  25451. padded[i++] = length << 3 & 0xFF;
  25452. var w = new Array(80);
  25453. for (i = 0; i < 80; i++) {
  25454. w[i] = new Word64(0, 0);
  25455. }
  25456. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  25457. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  25458. var g = new Word64(0, 0), h = new Word64(0, 0);
  25459. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  25460. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  25461. for (i = 0; i < paddedLength;) {
  25462. for (j = 0; j < 16; ++j) {
  25463. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25464. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  25465. i += 8;
  25466. }
  25467. for (j = 16; j < 80; ++j) {
  25468. tmp3 = w[j];
  25469. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  25470. tmp3.add(w[j - 7]);
  25471. littleSigma(tmp1, w[j - 15], tmp2);
  25472. tmp3.add(tmp1);
  25473. tmp3.add(w[j - 16]);
  25474. }
  25475. a.assign(h0);
  25476. b.assign(h1);
  25477. c.assign(h2);
  25478. d.assign(h3);
  25479. e.assign(h4);
  25480. f.assign(h5);
  25481. g.assign(h6);
  25482. h.assign(h7);
  25483. for (j = 0; j < 80; ++j) {
  25484. t1.assign(h);
  25485. sigmaPrime(tmp1, e, tmp2);
  25486. t1.add(tmp1);
  25487. ch(tmp1, e, f, g, tmp2);
  25488. t1.add(tmp1);
  25489. t1.add(k[j]);
  25490. t1.add(w[j]);
  25491. sigma(t2, a, tmp2);
  25492. maj(tmp1, a, b, c, tmp2);
  25493. t2.add(tmp1);
  25494. tmp3 = h;
  25495. h = g;
  25496. g = f;
  25497. f = e;
  25498. d.add(t1);
  25499. e = d;
  25500. d = c;
  25501. c = b;
  25502. b = a;
  25503. tmp3.assign(t1);
  25504. tmp3.add(t2);
  25505. a = tmp3;
  25506. }
  25507. h0.add(a);
  25508. h1.add(b);
  25509. h2.add(c);
  25510. h3.add(d);
  25511. h4.add(e);
  25512. h5.add(f);
  25513. h6.add(g);
  25514. h7.add(h);
  25515. }
  25516. var result;
  25517. if (!mode384) {
  25518. result = new Uint8Array(64);
  25519. h0.copyTo(result, 0);
  25520. h1.copyTo(result, 8);
  25521. h2.copyTo(result, 16);
  25522. h3.copyTo(result, 24);
  25523. h4.copyTo(result, 32);
  25524. h5.copyTo(result, 40);
  25525. h6.copyTo(result, 48);
  25526. h7.copyTo(result, 56);
  25527. } else {
  25528. result = new Uint8Array(48);
  25529. h0.copyTo(result, 0);
  25530. h1.copyTo(result, 8);
  25531. h2.copyTo(result, 16);
  25532. h3.copyTo(result, 24);
  25533. h4.copyTo(result, 32);
  25534. h5.copyTo(result, 40);
  25535. }
  25536. return result;
  25537. }
  25538. return hash;
  25539. }();
  25540. var calculateSHA384 = function calculateSHA384Closure() {
  25541. function hash(data, offset, length) {
  25542. return calculateSHA512(data, offset, length, true);
  25543. }
  25544. return hash;
  25545. }();
  25546. var NullCipher = function NullCipherClosure() {
  25547. function NullCipher() {
  25548. }
  25549. NullCipher.prototype = {
  25550. decryptBlock: function NullCipher_decryptBlock(data) {
  25551. return data;
  25552. }
  25553. };
  25554. return NullCipher;
  25555. }();
  25556. var AES128Cipher = function AES128CipherClosure() {
  25557. var rcon = new Uint8Array([
  25558. 0x8d,
  25559. 0x01,
  25560. 0x02,
  25561. 0x04,
  25562. 0x08,
  25563. 0x10,
  25564. 0x20,
  25565. 0x40,
  25566. 0x80,
  25567. 0x1b,
  25568. 0x36,
  25569. 0x6c,
  25570. 0xd8,
  25571. 0xab,
  25572. 0x4d,
  25573. 0x9a,
  25574. 0x2f,
  25575. 0x5e,
  25576. 0xbc,
  25577. 0x63,
  25578. 0xc6,
  25579. 0x97,
  25580. 0x35,
  25581. 0x6a,
  25582. 0xd4,
  25583. 0xb3,
  25584. 0x7d,
  25585. 0xfa,
  25586. 0xef,
  25587. 0xc5,
  25588. 0x91,
  25589. 0x39,
  25590. 0x72,
  25591. 0xe4,
  25592. 0xd3,
  25593. 0xbd,
  25594. 0x61,
  25595. 0xc2,
  25596. 0x9f,
  25597. 0x25,
  25598. 0x4a,
  25599. 0x94,
  25600. 0x33,
  25601. 0x66,
  25602. 0xcc,
  25603. 0x83,
  25604. 0x1d,
  25605. 0x3a,
  25606. 0x74,
  25607. 0xe8,
  25608. 0xcb,
  25609. 0x8d,
  25610. 0x01,
  25611. 0x02,
  25612. 0x04,
  25613. 0x08,
  25614. 0x10,
  25615. 0x20,
  25616. 0x40,
  25617. 0x80,
  25618. 0x1b,
  25619. 0x36,
  25620. 0x6c,
  25621. 0xd8,
  25622. 0xab,
  25623. 0x4d,
  25624. 0x9a,
  25625. 0x2f,
  25626. 0x5e,
  25627. 0xbc,
  25628. 0x63,
  25629. 0xc6,
  25630. 0x97,
  25631. 0x35,
  25632. 0x6a,
  25633. 0xd4,
  25634. 0xb3,
  25635. 0x7d,
  25636. 0xfa,
  25637. 0xef,
  25638. 0xc5,
  25639. 0x91,
  25640. 0x39,
  25641. 0x72,
  25642. 0xe4,
  25643. 0xd3,
  25644. 0xbd,
  25645. 0x61,
  25646. 0xc2,
  25647. 0x9f,
  25648. 0x25,
  25649. 0x4a,
  25650. 0x94,
  25651. 0x33,
  25652. 0x66,
  25653. 0xcc,
  25654. 0x83,
  25655. 0x1d,
  25656. 0x3a,
  25657. 0x74,
  25658. 0xe8,
  25659. 0xcb,
  25660. 0x8d,
  25661. 0x01,
  25662. 0x02,
  25663. 0x04,
  25664. 0x08,
  25665. 0x10,
  25666. 0x20,
  25667. 0x40,
  25668. 0x80,
  25669. 0x1b,
  25670. 0x36,
  25671. 0x6c,
  25672. 0xd8,
  25673. 0xab,
  25674. 0x4d,
  25675. 0x9a,
  25676. 0x2f,
  25677. 0x5e,
  25678. 0xbc,
  25679. 0x63,
  25680. 0xc6,
  25681. 0x97,
  25682. 0x35,
  25683. 0x6a,
  25684. 0xd4,
  25685. 0xb3,
  25686. 0x7d,
  25687. 0xfa,
  25688. 0xef,
  25689. 0xc5,
  25690. 0x91,
  25691. 0x39,
  25692. 0x72,
  25693. 0xe4,
  25694. 0xd3,
  25695. 0xbd,
  25696. 0x61,
  25697. 0xc2,
  25698. 0x9f,
  25699. 0x25,
  25700. 0x4a,
  25701. 0x94,
  25702. 0x33,
  25703. 0x66,
  25704. 0xcc,
  25705. 0x83,
  25706. 0x1d,
  25707. 0x3a,
  25708. 0x74,
  25709. 0xe8,
  25710. 0xcb,
  25711. 0x8d,
  25712. 0x01,
  25713. 0x02,
  25714. 0x04,
  25715. 0x08,
  25716. 0x10,
  25717. 0x20,
  25718. 0x40,
  25719. 0x80,
  25720. 0x1b,
  25721. 0x36,
  25722. 0x6c,
  25723. 0xd8,
  25724. 0xab,
  25725. 0x4d,
  25726. 0x9a,
  25727. 0x2f,
  25728. 0x5e,
  25729. 0xbc,
  25730. 0x63,
  25731. 0xc6,
  25732. 0x97,
  25733. 0x35,
  25734. 0x6a,
  25735. 0xd4,
  25736. 0xb3,
  25737. 0x7d,
  25738. 0xfa,
  25739. 0xef,
  25740. 0xc5,
  25741. 0x91,
  25742. 0x39,
  25743. 0x72,
  25744. 0xe4,
  25745. 0xd3,
  25746. 0xbd,
  25747. 0x61,
  25748. 0xc2,
  25749. 0x9f,
  25750. 0x25,
  25751. 0x4a,
  25752. 0x94,
  25753. 0x33,
  25754. 0x66,
  25755. 0xcc,
  25756. 0x83,
  25757. 0x1d,
  25758. 0x3a,
  25759. 0x74,
  25760. 0xe8,
  25761. 0xcb,
  25762. 0x8d,
  25763. 0x01,
  25764. 0x02,
  25765. 0x04,
  25766. 0x08,
  25767. 0x10,
  25768. 0x20,
  25769. 0x40,
  25770. 0x80,
  25771. 0x1b,
  25772. 0x36,
  25773. 0x6c,
  25774. 0xd8,
  25775. 0xab,
  25776. 0x4d,
  25777. 0x9a,
  25778. 0x2f,
  25779. 0x5e,
  25780. 0xbc,
  25781. 0x63,
  25782. 0xc6,
  25783. 0x97,
  25784. 0x35,
  25785. 0x6a,
  25786. 0xd4,
  25787. 0xb3,
  25788. 0x7d,
  25789. 0xfa,
  25790. 0xef,
  25791. 0xc5,
  25792. 0x91,
  25793. 0x39,
  25794. 0x72,
  25795. 0xe4,
  25796. 0xd3,
  25797. 0xbd,
  25798. 0x61,
  25799. 0xc2,
  25800. 0x9f,
  25801. 0x25,
  25802. 0x4a,
  25803. 0x94,
  25804. 0x33,
  25805. 0x66,
  25806. 0xcc,
  25807. 0x83,
  25808. 0x1d,
  25809. 0x3a,
  25810. 0x74,
  25811. 0xe8,
  25812. 0xcb,
  25813. 0x8d
  25814. ]);
  25815. var s = new Uint8Array([
  25816. 0x63,
  25817. 0x7c,
  25818. 0x77,
  25819. 0x7b,
  25820. 0xf2,
  25821. 0x6b,
  25822. 0x6f,
  25823. 0xc5,
  25824. 0x30,
  25825. 0x01,
  25826. 0x67,
  25827. 0x2b,
  25828. 0xfe,
  25829. 0xd7,
  25830. 0xab,
  25831. 0x76,
  25832. 0xca,
  25833. 0x82,
  25834. 0xc9,
  25835. 0x7d,
  25836. 0xfa,
  25837. 0x59,
  25838. 0x47,
  25839. 0xf0,
  25840. 0xad,
  25841. 0xd4,
  25842. 0xa2,
  25843. 0xaf,
  25844. 0x9c,
  25845. 0xa4,
  25846. 0x72,
  25847. 0xc0,
  25848. 0xb7,
  25849. 0xfd,
  25850. 0x93,
  25851. 0x26,
  25852. 0x36,
  25853. 0x3f,
  25854. 0xf7,
  25855. 0xcc,
  25856. 0x34,
  25857. 0xa5,
  25858. 0xe5,
  25859. 0xf1,
  25860. 0x71,
  25861. 0xd8,
  25862. 0x31,
  25863. 0x15,
  25864. 0x04,
  25865. 0xc7,
  25866. 0x23,
  25867. 0xc3,
  25868. 0x18,
  25869. 0x96,
  25870. 0x05,
  25871. 0x9a,
  25872. 0x07,
  25873. 0x12,
  25874. 0x80,
  25875. 0xe2,
  25876. 0xeb,
  25877. 0x27,
  25878. 0xb2,
  25879. 0x75,
  25880. 0x09,
  25881. 0x83,
  25882. 0x2c,
  25883. 0x1a,
  25884. 0x1b,
  25885. 0x6e,
  25886. 0x5a,
  25887. 0xa0,
  25888. 0x52,
  25889. 0x3b,
  25890. 0xd6,
  25891. 0xb3,
  25892. 0x29,
  25893. 0xe3,
  25894. 0x2f,
  25895. 0x84,
  25896. 0x53,
  25897. 0xd1,
  25898. 0x00,
  25899. 0xed,
  25900. 0x20,
  25901. 0xfc,
  25902. 0xb1,
  25903. 0x5b,
  25904. 0x6a,
  25905. 0xcb,
  25906. 0xbe,
  25907. 0x39,
  25908. 0x4a,
  25909. 0x4c,
  25910. 0x58,
  25911. 0xcf,
  25912. 0xd0,
  25913. 0xef,
  25914. 0xaa,
  25915. 0xfb,
  25916. 0x43,
  25917. 0x4d,
  25918. 0x33,
  25919. 0x85,
  25920. 0x45,
  25921. 0xf9,
  25922. 0x02,
  25923. 0x7f,
  25924. 0x50,
  25925. 0x3c,
  25926. 0x9f,
  25927. 0xa8,
  25928. 0x51,
  25929. 0xa3,
  25930. 0x40,
  25931. 0x8f,
  25932. 0x92,
  25933. 0x9d,
  25934. 0x38,
  25935. 0xf5,
  25936. 0xbc,
  25937. 0xb6,
  25938. 0xda,
  25939. 0x21,
  25940. 0x10,
  25941. 0xff,
  25942. 0xf3,
  25943. 0xd2,
  25944. 0xcd,
  25945. 0x0c,
  25946. 0x13,
  25947. 0xec,
  25948. 0x5f,
  25949. 0x97,
  25950. 0x44,
  25951. 0x17,
  25952. 0xc4,
  25953. 0xa7,
  25954. 0x7e,
  25955. 0x3d,
  25956. 0x64,
  25957. 0x5d,
  25958. 0x19,
  25959. 0x73,
  25960. 0x60,
  25961. 0x81,
  25962. 0x4f,
  25963. 0xdc,
  25964. 0x22,
  25965. 0x2a,
  25966. 0x90,
  25967. 0x88,
  25968. 0x46,
  25969. 0xee,
  25970. 0xb8,
  25971. 0x14,
  25972. 0xde,
  25973. 0x5e,
  25974. 0x0b,
  25975. 0xdb,
  25976. 0xe0,
  25977. 0x32,
  25978. 0x3a,
  25979. 0x0a,
  25980. 0x49,
  25981. 0x06,
  25982. 0x24,
  25983. 0x5c,
  25984. 0xc2,
  25985. 0xd3,
  25986. 0xac,
  25987. 0x62,
  25988. 0x91,
  25989. 0x95,
  25990. 0xe4,
  25991. 0x79,
  25992. 0xe7,
  25993. 0xc8,
  25994. 0x37,
  25995. 0x6d,
  25996. 0x8d,
  25997. 0xd5,
  25998. 0x4e,
  25999. 0xa9,
  26000. 0x6c,
  26001. 0x56,
  26002. 0xf4,
  26003. 0xea,
  26004. 0x65,
  26005. 0x7a,
  26006. 0xae,
  26007. 0x08,
  26008. 0xba,
  26009. 0x78,
  26010. 0x25,
  26011. 0x2e,
  26012. 0x1c,
  26013. 0xa6,
  26014. 0xb4,
  26015. 0xc6,
  26016. 0xe8,
  26017. 0xdd,
  26018. 0x74,
  26019. 0x1f,
  26020. 0x4b,
  26021. 0xbd,
  26022. 0x8b,
  26023. 0x8a,
  26024. 0x70,
  26025. 0x3e,
  26026. 0xb5,
  26027. 0x66,
  26028. 0x48,
  26029. 0x03,
  26030. 0xf6,
  26031. 0x0e,
  26032. 0x61,
  26033. 0x35,
  26034. 0x57,
  26035. 0xb9,
  26036. 0x86,
  26037. 0xc1,
  26038. 0x1d,
  26039. 0x9e,
  26040. 0xe1,
  26041. 0xf8,
  26042. 0x98,
  26043. 0x11,
  26044. 0x69,
  26045. 0xd9,
  26046. 0x8e,
  26047. 0x94,
  26048. 0x9b,
  26049. 0x1e,
  26050. 0x87,
  26051. 0xe9,
  26052. 0xce,
  26053. 0x55,
  26054. 0x28,
  26055. 0xdf,
  26056. 0x8c,
  26057. 0xa1,
  26058. 0x89,
  26059. 0x0d,
  26060. 0xbf,
  26061. 0xe6,
  26062. 0x42,
  26063. 0x68,
  26064. 0x41,
  26065. 0x99,
  26066. 0x2d,
  26067. 0x0f,
  26068. 0xb0,
  26069. 0x54,
  26070. 0xbb,
  26071. 0x16
  26072. ]);
  26073. var inv_s = new Uint8Array([
  26074. 0x52,
  26075. 0x09,
  26076. 0x6a,
  26077. 0xd5,
  26078. 0x30,
  26079. 0x36,
  26080. 0xa5,
  26081. 0x38,
  26082. 0xbf,
  26083. 0x40,
  26084. 0xa3,
  26085. 0x9e,
  26086. 0x81,
  26087. 0xf3,
  26088. 0xd7,
  26089. 0xfb,
  26090. 0x7c,
  26091. 0xe3,
  26092. 0x39,
  26093. 0x82,
  26094. 0x9b,
  26095. 0x2f,
  26096. 0xff,
  26097. 0x87,
  26098. 0x34,
  26099. 0x8e,
  26100. 0x43,
  26101. 0x44,
  26102. 0xc4,
  26103. 0xde,
  26104. 0xe9,
  26105. 0xcb,
  26106. 0x54,
  26107. 0x7b,
  26108. 0x94,
  26109. 0x32,
  26110. 0xa6,
  26111. 0xc2,
  26112. 0x23,
  26113. 0x3d,
  26114. 0xee,
  26115. 0x4c,
  26116. 0x95,
  26117. 0x0b,
  26118. 0x42,
  26119. 0xfa,
  26120. 0xc3,
  26121. 0x4e,
  26122. 0x08,
  26123. 0x2e,
  26124. 0xa1,
  26125. 0x66,
  26126. 0x28,
  26127. 0xd9,
  26128. 0x24,
  26129. 0xb2,
  26130. 0x76,
  26131. 0x5b,
  26132. 0xa2,
  26133. 0x49,
  26134. 0x6d,
  26135. 0x8b,
  26136. 0xd1,
  26137. 0x25,
  26138. 0x72,
  26139. 0xf8,
  26140. 0xf6,
  26141. 0x64,
  26142. 0x86,
  26143. 0x68,
  26144. 0x98,
  26145. 0x16,
  26146. 0xd4,
  26147. 0xa4,
  26148. 0x5c,
  26149. 0xcc,
  26150. 0x5d,
  26151. 0x65,
  26152. 0xb6,
  26153. 0x92,
  26154. 0x6c,
  26155. 0x70,
  26156. 0x48,
  26157. 0x50,
  26158. 0xfd,
  26159. 0xed,
  26160. 0xb9,
  26161. 0xda,
  26162. 0x5e,
  26163. 0x15,
  26164. 0x46,
  26165. 0x57,
  26166. 0xa7,
  26167. 0x8d,
  26168. 0x9d,
  26169. 0x84,
  26170. 0x90,
  26171. 0xd8,
  26172. 0xab,
  26173. 0x00,
  26174. 0x8c,
  26175. 0xbc,
  26176. 0xd3,
  26177. 0x0a,
  26178. 0xf7,
  26179. 0xe4,
  26180. 0x58,
  26181. 0x05,
  26182. 0xb8,
  26183. 0xb3,
  26184. 0x45,
  26185. 0x06,
  26186. 0xd0,
  26187. 0x2c,
  26188. 0x1e,
  26189. 0x8f,
  26190. 0xca,
  26191. 0x3f,
  26192. 0x0f,
  26193. 0x02,
  26194. 0xc1,
  26195. 0xaf,
  26196. 0xbd,
  26197. 0x03,
  26198. 0x01,
  26199. 0x13,
  26200. 0x8a,
  26201. 0x6b,
  26202. 0x3a,
  26203. 0x91,
  26204. 0x11,
  26205. 0x41,
  26206. 0x4f,
  26207. 0x67,
  26208. 0xdc,
  26209. 0xea,
  26210. 0x97,
  26211. 0xf2,
  26212. 0xcf,
  26213. 0xce,
  26214. 0xf0,
  26215. 0xb4,
  26216. 0xe6,
  26217. 0x73,
  26218. 0x96,
  26219. 0xac,
  26220. 0x74,
  26221. 0x22,
  26222. 0xe7,
  26223. 0xad,
  26224. 0x35,
  26225. 0x85,
  26226. 0xe2,
  26227. 0xf9,
  26228. 0x37,
  26229. 0xe8,
  26230. 0x1c,
  26231. 0x75,
  26232. 0xdf,
  26233. 0x6e,
  26234. 0x47,
  26235. 0xf1,
  26236. 0x1a,
  26237. 0x71,
  26238. 0x1d,
  26239. 0x29,
  26240. 0xc5,
  26241. 0x89,
  26242. 0x6f,
  26243. 0xb7,
  26244. 0x62,
  26245. 0x0e,
  26246. 0xaa,
  26247. 0x18,
  26248. 0xbe,
  26249. 0x1b,
  26250. 0xfc,
  26251. 0x56,
  26252. 0x3e,
  26253. 0x4b,
  26254. 0xc6,
  26255. 0xd2,
  26256. 0x79,
  26257. 0x20,
  26258. 0x9a,
  26259. 0xdb,
  26260. 0xc0,
  26261. 0xfe,
  26262. 0x78,
  26263. 0xcd,
  26264. 0x5a,
  26265. 0xf4,
  26266. 0x1f,
  26267. 0xdd,
  26268. 0xa8,
  26269. 0x33,
  26270. 0x88,
  26271. 0x07,
  26272. 0xc7,
  26273. 0x31,
  26274. 0xb1,
  26275. 0x12,
  26276. 0x10,
  26277. 0x59,
  26278. 0x27,
  26279. 0x80,
  26280. 0xec,
  26281. 0x5f,
  26282. 0x60,
  26283. 0x51,
  26284. 0x7f,
  26285. 0xa9,
  26286. 0x19,
  26287. 0xb5,
  26288. 0x4a,
  26289. 0x0d,
  26290. 0x2d,
  26291. 0xe5,
  26292. 0x7a,
  26293. 0x9f,
  26294. 0x93,
  26295. 0xc9,
  26296. 0x9c,
  26297. 0xef,
  26298. 0xa0,
  26299. 0xe0,
  26300. 0x3b,
  26301. 0x4d,
  26302. 0xae,
  26303. 0x2a,
  26304. 0xf5,
  26305. 0xb0,
  26306. 0xc8,
  26307. 0xeb,
  26308. 0xbb,
  26309. 0x3c,
  26310. 0x83,
  26311. 0x53,
  26312. 0x99,
  26313. 0x61,
  26314. 0x17,
  26315. 0x2b,
  26316. 0x04,
  26317. 0x7e,
  26318. 0xba,
  26319. 0x77,
  26320. 0xd6,
  26321. 0x26,
  26322. 0xe1,
  26323. 0x69,
  26324. 0x14,
  26325. 0x63,
  26326. 0x55,
  26327. 0x21,
  26328. 0x0c,
  26329. 0x7d
  26330. ]);
  26331. var mixCol = new Uint8Array(256);
  26332. for (var i = 0; i < 256; i++) {
  26333. if (i < 128) {
  26334. mixCol[i] = i << 1;
  26335. } else {
  26336. mixCol[i] = i << 1 ^ 0x1b;
  26337. }
  26338. }
  26339. var mix = new Uint32Array([
  26340. 0x00000000,
  26341. 0x0e090d0b,
  26342. 0x1c121a16,
  26343. 0x121b171d,
  26344. 0x3824342c,
  26345. 0x362d3927,
  26346. 0x24362e3a,
  26347. 0x2a3f2331,
  26348. 0x70486858,
  26349. 0x7e416553,
  26350. 0x6c5a724e,
  26351. 0x62537f45,
  26352. 0x486c5c74,
  26353. 0x4665517f,
  26354. 0x547e4662,
  26355. 0x5a774b69,
  26356. 0xe090d0b0,
  26357. 0xee99ddbb,
  26358. 0xfc82caa6,
  26359. 0xf28bc7ad,
  26360. 0xd8b4e49c,
  26361. 0xd6bde997,
  26362. 0xc4a6fe8a,
  26363. 0xcaaff381,
  26364. 0x90d8b8e8,
  26365. 0x9ed1b5e3,
  26366. 0x8ccaa2fe,
  26367. 0x82c3aff5,
  26368. 0xa8fc8cc4,
  26369. 0xa6f581cf,
  26370. 0xb4ee96d2,
  26371. 0xbae79bd9,
  26372. 0xdb3bbb7b,
  26373. 0xd532b670,
  26374. 0xc729a16d,
  26375. 0xc920ac66,
  26376. 0xe31f8f57,
  26377. 0xed16825c,
  26378. 0xff0d9541,
  26379. 0xf104984a,
  26380. 0xab73d323,
  26381. 0xa57ade28,
  26382. 0xb761c935,
  26383. 0xb968c43e,
  26384. 0x9357e70f,
  26385. 0x9d5eea04,
  26386. 0x8f45fd19,
  26387. 0x814cf012,
  26388. 0x3bab6bcb,
  26389. 0x35a266c0,
  26390. 0x27b971dd,
  26391. 0x29b07cd6,
  26392. 0x038f5fe7,
  26393. 0x0d8652ec,
  26394. 0x1f9d45f1,
  26395. 0x119448fa,
  26396. 0x4be30393,
  26397. 0x45ea0e98,
  26398. 0x57f11985,
  26399. 0x59f8148e,
  26400. 0x73c737bf,
  26401. 0x7dce3ab4,
  26402. 0x6fd52da9,
  26403. 0x61dc20a2,
  26404. 0xad766df6,
  26405. 0xa37f60fd,
  26406. 0xb16477e0,
  26407. 0xbf6d7aeb,
  26408. 0x955259da,
  26409. 0x9b5b54d1,
  26410. 0x894043cc,
  26411. 0x87494ec7,
  26412. 0xdd3e05ae,
  26413. 0xd33708a5,
  26414. 0xc12c1fb8,
  26415. 0xcf2512b3,
  26416. 0xe51a3182,
  26417. 0xeb133c89,
  26418. 0xf9082b94,
  26419. 0xf701269f,
  26420. 0x4de6bd46,
  26421. 0x43efb04d,
  26422. 0x51f4a750,
  26423. 0x5ffdaa5b,
  26424. 0x75c2896a,
  26425. 0x7bcb8461,
  26426. 0x69d0937c,
  26427. 0x67d99e77,
  26428. 0x3daed51e,
  26429. 0x33a7d815,
  26430. 0x21bccf08,
  26431. 0x2fb5c203,
  26432. 0x058ae132,
  26433. 0x0b83ec39,
  26434. 0x1998fb24,
  26435. 0x1791f62f,
  26436. 0x764dd68d,
  26437. 0x7844db86,
  26438. 0x6a5fcc9b,
  26439. 0x6456c190,
  26440. 0x4e69e2a1,
  26441. 0x4060efaa,
  26442. 0x527bf8b7,
  26443. 0x5c72f5bc,
  26444. 0x0605bed5,
  26445. 0x080cb3de,
  26446. 0x1a17a4c3,
  26447. 0x141ea9c8,
  26448. 0x3e218af9,
  26449. 0x302887f2,
  26450. 0x223390ef,
  26451. 0x2c3a9de4,
  26452. 0x96dd063d,
  26453. 0x98d40b36,
  26454. 0x8acf1c2b,
  26455. 0x84c61120,
  26456. 0xaef93211,
  26457. 0xa0f03f1a,
  26458. 0xb2eb2807,
  26459. 0xbce2250c,
  26460. 0xe6956e65,
  26461. 0xe89c636e,
  26462. 0xfa877473,
  26463. 0xf48e7978,
  26464. 0xdeb15a49,
  26465. 0xd0b85742,
  26466. 0xc2a3405f,
  26467. 0xccaa4d54,
  26468. 0x41ecdaf7,
  26469. 0x4fe5d7fc,
  26470. 0x5dfec0e1,
  26471. 0x53f7cdea,
  26472. 0x79c8eedb,
  26473. 0x77c1e3d0,
  26474. 0x65daf4cd,
  26475. 0x6bd3f9c6,
  26476. 0x31a4b2af,
  26477. 0x3fadbfa4,
  26478. 0x2db6a8b9,
  26479. 0x23bfa5b2,
  26480. 0x09808683,
  26481. 0x07898b88,
  26482. 0x15929c95,
  26483. 0x1b9b919e,
  26484. 0xa17c0a47,
  26485. 0xaf75074c,
  26486. 0xbd6e1051,
  26487. 0xb3671d5a,
  26488. 0x99583e6b,
  26489. 0x97513360,
  26490. 0x854a247d,
  26491. 0x8b432976,
  26492. 0xd134621f,
  26493. 0xdf3d6f14,
  26494. 0xcd267809,
  26495. 0xc32f7502,
  26496. 0xe9105633,
  26497. 0xe7195b38,
  26498. 0xf5024c25,
  26499. 0xfb0b412e,
  26500. 0x9ad7618c,
  26501. 0x94de6c87,
  26502. 0x86c57b9a,
  26503. 0x88cc7691,
  26504. 0xa2f355a0,
  26505. 0xacfa58ab,
  26506. 0xbee14fb6,
  26507. 0xb0e842bd,
  26508. 0xea9f09d4,
  26509. 0xe49604df,
  26510. 0xf68d13c2,
  26511. 0xf8841ec9,
  26512. 0xd2bb3df8,
  26513. 0xdcb230f3,
  26514. 0xcea927ee,
  26515. 0xc0a02ae5,
  26516. 0x7a47b13c,
  26517. 0x744ebc37,
  26518. 0x6655ab2a,
  26519. 0x685ca621,
  26520. 0x42638510,
  26521. 0x4c6a881b,
  26522. 0x5e719f06,
  26523. 0x5078920d,
  26524. 0x0a0fd964,
  26525. 0x0406d46f,
  26526. 0x161dc372,
  26527. 0x1814ce79,
  26528. 0x322bed48,
  26529. 0x3c22e043,
  26530. 0x2e39f75e,
  26531. 0x2030fa55,
  26532. 0xec9ab701,
  26533. 0xe293ba0a,
  26534. 0xf088ad17,
  26535. 0xfe81a01c,
  26536. 0xd4be832d,
  26537. 0xdab78e26,
  26538. 0xc8ac993b,
  26539. 0xc6a59430,
  26540. 0x9cd2df59,
  26541. 0x92dbd252,
  26542. 0x80c0c54f,
  26543. 0x8ec9c844,
  26544. 0xa4f6eb75,
  26545. 0xaaffe67e,
  26546. 0xb8e4f163,
  26547. 0xb6edfc68,
  26548. 0x0c0a67b1,
  26549. 0x02036aba,
  26550. 0x10187da7,
  26551. 0x1e1170ac,
  26552. 0x342e539d,
  26553. 0x3a275e96,
  26554. 0x283c498b,
  26555. 0x26354480,
  26556. 0x7c420fe9,
  26557. 0x724b02e2,
  26558. 0x605015ff,
  26559. 0x6e5918f4,
  26560. 0x44663bc5,
  26561. 0x4a6f36ce,
  26562. 0x587421d3,
  26563. 0x567d2cd8,
  26564. 0x37a10c7a,
  26565. 0x39a80171,
  26566. 0x2bb3166c,
  26567. 0x25ba1b67,
  26568. 0x0f853856,
  26569. 0x018c355d,
  26570. 0x13972240,
  26571. 0x1d9e2f4b,
  26572. 0x47e96422,
  26573. 0x49e06929,
  26574. 0x5bfb7e34,
  26575. 0x55f2733f,
  26576. 0x7fcd500e,
  26577. 0x71c45d05,
  26578. 0x63df4a18,
  26579. 0x6dd64713,
  26580. 0xd731dcca,
  26581. 0xd938d1c1,
  26582. 0xcb23c6dc,
  26583. 0xc52acbd7,
  26584. 0xef15e8e6,
  26585. 0xe11ce5ed,
  26586. 0xf307f2f0,
  26587. 0xfd0efffb,
  26588. 0xa779b492,
  26589. 0xa970b999,
  26590. 0xbb6bae84,
  26591. 0xb562a38f,
  26592. 0x9f5d80be,
  26593. 0x91548db5,
  26594. 0x834f9aa8,
  26595. 0x8d4697a3
  26596. ]);
  26597. function expandKey128(cipherKey) {
  26598. var b = 176, result = new Uint8Array(b);
  26599. result.set(cipherKey);
  26600. for (var j = 16, i = 1; j < b; ++i) {
  26601. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  26602. t1 = s[t1];
  26603. t2 = s[t2];
  26604. t3 = s[t3];
  26605. t4 = s[t4];
  26606. t1 = t1 ^ rcon[i];
  26607. for (var n = 0; n < 4; ++n) {
  26608. result[j] = t1 ^= result[j - 16];
  26609. j++;
  26610. result[j] = t2 ^= result[j - 16];
  26611. j++;
  26612. result[j] = t3 ^= result[j - 16];
  26613. j++;
  26614. result[j] = t4 ^= result[j - 16];
  26615. j++;
  26616. }
  26617. }
  26618. return result;
  26619. }
  26620. function decrypt128(input, key) {
  26621. var state = new Uint8Array(16);
  26622. state.set(input);
  26623. var i, j, k;
  26624. var t, u, v;
  26625. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26626. state[j] ^= key[k];
  26627. }
  26628. for (i = 9; i >= 1; --i) {
  26629. t = state[13];
  26630. state[13] = state[9];
  26631. state[9] = state[5];
  26632. state[5] = state[1];
  26633. state[1] = t;
  26634. t = state[14];
  26635. u = state[10];
  26636. state[14] = state[6];
  26637. state[10] = state[2];
  26638. state[6] = t;
  26639. state[2] = u;
  26640. t = state[15];
  26641. u = state[11];
  26642. v = state[7];
  26643. state[15] = state[3];
  26644. state[11] = t;
  26645. state[7] = u;
  26646. state[3] = v;
  26647. for (j = 0; j < 16; ++j) {
  26648. state[j] = inv_s[state[j]];
  26649. }
  26650. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26651. state[j] ^= key[k];
  26652. }
  26653. for (j = 0; j < 16; j += 4) {
  26654. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  26655. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  26656. state[j] = t >>> 24 & 0xFF;
  26657. state[j + 1] = t >> 16 & 0xFF;
  26658. state[j + 2] = t >> 8 & 0xFF;
  26659. state[j + 3] = t & 0xFF;
  26660. }
  26661. }
  26662. t = state[13];
  26663. state[13] = state[9];
  26664. state[9] = state[5];
  26665. state[5] = state[1];
  26666. state[1] = t;
  26667. t = state[14];
  26668. u = state[10];
  26669. state[14] = state[6];
  26670. state[10] = state[2];
  26671. state[6] = t;
  26672. state[2] = u;
  26673. t = state[15];
  26674. u = state[11];
  26675. v = state[7];
  26676. state[15] = state[3];
  26677. state[11] = t;
  26678. state[7] = u;
  26679. state[3] = v;
  26680. for (j = 0; j < 16; ++j) {
  26681. state[j] = inv_s[state[j]];
  26682. state[j] ^= key[j];
  26683. }
  26684. return state;
  26685. }
  26686. function encrypt128(input, key) {
  26687. var t, u, v, k;
  26688. var state = new Uint8Array(16);
  26689. state.set(input);
  26690. for (j = 0; j < 16; ++j) {
  26691. state[j] ^= key[j];
  26692. }
  26693. for (i = 1; i < 10; i++) {
  26694. for (j = 0; j < 16; ++j) {
  26695. state[j] = s[state[j]];
  26696. }
  26697. v = state[1];
  26698. state[1] = state[5];
  26699. state[5] = state[9];
  26700. state[9] = state[13];
  26701. state[13] = v;
  26702. v = state[2];
  26703. u = state[6];
  26704. state[2] = state[10];
  26705. state[6] = state[14];
  26706. state[10] = v;
  26707. state[14] = u;
  26708. v = state[3];
  26709. u = state[7];
  26710. t = state[11];
  26711. state[3] = state[15];
  26712. state[7] = v;
  26713. state[11] = u;
  26714. state[15] = t;
  26715. for (var j = 0; j < 16; j += 4) {
  26716. var s0 = state[j + 0], s1 = state[j + 1];
  26717. var s2 = state[j + 2], s3 = state[j + 3];
  26718. t = s0 ^ s1 ^ s2 ^ s3;
  26719. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  26720. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  26721. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  26722. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  26723. }
  26724. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26725. state[j] ^= key[k];
  26726. }
  26727. }
  26728. for (j = 0; j < 16; ++j) {
  26729. state[j] = s[state[j]];
  26730. }
  26731. v = state[1];
  26732. state[1] = state[5];
  26733. state[5] = state[9];
  26734. state[9] = state[13];
  26735. state[13] = v;
  26736. v = state[2];
  26737. u = state[6];
  26738. state[2] = state[10];
  26739. state[6] = state[14];
  26740. state[10] = v;
  26741. state[14] = u;
  26742. v = state[3];
  26743. u = state[7];
  26744. t = state[11];
  26745. state[3] = state[15];
  26746. state[7] = v;
  26747. state[11] = u;
  26748. state[15] = t;
  26749. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26750. state[j] ^= key[k];
  26751. }
  26752. return state;
  26753. }
  26754. function AES128Cipher(key) {
  26755. this.key = expandKey128(key);
  26756. this.buffer = new Uint8Array(16);
  26757. this.bufferPosition = 0;
  26758. }
  26759. function decryptBlock2(data, finalize) {
  26760. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  26761. for (i = 0; i < sourceLength; ++i) {
  26762. buffer[bufferLength] = data[i];
  26763. ++bufferLength;
  26764. if (bufferLength < 16) {
  26765. continue;
  26766. }
  26767. var plain = decrypt128(buffer, this.key);
  26768. for (j = 0; j < 16; ++j) {
  26769. plain[j] ^= iv[j];
  26770. }
  26771. iv = buffer;
  26772. result.push(plain);
  26773. buffer = new Uint8Array(16);
  26774. bufferLength = 0;
  26775. }
  26776. this.buffer = buffer;
  26777. this.bufferLength = bufferLength;
  26778. this.iv = iv;
  26779. if (result.length === 0) {
  26780. return new Uint8Array([]);
  26781. }
  26782. var outputLength = 16 * result.length;
  26783. if (finalize) {
  26784. var lastBlock = result[result.length - 1];
  26785. var psLen = lastBlock[15];
  26786. if (psLen <= 16) {
  26787. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  26788. if (lastBlock[i] !== psLen) {
  26789. psLen = 0;
  26790. break;
  26791. }
  26792. }
  26793. outputLength -= psLen;
  26794. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  26795. }
  26796. }
  26797. var output = new Uint8Array(outputLength);
  26798. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26799. output.set(result[i], j);
  26800. }
  26801. return output;
  26802. }
  26803. AES128Cipher.prototype = {
  26804. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  26805. var i, sourceLength = data.length;
  26806. var buffer = this.buffer, bufferLength = this.bufferPosition;
  26807. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  26808. buffer[bufferLength] = data[i];
  26809. }
  26810. if (bufferLength < 16) {
  26811. this.bufferLength = bufferLength;
  26812. return new Uint8Array([]);
  26813. }
  26814. this.iv = buffer;
  26815. this.buffer = new Uint8Array(16);
  26816. this.bufferLength = 0;
  26817. this.decryptBlock = decryptBlock2;
  26818. return this.decryptBlock(data.subarray(16), finalize);
  26819. },
  26820. encrypt: function AES128Cipher_encrypt(data, iv) {
  26821. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  26822. if (!iv) {
  26823. iv = new Uint8Array(16);
  26824. }
  26825. for (i = 0; i < sourceLength; ++i) {
  26826. buffer[bufferLength] = data[i];
  26827. ++bufferLength;
  26828. if (bufferLength < 16) {
  26829. continue;
  26830. }
  26831. for (j = 0; j < 16; ++j) {
  26832. buffer[j] ^= iv[j];
  26833. }
  26834. var cipher = encrypt128(buffer, this.key);
  26835. iv = cipher;
  26836. result.push(cipher);
  26837. buffer = new Uint8Array(16);
  26838. bufferLength = 0;
  26839. }
  26840. this.buffer = buffer;
  26841. this.bufferLength = bufferLength;
  26842. this.iv = iv;
  26843. if (result.length === 0) {
  26844. return new Uint8Array([]);
  26845. }
  26846. var outputLength = 16 * result.length;
  26847. var output = new Uint8Array(outputLength);
  26848. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26849. output.set(result[i], j);
  26850. }
  26851. return output;
  26852. }
  26853. };
  26854. return AES128Cipher;
  26855. }();
  26856. var AES256Cipher = function AES256CipherClosure() {
  26857. var s = new Uint8Array([
  26858. 0x63,
  26859. 0x7c,
  26860. 0x77,
  26861. 0x7b,
  26862. 0xf2,
  26863. 0x6b,
  26864. 0x6f,
  26865. 0xc5,
  26866. 0x30,
  26867. 0x01,
  26868. 0x67,
  26869. 0x2b,
  26870. 0xfe,
  26871. 0xd7,
  26872. 0xab,
  26873. 0x76,
  26874. 0xca,
  26875. 0x82,
  26876. 0xc9,
  26877. 0x7d,
  26878. 0xfa,
  26879. 0x59,
  26880. 0x47,
  26881. 0xf0,
  26882. 0xad,
  26883. 0xd4,
  26884. 0xa2,
  26885. 0xaf,
  26886. 0x9c,
  26887. 0xa4,
  26888. 0x72,
  26889. 0xc0,
  26890. 0xb7,
  26891. 0xfd,
  26892. 0x93,
  26893. 0x26,
  26894. 0x36,
  26895. 0x3f,
  26896. 0xf7,
  26897. 0xcc,
  26898. 0x34,
  26899. 0xa5,
  26900. 0xe5,
  26901. 0xf1,
  26902. 0x71,
  26903. 0xd8,
  26904. 0x31,
  26905. 0x15,
  26906. 0x04,
  26907. 0xc7,
  26908. 0x23,
  26909. 0xc3,
  26910. 0x18,
  26911. 0x96,
  26912. 0x05,
  26913. 0x9a,
  26914. 0x07,
  26915. 0x12,
  26916. 0x80,
  26917. 0xe2,
  26918. 0xeb,
  26919. 0x27,
  26920. 0xb2,
  26921. 0x75,
  26922. 0x09,
  26923. 0x83,
  26924. 0x2c,
  26925. 0x1a,
  26926. 0x1b,
  26927. 0x6e,
  26928. 0x5a,
  26929. 0xa0,
  26930. 0x52,
  26931. 0x3b,
  26932. 0xd6,
  26933. 0xb3,
  26934. 0x29,
  26935. 0xe3,
  26936. 0x2f,
  26937. 0x84,
  26938. 0x53,
  26939. 0xd1,
  26940. 0x00,
  26941. 0xed,
  26942. 0x20,
  26943. 0xfc,
  26944. 0xb1,
  26945. 0x5b,
  26946. 0x6a,
  26947. 0xcb,
  26948. 0xbe,
  26949. 0x39,
  26950. 0x4a,
  26951. 0x4c,
  26952. 0x58,
  26953. 0xcf,
  26954. 0xd0,
  26955. 0xef,
  26956. 0xaa,
  26957. 0xfb,
  26958. 0x43,
  26959. 0x4d,
  26960. 0x33,
  26961. 0x85,
  26962. 0x45,
  26963. 0xf9,
  26964. 0x02,
  26965. 0x7f,
  26966. 0x50,
  26967. 0x3c,
  26968. 0x9f,
  26969. 0xa8,
  26970. 0x51,
  26971. 0xa3,
  26972. 0x40,
  26973. 0x8f,
  26974. 0x92,
  26975. 0x9d,
  26976. 0x38,
  26977. 0xf5,
  26978. 0xbc,
  26979. 0xb6,
  26980. 0xda,
  26981. 0x21,
  26982. 0x10,
  26983. 0xff,
  26984. 0xf3,
  26985. 0xd2,
  26986. 0xcd,
  26987. 0x0c,
  26988. 0x13,
  26989. 0xec,
  26990. 0x5f,
  26991. 0x97,
  26992. 0x44,
  26993. 0x17,
  26994. 0xc4,
  26995. 0xa7,
  26996. 0x7e,
  26997. 0x3d,
  26998. 0x64,
  26999. 0x5d,
  27000. 0x19,
  27001. 0x73,
  27002. 0x60,
  27003. 0x81,
  27004. 0x4f,
  27005. 0xdc,
  27006. 0x22,
  27007. 0x2a,
  27008. 0x90,
  27009. 0x88,
  27010. 0x46,
  27011. 0xee,
  27012. 0xb8,
  27013. 0x14,
  27014. 0xde,
  27015. 0x5e,
  27016. 0x0b,
  27017. 0xdb,
  27018. 0xe0,
  27019. 0x32,
  27020. 0x3a,
  27021. 0x0a,
  27022. 0x49,
  27023. 0x06,
  27024. 0x24,
  27025. 0x5c,
  27026. 0xc2,
  27027. 0xd3,
  27028. 0xac,
  27029. 0x62,
  27030. 0x91,
  27031. 0x95,
  27032. 0xe4,
  27033. 0x79,
  27034. 0xe7,
  27035. 0xc8,
  27036. 0x37,
  27037. 0x6d,
  27038. 0x8d,
  27039. 0xd5,
  27040. 0x4e,
  27041. 0xa9,
  27042. 0x6c,
  27043. 0x56,
  27044. 0xf4,
  27045. 0xea,
  27046. 0x65,
  27047. 0x7a,
  27048. 0xae,
  27049. 0x08,
  27050. 0xba,
  27051. 0x78,
  27052. 0x25,
  27053. 0x2e,
  27054. 0x1c,
  27055. 0xa6,
  27056. 0xb4,
  27057. 0xc6,
  27058. 0xe8,
  27059. 0xdd,
  27060. 0x74,
  27061. 0x1f,
  27062. 0x4b,
  27063. 0xbd,
  27064. 0x8b,
  27065. 0x8a,
  27066. 0x70,
  27067. 0x3e,
  27068. 0xb5,
  27069. 0x66,
  27070. 0x48,
  27071. 0x03,
  27072. 0xf6,
  27073. 0x0e,
  27074. 0x61,
  27075. 0x35,
  27076. 0x57,
  27077. 0xb9,
  27078. 0x86,
  27079. 0xc1,
  27080. 0x1d,
  27081. 0x9e,
  27082. 0xe1,
  27083. 0xf8,
  27084. 0x98,
  27085. 0x11,
  27086. 0x69,
  27087. 0xd9,
  27088. 0x8e,
  27089. 0x94,
  27090. 0x9b,
  27091. 0x1e,
  27092. 0x87,
  27093. 0xe9,
  27094. 0xce,
  27095. 0x55,
  27096. 0x28,
  27097. 0xdf,
  27098. 0x8c,
  27099. 0xa1,
  27100. 0x89,
  27101. 0x0d,
  27102. 0xbf,
  27103. 0xe6,
  27104. 0x42,
  27105. 0x68,
  27106. 0x41,
  27107. 0x99,
  27108. 0x2d,
  27109. 0x0f,
  27110. 0xb0,
  27111. 0x54,
  27112. 0xbb,
  27113. 0x16
  27114. ]);
  27115. var inv_s = new Uint8Array([
  27116. 0x52,
  27117. 0x09,
  27118. 0x6a,
  27119. 0xd5,
  27120. 0x30,
  27121. 0x36,
  27122. 0xa5,
  27123. 0x38,
  27124. 0xbf,
  27125. 0x40,
  27126. 0xa3,
  27127. 0x9e,
  27128. 0x81,
  27129. 0xf3,
  27130. 0xd7,
  27131. 0xfb,
  27132. 0x7c,
  27133. 0xe3,
  27134. 0x39,
  27135. 0x82,
  27136. 0x9b,
  27137. 0x2f,
  27138. 0xff,
  27139. 0x87,
  27140. 0x34,
  27141. 0x8e,
  27142. 0x43,
  27143. 0x44,
  27144. 0xc4,
  27145. 0xde,
  27146. 0xe9,
  27147. 0xcb,
  27148. 0x54,
  27149. 0x7b,
  27150. 0x94,
  27151. 0x32,
  27152. 0xa6,
  27153. 0xc2,
  27154. 0x23,
  27155. 0x3d,
  27156. 0xee,
  27157. 0x4c,
  27158. 0x95,
  27159. 0x0b,
  27160. 0x42,
  27161. 0xfa,
  27162. 0xc3,
  27163. 0x4e,
  27164. 0x08,
  27165. 0x2e,
  27166. 0xa1,
  27167. 0x66,
  27168. 0x28,
  27169. 0xd9,
  27170. 0x24,
  27171. 0xb2,
  27172. 0x76,
  27173. 0x5b,
  27174. 0xa2,
  27175. 0x49,
  27176. 0x6d,
  27177. 0x8b,
  27178. 0xd1,
  27179. 0x25,
  27180. 0x72,
  27181. 0xf8,
  27182. 0xf6,
  27183. 0x64,
  27184. 0x86,
  27185. 0x68,
  27186. 0x98,
  27187. 0x16,
  27188. 0xd4,
  27189. 0xa4,
  27190. 0x5c,
  27191. 0xcc,
  27192. 0x5d,
  27193. 0x65,
  27194. 0xb6,
  27195. 0x92,
  27196. 0x6c,
  27197. 0x70,
  27198. 0x48,
  27199. 0x50,
  27200. 0xfd,
  27201. 0xed,
  27202. 0xb9,
  27203. 0xda,
  27204. 0x5e,
  27205. 0x15,
  27206. 0x46,
  27207. 0x57,
  27208. 0xa7,
  27209. 0x8d,
  27210. 0x9d,
  27211. 0x84,
  27212. 0x90,
  27213. 0xd8,
  27214. 0xab,
  27215. 0x00,
  27216. 0x8c,
  27217. 0xbc,
  27218. 0xd3,
  27219. 0x0a,
  27220. 0xf7,
  27221. 0xe4,
  27222. 0x58,
  27223. 0x05,
  27224. 0xb8,
  27225. 0xb3,
  27226. 0x45,
  27227. 0x06,
  27228. 0xd0,
  27229. 0x2c,
  27230. 0x1e,
  27231. 0x8f,
  27232. 0xca,
  27233. 0x3f,
  27234. 0x0f,
  27235. 0x02,
  27236. 0xc1,
  27237. 0xaf,
  27238. 0xbd,
  27239. 0x03,
  27240. 0x01,
  27241. 0x13,
  27242. 0x8a,
  27243. 0x6b,
  27244. 0x3a,
  27245. 0x91,
  27246. 0x11,
  27247. 0x41,
  27248. 0x4f,
  27249. 0x67,
  27250. 0xdc,
  27251. 0xea,
  27252. 0x97,
  27253. 0xf2,
  27254. 0xcf,
  27255. 0xce,
  27256. 0xf0,
  27257. 0xb4,
  27258. 0xe6,
  27259. 0x73,
  27260. 0x96,
  27261. 0xac,
  27262. 0x74,
  27263. 0x22,
  27264. 0xe7,
  27265. 0xad,
  27266. 0x35,
  27267. 0x85,
  27268. 0xe2,
  27269. 0xf9,
  27270. 0x37,
  27271. 0xe8,
  27272. 0x1c,
  27273. 0x75,
  27274. 0xdf,
  27275. 0x6e,
  27276. 0x47,
  27277. 0xf1,
  27278. 0x1a,
  27279. 0x71,
  27280. 0x1d,
  27281. 0x29,
  27282. 0xc5,
  27283. 0x89,
  27284. 0x6f,
  27285. 0xb7,
  27286. 0x62,
  27287. 0x0e,
  27288. 0xaa,
  27289. 0x18,
  27290. 0xbe,
  27291. 0x1b,
  27292. 0xfc,
  27293. 0x56,
  27294. 0x3e,
  27295. 0x4b,
  27296. 0xc6,
  27297. 0xd2,
  27298. 0x79,
  27299. 0x20,
  27300. 0x9a,
  27301. 0xdb,
  27302. 0xc0,
  27303. 0xfe,
  27304. 0x78,
  27305. 0xcd,
  27306. 0x5a,
  27307. 0xf4,
  27308. 0x1f,
  27309. 0xdd,
  27310. 0xa8,
  27311. 0x33,
  27312. 0x88,
  27313. 0x07,
  27314. 0xc7,
  27315. 0x31,
  27316. 0xb1,
  27317. 0x12,
  27318. 0x10,
  27319. 0x59,
  27320. 0x27,
  27321. 0x80,
  27322. 0xec,
  27323. 0x5f,
  27324. 0x60,
  27325. 0x51,
  27326. 0x7f,
  27327. 0xa9,
  27328. 0x19,
  27329. 0xb5,
  27330. 0x4a,
  27331. 0x0d,
  27332. 0x2d,
  27333. 0xe5,
  27334. 0x7a,
  27335. 0x9f,
  27336. 0x93,
  27337. 0xc9,
  27338. 0x9c,
  27339. 0xef,
  27340. 0xa0,
  27341. 0xe0,
  27342. 0x3b,
  27343. 0x4d,
  27344. 0xae,
  27345. 0x2a,
  27346. 0xf5,
  27347. 0xb0,
  27348. 0xc8,
  27349. 0xeb,
  27350. 0xbb,
  27351. 0x3c,
  27352. 0x83,
  27353. 0x53,
  27354. 0x99,
  27355. 0x61,
  27356. 0x17,
  27357. 0x2b,
  27358. 0x04,
  27359. 0x7e,
  27360. 0xba,
  27361. 0x77,
  27362. 0xd6,
  27363. 0x26,
  27364. 0xe1,
  27365. 0x69,
  27366. 0x14,
  27367. 0x63,
  27368. 0x55,
  27369. 0x21,
  27370. 0x0c,
  27371. 0x7d
  27372. ]);
  27373. var mixCol = new Uint8Array(256);
  27374. for (var i = 0; i < 256; i++) {
  27375. if (i < 128) {
  27376. mixCol[i] = i << 1;
  27377. } else {
  27378. mixCol[i] = i << 1 ^ 0x1b;
  27379. }
  27380. }
  27381. var mix = new Uint32Array([
  27382. 0x00000000,
  27383. 0x0e090d0b,
  27384. 0x1c121a16,
  27385. 0x121b171d,
  27386. 0x3824342c,
  27387. 0x362d3927,
  27388. 0x24362e3a,
  27389. 0x2a3f2331,
  27390. 0x70486858,
  27391. 0x7e416553,
  27392. 0x6c5a724e,
  27393. 0x62537f45,
  27394. 0x486c5c74,
  27395. 0x4665517f,
  27396. 0x547e4662,
  27397. 0x5a774b69,
  27398. 0xe090d0b0,
  27399. 0xee99ddbb,
  27400. 0xfc82caa6,
  27401. 0xf28bc7ad,
  27402. 0xd8b4e49c,
  27403. 0xd6bde997,
  27404. 0xc4a6fe8a,
  27405. 0xcaaff381,
  27406. 0x90d8b8e8,
  27407. 0x9ed1b5e3,
  27408. 0x8ccaa2fe,
  27409. 0x82c3aff5,
  27410. 0xa8fc8cc4,
  27411. 0xa6f581cf,
  27412. 0xb4ee96d2,
  27413. 0xbae79bd9,
  27414. 0xdb3bbb7b,
  27415. 0xd532b670,
  27416. 0xc729a16d,
  27417. 0xc920ac66,
  27418. 0xe31f8f57,
  27419. 0xed16825c,
  27420. 0xff0d9541,
  27421. 0xf104984a,
  27422. 0xab73d323,
  27423. 0xa57ade28,
  27424. 0xb761c935,
  27425. 0xb968c43e,
  27426. 0x9357e70f,
  27427. 0x9d5eea04,
  27428. 0x8f45fd19,
  27429. 0x814cf012,
  27430. 0x3bab6bcb,
  27431. 0x35a266c0,
  27432. 0x27b971dd,
  27433. 0x29b07cd6,
  27434. 0x038f5fe7,
  27435. 0x0d8652ec,
  27436. 0x1f9d45f1,
  27437. 0x119448fa,
  27438. 0x4be30393,
  27439. 0x45ea0e98,
  27440. 0x57f11985,
  27441. 0x59f8148e,
  27442. 0x73c737bf,
  27443. 0x7dce3ab4,
  27444. 0x6fd52da9,
  27445. 0x61dc20a2,
  27446. 0xad766df6,
  27447. 0xa37f60fd,
  27448. 0xb16477e0,
  27449. 0xbf6d7aeb,
  27450. 0x955259da,
  27451. 0x9b5b54d1,
  27452. 0x894043cc,
  27453. 0x87494ec7,
  27454. 0xdd3e05ae,
  27455. 0xd33708a5,
  27456. 0xc12c1fb8,
  27457. 0xcf2512b3,
  27458. 0xe51a3182,
  27459. 0xeb133c89,
  27460. 0xf9082b94,
  27461. 0xf701269f,
  27462. 0x4de6bd46,
  27463. 0x43efb04d,
  27464. 0x51f4a750,
  27465. 0x5ffdaa5b,
  27466. 0x75c2896a,
  27467. 0x7bcb8461,
  27468. 0x69d0937c,
  27469. 0x67d99e77,
  27470. 0x3daed51e,
  27471. 0x33a7d815,
  27472. 0x21bccf08,
  27473. 0x2fb5c203,
  27474. 0x058ae132,
  27475. 0x0b83ec39,
  27476. 0x1998fb24,
  27477. 0x1791f62f,
  27478. 0x764dd68d,
  27479. 0x7844db86,
  27480. 0x6a5fcc9b,
  27481. 0x6456c190,
  27482. 0x4e69e2a1,
  27483. 0x4060efaa,
  27484. 0x527bf8b7,
  27485. 0x5c72f5bc,
  27486. 0x0605bed5,
  27487. 0x080cb3de,
  27488. 0x1a17a4c3,
  27489. 0x141ea9c8,
  27490. 0x3e218af9,
  27491. 0x302887f2,
  27492. 0x223390ef,
  27493. 0x2c3a9de4,
  27494. 0x96dd063d,
  27495. 0x98d40b36,
  27496. 0x8acf1c2b,
  27497. 0x84c61120,
  27498. 0xaef93211,
  27499. 0xa0f03f1a,
  27500. 0xb2eb2807,
  27501. 0xbce2250c,
  27502. 0xe6956e65,
  27503. 0xe89c636e,
  27504. 0xfa877473,
  27505. 0xf48e7978,
  27506. 0xdeb15a49,
  27507. 0xd0b85742,
  27508. 0xc2a3405f,
  27509. 0xccaa4d54,
  27510. 0x41ecdaf7,
  27511. 0x4fe5d7fc,
  27512. 0x5dfec0e1,
  27513. 0x53f7cdea,
  27514. 0x79c8eedb,
  27515. 0x77c1e3d0,
  27516. 0x65daf4cd,
  27517. 0x6bd3f9c6,
  27518. 0x31a4b2af,
  27519. 0x3fadbfa4,
  27520. 0x2db6a8b9,
  27521. 0x23bfa5b2,
  27522. 0x09808683,
  27523. 0x07898b88,
  27524. 0x15929c95,
  27525. 0x1b9b919e,
  27526. 0xa17c0a47,
  27527. 0xaf75074c,
  27528. 0xbd6e1051,
  27529. 0xb3671d5a,
  27530. 0x99583e6b,
  27531. 0x97513360,
  27532. 0x854a247d,
  27533. 0x8b432976,
  27534. 0xd134621f,
  27535. 0xdf3d6f14,
  27536. 0xcd267809,
  27537. 0xc32f7502,
  27538. 0xe9105633,
  27539. 0xe7195b38,
  27540. 0xf5024c25,
  27541. 0xfb0b412e,
  27542. 0x9ad7618c,
  27543. 0x94de6c87,
  27544. 0x86c57b9a,
  27545. 0x88cc7691,
  27546. 0xa2f355a0,
  27547. 0xacfa58ab,
  27548. 0xbee14fb6,
  27549. 0xb0e842bd,
  27550. 0xea9f09d4,
  27551. 0xe49604df,
  27552. 0xf68d13c2,
  27553. 0xf8841ec9,
  27554. 0xd2bb3df8,
  27555. 0xdcb230f3,
  27556. 0xcea927ee,
  27557. 0xc0a02ae5,
  27558. 0x7a47b13c,
  27559. 0x744ebc37,
  27560. 0x6655ab2a,
  27561. 0x685ca621,
  27562. 0x42638510,
  27563. 0x4c6a881b,
  27564. 0x5e719f06,
  27565. 0x5078920d,
  27566. 0x0a0fd964,
  27567. 0x0406d46f,
  27568. 0x161dc372,
  27569. 0x1814ce79,
  27570. 0x322bed48,
  27571. 0x3c22e043,
  27572. 0x2e39f75e,
  27573. 0x2030fa55,
  27574. 0xec9ab701,
  27575. 0xe293ba0a,
  27576. 0xf088ad17,
  27577. 0xfe81a01c,
  27578. 0xd4be832d,
  27579. 0xdab78e26,
  27580. 0xc8ac993b,
  27581. 0xc6a59430,
  27582. 0x9cd2df59,
  27583. 0x92dbd252,
  27584. 0x80c0c54f,
  27585. 0x8ec9c844,
  27586. 0xa4f6eb75,
  27587. 0xaaffe67e,
  27588. 0xb8e4f163,
  27589. 0xb6edfc68,
  27590. 0x0c0a67b1,
  27591. 0x02036aba,
  27592. 0x10187da7,
  27593. 0x1e1170ac,
  27594. 0x342e539d,
  27595. 0x3a275e96,
  27596. 0x283c498b,
  27597. 0x26354480,
  27598. 0x7c420fe9,
  27599. 0x724b02e2,
  27600. 0x605015ff,
  27601. 0x6e5918f4,
  27602. 0x44663bc5,
  27603. 0x4a6f36ce,
  27604. 0x587421d3,
  27605. 0x567d2cd8,
  27606. 0x37a10c7a,
  27607. 0x39a80171,
  27608. 0x2bb3166c,
  27609. 0x25ba1b67,
  27610. 0x0f853856,
  27611. 0x018c355d,
  27612. 0x13972240,
  27613. 0x1d9e2f4b,
  27614. 0x47e96422,
  27615. 0x49e06929,
  27616. 0x5bfb7e34,
  27617. 0x55f2733f,
  27618. 0x7fcd500e,
  27619. 0x71c45d05,
  27620. 0x63df4a18,
  27621. 0x6dd64713,
  27622. 0xd731dcca,
  27623. 0xd938d1c1,
  27624. 0xcb23c6dc,
  27625. 0xc52acbd7,
  27626. 0xef15e8e6,
  27627. 0xe11ce5ed,
  27628. 0xf307f2f0,
  27629. 0xfd0efffb,
  27630. 0xa779b492,
  27631. 0xa970b999,
  27632. 0xbb6bae84,
  27633. 0xb562a38f,
  27634. 0x9f5d80be,
  27635. 0x91548db5,
  27636. 0x834f9aa8,
  27637. 0x8d4697a3
  27638. ]);
  27639. function expandKey256(cipherKey) {
  27640. var b = 240, result = new Uint8Array(b);
  27641. var r = 1;
  27642. result.set(cipherKey);
  27643. for (var j = 32, i = 1; j < b; ++i) {
  27644. if (j % 32 === 16) {
  27645. t1 = s[t1];
  27646. t2 = s[t2];
  27647. t3 = s[t3];
  27648. t4 = s[t4];
  27649. } else if (j % 32 === 0) {
  27650. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27651. t1 = s[t1];
  27652. t2 = s[t2];
  27653. t3 = s[t3];
  27654. t4 = s[t4];
  27655. t1 = t1 ^ r;
  27656. if ((r <<= 1) >= 256) {
  27657. r = (r ^ 0x1b) & 0xFF;
  27658. }
  27659. }
  27660. for (var n = 0; n < 4; ++n) {
  27661. result[j] = t1 ^= result[j - 32];
  27662. j++;
  27663. result[j] = t2 ^= result[j - 32];
  27664. j++;
  27665. result[j] = t3 ^= result[j - 32];
  27666. j++;
  27667. result[j] = t4 ^= result[j - 32];
  27668. j++;
  27669. }
  27670. }
  27671. return result;
  27672. }
  27673. function decrypt256(input, key) {
  27674. var state = new Uint8Array(16);
  27675. state.set(input);
  27676. var i, j, k;
  27677. var t, u, v;
  27678. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27679. state[j] ^= key[k];
  27680. }
  27681. for (i = 13; i >= 1; --i) {
  27682. t = state[13];
  27683. state[13] = state[9];
  27684. state[9] = state[5];
  27685. state[5] = state[1];
  27686. state[1] = t;
  27687. t = state[14];
  27688. u = state[10];
  27689. state[14] = state[6];
  27690. state[10] = state[2];
  27691. state[6] = t;
  27692. state[2] = u;
  27693. t = state[15];
  27694. u = state[11];
  27695. v = state[7];
  27696. state[15] = state[3];
  27697. state[11] = t;
  27698. state[7] = u;
  27699. state[3] = v;
  27700. for (j = 0; j < 16; ++j) {
  27701. state[j] = inv_s[state[j]];
  27702. }
  27703. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27704. state[j] ^= key[k];
  27705. }
  27706. for (j = 0; j < 16; j += 4) {
  27707. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27708. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27709. state[j] = t >>> 24 & 0xFF;
  27710. state[j + 1] = t >> 16 & 0xFF;
  27711. state[j + 2] = t >> 8 & 0xFF;
  27712. state[j + 3] = t & 0xFF;
  27713. }
  27714. }
  27715. t = state[13];
  27716. state[13] = state[9];
  27717. state[9] = state[5];
  27718. state[5] = state[1];
  27719. state[1] = t;
  27720. t = state[14];
  27721. u = state[10];
  27722. state[14] = state[6];
  27723. state[10] = state[2];
  27724. state[6] = t;
  27725. state[2] = u;
  27726. t = state[15];
  27727. u = state[11];
  27728. v = state[7];
  27729. state[15] = state[3];
  27730. state[11] = t;
  27731. state[7] = u;
  27732. state[3] = v;
  27733. for (j = 0; j < 16; ++j) {
  27734. state[j] = inv_s[state[j]];
  27735. state[j] ^= key[j];
  27736. }
  27737. return state;
  27738. }
  27739. function encrypt256(input, key) {
  27740. var t, u, v, k;
  27741. var state = new Uint8Array(16);
  27742. state.set(input);
  27743. for (j = 0; j < 16; ++j) {
  27744. state[j] ^= key[j];
  27745. }
  27746. for (i = 1; i < 14; i++) {
  27747. for (j = 0; j < 16; ++j) {
  27748. state[j] = s[state[j]];
  27749. }
  27750. v = state[1];
  27751. state[1] = state[5];
  27752. state[5] = state[9];
  27753. state[9] = state[13];
  27754. state[13] = v;
  27755. v = state[2];
  27756. u = state[6];
  27757. state[2] = state[10];
  27758. state[6] = state[14];
  27759. state[10] = v;
  27760. state[14] = u;
  27761. v = state[3];
  27762. u = state[7];
  27763. t = state[11];
  27764. state[3] = state[15];
  27765. state[7] = v;
  27766. state[11] = u;
  27767. state[15] = t;
  27768. for (var j = 0; j < 16; j += 4) {
  27769. var s0 = state[j + 0], s1 = state[j + 1];
  27770. var s2 = state[j + 2], s3 = state[j + 3];
  27771. t = s0 ^ s1 ^ s2 ^ s3;
  27772. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27773. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27774. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27775. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27776. }
  27777. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27778. state[j] ^= key[k];
  27779. }
  27780. }
  27781. for (j = 0; j < 16; ++j) {
  27782. state[j] = s[state[j]];
  27783. }
  27784. v = state[1];
  27785. state[1] = state[5];
  27786. state[5] = state[9];
  27787. state[9] = state[13];
  27788. state[13] = v;
  27789. v = state[2];
  27790. u = state[6];
  27791. state[2] = state[10];
  27792. state[6] = state[14];
  27793. state[10] = v;
  27794. state[14] = u;
  27795. v = state[3];
  27796. u = state[7];
  27797. t = state[11];
  27798. state[3] = state[15];
  27799. state[7] = v;
  27800. state[11] = u;
  27801. state[15] = t;
  27802. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27803. state[j] ^= key[k];
  27804. }
  27805. return state;
  27806. }
  27807. function AES256Cipher(key) {
  27808. this.key = expandKey256(key);
  27809. this.buffer = new Uint8Array(16);
  27810. this.bufferPosition = 0;
  27811. }
  27812. function decryptBlock2(data, finalize) {
  27813. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27814. for (i = 0; i < sourceLength; ++i) {
  27815. buffer[bufferLength] = data[i];
  27816. ++bufferLength;
  27817. if (bufferLength < 16) {
  27818. continue;
  27819. }
  27820. var plain = decrypt256(buffer, this.key);
  27821. for (j = 0; j < 16; ++j) {
  27822. plain[j] ^= iv[j];
  27823. }
  27824. iv = buffer;
  27825. result.push(plain);
  27826. buffer = new Uint8Array(16);
  27827. bufferLength = 0;
  27828. }
  27829. this.buffer = buffer;
  27830. this.bufferLength = bufferLength;
  27831. this.iv = iv;
  27832. if (result.length === 0) {
  27833. return new Uint8Array([]);
  27834. }
  27835. var outputLength = 16 * result.length;
  27836. if (finalize) {
  27837. var lastBlock = result[result.length - 1];
  27838. var psLen = lastBlock[15];
  27839. if (psLen <= 16) {
  27840. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27841. if (lastBlock[i] !== psLen) {
  27842. psLen = 0;
  27843. break;
  27844. }
  27845. }
  27846. outputLength -= psLen;
  27847. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27848. }
  27849. }
  27850. var output = new Uint8Array(outputLength);
  27851. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27852. output.set(result[i], j);
  27853. }
  27854. return output;
  27855. }
  27856. AES256Cipher.prototype = {
  27857. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  27858. var i, sourceLength = data.length;
  27859. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27860. if (iv) {
  27861. this.iv = iv;
  27862. } else {
  27863. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27864. buffer[bufferLength] = data[i];
  27865. }
  27866. if (bufferLength < 16) {
  27867. this.bufferLength = bufferLength;
  27868. return new Uint8Array([]);
  27869. }
  27870. this.iv = buffer;
  27871. data = data.subarray(16);
  27872. }
  27873. this.buffer = new Uint8Array(16);
  27874. this.bufferLength = 0;
  27875. this.decryptBlock = decryptBlock2;
  27876. return this.decryptBlock(data, finalize);
  27877. },
  27878. encrypt: function AES256Cipher_encrypt(data, iv) {
  27879. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27880. if (!iv) {
  27881. iv = new Uint8Array(16);
  27882. }
  27883. for (i = 0; i < sourceLength; ++i) {
  27884. buffer[bufferLength] = data[i];
  27885. ++bufferLength;
  27886. if (bufferLength < 16) {
  27887. continue;
  27888. }
  27889. for (j = 0; j < 16; ++j) {
  27890. buffer[j] ^= iv[j];
  27891. }
  27892. var cipher = encrypt256(buffer, this.key);
  27893. this.iv = cipher;
  27894. result.push(cipher);
  27895. buffer = new Uint8Array(16);
  27896. bufferLength = 0;
  27897. }
  27898. this.buffer = buffer;
  27899. this.bufferLength = bufferLength;
  27900. this.iv = iv;
  27901. if (result.length === 0) {
  27902. return new Uint8Array([]);
  27903. }
  27904. var outputLength = 16 * result.length;
  27905. var output = new Uint8Array(outputLength);
  27906. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27907. output.set(result[i], j);
  27908. }
  27909. return output;
  27910. }
  27911. };
  27912. return AES256Cipher;
  27913. }();
  27914. var PDF17 = function PDF17Closure() {
  27915. function compareByteArrays(array1, array2) {
  27916. if (array1.length !== array2.length) {
  27917. return false;
  27918. }
  27919. for (var i = 0; i < array1.length; i++) {
  27920. if (array1[i] !== array2[i]) {
  27921. return false;
  27922. }
  27923. }
  27924. return true;
  27925. }
  27926. function PDF17() {
  27927. }
  27928. PDF17.prototype = {
  27929. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  27930. var hashData = new Uint8Array(password.length + 56);
  27931. hashData.set(password, 0);
  27932. hashData.set(ownerValidationSalt, password.length);
  27933. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  27934. var result = calculateSHA256(hashData, 0, hashData.length);
  27935. return compareByteArrays(result, ownerPassword);
  27936. },
  27937. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  27938. var hashData = new Uint8Array(password.length + 8);
  27939. hashData.set(password, 0);
  27940. hashData.set(userValidationSalt, password.length);
  27941. var result = calculateSHA256(hashData, 0, hashData.length);
  27942. return compareByteArrays(result, userPassword);
  27943. },
  27944. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  27945. var hashData = new Uint8Array(password.length + 56);
  27946. hashData.set(password, 0);
  27947. hashData.set(ownerKeySalt, password.length);
  27948. hashData.set(userBytes, password.length + ownerKeySalt.length);
  27949. var key = calculateSHA256(hashData, 0, hashData.length);
  27950. var cipher = new AES256Cipher(key);
  27951. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  27952. },
  27953. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  27954. var hashData = new Uint8Array(password.length + 8);
  27955. hashData.set(password, 0);
  27956. hashData.set(userKeySalt, password.length);
  27957. var key = calculateSHA256(hashData, 0, hashData.length);
  27958. var cipher = new AES256Cipher(key);
  27959. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  27960. }
  27961. };
  27962. return PDF17;
  27963. }();
  27964. var PDF20 = function PDF20Closure() {
  27965. function concatArrays(array1, array2) {
  27966. var t = new Uint8Array(array1.length + array2.length);
  27967. t.set(array1, 0);
  27968. t.set(array2, array1.length);
  27969. return t;
  27970. }
  27971. function calculatePDF20Hash(password, input, userBytes) {
  27972. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  27973. var e = [0];
  27974. var i = 0;
  27975. while (i < 64 || e[e.length - 1] > i - 32) {
  27976. var arrayLength = password.length + k.length + userBytes.length;
  27977. var k1 = new Uint8Array(arrayLength * 64);
  27978. var array = concatArrays(password, k);
  27979. array = concatArrays(array, userBytes);
  27980. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  27981. k1.set(array, pos);
  27982. }
  27983. var cipher = new AES128Cipher(k.subarray(0, 16));
  27984. e = cipher.encrypt(k1, k.subarray(16, 32));
  27985. var remainder = 0;
  27986. for (var z = 0; z < 16; z++) {
  27987. remainder *= 256 % 3;
  27988. remainder %= 3;
  27989. remainder += (e[z] >>> 0) % 3;
  27990. remainder %= 3;
  27991. }
  27992. if (remainder === 0) {
  27993. k = calculateSHA256(e, 0, e.length);
  27994. } else if (remainder === 1) {
  27995. k = calculateSHA384(e, 0, e.length);
  27996. } else if (remainder === 2) {
  27997. k = calculateSHA512(e, 0, e.length);
  27998. }
  27999. i++;
  28000. }
  28001. return k.subarray(0, 32);
  28002. }
  28003. function PDF20() {
  28004. }
  28005. function compareByteArrays(array1, array2) {
  28006. if (array1.length !== array2.length) {
  28007. return false;
  28008. }
  28009. for (var i = 0; i < array1.length; i++) {
  28010. if (array1[i] !== array2[i]) {
  28011. return false;
  28012. }
  28013. }
  28014. return true;
  28015. }
  28016. PDF20.prototype = {
  28017. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28018. return calculatePDF20Hash(password, concatBytes, userBytes);
  28019. },
  28020. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28021. var hashData = new Uint8Array(password.length + 56);
  28022. hashData.set(password, 0);
  28023. hashData.set(ownerValidationSalt, password.length);
  28024. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28025. var result = calculatePDF20Hash(password, hashData, userBytes);
  28026. return compareByteArrays(result, ownerPassword);
  28027. },
  28028. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28029. var hashData = new Uint8Array(password.length + 8);
  28030. hashData.set(password, 0);
  28031. hashData.set(userValidationSalt, password.length);
  28032. var result = calculatePDF20Hash(password, hashData, []);
  28033. return compareByteArrays(result, userPassword);
  28034. },
  28035. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28036. var hashData = new Uint8Array(password.length + 56);
  28037. hashData.set(password, 0);
  28038. hashData.set(ownerKeySalt, password.length);
  28039. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28040. var key = calculatePDF20Hash(password, hashData, userBytes);
  28041. var cipher = new AES256Cipher(key);
  28042. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28043. },
  28044. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28045. var hashData = new Uint8Array(password.length + 8);
  28046. hashData.set(password, 0);
  28047. hashData.set(userKeySalt, password.length);
  28048. var key = calculatePDF20Hash(password, hashData, []);
  28049. var cipher = new AES256Cipher(key);
  28050. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28051. }
  28052. };
  28053. return PDF20;
  28054. }();
  28055. var CipherTransform = function CipherTransformClosure() {
  28056. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28057. this.StringCipherConstructor = stringCipherConstructor;
  28058. this.StreamCipherConstructor = streamCipherConstructor;
  28059. }
  28060. CipherTransform.prototype = {
  28061. createStream: function CipherTransform_createStream(stream, length) {
  28062. var cipher = new this.StreamCipherConstructor();
  28063. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28064. return cipher.decryptBlock(data, finalize);
  28065. });
  28066. },
  28067. decryptString: function CipherTransform_decryptString(s) {
  28068. var cipher = new this.StringCipherConstructor();
  28069. var data = stringToBytes(s);
  28070. data = cipher.decryptBlock(data, true);
  28071. return bytesToString(data);
  28072. }
  28073. };
  28074. return CipherTransform;
  28075. }();
  28076. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28077. var defaultPasswordBytes = new Uint8Array([
  28078. 0x28,
  28079. 0xBF,
  28080. 0x4E,
  28081. 0x5E,
  28082. 0x4E,
  28083. 0x75,
  28084. 0x8A,
  28085. 0x41,
  28086. 0x64,
  28087. 0x00,
  28088. 0x4E,
  28089. 0x56,
  28090. 0xFF,
  28091. 0xFA,
  28092. 0x01,
  28093. 0x08,
  28094. 0x2E,
  28095. 0x2E,
  28096. 0x00,
  28097. 0xB6,
  28098. 0xD0,
  28099. 0x68,
  28100. 0x3E,
  28101. 0x80,
  28102. 0x2F,
  28103. 0x0C,
  28104. 0xA9,
  28105. 0xFE,
  28106. 0x64,
  28107. 0x53,
  28108. 0x69,
  28109. 0x7A
  28110. ]);
  28111. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28112. if (password) {
  28113. var passwordLength = Math.min(127, password.length);
  28114. password = password.subarray(0, passwordLength);
  28115. } else {
  28116. password = [];
  28117. }
  28118. var pdfAlgorithm;
  28119. if (revision === 6) {
  28120. pdfAlgorithm = new PDF20();
  28121. } else {
  28122. pdfAlgorithm = new PDF17();
  28123. }
  28124. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28125. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28126. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28127. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28128. }
  28129. return null;
  28130. }
  28131. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28132. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28133. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28134. if (password) {
  28135. n = Math.min(32, password.length);
  28136. for (; i < n; ++i) {
  28137. hashData[i] = password[i];
  28138. }
  28139. }
  28140. j = 0;
  28141. while (i < 32) {
  28142. hashData[i++] = defaultPasswordBytes[j++];
  28143. }
  28144. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28145. hashData[i++] = ownerPassword[j];
  28146. }
  28147. hashData[i++] = flags & 0xFF;
  28148. hashData[i++] = flags >> 8 & 0xFF;
  28149. hashData[i++] = flags >> 16 & 0xFF;
  28150. hashData[i++] = flags >>> 24 & 0xFF;
  28151. for (j = 0, n = fileId.length; j < n; ++j) {
  28152. hashData[i++] = fileId[j];
  28153. }
  28154. if (revision >= 4 && !encryptMetadata) {
  28155. hashData[i++] = 0xFF;
  28156. hashData[i++] = 0xFF;
  28157. hashData[i++] = 0xFF;
  28158. hashData[i++] = 0xFF;
  28159. }
  28160. var hash = calculateMD5(hashData, 0, i);
  28161. var keyLengthInBytes = keyLength >> 3;
  28162. if (revision >= 3) {
  28163. for (j = 0; j < 50; ++j) {
  28164. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28165. }
  28166. }
  28167. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28168. var cipher, checkData;
  28169. if (revision >= 3) {
  28170. for (i = 0; i < 32; ++i) {
  28171. hashData[i] = defaultPasswordBytes[i];
  28172. }
  28173. for (j = 0, n = fileId.length; j < n; ++j) {
  28174. hashData[i++] = fileId[j];
  28175. }
  28176. cipher = new ARCFourCipher(encryptionKey);
  28177. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28178. n = encryptionKey.length;
  28179. var derivedKey = new Uint8Array(n), k;
  28180. for (j = 1; j <= 19; ++j) {
  28181. for (k = 0; k < n; ++k) {
  28182. derivedKey[k] = encryptionKey[k] ^ j;
  28183. }
  28184. cipher = new ARCFourCipher(derivedKey);
  28185. checkData = cipher.encryptBlock(checkData);
  28186. }
  28187. for (j = 0, n = checkData.length; j < n; ++j) {
  28188. if (userPassword[j] !== checkData[j]) {
  28189. return null;
  28190. }
  28191. }
  28192. } else {
  28193. cipher = new ARCFourCipher(encryptionKey);
  28194. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28195. for (j = 0, n = checkData.length; j < n; ++j) {
  28196. if (userPassword[j] !== checkData[j]) {
  28197. return null;
  28198. }
  28199. }
  28200. }
  28201. return encryptionKey;
  28202. }
  28203. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28204. var hashData = new Uint8Array(32), i = 0, j, n;
  28205. n = Math.min(32, password.length);
  28206. for (; i < n; ++i) {
  28207. hashData[i] = password[i];
  28208. }
  28209. j = 0;
  28210. while (i < 32) {
  28211. hashData[i++] = defaultPasswordBytes[j++];
  28212. }
  28213. var hash = calculateMD5(hashData, 0, i);
  28214. var keyLengthInBytes = keyLength >> 3;
  28215. if (revision >= 3) {
  28216. for (j = 0; j < 50; ++j) {
  28217. hash = calculateMD5(hash, 0, hash.length);
  28218. }
  28219. }
  28220. var cipher, userPassword;
  28221. if (revision >= 3) {
  28222. userPassword = ownerPassword;
  28223. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28224. for (j = 19; j >= 0; j--) {
  28225. for (k = 0; k < keyLengthInBytes; ++k) {
  28226. derivedKey[k] = hash[k] ^ j;
  28227. }
  28228. cipher = new ARCFourCipher(derivedKey);
  28229. userPassword = cipher.encryptBlock(userPassword);
  28230. }
  28231. } else {
  28232. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28233. userPassword = cipher.encryptBlock(ownerPassword);
  28234. }
  28235. return userPassword;
  28236. }
  28237. var identityName = Name.get('Identity');
  28238. function CipherTransformFactory(dict, fileId, password) {
  28239. var filter = dict.get('Filter');
  28240. if (!isName(filter, 'Standard')) {
  28241. error('unknown encryption method');
  28242. }
  28243. this.dict = dict;
  28244. var algorithm = dict.get('V');
  28245. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28246. error('unsupported encryption algorithm');
  28247. }
  28248. this.algorithm = algorithm;
  28249. var keyLength = dict.get('Length');
  28250. if (!keyLength) {
  28251. if (algorithm <= 3) {
  28252. keyLength = 40;
  28253. } else {
  28254. var cfDict = dict.get('CF');
  28255. var streamCryptoName = dict.get('StmF');
  28256. if (isDict(cfDict) && isName(streamCryptoName)) {
  28257. cfDict.suppressEncryption = true;
  28258. var handlerDict = cfDict.get(streamCryptoName.name);
  28259. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28260. if (keyLength < 40) {
  28261. keyLength <<= 3;
  28262. }
  28263. }
  28264. }
  28265. }
  28266. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28267. error('invalid key length');
  28268. }
  28269. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28270. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28271. var flags = dict.get('P');
  28272. var revision = dict.get('R');
  28273. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28274. this.encryptMetadata = encryptMetadata;
  28275. var fileIdBytes = stringToBytes(fileId);
  28276. var passwordBytes;
  28277. if (password) {
  28278. if (revision === 6) {
  28279. try {
  28280. password = utf8StringToString(password);
  28281. } catch (ex) {
  28282. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  28283. }
  28284. }
  28285. passwordBytes = stringToBytes(password);
  28286. }
  28287. var encryptionKey;
  28288. if (algorithm !== 5) {
  28289. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28290. } else {
  28291. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  28292. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  28293. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  28294. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  28295. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  28296. var ownerEncryption = stringToBytes(dict.get('OE'));
  28297. var userEncryption = stringToBytes(dict.get('UE'));
  28298. var perms = stringToBytes(dict.get('Perms'));
  28299. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  28300. }
  28301. if (!encryptionKey && !password) {
  28302. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  28303. } else if (!encryptionKey && password) {
  28304. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  28305. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28306. }
  28307. if (!encryptionKey) {
  28308. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  28309. }
  28310. this.encryptionKey = encryptionKey;
  28311. if (algorithm >= 4) {
  28312. var cf = dict.get('CF');
  28313. if (isDict(cf)) {
  28314. cf.suppressEncryption = true;
  28315. }
  28316. this.cf = cf;
  28317. this.stmf = dict.get('StmF') || identityName;
  28318. this.strf = dict.get('StrF') || identityName;
  28319. this.eff = dict.get('EFF') || this.stmf;
  28320. }
  28321. }
  28322. function buildObjectKey(num, gen, encryptionKey, isAes) {
  28323. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  28324. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  28325. key[i] = encryptionKey[i];
  28326. }
  28327. key[i++] = num & 0xFF;
  28328. key[i++] = num >> 8 & 0xFF;
  28329. key[i++] = num >> 16 & 0xFF;
  28330. key[i++] = gen & 0xFF;
  28331. key[i++] = gen >> 8 & 0xFF;
  28332. if (isAes) {
  28333. key[i++] = 0x73;
  28334. key[i++] = 0x41;
  28335. key[i++] = 0x6C;
  28336. key[i++] = 0x54;
  28337. }
  28338. var hash = calculateMD5(key, 0, i);
  28339. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  28340. }
  28341. function buildCipherConstructor(cf, name, num, gen, key) {
  28342. assert(isName(name), 'Invalid crypt filter name.');
  28343. var cryptFilter = cf.get(name.name);
  28344. var cfm;
  28345. if (cryptFilter !== null && cryptFilter !== undefined) {
  28346. cfm = cryptFilter.get('CFM');
  28347. }
  28348. if (!cfm || cfm.name === 'None') {
  28349. return function cipherTransformFactoryBuildCipherConstructorNone() {
  28350. return new NullCipher();
  28351. };
  28352. }
  28353. if (cfm.name === 'V2') {
  28354. return function cipherTransformFactoryBuildCipherConstructorV2() {
  28355. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  28356. };
  28357. }
  28358. if (cfm.name === 'AESV2') {
  28359. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  28360. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  28361. };
  28362. }
  28363. if (cfm.name === 'AESV3') {
  28364. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  28365. return new AES256Cipher(key);
  28366. };
  28367. }
  28368. error('Unknown crypto method');
  28369. }
  28370. CipherTransformFactory.prototype = {
  28371. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  28372. if (this.algorithm === 4 || this.algorithm === 5) {
  28373. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  28374. }
  28375. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  28376. var cipherConstructor = function buildCipherCipherConstructor() {
  28377. return new ARCFourCipher(key);
  28378. };
  28379. return new CipherTransform(cipherConstructor, cipherConstructor);
  28380. }
  28381. };
  28382. return CipherTransformFactory;
  28383. }();
  28384. exports.AES128Cipher = AES128Cipher;
  28385. exports.AES256Cipher = AES256Cipher;
  28386. exports.ARCFourCipher = ARCFourCipher;
  28387. exports.CipherTransformFactory = CipherTransformFactory;
  28388. exports.PDF17 = PDF17;
  28389. exports.PDF20 = PDF20;
  28390. exports.calculateMD5 = calculateMD5;
  28391. exports.calculateSHA256 = calculateSHA256;
  28392. exports.calculateSHA384 = calculateSHA384;
  28393. exports.calculateSHA512 = calculateSHA512;
  28394. /***/ }),
  28395. /* 18 */
  28396. /***/ (function(module, exports, __w_pdfjs_require__) {
  28397. "use strict";
  28398. var sharedUtil = __w_pdfjs_require__(0);
  28399. var corePrimitives = __w_pdfjs_require__(1);
  28400. var coreStream = __w_pdfjs_require__(2);
  28401. var coreParser = __w_pdfjs_require__(6);
  28402. var coreImage = __w_pdfjs_require__(34);
  28403. var coreColorSpace = __w_pdfjs_require__(4);
  28404. var coreMurmurHash3 = __w_pdfjs_require__(38);
  28405. var coreFonts = __w_pdfjs_require__(33);
  28406. var coreFunction = __w_pdfjs_require__(7);
  28407. var corePattern = __w_pdfjs_require__(40);
  28408. var coreCMap = __w_pdfjs_require__(30);
  28409. var coreMetrics = __w_pdfjs_require__(37);
  28410. var coreBidi = __w_pdfjs_require__(28);
  28411. var coreEncodings = __w_pdfjs_require__(5);
  28412. var coreStandardFonts = __w_pdfjs_require__(21);
  28413. var coreUnicode = __w_pdfjs_require__(22);
  28414. var coreGlyphList = __w_pdfjs_require__(8);
  28415. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  28416. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  28417. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  28418. var ImageKind = sharedUtil.ImageKind;
  28419. var OPS = sharedUtil.OPS;
  28420. var TextRenderingMode = sharedUtil.TextRenderingMode;
  28421. var CMapCompressionType = sharedUtil.CMapCompressionType;
  28422. var Util = sharedUtil.Util;
  28423. var assert = sharedUtil.assert;
  28424. var createPromiseCapability = sharedUtil.createPromiseCapability;
  28425. var error = sharedUtil.error;
  28426. var info = sharedUtil.info;
  28427. var isArray = sharedUtil.isArray;
  28428. var isNum = sharedUtil.isNum;
  28429. var isString = sharedUtil.isString;
  28430. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  28431. var warn = sharedUtil.warn;
  28432. var Dict = corePrimitives.Dict;
  28433. var Name = corePrimitives.Name;
  28434. var isEOF = corePrimitives.isEOF;
  28435. var isCmd = corePrimitives.isCmd;
  28436. var isDict = corePrimitives.isDict;
  28437. var isName = corePrimitives.isName;
  28438. var isRef = corePrimitives.isRef;
  28439. var isStream = corePrimitives.isStream;
  28440. var DecodeStream = coreStream.DecodeStream;
  28441. var JpegStream = coreStream.JpegStream;
  28442. var Stream = coreStream.Stream;
  28443. var Lexer = coreParser.Lexer;
  28444. var Parser = coreParser.Parser;
  28445. var PDFImage = coreImage.PDFImage;
  28446. var ColorSpace = coreColorSpace.ColorSpace;
  28447. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  28448. var ErrorFont = coreFonts.ErrorFont;
  28449. var FontFlags = coreFonts.FontFlags;
  28450. var Font = coreFonts.Font;
  28451. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  28452. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  28453. var getFontType = coreFonts.getFontType;
  28454. var isPDFFunction = coreFunction.isPDFFunction;
  28455. var PDFFunction = coreFunction.PDFFunction;
  28456. var Pattern = corePattern.Pattern;
  28457. var getTilingPatternIR = corePattern.getTilingPatternIR;
  28458. var CMapFactory = coreCMap.CMapFactory;
  28459. var IdentityCMap = coreCMap.IdentityCMap;
  28460. var getMetrics = coreMetrics.getMetrics;
  28461. var bidi = coreBidi.bidi;
  28462. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  28463. var StandardEncoding = coreEncodings.StandardEncoding;
  28464. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  28465. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  28466. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  28467. var getEncoding = coreEncodings.getEncoding;
  28468. var getStdFontMap = coreStandardFonts.getStdFontMap;
  28469. var getSerifFonts = coreStandardFonts.getSerifFonts;
  28470. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  28471. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  28472. var reverseIfRtl = coreUnicode.reverseIfRtl;
  28473. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  28474. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  28475. var PartialEvaluator = function PartialEvaluatorClosure() {
  28476. var DefaultPartialEvaluatorOptions = {
  28477. forceDataSchema: false,
  28478. maxImageSize: -1,
  28479. disableFontFace: false,
  28480. disableNativeImageDecoder: false
  28481. };
  28482. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  28483. this.xref = xref;
  28484. this.resources = resources;
  28485. this.handler = handler;
  28486. this.forceDataSchema = forceDataSchema;
  28487. }
  28488. NativeImageDecoder.prototype = {
  28489. canDecode: function (image) {
  28490. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  28491. },
  28492. decode: function (image) {
  28493. var dict = image.dict;
  28494. var colorSpace = dict.get('ColorSpace', 'CS');
  28495. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  28496. var numComps = colorSpace.numComps;
  28497. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  28498. image.getIR(this.forceDataSchema),
  28499. numComps
  28500. ]);
  28501. return decodePromise.then(function (message) {
  28502. var data = message.data;
  28503. return new Stream(data, 0, data.length, image.dict);
  28504. });
  28505. }
  28506. };
  28507. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  28508. var dict = image.dict;
  28509. if (dict.has('DecodeParms') || dict.has('DP')) {
  28510. return false;
  28511. }
  28512. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28513. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28514. };
  28515. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  28516. var dict = image.dict;
  28517. if (dict.has('DecodeParms') || dict.has('DP')) {
  28518. return false;
  28519. }
  28520. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28521. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28522. };
  28523. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  28524. this.pdfManager = pdfManager;
  28525. this.xref = xref;
  28526. this.handler = handler;
  28527. this.pageIndex = pageIndex;
  28528. this.idFactory = idFactory;
  28529. this.fontCache = fontCache;
  28530. this.builtInCMapCache = builtInCMapCache;
  28531. this.options = options || DefaultPartialEvaluatorOptions;
  28532. this.fetchBuiltInCMap = function (name) {
  28533. var cachedCMap = builtInCMapCache[name];
  28534. if (cachedCMap) {
  28535. return Promise.resolve(cachedCMap);
  28536. }
  28537. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  28538. if (data.compressionType !== CMapCompressionType.NONE) {
  28539. builtInCMapCache[name] = data;
  28540. }
  28541. return data;
  28542. });
  28543. };
  28544. }
  28545. var TIME_SLOT_DURATION_MS = 20;
  28546. var CHECK_TIME_EVERY = 100;
  28547. function TimeSlotManager() {
  28548. this.reset();
  28549. }
  28550. TimeSlotManager.prototype = {
  28551. check: function TimeSlotManager_check() {
  28552. if (++this.checked < CHECK_TIME_EVERY) {
  28553. return false;
  28554. }
  28555. this.checked = 0;
  28556. return this.endTime <= Date.now();
  28557. },
  28558. reset: function TimeSlotManager_reset() {
  28559. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  28560. this.checked = 0;
  28561. }
  28562. };
  28563. var deferred = Promise.resolve();
  28564. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  28565. PartialEvaluator.prototype = {
  28566. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  28567. if (!isDict(resources)) {
  28568. return false;
  28569. }
  28570. var processed = Object.create(null);
  28571. if (resources.objId) {
  28572. processed[resources.objId] = true;
  28573. }
  28574. var nodes = [resources], xref = this.xref;
  28575. while (nodes.length) {
  28576. var key, i, ii;
  28577. var node = nodes.shift();
  28578. var graphicStates = node.get('ExtGState');
  28579. if (isDict(graphicStates)) {
  28580. var graphicStatesKeys = graphicStates.getKeys();
  28581. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  28582. key = graphicStatesKeys[i];
  28583. var graphicState = graphicStates.get(key);
  28584. var bm = graphicState.get('BM');
  28585. if (isName(bm) && bm.name !== 'Normal') {
  28586. return true;
  28587. }
  28588. }
  28589. }
  28590. var xObjects = node.get('XObject');
  28591. if (!isDict(xObjects)) {
  28592. continue;
  28593. }
  28594. var xObjectsKeys = xObjects.getKeys();
  28595. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  28596. key = xObjectsKeys[i];
  28597. var xObject = xObjects.getRaw(key);
  28598. if (isRef(xObject)) {
  28599. if (processed[xObject.toString()]) {
  28600. continue;
  28601. }
  28602. xObject = xref.fetch(xObject);
  28603. }
  28604. if (!isStream(xObject)) {
  28605. continue;
  28606. }
  28607. if (xObject.dict.objId) {
  28608. if (processed[xObject.dict.objId]) {
  28609. continue;
  28610. }
  28611. processed[xObject.dict.objId] = true;
  28612. }
  28613. var xResources = xObject.dict.get('Resources');
  28614. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  28615. nodes.push(xResources);
  28616. if (xResources.objId) {
  28617. processed[xResources.objId] = true;
  28618. }
  28619. }
  28620. }
  28621. }
  28622. return false;
  28623. },
  28624. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  28625. var matrix = xobj.dict.getArray('Matrix');
  28626. var bbox = xobj.dict.getArray('BBox');
  28627. var group = xobj.dict.get('Group');
  28628. if (group) {
  28629. var groupOptions = {
  28630. matrix: matrix,
  28631. bbox: bbox,
  28632. smask: smask,
  28633. isolated: false,
  28634. knockout: false
  28635. };
  28636. var groupSubtype = group.get('S');
  28637. var colorSpace;
  28638. if (isName(groupSubtype, 'Transparency')) {
  28639. groupOptions.isolated = group.get('I') || false;
  28640. groupOptions.knockout = group.get('K') || false;
  28641. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  28642. }
  28643. if (smask && smask.backdrop) {
  28644. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  28645. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  28646. }
  28647. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  28648. }
  28649. operatorList.addOp(OPS.paintFormXObjectBegin, [
  28650. matrix,
  28651. bbox
  28652. ]);
  28653. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  28654. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  28655. if (group) {
  28656. operatorList.addOp(OPS.endGroup, [groupOptions]);
  28657. }
  28658. });
  28659. },
  28660. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  28661. var self = this;
  28662. var dict = image.dict;
  28663. var w = dict.get('Width', 'W');
  28664. var h = dict.get('Height', 'H');
  28665. if (!(w && isNum(w)) || !(h && isNum(h))) {
  28666. warn('Image dimensions are missing, or not numbers.');
  28667. return;
  28668. }
  28669. var maxImageSize = this.options.maxImageSize;
  28670. if (maxImageSize !== -1 && w * h > maxImageSize) {
  28671. warn('Image exceeded maximum allowed size and was removed.');
  28672. return;
  28673. }
  28674. var imageMask = dict.get('ImageMask', 'IM') || false;
  28675. var imgData, args;
  28676. if (imageMask) {
  28677. var width = dict.get('Width', 'W');
  28678. var height = dict.get('Height', 'H');
  28679. var bitStrideLength = width + 7 >> 3;
  28680. var imgArray = image.getBytes(bitStrideLength * height);
  28681. var decode = dict.getArray('Decode', 'D');
  28682. var inverseDecode = !!decode && decode[0] > 0;
  28683. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  28684. imgData.cached = true;
  28685. args = [imgData];
  28686. operatorList.addOp(OPS.paintImageMaskXObject, args);
  28687. if (cacheKey) {
  28688. imageCache[cacheKey] = {
  28689. fn: OPS.paintImageMaskXObject,
  28690. args: args
  28691. };
  28692. }
  28693. return;
  28694. }
  28695. var softMask = dict.get('SMask', 'SM') || false;
  28696. var mask = dict.get('Mask') || false;
  28697. var SMALL_IMAGE_DIMENSIONS = 200;
  28698. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  28699. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  28700. imgData = imageObj.createImageData(true);
  28701. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  28702. return;
  28703. }
  28704. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  28705. var objId = 'img_' + this.idFactory.createObjId();
  28706. operatorList.addDependency(objId);
  28707. args = [
  28708. objId,
  28709. w,
  28710. h
  28711. ];
  28712. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  28713. operatorList.addOp(OPS.paintJpegXObject, args);
  28714. this.handler.send('obj', [
  28715. objId,
  28716. this.pageIndex,
  28717. 'JpegStream',
  28718. image.getIR(this.options.forceDataSchema)
  28719. ]);
  28720. return;
  28721. }
  28722. var nativeImageDecoder = null;
  28723. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  28724. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  28725. }
  28726. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  28727. var imgData = imageObj.createImageData(false);
  28728. self.handler.send('obj', [
  28729. objId,
  28730. self.pageIndex,
  28731. 'Image',
  28732. imgData
  28733. ], [imgData.data.buffer]);
  28734. }).then(undefined, function (reason) {
  28735. warn('Unable to decode image: ' + reason);
  28736. self.handler.send('obj', [
  28737. objId,
  28738. self.pageIndex,
  28739. 'Image',
  28740. null
  28741. ]);
  28742. });
  28743. operatorList.addOp(OPS.paintImageXObject, args);
  28744. if (cacheKey) {
  28745. imageCache[cacheKey] = {
  28746. fn: OPS.paintImageXObject,
  28747. args: args
  28748. };
  28749. }
  28750. },
  28751. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  28752. var smaskContent = smask.get('G');
  28753. var smaskOptions = {
  28754. subtype: smask.get('S').name,
  28755. backdrop: smask.get('BC')
  28756. };
  28757. var transferObj = smask.get('TR');
  28758. if (isPDFFunction(transferObj)) {
  28759. var transferFn = PDFFunction.parse(this.xref, transferObj);
  28760. var transferMap = new Uint8Array(256);
  28761. var tmp = new Float32Array(1);
  28762. for (var i = 0; i < 256; i++) {
  28763. tmp[0] = i / 255;
  28764. transferFn(tmp, 0, tmp, 0);
  28765. transferMap[i] = tmp[0] * 255 | 0;
  28766. }
  28767. smaskOptions.transferMap = transferMap;
  28768. }
  28769. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  28770. },
  28771. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  28772. var tilingOpList = new OperatorList();
  28773. var resourcesArray = [
  28774. patternDict.get('Resources'),
  28775. resources
  28776. ];
  28777. var patternResources = Dict.merge(this.xref, resourcesArray);
  28778. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  28779. operatorList.addDependencies(tilingOpList.dependencies);
  28780. operatorList.addOp(fn, getTilingPatternIR({
  28781. fnArray: tilingOpList.fnArray,
  28782. argsArray: tilingOpList.argsArray
  28783. }, patternDict, args));
  28784. });
  28785. },
  28786. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  28787. var fontName;
  28788. if (fontArgs) {
  28789. fontArgs = fontArgs.slice();
  28790. fontName = fontArgs[0].name;
  28791. }
  28792. var self = this;
  28793. return this.loadFont(fontName, fontRef, resources).then(function (translated) {
  28794. if (!translated.font.isType3Font) {
  28795. return translated;
  28796. }
  28797. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  28798. return translated;
  28799. }, function (reason) {
  28800. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28801. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  28802. });
  28803. }).then(function (translated) {
  28804. state.font = translated.font;
  28805. translated.send(self.handler);
  28806. return translated.loadedName;
  28807. });
  28808. },
  28809. handleText: function PartialEvaluator_handleText(chars, state) {
  28810. var font = state.font;
  28811. var glyphs = font.charsToGlyphs(chars);
  28812. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  28813. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  28814. var buildPath = function (fontChar) {
  28815. if (!font.renderer.hasBuiltPath(fontChar)) {
  28816. var path = font.renderer.getPathJs(fontChar);
  28817. this.handler.send('commonobj', [
  28818. font.loadedName + '_path_' + fontChar,
  28819. 'FontPath',
  28820. path
  28821. ]);
  28822. }
  28823. }.bind(this);
  28824. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  28825. var glyph = glyphs[i];
  28826. buildPath(glyph.fontChar);
  28827. var accent = glyph.accent;
  28828. if (accent && accent.fontChar) {
  28829. buildPath(accent.fontChar);
  28830. }
  28831. }
  28832. }
  28833. return glyphs;
  28834. },
  28835. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
  28836. var gStateObj = [];
  28837. var gStateKeys = gState.getKeys();
  28838. var self = this;
  28839. var promise = Promise.resolve();
  28840. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  28841. var key = gStateKeys[i];
  28842. var value = gState.get(key);
  28843. switch (key) {
  28844. case 'Type':
  28845. break;
  28846. case 'LW':
  28847. case 'LC':
  28848. case 'LJ':
  28849. case 'ML':
  28850. case 'D':
  28851. case 'RI':
  28852. case 'FL':
  28853. case 'CA':
  28854. case 'ca':
  28855. gStateObj.push([
  28856. key,
  28857. value
  28858. ]);
  28859. break;
  28860. case 'Font':
  28861. promise = promise.then(function () {
  28862. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  28863. operatorList.addDependency(loadedName);
  28864. gStateObj.push([
  28865. key,
  28866. [
  28867. loadedName,
  28868. value[1]
  28869. ]
  28870. ]);
  28871. });
  28872. });
  28873. break;
  28874. case 'BM':
  28875. gStateObj.push([
  28876. key,
  28877. value
  28878. ]);
  28879. break;
  28880. case 'SMask':
  28881. if (isName(value, 'None')) {
  28882. gStateObj.push([
  28883. key,
  28884. false
  28885. ]);
  28886. break;
  28887. }
  28888. if (isDict(value)) {
  28889. promise = promise.then(function (dict) {
  28890. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  28891. }.bind(this, value));
  28892. gStateObj.push([
  28893. key,
  28894. true
  28895. ]);
  28896. } else {
  28897. warn('Unsupported SMask type');
  28898. }
  28899. break;
  28900. case 'OP':
  28901. case 'op':
  28902. case 'OPM':
  28903. case 'BG':
  28904. case 'BG2':
  28905. case 'UCR':
  28906. case 'UCR2':
  28907. case 'TR':
  28908. case 'TR2':
  28909. case 'HT':
  28910. case 'SM':
  28911. case 'SA':
  28912. case 'AIS':
  28913. case 'TK':
  28914. info('graphic state operator ' + key);
  28915. break;
  28916. default:
  28917. info('Unknown graphic state operator ' + key);
  28918. break;
  28919. }
  28920. }
  28921. return promise.then(function () {
  28922. if (gStateObj.length > 0) {
  28923. operatorList.addOp(OPS.setGState, [gStateObj]);
  28924. }
  28925. });
  28926. },
  28927. loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
  28928. function errorFont() {
  28929. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  28930. }
  28931. var fontRef, xref = this.xref;
  28932. if (font) {
  28933. assert(isRef(font));
  28934. fontRef = font;
  28935. } else {
  28936. var fontRes = resources.get('Font');
  28937. if (fontRes) {
  28938. fontRef = fontRes.getRaw(fontName);
  28939. } else {
  28940. warn('fontRes not available');
  28941. return errorFont();
  28942. }
  28943. }
  28944. if (!fontRef) {
  28945. warn('fontRef not available');
  28946. return errorFont();
  28947. }
  28948. if (this.fontCache.has(fontRef)) {
  28949. return this.fontCache.get(fontRef);
  28950. }
  28951. font = xref.fetchIfRef(fontRef);
  28952. if (!isDict(font)) {
  28953. return errorFont();
  28954. }
  28955. if (font.translated) {
  28956. return font.translated;
  28957. }
  28958. var fontCapability = createPromiseCapability();
  28959. var preEvaluatedFont = this.preEvaluateFont(font);
  28960. var descriptor = preEvaluatedFont.descriptor;
  28961. var fontRefIsRef = isRef(fontRef), fontID;
  28962. if (fontRefIsRef) {
  28963. fontID = fontRef.toString();
  28964. }
  28965. if (isDict(descriptor)) {
  28966. if (!descriptor.fontAliases) {
  28967. descriptor.fontAliases = Object.create(null);
  28968. }
  28969. var fontAliases = descriptor.fontAliases;
  28970. var hash = preEvaluatedFont.hash;
  28971. if (fontAliases[hash]) {
  28972. var aliasFontRef = fontAliases[hash].aliasRef;
  28973. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  28974. this.fontCache.putAlias(fontRef, aliasFontRef);
  28975. return this.fontCache.get(fontRef);
  28976. }
  28977. } else {
  28978. fontAliases[hash] = { fontID: Font.getFontID() };
  28979. }
  28980. if (fontRefIsRef) {
  28981. fontAliases[hash].aliasRef = fontRef;
  28982. }
  28983. fontID = fontAliases[hash].fontID;
  28984. }
  28985. if (fontRefIsRef) {
  28986. this.fontCache.put(fontRef, fontCapability.promise);
  28987. } else {
  28988. if (!fontID) {
  28989. fontID = this.idFactory.createObjId();
  28990. }
  28991. this.fontCache.put('id_' + fontID, fontCapability.promise);
  28992. }
  28993. assert(fontID, 'The "fontID" must be defined.');
  28994. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  28995. font.translated = fontCapability.promise;
  28996. var translatedPromise;
  28997. try {
  28998. translatedPromise = this.translateFont(preEvaluatedFont);
  28999. } catch (e) {
  29000. translatedPromise = Promise.reject(e);
  29001. }
  29002. var self = this;
  29003. translatedPromise.then(function (translatedFont) {
  29004. if (translatedFont.fontType !== undefined) {
  29005. var xrefFontStats = xref.stats.fontTypes;
  29006. xrefFontStats[translatedFont.fontType] = true;
  29007. }
  29008. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29009. }, function (reason) {
  29010. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29011. try {
  29012. var descriptor = preEvaluatedFont.descriptor;
  29013. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29014. var subtype = fontFile3 && fontFile3.get('Subtype');
  29015. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29016. var xrefFontStats = xref.stats.fontTypes;
  29017. xrefFontStats[fontType] = true;
  29018. } catch (ex) {
  29019. }
  29020. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29021. });
  29022. return fontCapability.promise;
  29023. },
  29024. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29025. var lastIndex = operatorList.length - 1;
  29026. if (!args) {
  29027. args = [];
  29028. }
  29029. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29030. operatorList.addOp(OPS.constructPath, [
  29031. [fn],
  29032. args
  29033. ]);
  29034. } else {
  29035. var opArgs = operatorList.argsArray[lastIndex];
  29036. opArgs[0].push(fn);
  29037. Array.prototype.push.apply(opArgs[1], args);
  29038. }
  29039. },
  29040. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
  29041. var patternName = args[args.length - 1];
  29042. var pattern;
  29043. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29044. var dict = isStream(pattern) ? pattern.dict : pattern;
  29045. var typeNum = dict.get('PatternType');
  29046. if (typeNum === TILING_PATTERN) {
  29047. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29048. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29049. } else if (typeNum === SHADING_PATTERN) {
  29050. var shading = dict.get('Shading');
  29051. var matrix = dict.getArray('Matrix');
  29052. pattern = Pattern.parseShading(shading, matrix, this.xref, resources, this.handler);
  29053. operatorList.addOp(fn, pattern.getIR());
  29054. return Promise.resolve();
  29055. }
  29056. return Promise.reject('Unknown PatternType: ' + typeNum);
  29057. }
  29058. operatorList.addOp(fn, args);
  29059. return Promise.resolve();
  29060. },
  29061. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29062. var self = this;
  29063. var xref = this.xref;
  29064. var imageCache = Object.create(null);
  29065. assert(operatorList);
  29066. resources = resources || Dict.empty;
  29067. var xobjs = resources.get('XObject') || Dict.empty;
  29068. var patterns = resources.get('Pattern') || Dict.empty;
  29069. var stateManager = new StateManager(initialState || new EvalState());
  29070. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29071. var timeSlotManager = new TimeSlotManager();
  29072. return new Promise(function promiseBody(resolve, reject) {
  29073. var next = function (promise) {
  29074. promise.then(function () {
  29075. try {
  29076. promiseBody(resolve, reject);
  29077. } catch (ex) {
  29078. reject(ex);
  29079. }
  29080. }, reject);
  29081. };
  29082. task.ensureNotTerminated();
  29083. timeSlotManager.reset();
  29084. var stop, operation = {}, i, ii, cs;
  29085. while (!(stop = timeSlotManager.check())) {
  29086. operation.args = null;
  29087. if (!preprocessor.read(operation)) {
  29088. break;
  29089. }
  29090. var args = operation.args;
  29091. var fn = operation.fn;
  29092. switch (fn | 0) {
  29093. case OPS.paintXObject:
  29094. if (args[0].code) {
  29095. break;
  29096. }
  29097. var name = args[0].name;
  29098. if (!name) {
  29099. warn('XObject must be referred to by name.');
  29100. continue;
  29101. }
  29102. if (imageCache[name] !== undefined) {
  29103. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29104. args = null;
  29105. continue;
  29106. }
  29107. var xobj = xobjs.get(name);
  29108. if (xobj) {
  29109. assert(isStream(xobj), 'XObject should be a stream');
  29110. var type = xobj.dict.get('Subtype');
  29111. assert(isName(type), 'XObject should have a Name subtype');
  29112. if (type.name === 'Form') {
  29113. stateManager.save();
  29114. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29115. stateManager.restore();
  29116. }));
  29117. return;
  29118. } else if (type.name === 'Image') {
  29119. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29120. args = null;
  29121. continue;
  29122. } else if (type.name === 'PS') {
  29123. info('Ignored XObject subtype PS');
  29124. continue;
  29125. } else {
  29126. error('Unhandled XObject subtype ' + type.name);
  29127. }
  29128. }
  29129. break;
  29130. case OPS.setFont:
  29131. var fontSize = args[1];
  29132. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29133. operatorList.addDependency(loadedName);
  29134. operatorList.addOp(OPS.setFont, [
  29135. loadedName,
  29136. fontSize
  29137. ]);
  29138. }));
  29139. return;
  29140. case OPS.endInlineImage:
  29141. var cacheKey = args[0].cacheKey;
  29142. if (cacheKey) {
  29143. var cacheEntry = imageCache[cacheKey];
  29144. if (cacheEntry !== undefined) {
  29145. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29146. args = null;
  29147. continue;
  29148. }
  29149. }
  29150. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29151. args = null;
  29152. continue;
  29153. case OPS.showText:
  29154. args[0] = self.handleText(args[0], stateManager.state);
  29155. break;
  29156. case OPS.showSpacedText:
  29157. var arr = args[0];
  29158. var combinedGlyphs = [];
  29159. var arrLength = arr.length;
  29160. var state = stateManager.state;
  29161. for (i = 0; i < arrLength; ++i) {
  29162. var arrItem = arr[i];
  29163. if (isString(arrItem)) {
  29164. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29165. } else if (isNum(arrItem)) {
  29166. combinedGlyphs.push(arrItem);
  29167. }
  29168. }
  29169. args[0] = combinedGlyphs;
  29170. fn = OPS.showText;
  29171. break;
  29172. case OPS.nextLineShowText:
  29173. operatorList.addOp(OPS.nextLine);
  29174. args[0] = self.handleText(args[0], stateManager.state);
  29175. fn = OPS.showText;
  29176. break;
  29177. case OPS.nextLineSetSpacingShowText:
  29178. operatorList.addOp(OPS.nextLine);
  29179. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29180. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29181. args[0] = self.handleText(args[0], stateManager.state);
  29182. fn = OPS.showText;
  29183. break;
  29184. case OPS.setTextRenderingMode:
  29185. stateManager.state.textRenderingMode = args[0];
  29186. break;
  29187. case OPS.setFillColorSpace:
  29188. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29189. continue;
  29190. case OPS.setStrokeColorSpace:
  29191. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29192. continue;
  29193. case OPS.setFillColor:
  29194. cs = stateManager.state.fillColorSpace;
  29195. args = cs.getRgb(args, 0);
  29196. fn = OPS.setFillRGBColor;
  29197. break;
  29198. case OPS.setStrokeColor:
  29199. cs = stateManager.state.strokeColorSpace;
  29200. args = cs.getRgb(args, 0);
  29201. fn = OPS.setStrokeRGBColor;
  29202. break;
  29203. case OPS.setFillGray:
  29204. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29205. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29206. fn = OPS.setFillRGBColor;
  29207. break;
  29208. case OPS.setStrokeGray:
  29209. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29210. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29211. fn = OPS.setStrokeRGBColor;
  29212. break;
  29213. case OPS.setFillCMYKColor:
  29214. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29215. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29216. fn = OPS.setFillRGBColor;
  29217. break;
  29218. case OPS.setStrokeCMYKColor:
  29219. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29220. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29221. fn = OPS.setStrokeRGBColor;
  29222. break;
  29223. case OPS.setFillRGBColor:
  29224. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29225. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29226. break;
  29227. case OPS.setStrokeRGBColor:
  29228. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29229. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29230. break;
  29231. case OPS.setFillColorN:
  29232. cs = stateManager.state.fillColorSpace;
  29233. if (cs.name === 'Pattern') {
  29234. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task));
  29235. return;
  29236. }
  29237. args = cs.getRgb(args, 0);
  29238. fn = OPS.setFillRGBColor;
  29239. break;
  29240. case OPS.setStrokeColorN:
  29241. cs = stateManager.state.strokeColorSpace;
  29242. if (cs.name === 'Pattern') {
  29243. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task));
  29244. return;
  29245. }
  29246. args = cs.getRgb(args, 0);
  29247. fn = OPS.setStrokeRGBColor;
  29248. break;
  29249. case OPS.shadingFill:
  29250. var shadingRes = resources.get('Shading');
  29251. assert(shadingRes, 'No shading resource found');
  29252. var shading = shadingRes.get(args[0].name);
  29253. assert(shading, 'No shading object found');
  29254. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29255. var patternIR = shadingFill.getIR();
  29256. args = [patternIR];
  29257. fn = OPS.shadingFill;
  29258. break;
  29259. case OPS.setGState:
  29260. var dictName = args[0];
  29261. var extGState = resources.get('ExtGState');
  29262. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29263. break;
  29264. }
  29265. var gState = extGState.get(dictName.name);
  29266. next(self.setGState(resources, gState, operatorList, task, stateManager));
  29267. return;
  29268. case OPS.moveTo:
  29269. case OPS.lineTo:
  29270. case OPS.curveTo:
  29271. case OPS.curveTo2:
  29272. case OPS.curveTo3:
  29273. case OPS.closePath:
  29274. self.buildPath(operatorList, fn, args);
  29275. continue;
  29276. case OPS.rectangle:
  29277. self.buildPath(operatorList, fn, args);
  29278. continue;
  29279. case OPS.markPoint:
  29280. case OPS.markPointProps:
  29281. case OPS.beginMarkedContent:
  29282. case OPS.beginMarkedContentProps:
  29283. case OPS.endMarkedContent:
  29284. case OPS.beginCompat:
  29285. case OPS.endCompat:
  29286. continue;
  29287. default:
  29288. if (args !== null) {
  29289. for (i = 0, ii = args.length; i < ii; i++) {
  29290. if (args[i] instanceof Dict) {
  29291. break;
  29292. }
  29293. }
  29294. if (i < ii) {
  29295. warn('getOperatorList - ignoring operator: ' + fn);
  29296. continue;
  29297. }
  29298. }
  29299. }
  29300. operatorList.addOp(fn, args);
  29301. }
  29302. if (stop) {
  29303. next(deferred);
  29304. return;
  29305. }
  29306. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  29307. operatorList.addOp(OPS.restore, []);
  29308. }
  29309. resolve();
  29310. });
  29311. },
  29312. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  29313. stateManager = stateManager || new StateManager(new TextState());
  29314. var WhitespaceRegexp = /\s/g;
  29315. var textContent = {
  29316. items: [],
  29317. styles: Object.create(null)
  29318. };
  29319. var textContentItem = {
  29320. initialized: false,
  29321. str: [],
  29322. width: 0,
  29323. height: 0,
  29324. vertical: false,
  29325. lastAdvanceWidth: 0,
  29326. lastAdvanceHeight: 0,
  29327. textAdvanceScale: 0,
  29328. spaceWidth: 0,
  29329. fakeSpaceMin: Infinity,
  29330. fakeMultiSpaceMin: Infinity,
  29331. fakeMultiSpaceMax: -0,
  29332. textRunBreakAllowed: false,
  29333. transform: null,
  29334. fontName: null
  29335. };
  29336. var SPACE_FACTOR = 0.3;
  29337. var MULTI_SPACE_FACTOR = 1.5;
  29338. var MULTI_SPACE_FACTOR_MAX = 4;
  29339. var self = this;
  29340. var xref = this.xref;
  29341. resources = xref.fetchIfRef(resources) || Dict.empty;
  29342. var xobjs = null;
  29343. var xobjsCache = Object.create(null);
  29344. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29345. var textState;
  29346. function ensureTextContentItem() {
  29347. if (textContentItem.initialized) {
  29348. return textContentItem;
  29349. }
  29350. var font = textState.font;
  29351. if (!(font.loadedName in textContent.styles)) {
  29352. textContent.styles[font.loadedName] = {
  29353. fontFamily: font.fallbackName,
  29354. ascent: font.ascent,
  29355. descent: font.descent,
  29356. vertical: font.vertical
  29357. };
  29358. }
  29359. textContentItem.fontName = font.loadedName;
  29360. var tsm = [
  29361. textState.fontSize * textState.textHScale,
  29362. 0,
  29363. 0,
  29364. textState.fontSize,
  29365. 0,
  29366. textState.textRise
  29367. ];
  29368. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  29369. var glyphHeight = font.bbox[3] - font.bbox[1];
  29370. if (glyphHeight > 0) {
  29371. glyphHeight = glyphHeight * textState.fontMatrix[3];
  29372. tsm[3] *= glyphHeight;
  29373. }
  29374. }
  29375. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  29376. textContentItem.transform = trm;
  29377. if (!font.vertical) {
  29378. textContentItem.width = 0;
  29379. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  29380. textContentItem.vertical = false;
  29381. } else {
  29382. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  29383. textContentItem.height = 0;
  29384. textContentItem.vertical = true;
  29385. }
  29386. var a = textState.textLineMatrix[0];
  29387. var b = textState.textLineMatrix[1];
  29388. var scaleLineX = Math.sqrt(a * a + b * b);
  29389. a = textState.ctm[0];
  29390. b = textState.ctm[1];
  29391. var scaleCtmX = Math.sqrt(a * a + b * b);
  29392. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  29393. textContentItem.lastAdvanceWidth = 0;
  29394. textContentItem.lastAdvanceHeight = 0;
  29395. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  29396. if (spaceWidth) {
  29397. textContentItem.spaceWidth = spaceWidth;
  29398. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  29399. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  29400. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  29401. textContentItem.textRunBreakAllowed = !font.isMonospace;
  29402. } else {
  29403. textContentItem.spaceWidth = 0;
  29404. textContentItem.fakeSpaceMin = Infinity;
  29405. textContentItem.fakeMultiSpaceMin = Infinity;
  29406. textContentItem.fakeMultiSpaceMax = 0;
  29407. textContentItem.textRunBreakAllowed = false;
  29408. }
  29409. textContentItem.initialized = true;
  29410. return textContentItem;
  29411. }
  29412. function replaceWhitespace(str) {
  29413. var i = 0, ii = str.length, code;
  29414. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  29415. i++;
  29416. }
  29417. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  29418. }
  29419. function runBidiTransform(textChunk) {
  29420. var str = textChunk.str.join('');
  29421. var bidiResult = bidi(str, -1, textChunk.vertical);
  29422. return {
  29423. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  29424. dir: bidiResult.dir,
  29425. width: textChunk.width,
  29426. height: textChunk.height,
  29427. transform: textChunk.transform,
  29428. fontName: textChunk.fontName
  29429. };
  29430. }
  29431. function handleSetFont(fontName, fontRef) {
  29432. return self.loadFont(fontName, fontRef, resources).then(function (translated) {
  29433. textState.font = translated.font;
  29434. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  29435. });
  29436. }
  29437. function buildTextContentItem(chars) {
  29438. var font = textState.font;
  29439. var textChunk = ensureTextContentItem();
  29440. var width = 0;
  29441. var height = 0;
  29442. var glyphs = font.charsToGlyphs(chars);
  29443. for (var i = 0; i < glyphs.length; i++) {
  29444. var glyph = glyphs[i];
  29445. var glyphWidth = null;
  29446. if (font.vertical && glyph.vmetric) {
  29447. glyphWidth = glyph.vmetric[0];
  29448. } else {
  29449. glyphWidth = glyph.width;
  29450. }
  29451. var glyphUnicode = glyph.unicode;
  29452. var NormalizedUnicodes = getNormalizedUnicodes();
  29453. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  29454. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  29455. }
  29456. glyphUnicode = reverseIfRtl(glyphUnicode);
  29457. var charSpacing = textState.charSpacing;
  29458. if (glyph.isSpace) {
  29459. var wordSpacing = textState.wordSpacing;
  29460. charSpacing += wordSpacing;
  29461. if (wordSpacing > 0) {
  29462. addFakeSpaces(wordSpacing, textChunk.str);
  29463. }
  29464. }
  29465. var tx = 0;
  29466. var ty = 0;
  29467. if (!font.vertical) {
  29468. var w0 = glyphWidth * textState.fontMatrix[0];
  29469. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  29470. width += tx;
  29471. } else {
  29472. var w1 = glyphWidth * textState.fontMatrix[0];
  29473. ty = w1 * textState.fontSize + charSpacing;
  29474. height += ty;
  29475. }
  29476. textState.translateTextMatrix(tx, ty);
  29477. textChunk.str.push(glyphUnicode);
  29478. }
  29479. if (!font.vertical) {
  29480. textChunk.lastAdvanceWidth = width;
  29481. textChunk.width += width;
  29482. } else {
  29483. textChunk.lastAdvanceHeight = height;
  29484. textChunk.height += Math.abs(height);
  29485. }
  29486. return textChunk;
  29487. }
  29488. function addFakeSpaces(width, strBuf) {
  29489. if (width < textContentItem.fakeSpaceMin) {
  29490. return;
  29491. }
  29492. if (width < textContentItem.fakeMultiSpaceMin) {
  29493. strBuf.push(' ');
  29494. return;
  29495. }
  29496. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  29497. while (fakeSpaces-- > 0) {
  29498. strBuf.push(' ');
  29499. }
  29500. }
  29501. function flushTextContentItem() {
  29502. if (!textContentItem.initialized) {
  29503. return;
  29504. }
  29505. textContentItem.width *= textContentItem.textAdvanceScale;
  29506. textContentItem.height *= textContentItem.textAdvanceScale;
  29507. textContent.items.push(runBidiTransform(textContentItem));
  29508. textContentItem.initialized = false;
  29509. textContentItem.str.length = 0;
  29510. }
  29511. var timeSlotManager = new TimeSlotManager();
  29512. return new Promise(function promiseBody(resolve, reject) {
  29513. var next = function (promise) {
  29514. promise.then(function () {
  29515. try {
  29516. promiseBody(resolve, reject);
  29517. } catch (ex) {
  29518. reject(ex);
  29519. }
  29520. }, reject);
  29521. };
  29522. task.ensureNotTerminated();
  29523. timeSlotManager.reset();
  29524. var stop, operation = {}, args = [];
  29525. while (!(stop = timeSlotManager.check())) {
  29526. args.length = 0;
  29527. operation.args = args;
  29528. if (!preprocessor.read(operation)) {
  29529. break;
  29530. }
  29531. textState = stateManager.state;
  29532. var fn = operation.fn;
  29533. args = operation.args;
  29534. var advance, diff;
  29535. switch (fn | 0) {
  29536. case OPS.setFont:
  29537. var fontNameArg = args[0].name, fontSizeArg = args[1];
  29538. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  29539. break;
  29540. }
  29541. flushTextContentItem();
  29542. textState.fontName = fontNameArg;
  29543. textState.fontSize = fontSizeArg;
  29544. next(handleSetFont(fontNameArg, null));
  29545. return;
  29546. case OPS.setTextRise:
  29547. flushTextContentItem();
  29548. textState.textRise = args[0];
  29549. break;
  29550. case OPS.setHScale:
  29551. flushTextContentItem();
  29552. textState.textHScale = args[0] / 100;
  29553. break;
  29554. case OPS.setLeading:
  29555. flushTextContentItem();
  29556. textState.leading = args[0];
  29557. break;
  29558. case OPS.moveText:
  29559. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  29560. advance = args[0] - args[1];
  29561. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  29562. textState.translateTextLineMatrix(args[0], args[1]);
  29563. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  29564. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  29565. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  29566. addFakeSpaces(diff, textContentItem.str);
  29567. break;
  29568. }
  29569. flushTextContentItem();
  29570. textState.translateTextLineMatrix(args[0], args[1]);
  29571. textState.textMatrix = textState.textLineMatrix.slice();
  29572. break;
  29573. case OPS.setLeadingMoveText:
  29574. flushTextContentItem();
  29575. textState.leading = -args[1];
  29576. textState.translateTextLineMatrix(args[0], args[1]);
  29577. textState.textMatrix = textState.textLineMatrix.slice();
  29578. break;
  29579. case OPS.nextLine:
  29580. flushTextContentItem();
  29581. textState.carriageReturn();
  29582. break;
  29583. case OPS.setTextMatrix:
  29584. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  29585. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  29586. textState.translateTextLineMatrix(advance.width, advance.height);
  29587. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  29588. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  29589. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  29590. addFakeSpaces(diff, textContentItem.str);
  29591. break;
  29592. }
  29593. flushTextContentItem();
  29594. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29595. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29596. break;
  29597. case OPS.setCharSpacing:
  29598. textState.charSpacing = args[0];
  29599. break;
  29600. case OPS.setWordSpacing:
  29601. textState.wordSpacing = args[0];
  29602. break;
  29603. case OPS.beginText:
  29604. flushTextContentItem();
  29605. textState.textMatrix = IDENTITY_MATRIX.slice();
  29606. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  29607. break;
  29608. case OPS.showSpacedText:
  29609. var items = args[0];
  29610. var offset;
  29611. for (var j = 0, jj = items.length; j < jj; j++) {
  29612. if (typeof items[j] === 'string') {
  29613. buildTextContentItem(items[j]);
  29614. } else if (isNum(items[j])) {
  29615. ensureTextContentItem();
  29616. advance = items[j] * textState.fontSize / 1000;
  29617. var breakTextRun = false;
  29618. if (textState.font.vertical) {
  29619. offset = advance;
  29620. textState.translateTextMatrix(0, offset);
  29621. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29622. if (!breakTextRun) {
  29623. textContentItem.height += offset;
  29624. }
  29625. } else {
  29626. advance = -advance;
  29627. offset = advance * textState.textHScale;
  29628. textState.translateTextMatrix(offset, 0);
  29629. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29630. if (!breakTextRun) {
  29631. textContentItem.width += offset;
  29632. }
  29633. }
  29634. if (breakTextRun) {
  29635. flushTextContentItem();
  29636. } else if (advance > 0) {
  29637. addFakeSpaces(advance, textContentItem.str);
  29638. }
  29639. }
  29640. }
  29641. break;
  29642. case OPS.showText:
  29643. buildTextContentItem(args[0]);
  29644. break;
  29645. case OPS.nextLineShowText:
  29646. flushTextContentItem();
  29647. textState.carriageReturn();
  29648. buildTextContentItem(args[0]);
  29649. break;
  29650. case OPS.nextLineSetSpacingShowText:
  29651. flushTextContentItem();
  29652. textState.wordSpacing = args[0];
  29653. textState.charSpacing = args[1];
  29654. textState.carriageReturn();
  29655. buildTextContentItem(args[2]);
  29656. break;
  29657. case OPS.paintXObject:
  29658. flushTextContentItem();
  29659. if (args[0].code) {
  29660. break;
  29661. }
  29662. if (!xobjs) {
  29663. xobjs = resources.get('XObject') || Dict.empty;
  29664. }
  29665. var name = args[0].name;
  29666. if (xobjsCache.key === name) {
  29667. if (xobjsCache.texts) {
  29668. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  29669. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  29670. }
  29671. break;
  29672. }
  29673. var xobj = xobjs.get(name);
  29674. if (!xobj) {
  29675. break;
  29676. }
  29677. assert(isStream(xobj), 'XObject should be a stream');
  29678. var type = xobj.dict.get('Subtype');
  29679. assert(isName(type), 'XObject should have a Name subtype');
  29680. if (type.name !== 'Form') {
  29681. xobjsCache.key = name;
  29682. xobjsCache.texts = null;
  29683. break;
  29684. }
  29685. stateManager.save();
  29686. var matrix = xobj.dict.getArray('Matrix');
  29687. if (isArray(matrix) && matrix.length === 6) {
  29688. stateManager.transform(matrix);
  29689. }
  29690. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  29691. Util.appendToArray(textContent.items, formTextContent.items);
  29692. Util.extendObj(textContent.styles, formTextContent.styles);
  29693. stateManager.restore();
  29694. xobjsCache.key = name;
  29695. xobjsCache.texts = formTextContent;
  29696. }));
  29697. return;
  29698. case OPS.setGState:
  29699. flushTextContentItem();
  29700. var dictName = args[0];
  29701. var extGState = resources.get('ExtGState');
  29702. if (!isDict(extGState) || !isName(dictName)) {
  29703. break;
  29704. }
  29705. var gState = extGState.get(dictName.name);
  29706. if (!isDict(gState)) {
  29707. break;
  29708. }
  29709. var gStateFont = gState.get('Font');
  29710. if (gStateFont) {
  29711. textState.fontName = null;
  29712. textState.fontSize = gStateFont[1];
  29713. next(handleSetFont(null, gStateFont[0]));
  29714. return;
  29715. }
  29716. break;
  29717. }
  29718. }
  29719. if (stop) {
  29720. next(deferred);
  29721. return;
  29722. }
  29723. flushTextContentItem();
  29724. resolve(textContent);
  29725. });
  29726. },
  29727. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
  29728. var xref = this.xref;
  29729. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  29730. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  29731. if (properties.composite) {
  29732. var cidSystemInfo = dict.get('CIDSystemInfo');
  29733. if (isDict(cidSystemInfo)) {
  29734. properties.cidSystemInfo = {
  29735. registry: cidSystemInfo.get('Registry'),
  29736. ordering: cidSystemInfo.get('Ordering'),
  29737. supplement: cidSystemInfo.get('Supplement')
  29738. };
  29739. }
  29740. var cidToGidMap = dict.get('CIDToGIDMap');
  29741. if (isStream(cidToGidMap)) {
  29742. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  29743. }
  29744. }
  29745. var differences = [];
  29746. var baseEncodingName = null;
  29747. var encoding;
  29748. if (dict.has('Encoding')) {
  29749. encoding = dict.get('Encoding');
  29750. if (isDict(encoding)) {
  29751. baseEncodingName = encoding.get('BaseEncoding');
  29752. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  29753. if (encoding.has('Differences')) {
  29754. var diffEncoding = encoding.get('Differences');
  29755. var index = 0;
  29756. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  29757. var data = xref.fetchIfRef(diffEncoding[j]);
  29758. if (isNum(data)) {
  29759. index = data;
  29760. } else if (isName(data)) {
  29761. differences[index++] = data.name;
  29762. } else {
  29763. error('Invalid entry in \'Differences\' array: ' + data);
  29764. }
  29765. }
  29766. }
  29767. } else if (isName(encoding)) {
  29768. baseEncodingName = encoding.name;
  29769. } else {
  29770. error('Encoding is not a Name nor a Dict');
  29771. }
  29772. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  29773. baseEncodingName = null;
  29774. }
  29775. }
  29776. if (baseEncodingName) {
  29777. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  29778. } else {
  29779. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  29780. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  29781. encoding = StandardEncoding;
  29782. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  29783. encoding = WinAnsiEncoding;
  29784. }
  29785. if (isSymbolicFont) {
  29786. encoding = MacRomanEncoding;
  29787. if (!properties.file) {
  29788. if (/Symbol/i.test(properties.name)) {
  29789. encoding = SymbolSetEncoding;
  29790. } else if (/Dingbats/i.test(properties.name)) {
  29791. encoding = ZapfDingbatsEncoding;
  29792. }
  29793. }
  29794. }
  29795. properties.defaultEncoding = encoding;
  29796. }
  29797. properties.differences = differences;
  29798. properties.baseEncodingName = baseEncodingName;
  29799. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  29800. properties.dict = dict;
  29801. return toUnicodePromise.then(function (toUnicode) {
  29802. properties.toUnicode = toUnicode;
  29803. return this.buildToUnicode(properties);
  29804. }.bind(this)).then(function (toUnicode) {
  29805. properties.toUnicode = toUnicode;
  29806. return properties;
  29807. });
  29808. },
  29809. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  29810. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  29811. if (properties.hasIncludedToUnicodeMap) {
  29812. return Promise.resolve(properties.toUnicode);
  29813. }
  29814. var toUnicode, charcode, glyphName;
  29815. if (!properties.composite) {
  29816. toUnicode = [];
  29817. var encoding = properties.defaultEncoding.slice();
  29818. var baseEncodingName = properties.baseEncodingName;
  29819. var differences = properties.differences;
  29820. for (charcode in differences) {
  29821. glyphName = differences[charcode];
  29822. if (glyphName === '.notdef') {
  29823. continue;
  29824. }
  29825. encoding[charcode] = glyphName;
  29826. }
  29827. var glyphsUnicodeMap = getGlyphsUnicode();
  29828. for (charcode in encoding) {
  29829. glyphName = encoding[charcode];
  29830. if (glyphName === '') {
  29831. continue;
  29832. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  29833. var code = 0;
  29834. switch (glyphName[0]) {
  29835. case 'G':
  29836. if (glyphName.length === 3) {
  29837. code = parseInt(glyphName.substr(1), 16);
  29838. }
  29839. break;
  29840. case 'g':
  29841. if (glyphName.length === 5) {
  29842. code = parseInt(glyphName.substr(1), 16);
  29843. }
  29844. break;
  29845. case 'C':
  29846. case 'c':
  29847. if (glyphName.length >= 3) {
  29848. code = +glyphName.substr(1);
  29849. }
  29850. break;
  29851. default:
  29852. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  29853. if (unicode !== -1) {
  29854. code = unicode;
  29855. }
  29856. }
  29857. if (code) {
  29858. if (baseEncodingName && code === +charcode) {
  29859. var baseEncoding = getEncoding(baseEncodingName);
  29860. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  29861. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29862. continue;
  29863. }
  29864. }
  29865. toUnicode[charcode] = String.fromCharCode(code);
  29866. }
  29867. continue;
  29868. }
  29869. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29870. }
  29871. return Promise.resolve(new ToUnicodeMap(toUnicode));
  29872. }
  29873. 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'))) {
  29874. var registry = properties.cidSystemInfo.registry;
  29875. var ordering = properties.cidSystemInfo.ordering;
  29876. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  29877. return CMapFactory.create({
  29878. encoding: ucs2CMapName,
  29879. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29880. useCMap: null
  29881. }).then(function (ucs2CMap) {
  29882. var cMap = properties.cMap;
  29883. toUnicode = [];
  29884. cMap.forEach(function (charcode, cid) {
  29885. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  29886. var ucs2 = ucs2CMap.lookup(cid);
  29887. if (ucs2) {
  29888. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  29889. }
  29890. });
  29891. return new ToUnicodeMap(toUnicode);
  29892. });
  29893. }
  29894. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  29895. },
  29896. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  29897. var cmapObj = toUnicode;
  29898. if (isName(cmapObj)) {
  29899. return CMapFactory.create({
  29900. encoding: cmapObj,
  29901. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29902. useCMap: null
  29903. }).then(function (cmap) {
  29904. if (cmap instanceof IdentityCMap) {
  29905. return new IdentityToUnicodeMap(0, 0xFFFF);
  29906. }
  29907. return new ToUnicodeMap(cmap.getMap());
  29908. });
  29909. } else if (isStream(cmapObj)) {
  29910. return CMapFactory.create({
  29911. encoding: cmapObj,
  29912. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29913. useCMap: null
  29914. }).then(function (cmap) {
  29915. if (cmap instanceof IdentityCMap) {
  29916. return new IdentityToUnicodeMap(0, 0xFFFF);
  29917. }
  29918. var map = new Array(cmap.length);
  29919. cmap.forEach(function (charCode, token) {
  29920. var str = [];
  29921. for (var k = 0; k < token.length; k += 2) {
  29922. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29923. if ((w1 & 0xF800) !== 0xD800) {
  29924. str.push(w1);
  29925. continue;
  29926. }
  29927. k += 2;
  29928. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29929. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  29930. }
  29931. map[charCode] = String.fromCharCode.apply(String, str);
  29932. });
  29933. return new ToUnicodeMap(map);
  29934. });
  29935. }
  29936. return Promise.resolve(null);
  29937. },
  29938. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  29939. var glyphsData = cidToGidStream.getBytes();
  29940. var result = [];
  29941. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  29942. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  29943. if (glyphID === 0) {
  29944. continue;
  29945. }
  29946. var code = j >> 1;
  29947. result[code] = glyphID;
  29948. }
  29949. return result;
  29950. },
  29951. extractWidths: function PartialEvaluator_extractWidths(dict, descriptor, properties) {
  29952. var xref = this.xref;
  29953. var glyphsWidths = [];
  29954. var defaultWidth = 0;
  29955. var glyphsVMetrics = [];
  29956. var defaultVMetrics;
  29957. var i, ii, j, jj, start, code, widths;
  29958. if (properties.composite) {
  29959. defaultWidth = dict.get('DW') || 1000;
  29960. widths = dict.get('W');
  29961. if (widths) {
  29962. for (i = 0, ii = widths.length; i < ii; i++) {
  29963. start = xref.fetchIfRef(widths[i++]);
  29964. code = xref.fetchIfRef(widths[i]);
  29965. if (isArray(code)) {
  29966. for (j = 0, jj = code.length; j < jj; j++) {
  29967. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  29968. }
  29969. } else {
  29970. var width = xref.fetchIfRef(widths[++i]);
  29971. for (j = start; j <= code; j++) {
  29972. glyphsWidths[j] = width;
  29973. }
  29974. }
  29975. }
  29976. }
  29977. if (properties.vertical) {
  29978. var vmetrics = dict.getArray('DW2') || [
  29979. 880,
  29980. -1000
  29981. ];
  29982. defaultVMetrics = [
  29983. vmetrics[1],
  29984. defaultWidth * 0.5,
  29985. vmetrics[0]
  29986. ];
  29987. vmetrics = dict.get('W2');
  29988. if (vmetrics) {
  29989. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  29990. start = xref.fetchIfRef(vmetrics[i++]);
  29991. code = xref.fetchIfRef(vmetrics[i]);
  29992. if (isArray(code)) {
  29993. for (j = 0, jj = code.length; j < jj; j++) {
  29994. glyphsVMetrics[start++] = [
  29995. xref.fetchIfRef(code[j++]),
  29996. xref.fetchIfRef(code[j++]),
  29997. xref.fetchIfRef(code[j])
  29998. ];
  29999. }
  30000. } else {
  30001. var vmetric = [
  30002. xref.fetchIfRef(vmetrics[++i]),
  30003. xref.fetchIfRef(vmetrics[++i]),
  30004. xref.fetchIfRef(vmetrics[++i])
  30005. ];
  30006. for (j = start; j <= code; j++) {
  30007. glyphsVMetrics[j] = vmetric;
  30008. }
  30009. }
  30010. }
  30011. }
  30012. }
  30013. } else {
  30014. var firstChar = properties.firstChar;
  30015. widths = dict.get('Widths');
  30016. if (widths) {
  30017. j = firstChar;
  30018. for (i = 0, ii = widths.length; i < ii; i++) {
  30019. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30020. }
  30021. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30022. } else {
  30023. var baseFontName = dict.get('BaseFont');
  30024. if (isName(baseFontName)) {
  30025. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30026. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30027. defaultWidth = metrics.defaultWidth;
  30028. }
  30029. }
  30030. }
  30031. var isMonospace = true;
  30032. var firstWidth = defaultWidth;
  30033. for (var glyph in glyphsWidths) {
  30034. var glyphWidth = glyphsWidths[glyph];
  30035. if (!glyphWidth) {
  30036. continue;
  30037. }
  30038. if (!firstWidth) {
  30039. firstWidth = glyphWidth;
  30040. continue;
  30041. }
  30042. if (firstWidth !== glyphWidth) {
  30043. isMonospace = false;
  30044. break;
  30045. }
  30046. }
  30047. if (isMonospace) {
  30048. properties.flags |= FontFlags.FixedPitch;
  30049. }
  30050. properties.defaultWidth = defaultWidth;
  30051. properties.widths = glyphsWidths;
  30052. properties.defaultVMetrics = defaultVMetrics;
  30053. properties.vmetrics = glyphsVMetrics;
  30054. },
  30055. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30056. var fontNameWoStyle = baseFontName.split('-')[0];
  30057. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30058. },
  30059. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30060. var defaultWidth = 0;
  30061. var widths = [];
  30062. var monospace = false;
  30063. var stdFontMap = getStdFontMap();
  30064. var lookupName = stdFontMap[name] || name;
  30065. var Metrics = getMetrics();
  30066. if (!(lookupName in Metrics)) {
  30067. if (this.isSerifFont(name)) {
  30068. lookupName = 'Times-Roman';
  30069. } else {
  30070. lookupName = 'Helvetica';
  30071. }
  30072. }
  30073. var glyphWidths = Metrics[lookupName];
  30074. if (isNum(glyphWidths)) {
  30075. defaultWidth = glyphWidths;
  30076. monospace = true;
  30077. } else {
  30078. widths = glyphWidths();
  30079. }
  30080. return {
  30081. defaultWidth: defaultWidth,
  30082. monospace: monospace,
  30083. widths: widths
  30084. };
  30085. },
  30086. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30087. var widths = Object.create(null);
  30088. var differences = properties.differences;
  30089. var encoding = properties.defaultEncoding;
  30090. for (var charCode = 0; charCode < 256; charCode++) {
  30091. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30092. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30093. continue;
  30094. }
  30095. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30096. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30097. continue;
  30098. }
  30099. }
  30100. return widths;
  30101. },
  30102. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
  30103. var baseDict = dict;
  30104. var type = dict.get('Subtype');
  30105. assert(isName(type), 'invalid font Subtype');
  30106. var composite = false;
  30107. var uint8array;
  30108. if (type.name === 'Type0') {
  30109. var df = dict.get('DescendantFonts');
  30110. assert(df, 'Descendant fonts are not specified');
  30111. dict = isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
  30112. type = dict.get('Subtype');
  30113. assert(isName(type), 'invalid font Subtype');
  30114. composite = true;
  30115. }
  30116. var descriptor = dict.get('FontDescriptor');
  30117. if (descriptor) {
  30118. var hash = new MurmurHash3_64();
  30119. var encoding = baseDict.getRaw('Encoding');
  30120. if (isName(encoding)) {
  30121. hash.update(encoding.name);
  30122. } else if (isRef(encoding)) {
  30123. hash.update(encoding.toString());
  30124. } else if (isDict(encoding)) {
  30125. var keys = encoding.getKeys();
  30126. for (var i = 0, ii = keys.length; i < ii; i++) {
  30127. var entry = encoding.getRaw(keys[i]);
  30128. if (isName(entry)) {
  30129. hash.update(entry.name);
  30130. } else if (isRef(entry)) {
  30131. hash.update(entry.toString());
  30132. } else if (isArray(entry)) {
  30133. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30134. for (var j = 0; j < diffLength; j++) {
  30135. var diffEntry = entry[j];
  30136. if (isName(diffEntry)) {
  30137. diffBuf[j] = diffEntry.name;
  30138. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30139. diffBuf[j] = diffEntry.toString();
  30140. }
  30141. }
  30142. hash.update(diffBuf.join());
  30143. }
  30144. }
  30145. }
  30146. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30147. if (isStream(toUnicode)) {
  30148. var stream = toUnicode.str || toUnicode;
  30149. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30150. hash.update(uint8array);
  30151. } else if (isName(toUnicode)) {
  30152. hash.update(toUnicode.name);
  30153. }
  30154. var widths = dict.get('Widths') || baseDict.get('Widths');
  30155. if (widths) {
  30156. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30157. hash.update(uint8array);
  30158. }
  30159. }
  30160. return {
  30161. descriptor: descriptor,
  30162. dict: dict,
  30163. baseDict: baseDict,
  30164. composite: composite,
  30165. type: type.name,
  30166. hash: hash ? hash.hexdigest() : ''
  30167. };
  30168. },
  30169. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
  30170. var baseDict = preEvaluatedFont.baseDict;
  30171. var dict = preEvaluatedFont.dict;
  30172. var composite = preEvaluatedFont.composite;
  30173. var descriptor = preEvaluatedFont.descriptor;
  30174. var type = preEvaluatedFont.type;
  30175. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30176. var properties;
  30177. if (!descriptor) {
  30178. if (type === 'Type3') {
  30179. descriptor = new Dict(null);
  30180. descriptor.set('FontName', Name.get(type));
  30181. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30182. } else {
  30183. var baseFontName = dict.get('BaseFont');
  30184. assert(isName(baseFontName), 'Base font is not specified');
  30185. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30186. var metrics = this.getBaseFontMetrics(baseFontName);
  30187. var fontNameWoStyle = baseFontName.split('-')[0];
  30188. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30189. properties = {
  30190. type: type,
  30191. name: baseFontName,
  30192. widths: metrics.widths,
  30193. defaultWidth: metrics.defaultWidth,
  30194. flags: flags,
  30195. firstChar: 0,
  30196. lastChar: maxCharIndex
  30197. };
  30198. return this.extractDataStructures(dict, dict, properties).then(function (properties) {
  30199. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30200. return new Font(baseFontName, null, properties);
  30201. }.bind(this));
  30202. }
  30203. }
  30204. var firstChar = dict.get('FirstChar') || 0;
  30205. var lastChar = dict.get('LastChar') || maxCharIndex;
  30206. var fontName = descriptor.get('FontName');
  30207. var baseFont = dict.get('BaseFont');
  30208. if (isString(fontName)) {
  30209. fontName = Name.get(fontName);
  30210. }
  30211. if (isString(baseFont)) {
  30212. baseFont = Name.get(baseFont);
  30213. }
  30214. if (type !== 'Type3') {
  30215. var fontNameStr = fontName && fontName.name;
  30216. var baseFontStr = baseFont && baseFont.name;
  30217. if (fontNameStr !== baseFontStr) {
  30218. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30219. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30220. fontName = baseFont;
  30221. }
  30222. }
  30223. }
  30224. fontName = fontName || baseFont;
  30225. assert(isName(fontName), 'invalid font name');
  30226. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30227. if (fontFile) {
  30228. if (fontFile.dict) {
  30229. var subtype = fontFile.dict.get('Subtype');
  30230. if (subtype) {
  30231. subtype = subtype.name;
  30232. }
  30233. var length1 = fontFile.dict.get('Length1');
  30234. var length2 = fontFile.dict.get('Length2');
  30235. var length3 = fontFile.dict.get('Length3');
  30236. }
  30237. }
  30238. properties = {
  30239. type: type,
  30240. name: fontName.name,
  30241. subtype: subtype,
  30242. file: fontFile,
  30243. length1: length1,
  30244. length2: length2,
  30245. length3: length3,
  30246. loadedName: baseDict.loadedName,
  30247. composite: composite,
  30248. wideChars: composite,
  30249. fixedPitch: false,
  30250. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30251. firstChar: firstChar || 0,
  30252. lastChar: lastChar || maxCharIndex,
  30253. bbox: descriptor.getArray('FontBBox'),
  30254. ascent: descriptor.get('Ascent'),
  30255. descent: descriptor.get('Descent'),
  30256. xHeight: descriptor.get('XHeight'),
  30257. capHeight: descriptor.get('CapHeight'),
  30258. flags: descriptor.get('Flags'),
  30259. italicAngle: descriptor.get('ItalicAngle'),
  30260. coded: false
  30261. };
  30262. var cMapPromise;
  30263. if (composite) {
  30264. var cidEncoding = baseDict.get('Encoding');
  30265. if (isName(cidEncoding)) {
  30266. properties.cidEncoding = cidEncoding.name;
  30267. }
  30268. cMapPromise = CMapFactory.create({
  30269. encoding: cidEncoding,
  30270. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30271. useCMap: null
  30272. }).then(function (cMap) {
  30273. properties.cMap = cMap;
  30274. properties.vertical = properties.cMap.vertical;
  30275. });
  30276. } else {
  30277. cMapPromise = Promise.resolve(undefined);
  30278. }
  30279. return cMapPromise.then(function () {
  30280. return this.extractDataStructures(dict, baseDict, properties);
  30281. }.bind(this)).then(function (properties) {
  30282. this.extractWidths(dict, descriptor, properties);
  30283. if (type === 'Type3') {
  30284. properties.isType3Font = true;
  30285. }
  30286. return new Font(fontName.name, fontFile, properties);
  30287. }.bind(this));
  30288. }
  30289. };
  30290. return PartialEvaluator;
  30291. }();
  30292. var TranslatedFont = function TranslatedFontClosure() {
  30293. function TranslatedFont(loadedName, font, dict) {
  30294. this.loadedName = loadedName;
  30295. this.font = font;
  30296. this.dict = dict;
  30297. this.type3Loaded = null;
  30298. this.sent = false;
  30299. }
  30300. TranslatedFont.prototype = {
  30301. send: function (handler) {
  30302. if (this.sent) {
  30303. return;
  30304. }
  30305. var fontData = this.font.exportData();
  30306. handler.send('commonobj', [
  30307. this.loadedName,
  30308. 'Font',
  30309. fontData
  30310. ]);
  30311. this.sent = true;
  30312. },
  30313. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  30314. assert(this.font.isType3Font);
  30315. if (this.type3Loaded) {
  30316. return this.type3Loaded;
  30317. }
  30318. var translatedFont = this.font;
  30319. var loadCharProcsPromise = Promise.resolve();
  30320. var charProcs = this.dict.get('CharProcs');
  30321. var fontResources = this.dict.get('Resources') || resources;
  30322. var charProcKeys = charProcs.getKeys();
  30323. var charProcOperatorList = Object.create(null);
  30324. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  30325. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  30326. var glyphStream = charProcs.get(key);
  30327. var operatorList = new OperatorList();
  30328. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  30329. charProcOperatorList[key] = operatorList.getIR();
  30330. parentOperatorList.addDependencies(operatorList.dependencies);
  30331. }, function (reason) {
  30332. warn('Type3 font resource \"' + key + '\" is not available');
  30333. var operatorList = new OperatorList();
  30334. charProcOperatorList[key] = operatorList.getIR();
  30335. });
  30336. }.bind(this, charProcKeys[i]));
  30337. }
  30338. this.type3Loaded = loadCharProcsPromise.then(function () {
  30339. translatedFont.charProcOperatorList = charProcOperatorList;
  30340. });
  30341. return this.type3Loaded;
  30342. }
  30343. };
  30344. return TranslatedFont;
  30345. }();
  30346. var OperatorList = function OperatorListClosure() {
  30347. var CHUNK_SIZE = 1000;
  30348. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  30349. function getTransfers(queue) {
  30350. var transfers = [];
  30351. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  30352. for (var i = 0, ii = queue.length; i < ii; i++) {
  30353. switch (fnArray[i]) {
  30354. case OPS.paintInlineImageXObject:
  30355. case OPS.paintInlineImageXObjectGroup:
  30356. case OPS.paintImageMaskXObject:
  30357. var arg = argsArray[i][0];
  30358. if (!arg.cached) {
  30359. transfers.push(arg.data.buffer);
  30360. }
  30361. break;
  30362. }
  30363. }
  30364. return transfers;
  30365. }
  30366. function OperatorList(intent, messageHandler, pageIndex) {
  30367. this.messageHandler = messageHandler;
  30368. this.fnArray = [];
  30369. this.argsArray = [];
  30370. this.dependencies = Object.create(null);
  30371. this._totalLength = 0;
  30372. this.pageIndex = pageIndex;
  30373. this.intent = intent;
  30374. }
  30375. OperatorList.prototype = {
  30376. get length() {
  30377. return this.argsArray.length;
  30378. },
  30379. get totalLength() {
  30380. return this._totalLength + this.length;
  30381. },
  30382. addOp: function (fn, args) {
  30383. this.fnArray.push(fn);
  30384. this.argsArray.push(args);
  30385. if (this.messageHandler) {
  30386. if (this.fnArray.length >= CHUNK_SIZE) {
  30387. this.flush();
  30388. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  30389. this.flush();
  30390. }
  30391. }
  30392. },
  30393. addDependency: function (dependency) {
  30394. if (dependency in this.dependencies) {
  30395. return;
  30396. }
  30397. this.dependencies[dependency] = true;
  30398. this.addOp(OPS.dependency, [dependency]);
  30399. },
  30400. addDependencies: function (dependencies) {
  30401. for (var key in dependencies) {
  30402. this.addDependency(key);
  30403. }
  30404. },
  30405. addOpList: function (opList) {
  30406. Util.extendObj(this.dependencies, opList.dependencies);
  30407. for (var i = 0, ii = opList.length; i < ii; i++) {
  30408. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  30409. }
  30410. },
  30411. getIR: function () {
  30412. return {
  30413. fnArray: this.fnArray,
  30414. argsArray: this.argsArray,
  30415. length: this.length
  30416. };
  30417. },
  30418. flush: function (lastChunk) {
  30419. if (this.intent !== 'oplist') {
  30420. new QueueOptimizer().optimize(this);
  30421. }
  30422. var transfers = getTransfers(this);
  30423. var length = this.length;
  30424. this._totalLength += length;
  30425. this.messageHandler.send('RenderPageChunk', {
  30426. operatorList: {
  30427. fnArray: this.fnArray,
  30428. argsArray: this.argsArray,
  30429. lastChunk: lastChunk,
  30430. length: length
  30431. },
  30432. pageIndex: this.pageIndex,
  30433. intent: this.intent
  30434. }, transfers);
  30435. this.dependencies = Object.create(null);
  30436. this.fnArray.length = 0;
  30437. this.argsArray.length = 0;
  30438. }
  30439. };
  30440. return OperatorList;
  30441. }();
  30442. var StateManager = function StateManagerClosure() {
  30443. function StateManager(initialState) {
  30444. this.state = initialState;
  30445. this.stateStack = [];
  30446. }
  30447. StateManager.prototype = {
  30448. save: function () {
  30449. var old = this.state;
  30450. this.stateStack.push(this.state);
  30451. this.state = old.clone();
  30452. },
  30453. restore: function () {
  30454. var prev = this.stateStack.pop();
  30455. if (prev) {
  30456. this.state = prev;
  30457. }
  30458. },
  30459. transform: function (args) {
  30460. this.state.ctm = Util.transform(this.state.ctm, args);
  30461. }
  30462. };
  30463. return StateManager;
  30464. }();
  30465. var TextState = function TextStateClosure() {
  30466. function TextState() {
  30467. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30468. this.fontName = null;
  30469. this.fontSize = 0;
  30470. this.font = null;
  30471. this.fontMatrix = FONT_IDENTITY_MATRIX;
  30472. this.textMatrix = IDENTITY_MATRIX.slice();
  30473. this.textLineMatrix = IDENTITY_MATRIX.slice();
  30474. this.charSpacing = 0;
  30475. this.wordSpacing = 0;
  30476. this.leading = 0;
  30477. this.textHScale = 1;
  30478. this.textRise = 0;
  30479. }
  30480. TextState.prototype = {
  30481. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30482. var m = this.textMatrix;
  30483. m[0] = a;
  30484. m[1] = b;
  30485. m[2] = c;
  30486. m[3] = d;
  30487. m[4] = e;
  30488. m[5] = f;
  30489. },
  30490. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30491. var m = this.textLineMatrix;
  30492. m[0] = a;
  30493. m[1] = b;
  30494. m[2] = c;
  30495. m[3] = d;
  30496. m[4] = e;
  30497. m[5] = f;
  30498. },
  30499. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  30500. var m = this.textMatrix;
  30501. m[4] = m[0] * x + m[2] * y + m[4];
  30502. m[5] = m[1] * x + m[3] * y + m[5];
  30503. },
  30504. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  30505. var m = this.textLineMatrix;
  30506. m[4] = m[0] * x + m[2] * y + m[4];
  30507. m[5] = m[1] * x + m[3] * y + m[5];
  30508. },
  30509. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  30510. var font = this.font;
  30511. if (!font) {
  30512. return null;
  30513. }
  30514. var m = this.textLineMatrix;
  30515. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  30516. return null;
  30517. }
  30518. var txDiff = e - m[4], tyDiff = f - m[5];
  30519. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  30520. return null;
  30521. }
  30522. var tx, ty, denominator = a * d - b * c;
  30523. if (font.vertical) {
  30524. tx = -tyDiff * c / denominator;
  30525. ty = tyDiff * a / denominator;
  30526. } else {
  30527. tx = txDiff * d / denominator;
  30528. ty = -txDiff * b / denominator;
  30529. }
  30530. return {
  30531. width: tx,
  30532. height: ty,
  30533. value: font.vertical ? ty : tx
  30534. };
  30535. },
  30536. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  30537. var tsm = [
  30538. this.fontSize * this.textHScale,
  30539. 0,
  30540. 0,
  30541. this.fontSize,
  30542. 0,
  30543. this.textRise
  30544. ];
  30545. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  30546. },
  30547. carriageReturn: function TextState_carriageReturn() {
  30548. this.translateTextLineMatrix(0, -this.leading);
  30549. this.textMatrix = this.textLineMatrix.slice();
  30550. },
  30551. clone: function TextState_clone() {
  30552. var clone = Object.create(this);
  30553. clone.textMatrix = this.textMatrix.slice();
  30554. clone.textLineMatrix = this.textLineMatrix.slice();
  30555. clone.fontMatrix = this.fontMatrix.slice();
  30556. return clone;
  30557. }
  30558. };
  30559. return TextState;
  30560. }();
  30561. var EvalState = function EvalStateClosure() {
  30562. function EvalState() {
  30563. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30564. this.font = null;
  30565. this.textRenderingMode = TextRenderingMode.FILL;
  30566. this.fillColorSpace = ColorSpace.singletons.gray;
  30567. this.strokeColorSpace = ColorSpace.singletons.gray;
  30568. }
  30569. EvalState.prototype = {
  30570. clone: function CanvasExtraState_clone() {
  30571. return Object.create(this);
  30572. }
  30573. };
  30574. return EvalState;
  30575. }();
  30576. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  30577. var getOPMap = getLookupTableFactory(function (t) {
  30578. t['w'] = {
  30579. id: OPS.setLineWidth,
  30580. numArgs: 1,
  30581. variableArgs: false
  30582. };
  30583. t['J'] = {
  30584. id: OPS.setLineCap,
  30585. numArgs: 1,
  30586. variableArgs: false
  30587. };
  30588. t['j'] = {
  30589. id: OPS.setLineJoin,
  30590. numArgs: 1,
  30591. variableArgs: false
  30592. };
  30593. t['M'] = {
  30594. id: OPS.setMiterLimit,
  30595. numArgs: 1,
  30596. variableArgs: false
  30597. };
  30598. t['d'] = {
  30599. id: OPS.setDash,
  30600. numArgs: 2,
  30601. variableArgs: false
  30602. };
  30603. t['ri'] = {
  30604. id: OPS.setRenderingIntent,
  30605. numArgs: 1,
  30606. variableArgs: false
  30607. };
  30608. t['i'] = {
  30609. id: OPS.setFlatness,
  30610. numArgs: 1,
  30611. variableArgs: false
  30612. };
  30613. t['gs'] = {
  30614. id: OPS.setGState,
  30615. numArgs: 1,
  30616. variableArgs: false
  30617. };
  30618. t['q'] = {
  30619. id: OPS.save,
  30620. numArgs: 0,
  30621. variableArgs: false
  30622. };
  30623. t['Q'] = {
  30624. id: OPS.restore,
  30625. numArgs: 0,
  30626. variableArgs: false
  30627. };
  30628. t['cm'] = {
  30629. id: OPS.transform,
  30630. numArgs: 6,
  30631. variableArgs: false
  30632. };
  30633. t['m'] = {
  30634. id: OPS.moveTo,
  30635. numArgs: 2,
  30636. variableArgs: false
  30637. };
  30638. t['l'] = {
  30639. id: OPS.lineTo,
  30640. numArgs: 2,
  30641. variableArgs: false
  30642. };
  30643. t['c'] = {
  30644. id: OPS.curveTo,
  30645. numArgs: 6,
  30646. variableArgs: false
  30647. };
  30648. t['v'] = {
  30649. id: OPS.curveTo2,
  30650. numArgs: 4,
  30651. variableArgs: false
  30652. };
  30653. t['y'] = {
  30654. id: OPS.curveTo3,
  30655. numArgs: 4,
  30656. variableArgs: false
  30657. };
  30658. t['h'] = {
  30659. id: OPS.closePath,
  30660. numArgs: 0,
  30661. variableArgs: false
  30662. };
  30663. t['re'] = {
  30664. id: OPS.rectangle,
  30665. numArgs: 4,
  30666. variableArgs: false
  30667. };
  30668. t['S'] = {
  30669. id: OPS.stroke,
  30670. numArgs: 0,
  30671. variableArgs: false
  30672. };
  30673. t['s'] = {
  30674. id: OPS.closeStroke,
  30675. numArgs: 0,
  30676. variableArgs: false
  30677. };
  30678. t['f'] = {
  30679. id: OPS.fill,
  30680. numArgs: 0,
  30681. variableArgs: false
  30682. };
  30683. t['F'] = {
  30684. id: OPS.fill,
  30685. numArgs: 0,
  30686. variableArgs: false
  30687. };
  30688. t['f*'] = {
  30689. id: OPS.eoFill,
  30690. numArgs: 0,
  30691. variableArgs: false
  30692. };
  30693. t['B'] = {
  30694. id: OPS.fillStroke,
  30695. numArgs: 0,
  30696. variableArgs: false
  30697. };
  30698. t['B*'] = {
  30699. id: OPS.eoFillStroke,
  30700. numArgs: 0,
  30701. variableArgs: false
  30702. };
  30703. t['b'] = {
  30704. id: OPS.closeFillStroke,
  30705. numArgs: 0,
  30706. variableArgs: false
  30707. };
  30708. t['b*'] = {
  30709. id: OPS.closeEOFillStroke,
  30710. numArgs: 0,
  30711. variableArgs: false
  30712. };
  30713. t['n'] = {
  30714. id: OPS.endPath,
  30715. numArgs: 0,
  30716. variableArgs: false
  30717. };
  30718. t['W'] = {
  30719. id: OPS.clip,
  30720. numArgs: 0,
  30721. variableArgs: false
  30722. };
  30723. t['W*'] = {
  30724. id: OPS.eoClip,
  30725. numArgs: 0,
  30726. variableArgs: false
  30727. };
  30728. t['BT'] = {
  30729. id: OPS.beginText,
  30730. numArgs: 0,
  30731. variableArgs: false
  30732. };
  30733. t['ET'] = {
  30734. id: OPS.endText,
  30735. numArgs: 0,
  30736. variableArgs: false
  30737. };
  30738. t['Tc'] = {
  30739. id: OPS.setCharSpacing,
  30740. numArgs: 1,
  30741. variableArgs: false
  30742. };
  30743. t['Tw'] = {
  30744. id: OPS.setWordSpacing,
  30745. numArgs: 1,
  30746. variableArgs: false
  30747. };
  30748. t['Tz'] = {
  30749. id: OPS.setHScale,
  30750. numArgs: 1,
  30751. variableArgs: false
  30752. };
  30753. t['TL'] = {
  30754. id: OPS.setLeading,
  30755. numArgs: 1,
  30756. variableArgs: false
  30757. };
  30758. t['Tf'] = {
  30759. id: OPS.setFont,
  30760. numArgs: 2,
  30761. variableArgs: false
  30762. };
  30763. t['Tr'] = {
  30764. id: OPS.setTextRenderingMode,
  30765. numArgs: 1,
  30766. variableArgs: false
  30767. };
  30768. t['Ts'] = {
  30769. id: OPS.setTextRise,
  30770. numArgs: 1,
  30771. variableArgs: false
  30772. };
  30773. t['Td'] = {
  30774. id: OPS.moveText,
  30775. numArgs: 2,
  30776. variableArgs: false
  30777. };
  30778. t['TD'] = {
  30779. id: OPS.setLeadingMoveText,
  30780. numArgs: 2,
  30781. variableArgs: false
  30782. };
  30783. t['Tm'] = {
  30784. id: OPS.setTextMatrix,
  30785. numArgs: 6,
  30786. variableArgs: false
  30787. };
  30788. t['T*'] = {
  30789. id: OPS.nextLine,
  30790. numArgs: 0,
  30791. variableArgs: false
  30792. };
  30793. t['Tj'] = {
  30794. id: OPS.showText,
  30795. numArgs: 1,
  30796. variableArgs: false
  30797. };
  30798. t['TJ'] = {
  30799. id: OPS.showSpacedText,
  30800. numArgs: 1,
  30801. variableArgs: false
  30802. };
  30803. t['\''] = {
  30804. id: OPS.nextLineShowText,
  30805. numArgs: 1,
  30806. variableArgs: false
  30807. };
  30808. t['"'] = {
  30809. id: OPS.nextLineSetSpacingShowText,
  30810. numArgs: 3,
  30811. variableArgs: false
  30812. };
  30813. t['d0'] = {
  30814. id: OPS.setCharWidth,
  30815. numArgs: 2,
  30816. variableArgs: false
  30817. };
  30818. t['d1'] = {
  30819. id: OPS.setCharWidthAndBounds,
  30820. numArgs: 6,
  30821. variableArgs: false
  30822. };
  30823. t['CS'] = {
  30824. id: OPS.setStrokeColorSpace,
  30825. numArgs: 1,
  30826. variableArgs: false
  30827. };
  30828. t['cs'] = {
  30829. id: OPS.setFillColorSpace,
  30830. numArgs: 1,
  30831. variableArgs: false
  30832. };
  30833. t['SC'] = {
  30834. id: OPS.setStrokeColor,
  30835. numArgs: 4,
  30836. variableArgs: true
  30837. };
  30838. t['SCN'] = {
  30839. id: OPS.setStrokeColorN,
  30840. numArgs: 33,
  30841. variableArgs: true
  30842. };
  30843. t['sc'] = {
  30844. id: OPS.setFillColor,
  30845. numArgs: 4,
  30846. variableArgs: true
  30847. };
  30848. t['scn'] = {
  30849. id: OPS.setFillColorN,
  30850. numArgs: 33,
  30851. variableArgs: true
  30852. };
  30853. t['G'] = {
  30854. id: OPS.setStrokeGray,
  30855. numArgs: 1,
  30856. variableArgs: false
  30857. };
  30858. t['g'] = {
  30859. id: OPS.setFillGray,
  30860. numArgs: 1,
  30861. variableArgs: false
  30862. };
  30863. t['RG'] = {
  30864. id: OPS.setStrokeRGBColor,
  30865. numArgs: 3,
  30866. variableArgs: false
  30867. };
  30868. t['rg'] = {
  30869. id: OPS.setFillRGBColor,
  30870. numArgs: 3,
  30871. variableArgs: false
  30872. };
  30873. t['K'] = {
  30874. id: OPS.setStrokeCMYKColor,
  30875. numArgs: 4,
  30876. variableArgs: false
  30877. };
  30878. t['k'] = {
  30879. id: OPS.setFillCMYKColor,
  30880. numArgs: 4,
  30881. variableArgs: false
  30882. };
  30883. t['sh'] = {
  30884. id: OPS.shadingFill,
  30885. numArgs: 1,
  30886. variableArgs: false
  30887. };
  30888. t['BI'] = {
  30889. id: OPS.beginInlineImage,
  30890. numArgs: 0,
  30891. variableArgs: false
  30892. };
  30893. t['ID'] = {
  30894. id: OPS.beginImageData,
  30895. numArgs: 0,
  30896. variableArgs: false
  30897. };
  30898. t['EI'] = {
  30899. id: OPS.endInlineImage,
  30900. numArgs: 1,
  30901. variableArgs: false
  30902. };
  30903. t['Do'] = {
  30904. id: OPS.paintXObject,
  30905. numArgs: 1,
  30906. variableArgs: false
  30907. };
  30908. t['MP'] = {
  30909. id: OPS.markPoint,
  30910. numArgs: 1,
  30911. variableArgs: false
  30912. };
  30913. t['DP'] = {
  30914. id: OPS.markPointProps,
  30915. numArgs: 2,
  30916. variableArgs: false
  30917. };
  30918. t['BMC'] = {
  30919. id: OPS.beginMarkedContent,
  30920. numArgs: 1,
  30921. variableArgs: false
  30922. };
  30923. t['BDC'] = {
  30924. id: OPS.beginMarkedContentProps,
  30925. numArgs: 2,
  30926. variableArgs: false
  30927. };
  30928. t['EMC'] = {
  30929. id: OPS.endMarkedContent,
  30930. numArgs: 0,
  30931. variableArgs: false
  30932. };
  30933. t['BX'] = {
  30934. id: OPS.beginCompat,
  30935. numArgs: 0,
  30936. variableArgs: false
  30937. };
  30938. t['EX'] = {
  30939. id: OPS.endCompat,
  30940. numArgs: 0,
  30941. variableArgs: false
  30942. };
  30943. t['BM'] = null;
  30944. t['BD'] = null;
  30945. t['true'] = null;
  30946. t['fa'] = null;
  30947. t['fal'] = null;
  30948. t['fals'] = null;
  30949. t['false'] = null;
  30950. t['nu'] = null;
  30951. t['nul'] = null;
  30952. t['null'] = null;
  30953. });
  30954. function EvaluatorPreprocessor(stream, xref, stateManager) {
  30955. this.opMap = getOPMap();
  30956. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  30957. this.stateManager = stateManager;
  30958. this.nonProcessedArgs = [];
  30959. }
  30960. EvaluatorPreprocessor.prototype = {
  30961. get savedStatesDepth() {
  30962. return this.stateManager.stateStack.length;
  30963. },
  30964. read: function EvaluatorPreprocessor_read(operation) {
  30965. var args = operation.args;
  30966. while (true) {
  30967. var obj = this.parser.getObj();
  30968. if (isCmd(obj)) {
  30969. var cmd = obj.cmd;
  30970. var opSpec = this.opMap[cmd];
  30971. if (!opSpec) {
  30972. warn('Unknown command "' + cmd + '"');
  30973. continue;
  30974. }
  30975. var fn = opSpec.id;
  30976. var numArgs = opSpec.numArgs;
  30977. var argsLength = args !== null ? args.length : 0;
  30978. if (!opSpec.variableArgs) {
  30979. if (argsLength !== numArgs) {
  30980. var nonProcessedArgs = this.nonProcessedArgs;
  30981. while (argsLength > numArgs) {
  30982. nonProcessedArgs.push(args.shift());
  30983. argsLength--;
  30984. }
  30985. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  30986. if (args === null) {
  30987. args = [];
  30988. }
  30989. args.unshift(nonProcessedArgs.pop());
  30990. argsLength++;
  30991. }
  30992. }
  30993. if (argsLength < numArgs) {
  30994. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  30995. if (args !== null) {
  30996. args.length = 0;
  30997. }
  30998. continue;
  30999. }
  31000. } else if (argsLength > numArgs) {
  31001. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31002. }
  31003. this.preprocessCommand(fn, args);
  31004. operation.fn = fn;
  31005. operation.args = args;
  31006. return true;
  31007. }
  31008. if (isEOF(obj)) {
  31009. return false;
  31010. }
  31011. if (obj !== null) {
  31012. if (args === null) {
  31013. args = [];
  31014. }
  31015. args.push(obj);
  31016. assert(args.length <= 33, 'Too many arguments');
  31017. }
  31018. }
  31019. },
  31020. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31021. switch (fn | 0) {
  31022. case OPS.save:
  31023. this.stateManager.save();
  31024. break;
  31025. case OPS.restore:
  31026. this.stateManager.restore();
  31027. break;
  31028. case OPS.transform:
  31029. this.stateManager.transform(args);
  31030. break;
  31031. }
  31032. }
  31033. };
  31034. return EvaluatorPreprocessor;
  31035. }();
  31036. var QueueOptimizer = function QueueOptimizerClosure() {
  31037. function addState(parentState, pattern, fn) {
  31038. var state = parentState;
  31039. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31040. var item = pattern[i];
  31041. state = state[item] || (state[item] = []);
  31042. }
  31043. state[pattern[pattern.length - 1]] = fn;
  31044. }
  31045. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31046. var iFirstPIMXO = iFirstSave + 2;
  31047. for (var i = 0; i < count; i++) {
  31048. var arg = argsArray[iFirstPIMXO + 4 * i];
  31049. var imageMask = arg.length === 1 && arg[0];
  31050. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31051. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31052. continue;
  31053. }
  31054. break;
  31055. }
  31056. return count - i;
  31057. }
  31058. var InitialState = [];
  31059. addState(InitialState, [
  31060. OPS.save,
  31061. OPS.transform,
  31062. OPS.paintInlineImageXObject,
  31063. OPS.restore
  31064. ], function foundInlineImageGroup(context) {
  31065. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31066. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31067. var MAX_WIDTH = 1000;
  31068. var IMAGE_PADDING = 1;
  31069. var fnArray = context.fnArray, argsArray = context.argsArray;
  31070. var curr = context.iCurr;
  31071. var iFirstSave = curr - 3;
  31072. var iFirstTransform = curr - 2;
  31073. var iFirstPIIXO = curr - 1;
  31074. var i = iFirstSave + 4;
  31075. var ii = fnArray.length;
  31076. while (i + 3 < ii) {
  31077. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31078. break;
  31079. }
  31080. i += 4;
  31081. }
  31082. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31083. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31084. return i;
  31085. }
  31086. var maxX = 0;
  31087. var map = [], maxLineHeight = 0;
  31088. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31089. var q;
  31090. for (q = 0; q < count; q++) {
  31091. var transform = argsArray[iFirstTransform + (q << 2)];
  31092. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31093. if (currentX + img.width > MAX_WIDTH) {
  31094. maxX = Math.max(maxX, currentX);
  31095. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31096. currentX = 0;
  31097. maxLineHeight = 0;
  31098. }
  31099. map.push({
  31100. transform: transform,
  31101. x: currentX,
  31102. y: currentY,
  31103. w: img.width,
  31104. h: img.height
  31105. });
  31106. currentX += img.width + 2 * IMAGE_PADDING;
  31107. maxLineHeight = Math.max(maxLineHeight, img.height);
  31108. }
  31109. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31110. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31111. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31112. var imgRowSize = imgWidth << 2;
  31113. for (q = 0; q < count; q++) {
  31114. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31115. var rowSize = map[q].w << 2;
  31116. var dataOffset = 0;
  31117. var offset = map[q].x + map[q].y * imgWidth << 2;
  31118. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31119. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31120. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31121. dataOffset += rowSize;
  31122. offset += imgRowSize;
  31123. }
  31124. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31125. while (offset >= 0) {
  31126. data[offset - 4] = data[offset];
  31127. data[offset - 3] = data[offset + 1];
  31128. data[offset - 2] = data[offset + 2];
  31129. data[offset - 1] = data[offset + 3];
  31130. data[offset + rowSize] = data[offset + rowSize - 4];
  31131. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31132. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31133. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31134. offset -= imgRowSize;
  31135. }
  31136. }
  31137. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31138. argsArray.splice(iFirstSave, count * 4, [
  31139. {
  31140. width: imgWidth,
  31141. height: imgHeight,
  31142. kind: ImageKind.RGBA_32BPP,
  31143. data: imgData
  31144. },
  31145. map
  31146. ]);
  31147. return iFirstSave + 1;
  31148. });
  31149. addState(InitialState, [
  31150. OPS.save,
  31151. OPS.transform,
  31152. OPS.paintImageMaskXObject,
  31153. OPS.restore
  31154. ], function foundImageMaskGroup(context) {
  31155. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31156. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31157. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31158. var fnArray = context.fnArray, argsArray = context.argsArray;
  31159. var curr = context.iCurr;
  31160. var iFirstSave = curr - 3;
  31161. var iFirstTransform = curr - 2;
  31162. var iFirstPIMXO = curr - 1;
  31163. var i = iFirstSave + 4;
  31164. var ii = fnArray.length;
  31165. while (i + 3 < ii) {
  31166. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31167. break;
  31168. }
  31169. i += 4;
  31170. }
  31171. var count = (i - iFirstSave) / 4;
  31172. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31173. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31174. return i;
  31175. }
  31176. var q;
  31177. var isSameImage = false;
  31178. var iTransform, transformArgs;
  31179. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31180. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31181. isSameImage = true;
  31182. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31183. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31184. iTransform = iFirstTransform + 4;
  31185. var iPIMXO = iFirstPIMXO + 4;
  31186. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31187. transformArgs = argsArray[iTransform];
  31188. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31189. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31190. isSameImage = false;
  31191. } else {
  31192. count = q;
  31193. }
  31194. break;
  31195. }
  31196. }
  31197. }
  31198. if (isSameImage) {
  31199. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31200. var positions = new Float32Array(count * 2);
  31201. iTransform = iFirstTransform;
  31202. for (q = 0; q < count; q++, iTransform += 4) {
  31203. transformArgs = argsArray[iTransform];
  31204. positions[q << 1] = transformArgs[4];
  31205. positions[(q << 1) + 1] = transformArgs[5];
  31206. }
  31207. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31208. argsArray.splice(iFirstSave, count * 4, [
  31209. firstPIMXOArg0,
  31210. firstTransformArg0,
  31211. firstTransformArg3,
  31212. positions
  31213. ]);
  31214. } else {
  31215. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31216. var images = [];
  31217. for (q = 0; q < count; q++) {
  31218. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31219. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31220. images.push({
  31221. data: maskParams.data,
  31222. width: maskParams.width,
  31223. height: maskParams.height,
  31224. transform: transformArgs
  31225. });
  31226. }
  31227. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31228. argsArray.splice(iFirstSave, count * 4, [images]);
  31229. }
  31230. return iFirstSave + 1;
  31231. });
  31232. addState(InitialState, [
  31233. OPS.save,
  31234. OPS.transform,
  31235. OPS.paintImageXObject,
  31236. OPS.restore
  31237. ], function (context) {
  31238. var MIN_IMAGES_IN_BLOCK = 3;
  31239. var MAX_IMAGES_IN_BLOCK = 1000;
  31240. var fnArray = context.fnArray, argsArray = context.argsArray;
  31241. var curr = context.iCurr;
  31242. var iFirstSave = curr - 3;
  31243. var iFirstTransform = curr - 2;
  31244. var iFirstPIXO = curr - 1;
  31245. var iFirstRestore = curr;
  31246. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31247. return iFirstRestore + 1;
  31248. }
  31249. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31250. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31251. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31252. var i = iFirstSave + 4;
  31253. var ii = fnArray.length;
  31254. while (i + 3 < ii) {
  31255. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31256. break;
  31257. }
  31258. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31259. break;
  31260. }
  31261. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31262. break;
  31263. }
  31264. i += 4;
  31265. }
  31266. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31267. if (count < MIN_IMAGES_IN_BLOCK) {
  31268. return i;
  31269. }
  31270. var positions = new Float32Array(count * 2);
  31271. var iTransform = iFirstTransform;
  31272. for (var q = 0; q < count; q++, iTransform += 4) {
  31273. var transformArgs = argsArray[iTransform];
  31274. positions[q << 1] = transformArgs[4];
  31275. positions[(q << 1) + 1] = transformArgs[5];
  31276. }
  31277. var args = [
  31278. firstPIXOArg0,
  31279. firstTransformArg0,
  31280. firstTransformArg3,
  31281. positions
  31282. ];
  31283. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31284. argsArray.splice(iFirstSave, count * 4, args);
  31285. return iFirstSave + 1;
  31286. });
  31287. addState(InitialState, [
  31288. OPS.beginText,
  31289. OPS.setFont,
  31290. OPS.setTextMatrix,
  31291. OPS.showText,
  31292. OPS.endText
  31293. ], function (context) {
  31294. var MIN_CHARS_IN_BLOCK = 3;
  31295. var MAX_CHARS_IN_BLOCK = 1000;
  31296. var fnArray = context.fnArray, argsArray = context.argsArray;
  31297. var curr = context.iCurr;
  31298. var iFirstBeginText = curr - 4;
  31299. var iFirstSetFont = curr - 3;
  31300. var iFirstSetTextMatrix = curr - 2;
  31301. var iFirstShowText = curr - 1;
  31302. var iFirstEndText = curr;
  31303. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  31304. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  31305. var i = iFirstBeginText + 5;
  31306. var ii = fnArray.length;
  31307. while (i + 4 < ii) {
  31308. 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) {
  31309. break;
  31310. }
  31311. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  31312. break;
  31313. }
  31314. i += 5;
  31315. }
  31316. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  31317. if (count < MIN_CHARS_IN_BLOCK) {
  31318. return i;
  31319. }
  31320. var iFirst = iFirstBeginText;
  31321. 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) {
  31322. count++;
  31323. iFirst -= 5;
  31324. }
  31325. var iEndText = iFirst + 4;
  31326. for (var q = 1; q < count; q++) {
  31327. fnArray.splice(iEndText, 3);
  31328. argsArray.splice(iEndText, 3);
  31329. iEndText += 2;
  31330. }
  31331. return iEndText + 1;
  31332. });
  31333. function QueueOptimizer() {
  31334. }
  31335. QueueOptimizer.prototype = {
  31336. optimize: function QueueOptimizer_optimize(queue) {
  31337. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31338. var context = {
  31339. iCurr: 0,
  31340. fnArray: fnArray,
  31341. argsArray: argsArray
  31342. };
  31343. var state;
  31344. var i = 0, ii = fnArray.length;
  31345. while (i < ii) {
  31346. state = (state || InitialState)[fnArray[i]];
  31347. if (typeof state === 'function') {
  31348. context.iCurr = i;
  31349. i = state(context);
  31350. state = undefined;
  31351. ii = context.fnArray.length;
  31352. } else {
  31353. i++;
  31354. }
  31355. }
  31356. }
  31357. };
  31358. return QueueOptimizer;
  31359. }();
  31360. exports.OperatorList = OperatorList;
  31361. exports.PartialEvaluator = PartialEvaluator;
  31362. /***/ }),
  31363. /* 19 */
  31364. /***/ (function(module, exports, __w_pdfjs_require__) {
  31365. "use strict";
  31366. var sharedUtil = __w_pdfjs_require__(0);
  31367. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  31368. var info = sharedUtil.info;
  31369. var warn = sharedUtil.warn;
  31370. var error = sharedUtil.error;
  31371. var log2 = sharedUtil.log2;
  31372. var readUint16 = sharedUtil.readUint16;
  31373. var readUint32 = sharedUtil.readUint32;
  31374. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  31375. var JpxImage = function JpxImageClosure() {
  31376. var SubbandsGainLog2 = {
  31377. 'LL': 0,
  31378. 'LH': 1,
  31379. 'HL': 1,
  31380. 'HH': 2
  31381. };
  31382. function JpxImage() {
  31383. this.failOnCorruptedImage = false;
  31384. }
  31385. JpxImage.prototype = {
  31386. parse: function JpxImage_parse(data) {
  31387. var head = readUint16(data, 0);
  31388. if (head === 0xFF4F) {
  31389. this.parseCodestream(data, 0, data.length);
  31390. return;
  31391. }
  31392. var position = 0, length = data.length;
  31393. while (position < length) {
  31394. var headerSize = 8;
  31395. var lbox = readUint32(data, position);
  31396. var tbox = readUint32(data, position + 4);
  31397. position += headerSize;
  31398. if (lbox === 1) {
  31399. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  31400. position += 8;
  31401. headerSize += 8;
  31402. }
  31403. if (lbox === 0) {
  31404. lbox = length - position + headerSize;
  31405. }
  31406. if (lbox < headerSize) {
  31407. error('JPX Error: Invalid box field size');
  31408. }
  31409. var dataLength = lbox - headerSize;
  31410. var jumpDataLength = true;
  31411. switch (tbox) {
  31412. case 0x6A703268:
  31413. jumpDataLength = false;
  31414. break;
  31415. case 0x636F6C72:
  31416. var method = data[position];
  31417. if (method === 1) {
  31418. var colorspace = readUint32(data, position + 3);
  31419. switch (colorspace) {
  31420. case 16:
  31421. case 17:
  31422. case 18:
  31423. break;
  31424. default:
  31425. warn('Unknown colorspace ' + colorspace);
  31426. break;
  31427. }
  31428. } else if (method === 2) {
  31429. info('ICC profile not supported');
  31430. }
  31431. break;
  31432. case 0x6A703263:
  31433. this.parseCodestream(data, position, position + dataLength);
  31434. break;
  31435. case 0x6A502020:
  31436. if (readUint32(data, position) !== 0x0d0a870a) {
  31437. warn('Invalid JP2 signature');
  31438. }
  31439. break;
  31440. case 0x6A501A1A:
  31441. case 0x66747970:
  31442. case 0x72726571:
  31443. case 0x72657320:
  31444. case 0x69686472:
  31445. break;
  31446. default:
  31447. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  31448. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  31449. break;
  31450. }
  31451. if (jumpDataLength) {
  31452. position += dataLength;
  31453. }
  31454. }
  31455. },
  31456. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  31457. var newByte = stream.getByte();
  31458. while (newByte >= 0) {
  31459. var oldByte = newByte;
  31460. newByte = stream.getByte();
  31461. var code = oldByte << 8 | newByte;
  31462. if (code === 0xFF51) {
  31463. stream.skip(4);
  31464. var Xsiz = stream.getInt32() >>> 0;
  31465. var Ysiz = stream.getInt32() >>> 0;
  31466. var XOsiz = stream.getInt32() >>> 0;
  31467. var YOsiz = stream.getInt32() >>> 0;
  31468. stream.skip(16);
  31469. var Csiz = stream.getUint16();
  31470. this.width = Xsiz - XOsiz;
  31471. this.height = Ysiz - YOsiz;
  31472. this.componentsCount = Csiz;
  31473. this.bitsPerComponent = 8;
  31474. return;
  31475. }
  31476. }
  31477. error('JPX Error: No size marker found in JPX stream');
  31478. },
  31479. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  31480. var context = {};
  31481. var doNotRecover = false;
  31482. try {
  31483. var position = start;
  31484. while (position + 1 < end) {
  31485. var code = readUint16(data, position);
  31486. position += 2;
  31487. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  31488. switch (code) {
  31489. case 0xFF4F:
  31490. context.mainHeader = true;
  31491. break;
  31492. case 0xFFD9:
  31493. break;
  31494. case 0xFF51:
  31495. length = readUint16(data, position);
  31496. var siz = {};
  31497. siz.Xsiz = readUint32(data, position + 4);
  31498. siz.Ysiz = readUint32(data, position + 8);
  31499. siz.XOsiz = readUint32(data, position + 12);
  31500. siz.YOsiz = readUint32(data, position + 16);
  31501. siz.XTsiz = readUint32(data, position + 20);
  31502. siz.YTsiz = readUint32(data, position + 24);
  31503. siz.XTOsiz = readUint32(data, position + 28);
  31504. siz.YTOsiz = readUint32(data, position + 32);
  31505. var componentsCount = readUint16(data, position + 36);
  31506. siz.Csiz = componentsCount;
  31507. var components = [];
  31508. j = position + 38;
  31509. for (var i = 0; i < componentsCount; i++) {
  31510. var component = {
  31511. precision: (data[j] & 0x7F) + 1,
  31512. isSigned: !!(data[j] & 0x80),
  31513. XRsiz: data[j + 1],
  31514. YRsiz: data[j + 1]
  31515. };
  31516. calculateComponentDimensions(component, siz);
  31517. components.push(component);
  31518. }
  31519. context.SIZ = siz;
  31520. context.components = components;
  31521. calculateTileGrids(context, components);
  31522. context.QCC = [];
  31523. context.COC = [];
  31524. break;
  31525. case 0xFF5C:
  31526. length = readUint16(data, position);
  31527. var qcd = {};
  31528. j = position + 2;
  31529. sqcd = data[j++];
  31530. switch (sqcd & 0x1F) {
  31531. case 0:
  31532. spqcdSize = 8;
  31533. scalarExpounded = true;
  31534. break;
  31535. case 1:
  31536. spqcdSize = 16;
  31537. scalarExpounded = false;
  31538. break;
  31539. case 2:
  31540. spqcdSize = 16;
  31541. scalarExpounded = true;
  31542. break;
  31543. default:
  31544. throw new Error('Invalid SQcd value ' + sqcd);
  31545. }
  31546. qcd.noQuantization = spqcdSize === 8;
  31547. qcd.scalarExpounded = scalarExpounded;
  31548. qcd.guardBits = sqcd >> 5;
  31549. spqcds = [];
  31550. while (j < length + position) {
  31551. var spqcd = {};
  31552. if (spqcdSize === 8) {
  31553. spqcd.epsilon = data[j++] >> 3;
  31554. spqcd.mu = 0;
  31555. } else {
  31556. spqcd.epsilon = data[j] >> 3;
  31557. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31558. j += 2;
  31559. }
  31560. spqcds.push(spqcd);
  31561. }
  31562. qcd.SPqcds = spqcds;
  31563. if (context.mainHeader) {
  31564. context.QCD = qcd;
  31565. } else {
  31566. context.currentTile.QCD = qcd;
  31567. context.currentTile.QCC = [];
  31568. }
  31569. break;
  31570. case 0xFF5D:
  31571. length = readUint16(data, position);
  31572. var qcc = {};
  31573. j = position + 2;
  31574. var cqcc;
  31575. if (context.SIZ.Csiz < 257) {
  31576. cqcc = data[j++];
  31577. } else {
  31578. cqcc = readUint16(data, j);
  31579. j += 2;
  31580. }
  31581. sqcd = data[j++];
  31582. switch (sqcd & 0x1F) {
  31583. case 0:
  31584. spqcdSize = 8;
  31585. scalarExpounded = true;
  31586. break;
  31587. case 1:
  31588. spqcdSize = 16;
  31589. scalarExpounded = false;
  31590. break;
  31591. case 2:
  31592. spqcdSize = 16;
  31593. scalarExpounded = true;
  31594. break;
  31595. default:
  31596. throw new Error('Invalid SQcd value ' + sqcd);
  31597. }
  31598. qcc.noQuantization = spqcdSize === 8;
  31599. qcc.scalarExpounded = scalarExpounded;
  31600. qcc.guardBits = sqcd >> 5;
  31601. spqcds = [];
  31602. while (j < length + position) {
  31603. spqcd = {};
  31604. if (spqcdSize === 8) {
  31605. spqcd.epsilon = data[j++] >> 3;
  31606. spqcd.mu = 0;
  31607. } else {
  31608. spqcd.epsilon = data[j] >> 3;
  31609. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31610. j += 2;
  31611. }
  31612. spqcds.push(spqcd);
  31613. }
  31614. qcc.SPqcds = spqcds;
  31615. if (context.mainHeader) {
  31616. context.QCC[cqcc] = qcc;
  31617. } else {
  31618. context.currentTile.QCC[cqcc] = qcc;
  31619. }
  31620. break;
  31621. case 0xFF52:
  31622. length = readUint16(data, position);
  31623. var cod = {};
  31624. j = position + 2;
  31625. var scod = data[j++];
  31626. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  31627. cod.sopMarkerUsed = !!(scod & 2);
  31628. cod.ephMarkerUsed = !!(scod & 4);
  31629. cod.progressionOrder = data[j++];
  31630. cod.layersCount = readUint16(data, j);
  31631. j += 2;
  31632. cod.multipleComponentTransform = data[j++];
  31633. cod.decompositionLevelsCount = data[j++];
  31634. cod.xcb = (data[j++] & 0xF) + 2;
  31635. cod.ycb = (data[j++] & 0xF) + 2;
  31636. var blockStyle = data[j++];
  31637. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  31638. cod.resetContextProbabilities = !!(blockStyle & 2);
  31639. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  31640. cod.verticalyStripe = !!(blockStyle & 8);
  31641. cod.predictableTermination = !!(blockStyle & 16);
  31642. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  31643. cod.reversibleTransformation = data[j++];
  31644. if (cod.entropyCoderWithCustomPrecincts) {
  31645. var precinctsSizes = [];
  31646. while (j < length + position) {
  31647. var precinctsSize = data[j++];
  31648. precinctsSizes.push({
  31649. PPx: precinctsSize & 0xF,
  31650. PPy: precinctsSize >> 4
  31651. });
  31652. }
  31653. cod.precinctsSizes = precinctsSizes;
  31654. }
  31655. var unsupported = [];
  31656. if (cod.selectiveArithmeticCodingBypass) {
  31657. unsupported.push('selectiveArithmeticCodingBypass');
  31658. }
  31659. if (cod.resetContextProbabilities) {
  31660. unsupported.push('resetContextProbabilities');
  31661. }
  31662. if (cod.terminationOnEachCodingPass) {
  31663. unsupported.push('terminationOnEachCodingPass');
  31664. }
  31665. if (cod.verticalyStripe) {
  31666. unsupported.push('verticalyStripe');
  31667. }
  31668. if (cod.predictableTermination) {
  31669. unsupported.push('predictableTermination');
  31670. }
  31671. if (unsupported.length > 0) {
  31672. doNotRecover = true;
  31673. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  31674. }
  31675. if (context.mainHeader) {
  31676. context.COD = cod;
  31677. } else {
  31678. context.currentTile.COD = cod;
  31679. context.currentTile.COC = [];
  31680. }
  31681. break;
  31682. case 0xFF90:
  31683. length = readUint16(data, position);
  31684. tile = {};
  31685. tile.index = readUint16(data, position + 2);
  31686. tile.length = readUint32(data, position + 4);
  31687. tile.dataEnd = tile.length + position - 2;
  31688. tile.partIndex = data[position + 8];
  31689. tile.partsCount = data[position + 9];
  31690. context.mainHeader = false;
  31691. if (tile.partIndex === 0) {
  31692. tile.COD = context.COD;
  31693. tile.COC = context.COC.slice(0);
  31694. tile.QCD = context.QCD;
  31695. tile.QCC = context.QCC.slice(0);
  31696. }
  31697. context.currentTile = tile;
  31698. break;
  31699. case 0xFF93:
  31700. tile = context.currentTile;
  31701. if (tile.partIndex === 0) {
  31702. initializeTile(context, tile.index);
  31703. buildPackets(context);
  31704. }
  31705. length = tile.dataEnd - position;
  31706. parseTilePackets(context, data, position, length);
  31707. break;
  31708. case 0xFF55:
  31709. case 0xFF57:
  31710. case 0xFF58:
  31711. case 0xFF64:
  31712. length = readUint16(data, position);
  31713. break;
  31714. case 0xFF53:
  31715. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  31716. default:
  31717. throw new Error('Unknown codestream code: ' + code.toString(16));
  31718. }
  31719. position += length;
  31720. }
  31721. } catch (e) {
  31722. if (doNotRecover || this.failOnCorruptedImage) {
  31723. error('JPX Error: ' + e.message);
  31724. } else {
  31725. warn('JPX: Trying to recover from: ' + e.message);
  31726. }
  31727. }
  31728. this.tiles = transformComponents(context);
  31729. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  31730. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  31731. this.componentsCount = context.SIZ.Csiz;
  31732. }
  31733. };
  31734. function calculateComponentDimensions(component, siz) {
  31735. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  31736. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  31737. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  31738. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  31739. component.width = component.x1 - component.x0;
  31740. component.height = component.y1 - component.y0;
  31741. }
  31742. function calculateTileGrids(context, components) {
  31743. var siz = context.SIZ;
  31744. var tile, tiles = [];
  31745. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  31746. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  31747. for (var q = 0; q < numYtiles; q++) {
  31748. for (var p = 0; p < numXtiles; p++) {
  31749. tile = {};
  31750. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  31751. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  31752. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  31753. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  31754. tile.width = tile.tx1 - tile.tx0;
  31755. tile.height = tile.ty1 - tile.ty0;
  31756. tile.components = [];
  31757. tiles.push(tile);
  31758. }
  31759. }
  31760. context.tiles = tiles;
  31761. var componentsCount = siz.Csiz;
  31762. for (var i = 0, ii = componentsCount; i < ii; i++) {
  31763. var component = components[i];
  31764. for (var j = 0, jj = tiles.length; j < jj; j++) {
  31765. var tileComponent = {};
  31766. tile = tiles[j];
  31767. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  31768. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  31769. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  31770. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  31771. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  31772. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  31773. tile.components[i] = tileComponent;
  31774. }
  31775. }
  31776. }
  31777. function getBlocksDimensions(context, component, r) {
  31778. var codOrCoc = component.codingStyleParameters;
  31779. var result = {};
  31780. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  31781. result.PPx = 15;
  31782. result.PPy = 15;
  31783. } else {
  31784. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  31785. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  31786. }
  31787. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  31788. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  31789. return result;
  31790. }
  31791. function buildPrecincts(context, resolution, dimensions) {
  31792. var precinctWidth = 1 << dimensions.PPx;
  31793. var precinctHeight = 1 << dimensions.PPy;
  31794. var isZeroRes = resolution.resLevel === 0;
  31795. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  31796. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  31797. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  31798. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  31799. var numprecincts = numprecinctswide * numprecinctshigh;
  31800. resolution.precinctParameters = {
  31801. precinctWidth: precinctWidth,
  31802. precinctHeight: precinctHeight,
  31803. numprecinctswide: numprecinctswide,
  31804. numprecinctshigh: numprecinctshigh,
  31805. numprecincts: numprecincts,
  31806. precinctWidthInSubband: precinctWidthInSubband,
  31807. precinctHeightInSubband: precinctHeightInSubband
  31808. };
  31809. }
  31810. function buildCodeblocks(context, subband, dimensions) {
  31811. var xcb_ = dimensions.xcb_;
  31812. var ycb_ = dimensions.ycb_;
  31813. var codeblockWidth = 1 << xcb_;
  31814. var codeblockHeight = 1 << ycb_;
  31815. var cbx0 = subband.tbx0 >> xcb_;
  31816. var cby0 = subband.tby0 >> ycb_;
  31817. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  31818. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  31819. var precinctParameters = subband.resolution.precinctParameters;
  31820. var codeblocks = [];
  31821. var precincts = [];
  31822. var i, j, codeblock, precinctNumber;
  31823. for (j = cby0; j < cby1; j++) {
  31824. for (i = cbx0; i < cbx1; i++) {
  31825. codeblock = {
  31826. cbx: i,
  31827. cby: j,
  31828. tbx0: codeblockWidth * i,
  31829. tby0: codeblockHeight * j,
  31830. tbx1: codeblockWidth * (i + 1),
  31831. tby1: codeblockHeight * (j + 1)
  31832. };
  31833. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  31834. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  31835. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  31836. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  31837. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  31838. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  31839. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  31840. codeblock.precinctNumber = precinctNumber;
  31841. codeblock.subbandType = subband.type;
  31842. codeblock.Lblock = 3;
  31843. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  31844. continue;
  31845. }
  31846. codeblocks.push(codeblock);
  31847. var precinct = precincts[precinctNumber];
  31848. if (precinct !== undefined) {
  31849. if (i < precinct.cbxMin) {
  31850. precinct.cbxMin = i;
  31851. } else if (i > precinct.cbxMax) {
  31852. precinct.cbxMax = i;
  31853. }
  31854. if (j < precinct.cbyMin) {
  31855. precinct.cbxMin = j;
  31856. } else if (j > precinct.cbyMax) {
  31857. precinct.cbyMax = j;
  31858. }
  31859. } else {
  31860. precincts[precinctNumber] = precinct = {
  31861. cbxMin: i,
  31862. cbyMin: j,
  31863. cbxMax: i,
  31864. cbyMax: j
  31865. };
  31866. }
  31867. codeblock.precinct = precinct;
  31868. }
  31869. }
  31870. subband.codeblockParameters = {
  31871. codeblockWidth: xcb_,
  31872. codeblockHeight: ycb_,
  31873. numcodeblockwide: cbx1 - cbx0 + 1,
  31874. numcodeblockhigh: cby1 - cby0 + 1
  31875. };
  31876. subband.codeblocks = codeblocks;
  31877. subband.precincts = precincts;
  31878. }
  31879. function createPacket(resolution, precinctNumber, layerNumber) {
  31880. var precinctCodeblocks = [];
  31881. var subbands = resolution.subbands;
  31882. for (var i = 0, ii = subbands.length; i < ii; i++) {
  31883. var subband = subbands[i];
  31884. var codeblocks = subband.codeblocks;
  31885. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  31886. var codeblock = codeblocks[j];
  31887. if (codeblock.precinctNumber !== precinctNumber) {
  31888. continue;
  31889. }
  31890. precinctCodeblocks.push(codeblock);
  31891. }
  31892. }
  31893. return {
  31894. layerNumber: layerNumber,
  31895. codeblocks: precinctCodeblocks
  31896. };
  31897. }
  31898. function LayerResolutionComponentPositionIterator(context) {
  31899. var siz = context.SIZ;
  31900. var tileIndex = context.currentTile.index;
  31901. var tile = context.tiles[tileIndex];
  31902. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31903. var componentsCount = siz.Csiz;
  31904. var maxDecompositionLevelsCount = 0;
  31905. for (var q = 0; q < componentsCount; q++) {
  31906. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31907. }
  31908. var l = 0, r = 0, i = 0, k = 0;
  31909. this.nextPacket = function JpxImage_nextPacket() {
  31910. for (; l < layersCount; l++) {
  31911. for (; r <= maxDecompositionLevelsCount; r++) {
  31912. for (; i < componentsCount; i++) {
  31913. var component = tile.components[i];
  31914. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31915. continue;
  31916. }
  31917. var resolution = component.resolutions[r];
  31918. var numprecincts = resolution.precinctParameters.numprecincts;
  31919. for (; k < numprecincts;) {
  31920. var packet = createPacket(resolution, k, l);
  31921. k++;
  31922. return packet;
  31923. }
  31924. k = 0;
  31925. }
  31926. i = 0;
  31927. }
  31928. r = 0;
  31929. }
  31930. error('JPX Error: Out of packets');
  31931. };
  31932. }
  31933. function ResolutionLayerComponentPositionIterator(context) {
  31934. var siz = context.SIZ;
  31935. var tileIndex = context.currentTile.index;
  31936. var tile = context.tiles[tileIndex];
  31937. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31938. var componentsCount = siz.Csiz;
  31939. var maxDecompositionLevelsCount = 0;
  31940. for (var q = 0; q < componentsCount; q++) {
  31941. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31942. }
  31943. var r = 0, l = 0, i = 0, k = 0;
  31944. this.nextPacket = function JpxImage_nextPacket() {
  31945. for (; r <= maxDecompositionLevelsCount; r++) {
  31946. for (; l < layersCount; l++) {
  31947. for (; i < componentsCount; i++) {
  31948. var component = tile.components[i];
  31949. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31950. continue;
  31951. }
  31952. var resolution = component.resolutions[r];
  31953. var numprecincts = resolution.precinctParameters.numprecincts;
  31954. for (; k < numprecincts;) {
  31955. var packet = createPacket(resolution, k, l);
  31956. k++;
  31957. return packet;
  31958. }
  31959. k = 0;
  31960. }
  31961. i = 0;
  31962. }
  31963. l = 0;
  31964. }
  31965. error('JPX Error: Out of packets');
  31966. };
  31967. }
  31968. function ResolutionPositionComponentLayerIterator(context) {
  31969. var siz = context.SIZ;
  31970. var tileIndex = context.currentTile.index;
  31971. var tile = context.tiles[tileIndex];
  31972. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31973. var componentsCount = siz.Csiz;
  31974. var l, r, c, p;
  31975. var maxDecompositionLevelsCount = 0;
  31976. for (c = 0; c < componentsCount; c++) {
  31977. var component = tile.components[c];
  31978. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  31979. }
  31980. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  31981. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  31982. var maxNumPrecincts = 0;
  31983. for (c = 0; c < componentsCount; ++c) {
  31984. var resolutions = tile.components[c].resolutions;
  31985. if (r < resolutions.length) {
  31986. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  31987. }
  31988. }
  31989. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  31990. }
  31991. l = 0;
  31992. r = 0;
  31993. c = 0;
  31994. p = 0;
  31995. this.nextPacket = function JpxImage_nextPacket() {
  31996. for (; r <= maxDecompositionLevelsCount; r++) {
  31997. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  31998. for (; c < componentsCount; c++) {
  31999. var component = tile.components[c];
  32000. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32001. continue;
  32002. }
  32003. var resolution = component.resolutions[r];
  32004. var numprecincts = resolution.precinctParameters.numprecincts;
  32005. if (p >= numprecincts) {
  32006. continue;
  32007. }
  32008. for (; l < layersCount;) {
  32009. var packet = createPacket(resolution, p, l);
  32010. l++;
  32011. return packet;
  32012. }
  32013. l = 0;
  32014. }
  32015. c = 0;
  32016. }
  32017. p = 0;
  32018. }
  32019. error('JPX Error: Out of packets');
  32020. };
  32021. }
  32022. function PositionComponentResolutionLayerIterator(context) {
  32023. var siz = context.SIZ;
  32024. var tileIndex = context.currentTile.index;
  32025. var tile = context.tiles[tileIndex];
  32026. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32027. var componentsCount = siz.Csiz;
  32028. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32029. var precinctsIterationSizes = precinctsSizes;
  32030. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32031. this.nextPacket = function JpxImage_nextPacket() {
  32032. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32033. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32034. for (; c < componentsCount; c++) {
  32035. var component = tile.components[c];
  32036. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32037. for (; r <= decompositionLevelsCount; r++) {
  32038. var resolution = component.resolutions[r];
  32039. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32040. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32041. if (k === null) {
  32042. continue;
  32043. }
  32044. for (; l < layersCount;) {
  32045. var packet = createPacket(resolution, k, l);
  32046. l++;
  32047. return packet;
  32048. }
  32049. l = 0;
  32050. }
  32051. r = 0;
  32052. }
  32053. c = 0;
  32054. }
  32055. px = 0;
  32056. }
  32057. error('JPX Error: Out of packets');
  32058. };
  32059. }
  32060. function ComponentPositionResolutionLayerIterator(context) {
  32061. var siz = context.SIZ;
  32062. var tileIndex = context.currentTile.index;
  32063. var tile = context.tiles[tileIndex];
  32064. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32065. var componentsCount = siz.Csiz;
  32066. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32067. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32068. this.nextPacket = function JpxImage_nextPacket() {
  32069. for (; c < componentsCount; ++c) {
  32070. var component = tile.components[c];
  32071. var precinctsIterationSizes = precinctsSizes.components[c];
  32072. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32073. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32074. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32075. for (; r <= decompositionLevelsCount; r++) {
  32076. var resolution = component.resolutions[r];
  32077. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32078. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32079. if (k === null) {
  32080. continue;
  32081. }
  32082. for (; l < layersCount;) {
  32083. var packet = createPacket(resolution, k, l);
  32084. l++;
  32085. return packet;
  32086. }
  32087. l = 0;
  32088. }
  32089. r = 0;
  32090. }
  32091. px = 0;
  32092. }
  32093. py = 0;
  32094. }
  32095. error('JPX Error: Out of packets');
  32096. };
  32097. }
  32098. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32099. var posX = pxIndex * precinctIterationSizes.minWidth;
  32100. var posY = pyIndex * precinctIterationSizes.minHeight;
  32101. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32102. return null;
  32103. }
  32104. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32105. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32106. }
  32107. function getPrecinctSizesInImageScale(tile) {
  32108. var componentsCount = tile.components.length;
  32109. var minWidth = Number.MAX_VALUE;
  32110. var minHeight = Number.MAX_VALUE;
  32111. var maxNumWide = 0;
  32112. var maxNumHigh = 0;
  32113. var sizePerComponent = new Array(componentsCount);
  32114. for (var c = 0; c < componentsCount; c++) {
  32115. var component = tile.components[c];
  32116. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32117. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32118. var minWidthCurrentComponent = Number.MAX_VALUE;
  32119. var minHeightCurrentComponent = Number.MAX_VALUE;
  32120. var maxNumWideCurrentComponent = 0;
  32121. var maxNumHighCurrentComponent = 0;
  32122. var scale = 1;
  32123. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32124. var resolution = component.resolutions[r];
  32125. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32126. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32127. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32128. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32129. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32130. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32131. sizePerResolution[r] = {
  32132. width: widthCurrentResolution,
  32133. height: heightCurrentResolution
  32134. };
  32135. scale <<= 1;
  32136. }
  32137. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32138. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32139. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32140. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32141. sizePerComponent[c] = {
  32142. resolutions: sizePerResolution,
  32143. minWidth: minWidthCurrentComponent,
  32144. minHeight: minHeightCurrentComponent,
  32145. maxNumWide: maxNumWideCurrentComponent,
  32146. maxNumHigh: maxNumHighCurrentComponent
  32147. };
  32148. }
  32149. return {
  32150. components: sizePerComponent,
  32151. minWidth: minWidth,
  32152. minHeight: minHeight,
  32153. maxNumWide: maxNumWide,
  32154. maxNumHigh: maxNumHigh
  32155. };
  32156. }
  32157. function buildPackets(context) {
  32158. var siz = context.SIZ;
  32159. var tileIndex = context.currentTile.index;
  32160. var tile = context.tiles[tileIndex];
  32161. var componentsCount = siz.Csiz;
  32162. for (var c = 0; c < componentsCount; c++) {
  32163. var component = tile.components[c];
  32164. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32165. var resolutions = [];
  32166. var subbands = [];
  32167. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32168. var blocksDimensions = getBlocksDimensions(context, component, r);
  32169. var resolution = {};
  32170. var scale = 1 << decompositionLevelsCount - r;
  32171. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32172. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32173. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32174. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32175. resolution.resLevel = r;
  32176. buildPrecincts(context, resolution, blocksDimensions);
  32177. resolutions.push(resolution);
  32178. var subband;
  32179. if (r === 0) {
  32180. subband = {};
  32181. subband.type = 'LL';
  32182. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32183. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32184. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32185. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32186. subband.resolution = resolution;
  32187. buildCodeblocks(context, subband, blocksDimensions);
  32188. subbands.push(subband);
  32189. resolution.subbands = [subband];
  32190. } else {
  32191. var bscale = 1 << decompositionLevelsCount - r + 1;
  32192. var resolutionSubbands = [];
  32193. subband = {};
  32194. subband.type = 'HL';
  32195. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32196. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32197. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32198. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32199. subband.resolution = resolution;
  32200. buildCodeblocks(context, subband, blocksDimensions);
  32201. subbands.push(subband);
  32202. resolutionSubbands.push(subband);
  32203. subband = {};
  32204. subband.type = 'LH';
  32205. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32206. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32207. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32208. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32209. subband.resolution = resolution;
  32210. buildCodeblocks(context, subband, blocksDimensions);
  32211. subbands.push(subband);
  32212. resolutionSubbands.push(subband);
  32213. subband = {};
  32214. subband.type = 'HH';
  32215. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32216. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32217. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32218. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32219. subband.resolution = resolution;
  32220. buildCodeblocks(context, subband, blocksDimensions);
  32221. subbands.push(subband);
  32222. resolutionSubbands.push(subband);
  32223. resolution.subbands = resolutionSubbands;
  32224. }
  32225. }
  32226. component.resolutions = resolutions;
  32227. component.subbands = subbands;
  32228. }
  32229. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32230. switch (progressionOrder) {
  32231. case 0:
  32232. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32233. break;
  32234. case 1:
  32235. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32236. break;
  32237. case 2:
  32238. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32239. break;
  32240. case 3:
  32241. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32242. break;
  32243. case 4:
  32244. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32245. break;
  32246. default:
  32247. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32248. }
  32249. }
  32250. function parseTilePackets(context, data, offset, dataLength) {
  32251. var position = 0;
  32252. var buffer, bufferSize = 0, skipNextBit = false;
  32253. function readBits(count) {
  32254. while (bufferSize < count) {
  32255. var b = data[offset + position];
  32256. position++;
  32257. if (skipNextBit) {
  32258. buffer = buffer << 7 | b;
  32259. bufferSize += 7;
  32260. skipNextBit = false;
  32261. } else {
  32262. buffer = buffer << 8 | b;
  32263. bufferSize += 8;
  32264. }
  32265. if (b === 0xFF) {
  32266. skipNextBit = true;
  32267. }
  32268. }
  32269. bufferSize -= count;
  32270. return buffer >>> bufferSize & (1 << count) - 1;
  32271. }
  32272. function skipMarkerIfEqual(value) {
  32273. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32274. skipBytes(1);
  32275. return true;
  32276. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32277. skipBytes(2);
  32278. return true;
  32279. }
  32280. return false;
  32281. }
  32282. function skipBytes(count) {
  32283. position += count;
  32284. }
  32285. function alignToByte() {
  32286. bufferSize = 0;
  32287. if (skipNextBit) {
  32288. position++;
  32289. skipNextBit = false;
  32290. }
  32291. }
  32292. function readCodingpasses() {
  32293. if (readBits(1) === 0) {
  32294. return 1;
  32295. }
  32296. if (readBits(1) === 0) {
  32297. return 2;
  32298. }
  32299. var value = readBits(2);
  32300. if (value < 3) {
  32301. return value + 3;
  32302. }
  32303. value = readBits(5);
  32304. if (value < 31) {
  32305. return value + 6;
  32306. }
  32307. value = readBits(7);
  32308. return value + 37;
  32309. }
  32310. var tileIndex = context.currentTile.index;
  32311. var tile = context.tiles[tileIndex];
  32312. var sopMarkerUsed = context.COD.sopMarkerUsed;
  32313. var ephMarkerUsed = context.COD.ephMarkerUsed;
  32314. var packetsIterator = tile.packetsIterator;
  32315. while (position < dataLength) {
  32316. alignToByte();
  32317. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  32318. skipBytes(4);
  32319. }
  32320. var packet = packetsIterator.nextPacket();
  32321. if (!readBits(1)) {
  32322. continue;
  32323. }
  32324. var layerNumber = packet.layerNumber;
  32325. var queue = [], codeblock;
  32326. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  32327. codeblock = packet.codeblocks[i];
  32328. var precinct = codeblock.precinct;
  32329. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  32330. var codeblockRow = codeblock.cby - precinct.cbyMin;
  32331. var codeblockIncluded = false;
  32332. var firstTimeInclusion = false;
  32333. var valueReady;
  32334. if (codeblock['included'] !== undefined) {
  32335. codeblockIncluded = !!readBits(1);
  32336. } else {
  32337. precinct = codeblock.precinct;
  32338. var inclusionTree, zeroBitPlanesTree;
  32339. if (precinct['inclusionTree'] !== undefined) {
  32340. inclusionTree = precinct.inclusionTree;
  32341. } else {
  32342. var width = precinct.cbxMax - precinct.cbxMin + 1;
  32343. var height = precinct.cbyMax - precinct.cbyMin + 1;
  32344. inclusionTree = new InclusionTree(width, height, layerNumber);
  32345. zeroBitPlanesTree = new TagTree(width, height);
  32346. precinct.inclusionTree = inclusionTree;
  32347. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  32348. }
  32349. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  32350. while (true) {
  32351. if (readBits(1)) {
  32352. valueReady = !inclusionTree.nextLevel();
  32353. if (valueReady) {
  32354. codeblock.included = true;
  32355. codeblockIncluded = firstTimeInclusion = true;
  32356. break;
  32357. }
  32358. } else {
  32359. inclusionTree.incrementValue(layerNumber);
  32360. break;
  32361. }
  32362. }
  32363. }
  32364. }
  32365. if (!codeblockIncluded) {
  32366. continue;
  32367. }
  32368. if (firstTimeInclusion) {
  32369. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  32370. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  32371. while (true) {
  32372. if (readBits(1)) {
  32373. valueReady = !zeroBitPlanesTree.nextLevel();
  32374. if (valueReady) {
  32375. break;
  32376. }
  32377. } else {
  32378. zeroBitPlanesTree.incrementValue();
  32379. }
  32380. }
  32381. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  32382. }
  32383. var codingpasses = readCodingpasses();
  32384. while (readBits(1)) {
  32385. codeblock.Lblock++;
  32386. }
  32387. var codingpassesLog2 = log2(codingpasses);
  32388. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  32389. var codedDataLength = readBits(bits);
  32390. queue.push({
  32391. codeblock: codeblock,
  32392. codingpasses: codingpasses,
  32393. dataLength: codedDataLength
  32394. });
  32395. }
  32396. alignToByte();
  32397. if (ephMarkerUsed) {
  32398. skipMarkerIfEqual(0x92);
  32399. }
  32400. while (queue.length > 0) {
  32401. var packetItem = queue.shift();
  32402. codeblock = packetItem.codeblock;
  32403. if (codeblock['data'] === undefined) {
  32404. codeblock.data = [];
  32405. }
  32406. codeblock.data.push({
  32407. data: data,
  32408. start: offset + position,
  32409. end: offset + position + packetItem.dataLength,
  32410. codingpasses: packetItem.codingpasses
  32411. });
  32412. position += packetItem.dataLength;
  32413. }
  32414. }
  32415. return position;
  32416. }
  32417. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  32418. var x0 = subband.tbx0;
  32419. var y0 = subband.tby0;
  32420. var width = subband.tbx1 - subband.tbx0;
  32421. var codeblocks = subband.codeblocks;
  32422. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  32423. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  32424. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  32425. var codeblock = codeblocks[i];
  32426. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  32427. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  32428. if (blockWidth === 0 || blockHeight === 0) {
  32429. continue;
  32430. }
  32431. if (codeblock['data'] === undefined) {
  32432. continue;
  32433. }
  32434. var bitModel, currentCodingpassType;
  32435. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  32436. currentCodingpassType = 2;
  32437. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  32438. var j, jj, dataItem;
  32439. for (j = 0, jj = data.length; j < jj; j++) {
  32440. dataItem = data[j];
  32441. totalLength += dataItem.end - dataItem.start;
  32442. codingpasses += dataItem.codingpasses;
  32443. }
  32444. var encodedData = new Uint8Array(totalLength);
  32445. var position = 0;
  32446. for (j = 0, jj = data.length; j < jj; j++) {
  32447. dataItem = data[j];
  32448. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  32449. encodedData.set(chunk, position);
  32450. position += chunk.length;
  32451. }
  32452. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  32453. bitModel.setDecoder(decoder);
  32454. for (j = 0; j < codingpasses; j++) {
  32455. switch (currentCodingpassType) {
  32456. case 0:
  32457. bitModel.runSignificancePropagationPass();
  32458. break;
  32459. case 1:
  32460. bitModel.runMagnitudeRefinementPass();
  32461. break;
  32462. case 2:
  32463. bitModel.runCleanupPass();
  32464. if (segmentationSymbolUsed) {
  32465. bitModel.checkSegmentationSymbol();
  32466. }
  32467. break;
  32468. }
  32469. currentCodingpassType = (currentCodingpassType + 1) % 3;
  32470. }
  32471. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  32472. var sign = bitModel.coefficentsSign;
  32473. var magnitude = bitModel.coefficentsMagnitude;
  32474. var bitsDecoded = bitModel.bitsDecoded;
  32475. var magnitudeCorrection = reversible ? 0 : 0.5;
  32476. var k, n, nb;
  32477. position = 0;
  32478. var interleave = subband.type !== 'LL';
  32479. for (j = 0; j < blockHeight; j++) {
  32480. var row = offset / width | 0;
  32481. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  32482. for (k = 0; k < blockWidth; k++) {
  32483. n = magnitude[position];
  32484. if (n !== 0) {
  32485. n = (n + magnitudeCorrection) * delta;
  32486. if (sign[position] !== 0) {
  32487. n = -n;
  32488. }
  32489. nb = bitsDecoded[position];
  32490. var pos = interleave ? levelOffset + (offset << 1) : offset;
  32491. if (reversible && nb >= mb) {
  32492. coefficients[pos] = n;
  32493. } else {
  32494. coefficients[pos] = n * (1 << mb - nb);
  32495. }
  32496. }
  32497. offset++;
  32498. position++;
  32499. }
  32500. offset += width - blockWidth;
  32501. }
  32502. }
  32503. }
  32504. function transformTile(context, tile, c) {
  32505. var component = tile.components[c];
  32506. var codingStyleParameters = component.codingStyleParameters;
  32507. var quantizationParameters = component.quantizationParameters;
  32508. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  32509. var spqcds = quantizationParameters.SPqcds;
  32510. var scalarExpounded = quantizationParameters.scalarExpounded;
  32511. var guardBits = quantizationParameters.guardBits;
  32512. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  32513. var precision = context.components[c].precision;
  32514. var reversible = codingStyleParameters.reversibleTransformation;
  32515. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  32516. var subbandCoefficients = [];
  32517. var b = 0;
  32518. for (var i = 0; i <= decompositionLevelsCount; i++) {
  32519. var resolution = component.resolutions[i];
  32520. var width = resolution.trx1 - resolution.trx0;
  32521. var height = resolution.try1 - resolution.try0;
  32522. var coefficients = new Float32Array(width * height);
  32523. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  32524. var mu, epsilon;
  32525. if (!scalarExpounded) {
  32526. mu = spqcds[0].mu;
  32527. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  32528. } else {
  32529. mu = spqcds[b].mu;
  32530. epsilon = spqcds[b].epsilon;
  32531. b++;
  32532. }
  32533. var subband = resolution.subbands[j];
  32534. var gainLog2 = SubbandsGainLog2[subband.type];
  32535. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  32536. var mb = guardBits + epsilon - 1;
  32537. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  32538. }
  32539. subbandCoefficients.push({
  32540. width: width,
  32541. height: height,
  32542. items: coefficients
  32543. });
  32544. }
  32545. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  32546. return {
  32547. left: component.tcx0,
  32548. top: component.tcy0,
  32549. width: result.width,
  32550. height: result.height,
  32551. items: result.items
  32552. };
  32553. }
  32554. function transformComponents(context) {
  32555. var siz = context.SIZ;
  32556. var components = context.components;
  32557. var componentsCount = siz.Csiz;
  32558. var resultImages = [];
  32559. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  32560. var tile = context.tiles[i];
  32561. var transformedTiles = [];
  32562. var c;
  32563. for (c = 0; c < componentsCount; c++) {
  32564. transformedTiles[c] = transformTile(context, tile, c);
  32565. }
  32566. var tile0 = transformedTiles[0];
  32567. var out = new Uint8Array(tile0.items.length * componentsCount);
  32568. var result = {
  32569. left: tile0.left,
  32570. top: tile0.top,
  32571. width: tile0.width,
  32572. height: tile0.height,
  32573. items: out
  32574. };
  32575. var shift, offset, max, min, maxK;
  32576. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  32577. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  32578. var fourComponents = componentsCount === 4;
  32579. var y0items = transformedTiles[0].items;
  32580. var y1items = transformedTiles[1].items;
  32581. var y2items = transformedTiles[2].items;
  32582. var y3items = fourComponents ? transformedTiles[3].items : null;
  32583. shift = components[0].precision - 8;
  32584. offset = (128 << shift) + 0.5;
  32585. max = 255 * (1 << shift);
  32586. maxK = max * 0.5;
  32587. min = -maxK;
  32588. var component0 = tile.components[0];
  32589. var alpha01 = componentsCount - 3;
  32590. jj = y0items.length;
  32591. if (!component0.codingStyleParameters.reversibleTransformation) {
  32592. for (j = 0; j < jj; j++, pos += alpha01) {
  32593. y0 = y0items[j] + offset;
  32594. y1 = y1items[j];
  32595. y2 = y2items[j];
  32596. r = y0 + 1.402 * y2;
  32597. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  32598. b = y0 + 1.772 * y1;
  32599. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32600. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32601. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32602. }
  32603. } else {
  32604. for (j = 0; j < jj; j++, pos += alpha01) {
  32605. y0 = y0items[j] + offset;
  32606. y1 = y1items[j];
  32607. y2 = y2items[j];
  32608. g = y0 - (y2 + y1 >> 2);
  32609. r = g + y2;
  32610. b = g + y1;
  32611. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32612. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32613. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32614. }
  32615. }
  32616. if (fourComponents) {
  32617. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  32618. k = y3items[j];
  32619. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  32620. }
  32621. }
  32622. } else {
  32623. for (c = 0; c < componentsCount; c++) {
  32624. var items = transformedTiles[c].items;
  32625. shift = components[c].precision - 8;
  32626. offset = (128 << shift) + 0.5;
  32627. max = 127.5 * (1 << shift);
  32628. min = -max;
  32629. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  32630. val = items[j];
  32631. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  32632. pos += componentsCount;
  32633. }
  32634. }
  32635. }
  32636. resultImages.push(result);
  32637. }
  32638. return resultImages;
  32639. }
  32640. function initializeTile(context, tileIndex) {
  32641. var siz = context.SIZ;
  32642. var componentsCount = siz.Csiz;
  32643. var tile = context.tiles[tileIndex];
  32644. for (var c = 0; c < componentsCount; c++) {
  32645. var component = tile.components[c];
  32646. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  32647. component.quantizationParameters = qcdOrQcc;
  32648. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  32649. component.codingStyleParameters = codOrCoc;
  32650. }
  32651. tile.codingStyleDefaultParameters = context.currentTile.COD;
  32652. }
  32653. var TagTree = function TagTreeClosure() {
  32654. function TagTree(width, height) {
  32655. var levelsLength = log2(Math.max(width, height)) + 1;
  32656. this.levels = [];
  32657. for (var i = 0; i < levelsLength; i++) {
  32658. var level = {
  32659. width: width,
  32660. height: height,
  32661. items: []
  32662. };
  32663. this.levels.push(level);
  32664. width = Math.ceil(width / 2);
  32665. height = Math.ceil(height / 2);
  32666. }
  32667. }
  32668. TagTree.prototype = {
  32669. reset: function TagTree_reset(i, j) {
  32670. var currentLevel = 0, value = 0, level;
  32671. while (currentLevel < this.levels.length) {
  32672. level = this.levels[currentLevel];
  32673. var index = i + j * level.width;
  32674. if (level.items[index] !== undefined) {
  32675. value = level.items[index];
  32676. break;
  32677. }
  32678. level.index = index;
  32679. i >>= 1;
  32680. j >>= 1;
  32681. currentLevel++;
  32682. }
  32683. currentLevel--;
  32684. level = this.levels[currentLevel];
  32685. level.items[level.index] = value;
  32686. this.currentLevel = currentLevel;
  32687. delete this.value;
  32688. },
  32689. incrementValue: function TagTree_incrementValue() {
  32690. var level = this.levels[this.currentLevel];
  32691. level.items[level.index]++;
  32692. },
  32693. nextLevel: function TagTree_nextLevel() {
  32694. var currentLevel = this.currentLevel;
  32695. var level = this.levels[currentLevel];
  32696. var value = level.items[level.index];
  32697. currentLevel--;
  32698. if (currentLevel < 0) {
  32699. this.value = value;
  32700. return false;
  32701. }
  32702. this.currentLevel = currentLevel;
  32703. level = this.levels[currentLevel];
  32704. level.items[level.index] = value;
  32705. return true;
  32706. }
  32707. };
  32708. return TagTree;
  32709. }();
  32710. var InclusionTree = function InclusionTreeClosure() {
  32711. function InclusionTree(width, height, defaultValue) {
  32712. var levelsLength = log2(Math.max(width, height)) + 1;
  32713. this.levels = [];
  32714. for (var i = 0; i < levelsLength; i++) {
  32715. var items = new Uint8Array(width * height);
  32716. for (var j = 0, jj = items.length; j < jj; j++) {
  32717. items[j] = defaultValue;
  32718. }
  32719. var level = {
  32720. width: width,
  32721. height: height,
  32722. items: items
  32723. };
  32724. this.levels.push(level);
  32725. width = Math.ceil(width / 2);
  32726. height = Math.ceil(height / 2);
  32727. }
  32728. }
  32729. InclusionTree.prototype = {
  32730. reset: function InclusionTree_reset(i, j, stopValue) {
  32731. var currentLevel = 0;
  32732. while (currentLevel < this.levels.length) {
  32733. var level = this.levels[currentLevel];
  32734. var index = i + j * level.width;
  32735. level.index = index;
  32736. var value = level.items[index];
  32737. if (value === 0xFF) {
  32738. break;
  32739. }
  32740. if (value > stopValue) {
  32741. this.currentLevel = currentLevel;
  32742. this.propagateValues();
  32743. return false;
  32744. }
  32745. i >>= 1;
  32746. j >>= 1;
  32747. currentLevel++;
  32748. }
  32749. this.currentLevel = currentLevel - 1;
  32750. return true;
  32751. },
  32752. incrementValue: function InclusionTree_incrementValue(stopValue) {
  32753. var level = this.levels[this.currentLevel];
  32754. level.items[level.index] = stopValue + 1;
  32755. this.propagateValues();
  32756. },
  32757. propagateValues: function InclusionTree_propagateValues() {
  32758. var levelIndex = this.currentLevel;
  32759. var level = this.levels[levelIndex];
  32760. var currentValue = level.items[level.index];
  32761. while (--levelIndex >= 0) {
  32762. level = this.levels[levelIndex];
  32763. level.items[level.index] = currentValue;
  32764. }
  32765. },
  32766. nextLevel: function InclusionTree_nextLevel() {
  32767. var currentLevel = this.currentLevel;
  32768. var level = this.levels[currentLevel];
  32769. var value = level.items[level.index];
  32770. level.items[level.index] = 0xFF;
  32771. currentLevel--;
  32772. if (currentLevel < 0) {
  32773. return false;
  32774. }
  32775. this.currentLevel = currentLevel;
  32776. level = this.levels[currentLevel];
  32777. level.items[level.index] = value;
  32778. return true;
  32779. }
  32780. };
  32781. return InclusionTree;
  32782. }();
  32783. var BitModel = function BitModelClosure() {
  32784. var UNIFORM_CONTEXT = 17;
  32785. var RUNLENGTH_CONTEXT = 18;
  32786. var LLAndLHContextsLabel = new Uint8Array([
  32787. 0,
  32788. 5,
  32789. 8,
  32790. 0,
  32791. 3,
  32792. 7,
  32793. 8,
  32794. 0,
  32795. 4,
  32796. 7,
  32797. 8,
  32798. 0,
  32799. 0,
  32800. 0,
  32801. 0,
  32802. 0,
  32803. 1,
  32804. 6,
  32805. 8,
  32806. 0,
  32807. 3,
  32808. 7,
  32809. 8,
  32810. 0,
  32811. 4,
  32812. 7,
  32813. 8,
  32814. 0,
  32815. 0,
  32816. 0,
  32817. 0,
  32818. 0,
  32819. 2,
  32820. 6,
  32821. 8,
  32822. 0,
  32823. 3,
  32824. 7,
  32825. 8,
  32826. 0,
  32827. 4,
  32828. 7,
  32829. 8,
  32830. 0,
  32831. 0,
  32832. 0,
  32833. 0,
  32834. 0,
  32835. 2,
  32836. 6,
  32837. 8,
  32838. 0,
  32839. 3,
  32840. 7,
  32841. 8,
  32842. 0,
  32843. 4,
  32844. 7,
  32845. 8,
  32846. 0,
  32847. 0,
  32848. 0,
  32849. 0,
  32850. 0,
  32851. 2,
  32852. 6,
  32853. 8,
  32854. 0,
  32855. 3,
  32856. 7,
  32857. 8,
  32858. 0,
  32859. 4,
  32860. 7,
  32861. 8
  32862. ]);
  32863. var HLContextLabel = new Uint8Array([
  32864. 0,
  32865. 3,
  32866. 4,
  32867. 0,
  32868. 5,
  32869. 7,
  32870. 7,
  32871. 0,
  32872. 8,
  32873. 8,
  32874. 8,
  32875. 0,
  32876. 0,
  32877. 0,
  32878. 0,
  32879. 0,
  32880. 1,
  32881. 3,
  32882. 4,
  32883. 0,
  32884. 6,
  32885. 7,
  32886. 7,
  32887. 0,
  32888. 8,
  32889. 8,
  32890. 8,
  32891. 0,
  32892. 0,
  32893. 0,
  32894. 0,
  32895. 0,
  32896. 2,
  32897. 3,
  32898. 4,
  32899. 0,
  32900. 6,
  32901. 7,
  32902. 7,
  32903. 0,
  32904. 8,
  32905. 8,
  32906. 8,
  32907. 0,
  32908. 0,
  32909. 0,
  32910. 0,
  32911. 0,
  32912. 2,
  32913. 3,
  32914. 4,
  32915. 0,
  32916. 6,
  32917. 7,
  32918. 7,
  32919. 0,
  32920. 8,
  32921. 8,
  32922. 8,
  32923. 0,
  32924. 0,
  32925. 0,
  32926. 0,
  32927. 0,
  32928. 2,
  32929. 3,
  32930. 4,
  32931. 0,
  32932. 6,
  32933. 7,
  32934. 7,
  32935. 0,
  32936. 8,
  32937. 8,
  32938. 8
  32939. ]);
  32940. var HHContextLabel = new Uint8Array([
  32941. 0,
  32942. 1,
  32943. 2,
  32944. 0,
  32945. 1,
  32946. 2,
  32947. 2,
  32948. 0,
  32949. 2,
  32950. 2,
  32951. 2,
  32952. 0,
  32953. 0,
  32954. 0,
  32955. 0,
  32956. 0,
  32957. 3,
  32958. 4,
  32959. 5,
  32960. 0,
  32961. 4,
  32962. 5,
  32963. 5,
  32964. 0,
  32965. 5,
  32966. 5,
  32967. 5,
  32968. 0,
  32969. 0,
  32970. 0,
  32971. 0,
  32972. 0,
  32973. 6,
  32974. 7,
  32975. 7,
  32976. 0,
  32977. 7,
  32978. 7,
  32979. 7,
  32980. 0,
  32981. 7,
  32982. 7,
  32983. 7,
  32984. 0,
  32985. 0,
  32986. 0,
  32987. 0,
  32988. 0,
  32989. 8,
  32990. 8,
  32991. 8,
  32992. 0,
  32993. 8,
  32994. 8,
  32995. 8,
  32996. 0,
  32997. 8,
  32998. 8,
  32999. 8,
  33000. 0,
  33001. 0,
  33002. 0,
  33003. 0,
  33004. 0,
  33005. 8,
  33006. 8,
  33007. 8,
  33008. 0,
  33009. 8,
  33010. 8,
  33011. 8,
  33012. 0,
  33013. 8,
  33014. 8,
  33015. 8
  33016. ]);
  33017. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33018. this.width = width;
  33019. this.height = height;
  33020. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33021. var coefficientCount = width * height;
  33022. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33023. this.coefficentsSign = new Uint8Array(coefficientCount);
  33024. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33025. this.processingFlags = new Uint8Array(coefficientCount);
  33026. var bitsDecoded = new Uint8Array(coefficientCount);
  33027. if (zeroBitPlanes !== 0) {
  33028. for (var i = 0; i < coefficientCount; i++) {
  33029. bitsDecoded[i] = zeroBitPlanes;
  33030. }
  33031. }
  33032. this.bitsDecoded = bitsDecoded;
  33033. this.reset();
  33034. }
  33035. BitModel.prototype = {
  33036. setDecoder: function BitModel_setDecoder(decoder) {
  33037. this.decoder = decoder;
  33038. },
  33039. reset: function BitModel_reset() {
  33040. this.contexts = new Int8Array(19);
  33041. this.contexts[0] = 4 << 1 | 0;
  33042. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33043. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33044. },
  33045. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33046. var neighborsSignificance = this.neighborsSignificance;
  33047. var width = this.width, height = this.height;
  33048. var left = column > 0;
  33049. var right = column + 1 < width;
  33050. var i;
  33051. if (row > 0) {
  33052. i = index - width;
  33053. if (left) {
  33054. neighborsSignificance[i - 1] += 0x10;
  33055. }
  33056. if (right) {
  33057. neighborsSignificance[i + 1] += 0x10;
  33058. }
  33059. neighborsSignificance[i] += 0x04;
  33060. }
  33061. if (row + 1 < height) {
  33062. i = index + width;
  33063. if (left) {
  33064. neighborsSignificance[i - 1] += 0x10;
  33065. }
  33066. if (right) {
  33067. neighborsSignificance[i + 1] += 0x10;
  33068. }
  33069. neighborsSignificance[i] += 0x04;
  33070. }
  33071. if (left) {
  33072. neighborsSignificance[index - 1] += 0x01;
  33073. }
  33074. if (right) {
  33075. neighborsSignificance[index + 1] += 0x01;
  33076. }
  33077. neighborsSignificance[index] |= 0x80;
  33078. },
  33079. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33080. var decoder = this.decoder;
  33081. var width = this.width, height = this.height;
  33082. var coefficentsMagnitude = this.coefficentsMagnitude;
  33083. var coefficentsSign = this.coefficentsSign;
  33084. var neighborsSignificance = this.neighborsSignificance;
  33085. var processingFlags = this.processingFlags;
  33086. var contexts = this.contexts;
  33087. var labels = this.contextLabelTable;
  33088. var bitsDecoded = this.bitsDecoded;
  33089. var processedInverseMask = ~1;
  33090. var processedMask = 1;
  33091. var firstMagnitudeBitMask = 2;
  33092. for (var i0 = 0; i0 < height; i0 += 4) {
  33093. for (var j = 0; j < width; j++) {
  33094. var index = i0 * width + j;
  33095. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33096. var i = i0 + i1;
  33097. if (i >= height) {
  33098. break;
  33099. }
  33100. processingFlags[index] &= processedInverseMask;
  33101. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33102. continue;
  33103. }
  33104. var contextLabel = labels[neighborsSignificance[index]];
  33105. var decision = decoder.readBit(contexts, contextLabel);
  33106. if (decision) {
  33107. var sign = this.decodeSignBit(i, j, index);
  33108. coefficentsSign[index] = sign;
  33109. coefficentsMagnitude[index] = 1;
  33110. this.setNeighborsSignificance(i, j, index);
  33111. processingFlags[index] |= firstMagnitudeBitMask;
  33112. }
  33113. bitsDecoded[index]++;
  33114. processingFlags[index] |= processedMask;
  33115. }
  33116. }
  33117. }
  33118. },
  33119. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33120. var width = this.width, height = this.height;
  33121. var coefficentsMagnitude = this.coefficentsMagnitude;
  33122. var coefficentsSign = this.coefficentsSign;
  33123. var contribution, sign0, sign1, significance1;
  33124. var contextLabel, decoded;
  33125. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33126. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33127. sign1 = coefficentsSign[index + 1];
  33128. if (significance1) {
  33129. sign0 = coefficentsSign[index - 1];
  33130. contribution = 1 - sign1 - sign0;
  33131. } else {
  33132. contribution = 1 - sign1 - sign1;
  33133. }
  33134. } else if (significance1) {
  33135. sign0 = coefficentsSign[index - 1];
  33136. contribution = 1 - sign0 - sign0;
  33137. } else {
  33138. contribution = 0;
  33139. }
  33140. var horizontalContribution = 3 * contribution;
  33141. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33142. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33143. sign1 = coefficentsSign[index + width];
  33144. if (significance1) {
  33145. sign0 = coefficentsSign[index - width];
  33146. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33147. } else {
  33148. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33149. }
  33150. } else if (significance1) {
  33151. sign0 = coefficentsSign[index - width];
  33152. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33153. } else {
  33154. contribution = horizontalContribution;
  33155. }
  33156. if (contribution >= 0) {
  33157. contextLabel = 9 + contribution;
  33158. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33159. } else {
  33160. contextLabel = 9 - contribution;
  33161. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33162. }
  33163. return decoded;
  33164. },
  33165. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33166. var decoder = this.decoder;
  33167. var width = this.width, height = this.height;
  33168. var coefficentsMagnitude = this.coefficentsMagnitude;
  33169. var neighborsSignificance = this.neighborsSignificance;
  33170. var contexts = this.contexts;
  33171. var bitsDecoded = this.bitsDecoded;
  33172. var processingFlags = this.processingFlags;
  33173. var processedMask = 1;
  33174. var firstMagnitudeBitMask = 2;
  33175. var length = width * height;
  33176. var width4 = width * 4;
  33177. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33178. indexNext = Math.min(length, index0 + width4);
  33179. for (var j = 0; j < width; j++) {
  33180. for (var index = index0 + j; index < indexNext; index += width) {
  33181. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33182. continue;
  33183. }
  33184. var contextLabel = 16;
  33185. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33186. processingFlags[index] ^= firstMagnitudeBitMask;
  33187. var significance = neighborsSignificance[index] & 127;
  33188. contextLabel = significance === 0 ? 15 : 14;
  33189. }
  33190. var bit = decoder.readBit(contexts, contextLabel);
  33191. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33192. bitsDecoded[index]++;
  33193. processingFlags[index] |= processedMask;
  33194. }
  33195. }
  33196. }
  33197. },
  33198. runCleanupPass: function BitModel_runCleanupPass() {
  33199. var decoder = this.decoder;
  33200. var width = this.width, height = this.height;
  33201. var neighborsSignificance = this.neighborsSignificance;
  33202. var coefficentsMagnitude = this.coefficentsMagnitude;
  33203. var coefficentsSign = this.coefficentsSign;
  33204. var contexts = this.contexts;
  33205. var labels = this.contextLabelTable;
  33206. var bitsDecoded = this.bitsDecoded;
  33207. var processingFlags = this.processingFlags;
  33208. var processedMask = 1;
  33209. var firstMagnitudeBitMask = 2;
  33210. var oneRowDown = width;
  33211. var twoRowsDown = width * 2;
  33212. var threeRowsDown = width * 3;
  33213. var iNext;
  33214. for (var i0 = 0; i0 < height; i0 = iNext) {
  33215. iNext = Math.min(i0 + 4, height);
  33216. var indexBase = i0 * width;
  33217. var checkAllEmpty = i0 + 3 < height;
  33218. for (var j = 0; j < width; j++) {
  33219. var index0 = indexBase + j;
  33220. 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;
  33221. var i1 = 0, index = index0;
  33222. var i = i0, sign;
  33223. if (allEmpty) {
  33224. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33225. if (!hasSignificantCoefficent) {
  33226. bitsDecoded[index0]++;
  33227. bitsDecoded[index0 + oneRowDown]++;
  33228. bitsDecoded[index0 + twoRowsDown]++;
  33229. bitsDecoded[index0 + threeRowsDown]++;
  33230. continue;
  33231. }
  33232. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33233. if (i1 !== 0) {
  33234. i = i0 + i1;
  33235. index += i1 * width;
  33236. }
  33237. sign = this.decodeSignBit(i, j, index);
  33238. coefficentsSign[index] = sign;
  33239. coefficentsMagnitude[index] = 1;
  33240. this.setNeighborsSignificance(i, j, index);
  33241. processingFlags[index] |= firstMagnitudeBitMask;
  33242. index = index0;
  33243. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33244. bitsDecoded[index]++;
  33245. }
  33246. i1++;
  33247. }
  33248. for (i = i0 + i1; i < iNext; i++, index += width) {
  33249. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33250. continue;
  33251. }
  33252. var contextLabel = labels[neighborsSignificance[index]];
  33253. var decision = decoder.readBit(contexts, contextLabel);
  33254. if (decision === 1) {
  33255. sign = this.decodeSignBit(i, j, index);
  33256. coefficentsSign[index] = sign;
  33257. coefficentsMagnitude[index] = 1;
  33258. this.setNeighborsSignificance(i, j, index);
  33259. processingFlags[index] |= firstMagnitudeBitMask;
  33260. }
  33261. bitsDecoded[index]++;
  33262. }
  33263. }
  33264. }
  33265. },
  33266. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33267. var decoder = this.decoder;
  33268. var contexts = this.contexts;
  33269. 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);
  33270. if (symbol !== 0xA) {
  33271. error('JPX Error: Invalid segmentation symbol');
  33272. }
  33273. }
  33274. };
  33275. return BitModel;
  33276. }();
  33277. var Transform = function TransformClosure() {
  33278. function Transform() {
  33279. }
  33280. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33281. var ll = subbands[0];
  33282. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33283. ll = this.iterate(ll, subbands[i], u0, v0);
  33284. }
  33285. return ll;
  33286. };
  33287. Transform.prototype.extend = function extend(buffer, offset, size) {
  33288. var i1 = offset - 1, j1 = offset + 1;
  33289. var i2 = offset + size - 2, j2 = offset + size;
  33290. buffer[i1--] = buffer[j1++];
  33291. buffer[j2++] = buffer[i2--];
  33292. buffer[i1--] = buffer[j1++];
  33293. buffer[j2++] = buffer[i2--];
  33294. buffer[i1--] = buffer[j1++];
  33295. buffer[j2++] = buffer[i2--];
  33296. buffer[i1] = buffer[j1];
  33297. buffer[j2] = buffer[i2];
  33298. };
  33299. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  33300. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  33301. var width = hl_lh_hh.width;
  33302. var height = hl_lh_hh.height;
  33303. var items = hl_lh_hh.items;
  33304. var i, j, k, l, u, v;
  33305. for (k = 0, i = 0; i < llHeight; i++) {
  33306. l = i * 2 * width;
  33307. for (j = 0; j < llWidth; j++, k++, l += 2) {
  33308. items[l] = llItems[k];
  33309. }
  33310. }
  33311. llItems = ll.items = null;
  33312. var bufferPadding = 4;
  33313. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  33314. if (width === 1) {
  33315. if ((u0 & 1) !== 0) {
  33316. for (v = 0, k = 0; v < height; v++, k += width) {
  33317. items[k] *= 0.5;
  33318. }
  33319. }
  33320. } else {
  33321. for (v = 0, k = 0; v < height; v++, k += width) {
  33322. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  33323. this.extend(rowBuffer, bufferPadding, width);
  33324. this.filter(rowBuffer, bufferPadding, width);
  33325. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  33326. }
  33327. }
  33328. var numBuffers = 16;
  33329. var colBuffers = [];
  33330. for (i = 0; i < numBuffers; i++) {
  33331. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  33332. }
  33333. var b, currentBuffer = 0;
  33334. ll = bufferPadding + height;
  33335. if (height === 1) {
  33336. if ((v0 & 1) !== 0) {
  33337. for (u = 0; u < width; u++) {
  33338. items[u] *= 0.5;
  33339. }
  33340. }
  33341. } else {
  33342. for (u = 0; u < width; u++) {
  33343. if (currentBuffer === 0) {
  33344. numBuffers = Math.min(width - u, numBuffers);
  33345. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  33346. for (b = 0; b < numBuffers; b++) {
  33347. colBuffers[b][l] = items[k + b];
  33348. }
  33349. }
  33350. currentBuffer = numBuffers;
  33351. }
  33352. currentBuffer--;
  33353. var buffer = colBuffers[currentBuffer];
  33354. this.extend(buffer, bufferPadding, height);
  33355. this.filter(buffer, bufferPadding, height);
  33356. if (currentBuffer === 0) {
  33357. k = u - numBuffers + 1;
  33358. for (l = bufferPadding; l < ll; k += width, l++) {
  33359. for (b = 0; b < numBuffers; b++) {
  33360. items[k + b] = colBuffers[b][l];
  33361. }
  33362. }
  33363. }
  33364. }
  33365. }
  33366. return {
  33367. width: width,
  33368. height: height,
  33369. items: items
  33370. };
  33371. };
  33372. return Transform;
  33373. }();
  33374. var IrreversibleTransform = function IrreversibleTransformClosure() {
  33375. function IrreversibleTransform() {
  33376. Transform.call(this);
  33377. }
  33378. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  33379. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  33380. var len = length >> 1;
  33381. offset = offset | 0;
  33382. var j, n, current, next;
  33383. var alpha = -1.586134342059924;
  33384. var beta = -0.052980118572961;
  33385. var gamma = 0.882911075530934;
  33386. var delta = 0.443506852043971;
  33387. var K = 1.230174104914001;
  33388. var K_ = 1 / K;
  33389. j = offset - 3;
  33390. for (n = len + 4; n--; j += 2) {
  33391. x[j] *= K_;
  33392. }
  33393. j = offset - 2;
  33394. current = delta * x[j - 1];
  33395. for (n = len + 3; n--; j += 2) {
  33396. next = delta * x[j + 1];
  33397. x[j] = K * x[j] - current - next;
  33398. if (n--) {
  33399. j += 2;
  33400. current = delta * x[j + 1];
  33401. x[j] = K * x[j] - current - next;
  33402. } else {
  33403. break;
  33404. }
  33405. }
  33406. j = offset - 1;
  33407. current = gamma * x[j - 1];
  33408. for (n = len + 2; n--; j += 2) {
  33409. next = gamma * x[j + 1];
  33410. x[j] -= current + next;
  33411. if (n--) {
  33412. j += 2;
  33413. current = gamma * x[j + 1];
  33414. x[j] -= current + next;
  33415. } else {
  33416. break;
  33417. }
  33418. }
  33419. j = offset;
  33420. current = beta * x[j - 1];
  33421. for (n = len + 1; n--; j += 2) {
  33422. next = beta * x[j + 1];
  33423. x[j] -= current + next;
  33424. if (n--) {
  33425. j += 2;
  33426. current = beta * x[j + 1];
  33427. x[j] -= current + next;
  33428. } else {
  33429. break;
  33430. }
  33431. }
  33432. if (len !== 0) {
  33433. j = offset + 1;
  33434. current = alpha * x[j - 1];
  33435. for (n = len; n--; j += 2) {
  33436. next = alpha * x[j + 1];
  33437. x[j] -= current + next;
  33438. if (n--) {
  33439. j += 2;
  33440. current = alpha * x[j + 1];
  33441. x[j] -= current + next;
  33442. } else {
  33443. break;
  33444. }
  33445. }
  33446. }
  33447. };
  33448. return IrreversibleTransform;
  33449. }();
  33450. var ReversibleTransform = function ReversibleTransformClosure() {
  33451. function ReversibleTransform() {
  33452. Transform.call(this);
  33453. }
  33454. ReversibleTransform.prototype = Object.create(Transform.prototype);
  33455. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  33456. var len = length >> 1;
  33457. offset = offset | 0;
  33458. var j, n;
  33459. for (j = offset, n = len + 1; n--; j += 2) {
  33460. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  33461. }
  33462. for (j = offset + 1, n = len; n--; j += 2) {
  33463. x[j] += x[j - 1] + x[j + 1] >> 1;
  33464. }
  33465. };
  33466. return ReversibleTransform;
  33467. }();
  33468. return JpxImage;
  33469. }();
  33470. exports.JpxImage = JpxImage;
  33471. /***/ }),
  33472. /* 20 */
  33473. /***/ (function(module, exports, __w_pdfjs_require__) {
  33474. "use strict";
  33475. var sharedUtil = __w_pdfjs_require__(0);
  33476. var corePrimitives = __w_pdfjs_require__(1);
  33477. var coreCrypto = __w_pdfjs_require__(17);
  33478. var coreParser = __w_pdfjs_require__(6);
  33479. var coreChunkedStream = __w_pdfjs_require__(16);
  33480. var coreColorSpace = __w_pdfjs_require__(4);
  33481. var InvalidPDFException = sharedUtil.InvalidPDFException;
  33482. var MissingDataException = sharedUtil.MissingDataException;
  33483. var XRefParseException = sharedUtil.XRefParseException;
  33484. var assert = sharedUtil.assert;
  33485. var bytesToString = sharedUtil.bytesToString;
  33486. var createPromiseCapability = sharedUtil.createPromiseCapability;
  33487. var error = sharedUtil.error;
  33488. var info = sharedUtil.info;
  33489. var isArray = sharedUtil.isArray;
  33490. var isBool = sharedUtil.isBool;
  33491. var isInt = sharedUtil.isInt;
  33492. var isString = sharedUtil.isString;
  33493. var shadow = sharedUtil.shadow;
  33494. var stringToPDFString = sharedUtil.stringToPDFString;
  33495. var stringToUTF8String = sharedUtil.stringToUTF8String;
  33496. var warn = sharedUtil.warn;
  33497. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  33498. var Util = sharedUtil.Util;
  33499. var Ref = corePrimitives.Ref;
  33500. var RefSet = corePrimitives.RefSet;
  33501. var RefSetCache = corePrimitives.RefSetCache;
  33502. var isName = corePrimitives.isName;
  33503. var isCmd = corePrimitives.isCmd;
  33504. var isDict = corePrimitives.isDict;
  33505. var isRef = corePrimitives.isRef;
  33506. var isRefsEqual = corePrimitives.isRefsEqual;
  33507. var isStream = corePrimitives.isStream;
  33508. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  33509. var Lexer = coreParser.Lexer;
  33510. var Parser = coreParser.Parser;
  33511. var ChunkedStream = coreChunkedStream.ChunkedStream;
  33512. var ColorSpace = coreColorSpace.ColorSpace;
  33513. var Catalog = function CatalogClosure() {
  33514. function Catalog(pdfManager, xref, pageFactory) {
  33515. this.pdfManager = pdfManager;
  33516. this.xref = xref;
  33517. this.catDict = xref.getCatalogObj();
  33518. this.fontCache = new RefSetCache();
  33519. this.builtInCMapCache = Object.create(null);
  33520. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  33521. this.pageFactory = pageFactory;
  33522. this.pagePromises = [];
  33523. }
  33524. Catalog.prototype = {
  33525. get metadata() {
  33526. var streamRef = this.catDict.getRaw('Metadata');
  33527. if (!isRef(streamRef)) {
  33528. return shadow(this, 'metadata', null);
  33529. }
  33530. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  33531. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  33532. var metadata;
  33533. if (stream && isDict(stream.dict)) {
  33534. var type = stream.dict.get('Type');
  33535. var subtype = stream.dict.get('Subtype');
  33536. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  33537. try {
  33538. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  33539. } catch (e) {
  33540. if (e instanceof MissingDataException) {
  33541. throw e;
  33542. }
  33543. info('Skipping invalid metadata.');
  33544. }
  33545. }
  33546. }
  33547. return shadow(this, 'metadata', metadata);
  33548. },
  33549. get toplevelPagesDict() {
  33550. var pagesObj = this.catDict.get('Pages');
  33551. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  33552. return shadow(this, 'toplevelPagesDict', pagesObj);
  33553. },
  33554. get documentOutline() {
  33555. var obj = null;
  33556. try {
  33557. obj = this.readDocumentOutline();
  33558. } catch (ex) {
  33559. if (ex instanceof MissingDataException) {
  33560. throw ex;
  33561. }
  33562. warn('Unable to read document outline');
  33563. }
  33564. return shadow(this, 'documentOutline', obj);
  33565. },
  33566. readDocumentOutline: function Catalog_readDocumentOutline() {
  33567. var obj = this.catDict.get('Outlines');
  33568. if (!isDict(obj)) {
  33569. return null;
  33570. }
  33571. obj = obj.getRaw('First');
  33572. if (!isRef(obj)) {
  33573. return null;
  33574. }
  33575. var root = { items: [] };
  33576. var queue = [{
  33577. obj: obj,
  33578. parent: root
  33579. }];
  33580. var processed = new RefSet();
  33581. processed.put(obj);
  33582. var xref = this.xref, blackColor = new Uint8Array(3);
  33583. while (queue.length > 0) {
  33584. var i = queue.shift();
  33585. var outlineDict = xref.fetchIfRef(i.obj);
  33586. if (outlineDict === null) {
  33587. continue;
  33588. }
  33589. assert(outlineDict.has('Title'), 'Invalid outline item');
  33590. var data = {
  33591. url: null,
  33592. dest: null
  33593. };
  33594. Catalog.parseDestDictionary({
  33595. destDict: outlineDict,
  33596. resultObj: data,
  33597. docBaseUrl: this.pdfManager.docBaseUrl
  33598. });
  33599. var title = outlineDict.get('Title');
  33600. var flags = outlineDict.get('F') || 0;
  33601. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  33602. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  33603. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  33604. }
  33605. var outlineItem = {
  33606. dest: data.dest,
  33607. url: data.url,
  33608. unsafeUrl: data.unsafeUrl,
  33609. newWindow: data.newWindow,
  33610. title: stringToPDFString(title),
  33611. color: rgbColor,
  33612. count: outlineDict.get('Count'),
  33613. bold: !!(flags & 2),
  33614. italic: !!(flags & 1),
  33615. items: []
  33616. };
  33617. i.parent.items.push(outlineItem);
  33618. obj = outlineDict.getRaw('First');
  33619. if (isRef(obj) && !processed.has(obj)) {
  33620. queue.push({
  33621. obj: obj,
  33622. parent: outlineItem
  33623. });
  33624. processed.put(obj);
  33625. }
  33626. obj = outlineDict.getRaw('Next');
  33627. if (isRef(obj) && !processed.has(obj)) {
  33628. queue.push({
  33629. obj: obj,
  33630. parent: i.parent
  33631. });
  33632. processed.put(obj);
  33633. }
  33634. }
  33635. return root.items.length > 0 ? root.items : null;
  33636. },
  33637. get numPages() {
  33638. var obj = this.toplevelPagesDict.get('Count');
  33639. assert(isInt(obj), 'page count in top level pages object is not an integer');
  33640. return shadow(this, 'num', obj);
  33641. },
  33642. get destinations() {
  33643. function fetchDestination(dest) {
  33644. return isDict(dest) ? dest.get('D') : dest;
  33645. }
  33646. var xref = this.xref;
  33647. var dests = {}, nameTreeRef, nameDictionaryRef;
  33648. var obj = this.catDict.get('Names');
  33649. if (obj && obj.has('Dests')) {
  33650. nameTreeRef = obj.getRaw('Dests');
  33651. } else if (this.catDict.has('Dests')) {
  33652. nameDictionaryRef = this.catDict.get('Dests');
  33653. }
  33654. if (nameDictionaryRef) {
  33655. obj = nameDictionaryRef;
  33656. obj.forEach(function catalogForEach(key, value) {
  33657. if (!value) {
  33658. return;
  33659. }
  33660. dests[key] = fetchDestination(value);
  33661. });
  33662. }
  33663. if (nameTreeRef) {
  33664. var nameTree = new NameTree(nameTreeRef, xref);
  33665. var names = nameTree.getAll();
  33666. for (var name in names) {
  33667. dests[name] = fetchDestination(names[name]);
  33668. }
  33669. }
  33670. return shadow(this, 'destinations', dests);
  33671. },
  33672. getDestination: function Catalog_getDestination(destinationId) {
  33673. function fetchDestination(dest) {
  33674. return isDict(dest) ? dest.get('D') : dest;
  33675. }
  33676. var xref = this.xref;
  33677. var dest = null, nameTreeRef, nameDictionaryRef;
  33678. var obj = this.catDict.get('Names');
  33679. if (obj && obj.has('Dests')) {
  33680. nameTreeRef = obj.getRaw('Dests');
  33681. } else if (this.catDict.has('Dests')) {
  33682. nameDictionaryRef = this.catDict.get('Dests');
  33683. }
  33684. if (nameDictionaryRef) {
  33685. var value = nameDictionaryRef.get(destinationId);
  33686. if (value) {
  33687. dest = fetchDestination(value);
  33688. }
  33689. }
  33690. if (nameTreeRef) {
  33691. var nameTree = new NameTree(nameTreeRef, xref);
  33692. dest = fetchDestination(nameTree.get(destinationId));
  33693. }
  33694. return dest;
  33695. },
  33696. get pageLabels() {
  33697. var obj = null;
  33698. try {
  33699. obj = this.readPageLabels();
  33700. } catch (ex) {
  33701. if (ex instanceof MissingDataException) {
  33702. throw ex;
  33703. }
  33704. warn('Unable to read page labels.');
  33705. }
  33706. return shadow(this, 'pageLabels', obj);
  33707. },
  33708. readPageLabels: function Catalog_readPageLabels() {
  33709. var obj = this.catDict.getRaw('PageLabels');
  33710. if (!obj) {
  33711. return null;
  33712. }
  33713. var pageLabels = new Array(this.numPages);
  33714. var style = null;
  33715. var prefix = '';
  33716. var numberTree = new NumberTree(obj, this.xref);
  33717. var nums = numberTree.getAll();
  33718. var currentLabel = '', currentIndex = 1;
  33719. for (var i = 0, ii = this.numPages; i < ii; i++) {
  33720. if (i in nums) {
  33721. var labelDict = nums[i];
  33722. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  33723. var type = labelDict.get('Type');
  33724. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  33725. var s = labelDict.get('S');
  33726. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  33727. style = s ? s.name : null;
  33728. var p = labelDict.get('P');
  33729. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  33730. prefix = p ? stringToPDFString(p) : '';
  33731. var st = labelDict.get('St');
  33732. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  33733. currentIndex = st || 1;
  33734. }
  33735. switch (style) {
  33736. case 'D':
  33737. currentLabel = currentIndex;
  33738. break;
  33739. case 'R':
  33740. case 'r':
  33741. currentLabel = Util.toRoman(currentIndex, style === 'r');
  33742. break;
  33743. case 'A':
  33744. case 'a':
  33745. var LIMIT = 26;
  33746. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  33747. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  33748. var letterIndex = currentIndex - 1;
  33749. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  33750. var charBuf = [];
  33751. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  33752. charBuf.push(character);
  33753. }
  33754. currentLabel = charBuf.join('');
  33755. break;
  33756. default:
  33757. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  33758. }
  33759. pageLabels[i] = prefix + currentLabel;
  33760. currentLabel = '';
  33761. currentIndex++;
  33762. }
  33763. return pageLabels;
  33764. },
  33765. get attachments() {
  33766. var xref = this.xref;
  33767. var attachments = null, nameTreeRef;
  33768. var obj = this.catDict.get('Names');
  33769. if (obj) {
  33770. nameTreeRef = obj.getRaw('EmbeddedFiles');
  33771. }
  33772. if (nameTreeRef) {
  33773. var nameTree = new NameTree(nameTreeRef, xref);
  33774. var names = nameTree.getAll();
  33775. for (var name in names) {
  33776. var fs = new FileSpec(names[name], xref);
  33777. if (!attachments) {
  33778. attachments = Object.create(null);
  33779. }
  33780. attachments[stringToPDFString(name)] = fs.serializable;
  33781. }
  33782. }
  33783. return shadow(this, 'attachments', attachments);
  33784. },
  33785. get javaScript() {
  33786. var xref = this.xref;
  33787. var obj = this.catDict.get('Names');
  33788. var javaScript = [];
  33789. function appendIfJavaScriptDict(jsDict) {
  33790. var type = jsDict.get('S');
  33791. if (!isName(type, 'JavaScript')) {
  33792. return;
  33793. }
  33794. var js = jsDict.get('JS');
  33795. if (isStream(js)) {
  33796. js = bytesToString(js.getBytes());
  33797. } else if (!isString(js)) {
  33798. return;
  33799. }
  33800. javaScript.push(stringToPDFString(js));
  33801. }
  33802. if (obj && obj.has('JavaScript')) {
  33803. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  33804. var names = nameTree.getAll();
  33805. for (var name in names) {
  33806. var jsDict = names[name];
  33807. if (isDict(jsDict)) {
  33808. appendIfJavaScriptDict(jsDict);
  33809. }
  33810. }
  33811. }
  33812. var openactionDict = this.catDict.get('OpenAction');
  33813. if (isDict(openactionDict, 'Action')) {
  33814. var actionType = openactionDict.get('S');
  33815. if (isName(actionType, 'Named')) {
  33816. var action = openactionDict.get('N');
  33817. if (isName(action, 'Print')) {
  33818. javaScript.push('print({});');
  33819. }
  33820. } else {
  33821. appendIfJavaScriptDict(openactionDict);
  33822. }
  33823. }
  33824. return shadow(this, 'javaScript', javaScript);
  33825. },
  33826. cleanup: function Catalog_cleanup() {
  33827. var promises = [];
  33828. this.fontCache.forEach(function (promise) {
  33829. promises.push(promise);
  33830. });
  33831. return Promise.all(promises).then(function (translatedFonts) {
  33832. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  33833. var font = translatedFonts[i].dict;
  33834. delete font.translated;
  33835. }
  33836. this.fontCache.clear();
  33837. this.builtInCMapCache = Object.create(null);
  33838. }.bind(this));
  33839. },
  33840. getPage: function Catalog_getPage(pageIndex) {
  33841. if (!(pageIndex in this.pagePromises)) {
  33842. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  33843. var dict = a[0];
  33844. var ref = a[1];
  33845. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  33846. }.bind(this));
  33847. }
  33848. return this.pagePromises[pageIndex];
  33849. },
  33850. getPageDict: function Catalog_getPageDict(pageIndex) {
  33851. var capability = createPromiseCapability();
  33852. var nodesToVisit = [this.catDict.getRaw('Pages')];
  33853. var currentPageIndex = 0;
  33854. var xref = this.xref;
  33855. function next() {
  33856. while (nodesToVisit.length) {
  33857. var currentNode = nodesToVisit.pop();
  33858. if (isRef(currentNode)) {
  33859. xref.fetchAsync(currentNode).then(function (obj) {
  33860. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  33861. if (pageIndex === currentPageIndex) {
  33862. capability.resolve([
  33863. obj,
  33864. currentNode
  33865. ]);
  33866. } else {
  33867. currentPageIndex++;
  33868. next();
  33869. }
  33870. return;
  33871. }
  33872. nodesToVisit.push(obj);
  33873. next();
  33874. }, capability.reject);
  33875. return;
  33876. }
  33877. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  33878. var count = currentNode.get('Count');
  33879. if (currentPageIndex + count <= pageIndex) {
  33880. currentPageIndex += count;
  33881. continue;
  33882. }
  33883. var kids = currentNode.get('Kids');
  33884. assert(isArray(kids), 'page dictionary kids object is not an array');
  33885. for (var last = kids.length - 1; last >= 0; last--) {
  33886. nodesToVisit.push(kids[last]);
  33887. }
  33888. }
  33889. capability.reject('Page index ' + pageIndex + ' not found.');
  33890. }
  33891. next();
  33892. return capability.promise;
  33893. },
  33894. getPageIndex: function Catalog_getPageIndex(pageRef) {
  33895. var xref = this.xref;
  33896. function pagesBeforeRef(kidRef) {
  33897. var total = 0;
  33898. var parentRef;
  33899. return xref.fetchAsync(kidRef).then(function (node) {
  33900. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  33901. throw new Error('The reference does not point to a /Page Dict.');
  33902. }
  33903. if (!node) {
  33904. return null;
  33905. }
  33906. assert(isDict(node), 'node must be a Dict.');
  33907. parentRef = node.getRaw('Parent');
  33908. return node.getAsync('Parent');
  33909. }).then(function (parent) {
  33910. if (!parent) {
  33911. return null;
  33912. }
  33913. assert(isDict(parent), 'parent must be a Dict.');
  33914. return parent.getAsync('Kids');
  33915. }).then(function (kids) {
  33916. if (!kids) {
  33917. return null;
  33918. }
  33919. var kidPromises = [];
  33920. var found = false;
  33921. for (var i = 0; i < kids.length; i++) {
  33922. var kid = kids[i];
  33923. assert(isRef(kid), 'kid must be a Ref.');
  33924. if (kid.num === kidRef.num) {
  33925. found = true;
  33926. break;
  33927. }
  33928. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  33929. if (kid.has('Count')) {
  33930. var count = kid.get('Count');
  33931. total += count;
  33932. } else {
  33933. total++;
  33934. }
  33935. }));
  33936. }
  33937. if (!found) {
  33938. error('kid ref not found in parents kids');
  33939. }
  33940. return Promise.all(kidPromises).then(function () {
  33941. return [
  33942. total,
  33943. parentRef
  33944. ];
  33945. });
  33946. });
  33947. }
  33948. var total = 0;
  33949. function next(ref) {
  33950. return pagesBeforeRef(ref).then(function (args) {
  33951. if (!args) {
  33952. return total;
  33953. }
  33954. var count = args[0];
  33955. var parentRef = args[1];
  33956. total += count;
  33957. return next(parentRef);
  33958. });
  33959. }
  33960. return next(pageRef);
  33961. }
  33962. };
  33963. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  33964. function addDefaultProtocolToUrl(url) {
  33965. if (url.indexOf('www.') === 0) {
  33966. return 'http://' + url;
  33967. }
  33968. return url;
  33969. }
  33970. function tryConvertUrlEncoding(url) {
  33971. try {
  33972. return stringToUTF8String(url);
  33973. } catch (e) {
  33974. return url;
  33975. }
  33976. }
  33977. var destDict = params.destDict;
  33978. if (!isDict(destDict)) {
  33979. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  33980. return;
  33981. }
  33982. var resultObj = params.resultObj;
  33983. if (typeof resultObj !== 'object') {
  33984. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  33985. return;
  33986. }
  33987. var docBaseUrl = params.docBaseUrl || null;
  33988. var action = destDict.get('A'), url, dest;
  33989. if (isDict(action)) {
  33990. var linkType = action.get('S').name;
  33991. switch (linkType) {
  33992. case 'URI':
  33993. url = action.get('URI');
  33994. if (isName(url)) {
  33995. url = '/' + url.name;
  33996. } else if (isString(url)) {
  33997. url = addDefaultProtocolToUrl(url);
  33998. }
  33999. break;
  34000. case 'GoTo':
  34001. dest = action.get('D');
  34002. break;
  34003. case 'Launch':
  34004. case 'GoToR':
  34005. var urlDict = action.get('F');
  34006. if (isDict(urlDict)) {
  34007. url = urlDict.get('F') || null;
  34008. } else if (isString(urlDict)) {
  34009. url = urlDict;
  34010. }
  34011. var remoteDest = action.get('D');
  34012. if (remoteDest) {
  34013. if (isName(remoteDest)) {
  34014. remoteDest = remoteDest.name;
  34015. }
  34016. if (isString(url)) {
  34017. var baseUrl = url.split('#')[0];
  34018. if (isString(remoteDest)) {
  34019. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34020. } else if (isArray(remoteDest)) {
  34021. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34022. }
  34023. }
  34024. }
  34025. var newWindow = action.get('NewWindow');
  34026. if (isBool(newWindow)) {
  34027. resultObj.newWindow = newWindow;
  34028. }
  34029. break;
  34030. case 'Named':
  34031. var namedAction = action.get('N');
  34032. if (isName(namedAction)) {
  34033. resultObj.action = namedAction.name;
  34034. }
  34035. break;
  34036. case 'JavaScript':
  34037. var jsAction = action.get('JS'), js;
  34038. if (isStream(jsAction)) {
  34039. js = bytesToString(jsAction.getBytes());
  34040. } else if (isString(jsAction)) {
  34041. js = jsAction;
  34042. }
  34043. if (js) {
  34044. var URL_OPEN_METHODS = [
  34045. 'app.launchURL',
  34046. 'window.open'
  34047. ];
  34048. var regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
  34049. var jsUrl = regex.exec(stringToPDFString(js));
  34050. if (jsUrl && jsUrl[2]) {
  34051. url = jsUrl[2];
  34052. if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
  34053. resultObj.newWindow = true;
  34054. }
  34055. break;
  34056. }
  34057. }
  34058. default:
  34059. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34060. break;
  34061. }
  34062. } else if (destDict.has('Dest')) {
  34063. dest = destDict.get('Dest');
  34064. }
  34065. if (isString(url)) {
  34066. url = tryConvertUrlEncoding(url);
  34067. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34068. if (absoluteUrl) {
  34069. resultObj.url = absoluteUrl.href;
  34070. }
  34071. resultObj.unsafeUrl = url;
  34072. }
  34073. if (dest) {
  34074. if (isName(dest)) {
  34075. dest = dest.name;
  34076. }
  34077. if (isString(dest) || isArray(dest)) {
  34078. resultObj.dest = dest;
  34079. }
  34080. }
  34081. };
  34082. return Catalog;
  34083. }();
  34084. var XRef = function XRefClosure() {
  34085. function XRef(stream, pdfManager) {
  34086. this.stream = stream;
  34087. this.pdfManager = pdfManager;
  34088. this.entries = [];
  34089. this.xrefstms = Object.create(null);
  34090. this.cache = [];
  34091. this.stats = {
  34092. streamTypes: [],
  34093. fontTypes: []
  34094. };
  34095. }
  34096. XRef.prototype = {
  34097. setStartXRef: function XRef_setStartXRef(startXRef) {
  34098. this.startXRefQueue = [startXRef];
  34099. },
  34100. parse: function XRef_parse(recoveryMode) {
  34101. var trailerDict;
  34102. if (!recoveryMode) {
  34103. trailerDict = this.readXRef();
  34104. } else {
  34105. warn('Indexing all PDF objects');
  34106. trailerDict = this.indexObjects();
  34107. }
  34108. trailerDict.assignXref(this);
  34109. this.trailer = trailerDict;
  34110. var encrypt = trailerDict.get('Encrypt');
  34111. if (isDict(encrypt)) {
  34112. var ids = trailerDict.get('ID');
  34113. var fileId = ids && ids.length ? ids[0] : '';
  34114. encrypt.suppressEncryption = true;
  34115. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34116. }
  34117. if (!(this.root = trailerDict.get('Root'))) {
  34118. error('Invalid root reference');
  34119. }
  34120. },
  34121. processXRefTable: function XRef_processXRefTable(parser) {
  34122. if (!('tableState' in this)) {
  34123. this.tableState = {
  34124. entryNum: 0,
  34125. streamPos: parser.lexer.stream.pos,
  34126. parserBuf1: parser.buf1,
  34127. parserBuf2: parser.buf2
  34128. };
  34129. }
  34130. var obj = this.readXRefTable(parser);
  34131. if (!isCmd(obj, 'trailer')) {
  34132. error('Invalid XRef table: could not find trailer dictionary');
  34133. }
  34134. var dict = parser.getObj();
  34135. if (!isDict(dict) && dict.dict) {
  34136. dict = dict.dict;
  34137. }
  34138. if (!isDict(dict)) {
  34139. error('Invalid XRef table: could not parse trailer dictionary');
  34140. }
  34141. delete this.tableState;
  34142. return dict;
  34143. },
  34144. readXRefTable: function XRef_readXRefTable(parser) {
  34145. var stream = parser.lexer.stream;
  34146. var tableState = this.tableState;
  34147. stream.pos = tableState.streamPos;
  34148. parser.buf1 = tableState.parserBuf1;
  34149. parser.buf2 = tableState.parserBuf2;
  34150. var obj;
  34151. while (true) {
  34152. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34153. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34154. break;
  34155. }
  34156. tableState.firstEntryNum = obj;
  34157. tableState.entryCount = parser.getObj();
  34158. }
  34159. var first = tableState.firstEntryNum;
  34160. var count = tableState.entryCount;
  34161. if (!isInt(first) || !isInt(count)) {
  34162. error('Invalid XRef table: wrong types in subsection header');
  34163. }
  34164. for (var i = tableState.entryNum; i < count; i++) {
  34165. tableState.streamPos = stream.pos;
  34166. tableState.entryNum = i;
  34167. tableState.parserBuf1 = parser.buf1;
  34168. tableState.parserBuf2 = parser.buf2;
  34169. var entry = {};
  34170. entry.offset = parser.getObj();
  34171. entry.gen = parser.getObj();
  34172. var type = parser.getObj();
  34173. if (isCmd(type, 'f')) {
  34174. entry.free = true;
  34175. } else if (isCmd(type, 'n')) {
  34176. entry.uncompressed = true;
  34177. }
  34178. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34179. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34180. }
  34181. if (i === 0 && entry.free && first === 1) {
  34182. first = 0;
  34183. }
  34184. if (!this.entries[i + first]) {
  34185. this.entries[i + first] = entry;
  34186. }
  34187. }
  34188. tableState.entryNum = 0;
  34189. tableState.streamPos = stream.pos;
  34190. tableState.parserBuf1 = parser.buf1;
  34191. tableState.parserBuf2 = parser.buf2;
  34192. delete tableState.firstEntryNum;
  34193. delete tableState.entryCount;
  34194. }
  34195. if (this.entries[0] && !this.entries[0].free) {
  34196. error('Invalid XRef table: unexpected first object');
  34197. }
  34198. return obj;
  34199. },
  34200. processXRefStream: function XRef_processXRefStream(stream) {
  34201. if (!('streamState' in this)) {
  34202. var streamParameters = stream.dict;
  34203. var byteWidths = streamParameters.get('W');
  34204. var range = streamParameters.get('Index');
  34205. if (!range) {
  34206. range = [
  34207. 0,
  34208. streamParameters.get('Size')
  34209. ];
  34210. }
  34211. this.streamState = {
  34212. entryRanges: range,
  34213. byteWidths: byteWidths,
  34214. entryNum: 0,
  34215. streamPos: stream.pos
  34216. };
  34217. }
  34218. this.readXRefStream(stream);
  34219. delete this.streamState;
  34220. return stream.dict;
  34221. },
  34222. readXRefStream: function XRef_readXRefStream(stream) {
  34223. var i, j;
  34224. var streamState = this.streamState;
  34225. stream.pos = streamState.streamPos;
  34226. var byteWidths = streamState.byteWidths;
  34227. var typeFieldWidth = byteWidths[0];
  34228. var offsetFieldWidth = byteWidths[1];
  34229. var generationFieldWidth = byteWidths[2];
  34230. var entryRanges = streamState.entryRanges;
  34231. while (entryRanges.length > 0) {
  34232. var first = entryRanges[0];
  34233. var n = entryRanges[1];
  34234. if (!isInt(first) || !isInt(n)) {
  34235. error('Invalid XRef range fields: ' + first + ', ' + n);
  34236. }
  34237. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34238. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34239. }
  34240. for (i = streamState.entryNum; i < n; ++i) {
  34241. streamState.entryNum = i;
  34242. streamState.streamPos = stream.pos;
  34243. var type = 0, offset = 0, generation = 0;
  34244. for (j = 0; j < typeFieldWidth; ++j) {
  34245. type = type << 8 | stream.getByte();
  34246. }
  34247. if (typeFieldWidth === 0) {
  34248. type = 1;
  34249. }
  34250. for (j = 0; j < offsetFieldWidth; ++j) {
  34251. offset = offset << 8 | stream.getByte();
  34252. }
  34253. for (j = 0; j < generationFieldWidth; ++j) {
  34254. generation = generation << 8 | stream.getByte();
  34255. }
  34256. var entry = {};
  34257. entry.offset = offset;
  34258. entry.gen = generation;
  34259. switch (type) {
  34260. case 0:
  34261. entry.free = true;
  34262. break;
  34263. case 1:
  34264. entry.uncompressed = true;
  34265. break;
  34266. case 2:
  34267. break;
  34268. default:
  34269. error('Invalid XRef entry type: ' + type);
  34270. }
  34271. if (!this.entries[first + i]) {
  34272. this.entries[first + i] = entry;
  34273. }
  34274. }
  34275. streamState.entryNum = 0;
  34276. streamState.streamPos = stream.pos;
  34277. entryRanges.splice(0, 2);
  34278. }
  34279. },
  34280. indexObjects: function XRef_indexObjects() {
  34281. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34282. var PERCENT = 0x25, LT = 0x3C;
  34283. function readToken(data, offset) {
  34284. var token = '', ch = data[offset];
  34285. while (ch !== LF && ch !== CR && ch !== LT) {
  34286. if (++offset >= data.length) {
  34287. break;
  34288. }
  34289. token += String.fromCharCode(ch);
  34290. ch = data[offset];
  34291. }
  34292. return token;
  34293. }
  34294. function skipUntil(data, offset, what) {
  34295. var length = what.length, dataLength = data.length;
  34296. var skipped = 0;
  34297. while (offset < dataLength) {
  34298. var i = 0;
  34299. while (i < length && data[offset + i] === what[i]) {
  34300. ++i;
  34301. }
  34302. if (i >= length) {
  34303. break;
  34304. }
  34305. offset++;
  34306. skipped++;
  34307. }
  34308. return skipped;
  34309. }
  34310. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  34311. var trailerBytes = new Uint8Array([
  34312. 116,
  34313. 114,
  34314. 97,
  34315. 105,
  34316. 108,
  34317. 101,
  34318. 114
  34319. ]);
  34320. var startxrefBytes = new Uint8Array([
  34321. 115,
  34322. 116,
  34323. 97,
  34324. 114,
  34325. 116,
  34326. 120,
  34327. 114,
  34328. 101,
  34329. 102
  34330. ]);
  34331. var endobjBytes = new Uint8Array([
  34332. 101,
  34333. 110,
  34334. 100,
  34335. 111,
  34336. 98,
  34337. 106
  34338. ]);
  34339. var xrefBytes = new Uint8Array([
  34340. 47,
  34341. 88,
  34342. 82,
  34343. 101,
  34344. 102
  34345. ]);
  34346. this.entries.length = 0;
  34347. var stream = this.stream;
  34348. stream.pos = 0;
  34349. var buffer = stream.getBytes();
  34350. var position = stream.start, length = buffer.length;
  34351. var trailers = [], xrefStms = [];
  34352. while (position < length) {
  34353. var ch = buffer[position];
  34354. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  34355. ++position;
  34356. continue;
  34357. }
  34358. if (ch === PERCENT) {
  34359. do {
  34360. ++position;
  34361. if (position >= length) {
  34362. break;
  34363. }
  34364. ch = buffer[position];
  34365. } while (ch !== LF && ch !== CR);
  34366. continue;
  34367. }
  34368. var token = readToken(buffer, position);
  34369. var m;
  34370. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  34371. position += skipUntil(buffer, position, trailerBytes);
  34372. trailers.push(position);
  34373. position += skipUntil(buffer, position, startxrefBytes);
  34374. } else if (m = objRegExp.exec(token)) {
  34375. if (typeof this.entries[m[1]] === 'undefined') {
  34376. this.entries[m[1]] = {
  34377. offset: position - stream.start,
  34378. gen: m[2] | 0,
  34379. uncompressed: true
  34380. };
  34381. }
  34382. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  34383. var content = buffer.subarray(position, position + contentLength);
  34384. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  34385. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  34386. xrefStms.push(position - stream.start);
  34387. this.xrefstms[position - stream.start] = 1;
  34388. }
  34389. position += contentLength;
  34390. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  34391. trailers.push(position);
  34392. position += skipUntil(buffer, position, startxrefBytes);
  34393. } else {
  34394. position += token.length + 1;
  34395. }
  34396. }
  34397. var i, ii;
  34398. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  34399. this.startXRefQueue.push(xrefStms[i]);
  34400. this.readXRef(true);
  34401. }
  34402. var dict;
  34403. for (i = 0, ii = trailers.length; i < ii; ++i) {
  34404. stream.pos = trailers[i];
  34405. var parser = new Parser(new Lexer(stream), true, this, true);
  34406. var obj = parser.getObj();
  34407. if (!isCmd(obj, 'trailer')) {
  34408. continue;
  34409. }
  34410. dict = parser.getObj();
  34411. if (!isDict(dict)) {
  34412. continue;
  34413. }
  34414. if (dict.has('ID')) {
  34415. return dict;
  34416. }
  34417. }
  34418. if (dict) {
  34419. return dict;
  34420. }
  34421. throw new InvalidPDFException('Invalid PDF structure');
  34422. },
  34423. readXRef: function XRef_readXRef(recoveryMode) {
  34424. var stream = this.stream;
  34425. try {
  34426. while (this.startXRefQueue.length) {
  34427. var startXRef = this.startXRefQueue[0];
  34428. stream.pos = startXRef + stream.start;
  34429. var parser = new Parser(new Lexer(stream), true, this);
  34430. var obj = parser.getObj();
  34431. var dict;
  34432. if (isCmd(obj, 'xref')) {
  34433. dict = this.processXRefTable(parser);
  34434. if (!this.topDict) {
  34435. this.topDict = dict;
  34436. }
  34437. obj = dict.get('XRefStm');
  34438. if (isInt(obj)) {
  34439. var pos = obj;
  34440. if (!(pos in this.xrefstms)) {
  34441. this.xrefstms[pos] = 1;
  34442. this.startXRefQueue.push(pos);
  34443. }
  34444. }
  34445. } else if (isInt(obj)) {
  34446. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  34447. error('Invalid XRef stream');
  34448. }
  34449. dict = this.processXRefStream(obj);
  34450. if (!this.topDict) {
  34451. this.topDict = dict;
  34452. }
  34453. if (!dict) {
  34454. error('Failed to read XRef stream');
  34455. }
  34456. } else {
  34457. error('Invalid XRef stream header');
  34458. }
  34459. obj = dict.get('Prev');
  34460. if (isInt(obj)) {
  34461. this.startXRefQueue.push(obj);
  34462. } else if (isRef(obj)) {
  34463. this.startXRefQueue.push(obj.num);
  34464. }
  34465. this.startXRefQueue.shift();
  34466. }
  34467. return this.topDict;
  34468. } catch (e) {
  34469. if (e instanceof MissingDataException) {
  34470. throw e;
  34471. }
  34472. info('(while reading XRef): ' + e);
  34473. }
  34474. if (recoveryMode) {
  34475. return;
  34476. }
  34477. throw new XRefParseException();
  34478. },
  34479. getEntry: function XRef_getEntry(i) {
  34480. var xrefEntry = this.entries[i];
  34481. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  34482. return xrefEntry;
  34483. }
  34484. return null;
  34485. },
  34486. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  34487. if (!isRef(obj)) {
  34488. return obj;
  34489. }
  34490. return this.fetch(obj, suppressEncryption);
  34491. },
  34492. fetch: function XRef_fetch(ref, suppressEncryption) {
  34493. assert(isRef(ref), 'ref object is not a reference');
  34494. var num = ref.num;
  34495. if (num in this.cache) {
  34496. var cacheEntry = this.cache[num];
  34497. if (isDict(cacheEntry) && !cacheEntry.objId) {
  34498. cacheEntry.objId = ref.toString();
  34499. }
  34500. return cacheEntry;
  34501. }
  34502. var xrefEntry = this.getEntry(num);
  34503. if (xrefEntry === null) {
  34504. return this.cache[num] = null;
  34505. }
  34506. if (xrefEntry.uncompressed) {
  34507. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  34508. } else {
  34509. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  34510. }
  34511. if (isDict(xrefEntry)) {
  34512. xrefEntry.objId = ref.toString();
  34513. } else if (isStream(xrefEntry)) {
  34514. xrefEntry.dict.objId = ref.toString();
  34515. }
  34516. return xrefEntry;
  34517. },
  34518. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  34519. var gen = ref.gen;
  34520. var num = ref.num;
  34521. if (xrefEntry.gen !== gen) {
  34522. error('inconsistent generation in XRef');
  34523. }
  34524. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  34525. var parser = new Parser(new Lexer(stream), true, this);
  34526. var obj1 = parser.getObj();
  34527. var obj2 = parser.getObj();
  34528. var obj3 = parser.getObj();
  34529. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  34530. error('bad XRef entry');
  34531. }
  34532. if (!isCmd(obj3, 'obj')) {
  34533. if (obj3.cmd.indexOf('obj') === 0) {
  34534. num = parseInt(obj3.cmd.substring(3), 10);
  34535. if (!isNaN(num)) {
  34536. return num;
  34537. }
  34538. }
  34539. error('bad XRef entry');
  34540. }
  34541. if (this.encrypt && !suppressEncryption) {
  34542. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  34543. } else {
  34544. xrefEntry = parser.getObj();
  34545. }
  34546. if (!isStream(xrefEntry)) {
  34547. this.cache[num] = xrefEntry;
  34548. }
  34549. return xrefEntry;
  34550. },
  34551. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  34552. var tableOffset = xrefEntry.offset;
  34553. var stream = this.fetch(new Ref(tableOffset, 0));
  34554. if (!isStream(stream)) {
  34555. error('bad ObjStm stream');
  34556. }
  34557. var first = stream.dict.get('First');
  34558. var n = stream.dict.get('N');
  34559. if (!isInt(first) || !isInt(n)) {
  34560. error('invalid first and n parameters for ObjStm stream');
  34561. }
  34562. var parser = new Parser(new Lexer(stream), false, this);
  34563. parser.allowStreams = true;
  34564. var i, entries = [], num, nums = [];
  34565. for (i = 0; i < n; ++i) {
  34566. num = parser.getObj();
  34567. if (!isInt(num)) {
  34568. error('invalid object number in the ObjStm stream: ' + num);
  34569. }
  34570. nums.push(num);
  34571. var offset = parser.getObj();
  34572. if (!isInt(offset)) {
  34573. error('invalid object offset in the ObjStm stream: ' + offset);
  34574. }
  34575. }
  34576. for (i = 0; i < n; ++i) {
  34577. entries.push(parser.getObj());
  34578. if (isCmd(parser.buf1, 'endobj')) {
  34579. parser.shift();
  34580. }
  34581. num = nums[i];
  34582. var entry = this.entries[num];
  34583. if (entry && entry.offset === tableOffset && entry.gen === i) {
  34584. this.cache[num] = entries[i];
  34585. }
  34586. }
  34587. xrefEntry = entries[xrefEntry.gen];
  34588. if (xrefEntry === undefined) {
  34589. error('bad XRef entry for compressed object');
  34590. }
  34591. return xrefEntry;
  34592. },
  34593. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  34594. if (!isRef(obj)) {
  34595. return Promise.resolve(obj);
  34596. }
  34597. return this.fetchAsync(obj, suppressEncryption);
  34598. },
  34599. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  34600. var streamManager = this.stream.manager;
  34601. var xref = this;
  34602. return new Promise(function tryFetch(resolve, reject) {
  34603. try {
  34604. resolve(xref.fetch(ref, suppressEncryption));
  34605. } catch (e) {
  34606. if (e instanceof MissingDataException) {
  34607. streamManager.requestRange(e.begin, e.end).then(function () {
  34608. tryFetch(resolve, reject);
  34609. }, reject);
  34610. return;
  34611. }
  34612. reject(e);
  34613. }
  34614. });
  34615. },
  34616. getCatalogObj: function XRef_getCatalogObj() {
  34617. return this.root;
  34618. }
  34619. };
  34620. return XRef;
  34621. }();
  34622. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  34623. function NameOrNumberTree(root, xref) {
  34624. throw new Error('Cannot initialize NameOrNumberTree.');
  34625. }
  34626. NameOrNumberTree.prototype = {
  34627. getAll: function NameOrNumberTree_getAll() {
  34628. var dict = Object.create(null);
  34629. if (!this.root) {
  34630. return dict;
  34631. }
  34632. var xref = this.xref;
  34633. var processed = new RefSet();
  34634. processed.put(this.root);
  34635. var queue = [this.root];
  34636. while (queue.length > 0) {
  34637. var i, n;
  34638. var obj = xref.fetchIfRef(queue.shift());
  34639. if (!isDict(obj)) {
  34640. continue;
  34641. }
  34642. if (obj.has('Kids')) {
  34643. var kids = obj.get('Kids');
  34644. for (i = 0, n = kids.length; i < n; i++) {
  34645. var kid = kids[i];
  34646. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  34647. queue.push(kid);
  34648. processed.put(kid);
  34649. }
  34650. continue;
  34651. }
  34652. var entries = obj.get(this._type);
  34653. if (isArray(entries)) {
  34654. for (i = 0, n = entries.length; i < n; i += 2) {
  34655. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  34656. }
  34657. }
  34658. }
  34659. return dict;
  34660. },
  34661. get: function NameOrNumberTree_get(key) {
  34662. if (!this.root) {
  34663. return null;
  34664. }
  34665. var xref = this.xref;
  34666. var kidsOrEntries = xref.fetchIfRef(this.root);
  34667. var loopCount = 0;
  34668. var MAX_LEVELS = 10;
  34669. var l, r, m;
  34670. while (kidsOrEntries.has('Kids')) {
  34671. if (++loopCount > MAX_LEVELS) {
  34672. warn('Search depth limit reached for "' + this._type + '" tree.');
  34673. return null;
  34674. }
  34675. var kids = kidsOrEntries.get('Kids');
  34676. if (!isArray(kids)) {
  34677. return null;
  34678. }
  34679. l = 0;
  34680. r = kids.length - 1;
  34681. while (l <= r) {
  34682. m = l + r >> 1;
  34683. var kid = xref.fetchIfRef(kids[m]);
  34684. var limits = kid.get('Limits');
  34685. if (key < xref.fetchIfRef(limits[0])) {
  34686. r = m - 1;
  34687. } else if (key > xref.fetchIfRef(limits[1])) {
  34688. l = m + 1;
  34689. } else {
  34690. kidsOrEntries = xref.fetchIfRef(kids[m]);
  34691. break;
  34692. }
  34693. }
  34694. if (l > r) {
  34695. return null;
  34696. }
  34697. }
  34698. var entries = kidsOrEntries.get(this._type);
  34699. if (isArray(entries)) {
  34700. l = 0;
  34701. r = entries.length - 2;
  34702. while (l <= r) {
  34703. m = l + r & ~1;
  34704. var currentKey = xref.fetchIfRef(entries[m]);
  34705. if (key < currentKey) {
  34706. r = m - 2;
  34707. } else if (key > currentKey) {
  34708. l = m + 2;
  34709. } else {
  34710. return xref.fetchIfRef(entries[m + 1]);
  34711. }
  34712. }
  34713. }
  34714. return null;
  34715. }
  34716. };
  34717. return NameOrNumberTree;
  34718. }();
  34719. var NameTree = function NameTreeClosure() {
  34720. function NameTree(root, xref) {
  34721. this.root = root;
  34722. this.xref = xref;
  34723. this._type = 'Names';
  34724. }
  34725. Util.inherit(NameTree, NameOrNumberTree, {});
  34726. return NameTree;
  34727. }();
  34728. var NumberTree = function NumberTreeClosure() {
  34729. function NumberTree(root, xref) {
  34730. this.root = root;
  34731. this.xref = xref;
  34732. this._type = 'Nums';
  34733. }
  34734. Util.inherit(NumberTree, NameOrNumberTree, {});
  34735. return NumberTree;
  34736. }();
  34737. var FileSpec = function FileSpecClosure() {
  34738. function FileSpec(root, xref) {
  34739. if (!root || !isDict(root)) {
  34740. return;
  34741. }
  34742. this.xref = xref;
  34743. this.root = root;
  34744. if (root.has('FS')) {
  34745. this.fs = root.get('FS');
  34746. }
  34747. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  34748. if (root.has('RF')) {
  34749. warn('Related file specifications are not supported');
  34750. }
  34751. this.contentAvailable = true;
  34752. if (!root.has('EF')) {
  34753. this.contentAvailable = false;
  34754. warn('Non-embedded file specifications are not supported');
  34755. }
  34756. }
  34757. function pickPlatformItem(dict) {
  34758. if (dict.has('UF')) {
  34759. return dict.get('UF');
  34760. } else if (dict.has('F')) {
  34761. return dict.get('F');
  34762. } else if (dict.has('Unix')) {
  34763. return dict.get('Unix');
  34764. } else if (dict.has('Mac')) {
  34765. return dict.get('Mac');
  34766. } else if (dict.has('DOS')) {
  34767. return dict.get('DOS');
  34768. }
  34769. return null;
  34770. }
  34771. FileSpec.prototype = {
  34772. get filename() {
  34773. if (!this._filename && this.root) {
  34774. var filename = pickPlatformItem(this.root) || 'unnamed';
  34775. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  34776. }
  34777. return this._filename;
  34778. },
  34779. get content() {
  34780. if (!this.contentAvailable) {
  34781. return null;
  34782. }
  34783. if (!this.contentRef && this.root) {
  34784. this.contentRef = pickPlatformItem(this.root.get('EF'));
  34785. }
  34786. var content = null;
  34787. if (this.contentRef) {
  34788. var xref = this.xref;
  34789. var fileObj = xref.fetchIfRef(this.contentRef);
  34790. if (fileObj && isStream(fileObj)) {
  34791. content = fileObj.getBytes();
  34792. } else {
  34793. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  34794. }
  34795. } else {
  34796. warn('Embedded file specification does not have a content');
  34797. }
  34798. return content;
  34799. },
  34800. get serializable() {
  34801. return {
  34802. filename: this.filename,
  34803. content: this.content
  34804. };
  34805. }
  34806. };
  34807. return FileSpec;
  34808. }();
  34809. var ObjectLoader = function () {
  34810. function mayHaveChildren(value) {
  34811. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  34812. }
  34813. function addChildren(node, nodesToVisit) {
  34814. var value;
  34815. if (isDict(node) || isStream(node)) {
  34816. var map;
  34817. if (isDict(node)) {
  34818. map = node.map;
  34819. } else {
  34820. map = node.dict.map;
  34821. }
  34822. for (var key in map) {
  34823. value = map[key];
  34824. if (mayHaveChildren(value)) {
  34825. nodesToVisit.push(value);
  34826. }
  34827. }
  34828. } else if (isArray(node)) {
  34829. for (var i = 0, ii = node.length; i < ii; i++) {
  34830. value = node[i];
  34831. if (mayHaveChildren(value)) {
  34832. nodesToVisit.push(value);
  34833. }
  34834. }
  34835. }
  34836. }
  34837. function ObjectLoader(obj, keys, xref) {
  34838. this.obj = obj;
  34839. this.keys = keys;
  34840. this.xref = xref;
  34841. this.refSet = null;
  34842. this.capability = null;
  34843. }
  34844. ObjectLoader.prototype = {
  34845. load: function ObjectLoader_load() {
  34846. var keys = this.keys;
  34847. this.capability = createPromiseCapability();
  34848. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  34849. this.capability.resolve();
  34850. return this.capability.promise;
  34851. }
  34852. this.refSet = new RefSet();
  34853. var nodesToVisit = [];
  34854. for (var i = 0; i < keys.length; i++) {
  34855. nodesToVisit.push(this.obj[keys[i]]);
  34856. }
  34857. this._walk(nodesToVisit);
  34858. return this.capability.promise;
  34859. },
  34860. _walk: function ObjectLoader_walk(nodesToVisit) {
  34861. var nodesToRevisit = [];
  34862. var pendingRequests = [];
  34863. while (nodesToVisit.length) {
  34864. var currentNode = nodesToVisit.pop();
  34865. if (isRef(currentNode)) {
  34866. if (this.refSet.has(currentNode)) {
  34867. continue;
  34868. }
  34869. try {
  34870. var ref = currentNode;
  34871. this.refSet.put(ref);
  34872. currentNode = this.xref.fetch(currentNode);
  34873. } catch (e) {
  34874. if (!(e instanceof MissingDataException)) {
  34875. throw e;
  34876. }
  34877. nodesToRevisit.push(currentNode);
  34878. pendingRequests.push({
  34879. begin: e.begin,
  34880. end: e.end
  34881. });
  34882. }
  34883. }
  34884. if (currentNode && currentNode.getBaseStreams) {
  34885. var baseStreams = currentNode.getBaseStreams();
  34886. var foundMissingData = false;
  34887. for (var i = 0; i < baseStreams.length; i++) {
  34888. var stream = baseStreams[i];
  34889. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  34890. foundMissingData = true;
  34891. pendingRequests.push({
  34892. begin: stream.start,
  34893. end: stream.end
  34894. });
  34895. }
  34896. }
  34897. if (foundMissingData) {
  34898. nodesToRevisit.push(currentNode);
  34899. }
  34900. }
  34901. addChildren(currentNode, nodesToVisit);
  34902. }
  34903. if (pendingRequests.length) {
  34904. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  34905. nodesToVisit = nodesToRevisit;
  34906. for (var i = 0; i < nodesToRevisit.length; i++) {
  34907. var node = nodesToRevisit[i];
  34908. if (isRef(node)) {
  34909. this.refSet.remove(node);
  34910. }
  34911. }
  34912. this._walk(nodesToVisit);
  34913. }.bind(this), this.capability.reject);
  34914. return;
  34915. }
  34916. this.refSet = null;
  34917. this.capability.resolve();
  34918. }
  34919. };
  34920. return ObjectLoader;
  34921. }();
  34922. exports.Catalog = Catalog;
  34923. exports.ObjectLoader = ObjectLoader;
  34924. exports.XRef = XRef;
  34925. exports.FileSpec = FileSpec;
  34926. /***/ }),
  34927. /* 21 */
  34928. /***/ (function(module, exports, __w_pdfjs_require__) {
  34929. "use strict";
  34930. var sharedUtil = __w_pdfjs_require__(0);
  34931. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  34932. var getStdFontMap = getLookupTableFactory(function (t) {
  34933. t['ArialNarrow'] = 'Helvetica';
  34934. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  34935. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  34936. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  34937. t['ArialBlack'] = 'Helvetica';
  34938. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  34939. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  34940. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  34941. t['Arial-Black'] = 'Helvetica';
  34942. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  34943. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  34944. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  34945. t['Arial'] = 'Helvetica';
  34946. t['Arial-Bold'] = 'Helvetica-Bold';
  34947. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  34948. t['Arial-Italic'] = 'Helvetica-Oblique';
  34949. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  34950. t['Arial-BoldMT'] = 'Helvetica-Bold';
  34951. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  34952. t['ArialMT'] = 'Helvetica';
  34953. t['Courier-Bold'] = 'Courier-Bold';
  34954. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  34955. t['Courier-Italic'] = 'Courier-Oblique';
  34956. t['CourierNew'] = 'Courier';
  34957. t['CourierNew-Bold'] = 'Courier-Bold';
  34958. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  34959. t['CourierNew-Italic'] = 'Courier-Oblique';
  34960. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  34961. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  34962. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  34963. t['CourierNewPSMT'] = 'Courier';
  34964. t['Helvetica'] = 'Helvetica';
  34965. t['Helvetica-Bold'] = 'Helvetica-Bold';
  34966. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  34967. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  34968. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  34969. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  34970. t['Symbol-Bold'] = 'Symbol';
  34971. t['Symbol-BoldItalic'] = 'Symbol';
  34972. t['Symbol-Italic'] = 'Symbol';
  34973. t['TimesNewRoman'] = 'Times-Roman';
  34974. t['TimesNewRoman-Bold'] = 'Times-Bold';
  34975. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  34976. t['TimesNewRoman-Italic'] = 'Times-Italic';
  34977. t['TimesNewRomanPS'] = 'Times-Roman';
  34978. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  34979. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  34980. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  34981. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  34982. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  34983. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  34984. t['TimesNewRomanPSMT'] = 'Times-Roman';
  34985. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  34986. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  34987. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  34988. });
  34989. var getNonStdFontMap = getLookupTableFactory(function (t) {
  34990. t['CenturyGothic'] = 'Helvetica';
  34991. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  34992. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  34993. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  34994. t['ComicSansMS'] = 'Comic Sans MS';
  34995. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  34996. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  34997. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  34998. t['LucidaConsole'] = 'Courier';
  34999. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35000. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35001. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35002. t['MS-Gothic'] = 'MS Gothic';
  35003. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35004. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35005. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35006. t['MS-Mincho'] = 'MS Mincho';
  35007. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35008. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35009. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35010. t['MS-PGothic'] = 'MS PGothic';
  35011. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35012. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35013. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35014. t['MS-PMincho'] = 'MS PMincho';
  35015. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35016. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35017. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35018. t['NuptialScript'] = 'Times-Italic';
  35019. t['Wingdings'] = 'ZapfDingbats';
  35020. });
  35021. var getSerifFonts = getLookupTableFactory(function (t) {
  35022. t['Adobe Jenson'] = true;
  35023. t['Adobe Text'] = true;
  35024. t['Albertus'] = true;
  35025. t['Aldus'] = true;
  35026. t['Alexandria'] = true;
  35027. t['Algerian'] = true;
  35028. t['American Typewriter'] = true;
  35029. t['Antiqua'] = true;
  35030. t['Apex'] = true;
  35031. t['Arno'] = true;
  35032. t['Aster'] = true;
  35033. t['Aurora'] = true;
  35034. t['Baskerville'] = true;
  35035. t['Bell'] = true;
  35036. t['Bembo'] = true;
  35037. t['Bembo Schoolbook'] = true;
  35038. t['Benguiat'] = true;
  35039. t['Berkeley Old Style'] = true;
  35040. t['Bernhard Modern'] = true;
  35041. t['Berthold City'] = true;
  35042. t['Bodoni'] = true;
  35043. t['Bauer Bodoni'] = true;
  35044. t['Book Antiqua'] = true;
  35045. t['Bookman'] = true;
  35046. t['Bordeaux Roman'] = true;
  35047. t['Californian FB'] = true;
  35048. t['Calisto'] = true;
  35049. t['Calvert'] = true;
  35050. t['Capitals'] = true;
  35051. t['Cambria'] = true;
  35052. t['Cartier'] = true;
  35053. t['Caslon'] = true;
  35054. t['Catull'] = true;
  35055. t['Centaur'] = true;
  35056. t['Century Old Style'] = true;
  35057. t['Century Schoolbook'] = true;
  35058. t['Chaparral'] = true;
  35059. t['Charis SIL'] = true;
  35060. t['Cheltenham'] = true;
  35061. t['Cholla Slab'] = true;
  35062. t['Clarendon'] = true;
  35063. t['Clearface'] = true;
  35064. t['Cochin'] = true;
  35065. t['Colonna'] = true;
  35066. t['Computer Modern'] = true;
  35067. t['Concrete Roman'] = true;
  35068. t['Constantia'] = true;
  35069. t['Cooper Black'] = true;
  35070. t['Corona'] = true;
  35071. t['Ecotype'] = true;
  35072. t['Egyptienne'] = true;
  35073. t['Elephant'] = true;
  35074. t['Excelsior'] = true;
  35075. t['Fairfield'] = true;
  35076. t['FF Scala'] = true;
  35077. t['Folkard'] = true;
  35078. t['Footlight'] = true;
  35079. t['FreeSerif'] = true;
  35080. t['Friz Quadrata'] = true;
  35081. t['Garamond'] = true;
  35082. t['Gentium'] = true;
  35083. t['Georgia'] = true;
  35084. t['Gloucester'] = true;
  35085. t['Goudy Old Style'] = true;
  35086. t['Goudy Schoolbook'] = true;
  35087. t['Goudy Pro Font'] = true;
  35088. t['Granjon'] = true;
  35089. t['Guardian Egyptian'] = true;
  35090. t['Heather'] = true;
  35091. t['Hercules'] = true;
  35092. t['High Tower Text'] = true;
  35093. t['Hiroshige'] = true;
  35094. t['Hoefler Text'] = true;
  35095. t['Humana Serif'] = true;
  35096. t['Imprint'] = true;
  35097. t['Ionic No. 5'] = true;
  35098. t['Janson'] = true;
  35099. t['Joanna'] = true;
  35100. t['Korinna'] = true;
  35101. t['Lexicon'] = true;
  35102. t['Liberation Serif'] = true;
  35103. t['Linux Libertine'] = true;
  35104. t['Literaturnaya'] = true;
  35105. t['Lucida'] = true;
  35106. t['Lucida Bright'] = true;
  35107. t['Melior'] = true;
  35108. t['Memphis'] = true;
  35109. t['Miller'] = true;
  35110. t['Minion'] = true;
  35111. t['Modern'] = true;
  35112. t['Mona Lisa'] = true;
  35113. t['Mrs Eaves'] = true;
  35114. t['MS Serif'] = true;
  35115. t['Museo Slab'] = true;
  35116. t['New York'] = true;
  35117. t['Nimbus Roman'] = true;
  35118. t['NPS Rawlinson Roadway'] = true;
  35119. t['NuptialScript'] = true;
  35120. t['Palatino'] = true;
  35121. t['Perpetua'] = true;
  35122. t['Plantin'] = true;
  35123. t['Plantin Schoolbook'] = true;
  35124. t['Playbill'] = true;
  35125. t['Poor Richard'] = true;
  35126. t['Rawlinson Roadway'] = true;
  35127. t['Renault'] = true;
  35128. t['Requiem'] = true;
  35129. t['Rockwell'] = true;
  35130. t['Roman'] = true;
  35131. t['Rotis Serif'] = true;
  35132. t['Sabon'] = true;
  35133. t['Scala'] = true;
  35134. t['Seagull'] = true;
  35135. t['Sistina'] = true;
  35136. t['Souvenir'] = true;
  35137. t['STIX'] = true;
  35138. t['Stone Informal'] = true;
  35139. t['Stone Serif'] = true;
  35140. t['Sylfaen'] = true;
  35141. t['Times'] = true;
  35142. t['Trajan'] = true;
  35143. t['Trinité'] = true;
  35144. t['Trump Mediaeval'] = true;
  35145. t['Utopia'] = true;
  35146. t['Vale Type'] = true;
  35147. t['Bitstream Vera'] = true;
  35148. t['Vera Serif'] = true;
  35149. t['Versailles'] = true;
  35150. t['Wanted'] = true;
  35151. t['Weiss'] = true;
  35152. t['Wide Latin'] = true;
  35153. t['Windsor'] = true;
  35154. t['XITS'] = true;
  35155. });
  35156. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35157. t['Dingbats'] = true;
  35158. t['Symbol'] = true;
  35159. t['ZapfDingbats'] = true;
  35160. });
  35161. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35162. t[2] = 10;
  35163. t[3] = 32;
  35164. t[4] = 33;
  35165. t[5] = 34;
  35166. t[6] = 35;
  35167. t[7] = 36;
  35168. t[8] = 37;
  35169. t[9] = 38;
  35170. t[10] = 39;
  35171. t[11] = 40;
  35172. t[12] = 41;
  35173. t[13] = 42;
  35174. t[14] = 43;
  35175. t[15] = 44;
  35176. t[16] = 45;
  35177. t[17] = 46;
  35178. t[18] = 47;
  35179. t[19] = 48;
  35180. t[20] = 49;
  35181. t[21] = 50;
  35182. t[22] = 51;
  35183. t[23] = 52;
  35184. t[24] = 53;
  35185. t[25] = 54;
  35186. t[26] = 55;
  35187. t[27] = 56;
  35188. t[28] = 57;
  35189. t[29] = 58;
  35190. t[30] = 894;
  35191. t[31] = 60;
  35192. t[32] = 61;
  35193. t[33] = 62;
  35194. t[34] = 63;
  35195. t[35] = 64;
  35196. t[36] = 65;
  35197. t[37] = 66;
  35198. t[38] = 67;
  35199. t[39] = 68;
  35200. t[40] = 69;
  35201. t[41] = 70;
  35202. t[42] = 71;
  35203. t[43] = 72;
  35204. t[44] = 73;
  35205. t[45] = 74;
  35206. t[46] = 75;
  35207. t[47] = 76;
  35208. t[48] = 77;
  35209. t[49] = 78;
  35210. t[50] = 79;
  35211. t[51] = 80;
  35212. t[52] = 81;
  35213. t[53] = 82;
  35214. t[54] = 83;
  35215. t[55] = 84;
  35216. t[56] = 85;
  35217. t[57] = 86;
  35218. t[58] = 87;
  35219. t[59] = 88;
  35220. t[60] = 89;
  35221. t[61] = 90;
  35222. t[62] = 91;
  35223. t[63] = 92;
  35224. t[64] = 93;
  35225. t[65] = 94;
  35226. t[66] = 95;
  35227. t[67] = 96;
  35228. t[68] = 97;
  35229. t[69] = 98;
  35230. t[70] = 99;
  35231. t[71] = 100;
  35232. t[72] = 101;
  35233. t[73] = 102;
  35234. t[74] = 103;
  35235. t[75] = 104;
  35236. t[76] = 105;
  35237. t[77] = 106;
  35238. t[78] = 107;
  35239. t[79] = 108;
  35240. t[80] = 109;
  35241. t[81] = 110;
  35242. t[82] = 111;
  35243. t[83] = 112;
  35244. t[84] = 113;
  35245. t[85] = 114;
  35246. t[86] = 115;
  35247. t[87] = 116;
  35248. t[88] = 117;
  35249. t[89] = 118;
  35250. t[90] = 119;
  35251. t[91] = 120;
  35252. t[92] = 121;
  35253. t[93] = 122;
  35254. t[94] = 123;
  35255. t[95] = 124;
  35256. t[96] = 125;
  35257. t[97] = 126;
  35258. t[98] = 196;
  35259. t[99] = 197;
  35260. t[100] = 199;
  35261. t[101] = 201;
  35262. t[102] = 209;
  35263. t[103] = 214;
  35264. t[104] = 220;
  35265. t[105] = 225;
  35266. t[106] = 224;
  35267. t[107] = 226;
  35268. t[108] = 228;
  35269. t[109] = 227;
  35270. t[110] = 229;
  35271. t[111] = 231;
  35272. t[112] = 233;
  35273. t[113] = 232;
  35274. t[114] = 234;
  35275. t[115] = 235;
  35276. t[116] = 237;
  35277. t[117] = 236;
  35278. t[118] = 238;
  35279. t[119] = 239;
  35280. t[120] = 241;
  35281. t[121] = 243;
  35282. t[122] = 242;
  35283. t[123] = 244;
  35284. t[124] = 246;
  35285. t[125] = 245;
  35286. t[126] = 250;
  35287. t[127] = 249;
  35288. t[128] = 251;
  35289. t[129] = 252;
  35290. t[130] = 8224;
  35291. t[131] = 176;
  35292. t[132] = 162;
  35293. t[133] = 163;
  35294. t[134] = 167;
  35295. t[135] = 8226;
  35296. t[136] = 182;
  35297. t[137] = 223;
  35298. t[138] = 174;
  35299. t[139] = 169;
  35300. t[140] = 8482;
  35301. t[141] = 180;
  35302. t[142] = 168;
  35303. t[143] = 8800;
  35304. t[144] = 198;
  35305. t[145] = 216;
  35306. t[146] = 8734;
  35307. t[147] = 177;
  35308. t[148] = 8804;
  35309. t[149] = 8805;
  35310. t[150] = 165;
  35311. t[151] = 181;
  35312. t[152] = 8706;
  35313. t[153] = 8721;
  35314. t[154] = 8719;
  35315. t[156] = 8747;
  35316. t[157] = 170;
  35317. t[158] = 186;
  35318. t[159] = 8486;
  35319. t[160] = 230;
  35320. t[161] = 248;
  35321. t[162] = 191;
  35322. t[163] = 161;
  35323. t[164] = 172;
  35324. t[165] = 8730;
  35325. t[166] = 402;
  35326. t[167] = 8776;
  35327. t[168] = 8710;
  35328. t[169] = 171;
  35329. t[170] = 187;
  35330. t[171] = 8230;
  35331. t[210] = 218;
  35332. t[223] = 711;
  35333. t[224] = 321;
  35334. t[225] = 322;
  35335. t[227] = 353;
  35336. t[229] = 382;
  35337. t[234] = 253;
  35338. t[252] = 263;
  35339. t[253] = 268;
  35340. t[254] = 269;
  35341. t[258] = 258;
  35342. t[260] = 260;
  35343. t[261] = 261;
  35344. t[265] = 280;
  35345. t[266] = 281;
  35346. t[268] = 283;
  35347. t[269] = 313;
  35348. t[275] = 323;
  35349. t[276] = 324;
  35350. t[278] = 328;
  35351. t[284] = 345;
  35352. t[285] = 346;
  35353. t[286] = 347;
  35354. t[292] = 367;
  35355. t[295] = 377;
  35356. t[296] = 378;
  35357. t[298] = 380;
  35358. t[305] = 963;
  35359. t[306] = 964;
  35360. t[307] = 966;
  35361. t[308] = 8215;
  35362. t[309] = 8252;
  35363. t[310] = 8319;
  35364. t[311] = 8359;
  35365. t[312] = 8592;
  35366. t[313] = 8593;
  35367. t[337] = 9552;
  35368. t[493] = 1039;
  35369. t[494] = 1040;
  35370. t[705] = 1524;
  35371. t[706] = 8362;
  35372. t[710] = 64288;
  35373. t[711] = 64298;
  35374. t[759] = 1617;
  35375. t[761] = 1776;
  35376. t[763] = 1778;
  35377. t[775] = 1652;
  35378. t[777] = 1764;
  35379. t[778] = 1780;
  35380. t[779] = 1781;
  35381. t[780] = 1782;
  35382. t[782] = 771;
  35383. t[783] = 64726;
  35384. t[786] = 8363;
  35385. t[788] = 8532;
  35386. t[790] = 768;
  35387. t[791] = 769;
  35388. t[792] = 768;
  35389. t[795] = 803;
  35390. t[797] = 64336;
  35391. t[798] = 64337;
  35392. t[799] = 64342;
  35393. t[800] = 64343;
  35394. t[801] = 64344;
  35395. t[802] = 64345;
  35396. t[803] = 64362;
  35397. t[804] = 64363;
  35398. t[805] = 64364;
  35399. t[2424] = 7821;
  35400. t[2425] = 7822;
  35401. t[2426] = 7823;
  35402. t[2427] = 7824;
  35403. t[2428] = 7825;
  35404. t[2429] = 7826;
  35405. t[2430] = 7827;
  35406. t[2433] = 7682;
  35407. t[2678] = 8045;
  35408. t[2679] = 8046;
  35409. t[2830] = 1552;
  35410. t[2838] = 686;
  35411. t[2840] = 751;
  35412. t[2842] = 753;
  35413. t[2843] = 754;
  35414. t[2844] = 755;
  35415. t[2846] = 757;
  35416. t[2856] = 767;
  35417. t[2857] = 848;
  35418. t[2858] = 849;
  35419. t[2862] = 853;
  35420. t[2863] = 854;
  35421. t[2864] = 855;
  35422. t[2865] = 861;
  35423. t[2866] = 862;
  35424. t[2906] = 7460;
  35425. t[2908] = 7462;
  35426. t[2909] = 7463;
  35427. t[2910] = 7464;
  35428. t[2912] = 7466;
  35429. t[2913] = 7467;
  35430. t[2914] = 7468;
  35431. t[2916] = 7470;
  35432. t[2917] = 7471;
  35433. t[2918] = 7472;
  35434. t[2920] = 7474;
  35435. t[2921] = 7475;
  35436. t[2922] = 7476;
  35437. t[2924] = 7478;
  35438. t[2925] = 7479;
  35439. t[2926] = 7480;
  35440. t[2928] = 7482;
  35441. t[2929] = 7483;
  35442. t[2930] = 7484;
  35443. t[2932] = 7486;
  35444. t[2933] = 7487;
  35445. t[2934] = 7488;
  35446. t[2936] = 7490;
  35447. t[2937] = 7491;
  35448. t[2938] = 7492;
  35449. t[2940] = 7494;
  35450. t[2941] = 7495;
  35451. t[2942] = 7496;
  35452. t[2944] = 7498;
  35453. t[2946] = 7500;
  35454. t[2948] = 7502;
  35455. t[2950] = 7504;
  35456. t[2951] = 7505;
  35457. t[2952] = 7506;
  35458. t[2954] = 7508;
  35459. t[2955] = 7509;
  35460. t[2956] = 7510;
  35461. t[2958] = 7512;
  35462. t[2959] = 7513;
  35463. t[2960] = 7514;
  35464. t[2962] = 7516;
  35465. t[2963] = 7517;
  35466. t[2964] = 7518;
  35467. t[2966] = 7520;
  35468. t[2967] = 7521;
  35469. t[2968] = 7522;
  35470. t[2970] = 7524;
  35471. t[2971] = 7525;
  35472. t[2972] = 7526;
  35473. t[2974] = 7528;
  35474. t[2975] = 7529;
  35475. t[2976] = 7530;
  35476. t[2978] = 1537;
  35477. t[2979] = 1538;
  35478. t[2980] = 1539;
  35479. t[2982] = 1549;
  35480. t[2983] = 1551;
  35481. t[2984] = 1552;
  35482. t[2986] = 1554;
  35483. t[2987] = 1555;
  35484. t[2988] = 1556;
  35485. t[2990] = 1623;
  35486. t[2991] = 1624;
  35487. t[2995] = 1775;
  35488. t[2999] = 1791;
  35489. t[3002] = 64290;
  35490. t[3003] = 64291;
  35491. t[3004] = 64292;
  35492. t[3006] = 64294;
  35493. t[3007] = 64295;
  35494. t[3008] = 64296;
  35495. t[3011] = 1900;
  35496. t[3014] = 8223;
  35497. t[3015] = 8244;
  35498. t[3017] = 7532;
  35499. t[3018] = 7533;
  35500. t[3019] = 7534;
  35501. t[3075] = 7590;
  35502. t[3076] = 7591;
  35503. t[3079] = 7594;
  35504. t[3080] = 7595;
  35505. t[3083] = 7598;
  35506. t[3084] = 7599;
  35507. t[3087] = 7602;
  35508. t[3088] = 7603;
  35509. t[3091] = 7606;
  35510. t[3092] = 7607;
  35511. t[3095] = 7610;
  35512. t[3096] = 7611;
  35513. t[3099] = 7614;
  35514. t[3100] = 7615;
  35515. t[3103] = 7618;
  35516. t[3104] = 7619;
  35517. t[3107] = 8337;
  35518. t[3108] = 8338;
  35519. t[3116] = 1884;
  35520. t[3119] = 1885;
  35521. t[3120] = 1885;
  35522. t[3123] = 1886;
  35523. t[3124] = 1886;
  35524. t[3127] = 1887;
  35525. t[3128] = 1887;
  35526. t[3131] = 1888;
  35527. t[3132] = 1888;
  35528. t[3135] = 1889;
  35529. t[3136] = 1889;
  35530. t[3139] = 1890;
  35531. t[3140] = 1890;
  35532. t[3143] = 1891;
  35533. t[3144] = 1891;
  35534. t[3147] = 1892;
  35535. t[3148] = 1892;
  35536. t[3153] = 580;
  35537. t[3154] = 581;
  35538. t[3157] = 584;
  35539. t[3158] = 585;
  35540. t[3161] = 588;
  35541. t[3162] = 589;
  35542. t[3165] = 891;
  35543. t[3166] = 892;
  35544. t[3169] = 1274;
  35545. t[3170] = 1275;
  35546. t[3173] = 1278;
  35547. t[3174] = 1279;
  35548. t[3181] = 7622;
  35549. t[3182] = 7623;
  35550. t[3282] = 11799;
  35551. t[3316] = 578;
  35552. t[3379] = 42785;
  35553. t[3393] = 1159;
  35554. t[3416] = 8377;
  35555. });
  35556. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  35557. t[227] = 322;
  35558. t[264] = 261;
  35559. t[291] = 346;
  35560. });
  35561. exports.getStdFontMap = getStdFontMap;
  35562. exports.getNonStdFontMap = getNonStdFontMap;
  35563. exports.getSerifFonts = getSerifFonts;
  35564. exports.getSymbolsFonts = getSymbolsFonts;
  35565. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  35566. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  35567. /***/ }),
  35568. /* 22 */
  35569. /***/ (function(module, exports, __w_pdfjs_require__) {
  35570. "use strict";
  35571. var sharedUtil = __w_pdfjs_require__(0);
  35572. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35573. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  35574. t[63721] = 0x00A9;
  35575. t[63193] = 0x00A9;
  35576. t[63720] = 0x00AE;
  35577. t[63194] = 0x00AE;
  35578. t[63722] = 0x2122;
  35579. t[63195] = 0x2122;
  35580. t[63729] = 0x23A7;
  35581. t[63730] = 0x23A8;
  35582. t[63731] = 0x23A9;
  35583. t[63740] = 0x23AB;
  35584. t[63741] = 0x23AC;
  35585. t[63742] = 0x23AD;
  35586. t[63726] = 0x23A1;
  35587. t[63727] = 0x23A2;
  35588. t[63728] = 0x23A3;
  35589. t[63737] = 0x23A4;
  35590. t[63738] = 0x23A5;
  35591. t[63739] = 0x23A6;
  35592. t[63723] = 0x239B;
  35593. t[63724] = 0x239C;
  35594. t[63725] = 0x239D;
  35595. t[63734] = 0x239E;
  35596. t[63735] = 0x239F;
  35597. t[63736] = 0x23A0;
  35598. });
  35599. function mapSpecialUnicodeValues(code) {
  35600. if (code >= 0xFFF0 && code <= 0xFFFF) {
  35601. return 0;
  35602. } else if (code >= 0xF600 && code <= 0xF8FF) {
  35603. return getSpecialPUASymbols()[code] || code;
  35604. }
  35605. return code;
  35606. }
  35607. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  35608. var unicode = glyphsUnicodeMap[name];
  35609. if (unicode !== undefined) {
  35610. return unicode;
  35611. }
  35612. if (!name) {
  35613. return -1;
  35614. }
  35615. if (name[0] === 'u') {
  35616. var nameLen = name.length, hexStr;
  35617. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  35618. hexStr = name.substr(3);
  35619. } else if (nameLen >= 5 && nameLen <= 7) {
  35620. hexStr = name.substr(1);
  35621. } else {
  35622. return -1;
  35623. }
  35624. if (hexStr === hexStr.toUpperCase()) {
  35625. unicode = parseInt(hexStr, 16);
  35626. if (unicode >= 0) {
  35627. return unicode;
  35628. }
  35629. }
  35630. }
  35631. return -1;
  35632. }
  35633. var UnicodeRanges = [
  35634. {
  35635. 'begin': 0x0000,
  35636. 'end': 0x007F
  35637. },
  35638. {
  35639. 'begin': 0x0080,
  35640. 'end': 0x00FF
  35641. },
  35642. {
  35643. 'begin': 0x0100,
  35644. 'end': 0x017F
  35645. },
  35646. {
  35647. 'begin': 0x0180,
  35648. 'end': 0x024F
  35649. },
  35650. {
  35651. 'begin': 0x0250,
  35652. 'end': 0x02AF
  35653. },
  35654. {
  35655. 'begin': 0x02B0,
  35656. 'end': 0x02FF
  35657. },
  35658. {
  35659. 'begin': 0x0300,
  35660. 'end': 0x036F
  35661. },
  35662. {
  35663. 'begin': 0x0370,
  35664. 'end': 0x03FF
  35665. },
  35666. {
  35667. 'begin': 0x2C80,
  35668. 'end': 0x2CFF
  35669. },
  35670. {
  35671. 'begin': 0x0400,
  35672. 'end': 0x04FF
  35673. },
  35674. {
  35675. 'begin': 0x0530,
  35676. 'end': 0x058F
  35677. },
  35678. {
  35679. 'begin': 0x0590,
  35680. 'end': 0x05FF
  35681. },
  35682. {
  35683. 'begin': 0xA500,
  35684. 'end': 0xA63F
  35685. },
  35686. {
  35687. 'begin': 0x0600,
  35688. 'end': 0x06FF
  35689. },
  35690. {
  35691. 'begin': 0x07C0,
  35692. 'end': 0x07FF
  35693. },
  35694. {
  35695. 'begin': 0x0900,
  35696. 'end': 0x097F
  35697. },
  35698. {
  35699. 'begin': 0x0980,
  35700. 'end': 0x09FF
  35701. },
  35702. {
  35703. 'begin': 0x0A00,
  35704. 'end': 0x0A7F
  35705. },
  35706. {
  35707. 'begin': 0x0A80,
  35708. 'end': 0x0AFF
  35709. },
  35710. {
  35711. 'begin': 0x0B00,
  35712. 'end': 0x0B7F
  35713. },
  35714. {
  35715. 'begin': 0x0B80,
  35716. 'end': 0x0BFF
  35717. },
  35718. {
  35719. 'begin': 0x0C00,
  35720. 'end': 0x0C7F
  35721. },
  35722. {
  35723. 'begin': 0x0C80,
  35724. 'end': 0x0CFF
  35725. },
  35726. {
  35727. 'begin': 0x0D00,
  35728. 'end': 0x0D7F
  35729. },
  35730. {
  35731. 'begin': 0x0E00,
  35732. 'end': 0x0E7F
  35733. },
  35734. {
  35735. 'begin': 0x0E80,
  35736. 'end': 0x0EFF
  35737. },
  35738. {
  35739. 'begin': 0x10A0,
  35740. 'end': 0x10FF
  35741. },
  35742. {
  35743. 'begin': 0x1B00,
  35744. 'end': 0x1B7F
  35745. },
  35746. {
  35747. 'begin': 0x1100,
  35748. 'end': 0x11FF
  35749. },
  35750. {
  35751. 'begin': 0x1E00,
  35752. 'end': 0x1EFF
  35753. },
  35754. {
  35755. 'begin': 0x1F00,
  35756. 'end': 0x1FFF
  35757. },
  35758. {
  35759. 'begin': 0x2000,
  35760. 'end': 0x206F
  35761. },
  35762. {
  35763. 'begin': 0x2070,
  35764. 'end': 0x209F
  35765. },
  35766. {
  35767. 'begin': 0x20A0,
  35768. 'end': 0x20CF
  35769. },
  35770. {
  35771. 'begin': 0x20D0,
  35772. 'end': 0x20FF
  35773. },
  35774. {
  35775. 'begin': 0x2100,
  35776. 'end': 0x214F
  35777. },
  35778. {
  35779. 'begin': 0x2150,
  35780. 'end': 0x218F
  35781. },
  35782. {
  35783. 'begin': 0x2190,
  35784. 'end': 0x21FF
  35785. },
  35786. {
  35787. 'begin': 0x2200,
  35788. 'end': 0x22FF
  35789. },
  35790. {
  35791. 'begin': 0x2300,
  35792. 'end': 0x23FF
  35793. },
  35794. {
  35795. 'begin': 0x2400,
  35796. 'end': 0x243F
  35797. },
  35798. {
  35799. 'begin': 0x2440,
  35800. 'end': 0x245F
  35801. },
  35802. {
  35803. 'begin': 0x2460,
  35804. 'end': 0x24FF
  35805. },
  35806. {
  35807. 'begin': 0x2500,
  35808. 'end': 0x257F
  35809. },
  35810. {
  35811. 'begin': 0x2580,
  35812. 'end': 0x259F
  35813. },
  35814. {
  35815. 'begin': 0x25A0,
  35816. 'end': 0x25FF
  35817. },
  35818. {
  35819. 'begin': 0x2600,
  35820. 'end': 0x26FF
  35821. },
  35822. {
  35823. 'begin': 0x2700,
  35824. 'end': 0x27BF
  35825. },
  35826. {
  35827. 'begin': 0x3000,
  35828. 'end': 0x303F
  35829. },
  35830. {
  35831. 'begin': 0x3040,
  35832. 'end': 0x309F
  35833. },
  35834. {
  35835. 'begin': 0x30A0,
  35836. 'end': 0x30FF
  35837. },
  35838. {
  35839. 'begin': 0x3100,
  35840. 'end': 0x312F
  35841. },
  35842. {
  35843. 'begin': 0x3130,
  35844. 'end': 0x318F
  35845. },
  35846. {
  35847. 'begin': 0xA840,
  35848. 'end': 0xA87F
  35849. },
  35850. {
  35851. 'begin': 0x3200,
  35852. 'end': 0x32FF
  35853. },
  35854. {
  35855. 'begin': 0x3300,
  35856. 'end': 0x33FF
  35857. },
  35858. {
  35859. 'begin': 0xAC00,
  35860. 'end': 0xD7AF
  35861. },
  35862. {
  35863. 'begin': 0xD800,
  35864. 'end': 0xDFFF
  35865. },
  35866. {
  35867. 'begin': 0x10900,
  35868. 'end': 0x1091F
  35869. },
  35870. {
  35871. 'begin': 0x4E00,
  35872. 'end': 0x9FFF
  35873. },
  35874. {
  35875. 'begin': 0xE000,
  35876. 'end': 0xF8FF
  35877. },
  35878. {
  35879. 'begin': 0x31C0,
  35880. 'end': 0x31EF
  35881. },
  35882. {
  35883. 'begin': 0xFB00,
  35884. 'end': 0xFB4F
  35885. },
  35886. {
  35887. 'begin': 0xFB50,
  35888. 'end': 0xFDFF
  35889. },
  35890. {
  35891. 'begin': 0xFE20,
  35892. 'end': 0xFE2F
  35893. },
  35894. {
  35895. 'begin': 0xFE10,
  35896. 'end': 0xFE1F
  35897. },
  35898. {
  35899. 'begin': 0xFE50,
  35900. 'end': 0xFE6F
  35901. },
  35902. {
  35903. 'begin': 0xFE70,
  35904. 'end': 0xFEFF
  35905. },
  35906. {
  35907. 'begin': 0xFF00,
  35908. 'end': 0xFFEF
  35909. },
  35910. {
  35911. 'begin': 0xFFF0,
  35912. 'end': 0xFFFF
  35913. },
  35914. {
  35915. 'begin': 0x0F00,
  35916. 'end': 0x0FFF
  35917. },
  35918. {
  35919. 'begin': 0x0700,
  35920. 'end': 0x074F
  35921. },
  35922. {
  35923. 'begin': 0x0780,
  35924. 'end': 0x07BF
  35925. },
  35926. {
  35927. 'begin': 0x0D80,
  35928. 'end': 0x0DFF
  35929. },
  35930. {
  35931. 'begin': 0x1000,
  35932. 'end': 0x109F
  35933. },
  35934. {
  35935. 'begin': 0x1200,
  35936. 'end': 0x137F
  35937. },
  35938. {
  35939. 'begin': 0x13A0,
  35940. 'end': 0x13FF
  35941. },
  35942. {
  35943. 'begin': 0x1400,
  35944. 'end': 0x167F
  35945. },
  35946. {
  35947. 'begin': 0x1680,
  35948. 'end': 0x169F
  35949. },
  35950. {
  35951. 'begin': 0x16A0,
  35952. 'end': 0x16FF
  35953. },
  35954. {
  35955. 'begin': 0x1780,
  35956. 'end': 0x17FF
  35957. },
  35958. {
  35959. 'begin': 0x1800,
  35960. 'end': 0x18AF
  35961. },
  35962. {
  35963. 'begin': 0x2800,
  35964. 'end': 0x28FF
  35965. },
  35966. {
  35967. 'begin': 0xA000,
  35968. 'end': 0xA48F
  35969. },
  35970. {
  35971. 'begin': 0x1700,
  35972. 'end': 0x171F
  35973. },
  35974. {
  35975. 'begin': 0x10300,
  35976. 'end': 0x1032F
  35977. },
  35978. {
  35979. 'begin': 0x10330,
  35980. 'end': 0x1034F
  35981. },
  35982. {
  35983. 'begin': 0x10400,
  35984. 'end': 0x1044F
  35985. },
  35986. {
  35987. 'begin': 0x1D000,
  35988. 'end': 0x1D0FF
  35989. },
  35990. {
  35991. 'begin': 0x1D400,
  35992. 'end': 0x1D7FF
  35993. },
  35994. {
  35995. 'begin': 0xFF000,
  35996. 'end': 0xFFFFD
  35997. },
  35998. {
  35999. 'begin': 0xFE00,
  36000. 'end': 0xFE0F
  36001. },
  36002. {
  36003. 'begin': 0xE0000,
  36004. 'end': 0xE007F
  36005. },
  36006. {
  36007. 'begin': 0x1900,
  36008. 'end': 0x194F
  36009. },
  36010. {
  36011. 'begin': 0x1950,
  36012. 'end': 0x197F
  36013. },
  36014. {
  36015. 'begin': 0x1980,
  36016. 'end': 0x19DF
  36017. },
  36018. {
  36019. 'begin': 0x1A00,
  36020. 'end': 0x1A1F
  36021. },
  36022. {
  36023. 'begin': 0x2C00,
  36024. 'end': 0x2C5F
  36025. },
  36026. {
  36027. 'begin': 0x2D30,
  36028. 'end': 0x2D7F
  36029. },
  36030. {
  36031. 'begin': 0x4DC0,
  36032. 'end': 0x4DFF
  36033. },
  36034. {
  36035. 'begin': 0xA800,
  36036. 'end': 0xA82F
  36037. },
  36038. {
  36039. 'begin': 0x10000,
  36040. 'end': 0x1007F
  36041. },
  36042. {
  36043. 'begin': 0x10140,
  36044. 'end': 0x1018F
  36045. },
  36046. {
  36047. 'begin': 0x10380,
  36048. 'end': 0x1039F
  36049. },
  36050. {
  36051. 'begin': 0x103A0,
  36052. 'end': 0x103DF
  36053. },
  36054. {
  36055. 'begin': 0x10450,
  36056. 'end': 0x1047F
  36057. },
  36058. {
  36059. 'begin': 0x10480,
  36060. 'end': 0x104AF
  36061. },
  36062. {
  36063. 'begin': 0x10800,
  36064. 'end': 0x1083F
  36065. },
  36066. {
  36067. 'begin': 0x10A00,
  36068. 'end': 0x10A5F
  36069. },
  36070. {
  36071. 'begin': 0x1D300,
  36072. 'end': 0x1D35F
  36073. },
  36074. {
  36075. 'begin': 0x12000,
  36076. 'end': 0x123FF
  36077. },
  36078. {
  36079. 'begin': 0x1D360,
  36080. 'end': 0x1D37F
  36081. },
  36082. {
  36083. 'begin': 0x1B80,
  36084. 'end': 0x1BBF
  36085. },
  36086. {
  36087. 'begin': 0x1C00,
  36088. 'end': 0x1C4F
  36089. },
  36090. {
  36091. 'begin': 0x1C50,
  36092. 'end': 0x1C7F
  36093. },
  36094. {
  36095. 'begin': 0xA880,
  36096. 'end': 0xA8DF
  36097. },
  36098. {
  36099. 'begin': 0xA900,
  36100. 'end': 0xA92F
  36101. },
  36102. {
  36103. 'begin': 0xA930,
  36104. 'end': 0xA95F
  36105. },
  36106. {
  36107. 'begin': 0xAA00,
  36108. 'end': 0xAA5F
  36109. },
  36110. {
  36111. 'begin': 0x10190,
  36112. 'end': 0x101CF
  36113. },
  36114. {
  36115. 'begin': 0x101D0,
  36116. 'end': 0x101FF
  36117. },
  36118. {
  36119. 'begin': 0x102A0,
  36120. 'end': 0x102DF
  36121. },
  36122. {
  36123. 'begin': 0x1F030,
  36124. 'end': 0x1F09F
  36125. }
  36126. ];
  36127. function getUnicodeRangeFor(value) {
  36128. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36129. var range = UnicodeRanges[i];
  36130. if (value >= range.begin && value < range.end) {
  36131. return i;
  36132. }
  36133. }
  36134. return -1;
  36135. }
  36136. function isRTLRangeFor(value) {
  36137. var range = UnicodeRanges[13];
  36138. if (value >= range.begin && value < range.end) {
  36139. return true;
  36140. }
  36141. range = UnicodeRanges[11];
  36142. if (value >= range.begin && value < range.end) {
  36143. return true;
  36144. }
  36145. return false;
  36146. }
  36147. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36148. t['\u00A8'] = '\u0020\u0308';
  36149. t['\u00AF'] = '\u0020\u0304';
  36150. t['\u00B4'] = '\u0020\u0301';
  36151. t['\u00B5'] = '\u03BC';
  36152. t['\u00B8'] = '\u0020\u0327';
  36153. t['\u0132'] = '\u0049\u004A';
  36154. t['\u0133'] = '\u0069\u006A';
  36155. t['\u013F'] = '\u004C\u00B7';
  36156. t['\u0140'] = '\u006C\u00B7';
  36157. t['\u0149'] = '\u02BC\u006E';
  36158. t['\u017F'] = '\u0073';
  36159. t['\u01C4'] = '\u0044\u017D';
  36160. t['\u01C5'] = '\u0044\u017E';
  36161. t['\u01C6'] = '\u0064\u017E';
  36162. t['\u01C7'] = '\u004C\u004A';
  36163. t['\u01C8'] = '\u004C\u006A';
  36164. t['\u01C9'] = '\u006C\u006A';
  36165. t['\u01CA'] = '\u004E\u004A';
  36166. t['\u01CB'] = '\u004E\u006A';
  36167. t['\u01CC'] = '\u006E\u006A';
  36168. t['\u01F1'] = '\u0044\u005A';
  36169. t['\u01F2'] = '\u0044\u007A';
  36170. t['\u01F3'] = '\u0064\u007A';
  36171. t['\u02D8'] = '\u0020\u0306';
  36172. t['\u02D9'] = '\u0020\u0307';
  36173. t['\u02DA'] = '\u0020\u030A';
  36174. t['\u02DB'] = '\u0020\u0328';
  36175. t['\u02DC'] = '\u0020\u0303';
  36176. t['\u02DD'] = '\u0020\u030B';
  36177. t['\u037A'] = '\u0020\u0345';
  36178. t['\u0384'] = '\u0020\u0301';
  36179. t['\u03D0'] = '\u03B2';
  36180. t['\u03D1'] = '\u03B8';
  36181. t['\u03D2'] = '\u03A5';
  36182. t['\u03D5'] = '\u03C6';
  36183. t['\u03D6'] = '\u03C0';
  36184. t['\u03F0'] = '\u03BA';
  36185. t['\u03F1'] = '\u03C1';
  36186. t['\u03F2'] = '\u03C2';
  36187. t['\u03F4'] = '\u0398';
  36188. t['\u03F5'] = '\u03B5';
  36189. t['\u03F9'] = '\u03A3';
  36190. t['\u0587'] = '\u0565\u0582';
  36191. t['\u0675'] = '\u0627\u0674';
  36192. t['\u0676'] = '\u0648\u0674';
  36193. t['\u0677'] = '\u06C7\u0674';
  36194. t['\u0678'] = '\u064A\u0674';
  36195. t['\u0E33'] = '\u0E4D\u0E32';
  36196. t['\u0EB3'] = '\u0ECD\u0EB2';
  36197. t['\u0EDC'] = '\u0EAB\u0E99';
  36198. t['\u0EDD'] = '\u0EAB\u0EA1';
  36199. t['\u0F77'] = '\u0FB2\u0F81';
  36200. t['\u0F79'] = '\u0FB3\u0F81';
  36201. t['\u1E9A'] = '\u0061\u02BE';
  36202. t['\u1FBD'] = '\u0020\u0313';
  36203. t['\u1FBF'] = '\u0020\u0313';
  36204. t['\u1FC0'] = '\u0020\u0342';
  36205. t['\u1FFE'] = '\u0020\u0314';
  36206. t['\u2002'] = '\u0020';
  36207. t['\u2003'] = '\u0020';
  36208. t['\u2004'] = '\u0020';
  36209. t['\u2005'] = '\u0020';
  36210. t['\u2006'] = '\u0020';
  36211. t['\u2008'] = '\u0020';
  36212. t['\u2009'] = '\u0020';
  36213. t['\u200A'] = '\u0020';
  36214. t['\u2017'] = '\u0020\u0333';
  36215. t['\u2024'] = '\u002E';
  36216. t['\u2025'] = '\u002E\u002E';
  36217. t['\u2026'] = '\u002E\u002E\u002E';
  36218. t['\u2033'] = '\u2032\u2032';
  36219. t['\u2034'] = '\u2032\u2032\u2032';
  36220. t['\u2036'] = '\u2035\u2035';
  36221. t['\u2037'] = '\u2035\u2035\u2035';
  36222. t['\u203C'] = '\u0021\u0021';
  36223. t['\u203E'] = '\u0020\u0305';
  36224. t['\u2047'] = '\u003F\u003F';
  36225. t['\u2048'] = '\u003F\u0021';
  36226. t['\u2049'] = '\u0021\u003F';
  36227. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36228. t['\u205F'] = '\u0020';
  36229. t['\u20A8'] = '\u0052\u0073';
  36230. t['\u2100'] = '\u0061\u002F\u0063';
  36231. t['\u2101'] = '\u0061\u002F\u0073';
  36232. t['\u2103'] = '\u00B0\u0043';
  36233. t['\u2105'] = '\u0063\u002F\u006F';
  36234. t['\u2106'] = '\u0063\u002F\u0075';
  36235. t['\u2107'] = '\u0190';
  36236. t['\u2109'] = '\u00B0\u0046';
  36237. t['\u2116'] = '\u004E\u006F';
  36238. t['\u2121'] = '\u0054\u0045\u004C';
  36239. t['\u2135'] = '\u05D0';
  36240. t['\u2136'] = '\u05D1';
  36241. t['\u2137'] = '\u05D2';
  36242. t['\u2138'] = '\u05D3';
  36243. t['\u213B'] = '\u0046\u0041\u0058';
  36244. t['\u2160'] = '\u0049';
  36245. t['\u2161'] = '\u0049\u0049';
  36246. t['\u2162'] = '\u0049\u0049\u0049';
  36247. t['\u2163'] = '\u0049\u0056';
  36248. t['\u2164'] = '\u0056';
  36249. t['\u2165'] = '\u0056\u0049';
  36250. t['\u2166'] = '\u0056\u0049\u0049';
  36251. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36252. t['\u2168'] = '\u0049\u0058';
  36253. t['\u2169'] = '\u0058';
  36254. t['\u216A'] = '\u0058\u0049';
  36255. t['\u216B'] = '\u0058\u0049\u0049';
  36256. t['\u216C'] = '\u004C';
  36257. t['\u216D'] = '\u0043';
  36258. t['\u216E'] = '\u0044';
  36259. t['\u216F'] = '\u004D';
  36260. t['\u2170'] = '\u0069';
  36261. t['\u2171'] = '\u0069\u0069';
  36262. t['\u2172'] = '\u0069\u0069\u0069';
  36263. t['\u2173'] = '\u0069\u0076';
  36264. t['\u2174'] = '\u0076';
  36265. t['\u2175'] = '\u0076\u0069';
  36266. t['\u2176'] = '\u0076\u0069\u0069';
  36267. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36268. t['\u2178'] = '\u0069\u0078';
  36269. t['\u2179'] = '\u0078';
  36270. t['\u217A'] = '\u0078\u0069';
  36271. t['\u217B'] = '\u0078\u0069\u0069';
  36272. t['\u217C'] = '\u006C';
  36273. t['\u217D'] = '\u0063';
  36274. t['\u217E'] = '\u0064';
  36275. t['\u217F'] = '\u006D';
  36276. t['\u222C'] = '\u222B\u222B';
  36277. t['\u222D'] = '\u222B\u222B\u222B';
  36278. t['\u222F'] = '\u222E\u222E';
  36279. t['\u2230'] = '\u222E\u222E\u222E';
  36280. t['\u2474'] = '\u0028\u0031\u0029';
  36281. t['\u2475'] = '\u0028\u0032\u0029';
  36282. t['\u2476'] = '\u0028\u0033\u0029';
  36283. t['\u2477'] = '\u0028\u0034\u0029';
  36284. t['\u2478'] = '\u0028\u0035\u0029';
  36285. t['\u2479'] = '\u0028\u0036\u0029';
  36286. t['\u247A'] = '\u0028\u0037\u0029';
  36287. t['\u247B'] = '\u0028\u0038\u0029';
  36288. t['\u247C'] = '\u0028\u0039\u0029';
  36289. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36290. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36291. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36292. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36293. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36294. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36295. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36296. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36297. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36298. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36299. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  36300. t['\u2488'] = '\u0031\u002E';
  36301. t['\u2489'] = '\u0032\u002E';
  36302. t['\u248A'] = '\u0033\u002E';
  36303. t['\u248B'] = '\u0034\u002E';
  36304. t['\u248C'] = '\u0035\u002E';
  36305. t['\u248D'] = '\u0036\u002E';
  36306. t['\u248E'] = '\u0037\u002E';
  36307. t['\u248F'] = '\u0038\u002E';
  36308. t['\u2490'] = '\u0039\u002E';
  36309. t['\u2491'] = '\u0031\u0030\u002E';
  36310. t['\u2492'] = '\u0031\u0031\u002E';
  36311. t['\u2493'] = '\u0031\u0032\u002E';
  36312. t['\u2494'] = '\u0031\u0033\u002E';
  36313. t['\u2495'] = '\u0031\u0034\u002E';
  36314. t['\u2496'] = '\u0031\u0035\u002E';
  36315. t['\u2497'] = '\u0031\u0036\u002E';
  36316. t['\u2498'] = '\u0031\u0037\u002E';
  36317. t['\u2499'] = '\u0031\u0038\u002E';
  36318. t['\u249A'] = '\u0031\u0039\u002E';
  36319. t['\u249B'] = '\u0032\u0030\u002E';
  36320. t['\u249C'] = '\u0028\u0061\u0029';
  36321. t['\u249D'] = '\u0028\u0062\u0029';
  36322. t['\u249E'] = '\u0028\u0063\u0029';
  36323. t['\u249F'] = '\u0028\u0064\u0029';
  36324. t['\u24A0'] = '\u0028\u0065\u0029';
  36325. t['\u24A1'] = '\u0028\u0066\u0029';
  36326. t['\u24A2'] = '\u0028\u0067\u0029';
  36327. t['\u24A3'] = '\u0028\u0068\u0029';
  36328. t['\u24A4'] = '\u0028\u0069\u0029';
  36329. t['\u24A5'] = '\u0028\u006A\u0029';
  36330. t['\u24A6'] = '\u0028\u006B\u0029';
  36331. t['\u24A7'] = '\u0028\u006C\u0029';
  36332. t['\u24A8'] = '\u0028\u006D\u0029';
  36333. t['\u24A9'] = '\u0028\u006E\u0029';
  36334. t['\u24AA'] = '\u0028\u006F\u0029';
  36335. t['\u24AB'] = '\u0028\u0070\u0029';
  36336. t['\u24AC'] = '\u0028\u0071\u0029';
  36337. t['\u24AD'] = '\u0028\u0072\u0029';
  36338. t['\u24AE'] = '\u0028\u0073\u0029';
  36339. t['\u24AF'] = '\u0028\u0074\u0029';
  36340. t['\u24B0'] = '\u0028\u0075\u0029';
  36341. t['\u24B1'] = '\u0028\u0076\u0029';
  36342. t['\u24B2'] = '\u0028\u0077\u0029';
  36343. t['\u24B3'] = '\u0028\u0078\u0029';
  36344. t['\u24B4'] = '\u0028\u0079\u0029';
  36345. t['\u24B5'] = '\u0028\u007A\u0029';
  36346. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  36347. t['\u2A74'] = '\u003A\u003A\u003D';
  36348. t['\u2A75'] = '\u003D\u003D';
  36349. t['\u2A76'] = '\u003D\u003D\u003D';
  36350. t['\u2E9F'] = '\u6BCD';
  36351. t['\u2EF3'] = '\u9F9F';
  36352. t['\u2F00'] = '\u4E00';
  36353. t['\u2F01'] = '\u4E28';
  36354. t['\u2F02'] = '\u4E36';
  36355. t['\u2F03'] = '\u4E3F';
  36356. t['\u2F04'] = '\u4E59';
  36357. t['\u2F05'] = '\u4E85';
  36358. t['\u2F06'] = '\u4E8C';
  36359. t['\u2F07'] = '\u4EA0';
  36360. t['\u2F08'] = '\u4EBA';
  36361. t['\u2F09'] = '\u513F';
  36362. t['\u2F0A'] = '\u5165';
  36363. t['\u2F0B'] = '\u516B';
  36364. t['\u2F0C'] = '\u5182';
  36365. t['\u2F0D'] = '\u5196';
  36366. t['\u2F0E'] = '\u51AB';
  36367. t['\u2F0F'] = '\u51E0';
  36368. t['\u2F10'] = '\u51F5';
  36369. t['\u2F11'] = '\u5200';
  36370. t['\u2F12'] = '\u529B';
  36371. t['\u2F13'] = '\u52F9';
  36372. t['\u2F14'] = '\u5315';
  36373. t['\u2F15'] = '\u531A';
  36374. t['\u2F16'] = '\u5338';
  36375. t['\u2F17'] = '\u5341';
  36376. t['\u2F18'] = '\u535C';
  36377. t['\u2F19'] = '\u5369';
  36378. t['\u2F1A'] = '\u5382';
  36379. t['\u2F1B'] = '\u53B6';
  36380. t['\u2F1C'] = '\u53C8';
  36381. t['\u2F1D'] = '\u53E3';
  36382. t['\u2F1E'] = '\u56D7';
  36383. t['\u2F1F'] = '\u571F';
  36384. t['\u2F20'] = '\u58EB';
  36385. t['\u2F21'] = '\u5902';
  36386. t['\u2F22'] = '\u590A';
  36387. t['\u2F23'] = '\u5915';
  36388. t['\u2F24'] = '\u5927';
  36389. t['\u2F25'] = '\u5973';
  36390. t['\u2F26'] = '\u5B50';
  36391. t['\u2F27'] = '\u5B80';
  36392. t['\u2F28'] = '\u5BF8';
  36393. t['\u2F29'] = '\u5C0F';
  36394. t['\u2F2A'] = '\u5C22';
  36395. t['\u2F2B'] = '\u5C38';
  36396. t['\u2F2C'] = '\u5C6E';
  36397. t['\u2F2D'] = '\u5C71';
  36398. t['\u2F2E'] = '\u5DDB';
  36399. t['\u2F2F'] = '\u5DE5';
  36400. t['\u2F30'] = '\u5DF1';
  36401. t['\u2F31'] = '\u5DFE';
  36402. t['\u2F32'] = '\u5E72';
  36403. t['\u2F33'] = '\u5E7A';
  36404. t['\u2F34'] = '\u5E7F';
  36405. t['\u2F35'] = '\u5EF4';
  36406. t['\u2F36'] = '\u5EFE';
  36407. t['\u2F37'] = '\u5F0B';
  36408. t['\u2F38'] = '\u5F13';
  36409. t['\u2F39'] = '\u5F50';
  36410. t['\u2F3A'] = '\u5F61';
  36411. t['\u2F3B'] = '\u5F73';
  36412. t['\u2F3C'] = '\u5FC3';
  36413. t['\u2F3D'] = '\u6208';
  36414. t['\u2F3E'] = '\u6236';
  36415. t['\u2F3F'] = '\u624B';
  36416. t['\u2F40'] = '\u652F';
  36417. t['\u2F41'] = '\u6534';
  36418. t['\u2F42'] = '\u6587';
  36419. t['\u2F43'] = '\u6597';
  36420. t['\u2F44'] = '\u65A4';
  36421. t['\u2F45'] = '\u65B9';
  36422. t['\u2F46'] = '\u65E0';
  36423. t['\u2F47'] = '\u65E5';
  36424. t['\u2F48'] = '\u66F0';
  36425. t['\u2F49'] = '\u6708';
  36426. t['\u2F4A'] = '\u6728';
  36427. t['\u2F4B'] = '\u6B20';
  36428. t['\u2F4C'] = '\u6B62';
  36429. t['\u2F4D'] = '\u6B79';
  36430. t['\u2F4E'] = '\u6BB3';
  36431. t['\u2F4F'] = '\u6BCB';
  36432. t['\u2F50'] = '\u6BD4';
  36433. t['\u2F51'] = '\u6BDB';
  36434. t['\u2F52'] = '\u6C0F';
  36435. t['\u2F53'] = '\u6C14';
  36436. t['\u2F54'] = '\u6C34';
  36437. t['\u2F55'] = '\u706B';
  36438. t['\u2F56'] = '\u722A';
  36439. t['\u2F57'] = '\u7236';
  36440. t['\u2F58'] = '\u723B';
  36441. t['\u2F59'] = '\u723F';
  36442. t['\u2F5A'] = '\u7247';
  36443. t['\u2F5B'] = '\u7259';
  36444. t['\u2F5C'] = '\u725B';
  36445. t['\u2F5D'] = '\u72AC';
  36446. t['\u2F5E'] = '\u7384';
  36447. t['\u2F5F'] = '\u7389';
  36448. t['\u2F60'] = '\u74DC';
  36449. t['\u2F61'] = '\u74E6';
  36450. t['\u2F62'] = '\u7518';
  36451. t['\u2F63'] = '\u751F';
  36452. t['\u2F64'] = '\u7528';
  36453. t['\u2F65'] = '\u7530';
  36454. t['\u2F66'] = '\u758B';
  36455. t['\u2F67'] = '\u7592';
  36456. t['\u2F68'] = '\u7676';
  36457. t['\u2F69'] = '\u767D';
  36458. t['\u2F6A'] = '\u76AE';
  36459. t['\u2F6B'] = '\u76BF';
  36460. t['\u2F6C'] = '\u76EE';
  36461. t['\u2F6D'] = '\u77DB';
  36462. t['\u2F6E'] = '\u77E2';
  36463. t['\u2F6F'] = '\u77F3';
  36464. t['\u2F70'] = '\u793A';
  36465. t['\u2F71'] = '\u79B8';
  36466. t['\u2F72'] = '\u79BE';
  36467. t['\u2F73'] = '\u7A74';
  36468. t['\u2F74'] = '\u7ACB';
  36469. t['\u2F75'] = '\u7AF9';
  36470. t['\u2F76'] = '\u7C73';
  36471. t['\u2F77'] = '\u7CF8';
  36472. t['\u2F78'] = '\u7F36';
  36473. t['\u2F79'] = '\u7F51';
  36474. t['\u2F7A'] = '\u7F8A';
  36475. t['\u2F7B'] = '\u7FBD';
  36476. t['\u2F7C'] = '\u8001';
  36477. t['\u2F7D'] = '\u800C';
  36478. t['\u2F7E'] = '\u8012';
  36479. t['\u2F7F'] = '\u8033';
  36480. t['\u2F80'] = '\u807F';
  36481. t['\u2F81'] = '\u8089';
  36482. t['\u2F82'] = '\u81E3';
  36483. t['\u2F83'] = '\u81EA';
  36484. t['\u2F84'] = '\u81F3';
  36485. t['\u2F85'] = '\u81FC';
  36486. t['\u2F86'] = '\u820C';
  36487. t['\u2F87'] = '\u821B';
  36488. t['\u2F88'] = '\u821F';
  36489. t['\u2F89'] = '\u826E';
  36490. t['\u2F8A'] = '\u8272';
  36491. t['\u2F8B'] = '\u8278';
  36492. t['\u2F8C'] = '\u864D';
  36493. t['\u2F8D'] = '\u866B';
  36494. t['\u2F8E'] = '\u8840';
  36495. t['\u2F8F'] = '\u884C';
  36496. t['\u2F90'] = '\u8863';
  36497. t['\u2F91'] = '\u897E';
  36498. t['\u2F92'] = '\u898B';
  36499. t['\u2F93'] = '\u89D2';
  36500. t['\u2F94'] = '\u8A00';
  36501. t['\u2F95'] = '\u8C37';
  36502. t['\u2F96'] = '\u8C46';
  36503. t['\u2F97'] = '\u8C55';
  36504. t['\u2F98'] = '\u8C78';
  36505. t['\u2F99'] = '\u8C9D';
  36506. t['\u2F9A'] = '\u8D64';
  36507. t['\u2F9B'] = '\u8D70';
  36508. t['\u2F9C'] = '\u8DB3';
  36509. t['\u2F9D'] = '\u8EAB';
  36510. t['\u2F9E'] = '\u8ECA';
  36511. t['\u2F9F'] = '\u8F9B';
  36512. t['\u2FA0'] = '\u8FB0';
  36513. t['\u2FA1'] = '\u8FB5';
  36514. t['\u2FA2'] = '\u9091';
  36515. t['\u2FA3'] = '\u9149';
  36516. t['\u2FA4'] = '\u91C6';
  36517. t['\u2FA5'] = '\u91CC';
  36518. t['\u2FA6'] = '\u91D1';
  36519. t['\u2FA7'] = '\u9577';
  36520. t['\u2FA8'] = '\u9580';
  36521. t['\u2FA9'] = '\u961C';
  36522. t['\u2FAA'] = '\u96B6';
  36523. t['\u2FAB'] = '\u96B9';
  36524. t['\u2FAC'] = '\u96E8';
  36525. t['\u2FAD'] = '\u9751';
  36526. t['\u2FAE'] = '\u975E';
  36527. t['\u2FAF'] = '\u9762';
  36528. t['\u2FB0'] = '\u9769';
  36529. t['\u2FB1'] = '\u97CB';
  36530. t['\u2FB2'] = '\u97ED';
  36531. t['\u2FB3'] = '\u97F3';
  36532. t['\u2FB4'] = '\u9801';
  36533. t['\u2FB5'] = '\u98A8';
  36534. t['\u2FB6'] = '\u98DB';
  36535. t['\u2FB7'] = '\u98DF';
  36536. t['\u2FB8'] = '\u9996';
  36537. t['\u2FB9'] = '\u9999';
  36538. t['\u2FBA'] = '\u99AC';
  36539. t['\u2FBB'] = '\u9AA8';
  36540. t['\u2FBC'] = '\u9AD8';
  36541. t['\u2FBD'] = '\u9ADF';
  36542. t['\u2FBE'] = '\u9B25';
  36543. t['\u2FBF'] = '\u9B2F';
  36544. t['\u2FC0'] = '\u9B32';
  36545. t['\u2FC1'] = '\u9B3C';
  36546. t['\u2FC2'] = '\u9B5A';
  36547. t['\u2FC3'] = '\u9CE5';
  36548. t['\u2FC4'] = '\u9E75';
  36549. t['\u2FC5'] = '\u9E7F';
  36550. t['\u2FC6'] = '\u9EA5';
  36551. t['\u2FC7'] = '\u9EBB';
  36552. t['\u2FC8'] = '\u9EC3';
  36553. t['\u2FC9'] = '\u9ECD';
  36554. t['\u2FCA'] = '\u9ED1';
  36555. t['\u2FCB'] = '\u9EF9';
  36556. t['\u2FCC'] = '\u9EFD';
  36557. t['\u2FCD'] = '\u9F0E';
  36558. t['\u2FCE'] = '\u9F13';
  36559. t['\u2FCF'] = '\u9F20';
  36560. t['\u2FD0'] = '\u9F3B';
  36561. t['\u2FD1'] = '\u9F4A';
  36562. t['\u2FD2'] = '\u9F52';
  36563. t['\u2FD3'] = '\u9F8D';
  36564. t['\u2FD4'] = '\u9F9C';
  36565. t['\u2FD5'] = '\u9FA0';
  36566. t['\u3036'] = '\u3012';
  36567. t['\u3038'] = '\u5341';
  36568. t['\u3039'] = '\u5344';
  36569. t['\u303A'] = '\u5345';
  36570. t['\u309B'] = '\u0020\u3099';
  36571. t['\u309C'] = '\u0020\u309A';
  36572. t['\u3131'] = '\u1100';
  36573. t['\u3132'] = '\u1101';
  36574. t['\u3133'] = '\u11AA';
  36575. t['\u3134'] = '\u1102';
  36576. t['\u3135'] = '\u11AC';
  36577. t['\u3136'] = '\u11AD';
  36578. t['\u3137'] = '\u1103';
  36579. t['\u3138'] = '\u1104';
  36580. t['\u3139'] = '\u1105';
  36581. t['\u313A'] = '\u11B0';
  36582. t['\u313B'] = '\u11B1';
  36583. t['\u313C'] = '\u11B2';
  36584. t['\u313D'] = '\u11B3';
  36585. t['\u313E'] = '\u11B4';
  36586. t['\u313F'] = '\u11B5';
  36587. t['\u3140'] = '\u111A';
  36588. t['\u3141'] = '\u1106';
  36589. t['\u3142'] = '\u1107';
  36590. t['\u3143'] = '\u1108';
  36591. t['\u3144'] = '\u1121';
  36592. t['\u3145'] = '\u1109';
  36593. t['\u3146'] = '\u110A';
  36594. t['\u3147'] = '\u110B';
  36595. t['\u3148'] = '\u110C';
  36596. t['\u3149'] = '\u110D';
  36597. t['\u314A'] = '\u110E';
  36598. t['\u314B'] = '\u110F';
  36599. t['\u314C'] = '\u1110';
  36600. t['\u314D'] = '\u1111';
  36601. t['\u314E'] = '\u1112';
  36602. t['\u314F'] = '\u1161';
  36603. t['\u3150'] = '\u1162';
  36604. t['\u3151'] = '\u1163';
  36605. t['\u3152'] = '\u1164';
  36606. t['\u3153'] = '\u1165';
  36607. t['\u3154'] = '\u1166';
  36608. t['\u3155'] = '\u1167';
  36609. t['\u3156'] = '\u1168';
  36610. t['\u3157'] = '\u1169';
  36611. t['\u3158'] = '\u116A';
  36612. t['\u3159'] = '\u116B';
  36613. t['\u315A'] = '\u116C';
  36614. t['\u315B'] = '\u116D';
  36615. t['\u315C'] = '\u116E';
  36616. t['\u315D'] = '\u116F';
  36617. t['\u315E'] = '\u1170';
  36618. t['\u315F'] = '\u1171';
  36619. t['\u3160'] = '\u1172';
  36620. t['\u3161'] = '\u1173';
  36621. t['\u3162'] = '\u1174';
  36622. t['\u3163'] = '\u1175';
  36623. t['\u3164'] = '\u1160';
  36624. t['\u3165'] = '\u1114';
  36625. t['\u3166'] = '\u1115';
  36626. t['\u3167'] = '\u11C7';
  36627. t['\u3168'] = '\u11C8';
  36628. t['\u3169'] = '\u11CC';
  36629. t['\u316A'] = '\u11CE';
  36630. t['\u316B'] = '\u11D3';
  36631. t['\u316C'] = '\u11D7';
  36632. t['\u316D'] = '\u11D9';
  36633. t['\u316E'] = '\u111C';
  36634. t['\u316F'] = '\u11DD';
  36635. t['\u3170'] = '\u11DF';
  36636. t['\u3171'] = '\u111D';
  36637. t['\u3172'] = '\u111E';
  36638. t['\u3173'] = '\u1120';
  36639. t['\u3174'] = '\u1122';
  36640. t['\u3175'] = '\u1123';
  36641. t['\u3176'] = '\u1127';
  36642. t['\u3177'] = '\u1129';
  36643. t['\u3178'] = '\u112B';
  36644. t['\u3179'] = '\u112C';
  36645. t['\u317A'] = '\u112D';
  36646. t['\u317B'] = '\u112E';
  36647. t['\u317C'] = '\u112F';
  36648. t['\u317D'] = '\u1132';
  36649. t['\u317E'] = '\u1136';
  36650. t['\u317F'] = '\u1140';
  36651. t['\u3180'] = '\u1147';
  36652. t['\u3181'] = '\u114C';
  36653. t['\u3182'] = '\u11F1';
  36654. t['\u3183'] = '\u11F2';
  36655. t['\u3184'] = '\u1157';
  36656. t['\u3185'] = '\u1158';
  36657. t['\u3186'] = '\u1159';
  36658. t['\u3187'] = '\u1184';
  36659. t['\u3188'] = '\u1185';
  36660. t['\u3189'] = '\u1188';
  36661. t['\u318A'] = '\u1191';
  36662. t['\u318B'] = '\u1192';
  36663. t['\u318C'] = '\u1194';
  36664. t['\u318D'] = '\u119E';
  36665. t['\u318E'] = '\u11A1';
  36666. t['\u3200'] = '\u0028\u1100\u0029';
  36667. t['\u3201'] = '\u0028\u1102\u0029';
  36668. t['\u3202'] = '\u0028\u1103\u0029';
  36669. t['\u3203'] = '\u0028\u1105\u0029';
  36670. t['\u3204'] = '\u0028\u1106\u0029';
  36671. t['\u3205'] = '\u0028\u1107\u0029';
  36672. t['\u3206'] = '\u0028\u1109\u0029';
  36673. t['\u3207'] = '\u0028\u110B\u0029';
  36674. t['\u3208'] = '\u0028\u110C\u0029';
  36675. t['\u3209'] = '\u0028\u110E\u0029';
  36676. t['\u320A'] = '\u0028\u110F\u0029';
  36677. t['\u320B'] = '\u0028\u1110\u0029';
  36678. t['\u320C'] = '\u0028\u1111\u0029';
  36679. t['\u320D'] = '\u0028\u1112\u0029';
  36680. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  36681. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  36682. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  36683. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  36684. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  36685. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  36686. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  36687. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  36688. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  36689. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  36690. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  36691. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  36692. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  36693. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  36694. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  36695. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  36696. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  36697. t['\u3220'] = '\u0028\u4E00\u0029';
  36698. t['\u3221'] = '\u0028\u4E8C\u0029';
  36699. t['\u3222'] = '\u0028\u4E09\u0029';
  36700. t['\u3223'] = '\u0028\u56DB\u0029';
  36701. t['\u3224'] = '\u0028\u4E94\u0029';
  36702. t['\u3225'] = '\u0028\u516D\u0029';
  36703. t['\u3226'] = '\u0028\u4E03\u0029';
  36704. t['\u3227'] = '\u0028\u516B\u0029';
  36705. t['\u3228'] = '\u0028\u4E5D\u0029';
  36706. t['\u3229'] = '\u0028\u5341\u0029';
  36707. t['\u322A'] = '\u0028\u6708\u0029';
  36708. t['\u322B'] = '\u0028\u706B\u0029';
  36709. t['\u322C'] = '\u0028\u6C34\u0029';
  36710. t['\u322D'] = '\u0028\u6728\u0029';
  36711. t['\u322E'] = '\u0028\u91D1\u0029';
  36712. t['\u322F'] = '\u0028\u571F\u0029';
  36713. t['\u3230'] = '\u0028\u65E5\u0029';
  36714. t['\u3231'] = '\u0028\u682A\u0029';
  36715. t['\u3232'] = '\u0028\u6709\u0029';
  36716. t['\u3233'] = '\u0028\u793E\u0029';
  36717. t['\u3234'] = '\u0028\u540D\u0029';
  36718. t['\u3235'] = '\u0028\u7279\u0029';
  36719. t['\u3236'] = '\u0028\u8CA1\u0029';
  36720. t['\u3237'] = '\u0028\u795D\u0029';
  36721. t['\u3238'] = '\u0028\u52B4\u0029';
  36722. t['\u3239'] = '\u0028\u4EE3\u0029';
  36723. t['\u323A'] = '\u0028\u547C\u0029';
  36724. t['\u323B'] = '\u0028\u5B66\u0029';
  36725. t['\u323C'] = '\u0028\u76E3\u0029';
  36726. t['\u323D'] = '\u0028\u4F01\u0029';
  36727. t['\u323E'] = '\u0028\u8CC7\u0029';
  36728. t['\u323F'] = '\u0028\u5354\u0029';
  36729. t['\u3240'] = '\u0028\u796D\u0029';
  36730. t['\u3241'] = '\u0028\u4F11\u0029';
  36731. t['\u3242'] = '\u0028\u81EA\u0029';
  36732. t['\u3243'] = '\u0028\u81F3\u0029';
  36733. t['\u32C0'] = '\u0031\u6708';
  36734. t['\u32C1'] = '\u0032\u6708';
  36735. t['\u32C2'] = '\u0033\u6708';
  36736. t['\u32C3'] = '\u0034\u6708';
  36737. t['\u32C4'] = '\u0035\u6708';
  36738. t['\u32C5'] = '\u0036\u6708';
  36739. t['\u32C6'] = '\u0037\u6708';
  36740. t['\u32C7'] = '\u0038\u6708';
  36741. t['\u32C8'] = '\u0039\u6708';
  36742. t['\u32C9'] = '\u0031\u0030\u6708';
  36743. t['\u32CA'] = '\u0031\u0031\u6708';
  36744. t['\u32CB'] = '\u0031\u0032\u6708';
  36745. t['\u3358'] = '\u0030\u70B9';
  36746. t['\u3359'] = '\u0031\u70B9';
  36747. t['\u335A'] = '\u0032\u70B9';
  36748. t['\u335B'] = '\u0033\u70B9';
  36749. t['\u335C'] = '\u0034\u70B9';
  36750. t['\u335D'] = '\u0035\u70B9';
  36751. t['\u335E'] = '\u0036\u70B9';
  36752. t['\u335F'] = '\u0037\u70B9';
  36753. t['\u3360'] = '\u0038\u70B9';
  36754. t['\u3361'] = '\u0039\u70B9';
  36755. t['\u3362'] = '\u0031\u0030\u70B9';
  36756. t['\u3363'] = '\u0031\u0031\u70B9';
  36757. t['\u3364'] = '\u0031\u0032\u70B9';
  36758. t['\u3365'] = '\u0031\u0033\u70B9';
  36759. t['\u3366'] = '\u0031\u0034\u70B9';
  36760. t['\u3367'] = '\u0031\u0035\u70B9';
  36761. t['\u3368'] = '\u0031\u0036\u70B9';
  36762. t['\u3369'] = '\u0031\u0037\u70B9';
  36763. t['\u336A'] = '\u0031\u0038\u70B9';
  36764. t['\u336B'] = '\u0031\u0039\u70B9';
  36765. t['\u336C'] = '\u0032\u0030\u70B9';
  36766. t['\u336D'] = '\u0032\u0031\u70B9';
  36767. t['\u336E'] = '\u0032\u0032\u70B9';
  36768. t['\u336F'] = '\u0032\u0033\u70B9';
  36769. t['\u3370'] = '\u0032\u0034\u70B9';
  36770. t['\u33E0'] = '\u0031\u65E5';
  36771. t['\u33E1'] = '\u0032\u65E5';
  36772. t['\u33E2'] = '\u0033\u65E5';
  36773. t['\u33E3'] = '\u0034\u65E5';
  36774. t['\u33E4'] = '\u0035\u65E5';
  36775. t['\u33E5'] = '\u0036\u65E5';
  36776. t['\u33E6'] = '\u0037\u65E5';
  36777. t['\u33E7'] = '\u0038\u65E5';
  36778. t['\u33E8'] = '\u0039\u65E5';
  36779. t['\u33E9'] = '\u0031\u0030\u65E5';
  36780. t['\u33EA'] = '\u0031\u0031\u65E5';
  36781. t['\u33EB'] = '\u0031\u0032\u65E5';
  36782. t['\u33EC'] = '\u0031\u0033\u65E5';
  36783. t['\u33ED'] = '\u0031\u0034\u65E5';
  36784. t['\u33EE'] = '\u0031\u0035\u65E5';
  36785. t['\u33EF'] = '\u0031\u0036\u65E5';
  36786. t['\u33F0'] = '\u0031\u0037\u65E5';
  36787. t['\u33F1'] = '\u0031\u0038\u65E5';
  36788. t['\u33F2'] = '\u0031\u0039\u65E5';
  36789. t['\u33F3'] = '\u0032\u0030\u65E5';
  36790. t['\u33F4'] = '\u0032\u0031\u65E5';
  36791. t['\u33F5'] = '\u0032\u0032\u65E5';
  36792. t['\u33F6'] = '\u0032\u0033\u65E5';
  36793. t['\u33F7'] = '\u0032\u0034\u65E5';
  36794. t['\u33F8'] = '\u0032\u0035\u65E5';
  36795. t['\u33F9'] = '\u0032\u0036\u65E5';
  36796. t['\u33FA'] = '\u0032\u0037\u65E5';
  36797. t['\u33FB'] = '\u0032\u0038\u65E5';
  36798. t['\u33FC'] = '\u0032\u0039\u65E5';
  36799. t['\u33FD'] = '\u0033\u0030\u65E5';
  36800. t['\u33FE'] = '\u0033\u0031\u65E5';
  36801. t['\uFB00'] = '\u0066\u0066';
  36802. t['\uFB01'] = '\u0066\u0069';
  36803. t['\uFB02'] = '\u0066\u006C';
  36804. t['\uFB03'] = '\u0066\u0066\u0069';
  36805. t['\uFB04'] = '\u0066\u0066\u006C';
  36806. t['\uFB05'] = '\u017F\u0074';
  36807. t['\uFB06'] = '\u0073\u0074';
  36808. t['\uFB13'] = '\u0574\u0576';
  36809. t['\uFB14'] = '\u0574\u0565';
  36810. t['\uFB15'] = '\u0574\u056B';
  36811. t['\uFB16'] = '\u057E\u0576';
  36812. t['\uFB17'] = '\u0574\u056D';
  36813. t['\uFB4F'] = '\u05D0\u05DC';
  36814. t['\uFB50'] = '\u0671';
  36815. t['\uFB51'] = '\u0671';
  36816. t['\uFB52'] = '\u067B';
  36817. t['\uFB53'] = '\u067B';
  36818. t['\uFB54'] = '\u067B';
  36819. t['\uFB55'] = '\u067B';
  36820. t['\uFB56'] = '\u067E';
  36821. t['\uFB57'] = '\u067E';
  36822. t['\uFB58'] = '\u067E';
  36823. t['\uFB59'] = '\u067E';
  36824. t['\uFB5A'] = '\u0680';
  36825. t['\uFB5B'] = '\u0680';
  36826. t['\uFB5C'] = '\u0680';
  36827. t['\uFB5D'] = '\u0680';
  36828. t['\uFB5E'] = '\u067A';
  36829. t['\uFB5F'] = '\u067A';
  36830. t['\uFB60'] = '\u067A';
  36831. t['\uFB61'] = '\u067A';
  36832. t['\uFB62'] = '\u067F';
  36833. t['\uFB63'] = '\u067F';
  36834. t['\uFB64'] = '\u067F';
  36835. t['\uFB65'] = '\u067F';
  36836. t['\uFB66'] = '\u0679';
  36837. t['\uFB67'] = '\u0679';
  36838. t['\uFB68'] = '\u0679';
  36839. t['\uFB69'] = '\u0679';
  36840. t['\uFB6A'] = '\u06A4';
  36841. t['\uFB6B'] = '\u06A4';
  36842. t['\uFB6C'] = '\u06A4';
  36843. t['\uFB6D'] = '\u06A4';
  36844. t['\uFB6E'] = '\u06A6';
  36845. t['\uFB6F'] = '\u06A6';
  36846. t['\uFB70'] = '\u06A6';
  36847. t['\uFB71'] = '\u06A6';
  36848. t['\uFB72'] = '\u0684';
  36849. t['\uFB73'] = '\u0684';
  36850. t['\uFB74'] = '\u0684';
  36851. t['\uFB75'] = '\u0684';
  36852. t['\uFB76'] = '\u0683';
  36853. t['\uFB77'] = '\u0683';
  36854. t['\uFB78'] = '\u0683';
  36855. t['\uFB79'] = '\u0683';
  36856. t['\uFB7A'] = '\u0686';
  36857. t['\uFB7B'] = '\u0686';
  36858. t['\uFB7C'] = '\u0686';
  36859. t['\uFB7D'] = '\u0686';
  36860. t['\uFB7E'] = '\u0687';
  36861. t['\uFB7F'] = '\u0687';
  36862. t['\uFB80'] = '\u0687';
  36863. t['\uFB81'] = '\u0687';
  36864. t['\uFB82'] = '\u068D';
  36865. t['\uFB83'] = '\u068D';
  36866. t['\uFB84'] = '\u068C';
  36867. t['\uFB85'] = '\u068C';
  36868. t['\uFB86'] = '\u068E';
  36869. t['\uFB87'] = '\u068E';
  36870. t['\uFB88'] = '\u0688';
  36871. t['\uFB89'] = '\u0688';
  36872. t['\uFB8A'] = '\u0698';
  36873. t['\uFB8B'] = '\u0698';
  36874. t['\uFB8C'] = '\u0691';
  36875. t['\uFB8D'] = '\u0691';
  36876. t['\uFB8E'] = '\u06A9';
  36877. t['\uFB8F'] = '\u06A9';
  36878. t['\uFB90'] = '\u06A9';
  36879. t['\uFB91'] = '\u06A9';
  36880. t['\uFB92'] = '\u06AF';
  36881. t['\uFB93'] = '\u06AF';
  36882. t['\uFB94'] = '\u06AF';
  36883. t['\uFB95'] = '\u06AF';
  36884. t['\uFB96'] = '\u06B3';
  36885. t['\uFB97'] = '\u06B3';
  36886. t['\uFB98'] = '\u06B3';
  36887. t['\uFB99'] = '\u06B3';
  36888. t['\uFB9A'] = '\u06B1';
  36889. t['\uFB9B'] = '\u06B1';
  36890. t['\uFB9C'] = '\u06B1';
  36891. t['\uFB9D'] = '\u06B1';
  36892. t['\uFB9E'] = '\u06BA';
  36893. t['\uFB9F'] = '\u06BA';
  36894. t['\uFBA0'] = '\u06BB';
  36895. t['\uFBA1'] = '\u06BB';
  36896. t['\uFBA2'] = '\u06BB';
  36897. t['\uFBA3'] = '\u06BB';
  36898. t['\uFBA4'] = '\u06C0';
  36899. t['\uFBA5'] = '\u06C0';
  36900. t['\uFBA6'] = '\u06C1';
  36901. t['\uFBA7'] = '\u06C1';
  36902. t['\uFBA8'] = '\u06C1';
  36903. t['\uFBA9'] = '\u06C1';
  36904. t['\uFBAA'] = '\u06BE';
  36905. t['\uFBAB'] = '\u06BE';
  36906. t['\uFBAC'] = '\u06BE';
  36907. t['\uFBAD'] = '\u06BE';
  36908. t['\uFBAE'] = '\u06D2';
  36909. t['\uFBAF'] = '\u06D2';
  36910. t['\uFBB0'] = '\u06D3';
  36911. t['\uFBB1'] = '\u06D3';
  36912. t['\uFBD3'] = '\u06AD';
  36913. t['\uFBD4'] = '\u06AD';
  36914. t['\uFBD5'] = '\u06AD';
  36915. t['\uFBD6'] = '\u06AD';
  36916. t['\uFBD7'] = '\u06C7';
  36917. t['\uFBD8'] = '\u06C7';
  36918. t['\uFBD9'] = '\u06C6';
  36919. t['\uFBDA'] = '\u06C6';
  36920. t['\uFBDB'] = '\u06C8';
  36921. t['\uFBDC'] = '\u06C8';
  36922. t['\uFBDD'] = '\u0677';
  36923. t['\uFBDE'] = '\u06CB';
  36924. t['\uFBDF'] = '\u06CB';
  36925. t['\uFBE0'] = '\u06C5';
  36926. t['\uFBE1'] = '\u06C5';
  36927. t['\uFBE2'] = '\u06C9';
  36928. t['\uFBE3'] = '\u06C9';
  36929. t['\uFBE4'] = '\u06D0';
  36930. t['\uFBE5'] = '\u06D0';
  36931. t['\uFBE6'] = '\u06D0';
  36932. t['\uFBE7'] = '\u06D0';
  36933. t['\uFBE8'] = '\u0649';
  36934. t['\uFBE9'] = '\u0649';
  36935. t['\uFBEA'] = '\u0626\u0627';
  36936. t['\uFBEB'] = '\u0626\u0627';
  36937. t['\uFBEC'] = '\u0626\u06D5';
  36938. t['\uFBED'] = '\u0626\u06D5';
  36939. t['\uFBEE'] = '\u0626\u0648';
  36940. t['\uFBEF'] = '\u0626\u0648';
  36941. t['\uFBF0'] = '\u0626\u06C7';
  36942. t['\uFBF1'] = '\u0626\u06C7';
  36943. t['\uFBF2'] = '\u0626\u06C6';
  36944. t['\uFBF3'] = '\u0626\u06C6';
  36945. t['\uFBF4'] = '\u0626\u06C8';
  36946. t['\uFBF5'] = '\u0626\u06C8';
  36947. t['\uFBF6'] = '\u0626\u06D0';
  36948. t['\uFBF7'] = '\u0626\u06D0';
  36949. t['\uFBF8'] = '\u0626\u06D0';
  36950. t['\uFBF9'] = '\u0626\u0649';
  36951. t['\uFBFA'] = '\u0626\u0649';
  36952. t['\uFBFB'] = '\u0626\u0649';
  36953. t['\uFBFC'] = '\u06CC';
  36954. t['\uFBFD'] = '\u06CC';
  36955. t['\uFBFE'] = '\u06CC';
  36956. t['\uFBFF'] = '\u06CC';
  36957. t['\uFC00'] = '\u0626\u062C';
  36958. t['\uFC01'] = '\u0626\u062D';
  36959. t['\uFC02'] = '\u0626\u0645';
  36960. t['\uFC03'] = '\u0626\u0649';
  36961. t['\uFC04'] = '\u0626\u064A';
  36962. t['\uFC05'] = '\u0628\u062C';
  36963. t['\uFC06'] = '\u0628\u062D';
  36964. t['\uFC07'] = '\u0628\u062E';
  36965. t['\uFC08'] = '\u0628\u0645';
  36966. t['\uFC09'] = '\u0628\u0649';
  36967. t['\uFC0A'] = '\u0628\u064A';
  36968. t['\uFC0B'] = '\u062A\u062C';
  36969. t['\uFC0C'] = '\u062A\u062D';
  36970. t['\uFC0D'] = '\u062A\u062E';
  36971. t['\uFC0E'] = '\u062A\u0645';
  36972. t['\uFC0F'] = '\u062A\u0649';
  36973. t['\uFC10'] = '\u062A\u064A';
  36974. t['\uFC11'] = '\u062B\u062C';
  36975. t['\uFC12'] = '\u062B\u0645';
  36976. t['\uFC13'] = '\u062B\u0649';
  36977. t['\uFC14'] = '\u062B\u064A';
  36978. t['\uFC15'] = '\u062C\u062D';
  36979. t['\uFC16'] = '\u062C\u0645';
  36980. t['\uFC17'] = '\u062D\u062C';
  36981. t['\uFC18'] = '\u062D\u0645';
  36982. t['\uFC19'] = '\u062E\u062C';
  36983. t['\uFC1A'] = '\u062E\u062D';
  36984. t['\uFC1B'] = '\u062E\u0645';
  36985. t['\uFC1C'] = '\u0633\u062C';
  36986. t['\uFC1D'] = '\u0633\u062D';
  36987. t['\uFC1E'] = '\u0633\u062E';
  36988. t['\uFC1F'] = '\u0633\u0645';
  36989. t['\uFC20'] = '\u0635\u062D';
  36990. t['\uFC21'] = '\u0635\u0645';
  36991. t['\uFC22'] = '\u0636\u062C';
  36992. t['\uFC23'] = '\u0636\u062D';
  36993. t['\uFC24'] = '\u0636\u062E';
  36994. t['\uFC25'] = '\u0636\u0645';
  36995. t['\uFC26'] = '\u0637\u062D';
  36996. t['\uFC27'] = '\u0637\u0645';
  36997. t['\uFC28'] = '\u0638\u0645';
  36998. t['\uFC29'] = '\u0639\u062C';
  36999. t['\uFC2A'] = '\u0639\u0645';
  37000. t['\uFC2B'] = '\u063A\u062C';
  37001. t['\uFC2C'] = '\u063A\u0645';
  37002. t['\uFC2D'] = '\u0641\u062C';
  37003. t['\uFC2E'] = '\u0641\u062D';
  37004. t['\uFC2F'] = '\u0641\u062E';
  37005. t['\uFC30'] = '\u0641\u0645';
  37006. t['\uFC31'] = '\u0641\u0649';
  37007. t['\uFC32'] = '\u0641\u064A';
  37008. t['\uFC33'] = '\u0642\u062D';
  37009. t['\uFC34'] = '\u0642\u0645';
  37010. t['\uFC35'] = '\u0642\u0649';
  37011. t['\uFC36'] = '\u0642\u064A';
  37012. t['\uFC37'] = '\u0643\u0627';
  37013. t['\uFC38'] = '\u0643\u062C';
  37014. t['\uFC39'] = '\u0643\u062D';
  37015. t['\uFC3A'] = '\u0643\u062E';
  37016. t['\uFC3B'] = '\u0643\u0644';
  37017. t['\uFC3C'] = '\u0643\u0645';
  37018. t['\uFC3D'] = '\u0643\u0649';
  37019. t['\uFC3E'] = '\u0643\u064A';
  37020. t['\uFC3F'] = '\u0644\u062C';
  37021. t['\uFC40'] = '\u0644\u062D';
  37022. t['\uFC41'] = '\u0644\u062E';
  37023. t['\uFC42'] = '\u0644\u0645';
  37024. t['\uFC43'] = '\u0644\u0649';
  37025. t['\uFC44'] = '\u0644\u064A';
  37026. t['\uFC45'] = '\u0645\u062C';
  37027. t['\uFC46'] = '\u0645\u062D';
  37028. t['\uFC47'] = '\u0645\u062E';
  37029. t['\uFC48'] = '\u0645\u0645';
  37030. t['\uFC49'] = '\u0645\u0649';
  37031. t['\uFC4A'] = '\u0645\u064A';
  37032. t['\uFC4B'] = '\u0646\u062C';
  37033. t['\uFC4C'] = '\u0646\u062D';
  37034. t['\uFC4D'] = '\u0646\u062E';
  37035. t['\uFC4E'] = '\u0646\u0645';
  37036. t['\uFC4F'] = '\u0646\u0649';
  37037. t['\uFC50'] = '\u0646\u064A';
  37038. t['\uFC51'] = '\u0647\u062C';
  37039. t['\uFC52'] = '\u0647\u0645';
  37040. t['\uFC53'] = '\u0647\u0649';
  37041. t['\uFC54'] = '\u0647\u064A';
  37042. t['\uFC55'] = '\u064A\u062C';
  37043. t['\uFC56'] = '\u064A\u062D';
  37044. t['\uFC57'] = '\u064A\u062E';
  37045. t['\uFC58'] = '\u064A\u0645';
  37046. t['\uFC59'] = '\u064A\u0649';
  37047. t['\uFC5A'] = '\u064A\u064A';
  37048. t['\uFC5B'] = '\u0630\u0670';
  37049. t['\uFC5C'] = '\u0631\u0670';
  37050. t['\uFC5D'] = '\u0649\u0670';
  37051. t['\uFC5E'] = '\u0020\u064C\u0651';
  37052. t['\uFC5F'] = '\u0020\u064D\u0651';
  37053. t['\uFC60'] = '\u0020\u064E\u0651';
  37054. t['\uFC61'] = '\u0020\u064F\u0651';
  37055. t['\uFC62'] = '\u0020\u0650\u0651';
  37056. t['\uFC63'] = '\u0020\u0651\u0670';
  37057. t['\uFC64'] = '\u0626\u0631';
  37058. t['\uFC65'] = '\u0626\u0632';
  37059. t['\uFC66'] = '\u0626\u0645';
  37060. t['\uFC67'] = '\u0626\u0646';
  37061. t['\uFC68'] = '\u0626\u0649';
  37062. t['\uFC69'] = '\u0626\u064A';
  37063. t['\uFC6A'] = '\u0628\u0631';
  37064. t['\uFC6B'] = '\u0628\u0632';
  37065. t['\uFC6C'] = '\u0628\u0645';
  37066. t['\uFC6D'] = '\u0628\u0646';
  37067. t['\uFC6E'] = '\u0628\u0649';
  37068. t['\uFC6F'] = '\u0628\u064A';
  37069. t['\uFC70'] = '\u062A\u0631';
  37070. t['\uFC71'] = '\u062A\u0632';
  37071. t['\uFC72'] = '\u062A\u0645';
  37072. t['\uFC73'] = '\u062A\u0646';
  37073. t['\uFC74'] = '\u062A\u0649';
  37074. t['\uFC75'] = '\u062A\u064A';
  37075. t['\uFC76'] = '\u062B\u0631';
  37076. t['\uFC77'] = '\u062B\u0632';
  37077. t['\uFC78'] = '\u062B\u0645';
  37078. t['\uFC79'] = '\u062B\u0646';
  37079. t['\uFC7A'] = '\u062B\u0649';
  37080. t['\uFC7B'] = '\u062B\u064A';
  37081. t['\uFC7C'] = '\u0641\u0649';
  37082. t['\uFC7D'] = '\u0641\u064A';
  37083. t['\uFC7E'] = '\u0642\u0649';
  37084. t['\uFC7F'] = '\u0642\u064A';
  37085. t['\uFC80'] = '\u0643\u0627';
  37086. t['\uFC81'] = '\u0643\u0644';
  37087. t['\uFC82'] = '\u0643\u0645';
  37088. t['\uFC83'] = '\u0643\u0649';
  37089. t['\uFC84'] = '\u0643\u064A';
  37090. t['\uFC85'] = '\u0644\u0645';
  37091. t['\uFC86'] = '\u0644\u0649';
  37092. t['\uFC87'] = '\u0644\u064A';
  37093. t['\uFC88'] = '\u0645\u0627';
  37094. t['\uFC89'] = '\u0645\u0645';
  37095. t['\uFC8A'] = '\u0646\u0631';
  37096. t['\uFC8B'] = '\u0646\u0632';
  37097. t['\uFC8C'] = '\u0646\u0645';
  37098. t['\uFC8D'] = '\u0646\u0646';
  37099. t['\uFC8E'] = '\u0646\u0649';
  37100. t['\uFC8F'] = '\u0646\u064A';
  37101. t['\uFC90'] = '\u0649\u0670';
  37102. t['\uFC91'] = '\u064A\u0631';
  37103. t['\uFC92'] = '\u064A\u0632';
  37104. t['\uFC93'] = '\u064A\u0645';
  37105. t['\uFC94'] = '\u064A\u0646';
  37106. t['\uFC95'] = '\u064A\u0649';
  37107. t['\uFC96'] = '\u064A\u064A';
  37108. t['\uFC97'] = '\u0626\u062C';
  37109. t['\uFC98'] = '\u0626\u062D';
  37110. t['\uFC99'] = '\u0626\u062E';
  37111. t['\uFC9A'] = '\u0626\u0645';
  37112. t['\uFC9B'] = '\u0626\u0647';
  37113. t['\uFC9C'] = '\u0628\u062C';
  37114. t['\uFC9D'] = '\u0628\u062D';
  37115. t['\uFC9E'] = '\u0628\u062E';
  37116. t['\uFC9F'] = '\u0628\u0645';
  37117. t['\uFCA0'] = '\u0628\u0647';
  37118. t['\uFCA1'] = '\u062A\u062C';
  37119. t['\uFCA2'] = '\u062A\u062D';
  37120. t['\uFCA3'] = '\u062A\u062E';
  37121. t['\uFCA4'] = '\u062A\u0645';
  37122. t['\uFCA5'] = '\u062A\u0647';
  37123. t['\uFCA6'] = '\u062B\u0645';
  37124. t['\uFCA7'] = '\u062C\u062D';
  37125. t['\uFCA8'] = '\u062C\u0645';
  37126. t['\uFCA9'] = '\u062D\u062C';
  37127. t['\uFCAA'] = '\u062D\u0645';
  37128. t['\uFCAB'] = '\u062E\u062C';
  37129. t['\uFCAC'] = '\u062E\u0645';
  37130. t['\uFCAD'] = '\u0633\u062C';
  37131. t['\uFCAE'] = '\u0633\u062D';
  37132. t['\uFCAF'] = '\u0633\u062E';
  37133. t['\uFCB0'] = '\u0633\u0645';
  37134. t['\uFCB1'] = '\u0635\u062D';
  37135. t['\uFCB2'] = '\u0635\u062E';
  37136. t['\uFCB3'] = '\u0635\u0645';
  37137. t['\uFCB4'] = '\u0636\u062C';
  37138. t['\uFCB5'] = '\u0636\u062D';
  37139. t['\uFCB6'] = '\u0636\u062E';
  37140. t['\uFCB7'] = '\u0636\u0645';
  37141. t['\uFCB8'] = '\u0637\u062D';
  37142. t['\uFCB9'] = '\u0638\u0645';
  37143. t['\uFCBA'] = '\u0639\u062C';
  37144. t['\uFCBB'] = '\u0639\u0645';
  37145. t['\uFCBC'] = '\u063A\u062C';
  37146. t['\uFCBD'] = '\u063A\u0645';
  37147. t['\uFCBE'] = '\u0641\u062C';
  37148. t['\uFCBF'] = '\u0641\u062D';
  37149. t['\uFCC0'] = '\u0641\u062E';
  37150. t['\uFCC1'] = '\u0641\u0645';
  37151. t['\uFCC2'] = '\u0642\u062D';
  37152. t['\uFCC3'] = '\u0642\u0645';
  37153. t['\uFCC4'] = '\u0643\u062C';
  37154. t['\uFCC5'] = '\u0643\u062D';
  37155. t['\uFCC6'] = '\u0643\u062E';
  37156. t['\uFCC7'] = '\u0643\u0644';
  37157. t['\uFCC8'] = '\u0643\u0645';
  37158. t['\uFCC9'] = '\u0644\u062C';
  37159. t['\uFCCA'] = '\u0644\u062D';
  37160. t['\uFCCB'] = '\u0644\u062E';
  37161. t['\uFCCC'] = '\u0644\u0645';
  37162. t['\uFCCD'] = '\u0644\u0647';
  37163. t['\uFCCE'] = '\u0645\u062C';
  37164. t['\uFCCF'] = '\u0645\u062D';
  37165. t['\uFCD0'] = '\u0645\u062E';
  37166. t['\uFCD1'] = '\u0645\u0645';
  37167. t['\uFCD2'] = '\u0646\u062C';
  37168. t['\uFCD3'] = '\u0646\u062D';
  37169. t['\uFCD4'] = '\u0646\u062E';
  37170. t['\uFCD5'] = '\u0646\u0645';
  37171. t['\uFCD6'] = '\u0646\u0647';
  37172. t['\uFCD7'] = '\u0647\u062C';
  37173. t['\uFCD8'] = '\u0647\u0645';
  37174. t['\uFCD9'] = '\u0647\u0670';
  37175. t['\uFCDA'] = '\u064A\u062C';
  37176. t['\uFCDB'] = '\u064A\u062D';
  37177. t['\uFCDC'] = '\u064A\u062E';
  37178. t['\uFCDD'] = '\u064A\u0645';
  37179. t['\uFCDE'] = '\u064A\u0647';
  37180. t['\uFCDF'] = '\u0626\u0645';
  37181. t['\uFCE0'] = '\u0626\u0647';
  37182. t['\uFCE1'] = '\u0628\u0645';
  37183. t['\uFCE2'] = '\u0628\u0647';
  37184. t['\uFCE3'] = '\u062A\u0645';
  37185. t['\uFCE4'] = '\u062A\u0647';
  37186. t['\uFCE5'] = '\u062B\u0645';
  37187. t['\uFCE6'] = '\u062B\u0647';
  37188. t['\uFCE7'] = '\u0633\u0645';
  37189. t['\uFCE8'] = '\u0633\u0647';
  37190. t['\uFCE9'] = '\u0634\u0645';
  37191. t['\uFCEA'] = '\u0634\u0647';
  37192. t['\uFCEB'] = '\u0643\u0644';
  37193. t['\uFCEC'] = '\u0643\u0645';
  37194. t['\uFCED'] = '\u0644\u0645';
  37195. t['\uFCEE'] = '\u0646\u0645';
  37196. t['\uFCEF'] = '\u0646\u0647';
  37197. t['\uFCF0'] = '\u064A\u0645';
  37198. t['\uFCF1'] = '\u064A\u0647';
  37199. t['\uFCF2'] = '\u0640\u064E\u0651';
  37200. t['\uFCF3'] = '\u0640\u064F\u0651';
  37201. t['\uFCF4'] = '\u0640\u0650\u0651';
  37202. t['\uFCF5'] = '\u0637\u0649';
  37203. t['\uFCF6'] = '\u0637\u064A';
  37204. t['\uFCF7'] = '\u0639\u0649';
  37205. t['\uFCF8'] = '\u0639\u064A';
  37206. t['\uFCF9'] = '\u063A\u0649';
  37207. t['\uFCFA'] = '\u063A\u064A';
  37208. t['\uFCFB'] = '\u0633\u0649';
  37209. t['\uFCFC'] = '\u0633\u064A';
  37210. t['\uFCFD'] = '\u0634\u0649';
  37211. t['\uFCFE'] = '\u0634\u064A';
  37212. t['\uFCFF'] = '\u062D\u0649';
  37213. t['\uFD00'] = '\u062D\u064A';
  37214. t['\uFD01'] = '\u062C\u0649';
  37215. t['\uFD02'] = '\u062C\u064A';
  37216. t['\uFD03'] = '\u062E\u0649';
  37217. t['\uFD04'] = '\u062E\u064A';
  37218. t['\uFD05'] = '\u0635\u0649';
  37219. t['\uFD06'] = '\u0635\u064A';
  37220. t['\uFD07'] = '\u0636\u0649';
  37221. t['\uFD08'] = '\u0636\u064A';
  37222. t['\uFD09'] = '\u0634\u062C';
  37223. t['\uFD0A'] = '\u0634\u062D';
  37224. t['\uFD0B'] = '\u0634\u062E';
  37225. t['\uFD0C'] = '\u0634\u0645';
  37226. t['\uFD0D'] = '\u0634\u0631';
  37227. t['\uFD0E'] = '\u0633\u0631';
  37228. t['\uFD0F'] = '\u0635\u0631';
  37229. t['\uFD10'] = '\u0636\u0631';
  37230. t['\uFD11'] = '\u0637\u0649';
  37231. t['\uFD12'] = '\u0637\u064A';
  37232. t['\uFD13'] = '\u0639\u0649';
  37233. t['\uFD14'] = '\u0639\u064A';
  37234. t['\uFD15'] = '\u063A\u0649';
  37235. t['\uFD16'] = '\u063A\u064A';
  37236. t['\uFD17'] = '\u0633\u0649';
  37237. t['\uFD18'] = '\u0633\u064A';
  37238. t['\uFD19'] = '\u0634\u0649';
  37239. t['\uFD1A'] = '\u0634\u064A';
  37240. t['\uFD1B'] = '\u062D\u0649';
  37241. t['\uFD1C'] = '\u062D\u064A';
  37242. t['\uFD1D'] = '\u062C\u0649';
  37243. t['\uFD1E'] = '\u062C\u064A';
  37244. t['\uFD1F'] = '\u062E\u0649';
  37245. t['\uFD20'] = '\u062E\u064A';
  37246. t['\uFD21'] = '\u0635\u0649';
  37247. t['\uFD22'] = '\u0635\u064A';
  37248. t['\uFD23'] = '\u0636\u0649';
  37249. t['\uFD24'] = '\u0636\u064A';
  37250. t['\uFD25'] = '\u0634\u062C';
  37251. t['\uFD26'] = '\u0634\u062D';
  37252. t['\uFD27'] = '\u0634\u062E';
  37253. t['\uFD28'] = '\u0634\u0645';
  37254. t['\uFD29'] = '\u0634\u0631';
  37255. t['\uFD2A'] = '\u0633\u0631';
  37256. t['\uFD2B'] = '\u0635\u0631';
  37257. t['\uFD2C'] = '\u0636\u0631';
  37258. t['\uFD2D'] = '\u0634\u062C';
  37259. t['\uFD2E'] = '\u0634\u062D';
  37260. t['\uFD2F'] = '\u0634\u062E';
  37261. t['\uFD30'] = '\u0634\u0645';
  37262. t['\uFD31'] = '\u0633\u0647';
  37263. t['\uFD32'] = '\u0634\u0647';
  37264. t['\uFD33'] = '\u0637\u0645';
  37265. t['\uFD34'] = '\u0633\u062C';
  37266. t['\uFD35'] = '\u0633\u062D';
  37267. t['\uFD36'] = '\u0633\u062E';
  37268. t['\uFD37'] = '\u0634\u062C';
  37269. t['\uFD38'] = '\u0634\u062D';
  37270. t['\uFD39'] = '\u0634\u062E';
  37271. t['\uFD3A'] = '\u0637\u0645';
  37272. t['\uFD3B'] = '\u0638\u0645';
  37273. t['\uFD3C'] = '\u0627\u064B';
  37274. t['\uFD3D'] = '\u0627\u064B';
  37275. t['\uFD50'] = '\u062A\u062C\u0645';
  37276. t['\uFD51'] = '\u062A\u062D\u062C';
  37277. t['\uFD52'] = '\u062A\u062D\u062C';
  37278. t['\uFD53'] = '\u062A\u062D\u0645';
  37279. t['\uFD54'] = '\u062A\u062E\u0645';
  37280. t['\uFD55'] = '\u062A\u0645\u062C';
  37281. t['\uFD56'] = '\u062A\u0645\u062D';
  37282. t['\uFD57'] = '\u062A\u0645\u062E';
  37283. t['\uFD58'] = '\u062C\u0645\u062D';
  37284. t['\uFD59'] = '\u062C\u0645\u062D';
  37285. t['\uFD5A'] = '\u062D\u0645\u064A';
  37286. t['\uFD5B'] = '\u062D\u0645\u0649';
  37287. t['\uFD5C'] = '\u0633\u062D\u062C';
  37288. t['\uFD5D'] = '\u0633\u062C\u062D';
  37289. t['\uFD5E'] = '\u0633\u062C\u0649';
  37290. t['\uFD5F'] = '\u0633\u0645\u062D';
  37291. t['\uFD60'] = '\u0633\u0645\u062D';
  37292. t['\uFD61'] = '\u0633\u0645\u062C';
  37293. t['\uFD62'] = '\u0633\u0645\u0645';
  37294. t['\uFD63'] = '\u0633\u0645\u0645';
  37295. t['\uFD64'] = '\u0635\u062D\u062D';
  37296. t['\uFD65'] = '\u0635\u062D\u062D';
  37297. t['\uFD66'] = '\u0635\u0645\u0645';
  37298. t['\uFD67'] = '\u0634\u062D\u0645';
  37299. t['\uFD68'] = '\u0634\u062D\u0645';
  37300. t['\uFD69'] = '\u0634\u062C\u064A';
  37301. t['\uFD6A'] = '\u0634\u0645\u062E';
  37302. t['\uFD6B'] = '\u0634\u0645\u062E';
  37303. t['\uFD6C'] = '\u0634\u0645\u0645';
  37304. t['\uFD6D'] = '\u0634\u0645\u0645';
  37305. t['\uFD6E'] = '\u0636\u062D\u0649';
  37306. t['\uFD6F'] = '\u0636\u062E\u0645';
  37307. t['\uFD70'] = '\u0636\u062E\u0645';
  37308. t['\uFD71'] = '\u0637\u0645\u062D';
  37309. t['\uFD72'] = '\u0637\u0645\u062D';
  37310. t['\uFD73'] = '\u0637\u0645\u0645';
  37311. t['\uFD74'] = '\u0637\u0645\u064A';
  37312. t['\uFD75'] = '\u0639\u062C\u0645';
  37313. t['\uFD76'] = '\u0639\u0645\u0645';
  37314. t['\uFD77'] = '\u0639\u0645\u0645';
  37315. t['\uFD78'] = '\u0639\u0645\u0649';
  37316. t['\uFD79'] = '\u063A\u0645\u0645';
  37317. t['\uFD7A'] = '\u063A\u0645\u064A';
  37318. t['\uFD7B'] = '\u063A\u0645\u0649';
  37319. t['\uFD7C'] = '\u0641\u062E\u0645';
  37320. t['\uFD7D'] = '\u0641\u062E\u0645';
  37321. t['\uFD7E'] = '\u0642\u0645\u062D';
  37322. t['\uFD7F'] = '\u0642\u0645\u0645';
  37323. t['\uFD80'] = '\u0644\u062D\u0645';
  37324. t['\uFD81'] = '\u0644\u062D\u064A';
  37325. t['\uFD82'] = '\u0644\u062D\u0649';
  37326. t['\uFD83'] = '\u0644\u062C\u062C';
  37327. t['\uFD84'] = '\u0644\u062C\u062C';
  37328. t['\uFD85'] = '\u0644\u062E\u0645';
  37329. t['\uFD86'] = '\u0644\u062E\u0645';
  37330. t['\uFD87'] = '\u0644\u0645\u062D';
  37331. t['\uFD88'] = '\u0644\u0645\u062D';
  37332. t['\uFD89'] = '\u0645\u062D\u062C';
  37333. t['\uFD8A'] = '\u0645\u062D\u0645';
  37334. t['\uFD8B'] = '\u0645\u062D\u064A';
  37335. t['\uFD8C'] = '\u0645\u062C\u062D';
  37336. t['\uFD8D'] = '\u0645\u062C\u0645';
  37337. t['\uFD8E'] = '\u0645\u062E\u062C';
  37338. t['\uFD8F'] = '\u0645\u062E\u0645';
  37339. t['\uFD92'] = '\u0645\u062C\u062E';
  37340. t['\uFD93'] = '\u0647\u0645\u062C';
  37341. t['\uFD94'] = '\u0647\u0645\u0645';
  37342. t['\uFD95'] = '\u0646\u062D\u0645';
  37343. t['\uFD96'] = '\u0646\u062D\u0649';
  37344. t['\uFD97'] = '\u0646\u062C\u0645';
  37345. t['\uFD98'] = '\u0646\u062C\u0645';
  37346. t['\uFD99'] = '\u0646\u062C\u0649';
  37347. t['\uFD9A'] = '\u0646\u0645\u064A';
  37348. t['\uFD9B'] = '\u0646\u0645\u0649';
  37349. t['\uFD9C'] = '\u064A\u0645\u0645';
  37350. t['\uFD9D'] = '\u064A\u0645\u0645';
  37351. t['\uFD9E'] = '\u0628\u062E\u064A';
  37352. t['\uFD9F'] = '\u062A\u062C\u064A';
  37353. t['\uFDA0'] = '\u062A\u062C\u0649';
  37354. t['\uFDA1'] = '\u062A\u062E\u064A';
  37355. t['\uFDA2'] = '\u062A\u062E\u0649';
  37356. t['\uFDA3'] = '\u062A\u0645\u064A';
  37357. t['\uFDA4'] = '\u062A\u0645\u0649';
  37358. t['\uFDA5'] = '\u062C\u0645\u064A';
  37359. t['\uFDA6'] = '\u062C\u062D\u0649';
  37360. t['\uFDA7'] = '\u062C\u0645\u0649';
  37361. t['\uFDA8'] = '\u0633\u062E\u0649';
  37362. t['\uFDA9'] = '\u0635\u062D\u064A';
  37363. t['\uFDAA'] = '\u0634\u062D\u064A';
  37364. t['\uFDAB'] = '\u0636\u062D\u064A';
  37365. t['\uFDAC'] = '\u0644\u062C\u064A';
  37366. t['\uFDAD'] = '\u0644\u0645\u064A';
  37367. t['\uFDAE'] = '\u064A\u062D\u064A';
  37368. t['\uFDAF'] = '\u064A\u062C\u064A';
  37369. t['\uFDB0'] = '\u064A\u0645\u064A';
  37370. t['\uFDB1'] = '\u0645\u0645\u064A';
  37371. t['\uFDB2'] = '\u0642\u0645\u064A';
  37372. t['\uFDB3'] = '\u0646\u062D\u064A';
  37373. t['\uFDB4'] = '\u0642\u0645\u062D';
  37374. t['\uFDB5'] = '\u0644\u062D\u0645';
  37375. t['\uFDB6'] = '\u0639\u0645\u064A';
  37376. t['\uFDB7'] = '\u0643\u0645\u064A';
  37377. t['\uFDB8'] = '\u0646\u062C\u062D';
  37378. t['\uFDB9'] = '\u0645\u062E\u064A';
  37379. t['\uFDBA'] = '\u0644\u062C\u0645';
  37380. t['\uFDBB'] = '\u0643\u0645\u0645';
  37381. t['\uFDBC'] = '\u0644\u062C\u0645';
  37382. t['\uFDBD'] = '\u0646\u062C\u062D';
  37383. t['\uFDBE'] = '\u062C\u062D\u064A';
  37384. t['\uFDBF'] = '\u062D\u062C\u064A';
  37385. t['\uFDC0'] = '\u0645\u062C\u064A';
  37386. t['\uFDC1'] = '\u0641\u0645\u064A';
  37387. t['\uFDC2'] = '\u0628\u062D\u064A';
  37388. t['\uFDC3'] = '\u0643\u0645\u0645';
  37389. t['\uFDC4'] = '\u0639\u062C\u0645';
  37390. t['\uFDC5'] = '\u0635\u0645\u0645';
  37391. t['\uFDC6'] = '\u0633\u062E\u064A';
  37392. t['\uFDC7'] = '\u0646\u062C\u064A';
  37393. t['\uFE49'] = '\u203E';
  37394. t['\uFE4A'] = '\u203E';
  37395. t['\uFE4B'] = '\u203E';
  37396. t['\uFE4C'] = '\u203E';
  37397. t['\uFE4D'] = '\u005F';
  37398. t['\uFE4E'] = '\u005F';
  37399. t['\uFE4F'] = '\u005F';
  37400. t['\uFE80'] = '\u0621';
  37401. t['\uFE81'] = '\u0622';
  37402. t['\uFE82'] = '\u0622';
  37403. t['\uFE83'] = '\u0623';
  37404. t['\uFE84'] = '\u0623';
  37405. t['\uFE85'] = '\u0624';
  37406. t['\uFE86'] = '\u0624';
  37407. t['\uFE87'] = '\u0625';
  37408. t['\uFE88'] = '\u0625';
  37409. t['\uFE89'] = '\u0626';
  37410. t['\uFE8A'] = '\u0626';
  37411. t['\uFE8B'] = '\u0626';
  37412. t['\uFE8C'] = '\u0626';
  37413. t['\uFE8D'] = '\u0627';
  37414. t['\uFE8E'] = '\u0627';
  37415. t['\uFE8F'] = '\u0628';
  37416. t['\uFE90'] = '\u0628';
  37417. t['\uFE91'] = '\u0628';
  37418. t['\uFE92'] = '\u0628';
  37419. t['\uFE93'] = '\u0629';
  37420. t['\uFE94'] = '\u0629';
  37421. t['\uFE95'] = '\u062A';
  37422. t['\uFE96'] = '\u062A';
  37423. t['\uFE97'] = '\u062A';
  37424. t['\uFE98'] = '\u062A';
  37425. t['\uFE99'] = '\u062B';
  37426. t['\uFE9A'] = '\u062B';
  37427. t['\uFE9B'] = '\u062B';
  37428. t['\uFE9C'] = '\u062B';
  37429. t['\uFE9D'] = '\u062C';
  37430. t['\uFE9E'] = '\u062C';
  37431. t['\uFE9F'] = '\u062C';
  37432. t['\uFEA0'] = '\u062C';
  37433. t['\uFEA1'] = '\u062D';
  37434. t['\uFEA2'] = '\u062D';
  37435. t['\uFEA3'] = '\u062D';
  37436. t['\uFEA4'] = '\u062D';
  37437. t['\uFEA5'] = '\u062E';
  37438. t['\uFEA6'] = '\u062E';
  37439. t['\uFEA7'] = '\u062E';
  37440. t['\uFEA8'] = '\u062E';
  37441. t['\uFEA9'] = '\u062F';
  37442. t['\uFEAA'] = '\u062F';
  37443. t['\uFEAB'] = '\u0630';
  37444. t['\uFEAC'] = '\u0630';
  37445. t['\uFEAD'] = '\u0631';
  37446. t['\uFEAE'] = '\u0631';
  37447. t['\uFEAF'] = '\u0632';
  37448. t['\uFEB0'] = '\u0632';
  37449. t['\uFEB1'] = '\u0633';
  37450. t['\uFEB2'] = '\u0633';
  37451. t['\uFEB3'] = '\u0633';
  37452. t['\uFEB4'] = '\u0633';
  37453. t['\uFEB5'] = '\u0634';
  37454. t['\uFEB6'] = '\u0634';
  37455. t['\uFEB7'] = '\u0634';
  37456. t['\uFEB8'] = '\u0634';
  37457. t['\uFEB9'] = '\u0635';
  37458. t['\uFEBA'] = '\u0635';
  37459. t['\uFEBB'] = '\u0635';
  37460. t['\uFEBC'] = '\u0635';
  37461. t['\uFEBD'] = '\u0636';
  37462. t['\uFEBE'] = '\u0636';
  37463. t['\uFEBF'] = '\u0636';
  37464. t['\uFEC0'] = '\u0636';
  37465. t['\uFEC1'] = '\u0637';
  37466. t['\uFEC2'] = '\u0637';
  37467. t['\uFEC3'] = '\u0637';
  37468. t['\uFEC4'] = '\u0637';
  37469. t['\uFEC5'] = '\u0638';
  37470. t['\uFEC6'] = '\u0638';
  37471. t['\uFEC7'] = '\u0638';
  37472. t['\uFEC8'] = '\u0638';
  37473. t['\uFEC9'] = '\u0639';
  37474. t['\uFECA'] = '\u0639';
  37475. t['\uFECB'] = '\u0639';
  37476. t['\uFECC'] = '\u0639';
  37477. t['\uFECD'] = '\u063A';
  37478. t['\uFECE'] = '\u063A';
  37479. t['\uFECF'] = '\u063A';
  37480. t['\uFED0'] = '\u063A';
  37481. t['\uFED1'] = '\u0641';
  37482. t['\uFED2'] = '\u0641';
  37483. t['\uFED3'] = '\u0641';
  37484. t['\uFED4'] = '\u0641';
  37485. t['\uFED5'] = '\u0642';
  37486. t['\uFED6'] = '\u0642';
  37487. t['\uFED7'] = '\u0642';
  37488. t['\uFED8'] = '\u0642';
  37489. t['\uFED9'] = '\u0643';
  37490. t['\uFEDA'] = '\u0643';
  37491. t['\uFEDB'] = '\u0643';
  37492. t['\uFEDC'] = '\u0643';
  37493. t['\uFEDD'] = '\u0644';
  37494. t['\uFEDE'] = '\u0644';
  37495. t['\uFEDF'] = '\u0644';
  37496. t['\uFEE0'] = '\u0644';
  37497. t['\uFEE1'] = '\u0645';
  37498. t['\uFEE2'] = '\u0645';
  37499. t['\uFEE3'] = '\u0645';
  37500. t['\uFEE4'] = '\u0645';
  37501. t['\uFEE5'] = '\u0646';
  37502. t['\uFEE6'] = '\u0646';
  37503. t['\uFEE7'] = '\u0646';
  37504. t['\uFEE8'] = '\u0646';
  37505. t['\uFEE9'] = '\u0647';
  37506. t['\uFEEA'] = '\u0647';
  37507. t['\uFEEB'] = '\u0647';
  37508. t['\uFEEC'] = '\u0647';
  37509. t['\uFEED'] = '\u0648';
  37510. t['\uFEEE'] = '\u0648';
  37511. t['\uFEEF'] = '\u0649';
  37512. t['\uFEF0'] = '\u0649';
  37513. t['\uFEF1'] = '\u064A';
  37514. t['\uFEF2'] = '\u064A';
  37515. t['\uFEF3'] = '\u064A';
  37516. t['\uFEF4'] = '\u064A';
  37517. t['\uFEF5'] = '\u0644\u0622';
  37518. t['\uFEF6'] = '\u0644\u0622';
  37519. t['\uFEF7'] = '\u0644\u0623';
  37520. t['\uFEF8'] = '\u0644\u0623';
  37521. t['\uFEF9'] = '\u0644\u0625';
  37522. t['\uFEFA'] = '\u0644\u0625';
  37523. t['\uFEFB'] = '\u0644\u0627';
  37524. t['\uFEFC'] = '\u0644\u0627';
  37525. });
  37526. function reverseIfRtl(chars) {
  37527. var charsLength = chars.length;
  37528. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  37529. return chars;
  37530. }
  37531. var s = '';
  37532. for (var ii = charsLength - 1; ii >= 0; ii--) {
  37533. s += chars[ii];
  37534. }
  37535. return s;
  37536. }
  37537. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  37538. exports.reverseIfRtl = reverseIfRtl;
  37539. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  37540. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  37541. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  37542. /***/ }),
  37543. /* 23 */
  37544. /***/ (function(module, exports, __w_pdfjs_require__) {
  37545. "use strict";
  37546. var sharedUtil = __w_pdfjs_require__(0);
  37547. var corePrimitives = __w_pdfjs_require__(1);
  37548. var corePdfManager = __w_pdfjs_require__(41);
  37549. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  37550. var InvalidPDFException = sharedUtil.InvalidPDFException;
  37551. var MessageHandler = sharedUtil.MessageHandler;
  37552. var MissingPDFException = sharedUtil.MissingPDFException;
  37553. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  37554. var PasswordException = sharedUtil.PasswordException;
  37555. var UnknownErrorException = sharedUtil.UnknownErrorException;
  37556. var XRefParseException = sharedUtil.XRefParseException;
  37557. var arrayByteLength = sharedUtil.arrayByteLength;
  37558. var arraysToBytes = sharedUtil.arraysToBytes;
  37559. var assert = sharedUtil.assert;
  37560. var createPromiseCapability = sharedUtil.createPromiseCapability;
  37561. var info = sharedUtil.info;
  37562. var warn = sharedUtil.warn;
  37563. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  37564. var isNodeJS = sharedUtil.isNodeJS;
  37565. var Ref = corePrimitives.Ref;
  37566. var LocalPdfManager = corePdfManager.LocalPdfManager;
  37567. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  37568. var WorkerTask = function WorkerTaskClosure() {
  37569. function WorkerTask(name) {
  37570. this.name = name;
  37571. this.terminated = false;
  37572. this._capability = createPromiseCapability();
  37573. }
  37574. WorkerTask.prototype = {
  37575. get finished() {
  37576. return this._capability.promise;
  37577. },
  37578. finish: function () {
  37579. this._capability.resolve();
  37580. },
  37581. terminate: function () {
  37582. this.terminated = true;
  37583. },
  37584. ensureNotTerminated: function () {
  37585. if (this.terminated) {
  37586. throw new Error('Worker task was terminated');
  37587. }
  37588. }
  37589. };
  37590. return WorkerTask;
  37591. }();
  37592. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  37593. function PDFWorkerStream(params, msgHandler) {
  37594. this._queuedChunks = [];
  37595. var initialData = params.initialData;
  37596. if (initialData && initialData.length > 0) {
  37597. this._queuedChunks.push(initialData);
  37598. }
  37599. this._msgHandler = msgHandler;
  37600. this._isRangeSupported = !params.disableRange;
  37601. this._isStreamingSupported = !params.disableStream;
  37602. this._contentLength = params.length;
  37603. this._fullRequestReader = null;
  37604. this._rangeReaders = [];
  37605. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  37606. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  37607. }
  37608. PDFWorkerStream.prototype = {
  37609. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  37610. if (args.begin === undefined) {
  37611. if (this._fullRequestReader) {
  37612. this._fullRequestReader._enqueue(args.chunk);
  37613. } else {
  37614. this._queuedChunks.push(args.chunk);
  37615. }
  37616. } else {
  37617. var found = this._rangeReaders.some(function (rangeReader) {
  37618. if (rangeReader._begin !== args.begin) {
  37619. return false;
  37620. }
  37621. rangeReader._enqueue(args.chunk);
  37622. return true;
  37623. });
  37624. assert(found);
  37625. }
  37626. },
  37627. _onProgress: function PDFWorkerStream_onProgress(evt) {
  37628. if (this._rangeReaders.length > 0) {
  37629. var firstReader = this._rangeReaders[0];
  37630. if (firstReader.onProgress) {
  37631. firstReader.onProgress({ loaded: evt.loaded });
  37632. }
  37633. }
  37634. },
  37635. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  37636. var i = this._rangeReaders.indexOf(reader);
  37637. if (i >= 0) {
  37638. this._rangeReaders.splice(i, 1);
  37639. }
  37640. },
  37641. getFullReader: function PDFWorkerStream_getFullReader() {
  37642. assert(!this._fullRequestReader);
  37643. var queuedChunks = this._queuedChunks;
  37644. this._queuedChunks = null;
  37645. return new PDFWorkerStreamReader(this, queuedChunks);
  37646. },
  37647. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  37648. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  37649. this._msgHandler.send('RequestDataRange', {
  37650. begin: begin,
  37651. end: end
  37652. });
  37653. this._rangeReaders.push(reader);
  37654. return reader;
  37655. },
  37656. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  37657. if (this._fullRequestReader) {
  37658. this._fullRequestReader.cancel(reason);
  37659. }
  37660. var readers = this._rangeReaders.slice(0);
  37661. readers.forEach(function (rangeReader) {
  37662. rangeReader.cancel(reason);
  37663. });
  37664. }
  37665. };
  37666. function PDFWorkerStreamReader(stream, queuedChunks) {
  37667. this._stream = stream;
  37668. this._done = false;
  37669. this._queuedChunks = queuedChunks || [];
  37670. this._requests = [];
  37671. this._headersReady = Promise.resolve();
  37672. stream._fullRequestReader = this;
  37673. this.onProgress = null;
  37674. }
  37675. PDFWorkerStreamReader.prototype = {
  37676. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  37677. if (this._done) {
  37678. return;
  37679. }
  37680. if (this._requests.length > 0) {
  37681. var requestCapability = this._requests.shift();
  37682. requestCapability.resolve({
  37683. value: chunk,
  37684. done: false
  37685. });
  37686. return;
  37687. }
  37688. this._queuedChunks.push(chunk);
  37689. },
  37690. get headersReady() {
  37691. return this._headersReady;
  37692. },
  37693. get isRangeSupported() {
  37694. return this._stream._isRangeSupported;
  37695. },
  37696. get isStreamingSupported() {
  37697. return this._stream._isStreamingSupported;
  37698. },
  37699. get contentLength() {
  37700. return this._stream._contentLength;
  37701. },
  37702. read: function PDFWorkerStreamReader_read() {
  37703. if (this._queuedChunks.length > 0) {
  37704. var chunk = this._queuedChunks.shift();
  37705. return Promise.resolve({
  37706. value: chunk,
  37707. done: false
  37708. });
  37709. }
  37710. if (this._done) {
  37711. return Promise.resolve({
  37712. value: undefined,
  37713. done: true
  37714. });
  37715. }
  37716. var requestCapability = createPromiseCapability();
  37717. this._requests.push(requestCapability);
  37718. return requestCapability.promise;
  37719. },
  37720. cancel: function PDFWorkerStreamReader_cancel(reason) {
  37721. this._done = true;
  37722. this._requests.forEach(function (requestCapability) {
  37723. requestCapability.resolve({
  37724. value: undefined,
  37725. done: true
  37726. });
  37727. });
  37728. this._requests = [];
  37729. }
  37730. };
  37731. function PDFWorkerStreamRangeReader(stream, begin, end) {
  37732. this._stream = stream;
  37733. this._begin = begin;
  37734. this._end = end;
  37735. this._queuedChunk = null;
  37736. this._requests = [];
  37737. this._done = false;
  37738. this.onProgress = null;
  37739. }
  37740. PDFWorkerStreamRangeReader.prototype = {
  37741. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  37742. if (this._done) {
  37743. return;
  37744. }
  37745. if (this._requests.length === 0) {
  37746. this._queuedChunk = chunk;
  37747. } else {
  37748. var requestsCapability = this._requests.shift();
  37749. requestsCapability.resolve({
  37750. value: chunk,
  37751. done: false
  37752. });
  37753. this._requests.forEach(function (requestCapability) {
  37754. requestCapability.resolve({
  37755. value: undefined,
  37756. done: true
  37757. });
  37758. });
  37759. this._requests = [];
  37760. }
  37761. this._done = true;
  37762. this._stream._removeRangeReader(this);
  37763. },
  37764. get isStreamingSupported() {
  37765. return false;
  37766. },
  37767. read: function PDFWorkerStreamRangeReader_read() {
  37768. if (this._queuedChunk) {
  37769. return Promise.resolve({
  37770. value: this._queuedChunk,
  37771. done: false
  37772. });
  37773. }
  37774. if (this._done) {
  37775. return Promise.resolve({
  37776. value: undefined,
  37777. done: true
  37778. });
  37779. }
  37780. var requestCapability = createPromiseCapability();
  37781. this._requests.push(requestCapability);
  37782. return requestCapability.promise;
  37783. },
  37784. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  37785. this._done = true;
  37786. this._requests.forEach(function (requestCapability) {
  37787. requestCapability.resolve({
  37788. value: undefined,
  37789. done: true
  37790. });
  37791. });
  37792. this._requests = [];
  37793. this._stream._removeRangeReader(this);
  37794. }
  37795. };
  37796. return PDFWorkerStream;
  37797. }();
  37798. var PDFNetworkStream;
  37799. function setPDFNetworkStreamClass(cls) {
  37800. PDFNetworkStream = cls;
  37801. }
  37802. var WorkerMessageHandler = {
  37803. setup: function wphSetup(handler, port) {
  37804. var testMessageProcessed = false;
  37805. handler.on('test', function wphSetupTest(data) {
  37806. if (testMessageProcessed) {
  37807. return;
  37808. }
  37809. testMessageProcessed = true;
  37810. if (!(data instanceof Uint8Array)) {
  37811. handler.send('test', 'main', false);
  37812. return;
  37813. }
  37814. var supportTransfers = data[0] === 255;
  37815. handler.postMessageTransfers = supportTransfers;
  37816. var xhr = new XMLHttpRequest();
  37817. var responseExists = 'response' in xhr;
  37818. try {
  37819. xhr.responseType;
  37820. } catch (e) {
  37821. responseExists = false;
  37822. }
  37823. if (!responseExists) {
  37824. handler.send('test', false);
  37825. return;
  37826. }
  37827. handler.send('test', {
  37828. supportTypedArray: true,
  37829. supportTransfers: supportTransfers
  37830. });
  37831. });
  37832. handler.on('configure', function wphConfigure(data) {
  37833. setVerbosityLevel(data.verbosity);
  37834. });
  37835. handler.on('GetDocRequest', function wphSetupDoc(data) {
  37836. return WorkerMessageHandler.createDocumentHandler(data, port);
  37837. });
  37838. },
  37839. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  37840. var pdfManager;
  37841. var terminated = false;
  37842. var cancelXHRs = null;
  37843. var WorkerTasks = [];
  37844. var docId = docParams.docId;
  37845. var docBaseUrl = docParams.docBaseUrl;
  37846. var workerHandlerName = docParams.docId + '_worker';
  37847. var handler = new MessageHandler(workerHandlerName, docId, port);
  37848. handler.postMessageTransfers = docParams.postMessageTransfers;
  37849. function ensureNotTerminated() {
  37850. if (terminated) {
  37851. throw new Error('Worker was terminated');
  37852. }
  37853. }
  37854. function startWorkerTask(task) {
  37855. WorkerTasks.push(task);
  37856. }
  37857. function finishWorkerTask(task) {
  37858. task.finish();
  37859. var i = WorkerTasks.indexOf(task);
  37860. WorkerTasks.splice(i, 1);
  37861. }
  37862. function loadDocument(recoveryMode) {
  37863. var loadDocumentCapability = createPromiseCapability();
  37864. var parseSuccess = function parseSuccess() {
  37865. var numPagesPromise = pdfManager.ensureDoc('numPages');
  37866. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  37867. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  37868. Promise.all([
  37869. numPagesPromise,
  37870. fingerprintPromise,
  37871. encryptedPromise
  37872. ]).then(function onDocReady(results) {
  37873. var doc = {
  37874. numPages: results[0],
  37875. fingerprint: results[1],
  37876. encrypted: !!results[2]
  37877. };
  37878. loadDocumentCapability.resolve(doc);
  37879. }, parseFailure);
  37880. };
  37881. var parseFailure = function parseFailure(e) {
  37882. loadDocumentCapability.reject(e);
  37883. };
  37884. pdfManager.ensureDoc('checkHeader', []).then(function () {
  37885. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  37886. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  37887. }, parseFailure);
  37888. }, parseFailure);
  37889. return loadDocumentCapability.promise;
  37890. }
  37891. function getPdfManager(data, evaluatorOptions) {
  37892. var pdfManagerCapability = createPromiseCapability();
  37893. var pdfManager;
  37894. var source = data.source;
  37895. if (source.data) {
  37896. try {
  37897. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  37898. pdfManagerCapability.resolve(pdfManager);
  37899. } catch (ex) {
  37900. pdfManagerCapability.reject(ex);
  37901. }
  37902. return pdfManagerCapability.promise;
  37903. }
  37904. var pdfStream;
  37905. try {
  37906. if (source.chunkedViewerLoading) {
  37907. pdfStream = new PDFWorkerStream(source, handler);
  37908. } else {
  37909. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  37910. pdfStream = new PDFNetworkStream(data);
  37911. }
  37912. } catch (ex) {
  37913. pdfManagerCapability.reject(ex);
  37914. return pdfManagerCapability.promise;
  37915. }
  37916. var fullRequest = pdfStream.getFullReader();
  37917. fullRequest.headersReady.then(function () {
  37918. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  37919. fullRequest.onProgress = function (evt) {
  37920. handler.send('DocProgress', {
  37921. loaded: evt.loaded,
  37922. total: evt.total
  37923. });
  37924. };
  37925. }
  37926. if (!fullRequest.isRangeSupported) {
  37927. return;
  37928. }
  37929. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  37930. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  37931. msgHandler: handler,
  37932. url: source.url,
  37933. password: source.password,
  37934. length: fullRequest.contentLength,
  37935. disableAutoFetch: disableAutoFetch,
  37936. rangeChunkSize: source.rangeChunkSize
  37937. }, evaluatorOptions, docBaseUrl);
  37938. pdfManagerCapability.resolve(pdfManager);
  37939. cancelXHRs = null;
  37940. }).catch(function (reason) {
  37941. pdfManagerCapability.reject(reason);
  37942. cancelXHRs = null;
  37943. });
  37944. var cachedChunks = [], loaded = 0;
  37945. var flushChunks = function () {
  37946. var pdfFile = arraysToBytes(cachedChunks);
  37947. if (source.length && pdfFile.length !== source.length) {
  37948. warn('reported HTTP length is different from actual');
  37949. }
  37950. try {
  37951. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  37952. pdfManagerCapability.resolve(pdfManager);
  37953. } catch (ex) {
  37954. pdfManagerCapability.reject(ex);
  37955. }
  37956. cachedChunks = [];
  37957. };
  37958. var readPromise = new Promise(function (resolve, reject) {
  37959. var readChunk = function (chunk) {
  37960. try {
  37961. ensureNotTerminated();
  37962. if (chunk.done) {
  37963. if (!pdfManager) {
  37964. flushChunks();
  37965. }
  37966. cancelXHRs = null;
  37967. return;
  37968. }
  37969. var data = chunk.value;
  37970. loaded += arrayByteLength(data);
  37971. if (!fullRequest.isStreamingSupported) {
  37972. handler.send('DocProgress', {
  37973. loaded: loaded,
  37974. total: Math.max(loaded, fullRequest.contentLength || 0)
  37975. });
  37976. }
  37977. if (pdfManager) {
  37978. pdfManager.sendProgressiveData(data);
  37979. } else {
  37980. cachedChunks.push(data);
  37981. }
  37982. fullRequest.read().then(readChunk, reject);
  37983. } catch (e) {
  37984. reject(e);
  37985. }
  37986. };
  37987. fullRequest.read().then(readChunk, reject);
  37988. });
  37989. readPromise.catch(function (e) {
  37990. pdfManagerCapability.reject(e);
  37991. cancelXHRs = null;
  37992. });
  37993. cancelXHRs = function () {
  37994. pdfStream.cancelAllRequests('abort');
  37995. };
  37996. return pdfManagerCapability.promise;
  37997. }
  37998. function setupDoc(data) {
  37999. function onSuccess(doc) {
  38000. ensureNotTerminated();
  38001. handler.send('GetDoc', { pdfInfo: doc });
  38002. }
  38003. function onFailure(e) {
  38004. if (e instanceof PasswordException) {
  38005. var task = new WorkerTask('PasswordException: response ' + e.code);
  38006. startWorkerTask(task);
  38007. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38008. finishWorkerTask(task);
  38009. pdfManager.updatePassword(data.password);
  38010. pdfManagerReady();
  38011. }).catch(function (ex) {
  38012. finishWorkerTask(task);
  38013. handler.send('PasswordException', ex);
  38014. }.bind(null, e));
  38015. } else if (e instanceof InvalidPDFException) {
  38016. handler.send('InvalidPDF', e);
  38017. } else if (e instanceof MissingPDFException) {
  38018. handler.send('MissingPDF', e);
  38019. } else if (e instanceof UnexpectedResponseException) {
  38020. handler.send('UnexpectedResponse', e);
  38021. } else {
  38022. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38023. }
  38024. }
  38025. function pdfManagerReady() {
  38026. ensureNotTerminated();
  38027. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38028. ensureNotTerminated();
  38029. if (!(ex instanceof XRefParseException)) {
  38030. onFailure(ex);
  38031. return;
  38032. }
  38033. pdfManager.requestLoadedStream();
  38034. pdfManager.onLoadedStream().then(function () {
  38035. ensureNotTerminated();
  38036. loadDocument(true).then(onSuccess, onFailure);
  38037. });
  38038. }, onFailure);
  38039. }
  38040. ensureNotTerminated();
  38041. var evaluatorOptions = {
  38042. forceDataSchema: data.disableCreateObjectURL,
  38043. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38044. disableFontFace: data.disableFontFace,
  38045. disableNativeImageDecoder: data.disableNativeImageDecoder
  38046. };
  38047. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38048. if (terminated) {
  38049. newPdfManager.terminate();
  38050. throw new Error('Worker was terminated');
  38051. }
  38052. pdfManager = newPdfManager;
  38053. handler.send('PDFManagerReady', null);
  38054. pdfManager.onLoadedStream().then(function (stream) {
  38055. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38056. });
  38057. }).then(pdfManagerReady, onFailure);
  38058. }
  38059. handler.on('GetPage', function wphSetupGetPage(data) {
  38060. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38061. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38062. var refPromise = pdfManager.ensure(page, 'ref');
  38063. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38064. var viewPromise = pdfManager.ensure(page, 'view');
  38065. return Promise.all([
  38066. rotatePromise,
  38067. refPromise,
  38068. userUnitPromise,
  38069. viewPromise
  38070. ]).then(function (results) {
  38071. return {
  38072. rotate: results[0],
  38073. ref: results[1],
  38074. userUnit: results[2],
  38075. view: results[3]
  38076. };
  38077. });
  38078. });
  38079. });
  38080. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38081. var ref = new Ref(data.ref.num, data.ref.gen);
  38082. var catalog = pdfManager.pdfDocument.catalog;
  38083. return catalog.getPageIndex(ref);
  38084. });
  38085. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38086. return pdfManager.ensureCatalog('destinations');
  38087. });
  38088. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38089. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38090. });
  38091. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38092. return pdfManager.ensureCatalog('pageLabels');
  38093. });
  38094. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38095. return pdfManager.ensureCatalog('attachments');
  38096. });
  38097. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38098. return pdfManager.ensureCatalog('javaScript');
  38099. });
  38100. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38101. return pdfManager.ensureCatalog('documentOutline');
  38102. });
  38103. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38104. return Promise.all([
  38105. pdfManager.ensureDoc('documentInfo'),
  38106. pdfManager.ensureCatalog('metadata')
  38107. ]);
  38108. });
  38109. handler.on('GetData', function wphSetupGetData(data) {
  38110. pdfManager.requestLoadedStream();
  38111. return pdfManager.onLoadedStream().then(function (stream) {
  38112. return stream.bytes;
  38113. });
  38114. });
  38115. handler.on('GetStats', function wphSetupGetStats(data) {
  38116. return pdfManager.pdfDocument.xref.stats;
  38117. });
  38118. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38119. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38120. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38121. });
  38122. });
  38123. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38124. var pageIndex = data.pageIndex;
  38125. pdfManager.getPage(pageIndex).then(function (page) {
  38126. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38127. startWorkerTask(task);
  38128. var pageNum = pageIndex + 1;
  38129. var start = Date.now();
  38130. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38131. finishWorkerTask(task);
  38132. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38133. }, function (e) {
  38134. finishWorkerTask(task);
  38135. if (task.terminated) {
  38136. return;
  38137. }
  38138. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38139. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38140. var wrappedException;
  38141. if (typeof e === 'string') {
  38142. wrappedException = {
  38143. message: e,
  38144. stack: minimumStackMessage
  38145. };
  38146. } else if (typeof e === 'object') {
  38147. wrappedException = {
  38148. message: e.message || e.toString(),
  38149. stack: e.stack || minimumStackMessage
  38150. };
  38151. } else {
  38152. wrappedException = {
  38153. message: 'Unknown exception type: ' + typeof e,
  38154. stack: minimumStackMessage
  38155. };
  38156. }
  38157. handler.send('PageError', {
  38158. pageNum: pageNum,
  38159. error: wrappedException,
  38160. intent: data.intent
  38161. });
  38162. });
  38163. });
  38164. }, this);
  38165. handler.on('GetTextContent', function wphExtractText(data) {
  38166. var pageIndex = data.pageIndex;
  38167. var normalizeWhitespace = data.normalizeWhitespace;
  38168. var combineTextItems = data.combineTextItems;
  38169. return pdfManager.getPage(pageIndex).then(function (page) {
  38170. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38171. startWorkerTask(task);
  38172. var pageNum = pageIndex + 1;
  38173. var start = Date.now();
  38174. return page.extractTextContent(handler, task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38175. finishWorkerTask(task);
  38176. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38177. return textContent;
  38178. }, function (reason) {
  38179. finishWorkerTask(task);
  38180. if (task.terminated) {
  38181. return;
  38182. }
  38183. throw reason;
  38184. });
  38185. });
  38186. });
  38187. handler.on('Cleanup', function wphCleanup(data) {
  38188. return pdfManager.cleanup();
  38189. });
  38190. handler.on('Terminate', function wphTerminate(data) {
  38191. terminated = true;
  38192. if (pdfManager) {
  38193. pdfManager.terminate();
  38194. pdfManager = null;
  38195. }
  38196. if (cancelXHRs) {
  38197. cancelXHRs();
  38198. }
  38199. var waitOn = [];
  38200. WorkerTasks.forEach(function (task) {
  38201. waitOn.push(task.finished);
  38202. task.terminate();
  38203. });
  38204. return Promise.all(waitOn).then(function () {
  38205. handler.destroy();
  38206. handler = null;
  38207. });
  38208. });
  38209. handler.on('Ready', function wphReady(data) {
  38210. setupDoc(docParams);
  38211. docParams = null;
  38212. });
  38213. return workerHandlerName;
  38214. }
  38215. };
  38216. function initializeWorker() {
  38217. var handler = new MessageHandler('worker', 'main', self);
  38218. WorkerMessageHandler.setup(handler, self);
  38219. handler.send('ready', null);
  38220. }
  38221. if (typeof window === 'undefined' && !isNodeJS()) {
  38222. initializeWorker();
  38223. }
  38224. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38225. exports.WorkerTask = WorkerTask;
  38226. exports.WorkerMessageHandler = WorkerMessageHandler;
  38227. /***/ }),
  38228. /* 24 */
  38229. /***/ (function(module, exports, __w_pdfjs_require__) {
  38230. "use strict";
  38231. var sharedUtil = __w_pdfjs_require__(0);
  38232. var error = sharedUtil.error;
  38233. function fixMetadata(meta) {
  38234. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38235. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38236. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38237. });
  38238. var chars = '';
  38239. for (var i = 0; i < bytes.length; i += 2) {
  38240. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38241. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38242. }
  38243. return '>' + chars;
  38244. });
  38245. }
  38246. function Metadata(meta) {
  38247. if (typeof meta === 'string') {
  38248. meta = fixMetadata(meta);
  38249. var parser = new DOMParser();
  38250. meta = parser.parseFromString(meta, 'application/xml');
  38251. } else if (!(meta instanceof Document)) {
  38252. error('Metadata: Invalid metadata object');
  38253. }
  38254. this.metaDocument = meta;
  38255. this.metadata = Object.create(null);
  38256. this.parse();
  38257. }
  38258. Metadata.prototype = {
  38259. parse: function Metadata_parse() {
  38260. var doc = this.metaDocument;
  38261. var rdf = doc.documentElement;
  38262. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38263. rdf = rdf.firstChild;
  38264. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38265. rdf = rdf.nextSibling;
  38266. }
  38267. }
  38268. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  38269. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  38270. return;
  38271. }
  38272. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  38273. for (i = 0, length = children.length; i < length; i++) {
  38274. desc = children[i];
  38275. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  38276. continue;
  38277. }
  38278. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  38279. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  38280. entry = desc.childNodes[ii];
  38281. name = entry.nodeName.toLowerCase();
  38282. this.metadata[name] = entry.textContent.trim();
  38283. }
  38284. }
  38285. }
  38286. },
  38287. get: function Metadata_get(name) {
  38288. return this.metadata[name] || null;
  38289. },
  38290. has: function Metadata_has(name) {
  38291. return typeof this.metadata[name] !== 'undefined';
  38292. }
  38293. };
  38294. exports.Metadata = Metadata;
  38295. /***/ }),
  38296. /* 25 */
  38297. /***/ (function(module, exports, __w_pdfjs_require__) {
  38298. "use strict";
  38299. var sharedUtil = __w_pdfjs_require__(0);
  38300. var displayDOMUtils = __w_pdfjs_require__(3);
  38301. var shadow = sharedUtil.shadow;
  38302. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  38303. var WebGLUtils = function WebGLUtilsClosure() {
  38304. function loadShader(gl, code, shaderType) {
  38305. var shader = gl.createShader(shaderType);
  38306. gl.shaderSource(shader, code);
  38307. gl.compileShader(shader);
  38308. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  38309. if (!compiled) {
  38310. var errorMsg = gl.getShaderInfoLog(shader);
  38311. throw new Error('Error during shader compilation: ' + errorMsg);
  38312. }
  38313. return shader;
  38314. }
  38315. function createVertexShader(gl, code) {
  38316. return loadShader(gl, code, gl.VERTEX_SHADER);
  38317. }
  38318. function createFragmentShader(gl, code) {
  38319. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  38320. }
  38321. function createProgram(gl, shaders) {
  38322. var program = gl.createProgram();
  38323. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  38324. gl.attachShader(program, shaders[i]);
  38325. }
  38326. gl.linkProgram(program);
  38327. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  38328. if (!linked) {
  38329. var errorMsg = gl.getProgramInfoLog(program);
  38330. throw new Error('Error during program linking: ' + errorMsg);
  38331. }
  38332. return program;
  38333. }
  38334. function createTexture(gl, image, textureId) {
  38335. gl.activeTexture(textureId);
  38336. var texture = gl.createTexture();
  38337. gl.bindTexture(gl.TEXTURE_2D, texture);
  38338. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  38339. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  38340. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  38341. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  38342. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  38343. return texture;
  38344. }
  38345. var currentGL, currentCanvas;
  38346. function generateGL() {
  38347. if (currentGL) {
  38348. return;
  38349. }
  38350. currentCanvas = document.createElement('canvas');
  38351. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  38352. }
  38353. var smaskVertexShaderCode = '\
  38354. attribute vec2 a_position; \
  38355. attribute vec2 a_texCoord; \
  38356. \
  38357. uniform vec2 u_resolution; \
  38358. \
  38359. varying vec2 v_texCoord; \
  38360. \
  38361. void main() { \
  38362. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  38363. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38364. \
  38365. v_texCoord = a_texCoord; \
  38366. } ';
  38367. var smaskFragmentShaderCode = '\
  38368. precision mediump float; \
  38369. \
  38370. uniform vec4 u_backdrop; \
  38371. uniform int u_subtype; \
  38372. uniform sampler2D u_image; \
  38373. uniform sampler2D u_mask; \
  38374. \
  38375. varying vec2 v_texCoord; \
  38376. \
  38377. void main() { \
  38378. vec4 imageColor = texture2D(u_image, v_texCoord); \
  38379. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  38380. if (u_backdrop.a > 0.0) { \
  38381. maskColor.rgb = maskColor.rgb * maskColor.a + \
  38382. u_backdrop.rgb * (1.0 - maskColor.a); \
  38383. } \
  38384. float lum; \
  38385. if (u_subtype == 0) { \
  38386. lum = maskColor.a; \
  38387. } else { \
  38388. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  38389. maskColor.b * 0.11; \
  38390. } \
  38391. imageColor.a *= lum; \
  38392. imageColor.rgb *= imageColor.a; \
  38393. gl_FragColor = imageColor; \
  38394. } ';
  38395. var smaskCache = null;
  38396. function initSmaskGL() {
  38397. var canvas, gl;
  38398. generateGL();
  38399. canvas = currentCanvas;
  38400. currentCanvas = null;
  38401. gl = currentGL;
  38402. currentGL = null;
  38403. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  38404. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  38405. var program = createProgram(gl, [
  38406. vertexShader,
  38407. fragmentShader
  38408. ]);
  38409. gl.useProgram(program);
  38410. var cache = {};
  38411. cache.gl = gl;
  38412. cache.canvas = canvas;
  38413. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38414. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38415. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  38416. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  38417. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  38418. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  38419. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  38420. var texCoordBuffer = gl.createBuffer();
  38421. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  38422. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38423. 0.0,
  38424. 0.0,
  38425. 1.0,
  38426. 0.0,
  38427. 0.0,
  38428. 1.0,
  38429. 0.0,
  38430. 1.0,
  38431. 1.0,
  38432. 0.0,
  38433. 1.0,
  38434. 1.0
  38435. ]), gl.STATIC_DRAW);
  38436. gl.enableVertexAttribArray(texCoordLocation);
  38437. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  38438. gl.uniform1i(texLayerLocation, 0);
  38439. gl.uniform1i(texMaskLocation, 1);
  38440. smaskCache = cache;
  38441. }
  38442. function composeSMask(layer, mask, properties) {
  38443. var width = layer.width, height = layer.height;
  38444. if (!smaskCache) {
  38445. initSmaskGL();
  38446. }
  38447. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  38448. canvas.width = width;
  38449. canvas.height = height;
  38450. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38451. gl.uniform2f(cache.resolutionLocation, width, height);
  38452. if (properties.backdrop) {
  38453. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  38454. } else {
  38455. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  38456. }
  38457. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  38458. var texture = createTexture(gl, layer, gl.TEXTURE0);
  38459. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  38460. var buffer = gl.createBuffer();
  38461. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  38462. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38463. 0,
  38464. 0,
  38465. width,
  38466. 0,
  38467. 0,
  38468. height,
  38469. 0,
  38470. height,
  38471. width,
  38472. 0,
  38473. width,
  38474. height
  38475. ]), gl.STATIC_DRAW);
  38476. gl.enableVertexAttribArray(cache.positionLocation);
  38477. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38478. gl.clearColor(0, 0, 0, 0);
  38479. gl.enable(gl.BLEND);
  38480. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  38481. gl.clear(gl.COLOR_BUFFER_BIT);
  38482. gl.drawArrays(gl.TRIANGLES, 0, 6);
  38483. gl.flush();
  38484. gl.deleteTexture(texture);
  38485. gl.deleteTexture(maskTexture);
  38486. gl.deleteBuffer(buffer);
  38487. return canvas;
  38488. }
  38489. var figuresVertexShaderCode = '\
  38490. attribute vec2 a_position; \
  38491. attribute vec3 a_color; \
  38492. \
  38493. uniform vec2 u_resolution; \
  38494. uniform vec2 u_scale; \
  38495. uniform vec2 u_offset; \
  38496. \
  38497. varying vec4 v_color; \
  38498. \
  38499. void main() { \
  38500. vec2 position = (a_position + u_offset) * u_scale; \
  38501. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  38502. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38503. \
  38504. v_color = vec4(a_color / 255.0, 1.0); \
  38505. } ';
  38506. var figuresFragmentShaderCode = '\
  38507. precision mediump float; \
  38508. \
  38509. varying vec4 v_color; \
  38510. \
  38511. void main() { \
  38512. gl_FragColor = v_color; \
  38513. } ';
  38514. var figuresCache = null;
  38515. function initFiguresGL() {
  38516. var canvas, gl;
  38517. generateGL();
  38518. canvas = currentCanvas;
  38519. currentCanvas = null;
  38520. gl = currentGL;
  38521. currentGL = null;
  38522. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  38523. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  38524. var program = createProgram(gl, [
  38525. vertexShader,
  38526. fragmentShader
  38527. ]);
  38528. gl.useProgram(program);
  38529. var cache = {};
  38530. cache.gl = gl;
  38531. cache.canvas = canvas;
  38532. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38533. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  38534. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  38535. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38536. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  38537. figuresCache = cache;
  38538. }
  38539. function drawFigures(width, height, backgroundColor, figures, context) {
  38540. if (!figuresCache) {
  38541. initFiguresGL();
  38542. }
  38543. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  38544. canvas.width = width;
  38545. canvas.height = height;
  38546. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38547. gl.uniform2f(cache.resolutionLocation, width, height);
  38548. var count = 0;
  38549. var i, ii, rows;
  38550. for (i = 0, ii = figures.length; i < ii; i++) {
  38551. switch (figures[i].type) {
  38552. case 'lattice':
  38553. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  38554. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  38555. break;
  38556. case 'triangles':
  38557. count += figures[i].coords.length;
  38558. break;
  38559. }
  38560. }
  38561. var coords = new Float32Array(count * 2);
  38562. var colors = new Uint8Array(count * 3);
  38563. var coordsMap = context.coords, colorsMap = context.colors;
  38564. var pIndex = 0, cIndex = 0;
  38565. for (i = 0, ii = figures.length; i < ii; i++) {
  38566. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  38567. switch (figure.type) {
  38568. case 'lattice':
  38569. var cols = figure.verticesPerRow;
  38570. rows = ps.length / cols | 0;
  38571. for (var row = 1; row < rows; row++) {
  38572. var offset = row * cols + 1;
  38573. for (var col = 1; col < cols; col++, offset++) {
  38574. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  38575. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  38576. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  38577. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  38578. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  38579. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  38580. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  38581. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  38582. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  38583. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  38584. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  38585. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  38586. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  38587. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  38588. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  38589. coords[pIndex + 6] = coords[pIndex + 2];
  38590. coords[pIndex + 7] = coords[pIndex + 3];
  38591. coords[pIndex + 8] = coords[pIndex + 4];
  38592. coords[pIndex + 9] = coords[pIndex + 5];
  38593. coords[pIndex + 10] = coordsMap[ps[offset]];
  38594. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  38595. colors[cIndex + 9] = colors[cIndex + 3];
  38596. colors[cIndex + 10] = colors[cIndex + 4];
  38597. colors[cIndex + 11] = colors[cIndex + 5];
  38598. colors[cIndex + 12] = colors[cIndex + 6];
  38599. colors[cIndex + 13] = colors[cIndex + 7];
  38600. colors[cIndex + 14] = colors[cIndex + 8];
  38601. colors[cIndex + 15] = colorsMap[cs[offset]];
  38602. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  38603. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  38604. pIndex += 12;
  38605. cIndex += 18;
  38606. }
  38607. }
  38608. break;
  38609. case 'triangles':
  38610. for (var j = 0, jj = ps.length; j < jj; j++) {
  38611. coords[pIndex] = coordsMap[ps[j]];
  38612. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  38613. colors[cIndex] = colorsMap[cs[j]];
  38614. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  38615. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  38616. pIndex += 2;
  38617. cIndex += 3;
  38618. }
  38619. break;
  38620. }
  38621. }
  38622. if (backgroundColor) {
  38623. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  38624. } else {
  38625. gl.clearColor(0, 0, 0, 0);
  38626. }
  38627. gl.clear(gl.COLOR_BUFFER_BIT);
  38628. var coordsBuffer = gl.createBuffer();
  38629. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  38630. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  38631. gl.enableVertexAttribArray(cache.positionLocation);
  38632. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38633. var colorsBuffer = gl.createBuffer();
  38634. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  38635. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  38636. gl.enableVertexAttribArray(cache.colorLocation);
  38637. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  38638. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  38639. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  38640. gl.drawArrays(gl.TRIANGLES, 0, count);
  38641. gl.flush();
  38642. gl.deleteBuffer(coordsBuffer);
  38643. gl.deleteBuffer(colorsBuffer);
  38644. return canvas;
  38645. }
  38646. function cleanup() {
  38647. if (smaskCache && smaskCache.canvas) {
  38648. smaskCache.canvas.width = 0;
  38649. smaskCache.canvas.height = 0;
  38650. }
  38651. if (figuresCache && figuresCache.canvas) {
  38652. figuresCache.canvas.width = 0;
  38653. figuresCache.canvas.height = 0;
  38654. }
  38655. smaskCache = null;
  38656. figuresCache = null;
  38657. }
  38658. return {
  38659. get isEnabled() {
  38660. if (getDefaultSetting('disableWebGL')) {
  38661. return false;
  38662. }
  38663. var enabled = false;
  38664. try {
  38665. generateGL();
  38666. enabled = !!currentGL;
  38667. } catch (e) {
  38668. }
  38669. return shadow(this, 'isEnabled', enabled);
  38670. },
  38671. composeSMask: composeSMask,
  38672. drawFigures: drawFigures,
  38673. clear: cleanup
  38674. };
  38675. }();
  38676. exports.WebGLUtils = WebGLUtils;
  38677. /***/ }),
  38678. /* 26 */
  38679. /***/ (function(module, exports, __w_pdfjs_require__) {
  38680. "use strict";
  38681. var sharedUtil = __w_pdfjs_require__(0);
  38682. var displayDOMUtils = __w_pdfjs_require__(3);
  38683. var displayAPI = __w_pdfjs_require__(10);
  38684. var displayAnnotationLayer = __w_pdfjs_require__(9);
  38685. var displayTextLayer = __w_pdfjs_require__(12);
  38686. var displayMetadata = __w_pdfjs_require__(24);
  38687. var displaySVG = __w_pdfjs_require__(11);
  38688. var globalScope = sharedUtil.globalScope;
  38689. var deprecated = sharedUtil.deprecated;
  38690. var warn = sharedUtil.warn;
  38691. var LinkTarget = displayDOMUtils.LinkTarget;
  38692. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  38693. var isWorker = typeof window === 'undefined';
  38694. if (!globalScope.PDFJS) {
  38695. globalScope.PDFJS = {};
  38696. }
  38697. var PDFJS = globalScope.PDFJS;
  38698. PDFJS.version = '1.7.387';
  38699. PDFJS.build = 'b6bf1a3e';
  38700. PDFJS.pdfBug = false;
  38701. if (PDFJS.verbosity !== undefined) {
  38702. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  38703. }
  38704. delete PDFJS.verbosity;
  38705. Object.defineProperty(PDFJS, 'verbosity', {
  38706. get: function () {
  38707. return sharedUtil.getVerbosityLevel();
  38708. },
  38709. set: function (level) {
  38710. sharedUtil.setVerbosityLevel(level);
  38711. },
  38712. enumerable: true,
  38713. configurable: true
  38714. });
  38715. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  38716. PDFJS.OPS = sharedUtil.OPS;
  38717. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38718. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  38719. PDFJS.shadow = sharedUtil.shadow;
  38720. PDFJS.createBlob = sharedUtil.createBlob;
  38721. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  38722. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  38723. };
  38724. Object.defineProperty(PDFJS, 'isLittleEndian', {
  38725. configurable: true,
  38726. get: function PDFJS_isLittleEndian() {
  38727. var value = sharedUtil.isLittleEndian();
  38728. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  38729. }
  38730. });
  38731. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  38732. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  38733. PDFJS.PasswordException = sharedUtil.PasswordException;
  38734. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  38735. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  38736. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  38737. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38738. PDFJS.Util = sharedUtil.Util;
  38739. PDFJS.PageViewport = sharedUtil.PageViewport;
  38740. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  38741. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  38742. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  38743. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  38744. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  38745. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  38746. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  38747. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  38748. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  38749. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  38750. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  38751. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  38752. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  38753. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  38754. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  38755. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  38756. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  38757. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  38758. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  38759. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  38760. delete PDFJS.openExternalLinksInNewWindow;
  38761. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  38762. get: function () {
  38763. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  38764. },
  38765. set: function (value) {
  38766. if (value) {
  38767. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  38768. }
  38769. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  38770. warn('PDFJS.externalLinkTarget is already initialized');
  38771. return;
  38772. }
  38773. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  38774. },
  38775. enumerable: true,
  38776. configurable: true
  38777. });
  38778. if (savedOpenExternalLinksInNewWindow) {
  38779. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  38780. }
  38781. PDFJS.getDocument = displayAPI.getDocument;
  38782. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  38783. PDFJS.PDFWorker = displayAPI.PDFWorker;
  38784. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  38785. configurable: true,
  38786. get: function PDFJS_hasCanvasTypedArrays() {
  38787. var value = displayDOMUtils.hasCanvasTypedArrays();
  38788. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  38789. }
  38790. });
  38791. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  38792. PDFJS.LinkTarget = LinkTarget;
  38793. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  38794. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  38795. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  38796. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  38797. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  38798. PDFJS.Metadata = displayMetadata.Metadata;
  38799. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  38800. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  38801. exports.globalScope = globalScope;
  38802. exports.isWorker = isWorker;
  38803. exports.PDFJS = globalScope.PDFJS;
  38804. /***/ }),
  38805. /* 27 */
  38806. /***/ (function(module, exports, __w_pdfjs_require__) {
  38807. "use strict";
  38808. var sharedUtil = __w_pdfjs_require__(0);
  38809. var corePrimitives = __w_pdfjs_require__(1);
  38810. var coreStream = __w_pdfjs_require__(2);
  38811. var coreColorSpace = __w_pdfjs_require__(4);
  38812. var coreObj = __w_pdfjs_require__(20);
  38813. var coreEvaluator = __w_pdfjs_require__(18);
  38814. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  38815. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  38816. var AnnotationFlag = sharedUtil.AnnotationFlag;
  38817. var AnnotationType = sharedUtil.AnnotationType;
  38818. var OPS = sharedUtil.OPS;
  38819. var Util = sharedUtil.Util;
  38820. var isArray = sharedUtil.isArray;
  38821. var isInt = sharedUtil.isInt;
  38822. var stringToBytes = sharedUtil.stringToBytes;
  38823. var stringToPDFString = sharedUtil.stringToPDFString;
  38824. var warn = sharedUtil.warn;
  38825. var Dict = corePrimitives.Dict;
  38826. var isDict = corePrimitives.isDict;
  38827. var isName = corePrimitives.isName;
  38828. var isRef = corePrimitives.isRef;
  38829. var isStream = corePrimitives.isStream;
  38830. var Stream = coreStream.Stream;
  38831. var ColorSpace = coreColorSpace.ColorSpace;
  38832. var Catalog = coreObj.Catalog;
  38833. var ObjectLoader = coreObj.ObjectLoader;
  38834. var FileSpec = coreObj.FileSpec;
  38835. var OperatorList = coreEvaluator.OperatorList;
  38836. function AnnotationFactory() {
  38837. }
  38838. AnnotationFactory.prototype = {
  38839. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  38840. var dict = xref.fetchIfRef(ref);
  38841. if (!isDict(dict)) {
  38842. return;
  38843. }
  38844. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  38845. var subtype = dict.get('Subtype');
  38846. subtype = isName(subtype) ? subtype.name : null;
  38847. var parameters = {
  38848. xref: xref,
  38849. dict: dict,
  38850. ref: isRef(ref) ? ref : null,
  38851. subtype: subtype,
  38852. id: id,
  38853. pdfManager: pdfManager
  38854. };
  38855. switch (subtype) {
  38856. case 'Link':
  38857. return new LinkAnnotation(parameters);
  38858. case 'Text':
  38859. return new TextAnnotation(parameters);
  38860. case 'Widget':
  38861. var fieldType = Util.getInheritableProperty(dict, 'FT');
  38862. fieldType = isName(fieldType) ? fieldType.name : null;
  38863. switch (fieldType) {
  38864. case 'Tx':
  38865. return new TextWidgetAnnotation(parameters);
  38866. case 'Btn':
  38867. return new ButtonWidgetAnnotation(parameters);
  38868. case 'Ch':
  38869. return new ChoiceWidgetAnnotation(parameters);
  38870. }
  38871. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  38872. return new WidgetAnnotation(parameters);
  38873. case 'Popup':
  38874. return new PopupAnnotation(parameters);
  38875. case 'Highlight':
  38876. return new HighlightAnnotation(parameters);
  38877. case 'Underline':
  38878. return new UnderlineAnnotation(parameters);
  38879. case 'Squiggly':
  38880. return new SquigglyAnnotation(parameters);
  38881. case 'StrikeOut':
  38882. return new StrikeOutAnnotation(parameters);
  38883. case 'FileAttachment':
  38884. return new FileAttachmentAnnotation(parameters);
  38885. default:
  38886. if (!subtype) {
  38887. warn('Annotation is missing the required /Subtype.');
  38888. } else {
  38889. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  38890. }
  38891. return new Annotation(parameters);
  38892. }
  38893. }
  38894. };
  38895. var Annotation = function AnnotationClosure() {
  38896. function getTransformMatrix(rect, bbox, matrix) {
  38897. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  38898. var minX = bounds[0];
  38899. var minY = bounds[1];
  38900. var maxX = bounds[2];
  38901. var maxY = bounds[3];
  38902. if (minX === maxX || minY === maxY) {
  38903. return [
  38904. 1,
  38905. 0,
  38906. 0,
  38907. 1,
  38908. rect[0],
  38909. rect[1]
  38910. ];
  38911. }
  38912. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  38913. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  38914. return [
  38915. xRatio,
  38916. 0,
  38917. 0,
  38918. yRatio,
  38919. rect[0] - minX * xRatio,
  38920. rect[1] - minY * yRatio
  38921. ];
  38922. }
  38923. function Annotation(params) {
  38924. var dict = params.dict;
  38925. this.setFlags(dict.get('F'));
  38926. this.setRectangle(dict.getArray('Rect'));
  38927. this.setColor(dict.getArray('C'));
  38928. this.setBorderStyle(dict);
  38929. this.setAppearance(dict);
  38930. this.data = {};
  38931. this.data.id = params.id;
  38932. this.data.subtype = params.subtype;
  38933. this.data.annotationFlags = this.flags;
  38934. this.data.rect = this.rectangle;
  38935. this.data.color = this.color;
  38936. this.data.borderStyle = this.borderStyle;
  38937. this.data.hasAppearance = !!this.appearance;
  38938. }
  38939. Annotation.prototype = {
  38940. _hasFlag: function Annotation_hasFlag(flags, flag) {
  38941. return !!(flags & flag);
  38942. },
  38943. _isViewable: function Annotation_isViewable(flags) {
  38944. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  38945. },
  38946. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  38947. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  38948. },
  38949. get viewable() {
  38950. if (this.flags === 0) {
  38951. return true;
  38952. }
  38953. return this._isViewable(this.flags);
  38954. },
  38955. get printable() {
  38956. if (this.flags === 0) {
  38957. return false;
  38958. }
  38959. return this._isPrintable(this.flags);
  38960. },
  38961. setFlags: function Annotation_setFlags(flags) {
  38962. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  38963. },
  38964. hasFlag: function Annotation_hasFlag(flag) {
  38965. return this._hasFlag(this.flags, flag);
  38966. },
  38967. setRectangle: function Annotation_setRectangle(rectangle) {
  38968. if (isArray(rectangle) && rectangle.length === 4) {
  38969. this.rectangle = Util.normalizeRect(rectangle);
  38970. } else {
  38971. this.rectangle = [
  38972. 0,
  38973. 0,
  38974. 0,
  38975. 0
  38976. ];
  38977. }
  38978. },
  38979. setColor: function Annotation_setColor(color) {
  38980. var rgbColor = new Uint8Array(3);
  38981. if (!isArray(color)) {
  38982. this.color = rgbColor;
  38983. return;
  38984. }
  38985. switch (color.length) {
  38986. case 0:
  38987. this.color = null;
  38988. break;
  38989. case 1:
  38990. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  38991. this.color = rgbColor;
  38992. break;
  38993. case 3:
  38994. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  38995. this.color = rgbColor;
  38996. break;
  38997. case 4:
  38998. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  38999. this.color = rgbColor;
  39000. break;
  39001. default:
  39002. this.color = rgbColor;
  39003. break;
  39004. }
  39005. },
  39006. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39007. this.borderStyle = new AnnotationBorderStyle();
  39008. if (!isDict(borderStyle)) {
  39009. return;
  39010. }
  39011. if (borderStyle.has('BS')) {
  39012. var dict = borderStyle.get('BS');
  39013. var dictType = dict.get('Type');
  39014. if (!dictType || isName(dictType, 'Border')) {
  39015. this.borderStyle.setWidth(dict.get('W'));
  39016. this.borderStyle.setStyle(dict.get('S'));
  39017. this.borderStyle.setDashArray(dict.getArray('D'));
  39018. }
  39019. } else if (borderStyle.has('Border')) {
  39020. var array = borderStyle.getArray('Border');
  39021. if (isArray(array) && array.length >= 3) {
  39022. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39023. this.borderStyle.setVerticalCornerRadius(array[1]);
  39024. this.borderStyle.setWidth(array[2]);
  39025. if (array.length === 4) {
  39026. this.borderStyle.setDashArray(array[3]);
  39027. }
  39028. }
  39029. } else {
  39030. this.borderStyle.setWidth(0);
  39031. }
  39032. },
  39033. setAppearance: function Annotation_setAppearance(dict) {
  39034. this.appearance = null;
  39035. var appearanceStates = dict.get('AP');
  39036. if (!isDict(appearanceStates)) {
  39037. return;
  39038. }
  39039. var normalAppearanceState = appearanceStates.get('N');
  39040. if (isStream(normalAppearanceState)) {
  39041. this.appearance = normalAppearanceState;
  39042. return;
  39043. }
  39044. if (!isDict(normalAppearanceState)) {
  39045. return;
  39046. }
  39047. var as = dict.get('AS');
  39048. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39049. return;
  39050. }
  39051. this.appearance = normalAppearanceState.get(as.name);
  39052. },
  39053. _preparePopup: function Annotation_preparePopup(dict) {
  39054. if (!dict.has('C')) {
  39055. this.data.color = null;
  39056. }
  39057. this.data.hasPopup = dict.has('Popup');
  39058. this.data.title = stringToPDFString(dict.get('T') || '');
  39059. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39060. },
  39061. loadResources: function Annotation_loadResources(keys) {
  39062. return new Promise(function (resolve, reject) {
  39063. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39064. if (!resources) {
  39065. resolve();
  39066. return;
  39067. }
  39068. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39069. objectLoader.load().then(function () {
  39070. resolve(resources);
  39071. }, reject);
  39072. }, reject);
  39073. }.bind(this));
  39074. },
  39075. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39076. if (!this.appearance) {
  39077. return Promise.resolve(new OperatorList());
  39078. }
  39079. var data = this.data;
  39080. var appearanceDict = this.appearance.dict;
  39081. var resourcesPromise = this.loadResources([
  39082. 'ExtGState',
  39083. 'ColorSpace',
  39084. 'Pattern',
  39085. 'Shading',
  39086. 'XObject',
  39087. 'Font'
  39088. ]);
  39089. var bbox = appearanceDict.getArray('BBox') || [
  39090. 0,
  39091. 0,
  39092. 1,
  39093. 1
  39094. ];
  39095. var matrix = appearanceDict.getArray('Matrix') || [
  39096. 1,
  39097. 0,
  39098. 0,
  39099. 1,
  39100. 0,
  39101. 0
  39102. ];
  39103. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39104. var self = this;
  39105. return resourcesPromise.then(function (resources) {
  39106. var opList = new OperatorList();
  39107. opList.addOp(OPS.beginAnnotation, [
  39108. data.rect,
  39109. transform,
  39110. matrix
  39111. ]);
  39112. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39113. opList.addOp(OPS.endAnnotation, []);
  39114. self.appearance.reset();
  39115. return opList;
  39116. });
  39117. });
  39118. }
  39119. };
  39120. return Annotation;
  39121. }();
  39122. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39123. function AnnotationBorderStyle() {
  39124. this.width = 1;
  39125. this.style = AnnotationBorderStyleType.SOLID;
  39126. this.dashArray = [3];
  39127. this.horizontalCornerRadius = 0;
  39128. this.verticalCornerRadius = 0;
  39129. }
  39130. AnnotationBorderStyle.prototype = {
  39131. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39132. if (width === (width | 0)) {
  39133. this.width = width;
  39134. }
  39135. },
  39136. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39137. if (!style) {
  39138. return;
  39139. }
  39140. switch (style.name) {
  39141. case 'S':
  39142. this.style = AnnotationBorderStyleType.SOLID;
  39143. break;
  39144. case 'D':
  39145. this.style = AnnotationBorderStyleType.DASHED;
  39146. break;
  39147. case 'B':
  39148. this.style = AnnotationBorderStyleType.BEVELED;
  39149. break;
  39150. case 'I':
  39151. this.style = AnnotationBorderStyleType.INSET;
  39152. break;
  39153. case 'U':
  39154. this.style = AnnotationBorderStyleType.UNDERLINE;
  39155. break;
  39156. default:
  39157. break;
  39158. }
  39159. },
  39160. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39161. if (isArray(dashArray) && dashArray.length > 0) {
  39162. var isValid = true;
  39163. var allZeros = true;
  39164. for (var i = 0, len = dashArray.length; i < len; i++) {
  39165. var element = dashArray[i];
  39166. var validNumber = +element >= 0;
  39167. if (!validNumber) {
  39168. isValid = false;
  39169. break;
  39170. } else if (element > 0) {
  39171. allZeros = false;
  39172. }
  39173. }
  39174. if (isValid && !allZeros) {
  39175. this.dashArray = dashArray;
  39176. } else {
  39177. this.width = 0;
  39178. }
  39179. } else if (dashArray) {
  39180. this.width = 0;
  39181. }
  39182. },
  39183. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39184. if (radius === (radius | 0)) {
  39185. this.horizontalCornerRadius = radius;
  39186. }
  39187. },
  39188. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39189. if (radius === (radius | 0)) {
  39190. this.verticalCornerRadius = radius;
  39191. }
  39192. }
  39193. };
  39194. return AnnotationBorderStyle;
  39195. }();
  39196. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39197. function WidgetAnnotation(params) {
  39198. Annotation.call(this, params);
  39199. var dict = params.dict;
  39200. var data = this.data;
  39201. data.annotationType = AnnotationType.WIDGET;
  39202. data.fieldName = this._constructFieldName(dict);
  39203. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39204. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39205. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39206. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39207. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39208. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39209. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39210. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39211. data.fieldFlags = 0;
  39212. }
  39213. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39214. if (data.fieldType === 'Sig') {
  39215. this.setFlags(AnnotationFlag.HIDDEN);
  39216. }
  39217. }
  39218. Util.inherit(WidgetAnnotation, Annotation, {
  39219. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39220. if (!dict.has('T') && !dict.has('Parent')) {
  39221. warn('Unknown field name, falling back to empty field name.');
  39222. return '';
  39223. }
  39224. if (!dict.has('Parent')) {
  39225. return stringToPDFString(dict.get('T'));
  39226. }
  39227. var fieldName = [];
  39228. if (dict.has('T')) {
  39229. fieldName.unshift(stringToPDFString(dict.get('T')));
  39230. }
  39231. var loopDict = dict;
  39232. while (loopDict.has('Parent')) {
  39233. loopDict = loopDict.get('Parent');
  39234. if (!isDict(loopDict)) {
  39235. break;
  39236. }
  39237. if (loopDict.has('T')) {
  39238. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  39239. }
  39240. }
  39241. return fieldName.join('.');
  39242. },
  39243. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  39244. return !!(this.data.fieldFlags & flag);
  39245. }
  39246. });
  39247. return WidgetAnnotation;
  39248. }();
  39249. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  39250. function TextWidgetAnnotation(params) {
  39251. WidgetAnnotation.call(this, params);
  39252. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  39253. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  39254. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  39255. alignment = null;
  39256. }
  39257. this.data.textAlignment = alignment;
  39258. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  39259. if (!isInt(maximumLength) || maximumLength < 0) {
  39260. maximumLength = null;
  39261. }
  39262. this.data.maxLen = maximumLength;
  39263. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  39264. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  39265. }
  39266. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  39267. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39268. var operatorList = new OperatorList();
  39269. if (renderForms) {
  39270. return Promise.resolve(operatorList);
  39271. }
  39272. if (this.appearance) {
  39273. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39274. }
  39275. if (!this.data.defaultAppearance) {
  39276. return Promise.resolve(operatorList);
  39277. }
  39278. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  39279. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  39280. return operatorList;
  39281. });
  39282. }
  39283. });
  39284. return TextWidgetAnnotation;
  39285. }();
  39286. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  39287. function ButtonWidgetAnnotation(params) {
  39288. WidgetAnnotation.call(this, params);
  39289. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39290. if (this.data.checkBox) {
  39291. if (!isName(this.data.fieldValue)) {
  39292. return;
  39293. }
  39294. this.data.fieldValue = this.data.fieldValue.name;
  39295. }
  39296. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39297. if (this.data.radioButton) {
  39298. this.data.fieldValue = this.data.buttonValue = null;
  39299. var fieldParent = params.dict.get('Parent');
  39300. if (isDict(fieldParent) && fieldParent.has('V')) {
  39301. var fieldParentValue = fieldParent.get('V');
  39302. if (isName(fieldParentValue)) {
  39303. this.data.fieldValue = fieldParentValue.name;
  39304. }
  39305. }
  39306. var appearanceStates = params.dict.get('AP');
  39307. if (!isDict(appearanceStates)) {
  39308. return;
  39309. }
  39310. var normalAppearanceState = appearanceStates.get('N');
  39311. if (!isDict(normalAppearanceState)) {
  39312. return;
  39313. }
  39314. var keys = normalAppearanceState.getKeys();
  39315. for (var i = 0, ii = keys.length; i < ii; i++) {
  39316. if (keys[i] !== 'Off') {
  39317. this.data.buttonValue = keys[i];
  39318. break;
  39319. }
  39320. }
  39321. }
  39322. }
  39323. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  39324. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39325. var operatorList = new OperatorList();
  39326. if (renderForms) {
  39327. return Promise.resolve(operatorList);
  39328. }
  39329. if (this.appearance) {
  39330. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39331. }
  39332. return Promise.resolve(operatorList);
  39333. }
  39334. });
  39335. return ButtonWidgetAnnotation;
  39336. }();
  39337. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  39338. function ChoiceWidgetAnnotation(params) {
  39339. WidgetAnnotation.call(this, params);
  39340. this.data.options = [];
  39341. var options = Util.getInheritableProperty(params.dict, 'Opt');
  39342. if (isArray(options)) {
  39343. var xref = params.xref;
  39344. for (var i = 0, ii = options.length; i < ii; i++) {
  39345. var option = xref.fetchIfRef(options[i]);
  39346. var isOptionArray = isArray(option);
  39347. this.data.options[i] = {
  39348. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  39349. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  39350. };
  39351. }
  39352. }
  39353. if (!isArray(this.data.fieldValue)) {
  39354. this.data.fieldValue = [this.data.fieldValue];
  39355. }
  39356. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  39357. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  39358. }
  39359. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  39360. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39361. var operatorList = new OperatorList();
  39362. if (renderForms) {
  39363. return Promise.resolve(operatorList);
  39364. }
  39365. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39366. }
  39367. });
  39368. return ChoiceWidgetAnnotation;
  39369. }();
  39370. var TextAnnotation = function TextAnnotationClosure() {
  39371. var DEFAULT_ICON_SIZE = 22;
  39372. function TextAnnotation(parameters) {
  39373. Annotation.call(this, parameters);
  39374. this.data.annotationType = AnnotationType.TEXT;
  39375. if (this.data.hasAppearance) {
  39376. this.data.name = 'NoIcon';
  39377. } else {
  39378. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  39379. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  39380. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  39381. }
  39382. this._preparePopup(parameters.dict);
  39383. }
  39384. Util.inherit(TextAnnotation, Annotation, {});
  39385. return TextAnnotation;
  39386. }();
  39387. var LinkAnnotation = function LinkAnnotationClosure() {
  39388. function LinkAnnotation(params) {
  39389. Annotation.call(this, params);
  39390. var data = this.data;
  39391. data.annotationType = AnnotationType.LINK;
  39392. Catalog.parseDestDictionary({
  39393. destDict: params.dict,
  39394. resultObj: data,
  39395. docBaseUrl: params.pdfManager.docBaseUrl
  39396. });
  39397. }
  39398. Util.inherit(LinkAnnotation, Annotation, {});
  39399. return LinkAnnotation;
  39400. }();
  39401. var PopupAnnotation = function PopupAnnotationClosure() {
  39402. function PopupAnnotation(parameters) {
  39403. Annotation.call(this, parameters);
  39404. this.data.annotationType = AnnotationType.POPUP;
  39405. var dict = parameters.dict;
  39406. var parentItem = dict.get('Parent');
  39407. if (!parentItem) {
  39408. warn('Popup annotation has a missing or invalid parent annotation.');
  39409. return;
  39410. }
  39411. this.data.parentId = dict.getRaw('Parent').toString();
  39412. this.data.title = stringToPDFString(parentItem.get('T') || '');
  39413. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  39414. if (!parentItem.has('C')) {
  39415. this.data.color = null;
  39416. } else {
  39417. this.setColor(parentItem.getArray('C'));
  39418. this.data.color = this.color;
  39419. }
  39420. if (!this.viewable) {
  39421. var parentFlags = parentItem.get('F');
  39422. if (this._isViewable(parentFlags)) {
  39423. this.setFlags(parentFlags);
  39424. }
  39425. }
  39426. }
  39427. Util.inherit(PopupAnnotation, Annotation, {});
  39428. return PopupAnnotation;
  39429. }();
  39430. var HighlightAnnotation = function HighlightAnnotationClosure() {
  39431. function HighlightAnnotation(parameters) {
  39432. Annotation.call(this, parameters);
  39433. this.data.annotationType = AnnotationType.HIGHLIGHT;
  39434. this._preparePopup(parameters.dict);
  39435. this.data.borderStyle.setWidth(0);
  39436. }
  39437. Util.inherit(HighlightAnnotation, Annotation, {});
  39438. return HighlightAnnotation;
  39439. }();
  39440. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  39441. function UnderlineAnnotation(parameters) {
  39442. Annotation.call(this, parameters);
  39443. this.data.annotationType = AnnotationType.UNDERLINE;
  39444. this._preparePopup(parameters.dict);
  39445. this.data.borderStyle.setWidth(0);
  39446. }
  39447. Util.inherit(UnderlineAnnotation, Annotation, {});
  39448. return UnderlineAnnotation;
  39449. }();
  39450. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  39451. function SquigglyAnnotation(parameters) {
  39452. Annotation.call(this, parameters);
  39453. this.data.annotationType = AnnotationType.SQUIGGLY;
  39454. this._preparePopup(parameters.dict);
  39455. this.data.borderStyle.setWidth(0);
  39456. }
  39457. Util.inherit(SquigglyAnnotation, Annotation, {});
  39458. return SquigglyAnnotation;
  39459. }();
  39460. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  39461. function StrikeOutAnnotation(parameters) {
  39462. Annotation.call(this, parameters);
  39463. this.data.annotationType = AnnotationType.STRIKEOUT;
  39464. this._preparePopup(parameters.dict);
  39465. this.data.borderStyle.setWidth(0);
  39466. }
  39467. Util.inherit(StrikeOutAnnotation, Annotation, {});
  39468. return StrikeOutAnnotation;
  39469. }();
  39470. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  39471. function FileAttachmentAnnotation(parameters) {
  39472. Annotation.call(this, parameters);
  39473. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  39474. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  39475. this.data.file = file.serializable;
  39476. this._preparePopup(parameters.dict);
  39477. }
  39478. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  39479. return FileAttachmentAnnotation;
  39480. }();
  39481. exports.Annotation = Annotation;
  39482. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  39483. exports.AnnotationFactory = AnnotationFactory;
  39484. /***/ }),
  39485. /* 28 */
  39486. /***/ (function(module, exports, __w_pdfjs_require__) {
  39487. "use strict";
  39488. var sharedUtil = __w_pdfjs_require__(0);
  39489. var warn = sharedUtil.warn;
  39490. var baseTypes = [
  39491. 'BN',
  39492. 'BN',
  39493. 'BN',
  39494. 'BN',
  39495. 'BN',
  39496. 'BN',
  39497. 'BN',
  39498. 'BN',
  39499. 'BN',
  39500. 'S',
  39501. 'B',
  39502. 'S',
  39503. 'WS',
  39504. 'B',
  39505. 'BN',
  39506. 'BN',
  39507. 'BN',
  39508. 'BN',
  39509. 'BN',
  39510. 'BN',
  39511. 'BN',
  39512. 'BN',
  39513. 'BN',
  39514. 'BN',
  39515. 'BN',
  39516. 'BN',
  39517. 'BN',
  39518. 'BN',
  39519. 'B',
  39520. 'B',
  39521. 'B',
  39522. 'S',
  39523. 'WS',
  39524. 'ON',
  39525. 'ON',
  39526. 'ET',
  39527. 'ET',
  39528. 'ET',
  39529. 'ON',
  39530. 'ON',
  39531. 'ON',
  39532. 'ON',
  39533. 'ON',
  39534. 'ES',
  39535. 'CS',
  39536. 'ES',
  39537. 'CS',
  39538. 'CS',
  39539. 'EN',
  39540. 'EN',
  39541. 'EN',
  39542. 'EN',
  39543. 'EN',
  39544. 'EN',
  39545. 'EN',
  39546. 'EN',
  39547. 'EN',
  39548. 'EN',
  39549. 'CS',
  39550. 'ON',
  39551. 'ON',
  39552. 'ON',
  39553. 'ON',
  39554. 'ON',
  39555. 'ON',
  39556. 'L',
  39557. 'L',
  39558. 'L',
  39559. 'L',
  39560. 'L',
  39561. 'L',
  39562. 'L',
  39563. 'L',
  39564. 'L',
  39565. 'L',
  39566. 'L',
  39567. 'L',
  39568. 'L',
  39569. 'L',
  39570. 'L',
  39571. 'L',
  39572. 'L',
  39573. 'L',
  39574. 'L',
  39575. 'L',
  39576. 'L',
  39577. 'L',
  39578. 'L',
  39579. 'L',
  39580. 'L',
  39581. 'L',
  39582. 'ON',
  39583. 'ON',
  39584. 'ON',
  39585. 'ON',
  39586. 'ON',
  39587. 'ON',
  39588. 'L',
  39589. 'L',
  39590. 'L',
  39591. 'L',
  39592. 'L',
  39593. 'L',
  39594. 'L',
  39595. 'L',
  39596. 'L',
  39597. 'L',
  39598. 'L',
  39599. 'L',
  39600. 'L',
  39601. 'L',
  39602. 'L',
  39603. 'L',
  39604. 'L',
  39605. 'L',
  39606. 'L',
  39607. 'L',
  39608. 'L',
  39609. 'L',
  39610. 'L',
  39611. 'L',
  39612. 'L',
  39613. 'L',
  39614. 'ON',
  39615. 'ON',
  39616. 'ON',
  39617. 'ON',
  39618. 'BN',
  39619. 'BN',
  39620. 'BN',
  39621. 'BN',
  39622. 'BN',
  39623. 'BN',
  39624. 'B',
  39625. 'BN',
  39626. 'BN',
  39627. 'BN',
  39628. 'BN',
  39629. 'BN',
  39630. 'BN',
  39631. 'BN',
  39632. 'BN',
  39633. 'BN',
  39634. 'BN',
  39635. 'BN',
  39636. 'BN',
  39637. 'BN',
  39638. 'BN',
  39639. 'BN',
  39640. 'BN',
  39641. 'BN',
  39642. 'BN',
  39643. 'BN',
  39644. 'BN',
  39645. 'BN',
  39646. 'BN',
  39647. 'BN',
  39648. 'BN',
  39649. 'BN',
  39650. 'BN',
  39651. 'CS',
  39652. 'ON',
  39653. 'ET',
  39654. 'ET',
  39655. 'ET',
  39656. 'ET',
  39657. 'ON',
  39658. 'ON',
  39659. 'ON',
  39660. 'ON',
  39661. 'L',
  39662. 'ON',
  39663. 'ON',
  39664. 'BN',
  39665. 'ON',
  39666. 'ON',
  39667. 'ET',
  39668. 'ET',
  39669. 'EN',
  39670. 'EN',
  39671. 'ON',
  39672. 'L',
  39673. 'ON',
  39674. 'ON',
  39675. 'ON',
  39676. 'EN',
  39677. 'L',
  39678. 'ON',
  39679. 'ON',
  39680. 'ON',
  39681. 'ON',
  39682. 'ON',
  39683. 'L',
  39684. 'L',
  39685. 'L',
  39686. 'L',
  39687. 'L',
  39688. 'L',
  39689. 'L',
  39690. 'L',
  39691. 'L',
  39692. 'L',
  39693. 'L',
  39694. 'L',
  39695. 'L',
  39696. 'L',
  39697. 'L',
  39698. 'L',
  39699. 'L',
  39700. 'L',
  39701. 'L',
  39702. 'L',
  39703. 'L',
  39704. 'L',
  39705. 'L',
  39706. 'ON',
  39707. 'L',
  39708. 'L',
  39709. 'L',
  39710. 'L',
  39711. 'L',
  39712. 'L',
  39713. 'L',
  39714. 'L',
  39715. 'L',
  39716. 'L',
  39717. 'L',
  39718. 'L',
  39719. 'L',
  39720. 'L',
  39721. 'L',
  39722. 'L',
  39723. 'L',
  39724. 'L',
  39725. 'L',
  39726. 'L',
  39727. 'L',
  39728. 'L',
  39729. 'L',
  39730. 'L',
  39731. 'L',
  39732. 'L',
  39733. 'L',
  39734. 'L',
  39735. 'L',
  39736. 'L',
  39737. 'L',
  39738. 'ON',
  39739. 'L',
  39740. 'L',
  39741. 'L',
  39742. 'L',
  39743. 'L',
  39744. 'L',
  39745. 'L',
  39746. 'L'
  39747. ];
  39748. var arabicTypes = [
  39749. 'AN',
  39750. 'AN',
  39751. 'AN',
  39752. 'AN',
  39753. 'AN',
  39754. 'AN',
  39755. 'ON',
  39756. 'ON',
  39757. 'AL',
  39758. 'ET',
  39759. 'ET',
  39760. 'AL',
  39761. 'CS',
  39762. 'AL',
  39763. 'ON',
  39764. 'ON',
  39765. 'NSM',
  39766. 'NSM',
  39767. 'NSM',
  39768. 'NSM',
  39769. 'NSM',
  39770. 'NSM',
  39771. 'NSM',
  39772. 'NSM',
  39773. 'NSM',
  39774. 'NSM',
  39775. 'NSM',
  39776. 'AL',
  39777. 'AL',
  39778. '',
  39779. 'AL',
  39780. 'AL',
  39781. 'AL',
  39782. 'AL',
  39783. 'AL',
  39784. 'AL',
  39785. 'AL',
  39786. 'AL',
  39787. 'AL',
  39788. 'AL',
  39789. 'AL',
  39790. 'AL',
  39791. 'AL',
  39792. 'AL',
  39793. 'AL',
  39794. 'AL',
  39795. 'AL',
  39796. 'AL',
  39797. 'AL',
  39798. 'AL',
  39799. 'AL',
  39800. 'AL',
  39801. 'AL',
  39802. 'AL',
  39803. 'AL',
  39804. 'AL',
  39805. 'AL',
  39806. 'AL',
  39807. 'AL',
  39808. 'AL',
  39809. 'AL',
  39810. 'AL',
  39811. 'AL',
  39812. 'AL',
  39813. 'AL',
  39814. 'AL',
  39815. 'AL',
  39816. 'AL',
  39817. 'AL',
  39818. 'AL',
  39819. 'AL',
  39820. 'AL',
  39821. 'AL',
  39822. 'AL',
  39823. 'AL',
  39824. 'NSM',
  39825. 'NSM',
  39826. 'NSM',
  39827. 'NSM',
  39828. 'NSM',
  39829. 'NSM',
  39830. 'NSM',
  39831. 'NSM',
  39832. 'NSM',
  39833. 'NSM',
  39834. 'NSM',
  39835. 'NSM',
  39836. 'NSM',
  39837. 'NSM',
  39838. 'NSM',
  39839. 'NSM',
  39840. 'NSM',
  39841. 'NSM',
  39842. 'NSM',
  39843. 'NSM',
  39844. 'NSM',
  39845. 'AN',
  39846. 'AN',
  39847. 'AN',
  39848. 'AN',
  39849. 'AN',
  39850. 'AN',
  39851. 'AN',
  39852. 'AN',
  39853. 'AN',
  39854. 'AN',
  39855. 'ET',
  39856. 'AN',
  39857. 'AN',
  39858. 'AL',
  39859. 'AL',
  39860. 'AL',
  39861. 'NSM',
  39862. 'AL',
  39863. 'AL',
  39864. 'AL',
  39865. 'AL',
  39866. 'AL',
  39867. 'AL',
  39868. 'AL',
  39869. 'AL',
  39870. 'AL',
  39871. 'AL',
  39872. 'AL',
  39873. 'AL',
  39874. 'AL',
  39875. 'AL',
  39876. 'AL',
  39877. 'AL',
  39878. 'AL',
  39879. 'AL',
  39880. 'AL',
  39881. 'AL',
  39882. 'AL',
  39883. 'AL',
  39884. 'AL',
  39885. 'AL',
  39886. 'AL',
  39887. 'AL',
  39888. 'AL',
  39889. 'AL',
  39890. 'AL',
  39891. 'AL',
  39892. 'AL',
  39893. 'AL',
  39894. 'AL',
  39895. 'AL',
  39896. 'AL',
  39897. 'AL',
  39898. 'AL',
  39899. 'AL',
  39900. 'AL',
  39901. 'AL',
  39902. 'AL',
  39903. 'AL',
  39904. 'AL',
  39905. 'AL',
  39906. 'AL',
  39907. 'AL',
  39908. 'AL',
  39909. 'AL',
  39910. 'AL',
  39911. 'AL',
  39912. 'AL',
  39913. 'AL',
  39914. 'AL',
  39915. 'AL',
  39916. 'AL',
  39917. 'AL',
  39918. 'AL',
  39919. 'AL',
  39920. 'AL',
  39921. 'AL',
  39922. 'AL',
  39923. 'AL',
  39924. 'AL',
  39925. 'AL',
  39926. 'AL',
  39927. 'AL',
  39928. 'AL',
  39929. 'AL',
  39930. 'AL',
  39931. 'AL',
  39932. 'AL',
  39933. 'AL',
  39934. 'AL',
  39935. 'AL',
  39936. 'AL',
  39937. 'AL',
  39938. 'AL',
  39939. 'AL',
  39940. 'AL',
  39941. 'AL',
  39942. 'AL',
  39943. 'AL',
  39944. 'AL',
  39945. 'AL',
  39946. 'AL',
  39947. 'AL',
  39948. 'AL',
  39949. 'AL',
  39950. 'AL',
  39951. 'AL',
  39952. 'AL',
  39953. 'AL',
  39954. 'AL',
  39955. 'AL',
  39956. 'AL',
  39957. 'AL',
  39958. 'AL',
  39959. 'AL',
  39960. 'AL',
  39961. 'AL',
  39962. 'AL',
  39963. 'NSM',
  39964. 'NSM',
  39965. 'NSM',
  39966. 'NSM',
  39967. 'NSM',
  39968. 'NSM',
  39969. 'NSM',
  39970. 'AN',
  39971. 'ON',
  39972. 'NSM',
  39973. 'NSM',
  39974. 'NSM',
  39975. 'NSM',
  39976. 'NSM',
  39977. 'NSM',
  39978. 'AL',
  39979. 'AL',
  39980. 'NSM',
  39981. 'NSM',
  39982. 'ON',
  39983. 'NSM',
  39984. 'NSM',
  39985. 'NSM',
  39986. 'NSM',
  39987. 'AL',
  39988. 'AL',
  39989. 'EN',
  39990. 'EN',
  39991. 'EN',
  39992. 'EN',
  39993. 'EN',
  39994. 'EN',
  39995. 'EN',
  39996. 'EN',
  39997. 'EN',
  39998. 'EN',
  39999. 'AL',
  40000. 'AL',
  40001. 'AL',
  40002. 'AL',
  40003. 'AL',
  40004. 'AL'
  40005. ];
  40006. function isOdd(i) {
  40007. return (i & 1) !== 0;
  40008. }
  40009. function isEven(i) {
  40010. return (i & 1) === 0;
  40011. }
  40012. function findUnequal(arr, start, value) {
  40013. for (var j = start, jj = arr.length; j < jj; ++j) {
  40014. if (arr[j] !== value) {
  40015. return j;
  40016. }
  40017. }
  40018. return j;
  40019. }
  40020. function setValues(arr, start, end, value) {
  40021. for (var j = start; j < end; ++j) {
  40022. arr[j] = value;
  40023. }
  40024. }
  40025. function reverseValues(arr, start, end) {
  40026. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40027. var temp = arr[i];
  40028. arr[i] = arr[j];
  40029. arr[j] = temp;
  40030. }
  40031. }
  40032. function createBidiText(str, isLTR, vertical) {
  40033. return {
  40034. str: str,
  40035. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40036. };
  40037. }
  40038. var chars = [];
  40039. var types = [];
  40040. function bidi(str, startLevel, vertical) {
  40041. var isLTR = true;
  40042. var strLength = str.length;
  40043. if (strLength === 0 || vertical) {
  40044. return createBidiText(str, isLTR, vertical);
  40045. }
  40046. chars.length = strLength;
  40047. types.length = strLength;
  40048. var numBidi = 0;
  40049. var i, ii;
  40050. for (i = 0; i < strLength; ++i) {
  40051. chars[i] = str.charAt(i);
  40052. var charCode = str.charCodeAt(i);
  40053. var charType = 'L';
  40054. if (charCode <= 0x00ff) {
  40055. charType = baseTypes[charCode];
  40056. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40057. charType = 'R';
  40058. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40059. charType = arabicTypes[charCode & 0xff];
  40060. if (!charType) {
  40061. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40062. }
  40063. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40064. charType = 'AL';
  40065. }
  40066. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40067. numBidi++;
  40068. }
  40069. types[i] = charType;
  40070. }
  40071. if (numBidi === 0) {
  40072. isLTR = true;
  40073. return createBidiText(str, isLTR);
  40074. }
  40075. if (startLevel === -1) {
  40076. if (numBidi / strLength < 0.3) {
  40077. isLTR = true;
  40078. startLevel = 0;
  40079. } else {
  40080. isLTR = false;
  40081. startLevel = 1;
  40082. }
  40083. }
  40084. var levels = [];
  40085. for (i = 0; i < strLength; ++i) {
  40086. levels[i] = startLevel;
  40087. }
  40088. var e = isOdd(startLevel) ? 'R' : 'L';
  40089. var sor = e;
  40090. var eor = sor;
  40091. var lastType = sor;
  40092. for (i = 0; i < strLength; ++i) {
  40093. if (types[i] === 'NSM') {
  40094. types[i] = lastType;
  40095. } else {
  40096. lastType = types[i];
  40097. }
  40098. }
  40099. lastType = sor;
  40100. var t;
  40101. for (i = 0; i < strLength; ++i) {
  40102. t = types[i];
  40103. if (t === 'EN') {
  40104. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40105. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40106. lastType = t;
  40107. }
  40108. }
  40109. for (i = 0; i < strLength; ++i) {
  40110. t = types[i];
  40111. if (t === 'AL') {
  40112. types[i] = 'R';
  40113. }
  40114. }
  40115. for (i = 1; i < strLength - 1; ++i) {
  40116. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40117. types[i] = 'EN';
  40118. }
  40119. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40120. types[i] = types[i - 1];
  40121. }
  40122. }
  40123. for (i = 0; i < strLength; ++i) {
  40124. if (types[i] === 'EN') {
  40125. var j;
  40126. for (j = i - 1; j >= 0; --j) {
  40127. if (types[j] !== 'ET') {
  40128. break;
  40129. }
  40130. types[j] = 'EN';
  40131. }
  40132. for (j = i + 1; j < strLength; ++j) {
  40133. if (types[j] !== 'ET') {
  40134. break;
  40135. }
  40136. types[j] = 'EN';
  40137. }
  40138. }
  40139. }
  40140. for (i = 0; i < strLength; ++i) {
  40141. t = types[i];
  40142. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40143. types[i] = 'ON';
  40144. }
  40145. }
  40146. lastType = sor;
  40147. for (i = 0; i < strLength; ++i) {
  40148. t = types[i];
  40149. if (t === 'EN') {
  40150. types[i] = lastType === 'L' ? 'L' : 'EN';
  40151. } else if (t === 'R' || t === 'L') {
  40152. lastType = t;
  40153. }
  40154. }
  40155. for (i = 0; i < strLength; ++i) {
  40156. if (types[i] === 'ON') {
  40157. var end = findUnequal(types, i + 1, 'ON');
  40158. var before = sor;
  40159. if (i > 0) {
  40160. before = types[i - 1];
  40161. }
  40162. var after = eor;
  40163. if (end + 1 < strLength) {
  40164. after = types[end + 1];
  40165. }
  40166. if (before !== 'L') {
  40167. before = 'R';
  40168. }
  40169. if (after !== 'L') {
  40170. after = 'R';
  40171. }
  40172. if (before === after) {
  40173. setValues(types, i, end, before);
  40174. }
  40175. i = end - 1;
  40176. }
  40177. }
  40178. for (i = 0; i < strLength; ++i) {
  40179. if (types[i] === 'ON') {
  40180. types[i] = e;
  40181. }
  40182. }
  40183. for (i = 0; i < strLength; ++i) {
  40184. t = types[i];
  40185. if (isEven(levels[i])) {
  40186. if (t === 'R') {
  40187. levels[i] += 1;
  40188. } else if (t === 'AN' || t === 'EN') {
  40189. levels[i] += 2;
  40190. }
  40191. } else {
  40192. if (t === 'L' || t === 'AN' || t === 'EN') {
  40193. levels[i] += 1;
  40194. }
  40195. }
  40196. }
  40197. var highestLevel = -1;
  40198. var lowestOddLevel = 99;
  40199. var level;
  40200. for (i = 0, ii = levels.length; i < ii; ++i) {
  40201. level = levels[i];
  40202. if (highestLevel < level) {
  40203. highestLevel = level;
  40204. }
  40205. if (lowestOddLevel > level && isOdd(level)) {
  40206. lowestOddLevel = level;
  40207. }
  40208. }
  40209. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40210. var start = -1;
  40211. for (i = 0, ii = levels.length; i < ii; ++i) {
  40212. if (levels[i] < level) {
  40213. if (start >= 0) {
  40214. reverseValues(chars, start, i);
  40215. start = -1;
  40216. }
  40217. } else if (start < 0) {
  40218. start = i;
  40219. }
  40220. }
  40221. if (start >= 0) {
  40222. reverseValues(chars, start, levels.length);
  40223. }
  40224. }
  40225. for (i = 0, ii = chars.length; i < ii; ++i) {
  40226. var ch = chars[i];
  40227. if (ch === '<' || ch === '>') {
  40228. chars[i] = '';
  40229. }
  40230. }
  40231. return createBidiText(chars.join(''), isLTR);
  40232. }
  40233. exports.bidi = bidi;
  40234. /***/ }),
  40235. /* 29 */
  40236. /***/ (function(module, exports, __w_pdfjs_require__) {
  40237. "use strict";
  40238. var ISOAdobeCharset = [
  40239. '.notdef',
  40240. 'space',
  40241. 'exclam',
  40242. 'quotedbl',
  40243. 'numbersign',
  40244. 'dollar',
  40245. 'percent',
  40246. 'ampersand',
  40247. 'quoteright',
  40248. 'parenleft',
  40249. 'parenright',
  40250. 'asterisk',
  40251. 'plus',
  40252. 'comma',
  40253. 'hyphen',
  40254. 'period',
  40255. 'slash',
  40256. 'zero',
  40257. 'one',
  40258. 'two',
  40259. 'three',
  40260. 'four',
  40261. 'five',
  40262. 'six',
  40263. 'seven',
  40264. 'eight',
  40265. 'nine',
  40266. 'colon',
  40267. 'semicolon',
  40268. 'less',
  40269. 'equal',
  40270. 'greater',
  40271. 'question',
  40272. 'at',
  40273. 'A',
  40274. 'B',
  40275. 'C',
  40276. 'D',
  40277. 'E',
  40278. 'F',
  40279. 'G',
  40280. 'H',
  40281. 'I',
  40282. 'J',
  40283. 'K',
  40284. 'L',
  40285. 'M',
  40286. 'N',
  40287. 'O',
  40288. 'P',
  40289. 'Q',
  40290. 'R',
  40291. 'S',
  40292. 'T',
  40293. 'U',
  40294. 'V',
  40295. 'W',
  40296. 'X',
  40297. 'Y',
  40298. 'Z',
  40299. 'bracketleft',
  40300. 'backslash',
  40301. 'bracketright',
  40302. 'asciicircum',
  40303. 'underscore',
  40304. 'quoteleft',
  40305. 'a',
  40306. 'b',
  40307. 'c',
  40308. 'd',
  40309. 'e',
  40310. 'f',
  40311. 'g',
  40312. 'h',
  40313. 'i',
  40314. 'j',
  40315. 'k',
  40316. 'l',
  40317. 'm',
  40318. 'n',
  40319. 'o',
  40320. 'p',
  40321. 'q',
  40322. 'r',
  40323. 's',
  40324. 't',
  40325. 'u',
  40326. 'v',
  40327. 'w',
  40328. 'x',
  40329. 'y',
  40330. 'z',
  40331. 'braceleft',
  40332. 'bar',
  40333. 'braceright',
  40334. 'asciitilde',
  40335. 'exclamdown',
  40336. 'cent',
  40337. 'sterling',
  40338. 'fraction',
  40339. 'yen',
  40340. 'florin',
  40341. 'section',
  40342. 'currency',
  40343. 'quotesingle',
  40344. 'quotedblleft',
  40345. 'guillemotleft',
  40346. 'guilsinglleft',
  40347. 'guilsinglright',
  40348. 'fi',
  40349. 'fl',
  40350. 'endash',
  40351. 'dagger',
  40352. 'daggerdbl',
  40353. 'periodcentered',
  40354. 'paragraph',
  40355. 'bullet',
  40356. 'quotesinglbase',
  40357. 'quotedblbase',
  40358. 'quotedblright',
  40359. 'guillemotright',
  40360. 'ellipsis',
  40361. 'perthousand',
  40362. 'questiondown',
  40363. 'grave',
  40364. 'acute',
  40365. 'circumflex',
  40366. 'tilde',
  40367. 'macron',
  40368. 'breve',
  40369. 'dotaccent',
  40370. 'dieresis',
  40371. 'ring',
  40372. 'cedilla',
  40373. 'hungarumlaut',
  40374. 'ogonek',
  40375. 'caron',
  40376. 'emdash',
  40377. 'AE',
  40378. 'ordfeminine',
  40379. 'Lslash',
  40380. 'Oslash',
  40381. 'OE',
  40382. 'ordmasculine',
  40383. 'ae',
  40384. 'dotlessi',
  40385. 'lslash',
  40386. 'oslash',
  40387. 'oe',
  40388. 'germandbls',
  40389. 'onesuperior',
  40390. 'logicalnot',
  40391. 'mu',
  40392. 'trademark',
  40393. 'Eth',
  40394. 'onehalf',
  40395. 'plusminus',
  40396. 'Thorn',
  40397. 'onequarter',
  40398. 'divide',
  40399. 'brokenbar',
  40400. 'degree',
  40401. 'thorn',
  40402. 'threequarters',
  40403. 'twosuperior',
  40404. 'registered',
  40405. 'minus',
  40406. 'eth',
  40407. 'multiply',
  40408. 'threesuperior',
  40409. 'copyright',
  40410. 'Aacute',
  40411. 'Acircumflex',
  40412. 'Adieresis',
  40413. 'Agrave',
  40414. 'Aring',
  40415. 'Atilde',
  40416. 'Ccedilla',
  40417. 'Eacute',
  40418. 'Ecircumflex',
  40419. 'Edieresis',
  40420. 'Egrave',
  40421. 'Iacute',
  40422. 'Icircumflex',
  40423. 'Idieresis',
  40424. 'Igrave',
  40425. 'Ntilde',
  40426. 'Oacute',
  40427. 'Ocircumflex',
  40428. 'Odieresis',
  40429. 'Ograve',
  40430. 'Otilde',
  40431. 'Scaron',
  40432. 'Uacute',
  40433. 'Ucircumflex',
  40434. 'Udieresis',
  40435. 'Ugrave',
  40436. 'Yacute',
  40437. 'Ydieresis',
  40438. 'Zcaron',
  40439. 'aacute',
  40440. 'acircumflex',
  40441. 'adieresis',
  40442. 'agrave',
  40443. 'aring',
  40444. 'atilde',
  40445. 'ccedilla',
  40446. 'eacute',
  40447. 'ecircumflex',
  40448. 'edieresis',
  40449. 'egrave',
  40450. 'iacute',
  40451. 'icircumflex',
  40452. 'idieresis',
  40453. 'igrave',
  40454. 'ntilde',
  40455. 'oacute',
  40456. 'ocircumflex',
  40457. 'odieresis',
  40458. 'ograve',
  40459. 'otilde',
  40460. 'scaron',
  40461. 'uacute',
  40462. 'ucircumflex',
  40463. 'udieresis',
  40464. 'ugrave',
  40465. 'yacute',
  40466. 'ydieresis',
  40467. 'zcaron'
  40468. ];
  40469. var ExpertCharset = [
  40470. '.notdef',
  40471. 'space',
  40472. 'exclamsmall',
  40473. 'Hungarumlautsmall',
  40474. 'dollaroldstyle',
  40475. 'dollarsuperior',
  40476. 'ampersandsmall',
  40477. 'Acutesmall',
  40478. 'parenleftsuperior',
  40479. 'parenrightsuperior',
  40480. 'twodotenleader',
  40481. 'onedotenleader',
  40482. 'comma',
  40483. 'hyphen',
  40484. 'period',
  40485. 'fraction',
  40486. 'zerooldstyle',
  40487. 'oneoldstyle',
  40488. 'twooldstyle',
  40489. 'threeoldstyle',
  40490. 'fouroldstyle',
  40491. 'fiveoldstyle',
  40492. 'sixoldstyle',
  40493. 'sevenoldstyle',
  40494. 'eightoldstyle',
  40495. 'nineoldstyle',
  40496. 'colon',
  40497. 'semicolon',
  40498. 'commasuperior',
  40499. 'threequartersemdash',
  40500. 'periodsuperior',
  40501. 'questionsmall',
  40502. 'asuperior',
  40503. 'bsuperior',
  40504. 'centsuperior',
  40505. 'dsuperior',
  40506. 'esuperior',
  40507. 'isuperior',
  40508. 'lsuperior',
  40509. 'msuperior',
  40510. 'nsuperior',
  40511. 'osuperior',
  40512. 'rsuperior',
  40513. 'ssuperior',
  40514. 'tsuperior',
  40515. 'ff',
  40516. 'fi',
  40517. 'fl',
  40518. 'ffi',
  40519. 'ffl',
  40520. 'parenleftinferior',
  40521. 'parenrightinferior',
  40522. 'Circumflexsmall',
  40523. 'hyphensuperior',
  40524. 'Gravesmall',
  40525. 'Asmall',
  40526. 'Bsmall',
  40527. 'Csmall',
  40528. 'Dsmall',
  40529. 'Esmall',
  40530. 'Fsmall',
  40531. 'Gsmall',
  40532. 'Hsmall',
  40533. 'Ismall',
  40534. 'Jsmall',
  40535. 'Ksmall',
  40536. 'Lsmall',
  40537. 'Msmall',
  40538. 'Nsmall',
  40539. 'Osmall',
  40540. 'Psmall',
  40541. 'Qsmall',
  40542. 'Rsmall',
  40543. 'Ssmall',
  40544. 'Tsmall',
  40545. 'Usmall',
  40546. 'Vsmall',
  40547. 'Wsmall',
  40548. 'Xsmall',
  40549. 'Ysmall',
  40550. 'Zsmall',
  40551. 'colonmonetary',
  40552. 'onefitted',
  40553. 'rupiah',
  40554. 'Tildesmall',
  40555. 'exclamdownsmall',
  40556. 'centoldstyle',
  40557. 'Lslashsmall',
  40558. 'Scaronsmall',
  40559. 'Zcaronsmall',
  40560. 'Dieresissmall',
  40561. 'Brevesmall',
  40562. 'Caronsmall',
  40563. 'Dotaccentsmall',
  40564. 'Macronsmall',
  40565. 'figuredash',
  40566. 'hypheninferior',
  40567. 'Ogoneksmall',
  40568. 'Ringsmall',
  40569. 'Cedillasmall',
  40570. 'onequarter',
  40571. 'onehalf',
  40572. 'threequarters',
  40573. 'questiondownsmall',
  40574. 'oneeighth',
  40575. 'threeeighths',
  40576. 'fiveeighths',
  40577. 'seveneighths',
  40578. 'onethird',
  40579. 'twothirds',
  40580. 'zerosuperior',
  40581. 'onesuperior',
  40582. 'twosuperior',
  40583. 'threesuperior',
  40584. 'foursuperior',
  40585. 'fivesuperior',
  40586. 'sixsuperior',
  40587. 'sevensuperior',
  40588. 'eightsuperior',
  40589. 'ninesuperior',
  40590. 'zeroinferior',
  40591. 'oneinferior',
  40592. 'twoinferior',
  40593. 'threeinferior',
  40594. 'fourinferior',
  40595. 'fiveinferior',
  40596. 'sixinferior',
  40597. 'seveninferior',
  40598. 'eightinferior',
  40599. 'nineinferior',
  40600. 'centinferior',
  40601. 'dollarinferior',
  40602. 'periodinferior',
  40603. 'commainferior',
  40604. 'Agravesmall',
  40605. 'Aacutesmall',
  40606. 'Acircumflexsmall',
  40607. 'Atildesmall',
  40608. 'Adieresissmall',
  40609. 'Aringsmall',
  40610. 'AEsmall',
  40611. 'Ccedillasmall',
  40612. 'Egravesmall',
  40613. 'Eacutesmall',
  40614. 'Ecircumflexsmall',
  40615. 'Edieresissmall',
  40616. 'Igravesmall',
  40617. 'Iacutesmall',
  40618. 'Icircumflexsmall',
  40619. 'Idieresissmall',
  40620. 'Ethsmall',
  40621. 'Ntildesmall',
  40622. 'Ogravesmall',
  40623. 'Oacutesmall',
  40624. 'Ocircumflexsmall',
  40625. 'Otildesmall',
  40626. 'Odieresissmall',
  40627. 'OEsmall',
  40628. 'Oslashsmall',
  40629. 'Ugravesmall',
  40630. 'Uacutesmall',
  40631. 'Ucircumflexsmall',
  40632. 'Udieresissmall',
  40633. 'Yacutesmall',
  40634. 'Thornsmall',
  40635. 'Ydieresissmall'
  40636. ];
  40637. var ExpertSubsetCharset = [
  40638. '.notdef',
  40639. 'space',
  40640. 'dollaroldstyle',
  40641. 'dollarsuperior',
  40642. 'parenleftsuperior',
  40643. 'parenrightsuperior',
  40644. 'twodotenleader',
  40645. 'onedotenleader',
  40646. 'comma',
  40647. 'hyphen',
  40648. 'period',
  40649. 'fraction',
  40650. 'zerooldstyle',
  40651. 'oneoldstyle',
  40652. 'twooldstyle',
  40653. 'threeoldstyle',
  40654. 'fouroldstyle',
  40655. 'fiveoldstyle',
  40656. 'sixoldstyle',
  40657. 'sevenoldstyle',
  40658. 'eightoldstyle',
  40659. 'nineoldstyle',
  40660. 'colon',
  40661. 'semicolon',
  40662. 'commasuperior',
  40663. 'threequartersemdash',
  40664. 'periodsuperior',
  40665. 'asuperior',
  40666. 'bsuperior',
  40667. 'centsuperior',
  40668. 'dsuperior',
  40669. 'esuperior',
  40670. 'isuperior',
  40671. 'lsuperior',
  40672. 'msuperior',
  40673. 'nsuperior',
  40674. 'osuperior',
  40675. 'rsuperior',
  40676. 'ssuperior',
  40677. 'tsuperior',
  40678. 'ff',
  40679. 'fi',
  40680. 'fl',
  40681. 'ffi',
  40682. 'ffl',
  40683. 'parenleftinferior',
  40684. 'parenrightinferior',
  40685. 'hyphensuperior',
  40686. 'colonmonetary',
  40687. 'onefitted',
  40688. 'rupiah',
  40689. 'centoldstyle',
  40690. 'figuredash',
  40691. 'hypheninferior',
  40692. 'onequarter',
  40693. 'onehalf',
  40694. 'threequarters',
  40695. 'oneeighth',
  40696. 'threeeighths',
  40697. 'fiveeighths',
  40698. 'seveneighths',
  40699. 'onethird',
  40700. 'twothirds',
  40701. 'zerosuperior',
  40702. 'onesuperior',
  40703. 'twosuperior',
  40704. 'threesuperior',
  40705. 'foursuperior',
  40706. 'fivesuperior',
  40707. 'sixsuperior',
  40708. 'sevensuperior',
  40709. 'eightsuperior',
  40710. 'ninesuperior',
  40711. 'zeroinferior',
  40712. 'oneinferior',
  40713. 'twoinferior',
  40714. 'threeinferior',
  40715. 'fourinferior',
  40716. 'fiveinferior',
  40717. 'sixinferior',
  40718. 'seveninferior',
  40719. 'eightinferior',
  40720. 'nineinferior',
  40721. 'centinferior',
  40722. 'dollarinferior',
  40723. 'periodinferior',
  40724. 'commainferior'
  40725. ];
  40726. exports.ISOAdobeCharset = ISOAdobeCharset;
  40727. exports.ExpertCharset = ExpertCharset;
  40728. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  40729. /***/ }),
  40730. /* 30 */
  40731. /***/ (function(module, exports, __w_pdfjs_require__) {
  40732. "use strict";
  40733. var sharedUtil = __w_pdfjs_require__(0);
  40734. var corePrimitives = __w_pdfjs_require__(1);
  40735. var coreStream = __w_pdfjs_require__(2);
  40736. var coreParser = __w_pdfjs_require__(6);
  40737. var Util = sharedUtil.Util;
  40738. var assert = sharedUtil.assert;
  40739. var warn = sharedUtil.warn;
  40740. var error = sharedUtil.error;
  40741. var isInt = sharedUtil.isInt;
  40742. var isString = sharedUtil.isString;
  40743. var MissingDataException = sharedUtil.MissingDataException;
  40744. var CMapCompressionType = sharedUtil.CMapCompressionType;
  40745. var isEOF = corePrimitives.isEOF;
  40746. var isName = corePrimitives.isName;
  40747. var isCmd = corePrimitives.isCmd;
  40748. var isStream = corePrimitives.isStream;
  40749. var Stream = coreStream.Stream;
  40750. var Lexer = coreParser.Lexer;
  40751. var BUILT_IN_CMAPS = [
  40752. 'Adobe-GB1-UCS2',
  40753. 'Adobe-CNS1-UCS2',
  40754. 'Adobe-Japan1-UCS2',
  40755. 'Adobe-Korea1-UCS2',
  40756. '78-EUC-H',
  40757. '78-EUC-V',
  40758. '78-H',
  40759. '78-RKSJ-H',
  40760. '78-RKSJ-V',
  40761. '78-V',
  40762. '78ms-RKSJ-H',
  40763. '78ms-RKSJ-V',
  40764. '83pv-RKSJ-H',
  40765. '90ms-RKSJ-H',
  40766. '90ms-RKSJ-V',
  40767. '90msp-RKSJ-H',
  40768. '90msp-RKSJ-V',
  40769. '90pv-RKSJ-H',
  40770. '90pv-RKSJ-V',
  40771. 'Add-H',
  40772. 'Add-RKSJ-H',
  40773. 'Add-RKSJ-V',
  40774. 'Add-V',
  40775. 'Adobe-CNS1-0',
  40776. 'Adobe-CNS1-1',
  40777. 'Adobe-CNS1-2',
  40778. 'Adobe-CNS1-3',
  40779. 'Adobe-CNS1-4',
  40780. 'Adobe-CNS1-5',
  40781. 'Adobe-CNS1-6',
  40782. 'Adobe-GB1-0',
  40783. 'Adobe-GB1-1',
  40784. 'Adobe-GB1-2',
  40785. 'Adobe-GB1-3',
  40786. 'Adobe-GB1-4',
  40787. 'Adobe-GB1-5',
  40788. 'Adobe-Japan1-0',
  40789. 'Adobe-Japan1-1',
  40790. 'Adobe-Japan1-2',
  40791. 'Adobe-Japan1-3',
  40792. 'Adobe-Japan1-4',
  40793. 'Adobe-Japan1-5',
  40794. 'Adobe-Japan1-6',
  40795. 'Adobe-Korea1-0',
  40796. 'Adobe-Korea1-1',
  40797. 'Adobe-Korea1-2',
  40798. 'B5-H',
  40799. 'B5-V',
  40800. 'B5pc-H',
  40801. 'B5pc-V',
  40802. 'CNS-EUC-H',
  40803. 'CNS-EUC-V',
  40804. 'CNS1-H',
  40805. 'CNS1-V',
  40806. 'CNS2-H',
  40807. 'CNS2-V',
  40808. 'ETHK-B5-H',
  40809. 'ETHK-B5-V',
  40810. 'ETen-B5-H',
  40811. 'ETen-B5-V',
  40812. 'ETenms-B5-H',
  40813. 'ETenms-B5-V',
  40814. 'EUC-H',
  40815. 'EUC-V',
  40816. 'Ext-H',
  40817. 'Ext-RKSJ-H',
  40818. 'Ext-RKSJ-V',
  40819. 'Ext-V',
  40820. 'GB-EUC-H',
  40821. 'GB-EUC-V',
  40822. 'GB-H',
  40823. 'GB-V',
  40824. 'GBK-EUC-H',
  40825. 'GBK-EUC-V',
  40826. 'GBK2K-H',
  40827. 'GBK2K-V',
  40828. 'GBKp-EUC-H',
  40829. 'GBKp-EUC-V',
  40830. 'GBT-EUC-H',
  40831. 'GBT-EUC-V',
  40832. 'GBT-H',
  40833. 'GBT-V',
  40834. 'GBTpc-EUC-H',
  40835. 'GBTpc-EUC-V',
  40836. 'GBpc-EUC-H',
  40837. 'GBpc-EUC-V',
  40838. 'H',
  40839. 'HKdla-B5-H',
  40840. 'HKdla-B5-V',
  40841. 'HKdlb-B5-H',
  40842. 'HKdlb-B5-V',
  40843. 'HKgccs-B5-H',
  40844. 'HKgccs-B5-V',
  40845. 'HKm314-B5-H',
  40846. 'HKm314-B5-V',
  40847. 'HKm471-B5-H',
  40848. 'HKm471-B5-V',
  40849. 'HKscs-B5-H',
  40850. 'HKscs-B5-V',
  40851. 'Hankaku',
  40852. 'Hiragana',
  40853. 'KSC-EUC-H',
  40854. 'KSC-EUC-V',
  40855. 'KSC-H',
  40856. 'KSC-Johab-H',
  40857. 'KSC-Johab-V',
  40858. 'KSC-V',
  40859. 'KSCms-UHC-H',
  40860. 'KSCms-UHC-HW-H',
  40861. 'KSCms-UHC-HW-V',
  40862. 'KSCms-UHC-V',
  40863. 'KSCpc-EUC-H',
  40864. 'KSCpc-EUC-V',
  40865. 'Katakana',
  40866. 'NWP-H',
  40867. 'NWP-V',
  40868. 'RKSJ-H',
  40869. 'RKSJ-V',
  40870. 'Roman',
  40871. 'UniCNS-UCS2-H',
  40872. 'UniCNS-UCS2-V',
  40873. 'UniCNS-UTF16-H',
  40874. 'UniCNS-UTF16-V',
  40875. 'UniCNS-UTF32-H',
  40876. 'UniCNS-UTF32-V',
  40877. 'UniCNS-UTF8-H',
  40878. 'UniCNS-UTF8-V',
  40879. 'UniGB-UCS2-H',
  40880. 'UniGB-UCS2-V',
  40881. 'UniGB-UTF16-H',
  40882. 'UniGB-UTF16-V',
  40883. 'UniGB-UTF32-H',
  40884. 'UniGB-UTF32-V',
  40885. 'UniGB-UTF8-H',
  40886. 'UniGB-UTF8-V',
  40887. 'UniJIS-UCS2-H',
  40888. 'UniJIS-UCS2-HW-H',
  40889. 'UniJIS-UCS2-HW-V',
  40890. 'UniJIS-UCS2-V',
  40891. 'UniJIS-UTF16-H',
  40892. 'UniJIS-UTF16-V',
  40893. 'UniJIS-UTF32-H',
  40894. 'UniJIS-UTF32-V',
  40895. 'UniJIS-UTF8-H',
  40896. 'UniJIS-UTF8-V',
  40897. 'UniJIS2004-UTF16-H',
  40898. 'UniJIS2004-UTF16-V',
  40899. 'UniJIS2004-UTF32-H',
  40900. 'UniJIS2004-UTF32-V',
  40901. 'UniJIS2004-UTF8-H',
  40902. 'UniJIS2004-UTF8-V',
  40903. 'UniJISPro-UCS2-HW-V',
  40904. 'UniJISPro-UCS2-V',
  40905. 'UniJISPro-UTF8-V',
  40906. 'UniJISX0213-UTF32-H',
  40907. 'UniJISX0213-UTF32-V',
  40908. 'UniJISX02132004-UTF32-H',
  40909. 'UniJISX02132004-UTF32-V',
  40910. 'UniKS-UCS2-H',
  40911. 'UniKS-UCS2-V',
  40912. 'UniKS-UTF16-H',
  40913. 'UniKS-UTF16-V',
  40914. 'UniKS-UTF32-H',
  40915. 'UniKS-UTF32-V',
  40916. 'UniKS-UTF8-H',
  40917. 'UniKS-UTF8-V',
  40918. 'V',
  40919. 'WP-Symbol'
  40920. ];
  40921. var CMap = function CMapClosure() {
  40922. function CMap(builtInCMap) {
  40923. this.codespaceRanges = [
  40924. [],
  40925. [],
  40926. [],
  40927. []
  40928. ];
  40929. this.numCodespaceRanges = 0;
  40930. this._map = [];
  40931. this.name = '';
  40932. this.vertical = false;
  40933. this.useCMap = null;
  40934. this.builtInCMap = builtInCMap;
  40935. }
  40936. CMap.prototype = {
  40937. addCodespaceRange: function (n, low, high) {
  40938. this.codespaceRanges[n - 1].push(low, high);
  40939. this.numCodespaceRanges++;
  40940. },
  40941. mapCidRange: function (low, high, dstLow) {
  40942. while (low <= high) {
  40943. this._map[low++] = dstLow++;
  40944. }
  40945. },
  40946. mapBfRange: function (low, high, dstLow) {
  40947. var lastByte = dstLow.length - 1;
  40948. while (low <= high) {
  40949. this._map[low++] = dstLow;
  40950. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40951. }
  40952. },
  40953. mapBfRangeToArray: function (low, high, array) {
  40954. var i = 0, ii = array.length;
  40955. while (low <= high && i < ii) {
  40956. this._map[low] = array[i++];
  40957. ++low;
  40958. }
  40959. },
  40960. mapOne: function (src, dst) {
  40961. this._map[src] = dst;
  40962. },
  40963. lookup: function (code) {
  40964. return this._map[code];
  40965. },
  40966. contains: function (code) {
  40967. return this._map[code] !== undefined;
  40968. },
  40969. forEach: function (callback) {
  40970. var map = this._map;
  40971. var length = map.length;
  40972. var i;
  40973. if (length <= 0x10000) {
  40974. for (i = 0; i < length; i++) {
  40975. if (map[i] !== undefined) {
  40976. callback(i, map[i]);
  40977. }
  40978. }
  40979. } else {
  40980. for (i in this._map) {
  40981. callback(i, map[i]);
  40982. }
  40983. }
  40984. },
  40985. charCodeOf: function (value) {
  40986. return this._map.indexOf(value);
  40987. },
  40988. getMap: function () {
  40989. return this._map;
  40990. },
  40991. readCharCode: function (str, offset, out) {
  40992. var c = 0;
  40993. var codespaceRanges = this.codespaceRanges;
  40994. var codespaceRangesLen = this.codespaceRanges.length;
  40995. for (var n = 0; n < codespaceRangesLen; n++) {
  40996. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  40997. var codespaceRange = codespaceRanges[n];
  40998. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  40999. var low = codespaceRange[k++];
  41000. var high = codespaceRange[k++];
  41001. if (c >= low && c <= high) {
  41002. out.charcode = c;
  41003. out.length = n + 1;
  41004. return;
  41005. }
  41006. }
  41007. }
  41008. out.charcode = 0;
  41009. out.length = 1;
  41010. },
  41011. get length() {
  41012. return this._map.length;
  41013. },
  41014. get isIdentityCMap() {
  41015. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41016. return false;
  41017. }
  41018. if (this._map.length !== 0x10000) {
  41019. return false;
  41020. }
  41021. for (var i = 0; i < 0x10000; i++) {
  41022. if (this._map[i] !== i) {
  41023. return false;
  41024. }
  41025. }
  41026. return true;
  41027. }
  41028. };
  41029. return CMap;
  41030. }();
  41031. var IdentityCMap = function IdentityCMapClosure() {
  41032. function IdentityCMap(vertical, n) {
  41033. CMap.call(this);
  41034. this.vertical = vertical;
  41035. this.addCodespaceRange(n, 0, 0xffff);
  41036. }
  41037. Util.inherit(IdentityCMap, CMap, {});
  41038. IdentityCMap.prototype = {
  41039. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41040. mapCidRange: function (low, high, dstLow) {
  41041. error('should not call mapCidRange');
  41042. },
  41043. mapBfRange: function (low, high, dstLow) {
  41044. error('should not call mapBfRange');
  41045. },
  41046. mapBfRangeToArray: function (low, high, array) {
  41047. error('should not call mapBfRangeToArray');
  41048. },
  41049. mapOne: function (src, dst) {
  41050. error('should not call mapCidOne');
  41051. },
  41052. lookup: function (code) {
  41053. return isInt(code) && code <= 0xffff ? code : undefined;
  41054. },
  41055. contains: function (code) {
  41056. return isInt(code) && code <= 0xffff;
  41057. },
  41058. forEach: function (callback) {
  41059. for (var i = 0; i <= 0xffff; i++) {
  41060. callback(i, i);
  41061. }
  41062. },
  41063. charCodeOf: function (value) {
  41064. return isInt(value) && value <= 0xffff ? value : -1;
  41065. },
  41066. getMap: function () {
  41067. var map = new Array(0x10000);
  41068. for (var i = 0; i <= 0xffff; i++) {
  41069. map[i] = i;
  41070. }
  41071. return map;
  41072. },
  41073. readCharCode: CMap.prototype.readCharCode,
  41074. get length() {
  41075. return 0x10000;
  41076. },
  41077. get isIdentityCMap() {
  41078. error('should not access .isIdentityCMap');
  41079. }
  41080. };
  41081. return IdentityCMap;
  41082. }();
  41083. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41084. function hexToInt(a, size) {
  41085. var n = 0;
  41086. for (var i = 0; i <= size; i++) {
  41087. n = n << 8 | a[i];
  41088. }
  41089. return n >>> 0;
  41090. }
  41091. function hexToStr(a, size) {
  41092. if (size === 1) {
  41093. return String.fromCharCode(a[0], a[1]);
  41094. }
  41095. if (size === 3) {
  41096. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41097. }
  41098. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41099. }
  41100. function addHex(a, b, size) {
  41101. var c = 0;
  41102. for (var i = size; i >= 0; i--) {
  41103. c += a[i] + b[i];
  41104. a[i] = c & 255;
  41105. c >>= 8;
  41106. }
  41107. }
  41108. function incHex(a, size) {
  41109. var c = 1;
  41110. for (var i = size; i >= 0 && c > 0; i--) {
  41111. c += a[i];
  41112. a[i] = c & 255;
  41113. c >>= 8;
  41114. }
  41115. }
  41116. var MAX_NUM_SIZE = 16;
  41117. var MAX_ENCODED_NUM_SIZE = 19;
  41118. function BinaryCMapStream(data) {
  41119. this.buffer = data;
  41120. this.pos = 0;
  41121. this.end = data.length;
  41122. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41123. }
  41124. BinaryCMapStream.prototype = {
  41125. readByte: function () {
  41126. if (this.pos >= this.end) {
  41127. return -1;
  41128. }
  41129. return this.buffer[this.pos++];
  41130. },
  41131. readNumber: function () {
  41132. var n = 0;
  41133. var last;
  41134. do {
  41135. var b = this.readByte();
  41136. if (b < 0) {
  41137. error('unexpected EOF in bcmap');
  41138. }
  41139. last = !(b & 0x80);
  41140. n = n << 7 | b & 0x7F;
  41141. } while (!last);
  41142. return n;
  41143. },
  41144. readSigned: function () {
  41145. var n = this.readNumber();
  41146. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41147. },
  41148. readHex: function (num, size) {
  41149. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41150. this.pos += size + 1;
  41151. },
  41152. readHexNumber: function (num, size) {
  41153. var last;
  41154. var stack = this.tmpBuf, sp = 0;
  41155. do {
  41156. var b = this.readByte();
  41157. if (b < 0) {
  41158. error('unexpected EOF in bcmap');
  41159. }
  41160. last = !(b & 0x80);
  41161. stack[sp++] = b & 0x7F;
  41162. } while (!last);
  41163. var i = size, buffer = 0, bufferSize = 0;
  41164. while (i >= 0) {
  41165. while (bufferSize < 8 && stack.length > 0) {
  41166. buffer = stack[--sp] << bufferSize | buffer;
  41167. bufferSize += 7;
  41168. }
  41169. num[i] = buffer & 255;
  41170. i--;
  41171. buffer >>= 8;
  41172. bufferSize -= 8;
  41173. }
  41174. },
  41175. readHexSigned: function (num, size) {
  41176. this.readHexNumber(num, size);
  41177. var sign = num[size] & 1 ? 255 : 0;
  41178. var c = 0;
  41179. for (var i = 0; i <= size; i++) {
  41180. c = (c & 1) << 8 | num[i];
  41181. num[i] = c >> 1 ^ sign;
  41182. }
  41183. },
  41184. readString: function () {
  41185. var len = this.readNumber();
  41186. var s = '';
  41187. for (var i = 0; i < len; i++) {
  41188. s += String.fromCharCode(this.readNumber());
  41189. }
  41190. return s;
  41191. }
  41192. };
  41193. function processBinaryCMap(data, cMap, extend) {
  41194. return new Promise(function (resolve, reject) {
  41195. var stream = new BinaryCMapStream(data);
  41196. var header = stream.readByte();
  41197. cMap.vertical = !!(header & 1);
  41198. var useCMap = null;
  41199. var start = new Uint8Array(MAX_NUM_SIZE);
  41200. var end = new Uint8Array(MAX_NUM_SIZE);
  41201. var char = new Uint8Array(MAX_NUM_SIZE);
  41202. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41203. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41204. var code;
  41205. var b;
  41206. while ((b = stream.readByte()) >= 0) {
  41207. var type = b >> 5;
  41208. if (type === 7) {
  41209. switch (b & 0x1F) {
  41210. case 0:
  41211. stream.readString();
  41212. break;
  41213. case 1:
  41214. useCMap = stream.readString();
  41215. break;
  41216. }
  41217. continue;
  41218. }
  41219. var sequence = !!(b & 0x10);
  41220. var dataSize = b & 15;
  41221. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41222. var ucs2DataSize = 1;
  41223. var subitemsCount = stream.readNumber();
  41224. var i;
  41225. switch (type) {
  41226. case 0:
  41227. stream.readHex(start, dataSize);
  41228. stream.readHexNumber(end, dataSize);
  41229. addHex(end, start, dataSize);
  41230. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41231. for (i = 1; i < subitemsCount; i++) {
  41232. incHex(end, dataSize);
  41233. stream.readHexNumber(start, dataSize);
  41234. addHex(start, end, dataSize);
  41235. stream.readHexNumber(end, dataSize);
  41236. addHex(end, start, dataSize);
  41237. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41238. }
  41239. break;
  41240. case 1:
  41241. stream.readHex(start, dataSize);
  41242. stream.readHexNumber(end, dataSize);
  41243. addHex(end, start, dataSize);
  41244. code = stream.readNumber();
  41245. for (i = 1; i < subitemsCount; i++) {
  41246. incHex(end, dataSize);
  41247. stream.readHexNumber(start, dataSize);
  41248. addHex(start, end, dataSize);
  41249. stream.readHexNumber(end, dataSize);
  41250. addHex(end, start, dataSize);
  41251. code = stream.readNumber();
  41252. }
  41253. break;
  41254. case 2:
  41255. stream.readHex(char, dataSize);
  41256. code = stream.readNumber();
  41257. cMap.mapOne(hexToInt(char, dataSize), code);
  41258. for (i = 1; i < subitemsCount; i++) {
  41259. incHex(char, dataSize);
  41260. if (!sequence) {
  41261. stream.readHexNumber(tmp, dataSize);
  41262. addHex(char, tmp, dataSize);
  41263. }
  41264. code = stream.readSigned() + (code + 1);
  41265. cMap.mapOne(hexToInt(char, dataSize), code);
  41266. }
  41267. break;
  41268. case 3:
  41269. stream.readHex(start, dataSize);
  41270. stream.readHexNumber(end, dataSize);
  41271. addHex(end, start, dataSize);
  41272. code = stream.readNumber();
  41273. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41274. for (i = 1; i < subitemsCount; i++) {
  41275. incHex(end, dataSize);
  41276. if (!sequence) {
  41277. stream.readHexNumber(start, dataSize);
  41278. addHex(start, end, dataSize);
  41279. } else {
  41280. start.set(end);
  41281. }
  41282. stream.readHexNumber(end, dataSize);
  41283. addHex(end, start, dataSize);
  41284. code = stream.readNumber();
  41285. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41286. }
  41287. break;
  41288. case 4:
  41289. stream.readHex(char, ucs2DataSize);
  41290. stream.readHex(charCode, dataSize);
  41291. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41292. for (i = 1; i < subitemsCount; i++) {
  41293. incHex(char, ucs2DataSize);
  41294. if (!sequence) {
  41295. stream.readHexNumber(tmp, ucs2DataSize);
  41296. addHex(char, tmp, ucs2DataSize);
  41297. }
  41298. incHex(charCode, dataSize);
  41299. stream.readHexSigned(tmp, dataSize);
  41300. addHex(charCode, tmp, dataSize);
  41301. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41302. }
  41303. break;
  41304. case 5:
  41305. stream.readHex(start, ucs2DataSize);
  41306. stream.readHexNumber(end, ucs2DataSize);
  41307. addHex(end, start, ucs2DataSize);
  41308. stream.readHex(charCode, dataSize);
  41309. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41310. for (i = 1; i < subitemsCount; i++) {
  41311. incHex(end, ucs2DataSize);
  41312. if (!sequence) {
  41313. stream.readHexNumber(start, ucs2DataSize);
  41314. addHex(start, end, ucs2DataSize);
  41315. } else {
  41316. start.set(end);
  41317. }
  41318. stream.readHexNumber(end, ucs2DataSize);
  41319. addHex(end, start, ucs2DataSize);
  41320. stream.readHex(charCode, dataSize);
  41321. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41322. }
  41323. break;
  41324. default:
  41325. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  41326. return;
  41327. }
  41328. }
  41329. if (useCMap) {
  41330. resolve(extend(useCMap));
  41331. return;
  41332. }
  41333. resolve(cMap);
  41334. });
  41335. }
  41336. function BinaryCMapReader() {
  41337. }
  41338. BinaryCMapReader.prototype = { process: processBinaryCMap };
  41339. return BinaryCMapReader;
  41340. }();
  41341. var CMapFactory = function CMapFactoryClosure() {
  41342. function strToInt(str) {
  41343. var a = 0;
  41344. for (var i = 0; i < str.length; i++) {
  41345. a = a << 8 | str.charCodeAt(i);
  41346. }
  41347. return a >>> 0;
  41348. }
  41349. function expectString(obj) {
  41350. if (!isString(obj)) {
  41351. error('Malformed CMap: expected string.');
  41352. }
  41353. }
  41354. function expectInt(obj) {
  41355. if (!isInt(obj)) {
  41356. error('Malformed CMap: expected int.');
  41357. }
  41358. }
  41359. function parseBfChar(cMap, lexer) {
  41360. while (true) {
  41361. var obj = lexer.getObj();
  41362. if (isEOF(obj)) {
  41363. break;
  41364. }
  41365. if (isCmd(obj, 'endbfchar')) {
  41366. return;
  41367. }
  41368. expectString(obj);
  41369. var src = strToInt(obj);
  41370. obj = lexer.getObj();
  41371. expectString(obj);
  41372. var dst = obj;
  41373. cMap.mapOne(src, dst);
  41374. }
  41375. }
  41376. function parseBfRange(cMap, lexer) {
  41377. while (true) {
  41378. var obj = lexer.getObj();
  41379. if (isEOF(obj)) {
  41380. break;
  41381. }
  41382. if (isCmd(obj, 'endbfrange')) {
  41383. return;
  41384. }
  41385. expectString(obj);
  41386. var low = strToInt(obj);
  41387. obj = lexer.getObj();
  41388. expectString(obj);
  41389. var high = strToInt(obj);
  41390. obj = lexer.getObj();
  41391. if (isInt(obj) || isString(obj)) {
  41392. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41393. cMap.mapBfRange(low, high, dstLow);
  41394. } else if (isCmd(obj, '[')) {
  41395. obj = lexer.getObj();
  41396. var array = [];
  41397. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41398. array.push(obj);
  41399. obj = lexer.getObj();
  41400. }
  41401. cMap.mapBfRangeToArray(low, high, array);
  41402. } else {
  41403. break;
  41404. }
  41405. }
  41406. error('Invalid bf range.');
  41407. }
  41408. function parseCidChar(cMap, lexer) {
  41409. while (true) {
  41410. var obj = lexer.getObj();
  41411. if (isEOF(obj)) {
  41412. break;
  41413. }
  41414. if (isCmd(obj, 'endcidchar')) {
  41415. return;
  41416. }
  41417. expectString(obj);
  41418. var src = strToInt(obj);
  41419. obj = lexer.getObj();
  41420. expectInt(obj);
  41421. var dst = obj;
  41422. cMap.mapOne(src, dst);
  41423. }
  41424. }
  41425. function parseCidRange(cMap, lexer) {
  41426. while (true) {
  41427. var obj = lexer.getObj();
  41428. if (isEOF(obj)) {
  41429. break;
  41430. }
  41431. if (isCmd(obj, 'endcidrange')) {
  41432. return;
  41433. }
  41434. expectString(obj);
  41435. var low = strToInt(obj);
  41436. obj = lexer.getObj();
  41437. expectString(obj);
  41438. var high = strToInt(obj);
  41439. obj = lexer.getObj();
  41440. expectInt(obj);
  41441. var dstLow = obj;
  41442. cMap.mapCidRange(low, high, dstLow);
  41443. }
  41444. }
  41445. function parseCodespaceRange(cMap, lexer) {
  41446. while (true) {
  41447. var obj = lexer.getObj();
  41448. if (isEOF(obj)) {
  41449. break;
  41450. }
  41451. if (isCmd(obj, 'endcodespacerange')) {
  41452. return;
  41453. }
  41454. if (!isString(obj)) {
  41455. break;
  41456. }
  41457. var low = strToInt(obj);
  41458. obj = lexer.getObj();
  41459. if (!isString(obj)) {
  41460. break;
  41461. }
  41462. var high = strToInt(obj);
  41463. cMap.addCodespaceRange(obj.length, low, high);
  41464. }
  41465. error('Invalid codespace range.');
  41466. }
  41467. function parseWMode(cMap, lexer) {
  41468. var obj = lexer.getObj();
  41469. if (isInt(obj)) {
  41470. cMap.vertical = !!obj;
  41471. }
  41472. }
  41473. function parseCMapName(cMap, lexer) {
  41474. var obj = lexer.getObj();
  41475. if (isName(obj) && isString(obj.name)) {
  41476. cMap.name = obj.name;
  41477. }
  41478. }
  41479. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  41480. var previous;
  41481. var embededUseCMap;
  41482. objLoop:
  41483. while (true) {
  41484. try {
  41485. var obj = lexer.getObj();
  41486. if (isEOF(obj)) {
  41487. break;
  41488. } else if (isName(obj)) {
  41489. if (obj.name === 'WMode') {
  41490. parseWMode(cMap, lexer);
  41491. } else if (obj.name === 'CMapName') {
  41492. parseCMapName(cMap, lexer);
  41493. }
  41494. previous = obj;
  41495. } else if (isCmd(obj)) {
  41496. switch (obj.cmd) {
  41497. case 'endcmap':
  41498. break objLoop;
  41499. case 'usecmap':
  41500. if (isName(previous)) {
  41501. embededUseCMap = previous.name;
  41502. }
  41503. break;
  41504. case 'begincodespacerange':
  41505. parseCodespaceRange(cMap, lexer);
  41506. break;
  41507. case 'beginbfchar':
  41508. parseBfChar(cMap, lexer);
  41509. break;
  41510. case 'begincidchar':
  41511. parseCidChar(cMap, lexer);
  41512. break;
  41513. case 'beginbfrange':
  41514. parseBfRange(cMap, lexer);
  41515. break;
  41516. case 'begincidrange':
  41517. parseCidRange(cMap, lexer);
  41518. break;
  41519. }
  41520. }
  41521. } catch (ex) {
  41522. if (ex instanceof MissingDataException) {
  41523. throw ex;
  41524. }
  41525. warn('Invalid cMap data: ' + ex);
  41526. continue;
  41527. }
  41528. }
  41529. if (!useCMap && embededUseCMap) {
  41530. useCMap = embededUseCMap;
  41531. }
  41532. if (useCMap) {
  41533. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41534. }
  41535. return Promise.resolve(cMap);
  41536. }
  41537. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  41538. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  41539. cMap.useCMap = newCMap;
  41540. if (cMap.numCodespaceRanges === 0) {
  41541. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41542. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41543. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41544. }
  41545. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41546. }
  41547. cMap.useCMap.forEach(function (key, value) {
  41548. if (!cMap.contains(key)) {
  41549. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41550. }
  41551. });
  41552. return cMap;
  41553. });
  41554. }
  41555. function createBuiltInCMap(name, fetchBuiltInCMap) {
  41556. if (name === 'Identity-H') {
  41557. return Promise.resolve(new IdentityCMap(false, 2));
  41558. } else if (name === 'Identity-V') {
  41559. return Promise.resolve(new IdentityCMap(true, 2));
  41560. }
  41561. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41562. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41563. }
  41564. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  41565. return fetchBuiltInCMap(name).then(function (data) {
  41566. var cMapData = data.cMapData, compressionType = data.compressionType;
  41567. var cMap = new CMap(true);
  41568. if (compressionType === CMapCompressionType.BINARY) {
  41569. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  41570. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41571. });
  41572. }
  41573. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  41574. var lexer = new Lexer(new Stream(cMapData));
  41575. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  41576. });
  41577. }
  41578. return {
  41579. create: function (params) {
  41580. var encoding = params.encoding;
  41581. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  41582. var useCMap = params.useCMap;
  41583. if (isName(encoding)) {
  41584. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  41585. } else if (isStream(encoding)) {
  41586. var cMap = new CMap();
  41587. var lexer = new Lexer(encoding);
  41588. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  41589. if (parsedCMap.isIdentityCMap) {
  41590. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  41591. }
  41592. return parsedCMap;
  41593. });
  41594. }
  41595. return Promise.reject(new Error('Encoding required.'));
  41596. }
  41597. };
  41598. }();
  41599. exports.CMap = CMap;
  41600. exports.CMapFactory = CMapFactory;
  41601. exports.IdentityCMap = IdentityCMap;
  41602. /***/ }),
  41603. /* 31 */
  41604. /***/ (function(module, exports, __w_pdfjs_require__) {
  41605. "use strict";
  41606. var sharedUtil = __w_pdfjs_require__(0);
  41607. var corePrimitives = __w_pdfjs_require__(1);
  41608. var coreStream = __w_pdfjs_require__(2);
  41609. var coreObj = __w_pdfjs_require__(20);
  41610. var coreParser = __w_pdfjs_require__(6);
  41611. var coreCrypto = __w_pdfjs_require__(17);
  41612. var coreEvaluator = __w_pdfjs_require__(18);
  41613. var coreAnnotation = __w_pdfjs_require__(27);
  41614. var OPS = sharedUtil.OPS;
  41615. var MissingDataException = sharedUtil.MissingDataException;
  41616. var Util = sharedUtil.Util;
  41617. var assert = sharedUtil.assert;
  41618. var error = sharedUtil.error;
  41619. var info = sharedUtil.info;
  41620. var isArray = sharedUtil.isArray;
  41621. var isArrayBuffer = sharedUtil.isArrayBuffer;
  41622. var isNum = sharedUtil.isNum;
  41623. var isString = sharedUtil.isString;
  41624. var shadow = sharedUtil.shadow;
  41625. var stringToBytes = sharedUtil.stringToBytes;
  41626. var stringToPDFString = sharedUtil.stringToPDFString;
  41627. var warn = sharedUtil.warn;
  41628. var isSpace = sharedUtil.isSpace;
  41629. var Dict = corePrimitives.Dict;
  41630. var isDict = corePrimitives.isDict;
  41631. var isName = corePrimitives.isName;
  41632. var isStream = corePrimitives.isStream;
  41633. var NullStream = coreStream.NullStream;
  41634. var Stream = coreStream.Stream;
  41635. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  41636. var Catalog = coreObj.Catalog;
  41637. var ObjectLoader = coreObj.ObjectLoader;
  41638. var XRef = coreObj.XRef;
  41639. var Linearization = coreParser.Linearization;
  41640. var calculateMD5 = coreCrypto.calculateMD5;
  41641. var OperatorList = coreEvaluator.OperatorList;
  41642. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  41643. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  41644. var Page = function PageClosure() {
  41645. var DEFAULT_USER_UNIT = 1.0;
  41646. var LETTER_SIZE_MEDIABOX = [
  41647. 0,
  41648. 0,
  41649. 612,
  41650. 792
  41651. ];
  41652. function isAnnotationRenderable(annotation, intent) {
  41653. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  41654. }
  41655. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  41656. this.pdfManager = pdfManager;
  41657. this.pageIndex = pageIndex;
  41658. this.pageDict = pageDict;
  41659. this.xref = xref;
  41660. this.ref = ref;
  41661. this.fontCache = fontCache;
  41662. this.builtInCMapCache = builtInCMapCache;
  41663. this.evaluatorOptions = pdfManager.evaluatorOptions;
  41664. this.resourcesPromise = null;
  41665. var uniquePrefix = 'p' + this.pageIndex + '_';
  41666. var idCounters = { obj: 0 };
  41667. this.idFactory = {
  41668. createObjId: function () {
  41669. return uniquePrefix + ++idCounters.obj;
  41670. }
  41671. };
  41672. }
  41673. Page.prototype = {
  41674. getPageProp: function Page_getPageProp(key) {
  41675. return this.pageDict.get(key);
  41676. },
  41677. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  41678. var dict = this.pageDict, valueArray = null, loopCount = 0;
  41679. var MAX_LOOP_COUNT = 100;
  41680. getArray = getArray || false;
  41681. while (dict) {
  41682. var value = getArray ? dict.getArray(key) : dict.get(key);
  41683. if (value !== undefined) {
  41684. if (!valueArray) {
  41685. valueArray = [];
  41686. }
  41687. valueArray.push(value);
  41688. }
  41689. if (++loopCount > MAX_LOOP_COUNT) {
  41690. warn('getInheritedPageProp: maximum loop count exceeded for ' + key);
  41691. return valueArray ? valueArray[0] : undefined;
  41692. }
  41693. dict = dict.get('Parent');
  41694. }
  41695. if (!valueArray) {
  41696. return undefined;
  41697. }
  41698. if (valueArray.length === 1 || !isDict(valueArray[0])) {
  41699. return valueArray[0];
  41700. }
  41701. return Dict.merge(this.xref, valueArray);
  41702. },
  41703. get content() {
  41704. return this.getPageProp('Contents');
  41705. },
  41706. get resources() {
  41707. return shadow(this, 'resources', this.getInheritedPageProp('Resources') || Dict.empty);
  41708. },
  41709. get mediaBox() {
  41710. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  41711. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  41712. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  41713. }
  41714. return shadow(this, 'mediaBox', mediaBox);
  41715. },
  41716. get cropBox() {
  41717. var cropBox = this.getInheritedPageProp('CropBox', true);
  41718. if (!isArray(cropBox) || cropBox.length !== 4) {
  41719. return shadow(this, 'cropBox', this.mediaBox);
  41720. }
  41721. return shadow(this, 'cropBox', cropBox);
  41722. },
  41723. get userUnit() {
  41724. var obj = this.getPageProp('UserUnit');
  41725. if (!isNum(obj) || obj <= 0) {
  41726. obj = DEFAULT_USER_UNIT;
  41727. }
  41728. return shadow(this, 'userUnit', obj);
  41729. },
  41730. get view() {
  41731. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  41732. if (mediaBox === cropBox) {
  41733. return shadow(this, 'view', mediaBox);
  41734. }
  41735. var intersection = Util.intersect(cropBox, mediaBox);
  41736. return shadow(this, 'view', intersection || mediaBox);
  41737. },
  41738. get rotate() {
  41739. var rotate = this.getInheritedPageProp('Rotate') || 0;
  41740. if (rotate % 90 !== 0) {
  41741. rotate = 0;
  41742. } else if (rotate >= 360) {
  41743. rotate = rotate % 360;
  41744. } else if (rotate < 0) {
  41745. rotate = (rotate % 360 + 360) % 360;
  41746. }
  41747. return shadow(this, 'rotate', rotate);
  41748. },
  41749. getContentStream: function Page_getContentStream() {
  41750. var content = this.content;
  41751. var stream;
  41752. if (isArray(content)) {
  41753. var xref = this.xref;
  41754. var i, n = content.length;
  41755. var streams = [];
  41756. for (i = 0; i < n; ++i) {
  41757. streams.push(xref.fetchIfRef(content[i]));
  41758. }
  41759. stream = new StreamsSequenceStream(streams);
  41760. } else if (isStream(content)) {
  41761. stream = content;
  41762. } else {
  41763. stream = new NullStream();
  41764. }
  41765. return stream;
  41766. },
  41767. loadResources: function Page_loadResources(keys) {
  41768. if (!this.resourcesPromise) {
  41769. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  41770. }
  41771. return this.resourcesPromise.then(function resourceSuccess() {
  41772. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  41773. return objectLoader.load();
  41774. }.bind(this));
  41775. },
  41776. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  41777. var self = this;
  41778. var pdfManager = this.pdfManager;
  41779. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41780. var resourcesPromise = this.loadResources([
  41781. 'ExtGState',
  41782. 'ColorSpace',
  41783. 'Pattern',
  41784. 'Shading',
  41785. 'XObject',
  41786. 'Font'
  41787. ]);
  41788. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  41789. var dataPromises = Promise.all([
  41790. contentStreamPromise,
  41791. resourcesPromise
  41792. ]);
  41793. var pageListPromise = dataPromises.then(function (data) {
  41794. var contentStream = data[0];
  41795. var opList = new OperatorList(intent, handler, self.pageIndex);
  41796. handler.send('StartRenderPage', {
  41797. transparency: partialEvaluator.hasBlendModes(self.resources),
  41798. pageIndex: self.pageIndex,
  41799. intent: intent
  41800. });
  41801. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  41802. return opList;
  41803. });
  41804. });
  41805. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  41806. return Promise.all([
  41807. pageListPromise,
  41808. annotationsPromise
  41809. ]).then(function (datas) {
  41810. var pageOpList = datas[0];
  41811. var annotations = datas[1];
  41812. if (annotations.length === 0) {
  41813. pageOpList.flush(true);
  41814. return pageOpList;
  41815. }
  41816. var i, ii, opListPromises = [];
  41817. for (i = 0, ii = annotations.length; i < ii; i++) {
  41818. if (isAnnotationRenderable(annotations[i], intent)) {
  41819. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  41820. }
  41821. }
  41822. return Promise.all(opListPromises).then(function (opLists) {
  41823. pageOpList.addOp(OPS.beginAnnotations, []);
  41824. for (i = 0, ii = opLists.length; i < ii; i++) {
  41825. pageOpList.addOpList(opLists[i]);
  41826. }
  41827. pageOpList.addOp(OPS.endAnnotations, []);
  41828. pageOpList.flush(true);
  41829. return pageOpList;
  41830. });
  41831. });
  41832. },
  41833. extractTextContent: function Page_extractTextContent(handler, task, normalizeWhitespace, combineTextItems) {
  41834. var self = this;
  41835. var pdfManager = this.pdfManager;
  41836. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41837. var resourcesPromise = this.loadResources([
  41838. 'ExtGState',
  41839. 'XObject',
  41840. 'Font'
  41841. ]);
  41842. var dataPromises = Promise.all([
  41843. contentStreamPromise,
  41844. resourcesPromise
  41845. ]);
  41846. return dataPromises.then(function (data) {
  41847. var contentStream = data[0];
  41848. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  41849. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  41850. });
  41851. },
  41852. getAnnotationsData: function Page_getAnnotationsData(intent) {
  41853. var annotations = this.annotations;
  41854. var annotationsData = [];
  41855. for (var i = 0, n = annotations.length; i < n; ++i) {
  41856. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  41857. annotationsData.push(annotations[i].data);
  41858. }
  41859. }
  41860. return annotationsData;
  41861. },
  41862. get annotations() {
  41863. var annotations = [];
  41864. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  41865. var annotationFactory = new AnnotationFactory();
  41866. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  41867. var annotationRef = annotationRefs[i];
  41868. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  41869. if (annotation) {
  41870. annotations.push(annotation);
  41871. }
  41872. }
  41873. return shadow(this, 'annotations', annotations);
  41874. }
  41875. };
  41876. return Page;
  41877. }();
  41878. var PDFDocument = function PDFDocumentClosure() {
  41879. var FINGERPRINT_FIRST_BYTES = 1024;
  41880. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  41881. function PDFDocument(pdfManager, arg) {
  41882. var stream;
  41883. if (isStream(arg)) {
  41884. stream = arg;
  41885. } else if (isArrayBuffer(arg)) {
  41886. stream = new Stream(arg);
  41887. } else {
  41888. error('PDFDocument: Unknown argument type');
  41889. }
  41890. assert(stream.length > 0, 'stream must have data');
  41891. this.pdfManager = pdfManager;
  41892. this.stream = stream;
  41893. this.xref = new XRef(stream, pdfManager);
  41894. }
  41895. function find(stream, needle, limit, backwards) {
  41896. var pos = stream.pos;
  41897. var end = stream.end;
  41898. var strBuf = [];
  41899. if (pos + limit > end) {
  41900. limit = end - pos;
  41901. }
  41902. for (var n = 0; n < limit; ++n) {
  41903. strBuf.push(String.fromCharCode(stream.getByte()));
  41904. }
  41905. var str = strBuf.join('');
  41906. stream.pos = pos;
  41907. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  41908. if (index === -1) {
  41909. return false;
  41910. }
  41911. stream.pos += index;
  41912. return true;
  41913. }
  41914. var DocumentInfoValidators = {
  41915. get entries() {
  41916. return shadow(this, 'entries', {
  41917. Title: isString,
  41918. Author: isString,
  41919. Subject: isString,
  41920. Keywords: isString,
  41921. Creator: isString,
  41922. Producer: isString,
  41923. CreationDate: isString,
  41924. ModDate: isString,
  41925. Trapped: isName
  41926. });
  41927. }
  41928. };
  41929. PDFDocument.prototype = {
  41930. parse: function PDFDocument_parse(recoveryMode) {
  41931. this.setup(recoveryMode);
  41932. var version = this.catalog.catDict.get('Version');
  41933. if (isName(version)) {
  41934. this.pdfFormatVersion = version.name;
  41935. }
  41936. try {
  41937. this.acroForm = this.catalog.catDict.get('AcroForm');
  41938. if (this.acroForm) {
  41939. this.xfa = this.acroForm.get('XFA');
  41940. var fields = this.acroForm.get('Fields');
  41941. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  41942. this.acroForm = null;
  41943. }
  41944. }
  41945. } catch (ex) {
  41946. if (ex instanceof MissingDataException) {
  41947. throw ex;
  41948. }
  41949. info('Something wrong with AcroForm entry');
  41950. this.acroForm = null;
  41951. }
  41952. },
  41953. get linearization() {
  41954. var linearization = null;
  41955. if (this.stream.length) {
  41956. try {
  41957. linearization = Linearization.create(this.stream);
  41958. } catch (err) {
  41959. if (err instanceof MissingDataException) {
  41960. throw err;
  41961. }
  41962. info(err);
  41963. }
  41964. }
  41965. return shadow(this, 'linearization', linearization);
  41966. },
  41967. get startXRef() {
  41968. var stream = this.stream;
  41969. var startXRef = 0;
  41970. var linearization = this.linearization;
  41971. if (linearization) {
  41972. stream.reset();
  41973. if (find(stream, 'endobj', 1024)) {
  41974. startXRef = stream.pos + 6;
  41975. }
  41976. } else {
  41977. var step = 1024;
  41978. var found = false, pos = stream.end;
  41979. while (!found && pos > 0) {
  41980. pos -= step - 'startxref'.length;
  41981. if (pos < 0) {
  41982. pos = 0;
  41983. }
  41984. stream.pos = pos;
  41985. found = find(stream, 'startxref', step, true);
  41986. }
  41987. if (found) {
  41988. stream.skip(9);
  41989. var ch;
  41990. do {
  41991. ch = stream.getByte();
  41992. } while (isSpace(ch));
  41993. var str = '';
  41994. while (ch >= 0x20 && ch <= 0x39) {
  41995. str += String.fromCharCode(ch);
  41996. ch = stream.getByte();
  41997. }
  41998. startXRef = parseInt(str, 10);
  41999. if (isNaN(startXRef)) {
  42000. startXRef = 0;
  42001. }
  42002. }
  42003. }
  42004. return shadow(this, 'startXRef', startXRef);
  42005. },
  42006. get mainXRefEntriesOffset() {
  42007. var mainXRefEntriesOffset = 0;
  42008. var linearization = this.linearization;
  42009. if (linearization) {
  42010. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42011. }
  42012. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42013. },
  42014. checkHeader: function PDFDocument_checkHeader() {
  42015. var stream = this.stream;
  42016. stream.reset();
  42017. if (find(stream, '%PDF-', 1024)) {
  42018. stream.moveStart();
  42019. var MAX_VERSION_LENGTH = 12;
  42020. var version = '', ch;
  42021. while ((ch = stream.getByte()) > 0x20) {
  42022. if (version.length >= MAX_VERSION_LENGTH) {
  42023. break;
  42024. }
  42025. version += String.fromCharCode(ch);
  42026. }
  42027. if (!this.pdfFormatVersion) {
  42028. this.pdfFormatVersion = version.substring(5);
  42029. }
  42030. return;
  42031. }
  42032. },
  42033. parseStartXRef: function PDFDocument_parseStartXRef() {
  42034. var startXRef = this.startXRef;
  42035. this.xref.setStartXRef(startXRef);
  42036. },
  42037. setup: function PDFDocument_setup(recoveryMode) {
  42038. this.xref.parse(recoveryMode);
  42039. var self = this;
  42040. var pageFactory = {
  42041. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42042. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42043. }
  42044. };
  42045. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42046. },
  42047. get numPages() {
  42048. var linearization = this.linearization;
  42049. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42050. return shadow(this, 'numPages', num);
  42051. },
  42052. get documentInfo() {
  42053. var docInfo = {
  42054. PDFFormatVersion: this.pdfFormatVersion,
  42055. IsAcroFormPresent: !!this.acroForm,
  42056. IsXFAPresent: !!this.xfa
  42057. };
  42058. var infoDict;
  42059. try {
  42060. infoDict = this.xref.trailer.get('Info');
  42061. } catch (err) {
  42062. if (err instanceof MissingDataException) {
  42063. throw err;
  42064. }
  42065. info('The document information dictionary is invalid.');
  42066. }
  42067. if (infoDict) {
  42068. var validEntries = DocumentInfoValidators.entries;
  42069. for (var key in validEntries) {
  42070. if (infoDict.has(key)) {
  42071. var value = infoDict.get(key);
  42072. if (validEntries[key](value)) {
  42073. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42074. } else {
  42075. info('Bad value in document info for "' + key + '"');
  42076. }
  42077. }
  42078. }
  42079. }
  42080. return shadow(this, 'documentInfo', docInfo);
  42081. },
  42082. get fingerprint() {
  42083. var xref = this.xref, hash, fileID = '';
  42084. var idArray = xref.trailer.get('ID');
  42085. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42086. hash = stringToBytes(idArray[0]);
  42087. } else {
  42088. if (this.stream.ensureRange) {
  42089. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42090. }
  42091. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42092. }
  42093. for (var i = 0, n = hash.length; i < n; i++) {
  42094. var hex = hash[i].toString(16);
  42095. fileID += hex.length === 1 ? '0' + hex : hex;
  42096. }
  42097. return shadow(this, 'fingerprint', fileID);
  42098. },
  42099. getPage: function PDFDocument_getPage(pageIndex) {
  42100. return this.catalog.getPage(pageIndex);
  42101. },
  42102. cleanup: function PDFDocument_cleanup() {
  42103. return this.catalog.cleanup();
  42104. }
  42105. };
  42106. return PDFDocument;
  42107. }();
  42108. exports.Page = Page;
  42109. exports.PDFDocument = PDFDocument;
  42110. /***/ }),
  42111. /* 32 */
  42112. /***/ (function(module, exports, __w_pdfjs_require__) {
  42113. "use strict";
  42114. var sharedUtil = __w_pdfjs_require__(0);
  42115. var coreStream = __w_pdfjs_require__(2);
  42116. var coreGlyphList = __w_pdfjs_require__(8);
  42117. var coreEncodings = __w_pdfjs_require__(5);
  42118. var coreCFFParser = __w_pdfjs_require__(15);
  42119. var Util = sharedUtil.Util;
  42120. var bytesToString = sharedUtil.bytesToString;
  42121. var error = sharedUtil.error;
  42122. var Stream = coreStream.Stream;
  42123. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42124. var StandardEncoding = coreEncodings.StandardEncoding;
  42125. var CFFParser = coreCFFParser.CFFParser;
  42126. var FontRendererFactory = function FontRendererFactoryClosure() {
  42127. function getLong(data, offset) {
  42128. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42129. }
  42130. function getUshort(data, offset) {
  42131. return data[offset] << 8 | data[offset + 1];
  42132. }
  42133. function parseCmap(data, start, end) {
  42134. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42135. var format = getUshort(data, start + offset);
  42136. var ranges, p, i;
  42137. if (format === 4) {
  42138. getUshort(data, start + offset + 2);
  42139. var segCount = getUshort(data, start + offset + 6) >> 1;
  42140. p = start + offset + 14;
  42141. ranges = [];
  42142. for (i = 0; i < segCount; i++, p += 2) {
  42143. ranges[i] = { end: getUshort(data, p) };
  42144. }
  42145. p += 2;
  42146. for (i = 0; i < segCount; i++, p += 2) {
  42147. ranges[i].start = getUshort(data, p);
  42148. }
  42149. for (i = 0; i < segCount; i++, p += 2) {
  42150. ranges[i].idDelta = getUshort(data, p);
  42151. }
  42152. for (i = 0; i < segCount; i++, p += 2) {
  42153. var idOffset = getUshort(data, p);
  42154. if (idOffset === 0) {
  42155. continue;
  42156. }
  42157. ranges[i].ids = [];
  42158. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42159. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42160. idOffset += 2;
  42161. }
  42162. }
  42163. return ranges;
  42164. } else if (format === 12) {
  42165. getLong(data, start + offset + 4);
  42166. var groups = getLong(data, start + offset + 12);
  42167. p = start + offset + 16;
  42168. ranges = [];
  42169. for (i = 0; i < groups; i++) {
  42170. ranges.push({
  42171. start: getLong(data, p),
  42172. end: getLong(data, p + 4),
  42173. idDelta: getLong(data, p + 8) - getLong(data, p)
  42174. });
  42175. p += 12;
  42176. }
  42177. return ranges;
  42178. }
  42179. error('not supported cmap: ' + format);
  42180. }
  42181. function parseCff(data, start, end, seacAnalysisEnabled) {
  42182. var properties = {};
  42183. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42184. var cff = parser.parse();
  42185. return {
  42186. glyphs: cff.charStrings.objects,
  42187. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42188. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42189. };
  42190. }
  42191. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42192. var itemSize, itemDecode;
  42193. if (isGlyphLocationsLong) {
  42194. itemSize = 4;
  42195. itemDecode = function fontItemDecodeLong(data, offset) {
  42196. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42197. };
  42198. } else {
  42199. itemSize = 2;
  42200. itemDecode = function fontItemDecode(data, offset) {
  42201. return data[offset] << 9 | data[offset + 1] << 1;
  42202. };
  42203. }
  42204. var glyphs = [];
  42205. var startOffset = itemDecode(loca, 0);
  42206. for (var j = itemSize; j < loca.length; j += itemSize) {
  42207. var endOffset = itemDecode(loca, j);
  42208. glyphs.push(glyf.subarray(startOffset, endOffset));
  42209. startOffset = endOffset;
  42210. }
  42211. return glyphs;
  42212. }
  42213. function lookupCmap(ranges, unicode) {
  42214. var code = unicode.charCodeAt(0), gid = 0;
  42215. var l = 0, r = ranges.length - 1;
  42216. while (l < r) {
  42217. var c = l + r + 1 >> 1;
  42218. if (code < ranges[c].start) {
  42219. r = c - 1;
  42220. } else {
  42221. l = c;
  42222. }
  42223. }
  42224. if (ranges[l].start <= code && code <= ranges[l].end) {
  42225. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  42226. }
  42227. return {
  42228. charCode: code,
  42229. glyphId: gid
  42230. };
  42231. }
  42232. function compileGlyf(code, cmds, font) {
  42233. function moveTo(x, y) {
  42234. cmds.push({
  42235. cmd: 'moveTo',
  42236. args: [
  42237. x,
  42238. y
  42239. ]
  42240. });
  42241. }
  42242. function lineTo(x, y) {
  42243. cmds.push({
  42244. cmd: 'lineTo',
  42245. args: [
  42246. x,
  42247. y
  42248. ]
  42249. });
  42250. }
  42251. function quadraticCurveTo(xa, ya, x, y) {
  42252. cmds.push({
  42253. cmd: 'quadraticCurveTo',
  42254. args: [
  42255. xa,
  42256. ya,
  42257. x,
  42258. y
  42259. ]
  42260. });
  42261. }
  42262. var i = 0;
  42263. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42264. var flags;
  42265. var x = 0, y = 0;
  42266. i += 10;
  42267. if (numberOfContours < 0) {
  42268. do {
  42269. flags = code[i] << 8 | code[i + 1];
  42270. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  42271. i += 4;
  42272. var arg1, arg2;
  42273. if (flags & 0x01) {
  42274. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42275. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  42276. i += 4;
  42277. } else {
  42278. arg1 = code[i++];
  42279. arg2 = code[i++];
  42280. }
  42281. if (flags & 0x02) {
  42282. x = arg1;
  42283. y = arg2;
  42284. } else {
  42285. x = 0;
  42286. y = 0;
  42287. }
  42288. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  42289. if (flags & 0x08) {
  42290. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42291. i += 2;
  42292. } else if (flags & 0x40) {
  42293. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42294. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42295. i += 4;
  42296. } else if (flags & 0x80) {
  42297. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42298. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42299. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  42300. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  42301. i += 8;
  42302. }
  42303. var subglyph = font.glyphs[glyphIndex];
  42304. if (subglyph) {
  42305. cmds.push({ cmd: 'save' });
  42306. cmds.push({
  42307. cmd: 'transform',
  42308. args: [
  42309. scaleX,
  42310. scale01,
  42311. scale10,
  42312. scaleY,
  42313. x,
  42314. y
  42315. ]
  42316. });
  42317. compileGlyf(subglyph, cmds, font);
  42318. cmds.push({ cmd: 'restore' });
  42319. }
  42320. } while (flags & 0x20);
  42321. } else {
  42322. var endPtsOfContours = [];
  42323. var j, jj;
  42324. for (j = 0; j < numberOfContours; j++) {
  42325. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  42326. i += 2;
  42327. }
  42328. var instructionLength = code[i] << 8 | code[i + 1];
  42329. i += 2 + instructionLength;
  42330. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  42331. var points = [];
  42332. while (points.length < numberOfPoints) {
  42333. flags = code[i++];
  42334. var repeat = 1;
  42335. if (flags & 0x08) {
  42336. repeat += code[i++];
  42337. }
  42338. while (repeat-- > 0) {
  42339. points.push({ flags: flags });
  42340. }
  42341. }
  42342. for (j = 0; j < numberOfPoints; j++) {
  42343. switch (points[j].flags & 0x12) {
  42344. case 0x00:
  42345. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42346. i += 2;
  42347. break;
  42348. case 0x02:
  42349. x -= code[i++];
  42350. break;
  42351. case 0x12:
  42352. x += code[i++];
  42353. break;
  42354. }
  42355. points[j].x = x;
  42356. }
  42357. for (j = 0; j < numberOfPoints; j++) {
  42358. switch (points[j].flags & 0x24) {
  42359. case 0x00:
  42360. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42361. i += 2;
  42362. break;
  42363. case 0x04:
  42364. y -= code[i++];
  42365. break;
  42366. case 0x24:
  42367. y += code[i++];
  42368. break;
  42369. }
  42370. points[j].y = y;
  42371. }
  42372. var startPoint = 0;
  42373. for (i = 0; i < numberOfContours; i++) {
  42374. var endPoint = endPtsOfContours[i];
  42375. var contour = points.slice(startPoint, endPoint + 1);
  42376. if (contour[0].flags & 1) {
  42377. contour.push(contour[0]);
  42378. } else if (contour[contour.length - 1].flags & 1) {
  42379. contour.unshift(contour[contour.length - 1]);
  42380. } else {
  42381. var p = {
  42382. flags: 1,
  42383. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  42384. y: (contour[0].y + contour[contour.length - 1].y) / 2
  42385. };
  42386. contour.unshift(p);
  42387. contour.push(p);
  42388. }
  42389. moveTo(contour[0].x, contour[0].y);
  42390. for (j = 1, jj = contour.length; j < jj; j++) {
  42391. if (contour[j].flags & 1) {
  42392. lineTo(contour[j].x, contour[j].y);
  42393. } else if (contour[j + 1].flags & 1) {
  42394. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  42395. j++;
  42396. } else {
  42397. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  42398. }
  42399. }
  42400. startPoint = endPoint + 1;
  42401. }
  42402. }
  42403. }
  42404. function compileCharString(code, cmds, font) {
  42405. var stack = [];
  42406. var x = 0, y = 0;
  42407. var stems = 0;
  42408. function moveTo(x, y) {
  42409. cmds.push({
  42410. cmd: 'moveTo',
  42411. args: [
  42412. x,
  42413. y
  42414. ]
  42415. });
  42416. }
  42417. function lineTo(x, y) {
  42418. cmds.push({
  42419. cmd: 'lineTo',
  42420. args: [
  42421. x,
  42422. y
  42423. ]
  42424. });
  42425. }
  42426. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  42427. cmds.push({
  42428. cmd: 'bezierCurveTo',
  42429. args: [
  42430. x1,
  42431. y1,
  42432. x2,
  42433. y2,
  42434. x,
  42435. y
  42436. ]
  42437. });
  42438. }
  42439. function parse(code) {
  42440. var i = 0;
  42441. while (i < code.length) {
  42442. var stackClean = false;
  42443. var v = code[i++];
  42444. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  42445. switch (v) {
  42446. case 1:
  42447. stems += stack.length >> 1;
  42448. stackClean = true;
  42449. break;
  42450. case 3:
  42451. stems += stack.length >> 1;
  42452. stackClean = true;
  42453. break;
  42454. case 4:
  42455. y += stack.pop();
  42456. moveTo(x, y);
  42457. stackClean = true;
  42458. break;
  42459. case 5:
  42460. while (stack.length > 0) {
  42461. x += stack.shift();
  42462. y += stack.shift();
  42463. lineTo(x, y);
  42464. }
  42465. break;
  42466. case 6:
  42467. while (stack.length > 0) {
  42468. x += stack.shift();
  42469. lineTo(x, y);
  42470. if (stack.length === 0) {
  42471. break;
  42472. }
  42473. y += stack.shift();
  42474. lineTo(x, y);
  42475. }
  42476. break;
  42477. case 7:
  42478. while (stack.length > 0) {
  42479. y += stack.shift();
  42480. lineTo(x, y);
  42481. if (stack.length === 0) {
  42482. break;
  42483. }
  42484. x += stack.shift();
  42485. lineTo(x, y);
  42486. }
  42487. break;
  42488. case 8:
  42489. while (stack.length > 0) {
  42490. xa = x + stack.shift();
  42491. ya = y + stack.shift();
  42492. xb = xa + stack.shift();
  42493. yb = ya + stack.shift();
  42494. x = xb + stack.shift();
  42495. y = yb + stack.shift();
  42496. bezierCurveTo(xa, ya, xb, yb, x, y);
  42497. }
  42498. break;
  42499. case 10:
  42500. n = stack.pop() + font.subrsBias;
  42501. subrCode = font.subrs[n];
  42502. if (subrCode) {
  42503. parse(subrCode);
  42504. }
  42505. break;
  42506. case 11:
  42507. return;
  42508. case 12:
  42509. v = code[i++];
  42510. switch (v) {
  42511. case 34:
  42512. xa = x + stack.shift();
  42513. xb = xa + stack.shift();
  42514. y1 = y + stack.shift();
  42515. x = xb + stack.shift();
  42516. bezierCurveTo(xa, y, xb, y1, x, y1);
  42517. xa = x + stack.shift();
  42518. xb = xa + stack.shift();
  42519. x = xb + stack.shift();
  42520. bezierCurveTo(xa, y1, xb, y, x, y);
  42521. break;
  42522. case 35:
  42523. xa = x + stack.shift();
  42524. ya = y + stack.shift();
  42525. xb = xa + stack.shift();
  42526. yb = ya + stack.shift();
  42527. x = xb + stack.shift();
  42528. y = yb + stack.shift();
  42529. bezierCurveTo(xa, ya, xb, yb, x, y);
  42530. xa = x + stack.shift();
  42531. ya = y + stack.shift();
  42532. xb = xa + stack.shift();
  42533. yb = ya + stack.shift();
  42534. x = xb + stack.shift();
  42535. y = yb + stack.shift();
  42536. bezierCurveTo(xa, ya, xb, yb, x, y);
  42537. stack.pop();
  42538. break;
  42539. case 36:
  42540. xa = x + stack.shift();
  42541. y1 = y + stack.shift();
  42542. xb = xa + stack.shift();
  42543. y2 = y1 + stack.shift();
  42544. x = xb + stack.shift();
  42545. bezierCurveTo(xa, y1, xb, y2, x, y2);
  42546. xa = x + stack.shift();
  42547. xb = xa + stack.shift();
  42548. y3 = y2 + stack.shift();
  42549. x = xb + stack.shift();
  42550. bezierCurveTo(xa, y2, xb, y3, x, y);
  42551. break;
  42552. case 37:
  42553. var x0 = x, y0 = y;
  42554. xa = x + stack.shift();
  42555. ya = y + stack.shift();
  42556. xb = xa + stack.shift();
  42557. yb = ya + stack.shift();
  42558. x = xb + stack.shift();
  42559. y = yb + stack.shift();
  42560. bezierCurveTo(xa, ya, xb, yb, x, y);
  42561. xa = x + stack.shift();
  42562. ya = y + stack.shift();
  42563. xb = xa + stack.shift();
  42564. yb = ya + stack.shift();
  42565. x = xb;
  42566. y = yb;
  42567. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  42568. x += stack.shift();
  42569. } else {
  42570. y += stack.shift();
  42571. }
  42572. bezierCurveTo(xa, ya, xb, yb, x, y);
  42573. break;
  42574. default:
  42575. error('unknown operator: 12 ' + v);
  42576. }
  42577. break;
  42578. case 14:
  42579. if (stack.length >= 4) {
  42580. var achar = stack.pop();
  42581. var bchar = stack.pop();
  42582. y = stack.pop();
  42583. x = stack.pop();
  42584. cmds.push({ cmd: 'save' });
  42585. cmds.push({
  42586. cmd: 'translate',
  42587. args: [
  42588. x,
  42589. y
  42590. ]
  42591. });
  42592. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  42593. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42594. cmds.push({ cmd: 'restore' });
  42595. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  42596. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42597. }
  42598. return;
  42599. case 18:
  42600. stems += stack.length >> 1;
  42601. stackClean = true;
  42602. break;
  42603. case 19:
  42604. stems += stack.length >> 1;
  42605. i += stems + 7 >> 3;
  42606. stackClean = true;
  42607. break;
  42608. case 20:
  42609. stems += stack.length >> 1;
  42610. i += stems + 7 >> 3;
  42611. stackClean = true;
  42612. break;
  42613. case 21:
  42614. y += stack.pop();
  42615. x += stack.pop();
  42616. moveTo(x, y);
  42617. stackClean = true;
  42618. break;
  42619. case 22:
  42620. x += stack.pop();
  42621. moveTo(x, y);
  42622. stackClean = true;
  42623. break;
  42624. case 23:
  42625. stems += stack.length >> 1;
  42626. stackClean = true;
  42627. break;
  42628. case 24:
  42629. while (stack.length > 2) {
  42630. xa = x + stack.shift();
  42631. ya = y + stack.shift();
  42632. xb = xa + stack.shift();
  42633. yb = ya + stack.shift();
  42634. x = xb + stack.shift();
  42635. y = yb + stack.shift();
  42636. bezierCurveTo(xa, ya, xb, yb, x, y);
  42637. }
  42638. x += stack.shift();
  42639. y += stack.shift();
  42640. lineTo(x, y);
  42641. break;
  42642. case 25:
  42643. while (stack.length > 6) {
  42644. x += stack.shift();
  42645. y += stack.shift();
  42646. lineTo(x, y);
  42647. }
  42648. xa = x + stack.shift();
  42649. ya = y + stack.shift();
  42650. xb = xa + stack.shift();
  42651. yb = ya + stack.shift();
  42652. x = xb + stack.shift();
  42653. y = yb + stack.shift();
  42654. bezierCurveTo(xa, ya, xb, yb, x, y);
  42655. break;
  42656. case 26:
  42657. if (stack.length % 2) {
  42658. x += stack.shift();
  42659. }
  42660. while (stack.length > 0) {
  42661. xa = x;
  42662. ya = y + stack.shift();
  42663. xb = xa + stack.shift();
  42664. yb = ya + stack.shift();
  42665. x = xb;
  42666. y = yb + stack.shift();
  42667. bezierCurveTo(xa, ya, xb, yb, x, y);
  42668. }
  42669. break;
  42670. case 27:
  42671. if (stack.length % 2) {
  42672. y += stack.shift();
  42673. }
  42674. while (stack.length > 0) {
  42675. xa = x + stack.shift();
  42676. ya = y;
  42677. xb = xa + stack.shift();
  42678. yb = ya + stack.shift();
  42679. x = xb + stack.shift();
  42680. y = yb;
  42681. bezierCurveTo(xa, ya, xb, yb, x, y);
  42682. }
  42683. break;
  42684. case 28:
  42685. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  42686. i += 2;
  42687. break;
  42688. case 29:
  42689. n = stack.pop() + font.gsubrsBias;
  42690. subrCode = font.gsubrs[n];
  42691. if (subrCode) {
  42692. parse(subrCode);
  42693. }
  42694. break;
  42695. case 30:
  42696. while (stack.length > 0) {
  42697. xa = x;
  42698. ya = y + stack.shift();
  42699. xb = xa + stack.shift();
  42700. yb = ya + stack.shift();
  42701. x = xb + stack.shift();
  42702. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42703. bezierCurveTo(xa, ya, xb, yb, x, y);
  42704. if (stack.length === 0) {
  42705. break;
  42706. }
  42707. xa = x + stack.shift();
  42708. ya = y;
  42709. xb = xa + stack.shift();
  42710. yb = ya + stack.shift();
  42711. y = yb + stack.shift();
  42712. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42713. bezierCurveTo(xa, ya, xb, yb, x, y);
  42714. }
  42715. break;
  42716. case 31:
  42717. while (stack.length > 0) {
  42718. xa = x + stack.shift();
  42719. ya = y;
  42720. xb = xa + stack.shift();
  42721. yb = ya + stack.shift();
  42722. y = yb + stack.shift();
  42723. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42724. bezierCurveTo(xa, ya, xb, yb, x, y);
  42725. if (stack.length === 0) {
  42726. break;
  42727. }
  42728. xa = x;
  42729. ya = y + stack.shift();
  42730. xb = xa + stack.shift();
  42731. yb = ya + stack.shift();
  42732. x = xb + stack.shift();
  42733. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42734. bezierCurveTo(xa, ya, xb, yb, x, y);
  42735. }
  42736. break;
  42737. default:
  42738. if (v < 32) {
  42739. error('unknown operator: ' + v);
  42740. }
  42741. if (v < 247) {
  42742. stack.push(v - 139);
  42743. } else if (v < 251) {
  42744. stack.push((v - 247) * 256 + code[i++] + 108);
  42745. } else if (v < 255) {
  42746. stack.push(-(v - 251) * 256 - code[i++] - 108);
  42747. } else {
  42748. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  42749. i += 4;
  42750. }
  42751. break;
  42752. }
  42753. if (stackClean) {
  42754. stack.length = 0;
  42755. }
  42756. }
  42757. }
  42758. parse(code);
  42759. }
  42760. var noop = '';
  42761. function CompiledFont(fontMatrix) {
  42762. this.compiledGlyphs = Object.create(null);
  42763. this.compiledCharCodeToGlyphId = Object.create(null);
  42764. this.fontMatrix = fontMatrix;
  42765. }
  42766. CompiledFont.prototype = {
  42767. getPathJs: function (unicode) {
  42768. var cmap = lookupCmap(this.cmap, unicode);
  42769. var fn = this.compiledGlyphs[cmap.glyphId];
  42770. if (!fn) {
  42771. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  42772. this.compiledGlyphs[cmap.glyphId] = fn;
  42773. }
  42774. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  42775. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  42776. }
  42777. return fn;
  42778. },
  42779. compileGlyph: function (code) {
  42780. if (!code || code.length === 0 || code[0] === 14) {
  42781. return noop;
  42782. }
  42783. var cmds = [];
  42784. cmds.push({ cmd: 'save' });
  42785. cmds.push({
  42786. cmd: 'transform',
  42787. args: this.fontMatrix.slice()
  42788. });
  42789. cmds.push({
  42790. cmd: 'scale',
  42791. args: [
  42792. 'size',
  42793. '-size'
  42794. ]
  42795. });
  42796. this.compileGlyphImpl(code, cmds);
  42797. cmds.push({ cmd: 'restore' });
  42798. return cmds;
  42799. },
  42800. compileGlyphImpl: function () {
  42801. error('Children classes should implement this.');
  42802. },
  42803. hasBuiltPath: function (unicode) {
  42804. var cmap = lookupCmap(this.cmap, unicode);
  42805. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  42806. }
  42807. };
  42808. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  42809. fontMatrix = fontMatrix || [
  42810. 0.000488,
  42811. 0,
  42812. 0,
  42813. 0.000488,
  42814. 0,
  42815. 0
  42816. ];
  42817. CompiledFont.call(this, fontMatrix);
  42818. this.glyphs = glyphs;
  42819. this.cmap = cmap;
  42820. }
  42821. Util.inherit(TrueTypeCompiled, CompiledFont, {
  42822. compileGlyphImpl: function (code, cmds) {
  42823. compileGlyf(code, cmds, this);
  42824. }
  42825. });
  42826. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  42827. fontMatrix = fontMatrix || [
  42828. 0.001,
  42829. 0,
  42830. 0,
  42831. 0.001,
  42832. 0,
  42833. 0
  42834. ];
  42835. CompiledFont.call(this, fontMatrix);
  42836. this.glyphs = cffInfo.glyphs;
  42837. this.gsubrs = cffInfo.gsubrs || [];
  42838. this.subrs = cffInfo.subrs || [];
  42839. this.cmap = cmap;
  42840. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  42841. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  42842. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  42843. }
  42844. Util.inherit(Type2Compiled, CompiledFont, {
  42845. compileGlyphImpl: function (code, cmds) {
  42846. compileCharString(code, cmds, this);
  42847. }
  42848. });
  42849. return {
  42850. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  42851. var data = new Uint8Array(font.data);
  42852. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  42853. var numTables = getUshort(data, 4);
  42854. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  42855. var tag = bytesToString(data.subarray(p, p + 4));
  42856. var offset = getLong(data, p + 8);
  42857. var length = getLong(data, p + 12);
  42858. switch (tag) {
  42859. case 'cmap':
  42860. cmap = parseCmap(data, offset, offset + length);
  42861. break;
  42862. case 'glyf':
  42863. glyf = data.subarray(offset, offset + length);
  42864. break;
  42865. case 'loca':
  42866. loca = data.subarray(offset, offset + length);
  42867. break;
  42868. case 'head':
  42869. unitsPerEm = getUshort(data, offset + 18);
  42870. indexToLocFormat = getUshort(data, offset + 50);
  42871. break;
  42872. case 'CFF ':
  42873. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  42874. break;
  42875. }
  42876. }
  42877. if (glyf) {
  42878. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  42879. 1 / unitsPerEm,
  42880. 0,
  42881. 0,
  42882. 1 / unitsPerEm,
  42883. 0,
  42884. 0
  42885. ];
  42886. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  42887. }
  42888. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  42889. }
  42890. };
  42891. }();
  42892. exports.FontRendererFactory = FontRendererFactory;
  42893. /***/ }),
  42894. /* 33 */
  42895. /***/ (function(module, exports, __w_pdfjs_require__) {
  42896. "use strict";
  42897. var sharedUtil = __w_pdfjs_require__(0);
  42898. var corePrimitives = __w_pdfjs_require__(1);
  42899. var coreStream = __w_pdfjs_require__(2);
  42900. var coreGlyphList = __w_pdfjs_require__(8);
  42901. var coreFontRenderer = __w_pdfjs_require__(32);
  42902. var coreEncodings = __w_pdfjs_require__(5);
  42903. var coreStandardFonts = __w_pdfjs_require__(21);
  42904. var coreUnicode = __w_pdfjs_require__(22);
  42905. var coreType1Parser = __w_pdfjs_require__(43);
  42906. var coreCFFParser = __w_pdfjs_require__(15);
  42907. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42908. var FontType = sharedUtil.FontType;
  42909. var assert = sharedUtil.assert;
  42910. var bytesToString = sharedUtil.bytesToString;
  42911. var error = sharedUtil.error;
  42912. var info = sharedUtil.info;
  42913. var isArray = sharedUtil.isArray;
  42914. var isInt = sharedUtil.isInt;
  42915. var isNum = sharedUtil.isNum;
  42916. var readUint32 = sharedUtil.readUint32;
  42917. var shadow = sharedUtil.shadow;
  42918. var string32 = sharedUtil.string32;
  42919. var warn = sharedUtil.warn;
  42920. var MissingDataException = sharedUtil.MissingDataException;
  42921. var isSpace = sharedUtil.isSpace;
  42922. var Stream = coreStream.Stream;
  42923. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42924. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42925. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42926. var StandardEncoding = coreEncodings.StandardEncoding;
  42927. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42928. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42929. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42930. var getEncoding = coreEncodings.getEncoding;
  42931. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42932. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42933. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42934. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42935. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42936. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42937. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42938. var Type1Parser = coreType1Parser.Type1Parser;
  42939. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42940. var CFFParser = coreCFFParser.CFFParser;
  42941. var CFFCompiler = coreCFFParser.CFFCompiler;
  42942. var CFF = coreCFFParser.CFF;
  42943. var CFFHeader = coreCFFParser.CFFHeader;
  42944. var CFFTopDict = coreCFFParser.CFFTopDict;
  42945. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42946. var CFFStrings = coreCFFParser.CFFStrings;
  42947. var CFFIndex = coreCFFParser.CFFIndex;
  42948. var CFFCharset = coreCFFParser.CFFCharset;
  42949. var PRIVATE_USE_OFFSET_START = 0xE000;
  42950. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42951. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42952. var PDF_GLYPH_SPACE_UNITS = 1000;
  42953. var SEAC_ANALYSIS_ENABLED = false;
  42954. var FontFlags = {
  42955. FixedPitch: 1,
  42956. Serif: 2,
  42957. Symbolic: 4,
  42958. Script: 8,
  42959. Nonsymbolic: 32,
  42960. Italic: 64,
  42961. AllCap: 65536,
  42962. SmallCap: 131072,
  42963. ForceBold: 262144
  42964. };
  42965. var MacStandardGlyphOrdering = [
  42966. '.notdef',
  42967. '.null',
  42968. 'nonmarkingreturn',
  42969. 'space',
  42970. 'exclam',
  42971. 'quotedbl',
  42972. 'numbersign',
  42973. 'dollar',
  42974. 'percent',
  42975. 'ampersand',
  42976. 'quotesingle',
  42977. 'parenleft',
  42978. 'parenright',
  42979. 'asterisk',
  42980. 'plus',
  42981. 'comma',
  42982. 'hyphen',
  42983. 'period',
  42984. 'slash',
  42985. 'zero',
  42986. 'one',
  42987. 'two',
  42988. 'three',
  42989. 'four',
  42990. 'five',
  42991. 'six',
  42992. 'seven',
  42993. 'eight',
  42994. 'nine',
  42995. 'colon',
  42996. 'semicolon',
  42997. 'less',
  42998. 'equal',
  42999. 'greater',
  43000. 'question',
  43001. 'at',
  43002. 'A',
  43003. 'B',
  43004. 'C',
  43005. 'D',
  43006. 'E',
  43007. 'F',
  43008. 'G',
  43009. 'H',
  43010. 'I',
  43011. 'J',
  43012. 'K',
  43013. 'L',
  43014. 'M',
  43015. 'N',
  43016. 'O',
  43017. 'P',
  43018. 'Q',
  43019. 'R',
  43020. 'S',
  43021. 'T',
  43022. 'U',
  43023. 'V',
  43024. 'W',
  43025. 'X',
  43026. 'Y',
  43027. 'Z',
  43028. 'bracketleft',
  43029. 'backslash',
  43030. 'bracketright',
  43031. 'asciicircum',
  43032. 'underscore',
  43033. 'grave',
  43034. 'a',
  43035. 'b',
  43036. 'c',
  43037. 'd',
  43038. 'e',
  43039. 'f',
  43040. 'g',
  43041. 'h',
  43042. 'i',
  43043. 'j',
  43044. 'k',
  43045. 'l',
  43046. 'm',
  43047. 'n',
  43048. 'o',
  43049. 'p',
  43050. 'q',
  43051. 'r',
  43052. 's',
  43053. 't',
  43054. 'u',
  43055. 'v',
  43056. 'w',
  43057. 'x',
  43058. 'y',
  43059. 'z',
  43060. 'braceleft',
  43061. 'bar',
  43062. 'braceright',
  43063. 'asciitilde',
  43064. 'Adieresis',
  43065. 'Aring',
  43066. 'Ccedilla',
  43067. 'Eacute',
  43068. 'Ntilde',
  43069. 'Odieresis',
  43070. 'Udieresis',
  43071. 'aacute',
  43072. 'agrave',
  43073. 'acircumflex',
  43074. 'adieresis',
  43075. 'atilde',
  43076. 'aring',
  43077. 'ccedilla',
  43078. 'eacute',
  43079. 'egrave',
  43080. 'ecircumflex',
  43081. 'edieresis',
  43082. 'iacute',
  43083. 'igrave',
  43084. 'icircumflex',
  43085. 'idieresis',
  43086. 'ntilde',
  43087. 'oacute',
  43088. 'ograve',
  43089. 'ocircumflex',
  43090. 'odieresis',
  43091. 'otilde',
  43092. 'uacute',
  43093. 'ugrave',
  43094. 'ucircumflex',
  43095. 'udieresis',
  43096. 'dagger',
  43097. 'degree',
  43098. 'cent',
  43099. 'sterling',
  43100. 'section',
  43101. 'bullet',
  43102. 'paragraph',
  43103. 'germandbls',
  43104. 'registered',
  43105. 'copyright',
  43106. 'trademark',
  43107. 'acute',
  43108. 'dieresis',
  43109. 'notequal',
  43110. 'AE',
  43111. 'Oslash',
  43112. 'infinity',
  43113. 'plusminus',
  43114. 'lessequal',
  43115. 'greaterequal',
  43116. 'yen',
  43117. 'mu',
  43118. 'partialdiff',
  43119. 'summation',
  43120. 'product',
  43121. 'pi',
  43122. 'integral',
  43123. 'ordfeminine',
  43124. 'ordmasculine',
  43125. 'Omega',
  43126. 'ae',
  43127. 'oslash',
  43128. 'questiondown',
  43129. 'exclamdown',
  43130. 'logicalnot',
  43131. 'radical',
  43132. 'florin',
  43133. 'approxequal',
  43134. 'Delta',
  43135. 'guillemotleft',
  43136. 'guillemotright',
  43137. 'ellipsis',
  43138. 'nonbreakingspace',
  43139. 'Agrave',
  43140. 'Atilde',
  43141. 'Otilde',
  43142. 'OE',
  43143. 'oe',
  43144. 'endash',
  43145. 'emdash',
  43146. 'quotedblleft',
  43147. 'quotedblright',
  43148. 'quoteleft',
  43149. 'quoteright',
  43150. 'divide',
  43151. 'lozenge',
  43152. 'ydieresis',
  43153. 'Ydieresis',
  43154. 'fraction',
  43155. 'currency',
  43156. 'guilsinglleft',
  43157. 'guilsinglright',
  43158. 'fi',
  43159. 'fl',
  43160. 'daggerdbl',
  43161. 'periodcentered',
  43162. 'quotesinglbase',
  43163. 'quotedblbase',
  43164. 'perthousand',
  43165. 'Acircumflex',
  43166. 'Ecircumflex',
  43167. 'Aacute',
  43168. 'Edieresis',
  43169. 'Egrave',
  43170. 'Iacute',
  43171. 'Icircumflex',
  43172. 'Idieresis',
  43173. 'Igrave',
  43174. 'Oacute',
  43175. 'Ocircumflex',
  43176. 'apple',
  43177. 'Ograve',
  43178. 'Uacute',
  43179. 'Ucircumflex',
  43180. 'Ugrave',
  43181. 'dotlessi',
  43182. 'circumflex',
  43183. 'tilde',
  43184. 'macron',
  43185. 'breve',
  43186. 'dotaccent',
  43187. 'ring',
  43188. 'cedilla',
  43189. 'hungarumlaut',
  43190. 'ogonek',
  43191. 'caron',
  43192. 'Lslash',
  43193. 'lslash',
  43194. 'Scaron',
  43195. 'scaron',
  43196. 'Zcaron',
  43197. 'zcaron',
  43198. 'brokenbar',
  43199. 'Eth',
  43200. 'eth',
  43201. 'Yacute',
  43202. 'yacute',
  43203. 'Thorn',
  43204. 'thorn',
  43205. 'minus',
  43206. 'multiply',
  43207. 'onesuperior',
  43208. 'twosuperior',
  43209. 'threesuperior',
  43210. 'onehalf',
  43211. 'onequarter',
  43212. 'threequarters',
  43213. 'franc',
  43214. 'Gbreve',
  43215. 'gbreve',
  43216. 'Idotaccent',
  43217. 'Scedilla',
  43218. 'scedilla',
  43219. 'Cacute',
  43220. 'cacute',
  43221. 'Ccaron',
  43222. 'ccaron',
  43223. 'dcroat'
  43224. ];
  43225. function adjustWidths(properties) {
  43226. if (!properties.fontMatrix) {
  43227. return;
  43228. }
  43229. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  43230. return;
  43231. }
  43232. var scale = 0.001 / properties.fontMatrix[0];
  43233. var glyphsWidths = properties.widths;
  43234. for (var glyph in glyphsWidths) {
  43235. glyphsWidths[glyph] *= scale;
  43236. }
  43237. properties.defaultWidth *= scale;
  43238. }
  43239. function adjustToUnicode(properties, builtInEncoding) {
  43240. if (properties.hasIncludedToUnicodeMap) {
  43241. return;
  43242. }
  43243. if (properties.hasEncoding) {
  43244. return;
  43245. }
  43246. if (builtInEncoding === properties.defaultEncoding) {
  43247. return;
  43248. }
  43249. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  43250. return;
  43251. }
  43252. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  43253. for (var charCode in builtInEncoding) {
  43254. var glyphName = builtInEncoding[charCode];
  43255. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43256. if (unicode !== -1) {
  43257. toUnicode[charCode] = String.fromCharCode(unicode);
  43258. }
  43259. }
  43260. properties.toUnicode.amend(toUnicode);
  43261. }
  43262. function getFontType(type, subtype) {
  43263. switch (type) {
  43264. case 'Type1':
  43265. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  43266. case 'CIDFontType0':
  43267. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  43268. case 'OpenType':
  43269. return FontType.OPENTYPE;
  43270. case 'TrueType':
  43271. return FontType.TRUETYPE;
  43272. case 'CIDFontType2':
  43273. return FontType.CIDFONTTYPE2;
  43274. case 'MMType1':
  43275. return FontType.MMTYPE1;
  43276. case 'Type0':
  43277. return FontType.TYPE0;
  43278. default:
  43279. return FontType.UNKNOWN;
  43280. }
  43281. }
  43282. function recoverGlyphName(name, glyphsUnicodeMap) {
  43283. if (glyphsUnicodeMap[name] !== undefined) {
  43284. return name;
  43285. }
  43286. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  43287. if (unicode !== -1) {
  43288. for (var key in glyphsUnicodeMap) {
  43289. if (glyphsUnicodeMap[key] === unicode) {
  43290. return key;
  43291. }
  43292. }
  43293. }
  43294. info('Unable to recover a standard glyph name for: ' + name);
  43295. return name;
  43296. }
  43297. var Glyph = function GlyphClosure() {
  43298. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43299. this.fontChar = fontChar;
  43300. this.unicode = unicode;
  43301. this.accent = accent;
  43302. this.width = width;
  43303. this.vmetric = vmetric;
  43304. this.operatorListId = operatorListId;
  43305. this.isSpace = isSpace;
  43306. this.isInFont = isInFont;
  43307. }
  43308. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43309. 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;
  43310. };
  43311. return Glyph;
  43312. }();
  43313. var ToUnicodeMap = function ToUnicodeMapClosure() {
  43314. function ToUnicodeMap(cmap) {
  43315. this._map = cmap;
  43316. }
  43317. ToUnicodeMap.prototype = {
  43318. get length() {
  43319. return this._map.length;
  43320. },
  43321. forEach: function (callback) {
  43322. for (var charCode in this._map) {
  43323. callback(charCode, this._map[charCode].charCodeAt(0));
  43324. }
  43325. },
  43326. has: function (i) {
  43327. return this._map[i] !== undefined;
  43328. },
  43329. get: function (i) {
  43330. return this._map[i];
  43331. },
  43332. charCodeOf: function (v) {
  43333. return this._map.indexOf(v);
  43334. },
  43335. amend: function (map) {
  43336. for (var charCode in map) {
  43337. this._map[charCode] = map[charCode];
  43338. }
  43339. }
  43340. };
  43341. return ToUnicodeMap;
  43342. }();
  43343. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  43344. function IdentityToUnicodeMap(firstChar, lastChar) {
  43345. this.firstChar = firstChar;
  43346. this.lastChar = lastChar;
  43347. }
  43348. IdentityToUnicodeMap.prototype = {
  43349. get length() {
  43350. return this.lastChar + 1 - this.firstChar;
  43351. },
  43352. forEach: function (callback) {
  43353. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  43354. callback(i, i);
  43355. }
  43356. },
  43357. has: function (i) {
  43358. return this.firstChar <= i && i <= this.lastChar;
  43359. },
  43360. get: function (i) {
  43361. if (this.firstChar <= i && i <= this.lastChar) {
  43362. return String.fromCharCode(i);
  43363. }
  43364. return undefined;
  43365. },
  43366. charCodeOf: function (v) {
  43367. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  43368. },
  43369. amend: function (map) {
  43370. error('Should not call amend()');
  43371. }
  43372. };
  43373. return IdentityToUnicodeMap;
  43374. }();
  43375. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  43376. function writeInt16(dest, offset, num) {
  43377. dest[offset] = num >> 8 & 0xFF;
  43378. dest[offset + 1] = num & 0xFF;
  43379. }
  43380. function writeInt32(dest, offset, num) {
  43381. dest[offset] = num >> 24 & 0xFF;
  43382. dest[offset + 1] = num >> 16 & 0xFF;
  43383. dest[offset + 2] = num >> 8 & 0xFF;
  43384. dest[offset + 3] = num & 0xFF;
  43385. }
  43386. function writeData(dest, offset, data) {
  43387. var i, ii;
  43388. if (data instanceof Uint8Array) {
  43389. dest.set(data, offset);
  43390. } else if (typeof data === 'string') {
  43391. for (i = 0, ii = data.length; i < ii; i++) {
  43392. dest[offset++] = data.charCodeAt(i) & 0xFF;
  43393. }
  43394. } else {
  43395. for (i = 0, ii = data.length; i < ii; i++) {
  43396. dest[offset++] = data[i] & 0xFF;
  43397. }
  43398. }
  43399. }
  43400. function OpenTypeFileBuilder(sfnt) {
  43401. this.sfnt = sfnt;
  43402. this.tables = Object.create(null);
  43403. }
  43404. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  43405. var maxPower2 = 1, log2 = 0;
  43406. while ((maxPower2 ^ entriesCount) > maxPower2) {
  43407. maxPower2 <<= 1;
  43408. log2++;
  43409. }
  43410. var searchRange = maxPower2 * entrySize;
  43411. return {
  43412. range: searchRange,
  43413. entry: log2,
  43414. rangeShift: entrySize * entriesCount - searchRange
  43415. };
  43416. };
  43417. var OTF_HEADER_SIZE = 12;
  43418. var OTF_TABLE_ENTRY_SIZE = 16;
  43419. OpenTypeFileBuilder.prototype = {
  43420. toArray: function OpenTypeFileBuilder_toArray() {
  43421. var sfnt = this.sfnt;
  43422. var tables = this.tables;
  43423. var tablesNames = Object.keys(tables);
  43424. tablesNames.sort();
  43425. var numTables = tablesNames.length;
  43426. var i, j, jj, table, tableName;
  43427. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  43428. var tableOffsets = [offset];
  43429. for (i = 0; i < numTables; i++) {
  43430. table = tables[tablesNames[i]];
  43431. var paddedLength = (table.length + 3 & ~3) >>> 0;
  43432. offset += paddedLength;
  43433. tableOffsets.push(offset);
  43434. }
  43435. var file = new Uint8Array(offset);
  43436. for (i = 0; i < numTables; i++) {
  43437. table = tables[tablesNames[i]];
  43438. writeData(file, tableOffsets[i], table);
  43439. }
  43440. if (sfnt === 'true') {
  43441. sfnt = string32(0x00010000);
  43442. }
  43443. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43444. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43445. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43446. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43447. writeInt16(file, 4, numTables);
  43448. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43449. writeInt16(file, 6, searchParams.range);
  43450. writeInt16(file, 8, searchParams.entry);
  43451. writeInt16(file, 10, searchParams.rangeShift);
  43452. offset = OTF_HEADER_SIZE;
  43453. for (i = 0; i < numTables; i++) {
  43454. tableName = tablesNames[i];
  43455. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43456. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43457. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43458. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43459. var checksum = 0;
  43460. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43461. var quad = readUint32(file, j);
  43462. checksum = checksum + quad >>> 0;
  43463. }
  43464. writeInt32(file, offset + 4, checksum);
  43465. writeInt32(file, offset + 8, tableOffsets[i]);
  43466. writeInt32(file, offset + 12, tables[tableName].length);
  43467. offset += OTF_TABLE_ENTRY_SIZE;
  43468. }
  43469. return file;
  43470. },
  43471. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43472. if (tag in this.tables) {
  43473. throw new Error('Table ' + tag + ' already exists');
  43474. }
  43475. this.tables[tag] = data;
  43476. }
  43477. };
  43478. return OpenTypeFileBuilder;
  43479. }();
  43480. var ProblematicCharRanges = new Int32Array([
  43481. 0x0000,
  43482. 0x0020,
  43483. 0x007F,
  43484. 0x00A1,
  43485. 0x00AD,
  43486. 0x00AE,
  43487. 0x0600,
  43488. 0x0780,
  43489. 0x08A0,
  43490. 0x10A0,
  43491. 0x1780,
  43492. 0x1800,
  43493. 0x1C00,
  43494. 0x1C50,
  43495. 0x2000,
  43496. 0x2010,
  43497. 0x2011,
  43498. 0x2012,
  43499. 0x2028,
  43500. 0x2030,
  43501. 0x205F,
  43502. 0x2070,
  43503. 0x25CC,
  43504. 0x25CD,
  43505. 0x3000,
  43506. 0x3001,
  43507. 0xAA60,
  43508. 0xAA80,
  43509. 0xFFF0,
  43510. 0x10000
  43511. ]);
  43512. var Font = function FontClosure() {
  43513. function Font(name, file, properties) {
  43514. var charCode, glyphName, unicode;
  43515. this.name = name;
  43516. this.loadedName = properties.loadedName;
  43517. this.isType3Font = properties.isType3Font;
  43518. this.sizes = [];
  43519. this.missingFile = false;
  43520. this.glyphCache = Object.create(null);
  43521. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43522. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43523. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43524. var type = properties.type;
  43525. var subtype = properties.subtype;
  43526. this.type = type;
  43527. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43528. this.differences = properties.differences;
  43529. this.widths = properties.widths;
  43530. this.defaultWidth = properties.defaultWidth;
  43531. this.composite = properties.composite;
  43532. this.wideChars = properties.wideChars;
  43533. this.cMap = properties.cMap;
  43534. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43535. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43536. this.fontMatrix = properties.fontMatrix;
  43537. this.bbox = properties.bbox;
  43538. this.toUnicode = properties.toUnicode;
  43539. this.toFontChar = [];
  43540. if (properties.type === 'Type3') {
  43541. for (charCode = 0; charCode < 256; charCode++) {
  43542. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43543. }
  43544. this.fontType = FontType.TYPE3;
  43545. return;
  43546. }
  43547. this.cidEncoding = properties.cidEncoding;
  43548. this.vertical = properties.vertical;
  43549. if (this.vertical) {
  43550. this.vmetrics = properties.vmetrics;
  43551. this.defaultVMetrics = properties.defaultVMetrics;
  43552. }
  43553. var glyphsUnicodeMap;
  43554. if (!file || file.isEmpty) {
  43555. if (file) {
  43556. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43557. }
  43558. this.missingFile = true;
  43559. var fontName = name.replace(/[,_]/g, '-');
  43560. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43561. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43562. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43563. this.bold = fontName.search(/bold/gi) !== -1;
  43564. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43565. this.black = name.search(/Black/g) !== -1;
  43566. this.remeasure = Object.keys(this.widths).length > 0;
  43567. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43568. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43569. var map = [];
  43570. for (charCode in GlyphMapForStandardFonts) {
  43571. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43572. }
  43573. if (/Arial-?Black/i.test(name)) {
  43574. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43575. for (charCode in SupplementalGlyphMapForArialBlack) {
  43576. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43577. }
  43578. }
  43579. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43580. if (!isIdentityUnicode) {
  43581. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43582. map[+charCode] = unicodeCharCode;
  43583. });
  43584. }
  43585. this.toFontChar = map;
  43586. this.toUnicode = new ToUnicodeMap(map);
  43587. } else if (/Symbol/i.test(fontName)) {
  43588. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43589. } else if (/Dingbats/i.test(fontName)) {
  43590. if (/Wingdings/i.test(name)) {
  43591. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43592. }
  43593. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43594. } else if (isStandardFont) {
  43595. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43596. } else {
  43597. glyphsUnicodeMap = getGlyphsUnicode();
  43598. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43599. if (!this.composite) {
  43600. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43601. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43602. if (unicode !== -1) {
  43603. unicodeCharCode = unicode;
  43604. }
  43605. }
  43606. this.toFontChar[charCode] = unicodeCharCode;
  43607. }.bind(this));
  43608. }
  43609. this.loadedName = fontName.split('-')[0];
  43610. this.loading = false;
  43611. this.fontType = getFontType(type, subtype);
  43612. return;
  43613. }
  43614. if (subtype === 'Type1C') {
  43615. if (type !== 'Type1' && type !== 'MMType1') {
  43616. if (isTrueTypeFile(file)) {
  43617. subtype = 'TrueType';
  43618. } else {
  43619. type = 'Type1';
  43620. }
  43621. } else if (isOpenTypeFile(file)) {
  43622. type = subtype = 'OpenType';
  43623. }
  43624. }
  43625. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43626. type = 'CIDFontType0';
  43627. }
  43628. if (subtype === 'OpenType') {
  43629. type = 'OpenType';
  43630. }
  43631. if (type === 'CIDFontType0') {
  43632. if (isType1File(file)) {
  43633. subtype = 'CIDFontType0';
  43634. } else if (isOpenTypeFile(file)) {
  43635. type = subtype = 'OpenType';
  43636. } else {
  43637. subtype = 'CIDFontType0C';
  43638. }
  43639. }
  43640. var data;
  43641. switch (type) {
  43642. case 'MMType1':
  43643. info('MMType1 font (' + name + '), falling back to Type1.');
  43644. case 'Type1':
  43645. case 'CIDFontType0':
  43646. this.mimetype = 'font/opentype';
  43647. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43648. adjustWidths(properties);
  43649. data = this.convert(name, cff, properties);
  43650. break;
  43651. case 'OpenType':
  43652. case 'TrueType':
  43653. case 'CIDFontType2':
  43654. this.mimetype = 'font/opentype';
  43655. data = this.checkAndRepair(name, file, properties);
  43656. if (this.isOpenType) {
  43657. adjustWidths(properties);
  43658. type = 'OpenType';
  43659. }
  43660. break;
  43661. default:
  43662. error('Font ' + type + ' is not supported');
  43663. break;
  43664. }
  43665. this.data = data;
  43666. this.fontType = getFontType(type, subtype);
  43667. this.fontMatrix = properties.fontMatrix;
  43668. this.widths = properties.widths;
  43669. this.defaultWidth = properties.defaultWidth;
  43670. this.toUnicode = properties.toUnicode;
  43671. this.encoding = properties.baseEncoding;
  43672. this.seacMap = properties.seacMap;
  43673. this.loading = true;
  43674. }
  43675. Font.getFontID = function () {
  43676. var ID = 1;
  43677. return function Font_getFontID() {
  43678. return String(ID++);
  43679. };
  43680. }();
  43681. function int16(b0, b1) {
  43682. return (b0 << 8) + b1;
  43683. }
  43684. function signedInt16(b0, b1) {
  43685. var value = (b0 << 8) + b1;
  43686. return value & 1 << 15 ? value - 0x10000 : value;
  43687. }
  43688. function int32(b0, b1, b2, b3) {
  43689. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43690. }
  43691. function string16(value) {
  43692. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43693. }
  43694. function safeString16(value) {
  43695. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43696. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43697. }
  43698. function isTrueTypeFile(file) {
  43699. var header = file.peekBytes(4);
  43700. return readUint32(header, 0) === 0x00010000;
  43701. }
  43702. function isOpenTypeFile(file) {
  43703. var header = file.peekBytes(4);
  43704. return bytesToString(header) === 'OTTO';
  43705. }
  43706. function isType1File(file) {
  43707. var header = file.peekBytes(2);
  43708. if (header[0] === 0x25 && header[1] === 0x21) {
  43709. return true;
  43710. }
  43711. if (header[0] === 0x80 && header[1] === 0x01) {
  43712. return true;
  43713. }
  43714. return false;
  43715. }
  43716. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43717. var toFontChar = [], unicode;
  43718. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43719. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43720. if (unicode !== -1) {
  43721. toFontChar[i] = unicode;
  43722. }
  43723. }
  43724. for (var charCode in differences) {
  43725. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43726. if (unicode !== -1) {
  43727. toFontChar[+charCode] = unicode;
  43728. }
  43729. }
  43730. return toFontChar;
  43731. }
  43732. function isProblematicUnicodeLocation(code) {
  43733. var i = 0, j = ProblematicCharRanges.length - 1;
  43734. while (i < j) {
  43735. var c = i + j + 1 >> 1;
  43736. if (code < ProblematicCharRanges[c]) {
  43737. j = c - 1;
  43738. } else {
  43739. i = c;
  43740. }
  43741. }
  43742. return !(i & 1);
  43743. }
  43744. function adjustMapping(charCodeToGlyphId, properties) {
  43745. var toUnicode = properties.toUnicode;
  43746. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43747. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43748. var newMap = Object.create(null);
  43749. var toFontChar = [];
  43750. var usedFontCharCodes = [];
  43751. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43752. for (var originalCharCode in charCodeToGlyphId) {
  43753. originalCharCode |= 0;
  43754. var glyphId = charCodeToGlyphId[originalCharCode];
  43755. var fontCharCode = originalCharCode;
  43756. var hasUnicodeValue = false;
  43757. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43758. hasUnicodeValue = true;
  43759. var unicode = toUnicode.get(fontCharCode);
  43760. if (unicode.length === 1) {
  43761. fontCharCode = unicode.charCodeAt(0);
  43762. }
  43763. }
  43764. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43765. do {
  43766. fontCharCode = nextAvailableFontCharCode++;
  43767. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43768. fontCharCode = 0xF020;
  43769. nextAvailableFontCharCode = fontCharCode + 1;
  43770. }
  43771. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43772. }
  43773. newMap[fontCharCode] = glyphId;
  43774. toFontChar[originalCharCode] = fontCharCode;
  43775. usedFontCharCodes[fontCharCode] = true;
  43776. }
  43777. return {
  43778. toFontChar: toFontChar,
  43779. charCodeToGlyphId: newMap,
  43780. nextAvailableFontCharCode: nextAvailableFontCharCode
  43781. };
  43782. }
  43783. function getRanges(glyphs, numGlyphs) {
  43784. var codes = [];
  43785. for (var charCode in glyphs) {
  43786. if (glyphs[charCode] >= numGlyphs) {
  43787. continue;
  43788. }
  43789. codes.push({
  43790. fontCharCode: charCode | 0,
  43791. glyphId: glyphs[charCode]
  43792. });
  43793. }
  43794. codes.sort(function fontGetRangesSort(a, b) {
  43795. return a.fontCharCode - b.fontCharCode;
  43796. });
  43797. var ranges = [];
  43798. var length = codes.length;
  43799. for (var n = 0; n < length;) {
  43800. var start = codes[n].fontCharCode;
  43801. var codeIndices = [codes[n].glyphId];
  43802. ++n;
  43803. var end = start;
  43804. while (n < length && end + 1 === codes[n].fontCharCode) {
  43805. codeIndices.push(codes[n].glyphId);
  43806. ++end;
  43807. ++n;
  43808. if (end === 0xFFFF) {
  43809. break;
  43810. }
  43811. }
  43812. ranges.push([
  43813. start,
  43814. end,
  43815. codeIndices
  43816. ]);
  43817. }
  43818. return ranges;
  43819. }
  43820. function createCmapTable(glyphs, numGlyphs) {
  43821. var ranges = getRanges(glyphs, numGlyphs);
  43822. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43823. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43824. var i, ii, j, jj;
  43825. for (i = ranges.length - 1; i >= 0; --i) {
  43826. if (ranges[i][0] <= 0xFFFF) {
  43827. break;
  43828. }
  43829. }
  43830. var bmpLength = i + 1;
  43831. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43832. ranges[i][1] = 0xFFFE;
  43833. }
  43834. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43835. var segCount = bmpLength + trailingRangesCount;
  43836. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43837. var startCount = '';
  43838. var endCount = '';
  43839. var idDeltas = '';
  43840. var idRangeOffsets = '';
  43841. var glyphsIds = '';
  43842. var bias = 0;
  43843. var range, start, end, codes;
  43844. for (i = 0, ii = bmpLength; i < ii; i++) {
  43845. range = ranges[i];
  43846. start = range[0];
  43847. end = range[1];
  43848. startCount += string16(start);
  43849. endCount += string16(end);
  43850. codes = range[2];
  43851. var contiguous = true;
  43852. for (j = 1, jj = codes.length; j < jj; ++j) {
  43853. if (codes[j] !== codes[j - 1] + 1) {
  43854. contiguous = false;
  43855. break;
  43856. }
  43857. }
  43858. if (!contiguous) {
  43859. var offset = (segCount - i) * 2 + bias * 2;
  43860. bias += end - start + 1;
  43861. idDeltas += string16(0);
  43862. idRangeOffsets += string16(offset);
  43863. for (j = 0, jj = codes.length; j < jj; ++j) {
  43864. glyphsIds += string16(codes[j]);
  43865. }
  43866. } else {
  43867. var startCode = codes[0];
  43868. idDeltas += string16(startCode - start & 0xFFFF);
  43869. idRangeOffsets += string16(0);
  43870. }
  43871. }
  43872. if (trailingRangesCount > 0) {
  43873. endCount += '\xFF\xFF';
  43874. startCount += '\xFF\xFF';
  43875. idDeltas += '\x00\x01';
  43876. idRangeOffsets += '\x00\x00';
  43877. }
  43878. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43879. var format31012 = '';
  43880. var header31012 = '';
  43881. if (numTables > 1) {
  43882. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43883. format31012 = '';
  43884. for (i = 0, ii = ranges.length; i < ii; i++) {
  43885. range = ranges[i];
  43886. start = range[0];
  43887. codes = range[2];
  43888. var code = codes[0];
  43889. for (j = 1, jj = codes.length; j < jj; ++j) {
  43890. if (codes[j] !== codes[j - 1] + 1) {
  43891. end = range[0] + j - 1;
  43892. format31012 += string32(start) + string32(end) + string32(code);
  43893. start = end + 1;
  43894. code = codes[j];
  43895. }
  43896. }
  43897. format31012 += string32(start) + string32(range[1]) + string32(code);
  43898. }
  43899. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43900. }
  43901. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43902. }
  43903. function validateOS2Table(os2) {
  43904. var stream = new Stream(os2.data);
  43905. var version = stream.getUint16();
  43906. stream.getBytes(60);
  43907. var selection = stream.getUint16();
  43908. if (version < 4 && selection & 0x0300) {
  43909. return false;
  43910. }
  43911. var firstChar = stream.getUint16();
  43912. var lastChar = stream.getUint16();
  43913. if (firstChar > lastChar) {
  43914. return false;
  43915. }
  43916. stream.getBytes(6);
  43917. var usWinAscent = stream.getUint16();
  43918. if (usWinAscent === 0) {
  43919. return false;
  43920. }
  43921. os2.data[8] = os2.data[9] = 0;
  43922. return true;
  43923. }
  43924. function createOS2Table(properties, charstrings, override) {
  43925. override = override || {
  43926. unitsPerEm: 0,
  43927. yMax: 0,
  43928. yMin: 0,
  43929. ascent: 0,
  43930. descent: 0
  43931. };
  43932. var ulUnicodeRange1 = 0;
  43933. var ulUnicodeRange2 = 0;
  43934. var ulUnicodeRange3 = 0;
  43935. var ulUnicodeRange4 = 0;
  43936. var firstCharIndex = null;
  43937. var lastCharIndex = 0;
  43938. if (charstrings) {
  43939. for (var code in charstrings) {
  43940. code |= 0;
  43941. if (firstCharIndex > code || !firstCharIndex) {
  43942. firstCharIndex = code;
  43943. }
  43944. if (lastCharIndex < code) {
  43945. lastCharIndex = code;
  43946. }
  43947. var position = getUnicodeRangeFor(code);
  43948. if (position < 32) {
  43949. ulUnicodeRange1 |= 1 << position;
  43950. } else if (position < 64) {
  43951. ulUnicodeRange2 |= 1 << position - 32;
  43952. } else if (position < 96) {
  43953. ulUnicodeRange3 |= 1 << position - 64;
  43954. } else if (position < 123) {
  43955. ulUnicodeRange4 |= 1 << position - 96;
  43956. } else {
  43957. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43958. }
  43959. }
  43960. } else {
  43961. firstCharIndex = 0;
  43962. lastCharIndex = 255;
  43963. }
  43964. var bbox = properties.bbox || [
  43965. 0,
  43966. 0,
  43967. 0,
  43968. 0
  43969. ];
  43970. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43971. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43972. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43973. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43974. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43975. typoDescent = -typoDescent;
  43976. }
  43977. var winAscent = override.yMax || typoAscent;
  43978. var winDescent = -override.yMin || -typoDescent;
  43979. 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';
  43980. }
  43981. function createPostTable(properties) {
  43982. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43983. 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';
  43984. }
  43985. function createNameTable(name, proto) {
  43986. if (!proto) {
  43987. proto = [
  43988. [],
  43989. []
  43990. ];
  43991. }
  43992. var strings = [
  43993. proto[0][0] || 'Original licence',
  43994. proto[0][1] || name,
  43995. proto[0][2] || 'Unknown',
  43996. proto[0][3] || 'uniqueID',
  43997. proto[0][4] || name,
  43998. proto[0][5] || 'Version 0.11',
  43999. proto[0][6] || '',
  44000. proto[0][7] || 'Unknown',
  44001. proto[0][8] || 'Unknown',
  44002. proto[0][9] || 'Unknown'
  44003. ];
  44004. var stringsUnicode = [];
  44005. var i, ii, j, jj, str;
  44006. for (i = 0, ii = strings.length; i < ii; i++) {
  44007. str = proto[1][i] || strings[i];
  44008. var strBufUnicode = [];
  44009. for (j = 0, jj = str.length; j < jj; j++) {
  44010. strBufUnicode.push(string16(str.charCodeAt(j)));
  44011. }
  44012. stringsUnicode.push(strBufUnicode.join(''));
  44013. }
  44014. var names = [
  44015. strings,
  44016. stringsUnicode
  44017. ];
  44018. var platforms = [
  44019. '\x00\x01',
  44020. '\x00\x03'
  44021. ];
  44022. var encodings = [
  44023. '\x00\x00',
  44024. '\x00\x01'
  44025. ];
  44026. var languages = [
  44027. '\x00\x00',
  44028. '\x04\x09'
  44029. ];
  44030. var namesRecordCount = strings.length * platforms.length;
  44031. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44032. var strOffset = 0;
  44033. for (i = 0, ii = platforms.length; i < ii; i++) {
  44034. var strs = names[i];
  44035. for (j = 0, jj = strs.length; j < jj; j++) {
  44036. str = strs[j];
  44037. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44038. nameTable += nameRecord;
  44039. strOffset += str.length;
  44040. }
  44041. }
  44042. nameTable += strings.join('') + stringsUnicode.join('');
  44043. return nameTable;
  44044. }
  44045. Font.prototype = {
  44046. name: null,
  44047. font: null,
  44048. mimetype: null,
  44049. encoding: null,
  44050. get renderer() {
  44051. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44052. return shadow(this, 'renderer', renderer);
  44053. },
  44054. exportData: function Font_exportData() {
  44055. var data = {};
  44056. for (var i in this) {
  44057. if (this.hasOwnProperty(i)) {
  44058. data[i] = this[i];
  44059. }
  44060. }
  44061. return data;
  44062. },
  44063. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44064. function readTableEntry(file) {
  44065. var tag = bytesToString(file.getBytes(4));
  44066. var checksum = file.getInt32() >>> 0;
  44067. var offset = file.getInt32() >>> 0;
  44068. var length = file.getInt32() >>> 0;
  44069. var previousPosition = file.pos;
  44070. file.pos = file.start ? file.start : 0;
  44071. file.skip(offset);
  44072. var data = file.getBytes(length);
  44073. file.pos = previousPosition;
  44074. if (tag === 'head') {
  44075. data[8] = data[9] = data[10] = data[11] = 0;
  44076. data[17] |= 0x20;
  44077. }
  44078. return {
  44079. tag: tag,
  44080. checksum: checksum,
  44081. length: length,
  44082. offset: offset,
  44083. data: data
  44084. };
  44085. }
  44086. function readOpenTypeHeader(ttf) {
  44087. return {
  44088. version: bytesToString(ttf.getBytes(4)),
  44089. numTables: ttf.getUint16(),
  44090. searchRange: ttf.getUint16(),
  44091. entrySelector: ttf.getUint16(),
  44092. rangeShift: ttf.getUint16()
  44093. };
  44094. }
  44095. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44096. if (!cmap) {
  44097. warn('No cmap table available.');
  44098. return {
  44099. platformId: -1,
  44100. encodingId: -1,
  44101. mappings: [],
  44102. hasShortCmap: false
  44103. };
  44104. }
  44105. var segment;
  44106. var start = (font.start ? font.start : 0) + cmap.offset;
  44107. font.pos = start;
  44108. font.getUint16();
  44109. var numTables = font.getUint16();
  44110. var potentialTable;
  44111. var canBreak = false;
  44112. for (var i = 0; i < numTables; i++) {
  44113. var platformId = font.getUint16();
  44114. var encodingId = font.getUint16();
  44115. var offset = font.getInt32() >>> 0;
  44116. var useTable = false;
  44117. if (platformId === 0 && encodingId === 0) {
  44118. useTable = true;
  44119. } else if (platformId === 1 && encodingId === 0) {
  44120. useTable = true;
  44121. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44122. useTable = true;
  44123. if (!isSymbolicFont) {
  44124. canBreak = true;
  44125. }
  44126. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44127. useTable = true;
  44128. canBreak = true;
  44129. }
  44130. if (useTable) {
  44131. potentialTable = {
  44132. platformId: platformId,
  44133. encodingId: encodingId,
  44134. offset: offset
  44135. };
  44136. }
  44137. if (canBreak) {
  44138. break;
  44139. }
  44140. }
  44141. if (potentialTable) {
  44142. font.pos = start + potentialTable.offset;
  44143. }
  44144. if (!potentialTable || font.peekByte() === -1) {
  44145. warn('Could not find a preferred cmap table.');
  44146. return {
  44147. platformId: -1,
  44148. encodingId: -1,
  44149. mappings: [],
  44150. hasShortCmap: false
  44151. };
  44152. }
  44153. var format = font.getUint16();
  44154. font.getUint16();
  44155. font.getUint16();
  44156. var hasShortCmap = false;
  44157. var mappings = [];
  44158. var j, glyphId;
  44159. if (format === 0) {
  44160. for (j = 0; j < 256; j++) {
  44161. var index = font.getByte();
  44162. if (!index) {
  44163. continue;
  44164. }
  44165. mappings.push({
  44166. charCode: j,
  44167. glyphId: index
  44168. });
  44169. }
  44170. hasShortCmap = true;
  44171. } else if (format === 4) {
  44172. var segCount = font.getUint16() >> 1;
  44173. font.getBytes(6);
  44174. var segIndex, segments = [];
  44175. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44176. segments.push({ end: font.getUint16() });
  44177. }
  44178. font.getUint16();
  44179. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44180. segments[segIndex].start = font.getUint16();
  44181. }
  44182. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44183. segments[segIndex].delta = font.getUint16();
  44184. }
  44185. var offsetsCount = 0;
  44186. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44187. segment = segments[segIndex];
  44188. var rangeOffset = font.getUint16();
  44189. if (!rangeOffset) {
  44190. segment.offsetIndex = -1;
  44191. continue;
  44192. }
  44193. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44194. segment.offsetIndex = offsetIndex;
  44195. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44196. }
  44197. var offsets = [];
  44198. for (j = 0; j < offsetsCount; j++) {
  44199. offsets.push(font.getUint16());
  44200. }
  44201. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44202. segment = segments[segIndex];
  44203. start = segment.start;
  44204. var end = segment.end;
  44205. var delta = segment.delta;
  44206. offsetIndex = segment.offsetIndex;
  44207. for (j = start; j <= end; j++) {
  44208. if (j === 0xFFFF) {
  44209. continue;
  44210. }
  44211. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  44212. glyphId = glyphId + delta & 0xFFFF;
  44213. if (glyphId === 0) {
  44214. continue;
  44215. }
  44216. mappings.push({
  44217. charCode: j,
  44218. glyphId: glyphId
  44219. });
  44220. }
  44221. }
  44222. } else if (format === 6) {
  44223. var firstCode = font.getUint16();
  44224. var entryCount = font.getUint16();
  44225. for (j = 0; j < entryCount; j++) {
  44226. glyphId = font.getUint16();
  44227. var charCode = firstCode + j;
  44228. mappings.push({
  44229. charCode: charCode,
  44230. glyphId: glyphId
  44231. });
  44232. }
  44233. } else {
  44234. warn('cmap table has unsupported format: ' + format);
  44235. return {
  44236. platformId: -1,
  44237. encodingId: -1,
  44238. mappings: [],
  44239. hasShortCmap: false
  44240. };
  44241. }
  44242. mappings.sort(function (a, b) {
  44243. return a.charCode - b.charCode;
  44244. });
  44245. for (i = 1; i < mappings.length; i++) {
  44246. if (mappings[i - 1].charCode === mappings[i].charCode) {
  44247. mappings.splice(i, 1);
  44248. i--;
  44249. }
  44250. }
  44251. return {
  44252. platformId: potentialTable.platformId,
  44253. encodingId: potentialTable.encodingId,
  44254. mappings: mappings,
  44255. hasShortCmap: hasShortCmap
  44256. };
  44257. }
  44258. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  44259. if (!header) {
  44260. if (metrics) {
  44261. metrics.data = null;
  44262. }
  44263. return;
  44264. }
  44265. font.pos = (font.start ? font.start : 0) + header.offset;
  44266. font.pos += header.length - 2;
  44267. var numOfMetrics = font.getUint16();
  44268. if (numOfMetrics > numGlyphs) {
  44269. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  44270. numOfMetrics = numGlyphs;
  44271. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  44272. header.data[35] = numOfMetrics & 0x00ff;
  44273. }
  44274. var numOfSidebearings = numGlyphs - numOfMetrics;
  44275. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  44276. if (numMissing > 0) {
  44277. var entries = new Uint8Array(metrics.length + numMissing * 2);
  44278. entries.set(metrics.data);
  44279. metrics.data = entries;
  44280. }
  44281. }
  44282. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  44283. if (sourceEnd - sourceStart <= 12) {
  44284. return 0;
  44285. }
  44286. var glyf = source.subarray(sourceStart, sourceEnd);
  44287. var contoursCount = glyf[0] << 8 | glyf[1];
  44288. if (contoursCount & 0x8000) {
  44289. dest.set(glyf, destStart);
  44290. return glyf.length;
  44291. }
  44292. var i, j = 10, flagsCount = 0;
  44293. for (i = 0; i < contoursCount; i++) {
  44294. var endPoint = glyf[j] << 8 | glyf[j + 1];
  44295. flagsCount = endPoint + 1;
  44296. j += 2;
  44297. }
  44298. var instructionsStart = j;
  44299. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  44300. j += 2 + instructionsLength;
  44301. var instructionsEnd = j;
  44302. var coordinatesLength = 0;
  44303. for (i = 0; i < flagsCount; i++) {
  44304. var flag = glyf[j++];
  44305. if (flag & 0xC0) {
  44306. glyf[j - 1] = flag & 0x3F;
  44307. }
  44308. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  44309. coordinatesLength += xyLength;
  44310. if (flag & 8) {
  44311. var repeat = glyf[j++];
  44312. i += repeat;
  44313. coordinatesLength += repeat * xyLength;
  44314. }
  44315. }
  44316. if (coordinatesLength === 0) {
  44317. return 0;
  44318. }
  44319. var glyphDataLength = j + coordinatesLength;
  44320. if (glyphDataLength > glyf.length) {
  44321. return 0;
  44322. }
  44323. if (!hintsValid && instructionsLength > 0) {
  44324. dest.set(glyf.subarray(0, instructionsStart), destStart);
  44325. dest.set([
  44326. 0,
  44327. 0
  44328. ], destStart + instructionsStart);
  44329. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  44330. glyphDataLength -= instructionsLength;
  44331. if (glyf.length - glyphDataLength > 3) {
  44332. glyphDataLength = glyphDataLength + 3 & ~3;
  44333. }
  44334. return glyphDataLength;
  44335. }
  44336. if (glyf.length - glyphDataLength > 3) {
  44337. glyphDataLength = glyphDataLength + 3 & ~3;
  44338. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  44339. return glyphDataLength;
  44340. }
  44341. dest.set(glyf, destStart);
  44342. return glyf.length;
  44343. }
  44344. function sanitizeHead(head, numGlyphs, locaLength) {
  44345. var data = head.data;
  44346. var version = int32(data[0], data[1], data[2], data[3]);
  44347. if (version >> 16 !== 1) {
  44348. info('Attempting to fix invalid version in head table: ' + version);
  44349. data[0] = 0;
  44350. data[1] = 1;
  44351. data[2] = 0;
  44352. data[3] = 0;
  44353. }
  44354. var indexToLocFormat = int16(data[50], data[51]);
  44355. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  44356. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  44357. var numGlyphsPlusOne = numGlyphs + 1;
  44358. if (locaLength === numGlyphsPlusOne << 1) {
  44359. data[50] = 0;
  44360. data[51] = 0;
  44361. } else if (locaLength === numGlyphsPlusOne << 2) {
  44362. data[50] = 0;
  44363. data[51] = 1;
  44364. } else {
  44365. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  44366. }
  44367. }
  44368. }
  44369. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  44370. var itemSize, itemDecode, itemEncode;
  44371. if (isGlyphLocationsLong) {
  44372. itemSize = 4;
  44373. itemDecode = function fontItemDecodeLong(data, offset) {
  44374. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  44375. };
  44376. itemEncode = function fontItemEncodeLong(data, offset, value) {
  44377. data[offset] = value >>> 24 & 0xFF;
  44378. data[offset + 1] = value >> 16 & 0xFF;
  44379. data[offset + 2] = value >> 8 & 0xFF;
  44380. data[offset + 3] = value & 0xFF;
  44381. };
  44382. } else {
  44383. itemSize = 2;
  44384. itemDecode = function fontItemDecode(data, offset) {
  44385. return data[offset] << 9 | data[offset + 1] << 1;
  44386. };
  44387. itemEncode = function fontItemEncode(data, offset, value) {
  44388. data[offset] = value >> 9 & 0xFF;
  44389. data[offset + 1] = value >> 1 & 0xFF;
  44390. };
  44391. }
  44392. var locaData = loca.data;
  44393. var locaDataSize = itemSize * (1 + numGlyphs);
  44394. if (locaData.length !== locaDataSize) {
  44395. locaData = new Uint8Array(locaDataSize);
  44396. locaData.set(loca.data.subarray(0, locaDataSize));
  44397. loca.data = locaData;
  44398. }
  44399. var oldGlyfData = glyf.data;
  44400. var oldGlyfDataLength = oldGlyfData.length;
  44401. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  44402. var startOffset = itemDecode(locaData, 0);
  44403. var writeOffset = 0;
  44404. var missingGlyphData = Object.create(null);
  44405. itemEncode(locaData, 0, writeOffset);
  44406. var i, j;
  44407. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44408. var endOffset = itemDecode(locaData, j);
  44409. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  44410. endOffset = oldGlyfDataLength;
  44411. }
  44412. if (endOffset > oldGlyfDataLength) {
  44413. itemEncode(locaData, j, writeOffset);
  44414. startOffset = endOffset;
  44415. continue;
  44416. }
  44417. if (startOffset === endOffset) {
  44418. missingGlyphData[i] = true;
  44419. }
  44420. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  44421. writeOffset += newLength;
  44422. itemEncode(locaData, j, writeOffset);
  44423. startOffset = endOffset;
  44424. }
  44425. if (writeOffset === 0) {
  44426. var simpleGlyph = new Uint8Array([
  44427. 0,
  44428. 1,
  44429. 0,
  44430. 0,
  44431. 0,
  44432. 0,
  44433. 0,
  44434. 0,
  44435. 0,
  44436. 0,
  44437. 0,
  44438. 0,
  44439. 0,
  44440. 0,
  44441. 49,
  44442. 0
  44443. ]);
  44444. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44445. itemEncode(locaData, j, simpleGlyph.length);
  44446. }
  44447. glyf.data = simpleGlyph;
  44448. return missingGlyphData;
  44449. }
  44450. if (dupFirstEntry) {
  44451. var firstEntryLength = itemDecode(locaData, itemSize);
  44452. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44453. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44454. } else {
  44455. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44456. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44457. }
  44458. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44459. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44460. } else {
  44461. glyf.data = newGlyfData.subarray(0, writeOffset);
  44462. }
  44463. return missingGlyphData;
  44464. }
  44465. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44466. var start = (font.start ? font.start : 0) + post.offset;
  44467. font.pos = start;
  44468. var length = post.length, end = start + length;
  44469. var version = font.getInt32();
  44470. font.getBytes(28);
  44471. var glyphNames;
  44472. var valid = true;
  44473. var i;
  44474. switch (version) {
  44475. case 0x00010000:
  44476. glyphNames = MacStandardGlyphOrdering;
  44477. break;
  44478. case 0x00020000:
  44479. var numGlyphs = font.getUint16();
  44480. if (numGlyphs !== maxpNumGlyphs) {
  44481. valid = false;
  44482. break;
  44483. }
  44484. var glyphNameIndexes = [];
  44485. for (i = 0; i < numGlyphs; ++i) {
  44486. var index = font.getUint16();
  44487. if (index >= 32768) {
  44488. valid = false;
  44489. break;
  44490. }
  44491. glyphNameIndexes.push(index);
  44492. }
  44493. if (!valid) {
  44494. break;
  44495. }
  44496. var customNames = [];
  44497. var strBuf = [];
  44498. while (font.pos < end) {
  44499. var stringLength = font.getByte();
  44500. strBuf.length = stringLength;
  44501. for (i = 0; i < stringLength; ++i) {
  44502. strBuf[i] = String.fromCharCode(font.getByte());
  44503. }
  44504. customNames.push(strBuf.join(''));
  44505. }
  44506. glyphNames = [];
  44507. for (i = 0; i < numGlyphs; ++i) {
  44508. var j = glyphNameIndexes[i];
  44509. if (j < 258) {
  44510. glyphNames.push(MacStandardGlyphOrdering[j]);
  44511. continue;
  44512. }
  44513. glyphNames.push(customNames[j - 258]);
  44514. }
  44515. break;
  44516. case 0x00030000:
  44517. break;
  44518. default:
  44519. warn('Unknown/unsupported post table version ' + version);
  44520. valid = false;
  44521. if (properties.defaultEncoding) {
  44522. glyphNames = properties.defaultEncoding;
  44523. }
  44524. break;
  44525. }
  44526. properties.glyphNames = glyphNames;
  44527. return valid;
  44528. }
  44529. function readNameTable(nameTable) {
  44530. var start = (font.start ? font.start : 0) + nameTable.offset;
  44531. font.pos = start;
  44532. var names = [
  44533. [],
  44534. []
  44535. ];
  44536. var length = nameTable.length, end = start + length;
  44537. var format = font.getUint16();
  44538. var FORMAT_0_HEADER_LENGTH = 6;
  44539. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44540. return names;
  44541. }
  44542. var numRecords = font.getUint16();
  44543. var stringsStart = font.getUint16();
  44544. var records = [];
  44545. var NAME_RECORD_LENGTH = 12;
  44546. var i, ii;
  44547. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44548. var r = {
  44549. platform: font.getUint16(),
  44550. encoding: font.getUint16(),
  44551. language: font.getUint16(),
  44552. name: font.getUint16(),
  44553. length: font.getUint16(),
  44554. offset: font.getUint16()
  44555. };
  44556. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44557. records.push(r);
  44558. }
  44559. }
  44560. for (i = 0, ii = records.length; i < ii; i++) {
  44561. var record = records[i];
  44562. if (record.length <= 0) {
  44563. continue;
  44564. }
  44565. var pos = start + stringsStart + record.offset;
  44566. if (pos + record.length > end) {
  44567. continue;
  44568. }
  44569. font.pos = pos;
  44570. var nameIndex = record.name;
  44571. if (record.encoding) {
  44572. var str = '';
  44573. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44574. str += String.fromCharCode(font.getUint16());
  44575. }
  44576. names[1][nameIndex] = str;
  44577. } else {
  44578. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44579. }
  44580. }
  44581. return names;
  44582. }
  44583. var TTOpsStackDeltas = [
  44584. 0,
  44585. 0,
  44586. 0,
  44587. 0,
  44588. 0,
  44589. 0,
  44590. 0,
  44591. 0,
  44592. -2,
  44593. -2,
  44594. -2,
  44595. -2,
  44596. 0,
  44597. 0,
  44598. -2,
  44599. -5,
  44600. -1,
  44601. -1,
  44602. -1,
  44603. -1,
  44604. -1,
  44605. -1,
  44606. -1,
  44607. -1,
  44608. 0,
  44609. 0,
  44610. -1,
  44611. 0,
  44612. -1,
  44613. -1,
  44614. -1,
  44615. -1,
  44616. 1,
  44617. -1,
  44618. -999,
  44619. 0,
  44620. 1,
  44621. 0,
  44622. -1,
  44623. -2,
  44624. 0,
  44625. -1,
  44626. -2,
  44627. -1,
  44628. -1,
  44629. 0,
  44630. -1,
  44631. -1,
  44632. 0,
  44633. 0,
  44634. -999,
  44635. -999,
  44636. -1,
  44637. -1,
  44638. -1,
  44639. -1,
  44640. -2,
  44641. -999,
  44642. -2,
  44643. -2,
  44644. -999,
  44645. 0,
  44646. -2,
  44647. -2,
  44648. 0,
  44649. 0,
  44650. -2,
  44651. 0,
  44652. -2,
  44653. 0,
  44654. 0,
  44655. 0,
  44656. -2,
  44657. -1,
  44658. -1,
  44659. 1,
  44660. 1,
  44661. 0,
  44662. 0,
  44663. -1,
  44664. -1,
  44665. -1,
  44666. -1,
  44667. -1,
  44668. -1,
  44669. -1,
  44670. 0,
  44671. 0,
  44672. -1,
  44673. 0,
  44674. -1,
  44675. -1,
  44676. 0,
  44677. -999,
  44678. -1,
  44679. -1,
  44680. -1,
  44681. -1,
  44682. -1,
  44683. -1,
  44684. 0,
  44685. 0,
  44686. 0,
  44687. 0,
  44688. 0,
  44689. 0,
  44690. 0,
  44691. 0,
  44692. 0,
  44693. 0,
  44694. 0,
  44695. 0,
  44696. -2,
  44697. -999,
  44698. -999,
  44699. -999,
  44700. -999,
  44701. -999,
  44702. -1,
  44703. -1,
  44704. -2,
  44705. -2,
  44706. 0,
  44707. 0,
  44708. 0,
  44709. 0,
  44710. -1,
  44711. -1,
  44712. -999,
  44713. -2,
  44714. -2,
  44715. 0,
  44716. 0,
  44717. -1,
  44718. -2,
  44719. -2,
  44720. 0,
  44721. 0,
  44722. 0,
  44723. -1,
  44724. -1,
  44725. -1,
  44726. -2
  44727. ];
  44728. function sanitizeTTProgram(table, ttContext) {
  44729. var data = table.data;
  44730. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44731. var stack = [];
  44732. var callstack = [];
  44733. var functionsCalled = [];
  44734. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44735. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44736. for (var ii = data.length; i < ii;) {
  44737. var op = data[i++];
  44738. if (op === 0x40) {
  44739. n = data[i++];
  44740. if (inFDEF || inELSE) {
  44741. i += n;
  44742. } else {
  44743. for (j = 0; j < n; j++) {
  44744. stack.push(data[i++]);
  44745. }
  44746. }
  44747. } else if (op === 0x41) {
  44748. n = data[i++];
  44749. if (inFDEF || inELSE) {
  44750. i += n * 2;
  44751. } else {
  44752. for (j = 0; j < n; j++) {
  44753. b = data[i++];
  44754. stack.push(b << 8 | data[i++]);
  44755. }
  44756. }
  44757. } else if ((op & 0xF8) === 0xB0) {
  44758. n = op - 0xB0 + 1;
  44759. if (inFDEF || inELSE) {
  44760. i += n;
  44761. } else {
  44762. for (j = 0; j < n; j++) {
  44763. stack.push(data[i++]);
  44764. }
  44765. }
  44766. } else if ((op & 0xF8) === 0xB8) {
  44767. n = op - 0xB8 + 1;
  44768. if (inFDEF || inELSE) {
  44769. i += n * 2;
  44770. } else {
  44771. for (j = 0; j < n; j++) {
  44772. b = data[i++];
  44773. stack.push(b << 8 | data[i++]);
  44774. }
  44775. }
  44776. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44777. if (!inFDEF && !inELSE) {
  44778. funcId = stack[stack.length - 1];
  44779. ttContext.functionsUsed[funcId] = true;
  44780. if (funcId in ttContext.functionsStackDeltas) {
  44781. stack.length += ttContext.functionsStackDeltas[funcId];
  44782. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44783. callstack.push({
  44784. data: data,
  44785. i: i,
  44786. stackTop: stack.length - 1
  44787. });
  44788. functionsCalled.push(funcId);
  44789. pc = ttContext.functionsDefined[funcId];
  44790. if (!pc) {
  44791. warn('TT: CALL non-existent function');
  44792. ttContext.hintsValid = false;
  44793. return;
  44794. }
  44795. data = pc.data;
  44796. i = pc.i;
  44797. }
  44798. }
  44799. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44800. if (inFDEF || inELSE) {
  44801. warn('TT: nested FDEFs not allowed');
  44802. tooComplexToFollowFunctions = true;
  44803. }
  44804. inFDEF = true;
  44805. lastDeff = i;
  44806. funcId = stack.pop();
  44807. ttContext.functionsDefined[funcId] = {
  44808. data: data,
  44809. i: i
  44810. };
  44811. } else if (op === 0x2D) {
  44812. if (inFDEF) {
  44813. inFDEF = false;
  44814. lastEndf = i;
  44815. } else {
  44816. pc = callstack.pop();
  44817. if (!pc) {
  44818. warn('TT: ENDF bad stack');
  44819. ttContext.hintsValid = false;
  44820. return;
  44821. }
  44822. funcId = functionsCalled.pop();
  44823. data = pc.data;
  44824. i = pc.i;
  44825. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44826. }
  44827. } else if (op === 0x89) {
  44828. if (inFDEF || inELSE) {
  44829. warn('TT: nested IDEFs not allowed');
  44830. tooComplexToFollowFunctions = true;
  44831. }
  44832. inFDEF = true;
  44833. lastDeff = i;
  44834. } else if (op === 0x58) {
  44835. ++ifLevel;
  44836. } else if (op === 0x1B) {
  44837. inELSE = ifLevel;
  44838. } else if (op === 0x59) {
  44839. if (inELSE === ifLevel) {
  44840. inELSE = 0;
  44841. }
  44842. --ifLevel;
  44843. } else if (op === 0x1C) {
  44844. if (!inFDEF && !inELSE) {
  44845. var offset = stack[stack.length - 1];
  44846. if (offset > 0) {
  44847. i += offset - 1;
  44848. }
  44849. }
  44850. }
  44851. if (!inFDEF && !inELSE) {
  44852. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44853. if (op >= 0x71 && op <= 0x75) {
  44854. n = stack.pop();
  44855. if (!isNaN(n)) {
  44856. stackDelta = -n * 2;
  44857. }
  44858. }
  44859. while (stackDelta < 0 && stack.length > 0) {
  44860. stack.pop();
  44861. stackDelta++;
  44862. }
  44863. while (stackDelta > 0) {
  44864. stack.push(NaN);
  44865. stackDelta--;
  44866. }
  44867. }
  44868. }
  44869. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44870. var content = [data];
  44871. if (i > data.length) {
  44872. content.push(new Uint8Array(i - data.length));
  44873. }
  44874. if (lastDeff > lastEndf) {
  44875. warn('TT: complementing a missing function tail');
  44876. content.push(new Uint8Array([
  44877. 0x22,
  44878. 0x2D
  44879. ]));
  44880. }
  44881. foldTTTable(table, content);
  44882. }
  44883. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44884. if (ttContext.tooComplexToFollowFunctions) {
  44885. return;
  44886. }
  44887. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44888. warn('TT: more functions defined than expected');
  44889. ttContext.hintsValid = false;
  44890. return;
  44891. }
  44892. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44893. if (j > maxFunctionDefs) {
  44894. warn('TT: invalid function id: ' + j);
  44895. ttContext.hintsValid = false;
  44896. return;
  44897. }
  44898. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44899. warn('TT: undefined function: ' + j);
  44900. ttContext.hintsValid = false;
  44901. return;
  44902. }
  44903. }
  44904. }
  44905. function foldTTTable(table, content) {
  44906. if (content.length > 1) {
  44907. var newLength = 0;
  44908. var j, jj;
  44909. for (j = 0, jj = content.length; j < jj; j++) {
  44910. newLength += content[j].length;
  44911. }
  44912. newLength = newLength + 3 & ~3;
  44913. var result = new Uint8Array(newLength);
  44914. var pos = 0;
  44915. for (j = 0, jj = content.length; j < jj; j++) {
  44916. result.set(content[j], pos);
  44917. pos += content[j].length;
  44918. }
  44919. table.data = result;
  44920. table.length = newLength;
  44921. }
  44922. }
  44923. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44924. var ttContext = {
  44925. functionsDefined: [],
  44926. functionsUsed: [],
  44927. functionsStackDeltas: [],
  44928. tooComplexToFollowFunctions: false,
  44929. hintsValid: true
  44930. };
  44931. if (fpgm) {
  44932. sanitizeTTProgram(fpgm, ttContext);
  44933. }
  44934. if (prep) {
  44935. sanitizeTTProgram(prep, ttContext);
  44936. }
  44937. if (fpgm) {
  44938. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44939. }
  44940. if (cvt && cvt.length & 1) {
  44941. var cvtData = new Uint8Array(cvt.length + 1);
  44942. cvtData.set(cvt.data);
  44943. cvt.data = cvtData;
  44944. }
  44945. return ttContext.hintsValid;
  44946. }
  44947. font = new Stream(new Uint8Array(font.getBytes()));
  44948. var VALID_TABLES = [
  44949. 'OS/2',
  44950. 'cmap',
  44951. 'head',
  44952. 'hhea',
  44953. 'hmtx',
  44954. 'maxp',
  44955. 'name',
  44956. 'post',
  44957. 'loca',
  44958. 'glyf',
  44959. 'fpgm',
  44960. 'prep',
  44961. 'cvt ',
  44962. 'CFF '
  44963. ];
  44964. var header = readOpenTypeHeader(font);
  44965. var numTables = header.numTables;
  44966. var cff, cffFile;
  44967. var tables = Object.create(null);
  44968. tables['OS/2'] = null;
  44969. tables['cmap'] = null;
  44970. tables['head'] = null;
  44971. tables['hhea'] = null;
  44972. tables['hmtx'] = null;
  44973. tables['maxp'] = null;
  44974. tables['name'] = null;
  44975. tables['post'] = null;
  44976. var table;
  44977. for (var i = 0; i < numTables; i++) {
  44978. table = readTableEntry(font);
  44979. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44980. continue;
  44981. }
  44982. if (table.length === 0) {
  44983. continue;
  44984. }
  44985. tables[table.tag] = table;
  44986. }
  44987. var isTrueType = !tables['CFF '];
  44988. if (!isTrueType) {
  44989. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44990. cffFile = new Stream(tables['CFF '].data);
  44991. cff = new CFFFont(cffFile, properties);
  44992. adjustWidths(properties);
  44993. return this.convert(name, cff, properties);
  44994. }
  44995. delete tables['glyf'];
  44996. delete tables['loca'];
  44997. delete tables['fpgm'];
  44998. delete tables['prep'];
  44999. delete tables['cvt '];
  45000. this.isOpenType = true;
  45001. } else {
  45002. if (!tables['loca']) {
  45003. error('Required "loca" table is not found');
  45004. }
  45005. if (!tables['glyf']) {
  45006. warn('Required "glyf" table is not found -- trying to recover.');
  45007. tables['glyf'] = {
  45008. tag: 'glyf',
  45009. data: new Uint8Array(0)
  45010. };
  45011. }
  45012. this.isOpenType = false;
  45013. }
  45014. if (!tables['maxp']) {
  45015. error('Required "maxp" table is not found');
  45016. }
  45017. font.pos = (font.start || 0) + tables['maxp'].offset;
  45018. var version = font.getInt32();
  45019. var numGlyphs = font.getUint16();
  45020. var maxFunctionDefs = 0;
  45021. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45022. font.pos += 8;
  45023. var maxZones = font.getUint16();
  45024. if (maxZones > 2) {
  45025. tables['maxp'].data[14] = 0;
  45026. tables['maxp'].data[15] = 2;
  45027. }
  45028. font.pos += 4;
  45029. maxFunctionDefs = font.getUint16();
  45030. }
  45031. var dupFirstEntry = false;
  45032. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45033. dupFirstEntry = true;
  45034. numGlyphs++;
  45035. tables['maxp'].data[4] = numGlyphs >> 8;
  45036. tables['maxp'].data[5] = numGlyphs & 255;
  45037. }
  45038. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45039. if (!hintsValid) {
  45040. delete tables['fpgm'];
  45041. delete tables['prep'];
  45042. delete tables['cvt '];
  45043. }
  45044. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45045. if (!tables['head']) {
  45046. error('Required "head" table is not found');
  45047. }
  45048. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45049. var missingGlyphs = Object.create(null);
  45050. if (isTrueType) {
  45051. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45052. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45053. }
  45054. if (!tables['hhea']) {
  45055. error('Required "hhea" table is not found');
  45056. }
  45057. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45058. tables['hhea'].data[10] = 0xFF;
  45059. tables['hhea'].data[11] = 0xFF;
  45060. }
  45061. var metricsOverride = {
  45062. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45063. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45064. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45065. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45066. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45067. };
  45068. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45069. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45070. if (tables['post']) {
  45071. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45072. if (!valid) {
  45073. tables['post'] = null;
  45074. }
  45075. }
  45076. var charCodeToGlyphId = [], charCode;
  45077. var toUnicode = properties.toUnicode, widths = properties.widths;
  45078. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45079. function hasGlyph(glyphId, charCode, widthCode) {
  45080. if (!missingGlyphs[glyphId]) {
  45081. return true;
  45082. }
  45083. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45084. return true;
  45085. }
  45086. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45087. return true;
  45088. }
  45089. return false;
  45090. }
  45091. if (properties.composite) {
  45092. var cidToGidMap = properties.cidToGidMap || [];
  45093. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45094. properties.cMap.forEach(function (charCode, cid) {
  45095. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45096. var glyphId = -1;
  45097. if (isCidToGidMapEmpty) {
  45098. glyphId = cid;
  45099. } else if (cidToGidMap[cid] !== undefined) {
  45100. glyphId = cidToGidMap[cid];
  45101. }
  45102. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45103. charCodeToGlyphId[charCode] = glyphId;
  45104. }
  45105. });
  45106. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45107. charCodeToGlyphId[0] = numGlyphs - 1;
  45108. }
  45109. } else {
  45110. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45111. var cmapPlatformId = cmapTable.platformId;
  45112. var cmapEncodingId = cmapTable.encodingId;
  45113. var cmapMappings = cmapTable.mappings;
  45114. var cmapMappingsLength = cmapMappings.length;
  45115. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45116. var baseEncoding = [];
  45117. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45118. baseEncoding = getEncoding(properties.baseEncodingName);
  45119. }
  45120. var glyphsUnicodeMap = getGlyphsUnicode();
  45121. for (charCode = 0; charCode < 256; charCode++) {
  45122. var glyphName, standardGlyphName;
  45123. if (this.differences && charCode in this.differences) {
  45124. glyphName = this.differences[charCode];
  45125. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45126. glyphName = baseEncoding[charCode];
  45127. } else {
  45128. glyphName = StandardEncoding[charCode];
  45129. }
  45130. if (!glyphName) {
  45131. continue;
  45132. }
  45133. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45134. var unicodeOrCharCode, isUnicode = false;
  45135. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45136. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45137. isUnicode = true;
  45138. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45139. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45140. }
  45141. var found = false;
  45142. for (i = 0; i < cmapMappingsLength; ++i) {
  45143. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45144. continue;
  45145. }
  45146. var code = isUnicode ? charCode : unicodeOrCharCode;
  45147. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45148. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45149. found = true;
  45150. break;
  45151. }
  45152. }
  45153. if (!found && properties.glyphNames) {
  45154. var glyphId = properties.glyphNames.indexOf(glyphName);
  45155. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45156. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45157. }
  45158. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45159. charCodeToGlyphId[charCode] = glyphId;
  45160. found = true;
  45161. }
  45162. }
  45163. if (!found) {
  45164. charCodeToGlyphId[charCode] = 0;
  45165. }
  45166. }
  45167. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45168. for (i = 0; i < cmapMappingsLength; ++i) {
  45169. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45170. }
  45171. } else {
  45172. for (i = 0; i < cmapMappingsLength; ++i) {
  45173. charCode = cmapMappings[i].charCode & 0xFF;
  45174. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45175. }
  45176. }
  45177. }
  45178. if (charCodeToGlyphId.length === 0) {
  45179. charCodeToGlyphId[0] = 0;
  45180. }
  45181. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45182. this.toFontChar = newMapping.toFontChar;
  45183. tables['cmap'] = {
  45184. tag: 'cmap',
  45185. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45186. };
  45187. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45188. tables['OS/2'] = {
  45189. tag: 'OS/2',
  45190. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45191. };
  45192. }
  45193. if (!tables['post']) {
  45194. tables['post'] = {
  45195. tag: 'post',
  45196. data: createPostTable(properties)
  45197. };
  45198. }
  45199. if (!isTrueType) {
  45200. try {
  45201. cffFile = new Stream(tables['CFF '].data);
  45202. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45203. cff = parser.parse();
  45204. var compiler = new CFFCompiler(cff);
  45205. tables['CFF '].data = compiler.compile();
  45206. } catch (e) {
  45207. warn('Failed to compile font ' + properties.loadedName);
  45208. }
  45209. }
  45210. if (!tables['name']) {
  45211. tables['name'] = {
  45212. tag: 'name',
  45213. data: createNameTable(this.name)
  45214. };
  45215. } else {
  45216. var namePrototype = readNameTable(tables['name']);
  45217. tables['name'].data = createNameTable(name, namePrototype);
  45218. }
  45219. var builder = new OpenTypeFileBuilder(header.version);
  45220. for (var tableTag in tables) {
  45221. builder.addTable(tableTag, tables[tableTag].data);
  45222. }
  45223. return builder.toArray();
  45224. },
  45225. convert: function Font_convert(fontName, font, properties) {
  45226. properties.fixedPitch = false;
  45227. if (properties.builtInEncoding) {
  45228. adjustToUnicode(properties, properties.builtInEncoding);
  45229. }
  45230. var mapping = font.getGlyphMapping(properties);
  45231. var newMapping = adjustMapping(mapping, properties);
  45232. this.toFontChar = newMapping.toFontChar;
  45233. var numGlyphs = font.numGlyphs;
  45234. function getCharCodes(charCodeToGlyphId, glyphId) {
  45235. var charCodes = null;
  45236. for (var charCode in charCodeToGlyphId) {
  45237. if (glyphId === charCodeToGlyphId[charCode]) {
  45238. if (!charCodes) {
  45239. charCodes = [];
  45240. }
  45241. charCodes.push(charCode | 0);
  45242. }
  45243. }
  45244. return charCodes;
  45245. }
  45246. function createCharCode(charCodeToGlyphId, glyphId) {
  45247. for (var charCode in charCodeToGlyphId) {
  45248. if (glyphId === charCodeToGlyphId[charCode]) {
  45249. return charCode | 0;
  45250. }
  45251. }
  45252. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  45253. return newMapping.nextAvailableFontCharCode++;
  45254. }
  45255. var seacs = font.seacs;
  45256. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  45257. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  45258. var charset = font.getCharset();
  45259. var seacMap = Object.create(null);
  45260. for (var glyphId in seacs) {
  45261. glyphId |= 0;
  45262. var seac = seacs[glyphId];
  45263. var baseGlyphName = StandardEncoding[seac[2]];
  45264. var accentGlyphName = StandardEncoding[seac[3]];
  45265. var baseGlyphId = charset.indexOf(baseGlyphName);
  45266. var accentGlyphId = charset.indexOf(accentGlyphName);
  45267. if (baseGlyphId < 0 || accentGlyphId < 0) {
  45268. continue;
  45269. }
  45270. var accentOffset = {
  45271. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  45272. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  45273. };
  45274. var charCodes = getCharCodes(mapping, glyphId);
  45275. if (!charCodes) {
  45276. continue;
  45277. }
  45278. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  45279. var charCode = charCodes[i];
  45280. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  45281. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  45282. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  45283. seacMap[charCode] = {
  45284. baseFontCharCode: baseFontCharCode,
  45285. accentFontCharCode: accentFontCharCode,
  45286. accentOffset: accentOffset
  45287. };
  45288. }
  45289. }
  45290. properties.seacMap = seacMap;
  45291. }
  45292. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45293. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  45294. builder.addTable('CFF ', font.data);
  45295. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  45296. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  45297. 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');
  45298. 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));
  45299. builder.addTable('hmtx', function fontFieldsHmtx() {
  45300. var charstrings = font.charstrings;
  45301. var cffWidths = font.cff ? font.cff.widths : null;
  45302. var hmtx = '\x00\x00\x00\x00';
  45303. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  45304. var width = 0;
  45305. if (charstrings) {
  45306. var charstring = charstrings[i - 1];
  45307. width = 'width' in charstring ? charstring.width : 0;
  45308. } else if (cffWidths) {
  45309. width = Math.ceil(cffWidths[i] || 0);
  45310. }
  45311. hmtx += string16(width) + string16(0);
  45312. }
  45313. return hmtx;
  45314. }());
  45315. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  45316. builder.addTable('name', createNameTable(fontName));
  45317. builder.addTable('post', createPostTable(properties));
  45318. return builder.toArray();
  45319. },
  45320. get spaceWidth() {
  45321. if ('_shadowWidth' in this) {
  45322. return this._shadowWidth;
  45323. }
  45324. var possibleSpaceReplacements = [
  45325. 'space',
  45326. 'minus',
  45327. 'one',
  45328. 'i',
  45329. 'I'
  45330. ];
  45331. var width;
  45332. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  45333. var glyphName = possibleSpaceReplacements[i];
  45334. if (glyphName in this.widths) {
  45335. width = this.widths[glyphName];
  45336. break;
  45337. }
  45338. var glyphsUnicodeMap = getGlyphsUnicode();
  45339. var glyphUnicode = glyphsUnicodeMap[glyphName];
  45340. var charcode = 0;
  45341. if (this.composite) {
  45342. if (this.cMap.contains(glyphUnicode)) {
  45343. charcode = this.cMap.lookup(glyphUnicode);
  45344. }
  45345. }
  45346. if (!charcode && this.toUnicode) {
  45347. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  45348. }
  45349. if (charcode <= 0) {
  45350. charcode = glyphUnicode;
  45351. }
  45352. width = this.widths[charcode];
  45353. if (width) {
  45354. break;
  45355. }
  45356. }
  45357. width = width || this.defaultWidth;
  45358. this._shadowWidth = width;
  45359. return width;
  45360. },
  45361. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  45362. var fontCharCode, width, operatorListId;
  45363. var widthCode = charcode;
  45364. if (this.cMap && this.cMap.contains(charcode)) {
  45365. widthCode = this.cMap.lookup(charcode);
  45366. }
  45367. width = this.widths[widthCode];
  45368. width = isNum(width) ? width : this.defaultWidth;
  45369. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  45370. var unicode = this.toUnicode.get(charcode) || charcode;
  45371. if (typeof unicode === 'number') {
  45372. unicode = String.fromCharCode(unicode);
  45373. }
  45374. var isInFont = charcode in this.toFontChar;
  45375. fontCharCode = this.toFontChar[charcode] || charcode;
  45376. if (this.missingFile) {
  45377. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  45378. }
  45379. if (this.isType3Font) {
  45380. operatorListId = fontCharCode;
  45381. }
  45382. var accent = null;
  45383. if (this.seacMap && this.seacMap[charcode]) {
  45384. isInFont = true;
  45385. var seac = this.seacMap[charcode];
  45386. fontCharCode = seac.baseFontCharCode;
  45387. accent = {
  45388. fontChar: String.fromCharCode(seac.accentFontCharCode),
  45389. offset: seac.accentOffset
  45390. };
  45391. }
  45392. var fontChar = String.fromCharCode(fontCharCode);
  45393. var glyph = this.glyphCache[charcode];
  45394. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  45395. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  45396. this.glyphCache[charcode] = glyph;
  45397. }
  45398. return glyph;
  45399. },
  45400. charsToGlyphs: function Font_charsToGlyphs(chars) {
  45401. var charsCache = this.charsCache;
  45402. var glyphs, glyph, charcode;
  45403. if (charsCache) {
  45404. glyphs = charsCache[chars];
  45405. if (glyphs) {
  45406. return glyphs;
  45407. }
  45408. }
  45409. if (!charsCache) {
  45410. charsCache = this.charsCache = Object.create(null);
  45411. }
  45412. glyphs = [];
  45413. var charsCacheKey = chars;
  45414. var i = 0, ii;
  45415. if (this.cMap) {
  45416. var c = Object.create(null);
  45417. while (i < chars.length) {
  45418. this.cMap.readCharCode(chars, i, c);
  45419. charcode = c.charcode;
  45420. var length = c.length;
  45421. i += length;
  45422. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  45423. glyph = this.charToGlyph(charcode, isSpace);
  45424. glyphs.push(glyph);
  45425. }
  45426. } else {
  45427. for (i = 0, ii = chars.length; i < ii; ++i) {
  45428. charcode = chars.charCodeAt(i);
  45429. glyph = this.charToGlyph(charcode, charcode === 0x20);
  45430. glyphs.push(glyph);
  45431. }
  45432. }
  45433. return charsCache[charsCacheKey] = glyphs;
  45434. }
  45435. };
  45436. return Font;
  45437. }();
  45438. var ErrorFont = function ErrorFontClosure() {
  45439. function ErrorFont(error) {
  45440. this.error = error;
  45441. this.loadedName = 'g_font_error';
  45442. this.loading = false;
  45443. }
  45444. ErrorFont.prototype = {
  45445. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45446. return [];
  45447. },
  45448. exportData: function ErrorFont_exportData() {
  45449. return { error: this.error };
  45450. }
  45451. };
  45452. return ErrorFont;
  45453. }();
  45454. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45455. var charCodeToGlyphId = Object.create(null);
  45456. var glyphId, charCode, baseEncoding;
  45457. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45458. if (properties.baseEncodingName) {
  45459. baseEncoding = getEncoding(properties.baseEncodingName);
  45460. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45461. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45462. if (glyphId >= 0) {
  45463. charCodeToGlyphId[charCode] = glyphId;
  45464. } else {
  45465. charCodeToGlyphId[charCode] = 0;
  45466. }
  45467. }
  45468. } else if (isSymbolicFont) {
  45469. for (charCode in builtInEncoding) {
  45470. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45471. }
  45472. } else {
  45473. baseEncoding = StandardEncoding;
  45474. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45475. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45476. if (glyphId >= 0) {
  45477. charCodeToGlyphId[charCode] = glyphId;
  45478. } else {
  45479. charCodeToGlyphId[charCode] = 0;
  45480. }
  45481. }
  45482. }
  45483. var differences = properties.differences, glyphsUnicodeMap;
  45484. if (differences) {
  45485. for (charCode in differences) {
  45486. var glyphName = differences[charCode];
  45487. glyphId = glyphNames.indexOf(glyphName);
  45488. if (glyphId === -1) {
  45489. if (!glyphsUnicodeMap) {
  45490. glyphsUnicodeMap = getGlyphsUnicode();
  45491. }
  45492. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45493. if (standardGlyphName !== glyphName) {
  45494. glyphId = glyphNames.indexOf(standardGlyphName);
  45495. }
  45496. }
  45497. if (glyphId >= 0) {
  45498. charCodeToGlyphId[charCode] = glyphId;
  45499. } else {
  45500. charCodeToGlyphId[charCode] = 0;
  45501. }
  45502. }
  45503. }
  45504. return charCodeToGlyphId;
  45505. }
  45506. var Type1Font = function Type1FontClosure() {
  45507. function findBlock(streamBytes, signature, startIndex) {
  45508. var streamBytesLength = streamBytes.length;
  45509. var signatureLength = signature.length;
  45510. var scanLength = streamBytesLength - signatureLength;
  45511. var i = startIndex, j, found = false;
  45512. while (i < scanLength) {
  45513. j = 0;
  45514. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45515. j++;
  45516. }
  45517. if (j >= signatureLength) {
  45518. i += j;
  45519. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45520. i++;
  45521. }
  45522. found = true;
  45523. break;
  45524. }
  45525. i++;
  45526. }
  45527. return {
  45528. found: found,
  45529. length: i
  45530. };
  45531. }
  45532. function getHeaderBlock(stream, suggestedLength) {
  45533. var EEXEC_SIGNATURE = [
  45534. 0x65,
  45535. 0x65,
  45536. 0x78,
  45537. 0x65,
  45538. 0x63
  45539. ];
  45540. var streamStartPos = stream.pos;
  45541. var headerBytes, headerBytesLength, block;
  45542. try {
  45543. headerBytes = stream.getBytes(suggestedLength);
  45544. headerBytesLength = headerBytes.length;
  45545. } catch (ex) {
  45546. if (ex instanceof MissingDataException) {
  45547. throw ex;
  45548. }
  45549. }
  45550. if (headerBytesLength === suggestedLength) {
  45551. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45552. if (block.found && block.length === suggestedLength) {
  45553. return {
  45554. stream: new Stream(headerBytes),
  45555. length: suggestedLength
  45556. };
  45557. }
  45558. }
  45559. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45560. stream.pos = streamStartPos;
  45561. var SCAN_BLOCK_LENGTH = 2048;
  45562. var actualLength;
  45563. while (true) {
  45564. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45565. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45566. if (block.length === 0) {
  45567. break;
  45568. }
  45569. stream.pos += block.length;
  45570. if (block.found) {
  45571. actualLength = stream.pos - streamStartPos;
  45572. break;
  45573. }
  45574. }
  45575. stream.pos = streamStartPos;
  45576. if (actualLength) {
  45577. return {
  45578. stream: new Stream(stream.getBytes(actualLength)),
  45579. length: actualLength
  45580. };
  45581. }
  45582. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45583. return {
  45584. stream: new Stream(stream.getBytes(suggestedLength)),
  45585. length: suggestedLength
  45586. };
  45587. }
  45588. function getEexecBlock(stream, suggestedLength) {
  45589. var eexecBytes = stream.getBytes();
  45590. return {
  45591. stream: new Stream(eexecBytes),
  45592. length: eexecBytes.length
  45593. };
  45594. }
  45595. function Type1Font(name, file, properties) {
  45596. var PFB_HEADER_SIZE = 6;
  45597. var headerBlockLength = properties.length1;
  45598. var eexecBlockLength = properties.length2;
  45599. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45600. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45601. if (pfbHeaderPresent) {
  45602. file.skip(PFB_HEADER_SIZE);
  45603. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45604. }
  45605. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45606. headerBlockLength = headerBlock.length;
  45607. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45608. headerBlockParser.extractFontHeader(properties);
  45609. if (pfbHeaderPresent) {
  45610. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45611. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45612. }
  45613. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45614. eexecBlockLength = eexecBlock.length;
  45615. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45616. var data = eexecBlockParser.extractFontProgram();
  45617. for (var info in data.properties) {
  45618. properties[info] = data.properties[info];
  45619. }
  45620. var charstrings = data.charstrings;
  45621. var type2Charstrings = this.getType2Charstrings(charstrings);
  45622. var subrs = this.getType2Subrs(data.subrs);
  45623. this.charstrings = charstrings;
  45624. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45625. this.seacs = this.getSeacs(data.charstrings);
  45626. }
  45627. Type1Font.prototype = {
  45628. get numGlyphs() {
  45629. return this.charstrings.length + 1;
  45630. },
  45631. getCharset: function Type1Font_getCharset() {
  45632. var charset = ['.notdef'];
  45633. var charstrings = this.charstrings;
  45634. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45635. charset.push(charstrings[glyphId].glyphName);
  45636. }
  45637. return charset;
  45638. },
  45639. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45640. var charstrings = this.charstrings;
  45641. var glyphNames = ['.notdef'], glyphId;
  45642. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45643. glyphNames.push(charstrings[glyphId].glyphName);
  45644. }
  45645. var encoding = properties.builtInEncoding;
  45646. if (encoding) {
  45647. var builtInEncoding = Object.create(null);
  45648. for (var charCode in encoding) {
  45649. glyphId = glyphNames.indexOf(encoding[charCode]);
  45650. if (glyphId >= 0) {
  45651. builtInEncoding[charCode] = glyphId;
  45652. }
  45653. }
  45654. }
  45655. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45656. },
  45657. getSeacs: function Type1Font_getSeacs(charstrings) {
  45658. var i, ii;
  45659. var seacMap = [];
  45660. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45661. var charstring = charstrings[i];
  45662. if (charstring.seac) {
  45663. seacMap[i + 1] = charstring.seac;
  45664. }
  45665. }
  45666. return seacMap;
  45667. },
  45668. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45669. var type2Charstrings = [];
  45670. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45671. type2Charstrings.push(type1Charstrings[i].charstring);
  45672. }
  45673. return type2Charstrings;
  45674. },
  45675. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45676. var bias = 0;
  45677. var count = type1Subrs.length;
  45678. if (count < 1133) {
  45679. bias = 107;
  45680. } else if (count < 33769) {
  45681. bias = 1131;
  45682. } else {
  45683. bias = 32768;
  45684. }
  45685. var type2Subrs = [];
  45686. var i;
  45687. for (i = 0; i < bias; i++) {
  45688. type2Subrs.push([0x0B]);
  45689. }
  45690. for (i = 0; i < count; i++) {
  45691. type2Subrs.push(type1Subrs[i]);
  45692. }
  45693. return type2Subrs;
  45694. },
  45695. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45696. var cff = new CFF();
  45697. cff.header = new CFFHeader(1, 0, 4, 4);
  45698. cff.names = [name];
  45699. var topDict = new CFFTopDict();
  45700. topDict.setByName('version', 391);
  45701. topDict.setByName('Notice', 392);
  45702. topDict.setByName('FullName', 393);
  45703. topDict.setByName('FamilyName', 394);
  45704. topDict.setByName('Weight', 395);
  45705. topDict.setByName('Encoding', null);
  45706. topDict.setByName('FontMatrix', properties.fontMatrix);
  45707. topDict.setByName('FontBBox', properties.bbox);
  45708. topDict.setByName('charset', null);
  45709. topDict.setByName('CharStrings', null);
  45710. topDict.setByName('Private', null);
  45711. cff.topDict = topDict;
  45712. var strings = new CFFStrings();
  45713. strings.add('Version 0.11');
  45714. strings.add('See original notice');
  45715. strings.add(name);
  45716. strings.add(name);
  45717. strings.add('Medium');
  45718. cff.strings = strings;
  45719. cff.globalSubrIndex = new CFFIndex();
  45720. var count = glyphs.length;
  45721. var charsetArray = [0];
  45722. var i, ii;
  45723. for (i = 0; i < count; i++) {
  45724. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45725. if (index === -1) {
  45726. index = 0;
  45727. }
  45728. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45729. }
  45730. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45731. var charStringsIndex = new CFFIndex();
  45732. charStringsIndex.add([
  45733. 0x8B,
  45734. 0x0E
  45735. ]);
  45736. for (i = 0; i < count; i++) {
  45737. var glyph = glyphs[i];
  45738. if (glyph.length === 0) {
  45739. charStringsIndex.add([
  45740. 0x8B,
  45741. 0x0E
  45742. ]);
  45743. continue;
  45744. }
  45745. charStringsIndex.add(glyph);
  45746. }
  45747. cff.charStrings = charStringsIndex;
  45748. var privateDict = new CFFPrivateDict();
  45749. privateDict.setByName('Subrs', null);
  45750. var fields = [
  45751. 'BlueValues',
  45752. 'OtherBlues',
  45753. 'FamilyBlues',
  45754. 'FamilyOtherBlues',
  45755. 'StemSnapH',
  45756. 'StemSnapV',
  45757. 'BlueShift',
  45758. 'BlueFuzz',
  45759. 'BlueScale',
  45760. 'LanguageGroup',
  45761. 'ExpansionFactor',
  45762. 'ForceBold',
  45763. 'StdHW',
  45764. 'StdVW'
  45765. ];
  45766. for (i = 0, ii = fields.length; i < ii; i++) {
  45767. var field = fields[i];
  45768. if (!(field in properties.privateData)) {
  45769. continue;
  45770. }
  45771. var value = properties.privateData[field];
  45772. if (isArray(value)) {
  45773. for (var j = value.length - 1; j > 0; j--) {
  45774. value[j] -= value[j - 1];
  45775. }
  45776. }
  45777. privateDict.setByName(field, value);
  45778. }
  45779. cff.topDict.privateDict = privateDict;
  45780. var subrIndex = new CFFIndex();
  45781. for (i = 0, ii = subrs.length; i < ii; i++) {
  45782. subrIndex.add(subrs[i]);
  45783. }
  45784. privateDict.subrsIndex = subrIndex;
  45785. var compiler = new CFFCompiler(cff);
  45786. return compiler.compile();
  45787. }
  45788. };
  45789. return Type1Font;
  45790. }();
  45791. var CFFFont = function CFFFontClosure() {
  45792. function CFFFont(file, properties) {
  45793. this.properties = properties;
  45794. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45795. this.cff = parser.parse();
  45796. var compiler = new CFFCompiler(this.cff);
  45797. this.seacs = this.cff.seacs;
  45798. try {
  45799. this.data = compiler.compile();
  45800. } catch (e) {
  45801. warn('Failed to compile font ' + properties.loadedName);
  45802. this.data = file;
  45803. }
  45804. }
  45805. CFFFont.prototype = {
  45806. get numGlyphs() {
  45807. return this.cff.charStrings.count;
  45808. },
  45809. getCharset: function CFFFont_getCharset() {
  45810. return this.cff.charset.charset;
  45811. },
  45812. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45813. var cff = this.cff;
  45814. var properties = this.properties;
  45815. var charsets = cff.charset.charset;
  45816. var charCodeToGlyphId;
  45817. var glyphId;
  45818. if (properties.composite) {
  45819. charCodeToGlyphId = Object.create(null);
  45820. if (cff.isCIDFont) {
  45821. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45822. var cid = charsets[glyphId];
  45823. var charCode = properties.cMap.charCodeOf(cid);
  45824. charCodeToGlyphId[charCode] = glyphId;
  45825. }
  45826. } else {
  45827. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45828. charCodeToGlyphId[glyphId] = glyphId;
  45829. }
  45830. }
  45831. return charCodeToGlyphId;
  45832. }
  45833. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45834. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45835. return charCodeToGlyphId;
  45836. }
  45837. };
  45838. return CFFFont;
  45839. }();
  45840. (function checkSeacSupport() {
  45841. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45842. SEAC_ANALYSIS_ENABLED = true;
  45843. }
  45844. }());
  45845. (function checkChromeWindows() {
  45846. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45847. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45848. }
  45849. }());
  45850. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  45851. exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START;
  45852. exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
  45853. exports.ErrorFont = ErrorFont;
  45854. exports.Font = Font;
  45855. exports.FontFlags = FontFlags;
  45856. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45857. exports.ProblematicCharRanges = ProblematicCharRanges;
  45858. exports.ToUnicodeMap = ToUnicodeMap;
  45859. exports.getFontType = getFontType;
  45860. /***/ }),
  45861. /* 34 */
  45862. /***/ (function(module, exports, __w_pdfjs_require__) {
  45863. "use strict";
  45864. var sharedUtil = __w_pdfjs_require__(0);
  45865. var corePrimitives = __w_pdfjs_require__(1);
  45866. var coreColorSpace = __w_pdfjs_require__(4);
  45867. var coreStream = __w_pdfjs_require__(2);
  45868. var coreJpx = __w_pdfjs_require__(19);
  45869. var ImageKind = sharedUtil.ImageKind;
  45870. var assert = sharedUtil.assert;
  45871. var error = sharedUtil.error;
  45872. var info = sharedUtil.info;
  45873. var isArray = sharedUtil.isArray;
  45874. var warn = sharedUtil.warn;
  45875. var Name = corePrimitives.Name;
  45876. var isStream = corePrimitives.isStream;
  45877. var ColorSpace = coreColorSpace.ColorSpace;
  45878. var DecodeStream = coreStream.DecodeStream;
  45879. var JpegStream = coreStream.JpegStream;
  45880. var JpxImage = coreJpx.JpxImage;
  45881. var PDFImage = function PDFImageClosure() {
  45882. function handleImageData(image, nativeDecoder) {
  45883. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  45884. return nativeDecoder.decode(image);
  45885. }
  45886. return Promise.resolve(image);
  45887. }
  45888. function decodeAndClamp(value, addend, coefficient, max) {
  45889. value = addend + value * coefficient;
  45890. return value < 0 ? 0 : value > max ? max : value;
  45891. }
  45892. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  45893. var length = w2 * h2;
  45894. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  45895. var xRatio = w1 / w2;
  45896. var yRatio = h1 / h2;
  45897. var i, j, py, newIndex = 0, oldIndex;
  45898. var xScaled = new Uint16Array(w2);
  45899. var w1Scanline = w1;
  45900. for (i = 0; i < w2; i++) {
  45901. xScaled[i] = Math.floor(i * xRatio);
  45902. }
  45903. for (i = 0; i < h2; i++) {
  45904. py = Math.floor(i * yRatio) * w1Scanline;
  45905. for (j = 0; j < w2; j++) {
  45906. oldIndex = py + xScaled[j];
  45907. dest[newIndex++] = src[oldIndex];
  45908. }
  45909. }
  45910. return dest;
  45911. }
  45912. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  45913. this.image = image;
  45914. var dict = image.dict;
  45915. if (dict.has('Filter')) {
  45916. var filter = dict.get('Filter').name;
  45917. if (filter === 'JPXDecode') {
  45918. var jpxImage = new JpxImage();
  45919. jpxImage.parseImageProperties(image.stream);
  45920. image.stream.reset();
  45921. image.bitsPerComponent = jpxImage.bitsPerComponent;
  45922. image.numComps = jpxImage.componentsCount;
  45923. } else if (filter === 'JBIG2Decode') {
  45924. image.bitsPerComponent = 1;
  45925. image.numComps = 1;
  45926. }
  45927. }
  45928. this.width = dict.get('Width', 'W');
  45929. this.height = dict.get('Height', 'H');
  45930. if (this.width < 1 || this.height < 1) {
  45931. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  45932. }
  45933. this.interpolate = dict.get('Interpolate', 'I') || false;
  45934. this.imageMask = dict.get('ImageMask', 'IM') || false;
  45935. this.matte = dict.get('Matte') || false;
  45936. var bitsPerComponent = image.bitsPerComponent;
  45937. if (!bitsPerComponent) {
  45938. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  45939. if (!bitsPerComponent) {
  45940. if (this.imageMask) {
  45941. bitsPerComponent = 1;
  45942. } else {
  45943. error('Bits per component missing in image: ' + this.imageMask);
  45944. }
  45945. }
  45946. }
  45947. this.bpc = bitsPerComponent;
  45948. if (!this.imageMask) {
  45949. var colorSpace = dict.get('ColorSpace', 'CS');
  45950. if (!colorSpace) {
  45951. info('JPX images (which do not require color spaces)');
  45952. switch (image.numComps) {
  45953. case 1:
  45954. colorSpace = Name.get('DeviceGray');
  45955. break;
  45956. case 3:
  45957. colorSpace = Name.get('DeviceRGB');
  45958. break;
  45959. case 4:
  45960. colorSpace = Name.get('DeviceCMYK');
  45961. break;
  45962. default:
  45963. error('JPX images with ' + this.numComps + ' color components not supported.');
  45964. }
  45965. }
  45966. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  45967. this.numComps = this.colorSpace.numComps;
  45968. }
  45969. this.decode = dict.getArray('Decode', 'D');
  45970. this.needsDecode = false;
  45971. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  45972. this.needsDecode = true;
  45973. var max = (1 << bitsPerComponent) - 1;
  45974. this.decodeCoefficients = [];
  45975. this.decodeAddends = [];
  45976. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  45977. var dmin = this.decode[i];
  45978. var dmax = this.decode[i + 1];
  45979. this.decodeCoefficients[j] = dmax - dmin;
  45980. this.decodeAddends[j] = max * dmin;
  45981. }
  45982. }
  45983. if (smask) {
  45984. this.smask = new PDFImage(xref, res, smask, false);
  45985. } else if (mask) {
  45986. if (isStream(mask)) {
  45987. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  45988. if (!imageMask) {
  45989. warn('Ignoring /Mask in image without /ImageMask.');
  45990. } else {
  45991. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  45992. }
  45993. } else {
  45994. this.mask = mask;
  45995. }
  45996. }
  45997. }
  45998. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  45999. var imagePromise = handleImageData(image, nativeDecoder);
  46000. var smaskPromise;
  46001. var maskPromise;
  46002. var smask = image.dict.get('SMask');
  46003. var mask = image.dict.get('Mask');
  46004. if (smask) {
  46005. smaskPromise = handleImageData(smask, nativeDecoder);
  46006. maskPromise = Promise.resolve(null);
  46007. } else {
  46008. smaskPromise = Promise.resolve(null);
  46009. if (mask) {
  46010. if (isStream(mask)) {
  46011. maskPromise = handleImageData(mask, nativeDecoder);
  46012. } else if (isArray(mask)) {
  46013. maskPromise = Promise.resolve(mask);
  46014. } else {
  46015. warn('Unsupported mask format.');
  46016. maskPromise = Promise.resolve(null);
  46017. }
  46018. } else {
  46019. maskPromise = Promise.resolve(null);
  46020. }
  46021. }
  46022. return Promise.all([
  46023. imagePromise,
  46024. smaskPromise,
  46025. maskPromise
  46026. ]).then(function (results) {
  46027. var imageData = results[0];
  46028. var smaskData = results[1];
  46029. var maskData = results[2];
  46030. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46031. });
  46032. };
  46033. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46034. var computedLength = (width + 7 >> 3) * height;
  46035. var actualLength = imgArray.byteLength;
  46036. var haveFullData = computedLength === actualLength;
  46037. var data, i;
  46038. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46039. data = imgArray;
  46040. } else if (!inverseDecode) {
  46041. data = new Uint8Array(actualLength);
  46042. data.set(imgArray);
  46043. } else {
  46044. data = new Uint8Array(computedLength);
  46045. data.set(imgArray);
  46046. for (i = actualLength; i < computedLength; i++) {
  46047. data[i] = 0xff;
  46048. }
  46049. }
  46050. if (inverseDecode) {
  46051. for (i = 0; i < actualLength; i++) {
  46052. data[i] = ~data[i];
  46053. }
  46054. }
  46055. return {
  46056. data: data,
  46057. width: width,
  46058. height: height
  46059. };
  46060. };
  46061. PDFImage.prototype = {
  46062. get drawWidth() {
  46063. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46064. },
  46065. get drawHeight() {
  46066. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46067. },
  46068. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46069. var bpc = this.bpc;
  46070. var numComps = this.numComps;
  46071. var decodeAddends = this.decodeAddends;
  46072. var decodeCoefficients = this.decodeCoefficients;
  46073. var max = (1 << bpc) - 1;
  46074. var i, ii;
  46075. if (bpc === 1) {
  46076. for (i = 0, ii = buffer.length; i < ii; i++) {
  46077. buffer[i] = +!buffer[i];
  46078. }
  46079. return;
  46080. }
  46081. var index = 0;
  46082. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46083. for (var j = 0; j < numComps; j++) {
  46084. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46085. index++;
  46086. }
  46087. }
  46088. },
  46089. getComponents: function PDFImage_getComponents(buffer) {
  46090. var bpc = this.bpc;
  46091. if (bpc === 8) {
  46092. return buffer;
  46093. }
  46094. var width = this.width;
  46095. var height = this.height;
  46096. var numComps = this.numComps;
  46097. var length = width * height * numComps;
  46098. var bufferPos = 0;
  46099. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46100. var rowComps = width * numComps;
  46101. var max = (1 << bpc) - 1;
  46102. var i = 0, ii, buf;
  46103. if (bpc === 1) {
  46104. var mask, loop1End, loop2End;
  46105. for (var j = 0; j < height; j++) {
  46106. loop1End = i + (rowComps & ~7);
  46107. loop2End = i + rowComps;
  46108. while (i < loop1End) {
  46109. buf = buffer[bufferPos++];
  46110. output[i] = buf >> 7 & 1;
  46111. output[i + 1] = buf >> 6 & 1;
  46112. output[i + 2] = buf >> 5 & 1;
  46113. output[i + 3] = buf >> 4 & 1;
  46114. output[i + 4] = buf >> 3 & 1;
  46115. output[i + 5] = buf >> 2 & 1;
  46116. output[i + 6] = buf >> 1 & 1;
  46117. output[i + 7] = buf & 1;
  46118. i += 8;
  46119. }
  46120. if (i < loop2End) {
  46121. buf = buffer[bufferPos++];
  46122. mask = 128;
  46123. while (i < loop2End) {
  46124. output[i++] = +!!(buf & mask);
  46125. mask >>= 1;
  46126. }
  46127. }
  46128. }
  46129. } else {
  46130. var bits = 0;
  46131. buf = 0;
  46132. for (i = 0, ii = length; i < ii; ++i) {
  46133. if (i % rowComps === 0) {
  46134. buf = 0;
  46135. bits = 0;
  46136. }
  46137. while (bits < bpc) {
  46138. buf = buf << 8 | buffer[bufferPos++];
  46139. bits += 8;
  46140. }
  46141. var remainingBits = bits - bpc;
  46142. var value = buf >> remainingBits;
  46143. output[i] = value < 0 ? 0 : value > max ? max : value;
  46144. buf = buf & (1 << remainingBits) - 1;
  46145. bits = remainingBits;
  46146. }
  46147. }
  46148. return output;
  46149. },
  46150. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46151. var smask = this.smask;
  46152. var mask = this.mask;
  46153. var alphaBuf, sw, sh, i, ii, j;
  46154. if (smask) {
  46155. sw = smask.width;
  46156. sh = smask.height;
  46157. alphaBuf = new Uint8Array(sw * sh);
  46158. smask.fillGrayBuffer(alphaBuf);
  46159. if (sw !== width || sh !== height) {
  46160. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46161. }
  46162. } else if (mask) {
  46163. if (mask instanceof PDFImage) {
  46164. sw = mask.width;
  46165. sh = mask.height;
  46166. alphaBuf = new Uint8Array(sw * sh);
  46167. mask.numComps = 1;
  46168. mask.fillGrayBuffer(alphaBuf);
  46169. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46170. alphaBuf[i] = 255 - alphaBuf[i];
  46171. }
  46172. if (sw !== width || sh !== height) {
  46173. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46174. }
  46175. } else if (isArray(mask)) {
  46176. alphaBuf = new Uint8Array(width * height);
  46177. var numComps = this.numComps;
  46178. for (i = 0, ii = width * height; i < ii; ++i) {
  46179. var opacity = 0;
  46180. var imageOffset = i * numComps;
  46181. for (j = 0; j < numComps; ++j) {
  46182. var color = image[imageOffset + j];
  46183. var maskOffset = j * 2;
  46184. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46185. opacity = 255;
  46186. break;
  46187. }
  46188. }
  46189. alphaBuf[i] = opacity;
  46190. }
  46191. } else {
  46192. error('Unknown mask format.');
  46193. }
  46194. }
  46195. if (alphaBuf) {
  46196. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46197. rgbaBuf[j] = alphaBuf[i];
  46198. }
  46199. } else {
  46200. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46201. rgbaBuf[j] = 255;
  46202. }
  46203. }
  46204. },
  46205. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46206. var matte = this.smask && this.smask.matte;
  46207. if (!matte) {
  46208. return;
  46209. }
  46210. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46211. var matteR = matteRgb[0];
  46212. var matteG = matteRgb[1];
  46213. var matteB = matteRgb[2];
  46214. var length = width * height * 4;
  46215. var r, g, b;
  46216. for (var i = 0; i < length; i += 4) {
  46217. var alpha = buffer[i + 3];
  46218. if (alpha === 0) {
  46219. buffer[i] = 255;
  46220. buffer[i + 1] = 255;
  46221. buffer[i + 2] = 255;
  46222. continue;
  46223. }
  46224. var k = 255 / alpha;
  46225. r = (buffer[i] - matteR) * k + matteR;
  46226. g = (buffer[i + 1] - matteG) * k + matteG;
  46227. b = (buffer[i + 2] - matteB) * k + matteB;
  46228. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  46229. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  46230. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  46231. }
  46232. },
  46233. createImageData: function PDFImage_createImageData(forceRGBA) {
  46234. var drawWidth = this.drawWidth;
  46235. var drawHeight = this.drawHeight;
  46236. var imgData = {
  46237. width: drawWidth,
  46238. height: drawHeight
  46239. };
  46240. var numComps = this.numComps;
  46241. var originalWidth = this.width;
  46242. var originalHeight = this.height;
  46243. var bpc = this.bpc;
  46244. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  46245. var imgArray;
  46246. if (!forceRGBA) {
  46247. var kind;
  46248. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  46249. kind = ImageKind.GRAYSCALE_1BPP;
  46250. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  46251. kind = ImageKind.RGB_24BPP;
  46252. }
  46253. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  46254. imgData.kind = kind;
  46255. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46256. if (this.image instanceof DecodeStream) {
  46257. imgData.data = imgArray;
  46258. } else {
  46259. var newArray = new Uint8Array(imgArray.length);
  46260. newArray.set(imgArray);
  46261. imgData.data = newArray;
  46262. }
  46263. if (this.needsDecode) {
  46264. assert(kind === ImageKind.GRAYSCALE_1BPP);
  46265. var buffer = imgData.data;
  46266. for (var i = 0, ii = buffer.length; i < ii; i++) {
  46267. buffer[i] ^= 0xff;
  46268. }
  46269. }
  46270. return imgData;
  46271. }
  46272. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  46273. imgData.kind = ImageKind.RGB_24BPP;
  46274. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  46275. return imgData;
  46276. }
  46277. }
  46278. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46279. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  46280. var comps = this.getComponents(imgArray);
  46281. var alpha01, maybeUndoPreblend;
  46282. if (!forceRGBA && !this.smask && !this.mask) {
  46283. imgData.kind = ImageKind.RGB_24BPP;
  46284. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  46285. alpha01 = 0;
  46286. maybeUndoPreblend = false;
  46287. } else {
  46288. imgData.kind = ImageKind.RGBA_32BPP;
  46289. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  46290. alpha01 = 1;
  46291. maybeUndoPreblend = true;
  46292. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  46293. }
  46294. if (this.needsDecode) {
  46295. this.decodeBuffer(comps);
  46296. }
  46297. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  46298. if (maybeUndoPreblend) {
  46299. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  46300. }
  46301. return imgData;
  46302. },
  46303. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  46304. var numComps = this.numComps;
  46305. if (numComps !== 1) {
  46306. error('Reading gray scale from a color image: ' + numComps);
  46307. }
  46308. var width = this.width;
  46309. var height = this.height;
  46310. var bpc = this.bpc;
  46311. var rowBytes = width * numComps * bpc + 7 >> 3;
  46312. var imgArray = this.getImageBytes(height * rowBytes);
  46313. var comps = this.getComponents(imgArray);
  46314. var i, length;
  46315. if (bpc === 1) {
  46316. length = width * height;
  46317. if (this.needsDecode) {
  46318. for (i = 0; i < length; ++i) {
  46319. buffer[i] = comps[i] - 1 & 255;
  46320. }
  46321. } else {
  46322. for (i = 0; i < length; ++i) {
  46323. buffer[i] = -comps[i] & 255;
  46324. }
  46325. }
  46326. return;
  46327. }
  46328. if (this.needsDecode) {
  46329. this.decodeBuffer(comps);
  46330. }
  46331. length = width * height;
  46332. var scale = 255 / ((1 << bpc) - 1);
  46333. for (i = 0; i < length; ++i) {
  46334. buffer[i] = scale * comps[i] | 0;
  46335. }
  46336. },
  46337. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  46338. this.image.reset();
  46339. this.image.drawWidth = drawWidth || this.width;
  46340. this.image.drawHeight = drawHeight || this.height;
  46341. this.image.forceRGB = !!forceRGB;
  46342. return this.image.getBytes(length);
  46343. }
  46344. };
  46345. return PDFImage;
  46346. }();
  46347. exports.PDFImage = PDFImage;
  46348. /***/ }),
  46349. /* 35 */
  46350. /***/ (function(module, exports, __w_pdfjs_require__) {
  46351. "use strict";
  46352. var sharedUtil = __w_pdfjs_require__(0);
  46353. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  46354. var error = sharedUtil.error;
  46355. var log2 = sharedUtil.log2;
  46356. var readInt8 = sharedUtil.readInt8;
  46357. var readUint16 = sharedUtil.readUint16;
  46358. var readUint32 = sharedUtil.readUint32;
  46359. var shadow = sharedUtil.shadow;
  46360. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  46361. var Jbig2Image = function Jbig2ImageClosure() {
  46362. function ContextCache() {
  46363. }
  46364. ContextCache.prototype = {
  46365. getContexts: function (id) {
  46366. if (id in this) {
  46367. return this[id];
  46368. }
  46369. return this[id] = new Int8Array(1 << 16);
  46370. }
  46371. };
  46372. function DecodingContext(data, start, end) {
  46373. this.data = data;
  46374. this.start = start;
  46375. this.end = end;
  46376. }
  46377. DecodingContext.prototype = {
  46378. get decoder() {
  46379. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  46380. return shadow(this, 'decoder', decoder);
  46381. },
  46382. get contextCache() {
  46383. var cache = new ContextCache();
  46384. return shadow(this, 'contextCache', cache);
  46385. }
  46386. };
  46387. function decodeInteger(contextCache, procedure, decoder) {
  46388. var contexts = contextCache.getContexts(procedure);
  46389. var prev = 1;
  46390. function readBits(length) {
  46391. var v = 0;
  46392. for (var i = 0; i < length; i++) {
  46393. var bit = decoder.readBit(contexts, prev);
  46394. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  46395. v = v << 1 | bit;
  46396. }
  46397. return v >>> 0;
  46398. }
  46399. var sign = readBits(1);
  46400. 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);
  46401. return sign === 0 ? value : value > 0 ? -value : null;
  46402. }
  46403. function decodeIAID(contextCache, decoder, codeLength) {
  46404. var contexts = contextCache.getContexts('IAID');
  46405. var prev = 1;
  46406. for (var i = 0; i < codeLength; i++) {
  46407. var bit = decoder.readBit(contexts, prev);
  46408. prev = prev << 1 | bit;
  46409. }
  46410. if (codeLength < 31) {
  46411. return prev & (1 << codeLength) - 1;
  46412. }
  46413. return prev & 0x7FFFFFFF;
  46414. }
  46415. var SegmentTypes = [
  46416. 'SymbolDictionary',
  46417. null,
  46418. null,
  46419. null,
  46420. 'IntermediateTextRegion',
  46421. null,
  46422. 'ImmediateTextRegion',
  46423. 'ImmediateLosslessTextRegion',
  46424. null,
  46425. null,
  46426. null,
  46427. null,
  46428. null,
  46429. null,
  46430. null,
  46431. null,
  46432. 'patternDictionary',
  46433. null,
  46434. null,
  46435. null,
  46436. 'IntermediateHalftoneRegion',
  46437. null,
  46438. 'ImmediateHalftoneRegion',
  46439. 'ImmediateLosslessHalftoneRegion',
  46440. null,
  46441. null,
  46442. null,
  46443. null,
  46444. null,
  46445. null,
  46446. null,
  46447. null,
  46448. null,
  46449. null,
  46450. null,
  46451. null,
  46452. 'IntermediateGenericRegion',
  46453. null,
  46454. 'ImmediateGenericRegion',
  46455. 'ImmediateLosslessGenericRegion',
  46456. 'IntermediateGenericRefinementRegion',
  46457. null,
  46458. 'ImmediateGenericRefinementRegion',
  46459. 'ImmediateLosslessGenericRefinementRegion',
  46460. null,
  46461. null,
  46462. null,
  46463. null,
  46464. 'PageInformation',
  46465. 'EndOfPage',
  46466. 'EndOfStripe',
  46467. 'EndOfFile',
  46468. 'Profiles',
  46469. 'Tables',
  46470. null,
  46471. null,
  46472. null,
  46473. null,
  46474. null,
  46475. null,
  46476. null,
  46477. null,
  46478. 'Extension'
  46479. ];
  46480. var CodingTemplates = [
  46481. [
  46482. {
  46483. x: -1,
  46484. y: -2
  46485. },
  46486. {
  46487. x: 0,
  46488. y: -2
  46489. },
  46490. {
  46491. x: 1,
  46492. y: -2
  46493. },
  46494. {
  46495. x: -2,
  46496. y: -1
  46497. },
  46498. {
  46499. x: -1,
  46500. y: -1
  46501. },
  46502. {
  46503. x: 0,
  46504. y: -1
  46505. },
  46506. {
  46507. x: 1,
  46508. y: -1
  46509. },
  46510. {
  46511. x: 2,
  46512. y: -1
  46513. },
  46514. {
  46515. x: -4,
  46516. y: 0
  46517. },
  46518. {
  46519. x: -3,
  46520. y: 0
  46521. },
  46522. {
  46523. x: -2,
  46524. y: 0
  46525. },
  46526. {
  46527. x: -1,
  46528. y: 0
  46529. }
  46530. ],
  46531. [
  46532. {
  46533. x: -1,
  46534. y: -2
  46535. },
  46536. {
  46537. x: 0,
  46538. y: -2
  46539. },
  46540. {
  46541. x: 1,
  46542. y: -2
  46543. },
  46544. {
  46545. x: 2,
  46546. y: -2
  46547. },
  46548. {
  46549. x: -2,
  46550. y: -1
  46551. },
  46552. {
  46553. x: -1,
  46554. y: -1
  46555. },
  46556. {
  46557. x: 0,
  46558. y: -1
  46559. },
  46560. {
  46561. x: 1,
  46562. y: -1
  46563. },
  46564. {
  46565. x: 2,
  46566. y: -1
  46567. },
  46568. {
  46569. x: -3,
  46570. y: 0
  46571. },
  46572. {
  46573. x: -2,
  46574. y: 0
  46575. },
  46576. {
  46577. x: -1,
  46578. y: 0
  46579. }
  46580. ],
  46581. [
  46582. {
  46583. x: -1,
  46584. y: -2
  46585. },
  46586. {
  46587. x: 0,
  46588. y: -2
  46589. },
  46590. {
  46591. x: 1,
  46592. y: -2
  46593. },
  46594. {
  46595. x: -2,
  46596. y: -1
  46597. },
  46598. {
  46599. x: -1,
  46600. y: -1
  46601. },
  46602. {
  46603. x: 0,
  46604. y: -1
  46605. },
  46606. {
  46607. x: 1,
  46608. y: -1
  46609. },
  46610. {
  46611. x: -2,
  46612. y: 0
  46613. },
  46614. {
  46615. x: -1,
  46616. y: 0
  46617. }
  46618. ],
  46619. [
  46620. {
  46621. x: -3,
  46622. y: -1
  46623. },
  46624. {
  46625. x: -2,
  46626. y: -1
  46627. },
  46628. {
  46629. x: -1,
  46630. y: -1
  46631. },
  46632. {
  46633. x: 0,
  46634. y: -1
  46635. },
  46636. {
  46637. x: 1,
  46638. y: -1
  46639. },
  46640. {
  46641. x: -4,
  46642. y: 0
  46643. },
  46644. {
  46645. x: -3,
  46646. y: 0
  46647. },
  46648. {
  46649. x: -2,
  46650. y: 0
  46651. },
  46652. {
  46653. x: -1,
  46654. y: 0
  46655. }
  46656. ]
  46657. ];
  46658. var RefinementTemplates = [
  46659. {
  46660. coding: [
  46661. {
  46662. x: 0,
  46663. y: -1
  46664. },
  46665. {
  46666. x: 1,
  46667. y: -1
  46668. },
  46669. {
  46670. x: -1,
  46671. y: 0
  46672. }
  46673. ],
  46674. reference: [
  46675. {
  46676. x: 0,
  46677. y: -1
  46678. },
  46679. {
  46680. x: 1,
  46681. y: -1
  46682. },
  46683. {
  46684. x: -1,
  46685. y: 0
  46686. },
  46687. {
  46688. x: 0,
  46689. y: 0
  46690. },
  46691. {
  46692. x: 1,
  46693. y: 0
  46694. },
  46695. {
  46696. x: -1,
  46697. y: 1
  46698. },
  46699. {
  46700. x: 0,
  46701. y: 1
  46702. },
  46703. {
  46704. x: 1,
  46705. y: 1
  46706. }
  46707. ]
  46708. },
  46709. {
  46710. coding: [
  46711. {
  46712. x: -1,
  46713. y: -1
  46714. },
  46715. {
  46716. x: 0,
  46717. y: -1
  46718. },
  46719. {
  46720. x: 1,
  46721. y: -1
  46722. },
  46723. {
  46724. x: -1,
  46725. y: 0
  46726. }
  46727. ],
  46728. reference: [
  46729. {
  46730. x: 0,
  46731. y: -1
  46732. },
  46733. {
  46734. x: -1,
  46735. y: 0
  46736. },
  46737. {
  46738. x: 0,
  46739. y: 0
  46740. },
  46741. {
  46742. x: 1,
  46743. y: 0
  46744. },
  46745. {
  46746. x: 0,
  46747. y: 1
  46748. },
  46749. {
  46750. x: 1,
  46751. y: 1
  46752. }
  46753. ]
  46754. }
  46755. ];
  46756. var ReusedContexts = [
  46757. 0x9B25,
  46758. 0x0795,
  46759. 0x00E5,
  46760. 0x0195
  46761. ];
  46762. var RefinementReusedContexts = [
  46763. 0x0020,
  46764. 0x0008
  46765. ];
  46766. function decodeBitmapTemplate0(width, height, decodingContext) {
  46767. var decoder = decodingContext.decoder;
  46768. var contexts = decodingContext.contextCache.getContexts('GB');
  46769. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  46770. var OLD_PIXEL_MASK = 0x7BF7;
  46771. for (i = 0; i < height; i++) {
  46772. row = bitmap[i] = new Uint8Array(width);
  46773. row1 = i < 1 ? row : bitmap[i - 1];
  46774. row2 = i < 2 ? row : bitmap[i - 2];
  46775. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  46776. for (j = 0; j < width; j++) {
  46777. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  46778. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  46779. }
  46780. }
  46781. return bitmap;
  46782. }
  46783. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  46784. if (mmr) {
  46785. error('JBIG2 error: MMR encoding is not supported');
  46786. }
  46787. 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) {
  46788. return decodeBitmapTemplate0(width, height, decodingContext);
  46789. }
  46790. var useskip = !!skip;
  46791. var template = CodingTemplates[templateIndex].concat(at);
  46792. template.sort(function (a, b) {
  46793. return a.y - b.y || a.x - b.x;
  46794. });
  46795. var templateLength = template.length;
  46796. var templateX = new Int8Array(templateLength);
  46797. var templateY = new Int8Array(templateLength);
  46798. var changingTemplateEntries = [];
  46799. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  46800. var c, k;
  46801. for (k = 0; k < templateLength; k++) {
  46802. templateX[k] = template[k].x;
  46803. templateY[k] = template[k].y;
  46804. minX = Math.min(minX, template[k].x);
  46805. maxX = Math.max(maxX, template[k].x);
  46806. minY = Math.min(minY, template[k].y);
  46807. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  46808. reuseMask |= 1 << templateLength - 1 - k;
  46809. } else {
  46810. changingTemplateEntries.push(k);
  46811. }
  46812. }
  46813. var changingEntriesLength = changingTemplateEntries.length;
  46814. var changingTemplateX = new Int8Array(changingEntriesLength);
  46815. var changingTemplateY = new Int8Array(changingEntriesLength);
  46816. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  46817. for (c = 0; c < changingEntriesLength; c++) {
  46818. k = changingTemplateEntries[c];
  46819. changingTemplateX[c] = template[k].x;
  46820. changingTemplateY[c] = template[k].y;
  46821. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  46822. }
  46823. var sbb_left = -minX;
  46824. var sbb_top = -minY;
  46825. var sbb_right = width - maxX;
  46826. var pseudoPixelContext = ReusedContexts[templateIndex];
  46827. var row = new Uint8Array(width);
  46828. var bitmap = [];
  46829. var decoder = decodingContext.decoder;
  46830. var contexts = decodingContext.contextCache.getContexts('GB');
  46831. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  46832. for (var i = 0; i < height; i++) {
  46833. if (prediction) {
  46834. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46835. ltp ^= sltp;
  46836. if (ltp) {
  46837. bitmap.push(row);
  46838. continue;
  46839. }
  46840. }
  46841. row = new Uint8Array(row);
  46842. bitmap.push(row);
  46843. for (j = 0; j < width; j++) {
  46844. if (useskip && skip[i][j]) {
  46845. row[j] = 0;
  46846. continue;
  46847. }
  46848. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  46849. contextLabel = contextLabel << 1 & reuseMask;
  46850. for (k = 0; k < changingEntriesLength; k++) {
  46851. i0 = i + changingTemplateY[k];
  46852. j0 = j + changingTemplateX[k];
  46853. bit = bitmap[i0][j0];
  46854. if (bit) {
  46855. bit = changingTemplateBit[k];
  46856. contextLabel |= bit;
  46857. }
  46858. }
  46859. } else {
  46860. contextLabel = 0;
  46861. shift = templateLength - 1;
  46862. for (k = 0; k < templateLength; k++, shift--) {
  46863. j0 = j + templateX[k];
  46864. if (j0 >= 0 && j0 < width) {
  46865. i0 = i + templateY[k];
  46866. if (i0 >= 0) {
  46867. bit = bitmap[i0][j0];
  46868. if (bit) {
  46869. contextLabel |= bit << shift;
  46870. }
  46871. }
  46872. }
  46873. }
  46874. }
  46875. var pixel = decoder.readBit(contexts, contextLabel);
  46876. row[j] = pixel;
  46877. }
  46878. }
  46879. return bitmap;
  46880. }
  46881. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  46882. var codingTemplate = RefinementTemplates[templateIndex].coding;
  46883. if (templateIndex === 0) {
  46884. codingTemplate = codingTemplate.concat([at[0]]);
  46885. }
  46886. var codingTemplateLength = codingTemplate.length;
  46887. var codingTemplateX = new Int32Array(codingTemplateLength);
  46888. var codingTemplateY = new Int32Array(codingTemplateLength);
  46889. var k;
  46890. for (k = 0; k < codingTemplateLength; k++) {
  46891. codingTemplateX[k] = codingTemplate[k].x;
  46892. codingTemplateY[k] = codingTemplate[k].y;
  46893. }
  46894. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  46895. if (templateIndex === 0) {
  46896. referenceTemplate = referenceTemplate.concat([at[1]]);
  46897. }
  46898. var referenceTemplateLength = referenceTemplate.length;
  46899. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  46900. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  46901. for (k = 0; k < referenceTemplateLength; k++) {
  46902. referenceTemplateX[k] = referenceTemplate[k].x;
  46903. referenceTemplateY[k] = referenceTemplate[k].y;
  46904. }
  46905. var referenceWidth = referenceBitmap[0].length;
  46906. var referenceHeight = referenceBitmap.length;
  46907. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  46908. var bitmap = [];
  46909. var decoder = decodingContext.decoder;
  46910. var contexts = decodingContext.contextCache.getContexts('GR');
  46911. var ltp = 0;
  46912. for (var i = 0; i < height; i++) {
  46913. if (prediction) {
  46914. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46915. ltp ^= sltp;
  46916. if (ltp) {
  46917. error('JBIG2 error: prediction is not supported');
  46918. }
  46919. }
  46920. var row = new Uint8Array(width);
  46921. bitmap.push(row);
  46922. for (var j = 0; j < width; j++) {
  46923. var i0, j0;
  46924. var contextLabel = 0;
  46925. for (k = 0; k < codingTemplateLength; k++) {
  46926. i0 = i + codingTemplateY[k];
  46927. j0 = j + codingTemplateX[k];
  46928. if (i0 < 0 || j0 < 0 || j0 >= width) {
  46929. contextLabel <<= 1;
  46930. } else {
  46931. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  46932. }
  46933. }
  46934. for (k = 0; k < referenceTemplateLength; k++) {
  46935. i0 = i + referenceTemplateY[k] + offsetY;
  46936. j0 = j + referenceTemplateX[k] + offsetX;
  46937. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  46938. contextLabel <<= 1;
  46939. } else {
  46940. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  46941. }
  46942. }
  46943. var pixel = decoder.readBit(contexts, contextLabel);
  46944. row[j] = pixel;
  46945. }
  46946. }
  46947. return bitmap;
  46948. }
  46949. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  46950. if (huffman) {
  46951. error('JBIG2 error: huffman is not supported');
  46952. }
  46953. var newSymbols = [];
  46954. var currentHeight = 0;
  46955. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  46956. var decoder = decodingContext.decoder;
  46957. var contextCache = decodingContext.contextCache;
  46958. while (newSymbols.length < numberOfNewSymbols) {
  46959. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  46960. currentHeight += deltaHeight;
  46961. var currentWidth = 0;
  46962. while (true) {
  46963. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  46964. if (deltaWidth === null) {
  46965. break;
  46966. }
  46967. currentWidth += deltaWidth;
  46968. var bitmap;
  46969. if (refinement) {
  46970. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  46971. if (numberOfInstances > 1) {
  46972. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  46973. } else {
  46974. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  46975. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  46976. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  46977. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  46978. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  46979. }
  46980. } else {
  46981. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  46982. }
  46983. newSymbols.push(bitmap);
  46984. }
  46985. }
  46986. var exportedSymbols = [];
  46987. var flags = [], currentFlag = false;
  46988. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  46989. while (flags.length < totalSymbolsLength) {
  46990. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  46991. while (runLength--) {
  46992. flags.push(currentFlag);
  46993. }
  46994. currentFlag = !currentFlag;
  46995. }
  46996. for (var i = 0, ii = symbols.length; i < ii; i++) {
  46997. if (flags[i]) {
  46998. exportedSymbols.push(symbols[i]);
  46999. }
  47000. }
  47001. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47002. if (flags[i]) {
  47003. exportedSymbols.push(newSymbols[j]);
  47004. }
  47005. }
  47006. return exportedSymbols;
  47007. }
  47008. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47009. if (huffman) {
  47010. error('JBIG2 error: huffman is not supported');
  47011. }
  47012. var bitmap = [];
  47013. var i, row;
  47014. for (i = 0; i < height; i++) {
  47015. row = new Uint8Array(width);
  47016. if (defaultPixelValue) {
  47017. for (var j = 0; j < width; j++) {
  47018. row[j] = defaultPixelValue;
  47019. }
  47020. }
  47021. bitmap.push(row);
  47022. }
  47023. var decoder = decodingContext.decoder;
  47024. var contextCache = decodingContext.contextCache;
  47025. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47026. var firstS = 0;
  47027. i = 0;
  47028. while (i < numberOfSymbolInstances) {
  47029. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47030. stripT += deltaT;
  47031. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47032. firstS += deltaFirstS;
  47033. var currentS = firstS;
  47034. do {
  47035. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47036. var t = stripSize * stripT + currentT;
  47037. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47038. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47039. var symbolBitmap = inputSymbols[symbolId];
  47040. var symbolWidth = symbolBitmap[0].length;
  47041. var symbolHeight = symbolBitmap.length;
  47042. if (applyRefinement) {
  47043. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47044. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47045. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47046. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47047. symbolWidth += rdw;
  47048. symbolHeight += rdh;
  47049. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47050. }
  47051. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47052. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47053. var s2, t2, symbolRow;
  47054. if (transposed) {
  47055. for (s2 = 0; s2 < symbolHeight; s2++) {
  47056. row = bitmap[offsetS + s2];
  47057. if (!row) {
  47058. continue;
  47059. }
  47060. symbolRow = symbolBitmap[s2];
  47061. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47062. switch (combinationOperator) {
  47063. case 0:
  47064. for (t2 = 0; t2 < maxWidth; t2++) {
  47065. row[offsetT + t2] |= symbolRow[t2];
  47066. }
  47067. break;
  47068. case 2:
  47069. for (t2 = 0; t2 < maxWidth; t2++) {
  47070. row[offsetT + t2] ^= symbolRow[t2];
  47071. }
  47072. break;
  47073. default:
  47074. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47075. }
  47076. }
  47077. currentS += symbolHeight - 1;
  47078. } else {
  47079. for (t2 = 0; t2 < symbolHeight; t2++) {
  47080. row = bitmap[offsetT + t2];
  47081. if (!row) {
  47082. continue;
  47083. }
  47084. symbolRow = symbolBitmap[t2];
  47085. switch (combinationOperator) {
  47086. case 0:
  47087. for (s2 = 0; s2 < symbolWidth; s2++) {
  47088. row[offsetS + s2] |= symbolRow[s2];
  47089. }
  47090. break;
  47091. case 2:
  47092. for (s2 = 0; s2 < symbolWidth; s2++) {
  47093. row[offsetS + s2] ^= symbolRow[s2];
  47094. }
  47095. break;
  47096. default:
  47097. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47098. }
  47099. }
  47100. currentS += symbolWidth - 1;
  47101. }
  47102. i++;
  47103. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47104. if (deltaS === null) {
  47105. break;
  47106. }
  47107. currentS += deltaS + dsOffset;
  47108. } while (true);
  47109. }
  47110. return bitmap;
  47111. }
  47112. function readSegmentHeader(data, start) {
  47113. var segmentHeader = {};
  47114. segmentHeader.number = readUint32(data, start);
  47115. var flags = data[start + 4];
  47116. var segmentType = flags & 0x3F;
  47117. if (!SegmentTypes[segmentType]) {
  47118. error('JBIG2 error: invalid segment type: ' + segmentType);
  47119. }
  47120. segmentHeader.type = segmentType;
  47121. segmentHeader.typeName = SegmentTypes[segmentType];
  47122. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47123. var pageAssociationFieldSize = !!(flags & 0x40);
  47124. var referredFlags = data[start + 5];
  47125. var referredToCount = referredFlags >> 5 & 7;
  47126. var retainBits = [referredFlags & 31];
  47127. var position = start + 6;
  47128. if (referredFlags === 7) {
  47129. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47130. position += 3;
  47131. var bytes = referredToCount + 7 >> 3;
  47132. retainBits[0] = data[position++];
  47133. while (--bytes > 0) {
  47134. retainBits.push(data[position++]);
  47135. }
  47136. } else if (referredFlags === 5 || referredFlags === 6) {
  47137. error('JBIG2 error: invalid referred-to flags');
  47138. }
  47139. segmentHeader.retainBits = retainBits;
  47140. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47141. var referredTo = [];
  47142. var i, ii;
  47143. for (i = 0; i < referredToCount; i++) {
  47144. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47145. referredTo.push(number);
  47146. position += referredToSegmentNumberSize;
  47147. }
  47148. segmentHeader.referredTo = referredTo;
  47149. if (!pageAssociationFieldSize) {
  47150. segmentHeader.pageAssociation = data[position++];
  47151. } else {
  47152. segmentHeader.pageAssociation = readUint32(data, position);
  47153. position += 4;
  47154. }
  47155. segmentHeader.length = readUint32(data, position);
  47156. position += 4;
  47157. if (segmentHeader.length === 0xFFFFFFFF) {
  47158. if (segmentType === 38) {
  47159. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47160. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47161. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47162. var searchPatternLength = 6;
  47163. var searchPattern = new Uint8Array(searchPatternLength);
  47164. if (!genericRegionMmr) {
  47165. searchPattern[0] = 0xFF;
  47166. searchPattern[1] = 0xAC;
  47167. }
  47168. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47169. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47170. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47171. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47172. for (i = position, ii = data.length; i < ii; i++) {
  47173. var j = 0;
  47174. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47175. j++;
  47176. }
  47177. if (j === searchPatternLength) {
  47178. segmentHeader.length = i + searchPatternLength;
  47179. break;
  47180. }
  47181. }
  47182. if (segmentHeader.length === 0xFFFFFFFF) {
  47183. error('JBIG2 error: segment end was not found');
  47184. }
  47185. } else {
  47186. error('JBIG2 error: invalid unknown segment length');
  47187. }
  47188. }
  47189. segmentHeader.headerEnd = position;
  47190. return segmentHeader;
  47191. }
  47192. function readSegments(header, data, start, end) {
  47193. var segments = [];
  47194. var position = start;
  47195. while (position < end) {
  47196. var segmentHeader = readSegmentHeader(data, position);
  47197. position = segmentHeader.headerEnd;
  47198. var segment = {
  47199. header: segmentHeader,
  47200. data: data
  47201. };
  47202. if (!header.randomAccess) {
  47203. segment.start = position;
  47204. position += segmentHeader.length;
  47205. segment.end = position;
  47206. }
  47207. segments.push(segment);
  47208. if (segmentHeader.type === 51) {
  47209. break;
  47210. }
  47211. }
  47212. if (header.randomAccess) {
  47213. for (var i = 0, ii = segments.length; i < ii; i++) {
  47214. segments[i].start = position;
  47215. position += segments[i].header.length;
  47216. segments[i].end = position;
  47217. }
  47218. }
  47219. return segments;
  47220. }
  47221. function readRegionSegmentInformation(data, start) {
  47222. return {
  47223. width: readUint32(data, start),
  47224. height: readUint32(data, start + 4),
  47225. x: readUint32(data, start + 8),
  47226. y: readUint32(data, start + 12),
  47227. combinationOperator: data[start + 16] & 7
  47228. };
  47229. }
  47230. var RegionSegmentInformationFieldLength = 17;
  47231. function processSegment(segment, visitor) {
  47232. var header = segment.header;
  47233. var data = segment.data, position = segment.start, end = segment.end;
  47234. var args, at, i, atLength;
  47235. switch (header.type) {
  47236. case 0:
  47237. var dictionary = {};
  47238. var dictionaryFlags = readUint16(data, position);
  47239. dictionary.huffman = !!(dictionaryFlags & 1);
  47240. dictionary.refinement = !!(dictionaryFlags & 2);
  47241. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  47242. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  47243. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  47244. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  47245. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  47246. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  47247. dictionary.template = dictionaryFlags >> 10 & 3;
  47248. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  47249. position += 2;
  47250. if (!dictionary.huffman) {
  47251. atLength = dictionary.template === 0 ? 4 : 1;
  47252. at = [];
  47253. for (i = 0; i < atLength; i++) {
  47254. at.push({
  47255. x: readInt8(data, position),
  47256. y: readInt8(data, position + 1)
  47257. });
  47258. position += 2;
  47259. }
  47260. dictionary.at = at;
  47261. }
  47262. if (dictionary.refinement && !dictionary.refinementTemplate) {
  47263. at = [];
  47264. for (i = 0; i < 2; i++) {
  47265. at.push({
  47266. x: readInt8(data, position),
  47267. y: readInt8(data, position + 1)
  47268. });
  47269. position += 2;
  47270. }
  47271. dictionary.refinementAt = at;
  47272. }
  47273. dictionary.numberOfExportedSymbols = readUint32(data, position);
  47274. position += 4;
  47275. dictionary.numberOfNewSymbols = readUint32(data, position);
  47276. position += 4;
  47277. args = [
  47278. dictionary,
  47279. header.number,
  47280. header.referredTo,
  47281. data,
  47282. position,
  47283. end
  47284. ];
  47285. break;
  47286. case 6:
  47287. case 7:
  47288. var textRegion = {};
  47289. textRegion.info = readRegionSegmentInformation(data, position);
  47290. position += RegionSegmentInformationFieldLength;
  47291. var textRegionSegmentFlags = readUint16(data, position);
  47292. position += 2;
  47293. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  47294. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  47295. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  47296. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  47297. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  47298. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  47299. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  47300. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  47301. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  47302. if (textRegion.huffman) {
  47303. var textRegionHuffmanFlags = readUint16(data, position);
  47304. position += 2;
  47305. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  47306. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  47307. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  47308. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  47309. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  47310. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  47311. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  47312. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  47313. }
  47314. if (textRegion.refinement && !textRegion.refinementTemplate) {
  47315. at = [];
  47316. for (i = 0; i < 2; i++) {
  47317. at.push({
  47318. x: readInt8(data, position),
  47319. y: readInt8(data, position + 1)
  47320. });
  47321. position += 2;
  47322. }
  47323. textRegion.refinementAt = at;
  47324. }
  47325. textRegion.numberOfSymbolInstances = readUint32(data, position);
  47326. position += 4;
  47327. if (textRegion.huffman) {
  47328. error('JBIG2 error: huffman is not supported');
  47329. }
  47330. args = [
  47331. textRegion,
  47332. header.referredTo,
  47333. data,
  47334. position,
  47335. end
  47336. ];
  47337. break;
  47338. case 38:
  47339. case 39:
  47340. var genericRegion = {};
  47341. genericRegion.info = readRegionSegmentInformation(data, position);
  47342. position += RegionSegmentInformationFieldLength;
  47343. var genericRegionSegmentFlags = data[position++];
  47344. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  47345. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  47346. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  47347. if (!genericRegion.mmr) {
  47348. atLength = genericRegion.template === 0 ? 4 : 1;
  47349. at = [];
  47350. for (i = 0; i < atLength; i++) {
  47351. at.push({
  47352. x: readInt8(data, position),
  47353. y: readInt8(data, position + 1)
  47354. });
  47355. position += 2;
  47356. }
  47357. genericRegion.at = at;
  47358. }
  47359. args = [
  47360. genericRegion,
  47361. data,
  47362. position,
  47363. end
  47364. ];
  47365. break;
  47366. case 48:
  47367. var pageInfo = {
  47368. width: readUint32(data, position),
  47369. height: readUint32(data, position + 4),
  47370. resolutionX: readUint32(data, position + 8),
  47371. resolutionY: readUint32(data, position + 12)
  47372. };
  47373. if (pageInfo.height === 0xFFFFFFFF) {
  47374. delete pageInfo.height;
  47375. }
  47376. var pageSegmentFlags = data[position + 16];
  47377. readUint16(data, position + 17);
  47378. pageInfo.lossless = !!(pageSegmentFlags & 1);
  47379. pageInfo.refinement = !!(pageSegmentFlags & 2);
  47380. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  47381. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  47382. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  47383. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  47384. args = [pageInfo];
  47385. break;
  47386. case 49:
  47387. break;
  47388. case 50:
  47389. break;
  47390. case 51:
  47391. break;
  47392. case 62:
  47393. break;
  47394. default:
  47395. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  47396. }
  47397. var callbackName = 'on' + header.typeName;
  47398. if (callbackName in visitor) {
  47399. visitor[callbackName].apply(visitor, args);
  47400. }
  47401. }
  47402. function processSegments(segments, visitor) {
  47403. for (var i = 0, ii = segments.length; i < ii; i++) {
  47404. processSegment(segments[i], visitor);
  47405. }
  47406. }
  47407. function parseJbig2(data, start, end) {
  47408. var position = start;
  47409. 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) {
  47410. error('JBIG2 error: invalid header');
  47411. }
  47412. var header = {};
  47413. position += 8;
  47414. var flags = data[position++];
  47415. header.randomAccess = !(flags & 1);
  47416. if (!(flags & 2)) {
  47417. header.numberOfPages = readUint32(data, position);
  47418. position += 4;
  47419. }
  47420. readSegments(header, data, position, end);
  47421. error('Not implemented');
  47422. }
  47423. function parseJbig2Chunks(chunks) {
  47424. var visitor = new SimpleSegmentVisitor();
  47425. for (var i = 0, ii = chunks.length; i < ii; i++) {
  47426. var chunk = chunks[i];
  47427. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  47428. processSegments(segments, visitor);
  47429. }
  47430. return visitor.buffer;
  47431. }
  47432. function SimpleSegmentVisitor() {
  47433. }
  47434. SimpleSegmentVisitor.prototype = {
  47435. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  47436. this.currentPageInfo = info;
  47437. var rowSize = info.width + 7 >> 3;
  47438. var buffer = new Uint8Array(rowSize * info.height);
  47439. if (info.defaultPixelValue) {
  47440. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47441. buffer[i] = 0xFF;
  47442. }
  47443. }
  47444. this.buffer = buffer;
  47445. },
  47446. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  47447. var pageInfo = this.currentPageInfo;
  47448. var width = regionInfo.width, height = regionInfo.height;
  47449. var rowSize = pageInfo.width + 7 >> 3;
  47450. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  47451. var buffer = this.buffer;
  47452. var mask0 = 128 >> (regionInfo.x & 7);
  47453. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  47454. var i, j, mask, offset;
  47455. switch (combinationOperator) {
  47456. case 0:
  47457. for (i = 0; i < height; i++) {
  47458. mask = mask0;
  47459. offset = offset0;
  47460. for (j = 0; j < width; j++) {
  47461. if (bitmap[i][j]) {
  47462. buffer[offset] |= mask;
  47463. }
  47464. mask >>= 1;
  47465. if (!mask) {
  47466. mask = 128;
  47467. offset++;
  47468. }
  47469. }
  47470. offset0 += rowSize;
  47471. }
  47472. break;
  47473. case 2:
  47474. for (i = 0; i < height; i++) {
  47475. mask = mask0;
  47476. offset = offset0;
  47477. for (j = 0; j < width; j++) {
  47478. if (bitmap[i][j]) {
  47479. buffer[offset] ^= mask;
  47480. }
  47481. mask >>= 1;
  47482. if (!mask) {
  47483. mask = 128;
  47484. offset++;
  47485. }
  47486. }
  47487. offset0 += rowSize;
  47488. }
  47489. break;
  47490. default:
  47491. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47492. }
  47493. },
  47494. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  47495. var regionInfo = region.info;
  47496. var decodingContext = new DecodingContext(data, start, end);
  47497. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  47498. this.drawBitmap(regionInfo, bitmap);
  47499. },
  47500. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  47501. this.onImmediateGenericRegion.apply(this, arguments);
  47502. },
  47503. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  47504. var huffmanTables;
  47505. if (dictionary.huffman) {
  47506. error('JBIG2 error: huffman is not supported');
  47507. }
  47508. var symbols = this.symbols;
  47509. if (!symbols) {
  47510. this.symbols = symbols = {};
  47511. }
  47512. var inputSymbols = [];
  47513. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47514. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47515. }
  47516. var decodingContext = new DecodingContext(data, start, end);
  47517. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  47518. },
  47519. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  47520. var regionInfo = region.info;
  47521. var huffmanTables;
  47522. var symbols = this.symbols;
  47523. var inputSymbols = [];
  47524. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47525. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47526. }
  47527. var symbolCodeLength = log2(inputSymbols.length);
  47528. var decodingContext = new DecodingContext(data, start, end);
  47529. 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);
  47530. this.drawBitmap(regionInfo, bitmap);
  47531. },
  47532. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  47533. this.onImmediateTextRegion.apply(this, arguments);
  47534. }
  47535. };
  47536. function Jbig2Image() {
  47537. }
  47538. Jbig2Image.prototype = {
  47539. parseChunks: function Jbig2Image_parseChunks(chunks) {
  47540. return parseJbig2Chunks(chunks);
  47541. }
  47542. };
  47543. return Jbig2Image;
  47544. }();
  47545. exports.Jbig2Image = Jbig2Image;
  47546. /***/ }),
  47547. /* 36 */
  47548. /***/ (function(module, exports, __w_pdfjs_require__) {
  47549. "use strict";
  47550. var sharedUtil = __w_pdfjs_require__(0);
  47551. var warn = sharedUtil.warn;
  47552. var error = sharedUtil.error;
  47553. var JpegImage = function JpegImageClosure() {
  47554. var dctZigZag = new Uint8Array([
  47555. 0,
  47556. 1,
  47557. 8,
  47558. 16,
  47559. 9,
  47560. 2,
  47561. 3,
  47562. 10,
  47563. 17,
  47564. 24,
  47565. 32,
  47566. 25,
  47567. 18,
  47568. 11,
  47569. 4,
  47570. 5,
  47571. 12,
  47572. 19,
  47573. 26,
  47574. 33,
  47575. 40,
  47576. 48,
  47577. 41,
  47578. 34,
  47579. 27,
  47580. 20,
  47581. 13,
  47582. 6,
  47583. 7,
  47584. 14,
  47585. 21,
  47586. 28,
  47587. 35,
  47588. 42,
  47589. 49,
  47590. 56,
  47591. 57,
  47592. 50,
  47593. 43,
  47594. 36,
  47595. 29,
  47596. 22,
  47597. 15,
  47598. 23,
  47599. 30,
  47600. 37,
  47601. 44,
  47602. 51,
  47603. 58,
  47604. 59,
  47605. 52,
  47606. 45,
  47607. 38,
  47608. 31,
  47609. 39,
  47610. 46,
  47611. 53,
  47612. 60,
  47613. 61,
  47614. 54,
  47615. 47,
  47616. 55,
  47617. 62,
  47618. 63
  47619. ]);
  47620. var dctCos1 = 4017;
  47621. var dctSin1 = 799;
  47622. var dctCos3 = 3406;
  47623. var dctSin3 = 2276;
  47624. var dctCos6 = 1567;
  47625. var dctSin6 = 3784;
  47626. var dctSqrt2 = 5793;
  47627. var dctSqrt1d2 = 2896;
  47628. function JpegImage() {
  47629. this.decodeTransform = null;
  47630. this.colorTransform = -1;
  47631. }
  47632. function buildHuffmanTable(codeLengths, values) {
  47633. var k = 0, code = [], i, j, length = 16;
  47634. while (length > 0 && !codeLengths[length - 1]) {
  47635. length--;
  47636. }
  47637. code.push({
  47638. children: [],
  47639. index: 0
  47640. });
  47641. var p = code[0], q;
  47642. for (i = 0; i < length; i++) {
  47643. for (j = 0; j < codeLengths[i]; j++) {
  47644. p = code.pop();
  47645. p.children[p.index] = values[k];
  47646. while (p.index > 0) {
  47647. p = code.pop();
  47648. }
  47649. p.index++;
  47650. code.push(p);
  47651. while (code.length <= i) {
  47652. code.push(q = {
  47653. children: [],
  47654. index: 0
  47655. });
  47656. p.children[p.index] = q.children;
  47657. p = q;
  47658. }
  47659. k++;
  47660. }
  47661. if (i + 1 < length) {
  47662. code.push(q = {
  47663. children: [],
  47664. index: 0
  47665. });
  47666. p.children[p.index] = q.children;
  47667. p = q;
  47668. }
  47669. }
  47670. return code[0].children;
  47671. }
  47672. function getBlockBufferOffset(component, row, col) {
  47673. return 64 * ((component.blocksPerLine + 1) * row + col);
  47674. }
  47675. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  47676. var mcusPerLine = frame.mcusPerLine;
  47677. var progressive = frame.progressive;
  47678. var startOffset = offset, bitsData = 0, bitsCount = 0;
  47679. function readBit() {
  47680. if (bitsCount > 0) {
  47681. bitsCount--;
  47682. return bitsData >> bitsCount & 1;
  47683. }
  47684. bitsData = data[offset++];
  47685. if (bitsData === 0xFF) {
  47686. var nextByte = data[offset++];
  47687. if (nextByte) {
  47688. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  47689. }
  47690. }
  47691. bitsCount = 7;
  47692. return bitsData >>> 7;
  47693. }
  47694. function decodeHuffman(tree) {
  47695. var node = tree;
  47696. while (true) {
  47697. node = node[readBit()];
  47698. if (typeof node === 'number') {
  47699. return node;
  47700. }
  47701. if (typeof node !== 'object') {
  47702. error('JPEG error: invalid huffman sequence');
  47703. }
  47704. }
  47705. }
  47706. function receive(length) {
  47707. var n = 0;
  47708. while (length > 0) {
  47709. n = n << 1 | readBit();
  47710. length--;
  47711. }
  47712. return n;
  47713. }
  47714. function receiveAndExtend(length) {
  47715. if (length === 1) {
  47716. return readBit() === 1 ? 1 : -1;
  47717. }
  47718. var n = receive(length);
  47719. if (n >= 1 << length - 1) {
  47720. return n;
  47721. }
  47722. return n + (-1 << length) + 1;
  47723. }
  47724. function decodeBaseline(component, offset) {
  47725. var t = decodeHuffman(component.huffmanTableDC);
  47726. var diff = t === 0 ? 0 : receiveAndExtend(t);
  47727. component.blockData[offset] = component.pred += diff;
  47728. var k = 1;
  47729. while (k < 64) {
  47730. var rs = decodeHuffman(component.huffmanTableAC);
  47731. var s = rs & 15, r = rs >> 4;
  47732. if (s === 0) {
  47733. if (r < 15) {
  47734. break;
  47735. }
  47736. k += 16;
  47737. continue;
  47738. }
  47739. k += r;
  47740. var z = dctZigZag[k];
  47741. component.blockData[offset + z] = receiveAndExtend(s);
  47742. k++;
  47743. }
  47744. }
  47745. function decodeDCFirst(component, offset) {
  47746. var t = decodeHuffman(component.huffmanTableDC);
  47747. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  47748. component.blockData[offset] = component.pred += diff;
  47749. }
  47750. function decodeDCSuccessive(component, offset) {
  47751. component.blockData[offset] |= readBit() << successive;
  47752. }
  47753. var eobrun = 0;
  47754. function decodeACFirst(component, offset) {
  47755. if (eobrun > 0) {
  47756. eobrun--;
  47757. return;
  47758. }
  47759. var k = spectralStart, e = spectralEnd;
  47760. while (k <= e) {
  47761. var rs = decodeHuffman(component.huffmanTableAC);
  47762. var s = rs & 15, r = rs >> 4;
  47763. if (s === 0) {
  47764. if (r < 15) {
  47765. eobrun = receive(r) + (1 << r) - 1;
  47766. break;
  47767. }
  47768. k += 16;
  47769. continue;
  47770. }
  47771. k += r;
  47772. var z = dctZigZag[k];
  47773. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  47774. k++;
  47775. }
  47776. }
  47777. var successiveACState = 0, successiveACNextValue;
  47778. function decodeACSuccessive(component, offset) {
  47779. var k = spectralStart;
  47780. var e = spectralEnd;
  47781. var r = 0;
  47782. var s;
  47783. var rs;
  47784. while (k <= e) {
  47785. var z = dctZigZag[k];
  47786. switch (successiveACState) {
  47787. case 0:
  47788. rs = decodeHuffman(component.huffmanTableAC);
  47789. s = rs & 15;
  47790. r = rs >> 4;
  47791. if (s === 0) {
  47792. if (r < 15) {
  47793. eobrun = receive(r) + (1 << r);
  47794. successiveACState = 4;
  47795. } else {
  47796. r = 16;
  47797. successiveACState = 1;
  47798. }
  47799. } else {
  47800. if (s !== 1) {
  47801. error('JPEG error: invalid ACn encoding');
  47802. }
  47803. successiveACNextValue = receiveAndExtend(s);
  47804. successiveACState = r ? 2 : 3;
  47805. }
  47806. continue;
  47807. case 1:
  47808. case 2:
  47809. if (component.blockData[offset + z]) {
  47810. component.blockData[offset + z] += readBit() << successive;
  47811. } else {
  47812. r--;
  47813. if (r === 0) {
  47814. successiveACState = successiveACState === 2 ? 3 : 0;
  47815. }
  47816. }
  47817. break;
  47818. case 3:
  47819. if (component.blockData[offset + z]) {
  47820. component.blockData[offset + z] += readBit() << successive;
  47821. } else {
  47822. component.blockData[offset + z] = successiveACNextValue << successive;
  47823. successiveACState = 0;
  47824. }
  47825. break;
  47826. case 4:
  47827. if (component.blockData[offset + z]) {
  47828. component.blockData[offset + z] += readBit() << successive;
  47829. }
  47830. break;
  47831. }
  47832. k++;
  47833. }
  47834. if (successiveACState === 4) {
  47835. eobrun--;
  47836. if (eobrun === 0) {
  47837. successiveACState = 0;
  47838. }
  47839. }
  47840. }
  47841. function decodeMcu(component, decode, mcu, row, col) {
  47842. var mcuRow = mcu / mcusPerLine | 0;
  47843. var mcuCol = mcu % mcusPerLine;
  47844. var blockRow = mcuRow * component.v + row;
  47845. var blockCol = mcuCol * component.h + col;
  47846. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47847. decode(component, offset);
  47848. }
  47849. function decodeBlock(component, decode, mcu) {
  47850. var blockRow = mcu / component.blocksPerLine | 0;
  47851. var blockCol = mcu % component.blocksPerLine;
  47852. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47853. decode(component, offset);
  47854. }
  47855. var componentsLength = components.length;
  47856. var component, i, j, k, n;
  47857. var decodeFn;
  47858. if (progressive) {
  47859. if (spectralStart === 0) {
  47860. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  47861. } else {
  47862. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  47863. }
  47864. } else {
  47865. decodeFn = decodeBaseline;
  47866. }
  47867. var mcu = 0, marker;
  47868. var mcuExpected;
  47869. if (componentsLength === 1) {
  47870. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  47871. } else {
  47872. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  47873. }
  47874. var h, v;
  47875. while (mcu < mcuExpected) {
  47876. var mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  47877. for (i = 0; i < componentsLength; i++) {
  47878. components[i].pred = 0;
  47879. }
  47880. eobrun = 0;
  47881. if (componentsLength === 1) {
  47882. component = components[0];
  47883. for (n = 0; n < mcuToRead; n++) {
  47884. decodeBlock(component, decodeFn, mcu);
  47885. mcu++;
  47886. }
  47887. } else {
  47888. for (n = 0; n < mcuToRead; n++) {
  47889. for (i = 0; i < componentsLength; i++) {
  47890. component = components[i];
  47891. h = component.h;
  47892. v = component.v;
  47893. for (j = 0; j < v; j++) {
  47894. for (k = 0; k < h; k++) {
  47895. decodeMcu(component, decodeFn, mcu, j, k);
  47896. }
  47897. }
  47898. }
  47899. mcu++;
  47900. }
  47901. }
  47902. bitsCount = 0;
  47903. marker = data[offset] << 8 | data[offset + 1];
  47904. while (data[offset] === 0x00 && offset < data.length - 1) {
  47905. offset++;
  47906. marker = data[offset] << 8 | data[offset + 1];
  47907. }
  47908. if (marker <= 0xFF00) {
  47909. error('JPEG error: marker was not found');
  47910. }
  47911. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  47912. offset += 2;
  47913. } else {
  47914. break;
  47915. }
  47916. }
  47917. return offset - startOffset;
  47918. }
  47919. function quantizeAndInverse(component, blockBufferOffset, p) {
  47920. var qt = component.quantizationTable, blockData = component.blockData;
  47921. var v0, v1, v2, v3, v4, v5, v6, v7;
  47922. var p0, p1, p2, p3, p4, p5, p6, p7;
  47923. var t;
  47924. if (!qt) {
  47925. error('JPEG error: missing required Quantization Table.');
  47926. }
  47927. for (var row = 0; row < 64; row += 8) {
  47928. p0 = blockData[blockBufferOffset + row];
  47929. p1 = blockData[blockBufferOffset + row + 1];
  47930. p2 = blockData[blockBufferOffset + row + 2];
  47931. p3 = blockData[blockBufferOffset + row + 3];
  47932. p4 = blockData[blockBufferOffset + row + 4];
  47933. p5 = blockData[blockBufferOffset + row + 5];
  47934. p6 = blockData[blockBufferOffset + row + 6];
  47935. p7 = blockData[blockBufferOffset + row + 7];
  47936. p0 *= qt[row];
  47937. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47938. t = dctSqrt2 * p0 + 512 >> 10;
  47939. p[row] = t;
  47940. p[row + 1] = t;
  47941. p[row + 2] = t;
  47942. p[row + 3] = t;
  47943. p[row + 4] = t;
  47944. p[row + 5] = t;
  47945. p[row + 6] = t;
  47946. p[row + 7] = t;
  47947. continue;
  47948. }
  47949. p1 *= qt[row + 1];
  47950. p2 *= qt[row + 2];
  47951. p3 *= qt[row + 3];
  47952. p4 *= qt[row + 4];
  47953. p5 *= qt[row + 5];
  47954. p6 *= qt[row + 6];
  47955. p7 *= qt[row + 7];
  47956. v0 = dctSqrt2 * p0 + 128 >> 8;
  47957. v1 = dctSqrt2 * p4 + 128 >> 8;
  47958. v2 = p2;
  47959. v3 = p6;
  47960. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  47961. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  47962. v5 = p3 << 4;
  47963. v6 = p5 << 4;
  47964. v0 = v0 + v1 + 1 >> 1;
  47965. v1 = v0 - v1;
  47966. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  47967. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  47968. v3 = t;
  47969. v4 = v4 + v6 + 1 >> 1;
  47970. v6 = v4 - v6;
  47971. v7 = v7 + v5 + 1 >> 1;
  47972. v5 = v7 - v5;
  47973. v0 = v0 + v3 + 1 >> 1;
  47974. v3 = v0 - v3;
  47975. v1 = v1 + v2 + 1 >> 1;
  47976. v2 = v1 - v2;
  47977. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  47978. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  47979. v7 = t;
  47980. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  47981. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  47982. v6 = t;
  47983. p[row] = v0 + v7;
  47984. p[row + 7] = v0 - v7;
  47985. p[row + 1] = v1 + v6;
  47986. p[row + 6] = v1 - v6;
  47987. p[row + 2] = v2 + v5;
  47988. p[row + 5] = v2 - v5;
  47989. p[row + 3] = v3 + v4;
  47990. p[row + 4] = v3 - v4;
  47991. }
  47992. for (var col = 0; col < 8; ++col) {
  47993. p0 = p[col];
  47994. p1 = p[col + 8];
  47995. p2 = p[col + 16];
  47996. p3 = p[col + 24];
  47997. p4 = p[col + 32];
  47998. p5 = p[col + 40];
  47999. p6 = p[col + 48];
  48000. p7 = p[col + 56];
  48001. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48002. t = dctSqrt2 * p0 + 8192 >> 14;
  48003. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48004. blockData[blockBufferOffset + col] = t;
  48005. blockData[blockBufferOffset + col + 8] = t;
  48006. blockData[blockBufferOffset + col + 16] = t;
  48007. blockData[blockBufferOffset + col + 24] = t;
  48008. blockData[blockBufferOffset + col + 32] = t;
  48009. blockData[blockBufferOffset + col + 40] = t;
  48010. blockData[blockBufferOffset + col + 48] = t;
  48011. blockData[blockBufferOffset + col + 56] = t;
  48012. continue;
  48013. }
  48014. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48015. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48016. v2 = p2;
  48017. v3 = p6;
  48018. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48019. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48020. v5 = p3;
  48021. v6 = p5;
  48022. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48023. v1 = v0 - v1;
  48024. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48025. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48026. v3 = t;
  48027. v4 = v4 + v6 + 1 >> 1;
  48028. v6 = v4 - v6;
  48029. v7 = v7 + v5 + 1 >> 1;
  48030. v5 = v7 - v5;
  48031. v0 = v0 + v3 + 1 >> 1;
  48032. v3 = v0 - v3;
  48033. v1 = v1 + v2 + 1 >> 1;
  48034. v2 = v1 - v2;
  48035. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48036. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48037. v7 = t;
  48038. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48039. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48040. v6 = t;
  48041. p0 = v0 + v7;
  48042. p7 = v0 - v7;
  48043. p1 = v1 + v6;
  48044. p6 = v1 - v6;
  48045. p2 = v2 + v5;
  48046. p5 = v2 - v5;
  48047. p3 = v3 + v4;
  48048. p4 = v3 - v4;
  48049. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48050. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48051. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48052. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48053. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48054. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48055. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48056. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48057. blockData[blockBufferOffset + col] = p0;
  48058. blockData[blockBufferOffset + col + 8] = p1;
  48059. blockData[blockBufferOffset + col + 16] = p2;
  48060. blockData[blockBufferOffset + col + 24] = p3;
  48061. blockData[blockBufferOffset + col + 32] = p4;
  48062. blockData[blockBufferOffset + col + 40] = p5;
  48063. blockData[blockBufferOffset + col + 48] = p6;
  48064. blockData[blockBufferOffset + col + 56] = p7;
  48065. }
  48066. }
  48067. function buildComponentData(frame, component) {
  48068. var blocksPerLine = component.blocksPerLine;
  48069. var blocksPerColumn = component.blocksPerColumn;
  48070. var computationBuffer = new Int16Array(64);
  48071. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48072. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48073. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48074. quantizeAndInverse(component, offset, computationBuffer);
  48075. }
  48076. }
  48077. return component.blockData;
  48078. }
  48079. function clamp0to255(a) {
  48080. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48081. }
  48082. JpegImage.prototype = {
  48083. parse: function parse(data) {
  48084. function readUint16() {
  48085. var value = data[offset] << 8 | data[offset + 1];
  48086. offset += 2;
  48087. return value;
  48088. }
  48089. function readDataBlock() {
  48090. function isValidMarkerAt(pos) {
  48091. if (pos < data.length - 1) {
  48092. return data[pos] === 0xFF && data[pos + 1] >= 0xC0 && data[pos + 1] <= 0xFE;
  48093. }
  48094. return true;
  48095. }
  48096. var length = readUint16();
  48097. var endOffset = offset + length - 2;
  48098. if (!isValidMarkerAt(endOffset)) {
  48099. warn('readDataBlock - incorrect length, next marker is: ' + (data[endOffset] << 8 | data[endOffset + 1]).toString('16'));
  48100. var pos = offset;
  48101. while (!isValidMarkerAt(pos)) {
  48102. pos++;
  48103. }
  48104. endOffset = pos;
  48105. }
  48106. var array = data.subarray(offset, endOffset);
  48107. offset += array.length;
  48108. return array;
  48109. }
  48110. function prepareComponents(frame) {
  48111. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48112. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48113. for (var i = 0; i < frame.components.length; i++) {
  48114. component = frame.components[i];
  48115. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48116. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48117. var blocksPerLineForMcu = mcusPerLine * component.h;
  48118. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48119. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48120. component.blockData = new Int16Array(blocksBufferSize);
  48121. component.blocksPerLine = blocksPerLine;
  48122. component.blocksPerColumn = blocksPerColumn;
  48123. }
  48124. frame.mcusPerLine = mcusPerLine;
  48125. frame.mcusPerColumn = mcusPerColumn;
  48126. }
  48127. var offset = 0;
  48128. var jfif = null;
  48129. var adobe = null;
  48130. var frame, resetInterval;
  48131. var quantizationTables = [];
  48132. var huffmanTablesAC = [], huffmanTablesDC = [];
  48133. var fileMarker = readUint16();
  48134. if (fileMarker !== 0xFFD8) {
  48135. error('JPEG error: SOI not found');
  48136. }
  48137. fileMarker = readUint16();
  48138. while (fileMarker !== 0xFFD9) {
  48139. var i, j, l;
  48140. switch (fileMarker) {
  48141. case 0xFFE0:
  48142. case 0xFFE1:
  48143. case 0xFFE2:
  48144. case 0xFFE3:
  48145. case 0xFFE4:
  48146. case 0xFFE5:
  48147. case 0xFFE6:
  48148. case 0xFFE7:
  48149. case 0xFFE8:
  48150. case 0xFFE9:
  48151. case 0xFFEA:
  48152. case 0xFFEB:
  48153. case 0xFFEC:
  48154. case 0xFFED:
  48155. case 0xFFEE:
  48156. case 0xFFEF:
  48157. case 0xFFFE:
  48158. var appData = readDataBlock();
  48159. if (fileMarker === 0xFFE0) {
  48160. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48161. jfif = {
  48162. version: {
  48163. major: appData[5],
  48164. minor: appData[6]
  48165. },
  48166. densityUnits: appData[7],
  48167. xDensity: appData[8] << 8 | appData[9],
  48168. yDensity: appData[10] << 8 | appData[11],
  48169. thumbWidth: appData[12],
  48170. thumbHeight: appData[13],
  48171. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48172. };
  48173. }
  48174. }
  48175. if (fileMarker === 0xFFEE) {
  48176. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48177. adobe = {
  48178. version: appData[5] << 8 | appData[6],
  48179. flags0: appData[7] << 8 | appData[8],
  48180. flags1: appData[9] << 8 | appData[10],
  48181. transformCode: appData[11]
  48182. };
  48183. }
  48184. }
  48185. break;
  48186. case 0xFFDB:
  48187. var quantizationTablesLength = readUint16();
  48188. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48189. var z;
  48190. while (offset < quantizationTablesEnd) {
  48191. var quantizationTableSpec = data[offset++];
  48192. var tableData = new Uint16Array(64);
  48193. if (quantizationTableSpec >> 4 === 0) {
  48194. for (j = 0; j < 64; j++) {
  48195. z = dctZigZag[j];
  48196. tableData[z] = data[offset++];
  48197. }
  48198. } else if (quantizationTableSpec >> 4 === 1) {
  48199. for (j = 0; j < 64; j++) {
  48200. z = dctZigZag[j];
  48201. tableData[z] = readUint16();
  48202. }
  48203. } else {
  48204. error('JPEG error: DQT - invalid table spec');
  48205. }
  48206. quantizationTables[quantizationTableSpec & 15] = tableData;
  48207. }
  48208. break;
  48209. case 0xFFC0:
  48210. case 0xFFC1:
  48211. case 0xFFC2:
  48212. if (frame) {
  48213. error('JPEG error: Only single frame JPEGs supported');
  48214. }
  48215. readUint16();
  48216. frame = {};
  48217. frame.extended = fileMarker === 0xFFC1;
  48218. frame.progressive = fileMarker === 0xFFC2;
  48219. frame.precision = data[offset++];
  48220. frame.scanLines = readUint16();
  48221. frame.samplesPerLine = readUint16();
  48222. frame.components = [];
  48223. frame.componentIds = {};
  48224. var componentsCount = data[offset++], componentId;
  48225. var maxH = 0, maxV = 0;
  48226. for (i = 0; i < componentsCount; i++) {
  48227. componentId = data[offset];
  48228. var h = data[offset + 1] >> 4;
  48229. var v = data[offset + 1] & 15;
  48230. if (maxH < h) {
  48231. maxH = h;
  48232. }
  48233. if (maxV < v) {
  48234. maxV = v;
  48235. }
  48236. var qId = data[offset + 2];
  48237. l = frame.components.push({
  48238. h: h,
  48239. v: v,
  48240. quantizationId: qId,
  48241. quantizationTable: null
  48242. });
  48243. frame.componentIds[componentId] = l - 1;
  48244. offset += 3;
  48245. }
  48246. frame.maxH = maxH;
  48247. frame.maxV = maxV;
  48248. prepareComponents(frame);
  48249. break;
  48250. case 0xFFC4:
  48251. var huffmanLength = readUint16();
  48252. for (i = 2; i < huffmanLength;) {
  48253. var huffmanTableSpec = data[offset++];
  48254. var codeLengths = new Uint8Array(16);
  48255. var codeLengthSum = 0;
  48256. for (j = 0; j < 16; j++, offset++) {
  48257. codeLengthSum += codeLengths[j] = data[offset];
  48258. }
  48259. var huffmanValues = new Uint8Array(codeLengthSum);
  48260. for (j = 0; j < codeLengthSum; j++, offset++) {
  48261. huffmanValues[j] = data[offset];
  48262. }
  48263. i += 17 + codeLengthSum;
  48264. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  48265. }
  48266. break;
  48267. case 0xFFDD:
  48268. readUint16();
  48269. resetInterval = readUint16();
  48270. break;
  48271. case 0xFFDA:
  48272. readUint16();
  48273. var selectorsCount = data[offset++];
  48274. var components = [], component;
  48275. for (i = 0; i < selectorsCount; i++) {
  48276. var componentIndex = frame.componentIds[data[offset++]];
  48277. component = frame.components[componentIndex];
  48278. var tableSpec = data[offset++];
  48279. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  48280. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  48281. components.push(component);
  48282. }
  48283. var spectralStart = data[offset++];
  48284. var spectralEnd = data[offset++];
  48285. var successiveApproximation = data[offset++];
  48286. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  48287. offset += processed;
  48288. break;
  48289. case 0xFFFF:
  48290. if (data[offset] !== 0xFF) {
  48291. offset--;
  48292. }
  48293. break;
  48294. default:
  48295. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  48296. offset -= 3;
  48297. break;
  48298. }
  48299. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  48300. }
  48301. fileMarker = readUint16();
  48302. }
  48303. this.width = frame.samplesPerLine;
  48304. this.height = frame.scanLines;
  48305. this.jfif = jfif;
  48306. this.adobe = adobe;
  48307. this.components = [];
  48308. for (i = 0; i < frame.components.length; i++) {
  48309. component = frame.components[i];
  48310. var quantizationTable = quantizationTables[component.quantizationId];
  48311. if (quantizationTable) {
  48312. component.quantizationTable = quantizationTable;
  48313. }
  48314. this.components.push({
  48315. output: buildComponentData(frame, component),
  48316. scaleX: component.h / frame.maxH,
  48317. scaleY: component.v / frame.maxV,
  48318. blocksPerLine: component.blocksPerLine,
  48319. blocksPerColumn: component.blocksPerColumn
  48320. });
  48321. }
  48322. this.numComponents = this.components.length;
  48323. },
  48324. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  48325. var scaleX = this.width / width, scaleY = this.height / height;
  48326. var component, componentScaleX, componentScaleY, blocksPerScanline;
  48327. var x, y, i, j, k;
  48328. var index;
  48329. var offset = 0;
  48330. var output;
  48331. var numComponents = this.components.length;
  48332. var dataLength = width * height * numComponents;
  48333. var data = new Uint8Array(dataLength);
  48334. var xScaleBlockOffset = new Uint32Array(width);
  48335. var mask3LSB = 0xfffffff8;
  48336. for (i = 0; i < numComponents; i++) {
  48337. component = this.components[i];
  48338. componentScaleX = component.scaleX * scaleX;
  48339. componentScaleY = component.scaleY * scaleY;
  48340. offset = i;
  48341. output = component.output;
  48342. blocksPerScanline = component.blocksPerLine + 1 << 3;
  48343. for (x = 0; x < width; x++) {
  48344. j = 0 | x * componentScaleX;
  48345. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  48346. }
  48347. for (y = 0; y < height; y++) {
  48348. j = 0 | y * componentScaleY;
  48349. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  48350. for (x = 0; x < width; x++) {
  48351. data[offset] = output[index + xScaleBlockOffset[x]];
  48352. offset += numComponents;
  48353. }
  48354. }
  48355. }
  48356. var transform = this.decodeTransform;
  48357. if (transform) {
  48358. for (i = 0; i < dataLength;) {
  48359. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  48360. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  48361. }
  48362. }
  48363. }
  48364. return data;
  48365. },
  48366. _isColorConversionNeeded: function isColorConversionNeeded() {
  48367. if (this.adobe && this.adobe.transformCode) {
  48368. return true;
  48369. } else if (this.numComponents === 3) {
  48370. if (!this.adobe && this.colorTransform === 0) {
  48371. return false;
  48372. }
  48373. return true;
  48374. }
  48375. if (!this.adobe && this.colorTransform === 1) {
  48376. return true;
  48377. }
  48378. return false;
  48379. },
  48380. _convertYccToRgb: function convertYccToRgb(data) {
  48381. var Y, Cb, Cr;
  48382. for (var i = 0, length = data.length; i < length; i += 3) {
  48383. Y = data[i];
  48384. Cb = data[i + 1];
  48385. Cr = data[i + 2];
  48386. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  48387. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  48388. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  48389. }
  48390. return data;
  48391. },
  48392. _convertYcckToRgb: function convertYcckToRgb(data) {
  48393. var Y, Cb, Cr, k;
  48394. var offset = 0;
  48395. for (var i = 0, length = data.length; i < length; i += 4) {
  48396. Y = data[i];
  48397. Cb = data[i + 1];
  48398. Cr = data[i + 2];
  48399. k = data[i + 3];
  48400. 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);
  48401. 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);
  48402. 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);
  48403. data[offset++] = clamp0to255(r);
  48404. data[offset++] = clamp0to255(g);
  48405. data[offset++] = clamp0to255(b);
  48406. }
  48407. return data;
  48408. },
  48409. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  48410. var Y, Cb, Cr;
  48411. for (var i = 0, length = data.length; i < length; i += 4) {
  48412. Y = data[i];
  48413. Cb = data[i + 1];
  48414. Cr = data[i + 2];
  48415. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  48416. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  48417. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  48418. }
  48419. return data;
  48420. },
  48421. _convertCmykToRgb: function convertCmykToRgb(data) {
  48422. var c, m, y, k;
  48423. var offset = 0;
  48424. var min = -255 * 255 * 255;
  48425. var scale = 1 / 255 / 255;
  48426. for (var i = 0, length = data.length; i < length; i += 4) {
  48427. c = data[i];
  48428. m = data[i + 1];
  48429. y = data[i + 2];
  48430. k = data[i + 3];
  48431. 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);
  48432. 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);
  48433. 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);
  48434. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  48435. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  48436. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  48437. }
  48438. return data;
  48439. },
  48440. getData: function getData(width, height, forceRGBoutput) {
  48441. if (this.numComponents > 4) {
  48442. error('JPEG error: Unsupported color mode');
  48443. }
  48444. var data = this._getLinearizedBlockData(width, height);
  48445. if (this.numComponents === 1 && forceRGBoutput) {
  48446. var dataLength = data.length;
  48447. var rgbData = new Uint8Array(dataLength * 3);
  48448. var offset = 0;
  48449. for (var i = 0; i < dataLength; i++) {
  48450. var grayColor = data[i];
  48451. rgbData[offset++] = grayColor;
  48452. rgbData[offset++] = grayColor;
  48453. rgbData[offset++] = grayColor;
  48454. }
  48455. return rgbData;
  48456. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  48457. return this._convertYccToRgb(data);
  48458. } else if (this.numComponents === 4) {
  48459. if (this._isColorConversionNeeded()) {
  48460. if (forceRGBoutput) {
  48461. return this._convertYcckToRgb(data);
  48462. }
  48463. return this._convertYcckToCmyk(data);
  48464. } else if (forceRGBoutput) {
  48465. return this._convertCmykToRgb(data);
  48466. }
  48467. }
  48468. return data;
  48469. }
  48470. };
  48471. return JpegImage;
  48472. }();
  48473. exports.JpegImage = JpegImage;
  48474. /***/ }),
  48475. /* 37 */
  48476. /***/ (function(module, exports, __w_pdfjs_require__) {
  48477. "use strict";
  48478. var sharedUtil = __w_pdfjs_require__(0);
  48479. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  48480. var getMetrics = getLookupTableFactory(function (t) {
  48481. t['Courier'] = 600;
  48482. t['Courier-Bold'] = 600;
  48483. t['Courier-BoldOblique'] = 600;
  48484. t['Courier-Oblique'] = 600;
  48485. t['Helvetica'] = getLookupTableFactory(function (t) {
  48486. t['space'] = 278;
  48487. t['exclam'] = 278;
  48488. t['quotedbl'] = 355;
  48489. t['numbersign'] = 556;
  48490. t['dollar'] = 556;
  48491. t['percent'] = 889;
  48492. t['ampersand'] = 667;
  48493. t['quoteright'] = 222;
  48494. t['parenleft'] = 333;
  48495. t['parenright'] = 333;
  48496. t['asterisk'] = 389;
  48497. t['plus'] = 584;
  48498. t['comma'] = 278;
  48499. t['hyphen'] = 333;
  48500. t['period'] = 278;
  48501. t['slash'] = 278;
  48502. t['zero'] = 556;
  48503. t['one'] = 556;
  48504. t['two'] = 556;
  48505. t['three'] = 556;
  48506. t['four'] = 556;
  48507. t['five'] = 556;
  48508. t['six'] = 556;
  48509. t['seven'] = 556;
  48510. t['eight'] = 556;
  48511. t['nine'] = 556;
  48512. t['colon'] = 278;
  48513. t['semicolon'] = 278;
  48514. t['less'] = 584;
  48515. t['equal'] = 584;
  48516. t['greater'] = 584;
  48517. t['question'] = 556;
  48518. t['at'] = 1015;
  48519. t['A'] = 667;
  48520. t['B'] = 667;
  48521. t['C'] = 722;
  48522. t['D'] = 722;
  48523. t['E'] = 667;
  48524. t['F'] = 611;
  48525. t['G'] = 778;
  48526. t['H'] = 722;
  48527. t['I'] = 278;
  48528. t['J'] = 500;
  48529. t['K'] = 667;
  48530. t['L'] = 556;
  48531. t['M'] = 833;
  48532. t['N'] = 722;
  48533. t['O'] = 778;
  48534. t['P'] = 667;
  48535. t['Q'] = 778;
  48536. t['R'] = 722;
  48537. t['S'] = 667;
  48538. t['T'] = 611;
  48539. t['U'] = 722;
  48540. t['V'] = 667;
  48541. t['W'] = 944;
  48542. t['X'] = 667;
  48543. t['Y'] = 667;
  48544. t['Z'] = 611;
  48545. t['bracketleft'] = 278;
  48546. t['backslash'] = 278;
  48547. t['bracketright'] = 278;
  48548. t['asciicircum'] = 469;
  48549. t['underscore'] = 556;
  48550. t['quoteleft'] = 222;
  48551. t['a'] = 556;
  48552. t['b'] = 556;
  48553. t['c'] = 500;
  48554. t['d'] = 556;
  48555. t['e'] = 556;
  48556. t['f'] = 278;
  48557. t['g'] = 556;
  48558. t['h'] = 556;
  48559. t['i'] = 222;
  48560. t['j'] = 222;
  48561. t['k'] = 500;
  48562. t['l'] = 222;
  48563. t['m'] = 833;
  48564. t['n'] = 556;
  48565. t['o'] = 556;
  48566. t['p'] = 556;
  48567. t['q'] = 556;
  48568. t['r'] = 333;
  48569. t['s'] = 500;
  48570. t['t'] = 278;
  48571. t['u'] = 556;
  48572. t['v'] = 500;
  48573. t['w'] = 722;
  48574. t['x'] = 500;
  48575. t['y'] = 500;
  48576. t['z'] = 500;
  48577. t['braceleft'] = 334;
  48578. t['bar'] = 260;
  48579. t['braceright'] = 334;
  48580. t['asciitilde'] = 584;
  48581. t['exclamdown'] = 333;
  48582. t['cent'] = 556;
  48583. t['sterling'] = 556;
  48584. t['fraction'] = 167;
  48585. t['yen'] = 556;
  48586. t['florin'] = 556;
  48587. t['section'] = 556;
  48588. t['currency'] = 556;
  48589. t['quotesingle'] = 191;
  48590. t['quotedblleft'] = 333;
  48591. t['guillemotleft'] = 556;
  48592. t['guilsinglleft'] = 333;
  48593. t['guilsinglright'] = 333;
  48594. t['fi'] = 500;
  48595. t['fl'] = 500;
  48596. t['endash'] = 556;
  48597. t['dagger'] = 556;
  48598. t['daggerdbl'] = 556;
  48599. t['periodcentered'] = 278;
  48600. t['paragraph'] = 537;
  48601. t['bullet'] = 350;
  48602. t['quotesinglbase'] = 222;
  48603. t['quotedblbase'] = 333;
  48604. t['quotedblright'] = 333;
  48605. t['guillemotright'] = 556;
  48606. t['ellipsis'] = 1000;
  48607. t['perthousand'] = 1000;
  48608. t['questiondown'] = 611;
  48609. t['grave'] = 333;
  48610. t['acute'] = 333;
  48611. t['circumflex'] = 333;
  48612. t['tilde'] = 333;
  48613. t['macron'] = 333;
  48614. t['breve'] = 333;
  48615. t['dotaccent'] = 333;
  48616. t['dieresis'] = 333;
  48617. t['ring'] = 333;
  48618. t['cedilla'] = 333;
  48619. t['hungarumlaut'] = 333;
  48620. t['ogonek'] = 333;
  48621. t['caron'] = 333;
  48622. t['emdash'] = 1000;
  48623. t['AE'] = 1000;
  48624. t['ordfeminine'] = 370;
  48625. t['Lslash'] = 556;
  48626. t['Oslash'] = 778;
  48627. t['OE'] = 1000;
  48628. t['ordmasculine'] = 365;
  48629. t['ae'] = 889;
  48630. t['dotlessi'] = 278;
  48631. t['lslash'] = 222;
  48632. t['oslash'] = 611;
  48633. t['oe'] = 944;
  48634. t['germandbls'] = 611;
  48635. t['Idieresis'] = 278;
  48636. t['eacute'] = 556;
  48637. t['abreve'] = 556;
  48638. t['uhungarumlaut'] = 556;
  48639. t['ecaron'] = 556;
  48640. t['Ydieresis'] = 667;
  48641. t['divide'] = 584;
  48642. t['Yacute'] = 667;
  48643. t['Acircumflex'] = 667;
  48644. t['aacute'] = 556;
  48645. t['Ucircumflex'] = 722;
  48646. t['yacute'] = 500;
  48647. t['scommaaccent'] = 500;
  48648. t['ecircumflex'] = 556;
  48649. t['Uring'] = 722;
  48650. t['Udieresis'] = 722;
  48651. t['aogonek'] = 556;
  48652. t['Uacute'] = 722;
  48653. t['uogonek'] = 556;
  48654. t['Edieresis'] = 667;
  48655. t['Dcroat'] = 722;
  48656. t['commaaccent'] = 250;
  48657. t['copyright'] = 737;
  48658. t['Emacron'] = 667;
  48659. t['ccaron'] = 500;
  48660. t['aring'] = 556;
  48661. t['Ncommaaccent'] = 722;
  48662. t['lacute'] = 222;
  48663. t['agrave'] = 556;
  48664. t['Tcommaaccent'] = 611;
  48665. t['Cacute'] = 722;
  48666. t['atilde'] = 556;
  48667. t['Edotaccent'] = 667;
  48668. t['scaron'] = 500;
  48669. t['scedilla'] = 500;
  48670. t['iacute'] = 278;
  48671. t['lozenge'] = 471;
  48672. t['Rcaron'] = 722;
  48673. t['Gcommaaccent'] = 778;
  48674. t['ucircumflex'] = 556;
  48675. t['acircumflex'] = 556;
  48676. t['Amacron'] = 667;
  48677. t['rcaron'] = 333;
  48678. t['ccedilla'] = 500;
  48679. t['Zdotaccent'] = 611;
  48680. t['Thorn'] = 667;
  48681. t['Omacron'] = 778;
  48682. t['Racute'] = 722;
  48683. t['Sacute'] = 667;
  48684. t['dcaron'] = 643;
  48685. t['Umacron'] = 722;
  48686. t['uring'] = 556;
  48687. t['threesuperior'] = 333;
  48688. t['Ograve'] = 778;
  48689. t['Agrave'] = 667;
  48690. t['Abreve'] = 667;
  48691. t['multiply'] = 584;
  48692. t['uacute'] = 556;
  48693. t['Tcaron'] = 611;
  48694. t['partialdiff'] = 476;
  48695. t['ydieresis'] = 500;
  48696. t['Nacute'] = 722;
  48697. t['icircumflex'] = 278;
  48698. t['Ecircumflex'] = 667;
  48699. t['adieresis'] = 556;
  48700. t['edieresis'] = 556;
  48701. t['cacute'] = 500;
  48702. t['nacute'] = 556;
  48703. t['umacron'] = 556;
  48704. t['Ncaron'] = 722;
  48705. t['Iacute'] = 278;
  48706. t['plusminus'] = 584;
  48707. t['brokenbar'] = 260;
  48708. t['registered'] = 737;
  48709. t['Gbreve'] = 778;
  48710. t['Idotaccent'] = 278;
  48711. t['summation'] = 600;
  48712. t['Egrave'] = 667;
  48713. t['racute'] = 333;
  48714. t['omacron'] = 556;
  48715. t['Zacute'] = 611;
  48716. t['Zcaron'] = 611;
  48717. t['greaterequal'] = 549;
  48718. t['Eth'] = 722;
  48719. t['Ccedilla'] = 722;
  48720. t['lcommaaccent'] = 222;
  48721. t['tcaron'] = 317;
  48722. t['eogonek'] = 556;
  48723. t['Uogonek'] = 722;
  48724. t['Aacute'] = 667;
  48725. t['Adieresis'] = 667;
  48726. t['egrave'] = 556;
  48727. t['zacute'] = 500;
  48728. t['iogonek'] = 222;
  48729. t['Oacute'] = 778;
  48730. t['oacute'] = 556;
  48731. t['amacron'] = 556;
  48732. t['sacute'] = 500;
  48733. t['idieresis'] = 278;
  48734. t['Ocircumflex'] = 778;
  48735. t['Ugrave'] = 722;
  48736. t['Delta'] = 612;
  48737. t['thorn'] = 556;
  48738. t['twosuperior'] = 333;
  48739. t['Odieresis'] = 778;
  48740. t['mu'] = 556;
  48741. t['igrave'] = 278;
  48742. t['ohungarumlaut'] = 556;
  48743. t['Eogonek'] = 667;
  48744. t['dcroat'] = 556;
  48745. t['threequarters'] = 834;
  48746. t['Scedilla'] = 667;
  48747. t['lcaron'] = 299;
  48748. t['Kcommaaccent'] = 667;
  48749. t['Lacute'] = 556;
  48750. t['trademark'] = 1000;
  48751. t['edotaccent'] = 556;
  48752. t['Igrave'] = 278;
  48753. t['Imacron'] = 278;
  48754. t['Lcaron'] = 556;
  48755. t['onehalf'] = 834;
  48756. t['lessequal'] = 549;
  48757. t['ocircumflex'] = 556;
  48758. t['ntilde'] = 556;
  48759. t['Uhungarumlaut'] = 722;
  48760. t['Eacute'] = 667;
  48761. t['emacron'] = 556;
  48762. t['gbreve'] = 556;
  48763. t['onequarter'] = 834;
  48764. t['Scaron'] = 667;
  48765. t['Scommaaccent'] = 667;
  48766. t['Ohungarumlaut'] = 778;
  48767. t['degree'] = 400;
  48768. t['ograve'] = 556;
  48769. t['Ccaron'] = 722;
  48770. t['ugrave'] = 556;
  48771. t['radical'] = 453;
  48772. t['Dcaron'] = 722;
  48773. t['rcommaaccent'] = 333;
  48774. t['Ntilde'] = 722;
  48775. t['otilde'] = 556;
  48776. t['Rcommaaccent'] = 722;
  48777. t['Lcommaaccent'] = 556;
  48778. t['Atilde'] = 667;
  48779. t['Aogonek'] = 667;
  48780. t['Aring'] = 667;
  48781. t['Otilde'] = 778;
  48782. t['zdotaccent'] = 500;
  48783. t['Ecaron'] = 667;
  48784. t['Iogonek'] = 278;
  48785. t['kcommaaccent'] = 500;
  48786. t['minus'] = 584;
  48787. t['Icircumflex'] = 278;
  48788. t['ncaron'] = 556;
  48789. t['tcommaaccent'] = 278;
  48790. t['logicalnot'] = 584;
  48791. t['odieresis'] = 556;
  48792. t['udieresis'] = 556;
  48793. t['notequal'] = 549;
  48794. t['gcommaaccent'] = 556;
  48795. t['eth'] = 556;
  48796. t['zcaron'] = 500;
  48797. t['ncommaaccent'] = 556;
  48798. t['onesuperior'] = 333;
  48799. t['imacron'] = 278;
  48800. t['Euro'] = 556;
  48801. });
  48802. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  48803. t['space'] = 278;
  48804. t['exclam'] = 333;
  48805. t['quotedbl'] = 474;
  48806. t['numbersign'] = 556;
  48807. t['dollar'] = 556;
  48808. t['percent'] = 889;
  48809. t['ampersand'] = 722;
  48810. t['quoteright'] = 278;
  48811. t['parenleft'] = 333;
  48812. t['parenright'] = 333;
  48813. t['asterisk'] = 389;
  48814. t['plus'] = 584;
  48815. t['comma'] = 278;
  48816. t['hyphen'] = 333;
  48817. t['period'] = 278;
  48818. t['slash'] = 278;
  48819. t['zero'] = 556;
  48820. t['one'] = 556;
  48821. t['two'] = 556;
  48822. t['three'] = 556;
  48823. t['four'] = 556;
  48824. t['five'] = 556;
  48825. t['six'] = 556;
  48826. t['seven'] = 556;
  48827. t['eight'] = 556;
  48828. t['nine'] = 556;
  48829. t['colon'] = 333;
  48830. t['semicolon'] = 333;
  48831. t['less'] = 584;
  48832. t['equal'] = 584;
  48833. t['greater'] = 584;
  48834. t['question'] = 611;
  48835. t['at'] = 975;
  48836. t['A'] = 722;
  48837. t['B'] = 722;
  48838. t['C'] = 722;
  48839. t['D'] = 722;
  48840. t['E'] = 667;
  48841. t['F'] = 611;
  48842. t['G'] = 778;
  48843. t['H'] = 722;
  48844. t['I'] = 278;
  48845. t['J'] = 556;
  48846. t['K'] = 722;
  48847. t['L'] = 611;
  48848. t['M'] = 833;
  48849. t['N'] = 722;
  48850. t['O'] = 778;
  48851. t['P'] = 667;
  48852. t['Q'] = 778;
  48853. t['R'] = 722;
  48854. t['S'] = 667;
  48855. t['T'] = 611;
  48856. t['U'] = 722;
  48857. t['V'] = 667;
  48858. t['W'] = 944;
  48859. t['X'] = 667;
  48860. t['Y'] = 667;
  48861. t['Z'] = 611;
  48862. t['bracketleft'] = 333;
  48863. t['backslash'] = 278;
  48864. t['bracketright'] = 333;
  48865. t['asciicircum'] = 584;
  48866. t['underscore'] = 556;
  48867. t['quoteleft'] = 278;
  48868. t['a'] = 556;
  48869. t['b'] = 611;
  48870. t['c'] = 556;
  48871. t['d'] = 611;
  48872. t['e'] = 556;
  48873. t['f'] = 333;
  48874. t['g'] = 611;
  48875. t['h'] = 611;
  48876. t['i'] = 278;
  48877. t['j'] = 278;
  48878. t['k'] = 556;
  48879. t['l'] = 278;
  48880. t['m'] = 889;
  48881. t['n'] = 611;
  48882. t['o'] = 611;
  48883. t['p'] = 611;
  48884. t['q'] = 611;
  48885. t['r'] = 389;
  48886. t['s'] = 556;
  48887. t['t'] = 333;
  48888. t['u'] = 611;
  48889. t['v'] = 556;
  48890. t['w'] = 778;
  48891. t['x'] = 556;
  48892. t['y'] = 556;
  48893. t['z'] = 500;
  48894. t['braceleft'] = 389;
  48895. t['bar'] = 280;
  48896. t['braceright'] = 389;
  48897. t['asciitilde'] = 584;
  48898. t['exclamdown'] = 333;
  48899. t['cent'] = 556;
  48900. t['sterling'] = 556;
  48901. t['fraction'] = 167;
  48902. t['yen'] = 556;
  48903. t['florin'] = 556;
  48904. t['section'] = 556;
  48905. t['currency'] = 556;
  48906. t['quotesingle'] = 238;
  48907. t['quotedblleft'] = 500;
  48908. t['guillemotleft'] = 556;
  48909. t['guilsinglleft'] = 333;
  48910. t['guilsinglright'] = 333;
  48911. t['fi'] = 611;
  48912. t['fl'] = 611;
  48913. t['endash'] = 556;
  48914. t['dagger'] = 556;
  48915. t['daggerdbl'] = 556;
  48916. t['periodcentered'] = 278;
  48917. t['paragraph'] = 556;
  48918. t['bullet'] = 350;
  48919. t['quotesinglbase'] = 278;
  48920. t['quotedblbase'] = 500;
  48921. t['quotedblright'] = 500;
  48922. t['guillemotright'] = 556;
  48923. t['ellipsis'] = 1000;
  48924. t['perthousand'] = 1000;
  48925. t['questiondown'] = 611;
  48926. t['grave'] = 333;
  48927. t['acute'] = 333;
  48928. t['circumflex'] = 333;
  48929. t['tilde'] = 333;
  48930. t['macron'] = 333;
  48931. t['breve'] = 333;
  48932. t['dotaccent'] = 333;
  48933. t['dieresis'] = 333;
  48934. t['ring'] = 333;
  48935. t['cedilla'] = 333;
  48936. t['hungarumlaut'] = 333;
  48937. t['ogonek'] = 333;
  48938. t['caron'] = 333;
  48939. t['emdash'] = 1000;
  48940. t['AE'] = 1000;
  48941. t['ordfeminine'] = 370;
  48942. t['Lslash'] = 611;
  48943. t['Oslash'] = 778;
  48944. t['OE'] = 1000;
  48945. t['ordmasculine'] = 365;
  48946. t['ae'] = 889;
  48947. t['dotlessi'] = 278;
  48948. t['lslash'] = 278;
  48949. t['oslash'] = 611;
  48950. t['oe'] = 944;
  48951. t['germandbls'] = 611;
  48952. t['Idieresis'] = 278;
  48953. t['eacute'] = 556;
  48954. t['abreve'] = 556;
  48955. t['uhungarumlaut'] = 611;
  48956. t['ecaron'] = 556;
  48957. t['Ydieresis'] = 667;
  48958. t['divide'] = 584;
  48959. t['Yacute'] = 667;
  48960. t['Acircumflex'] = 722;
  48961. t['aacute'] = 556;
  48962. t['Ucircumflex'] = 722;
  48963. t['yacute'] = 556;
  48964. t['scommaaccent'] = 556;
  48965. t['ecircumflex'] = 556;
  48966. t['Uring'] = 722;
  48967. t['Udieresis'] = 722;
  48968. t['aogonek'] = 556;
  48969. t['Uacute'] = 722;
  48970. t['uogonek'] = 611;
  48971. t['Edieresis'] = 667;
  48972. t['Dcroat'] = 722;
  48973. t['commaaccent'] = 250;
  48974. t['copyright'] = 737;
  48975. t['Emacron'] = 667;
  48976. t['ccaron'] = 556;
  48977. t['aring'] = 556;
  48978. t['Ncommaaccent'] = 722;
  48979. t['lacute'] = 278;
  48980. t['agrave'] = 556;
  48981. t['Tcommaaccent'] = 611;
  48982. t['Cacute'] = 722;
  48983. t['atilde'] = 556;
  48984. t['Edotaccent'] = 667;
  48985. t['scaron'] = 556;
  48986. t['scedilla'] = 556;
  48987. t['iacute'] = 278;
  48988. t['lozenge'] = 494;
  48989. t['Rcaron'] = 722;
  48990. t['Gcommaaccent'] = 778;
  48991. t['ucircumflex'] = 611;
  48992. t['acircumflex'] = 556;
  48993. t['Amacron'] = 722;
  48994. t['rcaron'] = 389;
  48995. t['ccedilla'] = 556;
  48996. t['Zdotaccent'] = 611;
  48997. t['Thorn'] = 667;
  48998. t['Omacron'] = 778;
  48999. t['Racute'] = 722;
  49000. t['Sacute'] = 667;
  49001. t['dcaron'] = 743;
  49002. t['Umacron'] = 722;
  49003. t['uring'] = 611;
  49004. t['threesuperior'] = 333;
  49005. t['Ograve'] = 778;
  49006. t['Agrave'] = 722;
  49007. t['Abreve'] = 722;
  49008. t['multiply'] = 584;
  49009. t['uacute'] = 611;
  49010. t['Tcaron'] = 611;
  49011. t['partialdiff'] = 494;
  49012. t['ydieresis'] = 556;
  49013. t['Nacute'] = 722;
  49014. t['icircumflex'] = 278;
  49015. t['Ecircumflex'] = 667;
  49016. t['adieresis'] = 556;
  49017. t['edieresis'] = 556;
  49018. t['cacute'] = 556;
  49019. t['nacute'] = 611;
  49020. t['umacron'] = 611;
  49021. t['Ncaron'] = 722;
  49022. t['Iacute'] = 278;
  49023. t['plusminus'] = 584;
  49024. t['brokenbar'] = 280;
  49025. t['registered'] = 737;
  49026. t['Gbreve'] = 778;
  49027. t['Idotaccent'] = 278;
  49028. t['summation'] = 600;
  49029. t['Egrave'] = 667;
  49030. t['racute'] = 389;
  49031. t['omacron'] = 611;
  49032. t['Zacute'] = 611;
  49033. t['Zcaron'] = 611;
  49034. t['greaterequal'] = 549;
  49035. t['Eth'] = 722;
  49036. t['Ccedilla'] = 722;
  49037. t['lcommaaccent'] = 278;
  49038. t['tcaron'] = 389;
  49039. t['eogonek'] = 556;
  49040. t['Uogonek'] = 722;
  49041. t['Aacute'] = 722;
  49042. t['Adieresis'] = 722;
  49043. t['egrave'] = 556;
  49044. t['zacute'] = 500;
  49045. t['iogonek'] = 278;
  49046. t['Oacute'] = 778;
  49047. t['oacute'] = 611;
  49048. t['amacron'] = 556;
  49049. t['sacute'] = 556;
  49050. t['idieresis'] = 278;
  49051. t['Ocircumflex'] = 778;
  49052. t['Ugrave'] = 722;
  49053. t['Delta'] = 612;
  49054. t['thorn'] = 611;
  49055. t['twosuperior'] = 333;
  49056. t['Odieresis'] = 778;
  49057. t['mu'] = 611;
  49058. t['igrave'] = 278;
  49059. t['ohungarumlaut'] = 611;
  49060. t['Eogonek'] = 667;
  49061. t['dcroat'] = 611;
  49062. t['threequarters'] = 834;
  49063. t['Scedilla'] = 667;
  49064. t['lcaron'] = 400;
  49065. t['Kcommaaccent'] = 722;
  49066. t['Lacute'] = 611;
  49067. t['trademark'] = 1000;
  49068. t['edotaccent'] = 556;
  49069. t['Igrave'] = 278;
  49070. t['Imacron'] = 278;
  49071. t['Lcaron'] = 611;
  49072. t['onehalf'] = 834;
  49073. t['lessequal'] = 549;
  49074. t['ocircumflex'] = 611;
  49075. t['ntilde'] = 611;
  49076. t['Uhungarumlaut'] = 722;
  49077. t['Eacute'] = 667;
  49078. t['emacron'] = 556;
  49079. t['gbreve'] = 611;
  49080. t['onequarter'] = 834;
  49081. t['Scaron'] = 667;
  49082. t['Scommaaccent'] = 667;
  49083. t['Ohungarumlaut'] = 778;
  49084. t['degree'] = 400;
  49085. t['ograve'] = 611;
  49086. t['Ccaron'] = 722;
  49087. t['ugrave'] = 611;
  49088. t['radical'] = 549;
  49089. t['Dcaron'] = 722;
  49090. t['rcommaaccent'] = 389;
  49091. t['Ntilde'] = 722;
  49092. t['otilde'] = 611;
  49093. t['Rcommaaccent'] = 722;
  49094. t['Lcommaaccent'] = 611;
  49095. t['Atilde'] = 722;
  49096. t['Aogonek'] = 722;
  49097. t['Aring'] = 722;
  49098. t['Otilde'] = 778;
  49099. t['zdotaccent'] = 500;
  49100. t['Ecaron'] = 667;
  49101. t['Iogonek'] = 278;
  49102. t['kcommaaccent'] = 556;
  49103. t['minus'] = 584;
  49104. t['Icircumflex'] = 278;
  49105. t['ncaron'] = 611;
  49106. t['tcommaaccent'] = 333;
  49107. t['logicalnot'] = 584;
  49108. t['odieresis'] = 611;
  49109. t['udieresis'] = 611;
  49110. t['notequal'] = 549;
  49111. t['gcommaaccent'] = 611;
  49112. t['eth'] = 611;
  49113. t['zcaron'] = 500;
  49114. t['ncommaaccent'] = 611;
  49115. t['onesuperior'] = 333;
  49116. t['imacron'] = 278;
  49117. t['Euro'] = 556;
  49118. });
  49119. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49120. t['space'] = 278;
  49121. t['exclam'] = 333;
  49122. t['quotedbl'] = 474;
  49123. t['numbersign'] = 556;
  49124. t['dollar'] = 556;
  49125. t['percent'] = 889;
  49126. t['ampersand'] = 722;
  49127. t['quoteright'] = 278;
  49128. t['parenleft'] = 333;
  49129. t['parenright'] = 333;
  49130. t['asterisk'] = 389;
  49131. t['plus'] = 584;
  49132. t['comma'] = 278;
  49133. t['hyphen'] = 333;
  49134. t['period'] = 278;
  49135. t['slash'] = 278;
  49136. t['zero'] = 556;
  49137. t['one'] = 556;
  49138. t['two'] = 556;
  49139. t['three'] = 556;
  49140. t['four'] = 556;
  49141. t['five'] = 556;
  49142. t['six'] = 556;
  49143. t['seven'] = 556;
  49144. t['eight'] = 556;
  49145. t['nine'] = 556;
  49146. t['colon'] = 333;
  49147. t['semicolon'] = 333;
  49148. t['less'] = 584;
  49149. t['equal'] = 584;
  49150. t['greater'] = 584;
  49151. t['question'] = 611;
  49152. t['at'] = 975;
  49153. t['A'] = 722;
  49154. t['B'] = 722;
  49155. t['C'] = 722;
  49156. t['D'] = 722;
  49157. t['E'] = 667;
  49158. t['F'] = 611;
  49159. t['G'] = 778;
  49160. t['H'] = 722;
  49161. t['I'] = 278;
  49162. t['J'] = 556;
  49163. t['K'] = 722;
  49164. t['L'] = 611;
  49165. t['M'] = 833;
  49166. t['N'] = 722;
  49167. t['O'] = 778;
  49168. t['P'] = 667;
  49169. t['Q'] = 778;
  49170. t['R'] = 722;
  49171. t['S'] = 667;
  49172. t['T'] = 611;
  49173. t['U'] = 722;
  49174. t['V'] = 667;
  49175. t['W'] = 944;
  49176. t['X'] = 667;
  49177. t['Y'] = 667;
  49178. t['Z'] = 611;
  49179. t['bracketleft'] = 333;
  49180. t['backslash'] = 278;
  49181. t['bracketright'] = 333;
  49182. t['asciicircum'] = 584;
  49183. t['underscore'] = 556;
  49184. t['quoteleft'] = 278;
  49185. t['a'] = 556;
  49186. t['b'] = 611;
  49187. t['c'] = 556;
  49188. t['d'] = 611;
  49189. t['e'] = 556;
  49190. t['f'] = 333;
  49191. t['g'] = 611;
  49192. t['h'] = 611;
  49193. t['i'] = 278;
  49194. t['j'] = 278;
  49195. t['k'] = 556;
  49196. t['l'] = 278;
  49197. t['m'] = 889;
  49198. t['n'] = 611;
  49199. t['o'] = 611;
  49200. t['p'] = 611;
  49201. t['q'] = 611;
  49202. t['r'] = 389;
  49203. t['s'] = 556;
  49204. t['t'] = 333;
  49205. t['u'] = 611;
  49206. t['v'] = 556;
  49207. t['w'] = 778;
  49208. t['x'] = 556;
  49209. t['y'] = 556;
  49210. t['z'] = 500;
  49211. t['braceleft'] = 389;
  49212. t['bar'] = 280;
  49213. t['braceright'] = 389;
  49214. t['asciitilde'] = 584;
  49215. t['exclamdown'] = 333;
  49216. t['cent'] = 556;
  49217. t['sterling'] = 556;
  49218. t['fraction'] = 167;
  49219. t['yen'] = 556;
  49220. t['florin'] = 556;
  49221. t['section'] = 556;
  49222. t['currency'] = 556;
  49223. t['quotesingle'] = 238;
  49224. t['quotedblleft'] = 500;
  49225. t['guillemotleft'] = 556;
  49226. t['guilsinglleft'] = 333;
  49227. t['guilsinglright'] = 333;
  49228. t['fi'] = 611;
  49229. t['fl'] = 611;
  49230. t['endash'] = 556;
  49231. t['dagger'] = 556;
  49232. t['daggerdbl'] = 556;
  49233. t['periodcentered'] = 278;
  49234. t['paragraph'] = 556;
  49235. t['bullet'] = 350;
  49236. t['quotesinglbase'] = 278;
  49237. t['quotedblbase'] = 500;
  49238. t['quotedblright'] = 500;
  49239. t['guillemotright'] = 556;
  49240. t['ellipsis'] = 1000;
  49241. t['perthousand'] = 1000;
  49242. t['questiondown'] = 611;
  49243. t['grave'] = 333;
  49244. t['acute'] = 333;
  49245. t['circumflex'] = 333;
  49246. t['tilde'] = 333;
  49247. t['macron'] = 333;
  49248. t['breve'] = 333;
  49249. t['dotaccent'] = 333;
  49250. t['dieresis'] = 333;
  49251. t['ring'] = 333;
  49252. t['cedilla'] = 333;
  49253. t['hungarumlaut'] = 333;
  49254. t['ogonek'] = 333;
  49255. t['caron'] = 333;
  49256. t['emdash'] = 1000;
  49257. t['AE'] = 1000;
  49258. t['ordfeminine'] = 370;
  49259. t['Lslash'] = 611;
  49260. t['Oslash'] = 778;
  49261. t['OE'] = 1000;
  49262. t['ordmasculine'] = 365;
  49263. t['ae'] = 889;
  49264. t['dotlessi'] = 278;
  49265. t['lslash'] = 278;
  49266. t['oslash'] = 611;
  49267. t['oe'] = 944;
  49268. t['germandbls'] = 611;
  49269. t['Idieresis'] = 278;
  49270. t['eacute'] = 556;
  49271. t['abreve'] = 556;
  49272. t['uhungarumlaut'] = 611;
  49273. t['ecaron'] = 556;
  49274. t['Ydieresis'] = 667;
  49275. t['divide'] = 584;
  49276. t['Yacute'] = 667;
  49277. t['Acircumflex'] = 722;
  49278. t['aacute'] = 556;
  49279. t['Ucircumflex'] = 722;
  49280. t['yacute'] = 556;
  49281. t['scommaaccent'] = 556;
  49282. t['ecircumflex'] = 556;
  49283. t['Uring'] = 722;
  49284. t['Udieresis'] = 722;
  49285. t['aogonek'] = 556;
  49286. t['Uacute'] = 722;
  49287. t['uogonek'] = 611;
  49288. t['Edieresis'] = 667;
  49289. t['Dcroat'] = 722;
  49290. t['commaaccent'] = 250;
  49291. t['copyright'] = 737;
  49292. t['Emacron'] = 667;
  49293. t['ccaron'] = 556;
  49294. t['aring'] = 556;
  49295. t['Ncommaaccent'] = 722;
  49296. t['lacute'] = 278;
  49297. t['agrave'] = 556;
  49298. t['Tcommaaccent'] = 611;
  49299. t['Cacute'] = 722;
  49300. t['atilde'] = 556;
  49301. t['Edotaccent'] = 667;
  49302. t['scaron'] = 556;
  49303. t['scedilla'] = 556;
  49304. t['iacute'] = 278;
  49305. t['lozenge'] = 494;
  49306. t['Rcaron'] = 722;
  49307. t['Gcommaaccent'] = 778;
  49308. t['ucircumflex'] = 611;
  49309. t['acircumflex'] = 556;
  49310. t['Amacron'] = 722;
  49311. t['rcaron'] = 389;
  49312. t['ccedilla'] = 556;
  49313. t['Zdotaccent'] = 611;
  49314. t['Thorn'] = 667;
  49315. t['Omacron'] = 778;
  49316. t['Racute'] = 722;
  49317. t['Sacute'] = 667;
  49318. t['dcaron'] = 743;
  49319. t['Umacron'] = 722;
  49320. t['uring'] = 611;
  49321. t['threesuperior'] = 333;
  49322. t['Ograve'] = 778;
  49323. t['Agrave'] = 722;
  49324. t['Abreve'] = 722;
  49325. t['multiply'] = 584;
  49326. t['uacute'] = 611;
  49327. t['Tcaron'] = 611;
  49328. t['partialdiff'] = 494;
  49329. t['ydieresis'] = 556;
  49330. t['Nacute'] = 722;
  49331. t['icircumflex'] = 278;
  49332. t['Ecircumflex'] = 667;
  49333. t['adieresis'] = 556;
  49334. t['edieresis'] = 556;
  49335. t['cacute'] = 556;
  49336. t['nacute'] = 611;
  49337. t['umacron'] = 611;
  49338. t['Ncaron'] = 722;
  49339. t['Iacute'] = 278;
  49340. t['plusminus'] = 584;
  49341. t['brokenbar'] = 280;
  49342. t['registered'] = 737;
  49343. t['Gbreve'] = 778;
  49344. t['Idotaccent'] = 278;
  49345. t['summation'] = 600;
  49346. t['Egrave'] = 667;
  49347. t['racute'] = 389;
  49348. t['omacron'] = 611;
  49349. t['Zacute'] = 611;
  49350. t['Zcaron'] = 611;
  49351. t['greaterequal'] = 549;
  49352. t['Eth'] = 722;
  49353. t['Ccedilla'] = 722;
  49354. t['lcommaaccent'] = 278;
  49355. t['tcaron'] = 389;
  49356. t['eogonek'] = 556;
  49357. t['Uogonek'] = 722;
  49358. t['Aacute'] = 722;
  49359. t['Adieresis'] = 722;
  49360. t['egrave'] = 556;
  49361. t['zacute'] = 500;
  49362. t['iogonek'] = 278;
  49363. t['Oacute'] = 778;
  49364. t['oacute'] = 611;
  49365. t['amacron'] = 556;
  49366. t['sacute'] = 556;
  49367. t['idieresis'] = 278;
  49368. t['Ocircumflex'] = 778;
  49369. t['Ugrave'] = 722;
  49370. t['Delta'] = 612;
  49371. t['thorn'] = 611;
  49372. t['twosuperior'] = 333;
  49373. t['Odieresis'] = 778;
  49374. t['mu'] = 611;
  49375. t['igrave'] = 278;
  49376. t['ohungarumlaut'] = 611;
  49377. t['Eogonek'] = 667;
  49378. t['dcroat'] = 611;
  49379. t['threequarters'] = 834;
  49380. t['Scedilla'] = 667;
  49381. t['lcaron'] = 400;
  49382. t['Kcommaaccent'] = 722;
  49383. t['Lacute'] = 611;
  49384. t['trademark'] = 1000;
  49385. t['edotaccent'] = 556;
  49386. t['Igrave'] = 278;
  49387. t['Imacron'] = 278;
  49388. t['Lcaron'] = 611;
  49389. t['onehalf'] = 834;
  49390. t['lessequal'] = 549;
  49391. t['ocircumflex'] = 611;
  49392. t['ntilde'] = 611;
  49393. t['Uhungarumlaut'] = 722;
  49394. t['Eacute'] = 667;
  49395. t['emacron'] = 556;
  49396. t['gbreve'] = 611;
  49397. t['onequarter'] = 834;
  49398. t['Scaron'] = 667;
  49399. t['Scommaaccent'] = 667;
  49400. t['Ohungarumlaut'] = 778;
  49401. t['degree'] = 400;
  49402. t['ograve'] = 611;
  49403. t['Ccaron'] = 722;
  49404. t['ugrave'] = 611;
  49405. t['radical'] = 549;
  49406. t['Dcaron'] = 722;
  49407. t['rcommaaccent'] = 389;
  49408. t['Ntilde'] = 722;
  49409. t['otilde'] = 611;
  49410. t['Rcommaaccent'] = 722;
  49411. t['Lcommaaccent'] = 611;
  49412. t['Atilde'] = 722;
  49413. t['Aogonek'] = 722;
  49414. t['Aring'] = 722;
  49415. t['Otilde'] = 778;
  49416. t['zdotaccent'] = 500;
  49417. t['Ecaron'] = 667;
  49418. t['Iogonek'] = 278;
  49419. t['kcommaaccent'] = 556;
  49420. t['minus'] = 584;
  49421. t['Icircumflex'] = 278;
  49422. t['ncaron'] = 611;
  49423. t['tcommaaccent'] = 333;
  49424. t['logicalnot'] = 584;
  49425. t['odieresis'] = 611;
  49426. t['udieresis'] = 611;
  49427. t['notequal'] = 549;
  49428. t['gcommaaccent'] = 611;
  49429. t['eth'] = 611;
  49430. t['zcaron'] = 500;
  49431. t['ncommaaccent'] = 611;
  49432. t['onesuperior'] = 333;
  49433. t['imacron'] = 278;
  49434. t['Euro'] = 556;
  49435. });
  49436. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  49437. t['space'] = 278;
  49438. t['exclam'] = 278;
  49439. t['quotedbl'] = 355;
  49440. t['numbersign'] = 556;
  49441. t['dollar'] = 556;
  49442. t['percent'] = 889;
  49443. t['ampersand'] = 667;
  49444. t['quoteright'] = 222;
  49445. t['parenleft'] = 333;
  49446. t['parenright'] = 333;
  49447. t['asterisk'] = 389;
  49448. t['plus'] = 584;
  49449. t['comma'] = 278;
  49450. t['hyphen'] = 333;
  49451. t['period'] = 278;
  49452. t['slash'] = 278;
  49453. t['zero'] = 556;
  49454. t['one'] = 556;
  49455. t['two'] = 556;
  49456. t['three'] = 556;
  49457. t['four'] = 556;
  49458. t['five'] = 556;
  49459. t['six'] = 556;
  49460. t['seven'] = 556;
  49461. t['eight'] = 556;
  49462. t['nine'] = 556;
  49463. t['colon'] = 278;
  49464. t['semicolon'] = 278;
  49465. t['less'] = 584;
  49466. t['equal'] = 584;
  49467. t['greater'] = 584;
  49468. t['question'] = 556;
  49469. t['at'] = 1015;
  49470. t['A'] = 667;
  49471. t['B'] = 667;
  49472. t['C'] = 722;
  49473. t['D'] = 722;
  49474. t['E'] = 667;
  49475. t['F'] = 611;
  49476. t['G'] = 778;
  49477. t['H'] = 722;
  49478. t['I'] = 278;
  49479. t['J'] = 500;
  49480. t['K'] = 667;
  49481. t['L'] = 556;
  49482. t['M'] = 833;
  49483. t['N'] = 722;
  49484. t['O'] = 778;
  49485. t['P'] = 667;
  49486. t['Q'] = 778;
  49487. t['R'] = 722;
  49488. t['S'] = 667;
  49489. t['T'] = 611;
  49490. t['U'] = 722;
  49491. t['V'] = 667;
  49492. t['W'] = 944;
  49493. t['X'] = 667;
  49494. t['Y'] = 667;
  49495. t['Z'] = 611;
  49496. t['bracketleft'] = 278;
  49497. t['backslash'] = 278;
  49498. t['bracketright'] = 278;
  49499. t['asciicircum'] = 469;
  49500. t['underscore'] = 556;
  49501. t['quoteleft'] = 222;
  49502. t['a'] = 556;
  49503. t['b'] = 556;
  49504. t['c'] = 500;
  49505. t['d'] = 556;
  49506. t['e'] = 556;
  49507. t['f'] = 278;
  49508. t['g'] = 556;
  49509. t['h'] = 556;
  49510. t['i'] = 222;
  49511. t['j'] = 222;
  49512. t['k'] = 500;
  49513. t['l'] = 222;
  49514. t['m'] = 833;
  49515. t['n'] = 556;
  49516. t['o'] = 556;
  49517. t['p'] = 556;
  49518. t['q'] = 556;
  49519. t['r'] = 333;
  49520. t['s'] = 500;
  49521. t['t'] = 278;
  49522. t['u'] = 556;
  49523. t['v'] = 500;
  49524. t['w'] = 722;
  49525. t['x'] = 500;
  49526. t['y'] = 500;
  49527. t['z'] = 500;
  49528. t['braceleft'] = 334;
  49529. t['bar'] = 260;
  49530. t['braceright'] = 334;
  49531. t['asciitilde'] = 584;
  49532. t['exclamdown'] = 333;
  49533. t['cent'] = 556;
  49534. t['sterling'] = 556;
  49535. t['fraction'] = 167;
  49536. t['yen'] = 556;
  49537. t['florin'] = 556;
  49538. t['section'] = 556;
  49539. t['currency'] = 556;
  49540. t['quotesingle'] = 191;
  49541. t['quotedblleft'] = 333;
  49542. t['guillemotleft'] = 556;
  49543. t['guilsinglleft'] = 333;
  49544. t['guilsinglright'] = 333;
  49545. t['fi'] = 500;
  49546. t['fl'] = 500;
  49547. t['endash'] = 556;
  49548. t['dagger'] = 556;
  49549. t['daggerdbl'] = 556;
  49550. t['periodcentered'] = 278;
  49551. t['paragraph'] = 537;
  49552. t['bullet'] = 350;
  49553. t['quotesinglbase'] = 222;
  49554. t['quotedblbase'] = 333;
  49555. t['quotedblright'] = 333;
  49556. t['guillemotright'] = 556;
  49557. t['ellipsis'] = 1000;
  49558. t['perthousand'] = 1000;
  49559. t['questiondown'] = 611;
  49560. t['grave'] = 333;
  49561. t['acute'] = 333;
  49562. t['circumflex'] = 333;
  49563. t['tilde'] = 333;
  49564. t['macron'] = 333;
  49565. t['breve'] = 333;
  49566. t['dotaccent'] = 333;
  49567. t['dieresis'] = 333;
  49568. t['ring'] = 333;
  49569. t['cedilla'] = 333;
  49570. t['hungarumlaut'] = 333;
  49571. t['ogonek'] = 333;
  49572. t['caron'] = 333;
  49573. t['emdash'] = 1000;
  49574. t['AE'] = 1000;
  49575. t['ordfeminine'] = 370;
  49576. t['Lslash'] = 556;
  49577. t['Oslash'] = 778;
  49578. t['OE'] = 1000;
  49579. t['ordmasculine'] = 365;
  49580. t['ae'] = 889;
  49581. t['dotlessi'] = 278;
  49582. t['lslash'] = 222;
  49583. t['oslash'] = 611;
  49584. t['oe'] = 944;
  49585. t['germandbls'] = 611;
  49586. t['Idieresis'] = 278;
  49587. t['eacute'] = 556;
  49588. t['abreve'] = 556;
  49589. t['uhungarumlaut'] = 556;
  49590. t['ecaron'] = 556;
  49591. t['Ydieresis'] = 667;
  49592. t['divide'] = 584;
  49593. t['Yacute'] = 667;
  49594. t['Acircumflex'] = 667;
  49595. t['aacute'] = 556;
  49596. t['Ucircumflex'] = 722;
  49597. t['yacute'] = 500;
  49598. t['scommaaccent'] = 500;
  49599. t['ecircumflex'] = 556;
  49600. t['Uring'] = 722;
  49601. t['Udieresis'] = 722;
  49602. t['aogonek'] = 556;
  49603. t['Uacute'] = 722;
  49604. t['uogonek'] = 556;
  49605. t['Edieresis'] = 667;
  49606. t['Dcroat'] = 722;
  49607. t['commaaccent'] = 250;
  49608. t['copyright'] = 737;
  49609. t['Emacron'] = 667;
  49610. t['ccaron'] = 500;
  49611. t['aring'] = 556;
  49612. t['Ncommaaccent'] = 722;
  49613. t['lacute'] = 222;
  49614. t['agrave'] = 556;
  49615. t['Tcommaaccent'] = 611;
  49616. t['Cacute'] = 722;
  49617. t['atilde'] = 556;
  49618. t['Edotaccent'] = 667;
  49619. t['scaron'] = 500;
  49620. t['scedilla'] = 500;
  49621. t['iacute'] = 278;
  49622. t['lozenge'] = 471;
  49623. t['Rcaron'] = 722;
  49624. t['Gcommaaccent'] = 778;
  49625. t['ucircumflex'] = 556;
  49626. t['acircumflex'] = 556;
  49627. t['Amacron'] = 667;
  49628. t['rcaron'] = 333;
  49629. t['ccedilla'] = 500;
  49630. t['Zdotaccent'] = 611;
  49631. t['Thorn'] = 667;
  49632. t['Omacron'] = 778;
  49633. t['Racute'] = 722;
  49634. t['Sacute'] = 667;
  49635. t['dcaron'] = 643;
  49636. t['Umacron'] = 722;
  49637. t['uring'] = 556;
  49638. t['threesuperior'] = 333;
  49639. t['Ograve'] = 778;
  49640. t['Agrave'] = 667;
  49641. t['Abreve'] = 667;
  49642. t['multiply'] = 584;
  49643. t['uacute'] = 556;
  49644. t['Tcaron'] = 611;
  49645. t['partialdiff'] = 476;
  49646. t['ydieresis'] = 500;
  49647. t['Nacute'] = 722;
  49648. t['icircumflex'] = 278;
  49649. t['Ecircumflex'] = 667;
  49650. t['adieresis'] = 556;
  49651. t['edieresis'] = 556;
  49652. t['cacute'] = 500;
  49653. t['nacute'] = 556;
  49654. t['umacron'] = 556;
  49655. t['Ncaron'] = 722;
  49656. t['Iacute'] = 278;
  49657. t['plusminus'] = 584;
  49658. t['brokenbar'] = 260;
  49659. t['registered'] = 737;
  49660. t['Gbreve'] = 778;
  49661. t['Idotaccent'] = 278;
  49662. t['summation'] = 600;
  49663. t['Egrave'] = 667;
  49664. t['racute'] = 333;
  49665. t['omacron'] = 556;
  49666. t['Zacute'] = 611;
  49667. t['Zcaron'] = 611;
  49668. t['greaterequal'] = 549;
  49669. t['Eth'] = 722;
  49670. t['Ccedilla'] = 722;
  49671. t['lcommaaccent'] = 222;
  49672. t['tcaron'] = 317;
  49673. t['eogonek'] = 556;
  49674. t['Uogonek'] = 722;
  49675. t['Aacute'] = 667;
  49676. t['Adieresis'] = 667;
  49677. t['egrave'] = 556;
  49678. t['zacute'] = 500;
  49679. t['iogonek'] = 222;
  49680. t['Oacute'] = 778;
  49681. t['oacute'] = 556;
  49682. t['amacron'] = 556;
  49683. t['sacute'] = 500;
  49684. t['idieresis'] = 278;
  49685. t['Ocircumflex'] = 778;
  49686. t['Ugrave'] = 722;
  49687. t['Delta'] = 612;
  49688. t['thorn'] = 556;
  49689. t['twosuperior'] = 333;
  49690. t['Odieresis'] = 778;
  49691. t['mu'] = 556;
  49692. t['igrave'] = 278;
  49693. t['ohungarumlaut'] = 556;
  49694. t['Eogonek'] = 667;
  49695. t['dcroat'] = 556;
  49696. t['threequarters'] = 834;
  49697. t['Scedilla'] = 667;
  49698. t['lcaron'] = 299;
  49699. t['Kcommaaccent'] = 667;
  49700. t['Lacute'] = 556;
  49701. t['trademark'] = 1000;
  49702. t['edotaccent'] = 556;
  49703. t['Igrave'] = 278;
  49704. t['Imacron'] = 278;
  49705. t['Lcaron'] = 556;
  49706. t['onehalf'] = 834;
  49707. t['lessequal'] = 549;
  49708. t['ocircumflex'] = 556;
  49709. t['ntilde'] = 556;
  49710. t['Uhungarumlaut'] = 722;
  49711. t['Eacute'] = 667;
  49712. t['emacron'] = 556;
  49713. t['gbreve'] = 556;
  49714. t['onequarter'] = 834;
  49715. t['Scaron'] = 667;
  49716. t['Scommaaccent'] = 667;
  49717. t['Ohungarumlaut'] = 778;
  49718. t['degree'] = 400;
  49719. t['ograve'] = 556;
  49720. t['Ccaron'] = 722;
  49721. t['ugrave'] = 556;
  49722. t['radical'] = 453;
  49723. t['Dcaron'] = 722;
  49724. t['rcommaaccent'] = 333;
  49725. t['Ntilde'] = 722;
  49726. t['otilde'] = 556;
  49727. t['Rcommaaccent'] = 722;
  49728. t['Lcommaaccent'] = 556;
  49729. t['Atilde'] = 667;
  49730. t['Aogonek'] = 667;
  49731. t['Aring'] = 667;
  49732. t['Otilde'] = 778;
  49733. t['zdotaccent'] = 500;
  49734. t['Ecaron'] = 667;
  49735. t['Iogonek'] = 278;
  49736. t['kcommaaccent'] = 500;
  49737. t['minus'] = 584;
  49738. t['Icircumflex'] = 278;
  49739. t['ncaron'] = 556;
  49740. t['tcommaaccent'] = 278;
  49741. t['logicalnot'] = 584;
  49742. t['odieresis'] = 556;
  49743. t['udieresis'] = 556;
  49744. t['notequal'] = 549;
  49745. t['gcommaaccent'] = 556;
  49746. t['eth'] = 556;
  49747. t['zcaron'] = 500;
  49748. t['ncommaaccent'] = 556;
  49749. t['onesuperior'] = 333;
  49750. t['imacron'] = 278;
  49751. t['Euro'] = 556;
  49752. });
  49753. t['Symbol'] = getLookupTableFactory(function (t) {
  49754. t['space'] = 250;
  49755. t['exclam'] = 333;
  49756. t['universal'] = 713;
  49757. t['numbersign'] = 500;
  49758. t['existential'] = 549;
  49759. t['percent'] = 833;
  49760. t['ampersand'] = 778;
  49761. t['suchthat'] = 439;
  49762. t['parenleft'] = 333;
  49763. t['parenright'] = 333;
  49764. t['asteriskmath'] = 500;
  49765. t['plus'] = 549;
  49766. t['comma'] = 250;
  49767. t['minus'] = 549;
  49768. t['period'] = 250;
  49769. t['slash'] = 278;
  49770. t['zero'] = 500;
  49771. t['one'] = 500;
  49772. t['two'] = 500;
  49773. t['three'] = 500;
  49774. t['four'] = 500;
  49775. t['five'] = 500;
  49776. t['six'] = 500;
  49777. t['seven'] = 500;
  49778. t['eight'] = 500;
  49779. t['nine'] = 500;
  49780. t['colon'] = 278;
  49781. t['semicolon'] = 278;
  49782. t['less'] = 549;
  49783. t['equal'] = 549;
  49784. t['greater'] = 549;
  49785. t['question'] = 444;
  49786. t['congruent'] = 549;
  49787. t['Alpha'] = 722;
  49788. t['Beta'] = 667;
  49789. t['Chi'] = 722;
  49790. t['Delta'] = 612;
  49791. t['Epsilon'] = 611;
  49792. t['Phi'] = 763;
  49793. t['Gamma'] = 603;
  49794. t['Eta'] = 722;
  49795. t['Iota'] = 333;
  49796. t['theta1'] = 631;
  49797. t['Kappa'] = 722;
  49798. t['Lambda'] = 686;
  49799. t['Mu'] = 889;
  49800. t['Nu'] = 722;
  49801. t['Omicron'] = 722;
  49802. t['Pi'] = 768;
  49803. t['Theta'] = 741;
  49804. t['Rho'] = 556;
  49805. t['Sigma'] = 592;
  49806. t['Tau'] = 611;
  49807. t['Upsilon'] = 690;
  49808. t['sigma1'] = 439;
  49809. t['Omega'] = 768;
  49810. t['Xi'] = 645;
  49811. t['Psi'] = 795;
  49812. t['Zeta'] = 611;
  49813. t['bracketleft'] = 333;
  49814. t['therefore'] = 863;
  49815. t['bracketright'] = 333;
  49816. t['perpendicular'] = 658;
  49817. t['underscore'] = 500;
  49818. t['radicalex'] = 500;
  49819. t['alpha'] = 631;
  49820. t['beta'] = 549;
  49821. t['chi'] = 549;
  49822. t['delta'] = 494;
  49823. t['epsilon'] = 439;
  49824. t['phi'] = 521;
  49825. t['gamma'] = 411;
  49826. t['eta'] = 603;
  49827. t['iota'] = 329;
  49828. t['phi1'] = 603;
  49829. t['kappa'] = 549;
  49830. t['lambda'] = 549;
  49831. t['mu'] = 576;
  49832. t['nu'] = 521;
  49833. t['omicron'] = 549;
  49834. t['pi'] = 549;
  49835. t['theta'] = 521;
  49836. t['rho'] = 549;
  49837. t['sigma'] = 603;
  49838. t['tau'] = 439;
  49839. t['upsilon'] = 576;
  49840. t['omega1'] = 713;
  49841. t['omega'] = 686;
  49842. t['xi'] = 493;
  49843. t['psi'] = 686;
  49844. t['zeta'] = 494;
  49845. t['braceleft'] = 480;
  49846. t['bar'] = 200;
  49847. t['braceright'] = 480;
  49848. t['similar'] = 549;
  49849. t['Euro'] = 750;
  49850. t['Upsilon1'] = 620;
  49851. t['minute'] = 247;
  49852. t['lessequal'] = 549;
  49853. t['fraction'] = 167;
  49854. t['infinity'] = 713;
  49855. t['florin'] = 500;
  49856. t['club'] = 753;
  49857. t['diamond'] = 753;
  49858. t['heart'] = 753;
  49859. t['spade'] = 753;
  49860. t['arrowboth'] = 1042;
  49861. t['arrowleft'] = 987;
  49862. t['arrowup'] = 603;
  49863. t['arrowright'] = 987;
  49864. t['arrowdown'] = 603;
  49865. t['degree'] = 400;
  49866. t['plusminus'] = 549;
  49867. t['second'] = 411;
  49868. t['greaterequal'] = 549;
  49869. t['multiply'] = 549;
  49870. t['proportional'] = 713;
  49871. t['partialdiff'] = 494;
  49872. t['bullet'] = 460;
  49873. t['divide'] = 549;
  49874. t['notequal'] = 549;
  49875. t['equivalence'] = 549;
  49876. t['approxequal'] = 549;
  49877. t['ellipsis'] = 1000;
  49878. t['arrowvertex'] = 603;
  49879. t['arrowhorizex'] = 1000;
  49880. t['carriagereturn'] = 658;
  49881. t['aleph'] = 823;
  49882. t['Ifraktur'] = 686;
  49883. t['Rfraktur'] = 795;
  49884. t['weierstrass'] = 987;
  49885. t['circlemultiply'] = 768;
  49886. t['circleplus'] = 768;
  49887. t['emptyset'] = 823;
  49888. t['intersection'] = 768;
  49889. t['union'] = 768;
  49890. t['propersuperset'] = 713;
  49891. t['reflexsuperset'] = 713;
  49892. t['notsubset'] = 713;
  49893. t['propersubset'] = 713;
  49894. t['reflexsubset'] = 713;
  49895. t['element'] = 713;
  49896. t['notelement'] = 713;
  49897. t['angle'] = 768;
  49898. t['gradient'] = 713;
  49899. t['registerserif'] = 790;
  49900. t['copyrightserif'] = 790;
  49901. t['trademarkserif'] = 890;
  49902. t['product'] = 823;
  49903. t['radical'] = 549;
  49904. t['dotmath'] = 250;
  49905. t['logicalnot'] = 713;
  49906. t['logicaland'] = 603;
  49907. t['logicalor'] = 603;
  49908. t['arrowdblboth'] = 1042;
  49909. t['arrowdblleft'] = 987;
  49910. t['arrowdblup'] = 603;
  49911. t['arrowdblright'] = 987;
  49912. t['arrowdbldown'] = 603;
  49913. t['lozenge'] = 494;
  49914. t['angleleft'] = 329;
  49915. t['registersans'] = 790;
  49916. t['copyrightsans'] = 790;
  49917. t['trademarksans'] = 786;
  49918. t['summation'] = 713;
  49919. t['parenlefttp'] = 384;
  49920. t['parenleftex'] = 384;
  49921. t['parenleftbt'] = 384;
  49922. t['bracketlefttp'] = 384;
  49923. t['bracketleftex'] = 384;
  49924. t['bracketleftbt'] = 384;
  49925. t['bracelefttp'] = 494;
  49926. t['braceleftmid'] = 494;
  49927. t['braceleftbt'] = 494;
  49928. t['braceex'] = 494;
  49929. t['angleright'] = 329;
  49930. t['integral'] = 274;
  49931. t['integraltp'] = 686;
  49932. t['integralex'] = 686;
  49933. t['integralbt'] = 686;
  49934. t['parenrighttp'] = 384;
  49935. t['parenrightex'] = 384;
  49936. t['parenrightbt'] = 384;
  49937. t['bracketrighttp'] = 384;
  49938. t['bracketrightex'] = 384;
  49939. t['bracketrightbt'] = 384;
  49940. t['bracerighttp'] = 494;
  49941. t['bracerightmid'] = 494;
  49942. t['bracerightbt'] = 494;
  49943. t['apple'] = 790;
  49944. });
  49945. t['Times-Roman'] = getLookupTableFactory(function (t) {
  49946. t['space'] = 250;
  49947. t['exclam'] = 333;
  49948. t['quotedbl'] = 408;
  49949. t['numbersign'] = 500;
  49950. t['dollar'] = 500;
  49951. t['percent'] = 833;
  49952. t['ampersand'] = 778;
  49953. t['quoteright'] = 333;
  49954. t['parenleft'] = 333;
  49955. t['parenright'] = 333;
  49956. t['asterisk'] = 500;
  49957. t['plus'] = 564;
  49958. t['comma'] = 250;
  49959. t['hyphen'] = 333;
  49960. t['period'] = 250;
  49961. t['slash'] = 278;
  49962. t['zero'] = 500;
  49963. t['one'] = 500;
  49964. t['two'] = 500;
  49965. t['three'] = 500;
  49966. t['four'] = 500;
  49967. t['five'] = 500;
  49968. t['six'] = 500;
  49969. t['seven'] = 500;
  49970. t['eight'] = 500;
  49971. t['nine'] = 500;
  49972. t['colon'] = 278;
  49973. t['semicolon'] = 278;
  49974. t['less'] = 564;
  49975. t['equal'] = 564;
  49976. t['greater'] = 564;
  49977. t['question'] = 444;
  49978. t['at'] = 921;
  49979. t['A'] = 722;
  49980. t['B'] = 667;
  49981. t['C'] = 667;
  49982. t['D'] = 722;
  49983. t['E'] = 611;
  49984. t['F'] = 556;
  49985. t['G'] = 722;
  49986. t['H'] = 722;
  49987. t['I'] = 333;
  49988. t['J'] = 389;
  49989. t['K'] = 722;
  49990. t['L'] = 611;
  49991. t['M'] = 889;
  49992. t['N'] = 722;
  49993. t['O'] = 722;
  49994. t['P'] = 556;
  49995. t['Q'] = 722;
  49996. t['R'] = 667;
  49997. t['S'] = 556;
  49998. t['T'] = 611;
  49999. t['U'] = 722;
  50000. t['V'] = 722;
  50001. t['W'] = 944;
  50002. t['X'] = 722;
  50003. t['Y'] = 722;
  50004. t['Z'] = 611;
  50005. t['bracketleft'] = 333;
  50006. t['backslash'] = 278;
  50007. t['bracketright'] = 333;
  50008. t['asciicircum'] = 469;
  50009. t['underscore'] = 500;
  50010. t['quoteleft'] = 333;
  50011. t['a'] = 444;
  50012. t['b'] = 500;
  50013. t['c'] = 444;
  50014. t['d'] = 500;
  50015. t['e'] = 444;
  50016. t['f'] = 333;
  50017. t['g'] = 500;
  50018. t['h'] = 500;
  50019. t['i'] = 278;
  50020. t['j'] = 278;
  50021. t['k'] = 500;
  50022. t['l'] = 278;
  50023. t['m'] = 778;
  50024. t['n'] = 500;
  50025. t['o'] = 500;
  50026. t['p'] = 500;
  50027. t['q'] = 500;
  50028. t['r'] = 333;
  50029. t['s'] = 389;
  50030. t['t'] = 278;
  50031. t['u'] = 500;
  50032. t['v'] = 500;
  50033. t['w'] = 722;
  50034. t['x'] = 500;
  50035. t['y'] = 500;
  50036. t['z'] = 444;
  50037. t['braceleft'] = 480;
  50038. t['bar'] = 200;
  50039. t['braceright'] = 480;
  50040. t['asciitilde'] = 541;
  50041. t['exclamdown'] = 333;
  50042. t['cent'] = 500;
  50043. t['sterling'] = 500;
  50044. t['fraction'] = 167;
  50045. t['yen'] = 500;
  50046. t['florin'] = 500;
  50047. t['section'] = 500;
  50048. t['currency'] = 500;
  50049. t['quotesingle'] = 180;
  50050. t['quotedblleft'] = 444;
  50051. t['guillemotleft'] = 500;
  50052. t['guilsinglleft'] = 333;
  50053. t['guilsinglright'] = 333;
  50054. t['fi'] = 556;
  50055. t['fl'] = 556;
  50056. t['endash'] = 500;
  50057. t['dagger'] = 500;
  50058. t['daggerdbl'] = 500;
  50059. t['periodcentered'] = 250;
  50060. t['paragraph'] = 453;
  50061. t['bullet'] = 350;
  50062. t['quotesinglbase'] = 333;
  50063. t['quotedblbase'] = 444;
  50064. t['quotedblright'] = 444;
  50065. t['guillemotright'] = 500;
  50066. t['ellipsis'] = 1000;
  50067. t['perthousand'] = 1000;
  50068. t['questiondown'] = 444;
  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'] = 889;
  50084. t['ordfeminine'] = 276;
  50085. t['Lslash'] = 611;
  50086. t['Oslash'] = 722;
  50087. t['OE'] = 889;
  50088. t['ordmasculine'] = 310;
  50089. t['ae'] = 667;
  50090. t['dotlessi'] = 278;
  50091. t['lslash'] = 278;
  50092. t['oslash'] = 500;
  50093. t['oe'] = 722;
  50094. t['germandbls'] = 500;
  50095. t['Idieresis'] = 333;
  50096. t['eacute'] = 444;
  50097. t['abreve'] = 444;
  50098. t['uhungarumlaut'] = 500;
  50099. t['ecaron'] = 444;
  50100. t['Ydieresis'] = 722;
  50101. t['divide'] = 564;
  50102. t['Yacute'] = 722;
  50103. t['Acircumflex'] = 722;
  50104. t['aacute'] = 444;
  50105. t['Ucircumflex'] = 722;
  50106. t['yacute'] = 500;
  50107. t['scommaaccent'] = 389;
  50108. t['ecircumflex'] = 444;
  50109. t['Uring'] = 722;
  50110. t['Udieresis'] = 722;
  50111. t['aogonek'] = 444;
  50112. t['Uacute'] = 722;
  50113. t['uogonek'] = 500;
  50114. t['Edieresis'] = 611;
  50115. t['Dcroat'] = 722;
  50116. t['commaaccent'] = 250;
  50117. t['copyright'] = 760;
  50118. t['Emacron'] = 611;
  50119. t['ccaron'] = 444;
  50120. t['aring'] = 444;
  50121. t['Ncommaaccent'] = 722;
  50122. t['lacute'] = 278;
  50123. t['agrave'] = 444;
  50124. t['Tcommaaccent'] = 611;
  50125. t['Cacute'] = 667;
  50126. t['atilde'] = 444;
  50127. t['Edotaccent'] = 611;
  50128. t['scaron'] = 389;
  50129. t['scedilla'] = 389;
  50130. t['iacute'] = 278;
  50131. t['lozenge'] = 471;
  50132. t['Rcaron'] = 667;
  50133. t['Gcommaaccent'] = 722;
  50134. t['ucircumflex'] = 500;
  50135. t['acircumflex'] = 444;
  50136. t['Amacron'] = 722;
  50137. t['rcaron'] = 333;
  50138. t['ccedilla'] = 444;
  50139. t['Zdotaccent'] = 611;
  50140. t['Thorn'] = 556;
  50141. t['Omacron'] = 722;
  50142. t['Racute'] = 667;
  50143. t['Sacute'] = 556;
  50144. t['dcaron'] = 588;
  50145. t['Umacron'] = 722;
  50146. t['uring'] = 500;
  50147. t['threesuperior'] = 300;
  50148. t['Ograve'] = 722;
  50149. t['Agrave'] = 722;
  50150. t['Abreve'] = 722;
  50151. t['multiply'] = 564;
  50152. t['uacute'] = 500;
  50153. t['Tcaron'] = 611;
  50154. t['partialdiff'] = 476;
  50155. t['ydieresis'] = 500;
  50156. t['Nacute'] = 722;
  50157. t['icircumflex'] = 278;
  50158. t['Ecircumflex'] = 611;
  50159. t['adieresis'] = 444;
  50160. t['edieresis'] = 444;
  50161. t['cacute'] = 444;
  50162. t['nacute'] = 500;
  50163. t['umacron'] = 500;
  50164. t['Ncaron'] = 722;
  50165. t['Iacute'] = 333;
  50166. t['plusminus'] = 564;
  50167. t['brokenbar'] = 200;
  50168. t['registered'] = 760;
  50169. t['Gbreve'] = 722;
  50170. t['Idotaccent'] = 333;
  50171. t['summation'] = 600;
  50172. t['Egrave'] = 611;
  50173. t['racute'] = 333;
  50174. t['omacron'] = 500;
  50175. t['Zacute'] = 611;
  50176. t['Zcaron'] = 611;
  50177. t['greaterequal'] = 549;
  50178. t['Eth'] = 722;
  50179. t['Ccedilla'] = 667;
  50180. t['lcommaaccent'] = 278;
  50181. t['tcaron'] = 326;
  50182. t['eogonek'] = 444;
  50183. t['Uogonek'] = 722;
  50184. t['Aacute'] = 722;
  50185. t['Adieresis'] = 722;
  50186. t['egrave'] = 444;
  50187. t['zacute'] = 444;
  50188. t['iogonek'] = 278;
  50189. t['Oacute'] = 722;
  50190. t['oacute'] = 500;
  50191. t['amacron'] = 444;
  50192. t['sacute'] = 389;
  50193. t['idieresis'] = 278;
  50194. t['Ocircumflex'] = 722;
  50195. t['Ugrave'] = 722;
  50196. t['Delta'] = 612;
  50197. t['thorn'] = 500;
  50198. t['twosuperior'] = 300;
  50199. t['Odieresis'] = 722;
  50200. t['mu'] = 500;
  50201. t['igrave'] = 278;
  50202. t['ohungarumlaut'] = 500;
  50203. t['Eogonek'] = 611;
  50204. t['dcroat'] = 500;
  50205. t['threequarters'] = 750;
  50206. t['Scedilla'] = 556;
  50207. t['lcaron'] = 344;
  50208. t['Kcommaaccent'] = 722;
  50209. t['Lacute'] = 611;
  50210. t['trademark'] = 980;
  50211. t['edotaccent'] = 444;
  50212. t['Igrave'] = 333;
  50213. t['Imacron'] = 333;
  50214. t['Lcaron'] = 611;
  50215. t['onehalf'] = 750;
  50216. t['lessequal'] = 549;
  50217. t['ocircumflex'] = 500;
  50218. t['ntilde'] = 500;
  50219. t['Uhungarumlaut'] = 722;
  50220. t['Eacute'] = 611;
  50221. t['emacron'] = 444;
  50222. t['gbreve'] = 500;
  50223. t['onequarter'] = 750;
  50224. t['Scaron'] = 556;
  50225. t['Scommaaccent'] = 556;
  50226. t['Ohungarumlaut'] = 722;
  50227. t['degree'] = 400;
  50228. t['ograve'] = 500;
  50229. t['Ccaron'] = 667;
  50230. t['ugrave'] = 500;
  50231. t['radical'] = 453;
  50232. t['Dcaron'] = 722;
  50233. t['rcommaaccent'] = 333;
  50234. t['Ntilde'] = 722;
  50235. t['otilde'] = 500;
  50236. t['Rcommaaccent'] = 667;
  50237. t['Lcommaaccent'] = 611;
  50238. t['Atilde'] = 722;
  50239. t['Aogonek'] = 722;
  50240. t['Aring'] = 722;
  50241. t['Otilde'] = 722;
  50242. t['zdotaccent'] = 444;
  50243. t['Ecaron'] = 611;
  50244. t['Iogonek'] = 333;
  50245. t['kcommaaccent'] = 500;
  50246. t['minus'] = 564;
  50247. t['Icircumflex'] = 333;
  50248. t['ncaron'] = 500;
  50249. t['tcommaaccent'] = 278;
  50250. t['logicalnot'] = 564;
  50251. t['odieresis'] = 500;
  50252. t['udieresis'] = 500;
  50253. t['notequal'] = 549;
  50254. t['gcommaaccent'] = 500;
  50255. t['eth'] = 500;
  50256. t['zcaron'] = 444;
  50257. t['ncommaaccent'] = 500;
  50258. t['onesuperior'] = 300;
  50259. t['imacron'] = 278;
  50260. t['Euro'] = 500;
  50261. });
  50262. t['Times-Bold'] = getLookupTableFactory(function (t) {
  50263. t['space'] = 250;
  50264. t['exclam'] = 333;
  50265. t['quotedbl'] = 555;
  50266. t['numbersign'] = 500;
  50267. t['dollar'] = 500;
  50268. t['percent'] = 1000;
  50269. t['ampersand'] = 833;
  50270. t['quoteright'] = 333;
  50271. t['parenleft'] = 333;
  50272. t['parenright'] = 333;
  50273. t['asterisk'] = 500;
  50274. t['plus'] = 570;
  50275. t['comma'] = 250;
  50276. t['hyphen'] = 333;
  50277. t['period'] = 250;
  50278. t['slash'] = 278;
  50279. t['zero'] = 500;
  50280. t['one'] = 500;
  50281. t['two'] = 500;
  50282. t['three'] = 500;
  50283. t['four'] = 500;
  50284. t['five'] = 500;
  50285. t['six'] = 500;
  50286. t['seven'] = 500;
  50287. t['eight'] = 500;
  50288. t['nine'] = 500;
  50289. t['colon'] = 333;
  50290. t['semicolon'] = 333;
  50291. t['less'] = 570;
  50292. t['equal'] = 570;
  50293. t['greater'] = 570;
  50294. t['question'] = 500;
  50295. t['at'] = 930;
  50296. t['A'] = 722;
  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'] = 778;
  50304. t['I'] = 389;
  50305. t['J'] = 500;
  50306. t['K'] = 778;
  50307. t['L'] = 667;
  50308. t['M'] = 944;
  50309. t['N'] = 722;
  50310. t['O'] = 778;
  50311. t['P'] = 611;
  50312. t['Q'] = 778;
  50313. t['R'] = 722;
  50314. t['S'] = 556;
  50315. t['T'] = 667;
  50316. t['U'] = 722;
  50317. t['V'] = 722;
  50318. t['W'] = 1000;
  50319. t['X'] = 722;
  50320. t['Y'] = 722;
  50321. t['Z'] = 667;
  50322. t['bracketleft'] = 333;
  50323. t['backslash'] = 278;
  50324. t['bracketright'] = 333;
  50325. t['asciicircum'] = 581;
  50326. t['underscore'] = 500;
  50327. t['quoteleft'] = 333;
  50328. t['a'] = 500;
  50329. t['b'] = 556;
  50330. t['c'] = 444;
  50331. t['d'] = 556;
  50332. t['e'] = 444;
  50333. t['f'] = 333;
  50334. t['g'] = 500;
  50335. t['h'] = 556;
  50336. t['i'] = 278;
  50337. t['j'] = 333;
  50338. t['k'] = 556;
  50339. t['l'] = 278;
  50340. t['m'] = 833;
  50341. t['n'] = 556;
  50342. t['o'] = 500;
  50343. t['p'] = 556;
  50344. t['q'] = 556;
  50345. t['r'] = 444;
  50346. t['s'] = 389;
  50347. t['t'] = 333;
  50348. t['u'] = 556;
  50349. t['v'] = 500;
  50350. t['w'] = 722;
  50351. t['x'] = 500;
  50352. t['y'] = 500;
  50353. t['z'] = 444;
  50354. t['braceleft'] = 394;
  50355. t['bar'] = 220;
  50356. t['braceright'] = 394;
  50357. t['asciitilde'] = 520;
  50358. t['exclamdown'] = 333;
  50359. t['cent'] = 500;
  50360. t['sterling'] = 500;
  50361. t['fraction'] = 167;
  50362. t['yen'] = 500;
  50363. t['florin'] = 500;
  50364. t['section'] = 500;
  50365. t['currency'] = 500;
  50366. t['quotesingle'] = 278;
  50367. t['quotedblleft'] = 500;
  50368. t['guillemotleft'] = 500;
  50369. t['guilsinglleft'] = 333;
  50370. t['guilsinglright'] = 333;
  50371. t['fi'] = 556;
  50372. t['fl'] = 556;
  50373. t['endash'] = 500;
  50374. t['dagger'] = 500;
  50375. t['daggerdbl'] = 500;
  50376. t['periodcentered'] = 250;
  50377. t['paragraph'] = 540;
  50378. t['bullet'] = 350;
  50379. t['quotesinglbase'] = 333;
  50380. t['quotedblbase'] = 500;
  50381. t['quotedblright'] = 500;
  50382. t['guillemotright'] = 500;
  50383. t['ellipsis'] = 1000;
  50384. t['perthousand'] = 1000;
  50385. t['questiondown'] = 500;
  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'] = 300;
  50402. t['Lslash'] = 667;
  50403. t['Oslash'] = 778;
  50404. t['OE'] = 1000;
  50405. t['ordmasculine'] = 330;
  50406. t['ae'] = 722;
  50407. t['dotlessi'] = 278;
  50408. t['lslash'] = 278;
  50409. t['oslash'] = 500;
  50410. t['oe'] = 722;
  50411. t['germandbls'] = 556;
  50412. t['Idieresis'] = 389;
  50413. t['eacute'] = 444;
  50414. t['abreve'] = 500;
  50415. t['uhungarumlaut'] = 556;
  50416. t['ecaron'] = 444;
  50417. t['Ydieresis'] = 722;
  50418. t['divide'] = 570;
  50419. t['Yacute'] = 722;
  50420. t['Acircumflex'] = 722;
  50421. t['aacute'] = 500;
  50422. t['Ucircumflex'] = 722;
  50423. t['yacute'] = 500;
  50424. t['scommaaccent'] = 389;
  50425. t['ecircumflex'] = 444;
  50426. t['Uring'] = 722;
  50427. t['Udieresis'] = 722;
  50428. t['aogonek'] = 500;
  50429. t['Uacute'] = 722;
  50430. t['uogonek'] = 556;
  50431. t['Edieresis'] = 667;
  50432. t['Dcroat'] = 722;
  50433. t['commaaccent'] = 250;
  50434. t['copyright'] = 747;
  50435. t['Emacron'] = 667;
  50436. t['ccaron'] = 444;
  50437. t['aring'] = 500;
  50438. t['Ncommaaccent'] = 722;
  50439. t['lacute'] = 278;
  50440. t['agrave'] = 500;
  50441. t['Tcommaaccent'] = 667;
  50442. t['Cacute'] = 722;
  50443. t['atilde'] = 500;
  50444. t['Edotaccent'] = 667;
  50445. t['scaron'] = 389;
  50446. t['scedilla'] = 389;
  50447. t['iacute'] = 278;
  50448. t['lozenge'] = 494;
  50449. t['Rcaron'] = 722;
  50450. t['Gcommaaccent'] = 778;
  50451. t['ucircumflex'] = 556;
  50452. t['acircumflex'] = 500;
  50453. t['Amacron'] = 722;
  50454. t['rcaron'] = 444;
  50455. t['ccedilla'] = 444;
  50456. t['Zdotaccent'] = 667;
  50457. t['Thorn'] = 611;
  50458. t['Omacron'] = 778;
  50459. t['Racute'] = 722;
  50460. t['Sacute'] = 556;
  50461. t['dcaron'] = 672;
  50462. t['Umacron'] = 722;
  50463. t['uring'] = 556;
  50464. t['threesuperior'] = 300;
  50465. t['Ograve'] = 778;
  50466. t['Agrave'] = 722;
  50467. t['Abreve'] = 722;
  50468. t['multiply'] = 570;
  50469. t['uacute'] = 556;
  50470. t['Tcaron'] = 667;
  50471. t['partialdiff'] = 494;
  50472. t['ydieresis'] = 500;
  50473. t['Nacute'] = 722;
  50474. t['icircumflex'] = 278;
  50475. t['Ecircumflex'] = 667;
  50476. t['adieresis'] = 500;
  50477. t['edieresis'] = 444;
  50478. t['cacute'] = 444;
  50479. t['nacute'] = 556;
  50480. t['umacron'] = 556;
  50481. t['Ncaron'] = 722;
  50482. t['Iacute'] = 389;
  50483. t['plusminus'] = 570;
  50484. t['brokenbar'] = 220;
  50485. t['registered'] = 747;
  50486. t['Gbreve'] = 778;
  50487. t['Idotaccent'] = 389;
  50488. t['summation'] = 600;
  50489. t['Egrave'] = 667;
  50490. t['racute'] = 444;
  50491. t['omacron'] = 500;
  50492. t['Zacute'] = 667;
  50493. t['Zcaron'] = 667;
  50494. t['greaterequal'] = 549;
  50495. t['Eth'] = 722;
  50496. t['Ccedilla'] = 722;
  50497. t['lcommaaccent'] = 278;
  50498. t['tcaron'] = 416;
  50499. t['eogonek'] = 444;
  50500. t['Uogonek'] = 722;
  50501. t['Aacute'] = 722;
  50502. t['Adieresis'] = 722;
  50503. t['egrave'] = 444;
  50504. t['zacute'] = 444;
  50505. t['iogonek'] = 278;
  50506. t['Oacute'] = 778;
  50507. t['oacute'] = 500;
  50508. t['amacron'] = 500;
  50509. t['sacute'] = 389;
  50510. t['idieresis'] = 278;
  50511. t['Ocircumflex'] = 778;
  50512. t['Ugrave'] = 722;
  50513. t['Delta'] = 612;
  50514. t['thorn'] = 556;
  50515. t['twosuperior'] = 300;
  50516. t['Odieresis'] = 778;
  50517. t['mu'] = 556;
  50518. t['igrave'] = 278;
  50519. t['ohungarumlaut'] = 500;
  50520. t['Eogonek'] = 667;
  50521. t['dcroat'] = 556;
  50522. t['threequarters'] = 750;
  50523. t['Scedilla'] = 556;
  50524. t['lcaron'] = 394;
  50525. t['Kcommaaccent'] = 778;
  50526. t['Lacute'] = 667;
  50527. t['trademark'] = 1000;
  50528. t['edotaccent'] = 444;
  50529. t['Igrave'] = 389;
  50530. t['Imacron'] = 389;
  50531. t['Lcaron'] = 667;
  50532. t['onehalf'] = 750;
  50533. t['lessequal'] = 549;
  50534. t['ocircumflex'] = 500;
  50535. t['ntilde'] = 556;
  50536. t['Uhungarumlaut'] = 722;
  50537. t['Eacute'] = 667;
  50538. t['emacron'] = 444;
  50539. t['gbreve'] = 500;
  50540. t['onequarter'] = 750;
  50541. t['Scaron'] = 556;
  50542. t['Scommaaccent'] = 556;
  50543. t['Ohungarumlaut'] = 778;
  50544. t['degree'] = 400;
  50545. t['ograve'] = 500;
  50546. t['Ccaron'] = 722;
  50547. t['ugrave'] = 556;
  50548. t['radical'] = 549;
  50549. t['Dcaron'] = 722;
  50550. t['rcommaaccent'] = 444;
  50551. t['Ntilde'] = 722;
  50552. t['otilde'] = 500;
  50553. t['Rcommaaccent'] = 722;
  50554. t['Lcommaaccent'] = 667;
  50555. t['Atilde'] = 722;
  50556. t['Aogonek'] = 722;
  50557. t['Aring'] = 722;
  50558. t['Otilde'] = 778;
  50559. t['zdotaccent'] = 444;
  50560. t['Ecaron'] = 667;
  50561. t['Iogonek'] = 389;
  50562. t['kcommaaccent'] = 556;
  50563. t['minus'] = 570;
  50564. t['Icircumflex'] = 389;
  50565. t['ncaron'] = 556;
  50566. t['tcommaaccent'] = 333;
  50567. t['logicalnot'] = 570;
  50568. t['odieresis'] = 500;
  50569. t['udieresis'] = 556;
  50570. t['notequal'] = 549;
  50571. t['gcommaaccent'] = 500;
  50572. t['eth'] = 500;
  50573. t['zcaron'] = 444;
  50574. t['ncommaaccent'] = 556;
  50575. t['onesuperior'] = 300;
  50576. t['imacron'] = 278;
  50577. t['Euro'] = 500;
  50578. });
  50579. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  50580. t['space'] = 250;
  50581. t['exclam'] = 389;
  50582. t['quotedbl'] = 555;
  50583. t['numbersign'] = 500;
  50584. t['dollar'] = 500;
  50585. t['percent'] = 833;
  50586. t['ampersand'] = 778;
  50587. t['quoteright'] = 333;
  50588. t['parenleft'] = 333;
  50589. t['parenright'] = 333;
  50590. t['asterisk'] = 500;
  50591. t['plus'] = 570;
  50592. t['comma'] = 250;
  50593. t['hyphen'] = 333;
  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'] = 333;
  50607. t['semicolon'] = 333;
  50608. t['less'] = 570;
  50609. t['equal'] = 570;
  50610. t['greater'] = 570;
  50611. t['question'] = 500;
  50612. t['at'] = 832;
  50613. t['A'] = 667;
  50614. t['B'] = 667;
  50615. t['C'] = 667;
  50616. t['D'] = 722;
  50617. t['E'] = 667;
  50618. t['F'] = 667;
  50619. t['G'] = 722;
  50620. t['H'] = 778;
  50621. t['I'] = 389;
  50622. t['J'] = 500;
  50623. t['K'] = 667;
  50624. t['L'] = 611;
  50625. t['M'] = 889;
  50626. t['N'] = 722;
  50627. t['O'] = 722;
  50628. t['P'] = 611;
  50629. t['Q'] = 722;
  50630. t['R'] = 667;
  50631. t['S'] = 556;
  50632. t['T'] = 611;
  50633. t['U'] = 722;
  50634. t['V'] = 667;
  50635. t['W'] = 889;
  50636. t['X'] = 667;
  50637. t['Y'] = 611;
  50638. t['Z'] = 611;
  50639. t['bracketleft'] = 333;
  50640. t['backslash'] = 278;
  50641. t['bracketright'] = 333;
  50642. t['asciicircum'] = 570;
  50643. t['underscore'] = 500;
  50644. t['quoteleft'] = 333;
  50645. t['a'] = 500;
  50646. t['b'] = 500;
  50647. t['c'] = 444;
  50648. t['d'] = 500;
  50649. t['e'] = 444;
  50650. t['f'] = 333;
  50651. t['g'] = 500;
  50652. t['h'] = 556;
  50653. t['i'] = 278;
  50654. t['j'] = 278;
  50655. t['k'] = 500;
  50656. t['l'] = 278;
  50657. t['m'] = 778;
  50658. t['n'] = 556;
  50659. t['o'] = 500;
  50660. t['p'] = 500;
  50661. t['q'] = 500;
  50662. t['r'] = 389;
  50663. t['s'] = 389;
  50664. t['t'] = 278;
  50665. t['u'] = 556;
  50666. t['v'] = 444;
  50667. t['w'] = 667;
  50668. t['x'] = 500;
  50669. t['y'] = 444;
  50670. t['z'] = 389;
  50671. t['braceleft'] = 348;
  50672. t['bar'] = 220;
  50673. t['braceright'] = 348;
  50674. t['asciitilde'] = 570;
  50675. t['exclamdown'] = 389;
  50676. t['cent'] = 500;
  50677. t['sterling'] = 500;
  50678. t['fraction'] = 167;
  50679. t['yen'] = 500;
  50680. t['florin'] = 500;
  50681. t['section'] = 500;
  50682. t['currency'] = 500;
  50683. t['quotesingle'] = 278;
  50684. t['quotedblleft'] = 500;
  50685. t['guillemotleft'] = 500;
  50686. t['guilsinglleft'] = 333;
  50687. t['guilsinglright'] = 333;
  50688. t['fi'] = 556;
  50689. t['fl'] = 556;
  50690. t['endash'] = 500;
  50691. t['dagger'] = 500;
  50692. t['daggerdbl'] = 500;
  50693. t['periodcentered'] = 250;
  50694. t['paragraph'] = 500;
  50695. t['bullet'] = 350;
  50696. t['quotesinglbase'] = 333;
  50697. t['quotedblbase'] = 500;
  50698. t['quotedblright'] = 500;
  50699. t['guillemotright'] = 500;
  50700. t['ellipsis'] = 1000;
  50701. t['perthousand'] = 1000;
  50702. t['questiondown'] = 500;
  50703. t['grave'] = 333;
  50704. t['acute'] = 333;
  50705. t['circumflex'] = 333;
  50706. t['tilde'] = 333;
  50707. t['macron'] = 333;
  50708. t['breve'] = 333;
  50709. t['dotaccent'] = 333;
  50710. t['dieresis'] = 333;
  50711. t['ring'] = 333;
  50712. t['cedilla'] = 333;
  50713. t['hungarumlaut'] = 333;
  50714. t['ogonek'] = 333;
  50715. t['caron'] = 333;
  50716. t['emdash'] = 1000;
  50717. t['AE'] = 944;
  50718. t['ordfeminine'] = 266;
  50719. t['Lslash'] = 611;
  50720. t['Oslash'] = 722;
  50721. t['OE'] = 944;
  50722. t['ordmasculine'] = 300;
  50723. t['ae'] = 722;
  50724. t['dotlessi'] = 278;
  50725. t['lslash'] = 278;
  50726. t['oslash'] = 500;
  50727. t['oe'] = 722;
  50728. t['germandbls'] = 500;
  50729. t['Idieresis'] = 389;
  50730. t['eacute'] = 444;
  50731. t['abreve'] = 500;
  50732. t['uhungarumlaut'] = 556;
  50733. t['ecaron'] = 444;
  50734. t['Ydieresis'] = 611;
  50735. t['divide'] = 570;
  50736. t['Yacute'] = 611;
  50737. t['Acircumflex'] = 667;
  50738. t['aacute'] = 500;
  50739. t['Ucircumflex'] = 722;
  50740. t['yacute'] = 444;
  50741. t['scommaaccent'] = 389;
  50742. t['ecircumflex'] = 444;
  50743. t['Uring'] = 722;
  50744. t['Udieresis'] = 722;
  50745. t['aogonek'] = 500;
  50746. t['Uacute'] = 722;
  50747. t['uogonek'] = 556;
  50748. t['Edieresis'] = 667;
  50749. t['Dcroat'] = 722;
  50750. t['commaaccent'] = 250;
  50751. t['copyright'] = 747;
  50752. t['Emacron'] = 667;
  50753. t['ccaron'] = 444;
  50754. t['aring'] = 500;
  50755. t['Ncommaaccent'] = 722;
  50756. t['lacute'] = 278;
  50757. t['agrave'] = 500;
  50758. t['Tcommaaccent'] = 611;
  50759. t['Cacute'] = 667;
  50760. t['atilde'] = 500;
  50761. t['Edotaccent'] = 667;
  50762. t['scaron'] = 389;
  50763. t['scedilla'] = 389;
  50764. t['iacute'] = 278;
  50765. t['lozenge'] = 494;
  50766. t['Rcaron'] = 667;
  50767. t['Gcommaaccent'] = 722;
  50768. t['ucircumflex'] = 556;
  50769. t['acircumflex'] = 500;
  50770. t['Amacron'] = 667;
  50771. t['rcaron'] = 389;
  50772. t['ccedilla'] = 444;
  50773. t['Zdotaccent'] = 611;
  50774. t['Thorn'] = 611;
  50775. t['Omacron'] = 722;
  50776. t['Racute'] = 667;
  50777. t['Sacute'] = 556;
  50778. t['dcaron'] = 608;
  50779. t['Umacron'] = 722;
  50780. t['uring'] = 556;
  50781. t['threesuperior'] = 300;
  50782. t['Ograve'] = 722;
  50783. t['Agrave'] = 667;
  50784. t['Abreve'] = 667;
  50785. t['multiply'] = 570;
  50786. t['uacute'] = 556;
  50787. t['Tcaron'] = 611;
  50788. t['partialdiff'] = 494;
  50789. t['ydieresis'] = 444;
  50790. t['Nacute'] = 722;
  50791. t['icircumflex'] = 278;
  50792. t['Ecircumflex'] = 667;
  50793. t['adieresis'] = 500;
  50794. t['edieresis'] = 444;
  50795. t['cacute'] = 444;
  50796. t['nacute'] = 556;
  50797. t['umacron'] = 556;
  50798. t['Ncaron'] = 722;
  50799. t['Iacute'] = 389;
  50800. t['plusminus'] = 570;
  50801. t['brokenbar'] = 220;
  50802. t['registered'] = 747;
  50803. t['Gbreve'] = 722;
  50804. t['Idotaccent'] = 389;
  50805. t['summation'] = 600;
  50806. t['Egrave'] = 667;
  50807. t['racute'] = 389;
  50808. t['omacron'] = 500;
  50809. t['Zacute'] = 611;
  50810. t['Zcaron'] = 611;
  50811. t['greaterequal'] = 549;
  50812. t['Eth'] = 722;
  50813. t['Ccedilla'] = 667;
  50814. t['lcommaaccent'] = 278;
  50815. t['tcaron'] = 366;
  50816. t['eogonek'] = 444;
  50817. t['Uogonek'] = 722;
  50818. t['Aacute'] = 667;
  50819. t['Adieresis'] = 667;
  50820. t['egrave'] = 444;
  50821. t['zacute'] = 389;
  50822. t['iogonek'] = 278;
  50823. t['Oacute'] = 722;
  50824. t['oacute'] = 500;
  50825. t['amacron'] = 500;
  50826. t['sacute'] = 389;
  50827. t['idieresis'] = 278;
  50828. t['Ocircumflex'] = 722;
  50829. t['Ugrave'] = 722;
  50830. t['Delta'] = 612;
  50831. t['thorn'] = 500;
  50832. t['twosuperior'] = 300;
  50833. t['Odieresis'] = 722;
  50834. t['mu'] = 576;
  50835. t['igrave'] = 278;
  50836. t['ohungarumlaut'] = 500;
  50837. t['Eogonek'] = 667;
  50838. t['dcroat'] = 500;
  50839. t['threequarters'] = 750;
  50840. t['Scedilla'] = 556;
  50841. t['lcaron'] = 382;
  50842. t['Kcommaaccent'] = 667;
  50843. t['Lacute'] = 611;
  50844. t['trademark'] = 1000;
  50845. t['edotaccent'] = 444;
  50846. t['Igrave'] = 389;
  50847. t['Imacron'] = 389;
  50848. t['Lcaron'] = 611;
  50849. t['onehalf'] = 750;
  50850. t['lessequal'] = 549;
  50851. t['ocircumflex'] = 500;
  50852. t['ntilde'] = 556;
  50853. t['Uhungarumlaut'] = 722;
  50854. t['Eacute'] = 667;
  50855. t['emacron'] = 444;
  50856. t['gbreve'] = 500;
  50857. t['onequarter'] = 750;
  50858. t['Scaron'] = 556;
  50859. t['Scommaaccent'] = 556;
  50860. t['Ohungarumlaut'] = 722;
  50861. t['degree'] = 400;
  50862. t['ograve'] = 500;
  50863. t['Ccaron'] = 667;
  50864. t['ugrave'] = 556;
  50865. t['radical'] = 549;
  50866. t['Dcaron'] = 722;
  50867. t['rcommaaccent'] = 389;
  50868. t['Ntilde'] = 722;
  50869. t['otilde'] = 500;
  50870. t['Rcommaaccent'] = 667;
  50871. t['Lcommaaccent'] = 611;
  50872. t['Atilde'] = 667;
  50873. t['Aogonek'] = 667;
  50874. t['Aring'] = 667;
  50875. t['Otilde'] = 722;
  50876. t['zdotaccent'] = 389;
  50877. t['Ecaron'] = 667;
  50878. t['Iogonek'] = 389;
  50879. t['kcommaaccent'] = 500;
  50880. t['minus'] = 606;
  50881. t['Icircumflex'] = 389;
  50882. t['ncaron'] = 556;
  50883. t['tcommaaccent'] = 278;
  50884. t['logicalnot'] = 606;
  50885. t['odieresis'] = 500;
  50886. t['udieresis'] = 556;
  50887. t['notequal'] = 549;
  50888. t['gcommaaccent'] = 500;
  50889. t['eth'] = 500;
  50890. t['zcaron'] = 389;
  50891. t['ncommaaccent'] = 556;
  50892. t['onesuperior'] = 300;
  50893. t['imacron'] = 278;
  50894. t['Euro'] = 500;
  50895. });
  50896. t['Times-Italic'] = getLookupTableFactory(function (t) {
  50897. t['space'] = 250;
  50898. t['exclam'] = 333;
  50899. t['quotedbl'] = 420;
  50900. t['numbersign'] = 500;
  50901. t['dollar'] = 500;
  50902. t['percent'] = 833;
  50903. t['ampersand'] = 778;
  50904. t['quoteright'] = 333;
  50905. t['parenleft'] = 333;
  50906. t['parenright'] = 333;
  50907. t['asterisk'] = 500;
  50908. t['plus'] = 675;
  50909. t['comma'] = 250;
  50910. t['hyphen'] = 333;
  50911. t['period'] = 250;
  50912. t['slash'] = 278;
  50913. t['zero'] = 500;
  50914. t['one'] = 500;
  50915. t['two'] = 500;
  50916. t['three'] = 500;
  50917. t['four'] = 500;
  50918. t['five'] = 500;
  50919. t['six'] = 500;
  50920. t['seven'] = 500;
  50921. t['eight'] = 500;
  50922. t['nine'] = 500;
  50923. t['colon'] = 333;
  50924. t['semicolon'] = 333;
  50925. t['less'] = 675;
  50926. t['equal'] = 675;
  50927. t['greater'] = 675;
  50928. t['question'] = 500;
  50929. t['at'] = 920;
  50930. t['A'] = 611;
  50931. t['B'] = 611;
  50932. t['C'] = 667;
  50933. t['D'] = 722;
  50934. t['E'] = 611;
  50935. t['F'] = 611;
  50936. t['G'] = 722;
  50937. t['H'] = 722;
  50938. t['I'] = 333;
  50939. t['J'] = 444;
  50940. t['K'] = 667;
  50941. t['L'] = 556;
  50942. t['M'] = 833;
  50943. t['N'] = 667;
  50944. t['O'] = 722;
  50945. t['P'] = 611;
  50946. t['Q'] = 722;
  50947. t['R'] = 611;
  50948. t['S'] = 500;
  50949. t['T'] = 556;
  50950. t['U'] = 722;
  50951. t['V'] = 611;
  50952. t['W'] = 833;
  50953. t['X'] = 611;
  50954. t['Y'] = 556;
  50955. t['Z'] = 556;
  50956. t['bracketleft'] = 389;
  50957. t['backslash'] = 278;
  50958. t['bracketright'] = 389;
  50959. t['asciicircum'] = 422;
  50960. t['underscore'] = 500;
  50961. t['quoteleft'] = 333;
  50962. t['a'] = 500;
  50963. t['b'] = 500;
  50964. t['c'] = 444;
  50965. t['d'] = 500;
  50966. t['e'] = 444;
  50967. t['f'] = 278;
  50968. t['g'] = 500;
  50969. t['h'] = 500;
  50970. t['i'] = 278;
  50971. t['j'] = 278;
  50972. t['k'] = 444;
  50973. t['l'] = 278;
  50974. t['m'] = 722;
  50975. t['n'] = 500;
  50976. t['o'] = 500;
  50977. t['p'] = 500;
  50978. t['q'] = 500;
  50979. t['r'] = 389;
  50980. t['s'] = 389;
  50981. t['t'] = 278;
  50982. t['u'] = 500;
  50983. t['v'] = 444;
  50984. t['w'] = 667;
  50985. t['x'] = 444;
  50986. t['y'] = 444;
  50987. t['z'] = 389;
  50988. t['braceleft'] = 400;
  50989. t['bar'] = 275;
  50990. t['braceright'] = 400;
  50991. t['asciitilde'] = 541;
  50992. t['exclamdown'] = 389;
  50993. t['cent'] = 500;
  50994. t['sterling'] = 500;
  50995. t['fraction'] = 167;
  50996. t['yen'] = 500;
  50997. t['florin'] = 500;
  50998. t['section'] = 500;
  50999. t['currency'] = 500;
  51000. t['quotesingle'] = 214;
  51001. t['quotedblleft'] = 556;
  51002. t['guillemotleft'] = 500;
  51003. t['guilsinglleft'] = 333;
  51004. t['guilsinglright'] = 333;
  51005. t['fi'] = 500;
  51006. t['fl'] = 500;
  51007. t['endash'] = 500;
  51008. t['dagger'] = 500;
  51009. t['daggerdbl'] = 500;
  51010. t['periodcentered'] = 250;
  51011. t['paragraph'] = 523;
  51012. t['bullet'] = 350;
  51013. t['quotesinglbase'] = 333;
  51014. t['quotedblbase'] = 556;
  51015. t['quotedblright'] = 556;
  51016. t['guillemotright'] = 500;
  51017. t['ellipsis'] = 889;
  51018. t['perthousand'] = 1000;
  51019. t['questiondown'] = 500;
  51020. t['grave'] = 333;
  51021. t['acute'] = 333;
  51022. t['circumflex'] = 333;
  51023. t['tilde'] = 333;
  51024. t['macron'] = 333;
  51025. t['breve'] = 333;
  51026. t['dotaccent'] = 333;
  51027. t['dieresis'] = 333;
  51028. t['ring'] = 333;
  51029. t['cedilla'] = 333;
  51030. t['hungarumlaut'] = 333;
  51031. t['ogonek'] = 333;
  51032. t['caron'] = 333;
  51033. t['emdash'] = 889;
  51034. t['AE'] = 889;
  51035. t['ordfeminine'] = 276;
  51036. t['Lslash'] = 556;
  51037. t['Oslash'] = 722;
  51038. t['OE'] = 944;
  51039. t['ordmasculine'] = 310;
  51040. t['ae'] = 667;
  51041. t['dotlessi'] = 278;
  51042. t['lslash'] = 278;
  51043. t['oslash'] = 500;
  51044. t['oe'] = 667;
  51045. t['germandbls'] = 500;
  51046. t['Idieresis'] = 333;
  51047. t['eacute'] = 444;
  51048. t['abreve'] = 500;
  51049. t['uhungarumlaut'] = 500;
  51050. t['ecaron'] = 444;
  51051. t['Ydieresis'] = 556;
  51052. t['divide'] = 675;
  51053. t['Yacute'] = 556;
  51054. t['Acircumflex'] = 611;
  51055. t['aacute'] = 500;
  51056. t['Ucircumflex'] = 722;
  51057. t['yacute'] = 444;
  51058. t['scommaaccent'] = 389;
  51059. t['ecircumflex'] = 444;
  51060. t['Uring'] = 722;
  51061. t['Udieresis'] = 722;
  51062. t['aogonek'] = 500;
  51063. t['Uacute'] = 722;
  51064. t['uogonek'] = 500;
  51065. t['Edieresis'] = 611;
  51066. t['Dcroat'] = 722;
  51067. t['commaaccent'] = 250;
  51068. t['copyright'] = 760;
  51069. t['Emacron'] = 611;
  51070. t['ccaron'] = 444;
  51071. t['aring'] = 500;
  51072. t['Ncommaaccent'] = 667;
  51073. t['lacute'] = 278;
  51074. t['agrave'] = 500;
  51075. t['Tcommaaccent'] = 556;
  51076. t['Cacute'] = 667;
  51077. t['atilde'] = 500;
  51078. t['Edotaccent'] = 611;
  51079. t['scaron'] = 389;
  51080. t['scedilla'] = 389;
  51081. t['iacute'] = 278;
  51082. t['lozenge'] = 471;
  51083. t['Rcaron'] = 611;
  51084. t['Gcommaaccent'] = 722;
  51085. t['ucircumflex'] = 500;
  51086. t['acircumflex'] = 500;
  51087. t['Amacron'] = 611;
  51088. t['rcaron'] = 389;
  51089. t['ccedilla'] = 444;
  51090. t['Zdotaccent'] = 556;
  51091. t['Thorn'] = 611;
  51092. t['Omacron'] = 722;
  51093. t['Racute'] = 611;
  51094. t['Sacute'] = 500;
  51095. t['dcaron'] = 544;
  51096. t['Umacron'] = 722;
  51097. t['uring'] = 500;
  51098. t['threesuperior'] = 300;
  51099. t['Ograve'] = 722;
  51100. t['Agrave'] = 611;
  51101. t['Abreve'] = 611;
  51102. t['multiply'] = 675;
  51103. t['uacute'] = 500;
  51104. t['Tcaron'] = 556;
  51105. t['partialdiff'] = 476;
  51106. t['ydieresis'] = 444;
  51107. t['Nacute'] = 667;
  51108. t['icircumflex'] = 278;
  51109. t['Ecircumflex'] = 611;
  51110. t['adieresis'] = 500;
  51111. t['edieresis'] = 444;
  51112. t['cacute'] = 444;
  51113. t['nacute'] = 500;
  51114. t['umacron'] = 500;
  51115. t['Ncaron'] = 667;
  51116. t['Iacute'] = 333;
  51117. t['plusminus'] = 675;
  51118. t['brokenbar'] = 275;
  51119. t['registered'] = 760;
  51120. t['Gbreve'] = 722;
  51121. t['Idotaccent'] = 333;
  51122. t['summation'] = 600;
  51123. t['Egrave'] = 611;
  51124. t['racute'] = 389;
  51125. t['omacron'] = 500;
  51126. t['Zacute'] = 556;
  51127. t['Zcaron'] = 556;
  51128. t['greaterequal'] = 549;
  51129. t['Eth'] = 722;
  51130. t['Ccedilla'] = 667;
  51131. t['lcommaaccent'] = 278;
  51132. t['tcaron'] = 300;
  51133. t['eogonek'] = 444;
  51134. t['Uogonek'] = 722;
  51135. t['Aacute'] = 611;
  51136. t['Adieresis'] = 611;
  51137. t['egrave'] = 444;
  51138. t['zacute'] = 389;
  51139. t['iogonek'] = 278;
  51140. t['Oacute'] = 722;
  51141. t['oacute'] = 500;
  51142. t['amacron'] = 500;
  51143. t['sacute'] = 389;
  51144. t['idieresis'] = 278;
  51145. t['Ocircumflex'] = 722;
  51146. t['Ugrave'] = 722;
  51147. t['Delta'] = 612;
  51148. t['thorn'] = 500;
  51149. t['twosuperior'] = 300;
  51150. t['Odieresis'] = 722;
  51151. t['mu'] = 500;
  51152. t['igrave'] = 278;
  51153. t['ohungarumlaut'] = 500;
  51154. t['Eogonek'] = 611;
  51155. t['dcroat'] = 500;
  51156. t['threequarters'] = 750;
  51157. t['Scedilla'] = 500;
  51158. t['lcaron'] = 300;
  51159. t['Kcommaaccent'] = 667;
  51160. t['Lacute'] = 556;
  51161. t['trademark'] = 980;
  51162. t['edotaccent'] = 444;
  51163. t['Igrave'] = 333;
  51164. t['Imacron'] = 333;
  51165. t['Lcaron'] = 611;
  51166. t['onehalf'] = 750;
  51167. t['lessequal'] = 549;
  51168. t['ocircumflex'] = 500;
  51169. t['ntilde'] = 500;
  51170. t['Uhungarumlaut'] = 722;
  51171. t['Eacute'] = 611;
  51172. t['emacron'] = 444;
  51173. t['gbreve'] = 500;
  51174. t['onequarter'] = 750;
  51175. t['Scaron'] = 500;
  51176. t['Scommaaccent'] = 500;
  51177. t['Ohungarumlaut'] = 722;
  51178. t['degree'] = 400;
  51179. t['ograve'] = 500;
  51180. t['Ccaron'] = 667;
  51181. t['ugrave'] = 500;
  51182. t['radical'] = 453;
  51183. t['Dcaron'] = 722;
  51184. t['rcommaaccent'] = 389;
  51185. t['Ntilde'] = 667;
  51186. t['otilde'] = 500;
  51187. t['Rcommaaccent'] = 611;
  51188. t['Lcommaaccent'] = 556;
  51189. t['Atilde'] = 611;
  51190. t['Aogonek'] = 611;
  51191. t['Aring'] = 611;
  51192. t['Otilde'] = 722;
  51193. t['zdotaccent'] = 389;
  51194. t['Ecaron'] = 611;
  51195. t['Iogonek'] = 333;
  51196. t['kcommaaccent'] = 444;
  51197. t['minus'] = 675;
  51198. t['Icircumflex'] = 333;
  51199. t['ncaron'] = 500;
  51200. t['tcommaaccent'] = 278;
  51201. t['logicalnot'] = 675;
  51202. t['odieresis'] = 500;
  51203. t['udieresis'] = 500;
  51204. t['notequal'] = 549;
  51205. t['gcommaaccent'] = 500;
  51206. t['eth'] = 500;
  51207. t['zcaron'] = 389;
  51208. t['ncommaaccent'] = 500;
  51209. t['onesuperior'] = 300;
  51210. t['imacron'] = 278;
  51211. t['Euro'] = 500;
  51212. });
  51213. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51214. t['space'] = 278;
  51215. t['a1'] = 974;
  51216. t['a2'] = 961;
  51217. t['a202'] = 974;
  51218. t['a3'] = 980;
  51219. t['a4'] = 719;
  51220. t['a5'] = 789;
  51221. t['a119'] = 790;
  51222. t['a118'] = 791;
  51223. t['a117'] = 690;
  51224. t['a11'] = 960;
  51225. t['a12'] = 939;
  51226. t['a13'] = 549;
  51227. t['a14'] = 855;
  51228. t['a15'] = 911;
  51229. t['a16'] = 933;
  51230. t['a105'] = 911;
  51231. t['a17'] = 945;
  51232. t['a18'] = 974;
  51233. t['a19'] = 755;
  51234. t['a20'] = 846;
  51235. t['a21'] = 762;
  51236. t['a22'] = 761;
  51237. t['a23'] = 571;
  51238. t['a24'] = 677;
  51239. t['a25'] = 763;
  51240. t['a26'] = 760;
  51241. t['a27'] = 759;
  51242. t['a28'] = 754;
  51243. t['a6'] = 494;
  51244. t['a7'] = 552;
  51245. t['a8'] = 537;
  51246. t['a9'] = 577;
  51247. t['a10'] = 692;
  51248. t['a29'] = 786;
  51249. t['a30'] = 788;
  51250. t['a31'] = 788;
  51251. t['a32'] = 790;
  51252. t['a33'] = 793;
  51253. t['a34'] = 794;
  51254. t['a35'] = 816;
  51255. t['a36'] = 823;
  51256. t['a37'] = 789;
  51257. t['a38'] = 841;
  51258. t['a39'] = 823;
  51259. t['a40'] = 833;
  51260. t['a41'] = 816;
  51261. t['a42'] = 831;
  51262. t['a43'] = 923;
  51263. t['a44'] = 744;
  51264. t['a45'] = 723;
  51265. t['a46'] = 749;
  51266. t['a47'] = 790;
  51267. t['a48'] = 792;
  51268. t['a49'] = 695;
  51269. t['a50'] = 776;
  51270. t['a51'] = 768;
  51271. t['a52'] = 792;
  51272. t['a53'] = 759;
  51273. t['a54'] = 707;
  51274. t['a55'] = 708;
  51275. t['a56'] = 682;
  51276. t['a57'] = 701;
  51277. t['a58'] = 826;
  51278. t['a59'] = 815;
  51279. t['a60'] = 789;
  51280. t['a61'] = 789;
  51281. t['a62'] = 707;
  51282. t['a63'] = 687;
  51283. t['a64'] = 696;
  51284. t['a65'] = 689;
  51285. t['a66'] = 786;
  51286. t['a67'] = 787;
  51287. t['a68'] = 713;
  51288. t['a69'] = 791;
  51289. t['a70'] = 785;
  51290. t['a71'] = 791;
  51291. t['a72'] = 873;
  51292. t['a73'] = 761;
  51293. t['a74'] = 762;
  51294. t['a203'] = 762;
  51295. t['a75'] = 759;
  51296. t['a204'] = 759;
  51297. t['a76'] = 892;
  51298. t['a77'] = 892;
  51299. t['a78'] = 788;
  51300. t['a79'] = 784;
  51301. t['a81'] = 438;
  51302. t['a82'] = 138;
  51303. t['a83'] = 277;
  51304. t['a84'] = 415;
  51305. t['a97'] = 392;
  51306. t['a98'] = 392;
  51307. t['a99'] = 668;
  51308. t['a100'] = 668;
  51309. t['a89'] = 390;
  51310. t['a90'] = 390;
  51311. t['a93'] = 317;
  51312. t['a94'] = 317;
  51313. t['a91'] = 276;
  51314. t['a92'] = 276;
  51315. t['a205'] = 509;
  51316. t['a85'] = 509;
  51317. t['a206'] = 410;
  51318. t['a86'] = 410;
  51319. t['a87'] = 234;
  51320. t['a88'] = 234;
  51321. t['a95'] = 334;
  51322. t['a96'] = 334;
  51323. t['a101'] = 732;
  51324. t['a102'] = 544;
  51325. t['a103'] = 544;
  51326. t['a104'] = 910;
  51327. t['a106'] = 667;
  51328. t['a107'] = 760;
  51329. t['a108'] = 760;
  51330. t['a112'] = 776;
  51331. t['a111'] = 595;
  51332. t['a110'] = 694;
  51333. t['a109'] = 626;
  51334. t['a120'] = 788;
  51335. t['a121'] = 788;
  51336. t['a122'] = 788;
  51337. t['a123'] = 788;
  51338. t['a124'] = 788;
  51339. t['a125'] = 788;
  51340. t['a126'] = 788;
  51341. t['a127'] = 788;
  51342. t['a128'] = 788;
  51343. t['a129'] = 788;
  51344. t['a130'] = 788;
  51345. t['a131'] = 788;
  51346. t['a132'] = 788;
  51347. t['a133'] = 788;
  51348. t['a134'] = 788;
  51349. t['a135'] = 788;
  51350. t['a136'] = 788;
  51351. t['a137'] = 788;
  51352. t['a138'] = 788;
  51353. t['a139'] = 788;
  51354. t['a140'] = 788;
  51355. t['a141'] = 788;
  51356. t['a142'] = 788;
  51357. t['a143'] = 788;
  51358. t['a144'] = 788;
  51359. t['a145'] = 788;
  51360. t['a146'] = 788;
  51361. t['a147'] = 788;
  51362. t['a148'] = 788;
  51363. t['a149'] = 788;
  51364. t['a150'] = 788;
  51365. t['a151'] = 788;
  51366. t['a152'] = 788;
  51367. t['a153'] = 788;
  51368. t['a154'] = 788;
  51369. t['a155'] = 788;
  51370. t['a156'] = 788;
  51371. t['a157'] = 788;
  51372. t['a158'] = 788;
  51373. t['a159'] = 788;
  51374. t['a160'] = 894;
  51375. t['a161'] = 838;
  51376. t['a163'] = 1016;
  51377. t['a164'] = 458;
  51378. t['a196'] = 748;
  51379. t['a165'] = 924;
  51380. t['a192'] = 748;
  51381. t['a166'] = 918;
  51382. t['a167'] = 927;
  51383. t['a168'] = 928;
  51384. t['a169'] = 928;
  51385. t['a170'] = 834;
  51386. t['a171'] = 873;
  51387. t['a172'] = 828;
  51388. t['a173'] = 924;
  51389. t['a162'] = 924;
  51390. t['a174'] = 917;
  51391. t['a175'] = 930;
  51392. t['a176'] = 931;
  51393. t['a177'] = 463;
  51394. t['a178'] = 883;
  51395. t['a179'] = 836;
  51396. t['a193'] = 836;
  51397. t['a180'] = 867;
  51398. t['a199'] = 867;
  51399. t['a181'] = 696;
  51400. t['a200'] = 696;
  51401. t['a182'] = 874;
  51402. t['a201'] = 874;
  51403. t['a183'] = 760;
  51404. t['a184'] = 946;
  51405. t['a197'] = 771;
  51406. t['a185'] = 865;
  51407. t['a194'] = 771;
  51408. t['a198'] = 888;
  51409. t['a186'] = 967;
  51410. t['a195'] = 888;
  51411. t['a187'] = 831;
  51412. t['a188'] = 873;
  51413. t['a189'] = 927;
  51414. t['a190'] = 970;
  51415. t['a191'] = 918;
  51416. });
  51417. });
  51418. exports.getMetrics = getMetrics;
  51419. /***/ }),
  51420. /* 38 */
  51421. /***/ (function(module, exports, __w_pdfjs_require__) {
  51422. "use strict";
  51423. var sharedUtil = __w_pdfjs_require__(0);
  51424. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  51425. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  51426. var MASK_HIGH = 0xffff0000;
  51427. var MASK_LOW = 0xffff;
  51428. function MurmurHash3_64(seed) {
  51429. var SEED = 0xc3d2e1f0;
  51430. this.h1 = seed ? seed & 0xffffffff : SEED;
  51431. this.h2 = seed ? seed & 0xffffffff : SEED;
  51432. }
  51433. var alwaysUseUint32ArrayView = false;
  51434. try {
  51435. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  51436. } catch (e) {
  51437. alwaysUseUint32ArrayView = true;
  51438. }
  51439. MurmurHash3_64.prototype = {
  51440. update: function MurmurHash3_64_update(input) {
  51441. var useUint32ArrayView = alwaysUseUint32ArrayView;
  51442. var i;
  51443. if (typeof input === 'string') {
  51444. var data = new Uint8Array(input.length * 2);
  51445. var length = 0;
  51446. for (i = 0; i < input.length; i++) {
  51447. var code = input.charCodeAt(i);
  51448. if (code <= 0xff) {
  51449. data[length++] = code;
  51450. } else {
  51451. data[length++] = code >>> 8;
  51452. data[length++] = code & 0xff;
  51453. }
  51454. }
  51455. } else if (input instanceof Uint8Array) {
  51456. data = input;
  51457. length = data.length;
  51458. } else if (typeof input === 'object' && 'length' in input) {
  51459. data = input;
  51460. length = data.length;
  51461. useUint32ArrayView = true;
  51462. } else {
  51463. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  51464. }
  51465. var blockCounts = length >> 2;
  51466. var tailLength = length - blockCounts * 4;
  51467. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  51468. var k1 = 0;
  51469. var k2 = 0;
  51470. var h1 = this.h1;
  51471. var h2 = this.h2;
  51472. var C1 = 0xcc9e2d51;
  51473. var C2 = 0x1b873593;
  51474. var C1_LOW = C1 & MASK_LOW;
  51475. var C2_LOW = C2 & MASK_LOW;
  51476. for (i = 0; i < blockCounts; i++) {
  51477. if (i & 1) {
  51478. k1 = dataUint32[i];
  51479. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51480. k1 = k1 << 15 | k1 >>> 17;
  51481. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51482. h1 ^= k1;
  51483. h1 = h1 << 13 | h1 >>> 19;
  51484. h1 = h1 * 5 + 0xe6546b64;
  51485. } else {
  51486. k2 = dataUint32[i];
  51487. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  51488. k2 = k2 << 15 | k2 >>> 17;
  51489. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  51490. h2 ^= k2;
  51491. h2 = h2 << 13 | h2 >>> 19;
  51492. h2 = h2 * 5 + 0xe6546b64;
  51493. }
  51494. }
  51495. k1 = 0;
  51496. switch (tailLength) {
  51497. case 3:
  51498. k1 ^= data[blockCounts * 4 + 2] << 16;
  51499. case 2:
  51500. k1 ^= data[blockCounts * 4 + 1] << 8;
  51501. case 1:
  51502. k1 ^= data[blockCounts * 4];
  51503. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51504. k1 = k1 << 15 | k1 >>> 17;
  51505. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51506. if (blockCounts & 1) {
  51507. h1 ^= k1;
  51508. } else {
  51509. h2 ^= k1;
  51510. }
  51511. }
  51512. this.h1 = h1;
  51513. this.h2 = h2;
  51514. return this;
  51515. },
  51516. hexdigest: function MurmurHash3_64_hexdigest() {
  51517. var h1 = this.h1;
  51518. var h2 = this.h2;
  51519. h1 ^= h2 >>> 1;
  51520. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  51521. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  51522. h1 ^= h2 >>> 1;
  51523. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  51524. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  51525. h1 ^= h2 >>> 1;
  51526. for (var i = 0, arr = [
  51527. h1,
  51528. h2
  51529. ], str = ''; i < arr.length; i++) {
  51530. var hex = (arr[i] >>> 0).toString(16);
  51531. while (hex.length < 8) {
  51532. hex = '0' + hex;
  51533. }
  51534. str += hex;
  51535. }
  51536. return str;
  51537. }
  51538. };
  51539. return MurmurHash3_64;
  51540. }();
  51541. exports.MurmurHash3_64 = MurmurHash3_64;
  51542. /***/ }),
  51543. /* 39 */
  51544. /***/ (function(module, exports, __w_pdfjs_require__) {
  51545. "use strict";
  51546. var sharedUtil = __w_pdfjs_require__(0);
  51547. var coreWorker = __w_pdfjs_require__(23);
  51548. var globalScope = sharedUtil.globalScope;
  51549. var OK_RESPONSE = 200;
  51550. var PARTIAL_CONTENT_RESPONSE = 206;
  51551. function NetworkManager(url, args) {
  51552. this.url = url;
  51553. args = args || {};
  51554. this.isHttp = /^https?:/i.test(url);
  51555. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  51556. this.withCredentials = args.withCredentials || false;
  51557. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  51558. return new XMLHttpRequest();
  51559. };
  51560. this.currXhrId = 0;
  51561. this.pendingRequests = Object.create(null);
  51562. this.loadedRequests = Object.create(null);
  51563. }
  51564. function getArrayBuffer(xhr) {
  51565. var data = xhr.response;
  51566. if (typeof data !== 'string') {
  51567. return data;
  51568. }
  51569. var length = data.length;
  51570. var array = new Uint8Array(length);
  51571. for (var i = 0; i < length; i++) {
  51572. array[i] = data.charCodeAt(i) & 0xFF;
  51573. }
  51574. return array.buffer;
  51575. }
  51576. var supportsMozChunked = function supportsMozChunkedClosure() {
  51577. try {
  51578. var x = new XMLHttpRequest();
  51579. x.open('GET', globalScope.location.href);
  51580. x.responseType = 'moz-chunked-arraybuffer';
  51581. return x.responseType === 'moz-chunked-arraybuffer';
  51582. } catch (e) {
  51583. return false;
  51584. }
  51585. }();
  51586. NetworkManager.prototype = {
  51587. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  51588. var args = {
  51589. begin: begin,
  51590. end: end
  51591. };
  51592. for (var prop in listeners) {
  51593. args[prop] = listeners[prop];
  51594. }
  51595. return this.request(args);
  51596. },
  51597. requestFull: function NetworkManager_requestFull(listeners) {
  51598. return this.request(listeners);
  51599. },
  51600. request: function NetworkManager_request(args) {
  51601. var xhr = this.getXhr();
  51602. var xhrId = this.currXhrId++;
  51603. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  51604. xhr.open('GET', this.url);
  51605. xhr.withCredentials = this.withCredentials;
  51606. for (var property in this.httpHeaders) {
  51607. var value = this.httpHeaders[property];
  51608. if (typeof value === 'undefined') {
  51609. continue;
  51610. }
  51611. xhr.setRequestHeader(property, value);
  51612. }
  51613. if (this.isHttp && 'begin' in args && 'end' in args) {
  51614. var rangeStr = args.begin + '-' + (args.end - 1);
  51615. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  51616. pendingRequest.expectedStatus = 206;
  51617. } else {
  51618. pendingRequest.expectedStatus = 200;
  51619. }
  51620. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  51621. if (useMozChunkedLoading) {
  51622. xhr.responseType = 'moz-chunked-arraybuffer';
  51623. pendingRequest.onProgressiveData = args.onProgressiveData;
  51624. pendingRequest.mozChunked = true;
  51625. } else {
  51626. xhr.responseType = 'arraybuffer';
  51627. }
  51628. if (args.onError) {
  51629. xhr.onerror = function (evt) {
  51630. args.onError(xhr.status);
  51631. };
  51632. }
  51633. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  51634. xhr.onprogress = this.onProgress.bind(this, xhrId);
  51635. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  51636. pendingRequest.onDone = args.onDone;
  51637. pendingRequest.onError = args.onError;
  51638. pendingRequest.onProgress = args.onProgress;
  51639. xhr.send(null);
  51640. return xhrId;
  51641. },
  51642. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  51643. var pendingRequest = this.pendingRequests[xhrId];
  51644. if (!pendingRequest) {
  51645. return;
  51646. }
  51647. if (pendingRequest.mozChunked) {
  51648. var chunk = getArrayBuffer(pendingRequest.xhr);
  51649. pendingRequest.onProgressiveData(chunk);
  51650. }
  51651. var onProgress = pendingRequest.onProgress;
  51652. if (onProgress) {
  51653. onProgress(evt);
  51654. }
  51655. },
  51656. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  51657. var pendingRequest = this.pendingRequests[xhrId];
  51658. if (!pendingRequest) {
  51659. return;
  51660. }
  51661. var xhr = pendingRequest.xhr;
  51662. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  51663. pendingRequest.onHeadersReceived();
  51664. delete pendingRequest.onHeadersReceived;
  51665. }
  51666. if (xhr.readyState !== 4) {
  51667. return;
  51668. }
  51669. if (!(xhrId in this.pendingRequests)) {
  51670. return;
  51671. }
  51672. delete this.pendingRequests[xhrId];
  51673. if (xhr.status === 0 && this.isHttp) {
  51674. if (pendingRequest.onError) {
  51675. pendingRequest.onError(xhr.status);
  51676. }
  51677. return;
  51678. }
  51679. var xhrStatus = xhr.status || OK_RESPONSE;
  51680. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  51681. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  51682. if (pendingRequest.onError) {
  51683. pendingRequest.onError(xhr.status);
  51684. }
  51685. return;
  51686. }
  51687. this.loadedRequests[xhrId] = true;
  51688. var chunk = getArrayBuffer(xhr);
  51689. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  51690. var rangeHeader = xhr.getResponseHeader('Content-Range');
  51691. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  51692. var begin = parseInt(matches[1], 10);
  51693. pendingRequest.onDone({
  51694. begin: begin,
  51695. chunk: chunk
  51696. });
  51697. } else if (pendingRequest.onProgressiveData) {
  51698. pendingRequest.onDone(null);
  51699. } else if (chunk) {
  51700. pendingRequest.onDone({
  51701. begin: 0,
  51702. chunk: chunk
  51703. });
  51704. } else if (pendingRequest.onError) {
  51705. pendingRequest.onError(xhr.status);
  51706. }
  51707. },
  51708. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  51709. for (var xhrId in this.pendingRequests) {
  51710. return true;
  51711. }
  51712. return false;
  51713. },
  51714. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  51715. return this.pendingRequests[xhrId].xhr;
  51716. },
  51717. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  51718. return !!this.pendingRequests[xhrId].onProgressiveData;
  51719. },
  51720. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  51721. return xhrId in this.pendingRequests;
  51722. },
  51723. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  51724. return xhrId in this.loadedRequests;
  51725. },
  51726. abortAllRequests: function NetworkManager_abortAllRequests() {
  51727. for (var xhrId in this.pendingRequests) {
  51728. this.abortRequest(xhrId | 0);
  51729. }
  51730. },
  51731. abortRequest: function NetworkManager_abortRequest(xhrId) {
  51732. var xhr = this.pendingRequests[xhrId].xhr;
  51733. delete this.pendingRequests[xhrId];
  51734. xhr.abort();
  51735. }
  51736. };
  51737. var assert = sharedUtil.assert;
  51738. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51739. var isInt = sharedUtil.isInt;
  51740. var MissingPDFException = sharedUtil.MissingPDFException;
  51741. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  51742. function PDFNetworkStream(options) {
  51743. this._options = options;
  51744. var source = options.source;
  51745. this._manager = new NetworkManager(source.url, {
  51746. httpHeaders: source.httpHeaders,
  51747. withCredentials: source.withCredentials
  51748. });
  51749. this._rangeChunkSize = source.rangeChunkSize;
  51750. this._fullRequestReader = null;
  51751. this._rangeRequestReaders = [];
  51752. }
  51753. PDFNetworkStream.prototype = {
  51754. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  51755. var i = this._rangeRequestReaders.indexOf(reader);
  51756. if (i >= 0) {
  51757. this._rangeRequestReaders.splice(i, 1);
  51758. }
  51759. },
  51760. getFullReader: function PDFNetworkStream_getFullReader() {
  51761. assert(!this._fullRequestReader);
  51762. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  51763. return this._fullRequestReader;
  51764. },
  51765. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  51766. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  51767. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  51768. this._rangeRequestReaders.push(reader);
  51769. return reader;
  51770. },
  51771. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  51772. if (this._fullRequestReader) {
  51773. this._fullRequestReader.cancel(reason);
  51774. }
  51775. var readers = this._rangeRequestReaders.slice(0);
  51776. readers.forEach(function (reader) {
  51777. reader.cancel(reason);
  51778. });
  51779. }
  51780. };
  51781. function PDFNetworkStreamFullRequestReader(manager, options) {
  51782. this._manager = manager;
  51783. var source = options.source;
  51784. var args = {
  51785. onHeadersReceived: this._onHeadersReceived.bind(this),
  51786. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  51787. onDone: this._onDone.bind(this),
  51788. onError: this._onError.bind(this),
  51789. onProgress: this._onProgress.bind(this)
  51790. };
  51791. this._url = source.url;
  51792. this._fullRequestId = manager.requestFull(args);
  51793. this._headersReceivedCapability = createPromiseCapability();
  51794. this._disableRange = options.disableRange || false;
  51795. this._contentLength = source.length;
  51796. this._rangeChunkSize = source.rangeChunkSize;
  51797. if (!this._rangeChunkSize && !this._disableRange) {
  51798. this._disableRange = true;
  51799. }
  51800. this._isStreamingSupported = false;
  51801. this._isRangeSupported = false;
  51802. this._cachedChunks = [];
  51803. this._requests = [];
  51804. this._done = false;
  51805. this._storedError = undefined;
  51806. this.onProgress = null;
  51807. }
  51808. PDFNetworkStreamFullRequestReader.prototype = {
  51809. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  51810. if (this._disableRange) {
  51811. return false;
  51812. }
  51813. var networkManager = this._manager;
  51814. if (!networkManager.isHttp) {
  51815. return false;
  51816. }
  51817. var fullRequestXhrId = this._fullRequestId;
  51818. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  51819. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  51820. return false;
  51821. }
  51822. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  51823. if (contentEncoding !== 'identity') {
  51824. return false;
  51825. }
  51826. var length = fullRequestXhr.getResponseHeader('Content-Length');
  51827. length = parseInt(length, 10);
  51828. if (!isInt(length)) {
  51829. return false;
  51830. }
  51831. this._contentLength = length;
  51832. if (length <= 2 * this._rangeChunkSize) {
  51833. return false;
  51834. }
  51835. return true;
  51836. },
  51837. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  51838. if (this._validateRangeRequestCapabilities()) {
  51839. this._isRangeSupported = true;
  51840. }
  51841. var networkManager = this._manager;
  51842. var fullRequestXhrId = this._fullRequestId;
  51843. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  51844. this._isStreamingSupported = true;
  51845. } else if (this._isRangeSupported) {
  51846. networkManager.abortRequest(fullRequestXhrId);
  51847. }
  51848. this._headersReceivedCapability.resolve();
  51849. },
  51850. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  51851. if (this._requests.length > 0) {
  51852. var requestCapability = this._requests.shift();
  51853. requestCapability.resolve({
  51854. value: chunk,
  51855. done: false
  51856. });
  51857. } else {
  51858. this._cachedChunks.push(chunk);
  51859. }
  51860. },
  51861. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  51862. if (args) {
  51863. this._onProgressiveData(args.chunk);
  51864. }
  51865. this._done = true;
  51866. if (this._cachedChunks.length > 0) {
  51867. return;
  51868. }
  51869. this._requests.forEach(function (requestCapability) {
  51870. requestCapability.resolve({
  51871. value: undefined,
  51872. done: true
  51873. });
  51874. });
  51875. this._requests = [];
  51876. },
  51877. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  51878. var url = this._url;
  51879. var exception;
  51880. if (status === 404 || status === 0 && /^file:/.test(url)) {
  51881. exception = new MissingPDFException('Missing PDF "' + url + '".');
  51882. } else {
  51883. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  51884. }
  51885. this._storedError = exception;
  51886. this._headersReceivedCapability.reject(exception);
  51887. this._requests.forEach(function (requestCapability) {
  51888. requestCapability.reject(exception);
  51889. });
  51890. this._requests = [];
  51891. this._cachedChunks = [];
  51892. },
  51893. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  51894. if (this.onProgress) {
  51895. this.onProgress({
  51896. loaded: data.loaded,
  51897. total: data.lengthComputable ? data.total : this._contentLength
  51898. });
  51899. }
  51900. },
  51901. get isRangeSupported() {
  51902. return this._isRangeSupported;
  51903. },
  51904. get isStreamingSupported() {
  51905. return this._isStreamingSupported;
  51906. },
  51907. get contentLength() {
  51908. return this._contentLength;
  51909. },
  51910. get headersReady() {
  51911. return this._headersReceivedCapability.promise;
  51912. },
  51913. read: function PDFNetworkStreamFullRequestReader_read() {
  51914. if (this._storedError) {
  51915. return Promise.reject(this._storedError);
  51916. }
  51917. if (this._cachedChunks.length > 0) {
  51918. var chunk = this._cachedChunks.shift();
  51919. return Promise.resolve(chunk);
  51920. }
  51921. if (this._done) {
  51922. return Promise.resolve({
  51923. value: undefined,
  51924. done: true
  51925. });
  51926. }
  51927. var requestCapability = createPromiseCapability();
  51928. this._requests.push(requestCapability);
  51929. return requestCapability.promise;
  51930. },
  51931. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  51932. this._done = true;
  51933. this._headersReceivedCapability.reject(reason);
  51934. this._requests.forEach(function (requestCapability) {
  51935. requestCapability.resolve({
  51936. value: undefined,
  51937. done: true
  51938. });
  51939. });
  51940. this._requests = [];
  51941. if (this._manager.isPendingRequest(this._fullRequestId)) {
  51942. this._manager.abortRequest(this._fullRequestId);
  51943. }
  51944. this._fullRequestReader = null;
  51945. }
  51946. };
  51947. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  51948. this._manager = manager;
  51949. var args = {
  51950. onDone: this._onDone.bind(this),
  51951. onProgress: this._onProgress.bind(this)
  51952. };
  51953. this._requestId = manager.requestRange(begin, end, args);
  51954. this._requests = [];
  51955. this._queuedChunk = null;
  51956. this._done = false;
  51957. this.onProgress = null;
  51958. this.onClosed = null;
  51959. }
  51960. PDFNetworkStreamRangeRequestReader.prototype = {
  51961. _close: function PDFNetworkStreamRangeRequestReader_close() {
  51962. if (this.onClosed) {
  51963. this.onClosed(this);
  51964. }
  51965. },
  51966. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  51967. var chunk = data.chunk;
  51968. if (this._requests.length > 0) {
  51969. var requestCapability = this._requests.shift();
  51970. requestCapability.resolve({
  51971. value: chunk,
  51972. done: false
  51973. });
  51974. } else {
  51975. this._queuedChunk = chunk;
  51976. }
  51977. this._done = true;
  51978. this._requests.forEach(function (requestCapability) {
  51979. requestCapability.resolve({
  51980. value: undefined,
  51981. done: true
  51982. });
  51983. });
  51984. this._requests = [];
  51985. this._close();
  51986. },
  51987. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  51988. if (!this.isStreamingSupported && this.onProgress) {
  51989. this.onProgress({ loaded: evt.loaded });
  51990. }
  51991. },
  51992. get isStreamingSupported() {
  51993. return false;
  51994. },
  51995. read: function PDFNetworkStreamRangeRequestReader_read() {
  51996. if (this._queuedChunk !== null) {
  51997. var chunk = this._queuedChunk;
  51998. this._queuedChunk = null;
  51999. return Promise.resolve({
  52000. value: chunk,
  52001. done: false
  52002. });
  52003. }
  52004. if (this._done) {
  52005. return Promise.resolve({
  52006. value: undefined,
  52007. done: true
  52008. });
  52009. }
  52010. var requestCapability = createPromiseCapability();
  52011. this._requests.push(requestCapability);
  52012. return requestCapability.promise;
  52013. },
  52014. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52015. this._done = true;
  52016. this._requests.forEach(function (requestCapability) {
  52017. requestCapability.resolve({
  52018. value: undefined,
  52019. done: true
  52020. });
  52021. });
  52022. this._requests = [];
  52023. if (this._manager.isPendingRequest(this._requestId)) {
  52024. this._manager.abortRequest(this._requestId);
  52025. }
  52026. this._close();
  52027. }
  52028. };
  52029. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52030. exports.PDFNetworkStream = PDFNetworkStream;
  52031. exports.NetworkManager = NetworkManager;
  52032. /***/ }),
  52033. /* 40 */
  52034. /***/ (function(module, exports, __w_pdfjs_require__) {
  52035. "use strict";
  52036. var sharedUtil = __w_pdfjs_require__(0);
  52037. var corePrimitives = __w_pdfjs_require__(1);
  52038. var coreFunction = __w_pdfjs_require__(7);
  52039. var coreColorSpace = __w_pdfjs_require__(4);
  52040. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52041. var MissingDataException = sharedUtil.MissingDataException;
  52042. var Util = sharedUtil.Util;
  52043. var assert = sharedUtil.assert;
  52044. var error = sharedUtil.error;
  52045. var info = sharedUtil.info;
  52046. var warn = sharedUtil.warn;
  52047. var isStream = corePrimitives.isStream;
  52048. var PDFFunction = coreFunction.PDFFunction;
  52049. var ColorSpace = coreColorSpace.ColorSpace;
  52050. var ShadingType = {
  52051. FUNCTION_BASED: 1,
  52052. AXIAL: 2,
  52053. RADIAL: 3,
  52054. FREE_FORM_MESH: 4,
  52055. LATTICE_FORM_MESH: 5,
  52056. COONS_PATCH_MESH: 6,
  52057. TENSOR_PATCH_MESH: 7
  52058. };
  52059. var Pattern = function PatternClosure() {
  52060. function Pattern() {
  52061. error('should not call Pattern constructor');
  52062. }
  52063. Pattern.prototype = {
  52064. getPattern: function Pattern_getPattern(ctx) {
  52065. error('Should not call Pattern.getStyle: ' + ctx);
  52066. }
  52067. };
  52068. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52069. var dict = isStream(shading) ? shading.dict : shading;
  52070. var type = dict.get('ShadingType');
  52071. try {
  52072. switch (type) {
  52073. case ShadingType.AXIAL:
  52074. case ShadingType.RADIAL:
  52075. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52076. case ShadingType.FREE_FORM_MESH:
  52077. case ShadingType.LATTICE_FORM_MESH:
  52078. case ShadingType.COONS_PATCH_MESH:
  52079. case ShadingType.TENSOR_PATCH_MESH:
  52080. return new Shadings.Mesh(shading, matrix, xref, res);
  52081. default:
  52082. throw new Error('Unsupported ShadingType: ' + type);
  52083. }
  52084. } catch (ex) {
  52085. if (ex instanceof MissingDataException) {
  52086. throw ex;
  52087. }
  52088. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52089. warn(ex);
  52090. return new Shadings.Dummy();
  52091. }
  52092. };
  52093. return Pattern;
  52094. }();
  52095. var Shadings = {};
  52096. Shadings.SMALL_NUMBER = 1e-6;
  52097. Shadings.RadialAxial = function RadialAxialClosure() {
  52098. function RadialAxial(dict, matrix, xref, res) {
  52099. this.matrix = matrix;
  52100. this.coordsArr = dict.getArray('Coords');
  52101. this.shadingType = dict.get('ShadingType');
  52102. this.type = 'Pattern';
  52103. var cs = dict.get('ColorSpace', 'CS');
  52104. cs = ColorSpace.parse(cs, xref, res);
  52105. this.cs = cs;
  52106. var t0 = 0.0, t1 = 1.0;
  52107. if (dict.has('Domain')) {
  52108. var domainArr = dict.getArray('Domain');
  52109. t0 = domainArr[0];
  52110. t1 = domainArr[1];
  52111. }
  52112. var extendStart = false, extendEnd = false;
  52113. if (dict.has('Extend')) {
  52114. var extendArr = dict.getArray('Extend');
  52115. extendStart = extendArr[0];
  52116. extendEnd = extendArr[1];
  52117. }
  52118. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52119. var x1 = this.coordsArr[0];
  52120. var y1 = this.coordsArr[1];
  52121. var r1 = this.coordsArr[2];
  52122. var x2 = this.coordsArr[3];
  52123. var y2 = this.coordsArr[4];
  52124. var r2 = this.coordsArr[5];
  52125. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52126. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52127. warn('Unsupported radial gradient.');
  52128. }
  52129. }
  52130. this.extendStart = extendStart;
  52131. this.extendEnd = extendEnd;
  52132. var fnObj = dict.get('Function');
  52133. var fn = PDFFunction.parseArray(xref, fnObj);
  52134. var diff = t1 - t0;
  52135. var step = diff / 10;
  52136. var colorStops = this.colorStops = [];
  52137. if (t0 >= t1 || step <= 0) {
  52138. info('Bad shading domain.');
  52139. return;
  52140. }
  52141. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52142. var rgbColor;
  52143. for (var i = t0; i <= t1; i += step) {
  52144. ratio[0] = i;
  52145. fn(ratio, 0, color, 0);
  52146. rgbColor = cs.getRgb(color, 0);
  52147. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52148. colorStops.push([
  52149. (i - t0) / diff,
  52150. cssColor
  52151. ]);
  52152. }
  52153. var background = 'transparent';
  52154. if (dict.has('Background')) {
  52155. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52156. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52157. }
  52158. if (!extendStart) {
  52159. colorStops.unshift([
  52160. 0,
  52161. background
  52162. ]);
  52163. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52164. }
  52165. if (!extendEnd) {
  52166. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52167. colorStops.push([
  52168. 1,
  52169. background
  52170. ]);
  52171. }
  52172. this.colorStops = colorStops;
  52173. }
  52174. RadialAxial.prototype = {
  52175. getIR: function RadialAxial_getIR() {
  52176. var coordsArr = this.coordsArr;
  52177. var shadingType = this.shadingType;
  52178. var type, p0, p1, r0, r1;
  52179. if (shadingType === ShadingType.AXIAL) {
  52180. p0 = [
  52181. coordsArr[0],
  52182. coordsArr[1]
  52183. ];
  52184. p1 = [
  52185. coordsArr[2],
  52186. coordsArr[3]
  52187. ];
  52188. r0 = null;
  52189. r1 = null;
  52190. type = 'axial';
  52191. } else if (shadingType === ShadingType.RADIAL) {
  52192. p0 = [
  52193. coordsArr[0],
  52194. coordsArr[1]
  52195. ];
  52196. p1 = [
  52197. coordsArr[3],
  52198. coordsArr[4]
  52199. ];
  52200. r0 = coordsArr[2];
  52201. r1 = coordsArr[5];
  52202. type = 'radial';
  52203. } else {
  52204. error('getPattern type unknown: ' + shadingType);
  52205. }
  52206. var matrix = this.matrix;
  52207. if (matrix) {
  52208. p0 = Util.applyTransform(p0, matrix);
  52209. p1 = Util.applyTransform(p1, matrix);
  52210. if (shadingType === ShadingType.RADIAL) {
  52211. var scale = Util.singularValueDecompose2dScale(matrix);
  52212. r0 *= scale[0];
  52213. r1 *= scale[1];
  52214. }
  52215. }
  52216. return [
  52217. 'RadialAxial',
  52218. type,
  52219. this.colorStops,
  52220. p0,
  52221. p1,
  52222. r0,
  52223. r1
  52224. ];
  52225. }
  52226. };
  52227. return RadialAxial;
  52228. }();
  52229. Shadings.Mesh = function MeshClosure() {
  52230. function MeshStreamReader(stream, context) {
  52231. this.stream = stream;
  52232. this.context = context;
  52233. this.buffer = 0;
  52234. this.bufferLength = 0;
  52235. var numComps = context.numComps;
  52236. this.tmpCompsBuf = new Float32Array(numComps);
  52237. var csNumComps = context.colorSpace.numComps;
  52238. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  52239. }
  52240. MeshStreamReader.prototype = {
  52241. get hasData() {
  52242. if (this.stream.end) {
  52243. return this.stream.pos < this.stream.end;
  52244. }
  52245. if (this.bufferLength > 0) {
  52246. return true;
  52247. }
  52248. var nextByte = this.stream.getByte();
  52249. if (nextByte < 0) {
  52250. return false;
  52251. }
  52252. this.buffer = nextByte;
  52253. this.bufferLength = 8;
  52254. return true;
  52255. },
  52256. readBits: function MeshStreamReader_readBits(n) {
  52257. var buffer = this.buffer;
  52258. var bufferLength = this.bufferLength;
  52259. if (n === 32) {
  52260. if (bufferLength === 0) {
  52261. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  52262. }
  52263. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  52264. var nextByte = this.stream.getByte();
  52265. this.buffer = nextByte & (1 << bufferLength) - 1;
  52266. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  52267. }
  52268. if (n === 8 && bufferLength === 0) {
  52269. return this.stream.getByte();
  52270. }
  52271. while (bufferLength < n) {
  52272. buffer = buffer << 8 | this.stream.getByte();
  52273. bufferLength += 8;
  52274. }
  52275. bufferLength -= n;
  52276. this.bufferLength = bufferLength;
  52277. this.buffer = buffer & (1 << bufferLength) - 1;
  52278. return buffer >> bufferLength;
  52279. },
  52280. align: function MeshStreamReader_align() {
  52281. this.buffer = 0;
  52282. this.bufferLength = 0;
  52283. },
  52284. readFlag: function MeshStreamReader_readFlag() {
  52285. return this.readBits(this.context.bitsPerFlag);
  52286. },
  52287. readCoordinate: function MeshStreamReader_readCoordinate() {
  52288. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  52289. var xi = this.readBits(bitsPerCoordinate);
  52290. var yi = this.readBits(bitsPerCoordinate);
  52291. var decode = this.context.decode;
  52292. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  52293. return [
  52294. xi * scale * (decode[1] - decode[0]) + decode[0],
  52295. yi * scale * (decode[3] - decode[2]) + decode[2]
  52296. ];
  52297. },
  52298. readComponents: function MeshStreamReader_readComponents() {
  52299. var numComps = this.context.numComps;
  52300. var bitsPerComponent = this.context.bitsPerComponent;
  52301. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  52302. var decode = this.context.decode;
  52303. var components = this.tmpCompsBuf;
  52304. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  52305. var ci = this.readBits(bitsPerComponent);
  52306. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  52307. }
  52308. var color = this.tmpCsCompsBuf;
  52309. if (this.context.colorFn) {
  52310. this.context.colorFn(components, 0, color, 0);
  52311. }
  52312. return this.context.colorSpace.getRgb(color, 0);
  52313. }
  52314. };
  52315. function decodeType4Shading(mesh, reader) {
  52316. var coords = mesh.coords;
  52317. var colors = mesh.colors;
  52318. var operators = [];
  52319. var ps = [];
  52320. var verticesLeft = 0;
  52321. while (reader.hasData) {
  52322. var f = reader.readFlag();
  52323. var coord = reader.readCoordinate();
  52324. var color = reader.readComponents();
  52325. if (verticesLeft === 0) {
  52326. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  52327. switch (f) {
  52328. case 0:
  52329. verticesLeft = 3;
  52330. break;
  52331. case 1:
  52332. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  52333. verticesLeft = 1;
  52334. break;
  52335. case 2:
  52336. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  52337. verticesLeft = 1;
  52338. break;
  52339. }
  52340. operators.push(f);
  52341. }
  52342. ps.push(coords.length);
  52343. coords.push(coord);
  52344. colors.push(color);
  52345. verticesLeft--;
  52346. reader.align();
  52347. }
  52348. mesh.figures.push({
  52349. type: 'triangles',
  52350. coords: new Int32Array(ps),
  52351. colors: new Int32Array(ps)
  52352. });
  52353. }
  52354. function decodeType5Shading(mesh, reader, verticesPerRow) {
  52355. var coords = mesh.coords;
  52356. var colors = mesh.colors;
  52357. var ps = [];
  52358. while (reader.hasData) {
  52359. var coord = reader.readCoordinate();
  52360. var color = reader.readComponents();
  52361. ps.push(coords.length);
  52362. coords.push(coord);
  52363. colors.push(color);
  52364. }
  52365. mesh.figures.push({
  52366. type: 'lattice',
  52367. coords: new Int32Array(ps),
  52368. colors: new Int32Array(ps),
  52369. verticesPerRow: verticesPerRow
  52370. });
  52371. }
  52372. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  52373. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  52374. var TRIANGLE_DENSITY = 20;
  52375. var getB = function getBClosure() {
  52376. function buildB(count) {
  52377. var lut = [];
  52378. for (var i = 0; i <= count; i++) {
  52379. var t = i / count, t_ = 1 - t;
  52380. lut.push(new Float32Array([
  52381. t_ * t_ * t_,
  52382. 3 * t * t_ * t_,
  52383. 3 * t * t * t_,
  52384. t * t * t
  52385. ]));
  52386. }
  52387. return lut;
  52388. }
  52389. var cache = [];
  52390. return function getB(count) {
  52391. if (!cache[count]) {
  52392. cache[count] = buildB(count);
  52393. }
  52394. return cache[count];
  52395. };
  52396. }();
  52397. function buildFigureFromPatch(mesh, index) {
  52398. var figure = mesh.figures[index];
  52399. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  52400. var coords = mesh.coords, colors = mesh.colors;
  52401. var pi = figure.coords;
  52402. var ci = figure.colors;
  52403. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52404. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52405. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52406. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52407. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  52408. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  52409. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  52410. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  52411. var verticesPerRow = splitXBy + 1;
  52412. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  52413. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  52414. var k = 0;
  52415. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  52416. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  52417. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  52418. for (var row = 0; row <= splitYBy; row++) {
  52419. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  52420. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  52421. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  52422. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  52423. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  52424. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  52425. for (var col = 0; col <= splitXBy; col++, k++) {
  52426. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  52427. continue;
  52428. }
  52429. var x = 0, y = 0;
  52430. var q = 0;
  52431. for (var i = 0; i <= 3; i++) {
  52432. for (var j = 0; j <= 3; j++, q++) {
  52433. var m = bRow[row][i] * bCol[col][j];
  52434. x += coords[pi[q]][0] * m;
  52435. y += coords[pi[q]][1] * m;
  52436. }
  52437. }
  52438. figureCoords[k] = coords.length;
  52439. coords.push([
  52440. x,
  52441. y
  52442. ]);
  52443. figureColors[k] = colors.length;
  52444. var newColor = new Uint8Array(3);
  52445. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  52446. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  52447. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  52448. colors.push(newColor);
  52449. }
  52450. }
  52451. figureCoords[0] = pi[0];
  52452. figureColors[0] = ci[0];
  52453. figureCoords[splitXBy] = pi[3];
  52454. figureColors[splitXBy] = ci[1];
  52455. figureCoords[verticesPerRow * splitYBy] = pi[12];
  52456. figureColors[verticesPerRow * splitYBy] = ci[2];
  52457. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  52458. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  52459. mesh.figures[index] = {
  52460. type: 'lattice',
  52461. coords: figureCoords,
  52462. colors: figureColors,
  52463. verticesPerRow: verticesPerRow
  52464. };
  52465. }
  52466. function decodeType6Shading(mesh, reader) {
  52467. var coords = mesh.coords;
  52468. var colors = mesh.colors;
  52469. var ps = new Int32Array(16);
  52470. var cs = new Int32Array(4);
  52471. while (reader.hasData) {
  52472. var f = reader.readFlag();
  52473. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  52474. var i, ii;
  52475. var pi = coords.length;
  52476. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  52477. coords.push(reader.readCoordinate());
  52478. }
  52479. var ci = colors.length;
  52480. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52481. colors.push(reader.readComponents());
  52482. }
  52483. var tmp1, tmp2, tmp3, tmp4;
  52484. switch (f) {
  52485. case 0:
  52486. ps[12] = pi + 3;
  52487. ps[13] = pi + 4;
  52488. ps[14] = pi + 5;
  52489. ps[15] = pi + 6;
  52490. ps[8] = pi + 2;
  52491. ps[11] = pi + 7;
  52492. ps[4] = pi + 1;
  52493. ps[7] = pi + 8;
  52494. ps[0] = pi;
  52495. ps[1] = pi + 11;
  52496. ps[2] = pi + 10;
  52497. ps[3] = pi + 9;
  52498. cs[2] = ci + 1;
  52499. cs[3] = ci + 2;
  52500. cs[0] = ci;
  52501. cs[1] = ci + 3;
  52502. break;
  52503. case 1:
  52504. tmp1 = ps[12];
  52505. tmp2 = ps[13];
  52506. tmp3 = ps[14];
  52507. tmp4 = ps[15];
  52508. ps[12] = tmp4;
  52509. ps[13] = pi + 0;
  52510. ps[14] = pi + 1;
  52511. ps[15] = pi + 2;
  52512. ps[8] = tmp3;
  52513. ps[11] = pi + 3;
  52514. ps[4] = tmp2;
  52515. ps[7] = pi + 4;
  52516. ps[0] = tmp1;
  52517. ps[1] = pi + 7;
  52518. ps[2] = pi + 6;
  52519. ps[3] = pi + 5;
  52520. tmp1 = cs[2];
  52521. tmp2 = cs[3];
  52522. cs[2] = tmp2;
  52523. cs[3] = ci;
  52524. cs[0] = tmp1;
  52525. cs[1] = ci + 1;
  52526. break;
  52527. case 2:
  52528. tmp1 = ps[15];
  52529. tmp2 = ps[11];
  52530. ps[12] = ps[3];
  52531. ps[13] = pi + 0;
  52532. ps[14] = pi + 1;
  52533. ps[15] = pi + 2;
  52534. ps[8] = ps[7];
  52535. ps[11] = pi + 3;
  52536. ps[4] = tmp2;
  52537. ps[7] = pi + 4;
  52538. ps[0] = tmp1;
  52539. ps[1] = pi + 7;
  52540. ps[2] = pi + 6;
  52541. ps[3] = pi + 5;
  52542. tmp1 = cs[3];
  52543. cs[2] = cs[1];
  52544. cs[3] = ci;
  52545. cs[0] = tmp1;
  52546. cs[1] = ci + 1;
  52547. break;
  52548. case 3:
  52549. ps[12] = ps[0];
  52550. ps[13] = pi + 0;
  52551. ps[14] = pi + 1;
  52552. ps[15] = pi + 2;
  52553. ps[8] = ps[1];
  52554. ps[11] = pi + 3;
  52555. ps[4] = ps[2];
  52556. ps[7] = pi + 4;
  52557. ps[0] = ps[3];
  52558. ps[1] = pi + 7;
  52559. ps[2] = pi + 6;
  52560. ps[3] = pi + 5;
  52561. cs[2] = cs[0];
  52562. cs[3] = ci;
  52563. cs[0] = cs[1];
  52564. cs[1] = ci + 1;
  52565. break;
  52566. }
  52567. ps[5] = coords.length;
  52568. coords.push([
  52569. (-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,
  52570. (-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
  52571. ]);
  52572. ps[6] = coords.length;
  52573. coords.push([
  52574. (-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,
  52575. (-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
  52576. ]);
  52577. ps[9] = coords.length;
  52578. coords.push([
  52579. (-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,
  52580. (-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
  52581. ]);
  52582. ps[10] = coords.length;
  52583. coords.push([
  52584. (-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,
  52585. (-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
  52586. ]);
  52587. mesh.figures.push({
  52588. type: 'patch',
  52589. coords: new Int32Array(ps),
  52590. colors: new Int32Array(cs)
  52591. });
  52592. }
  52593. }
  52594. function decodeType7Shading(mesh, reader) {
  52595. var coords = mesh.coords;
  52596. var colors = mesh.colors;
  52597. var ps = new Int32Array(16);
  52598. var cs = new Int32Array(4);
  52599. while (reader.hasData) {
  52600. var f = reader.readFlag();
  52601. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  52602. var i, ii;
  52603. var pi = coords.length;
  52604. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  52605. coords.push(reader.readCoordinate());
  52606. }
  52607. var ci = colors.length;
  52608. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52609. colors.push(reader.readComponents());
  52610. }
  52611. var tmp1, tmp2, tmp3, tmp4;
  52612. switch (f) {
  52613. case 0:
  52614. ps[12] = pi + 3;
  52615. ps[13] = pi + 4;
  52616. ps[14] = pi + 5;
  52617. ps[15] = pi + 6;
  52618. ps[8] = pi + 2;
  52619. ps[9] = pi + 13;
  52620. ps[10] = pi + 14;
  52621. ps[11] = pi + 7;
  52622. ps[4] = pi + 1;
  52623. ps[5] = pi + 12;
  52624. ps[6] = pi + 15;
  52625. ps[7] = pi + 8;
  52626. ps[0] = pi;
  52627. ps[1] = pi + 11;
  52628. ps[2] = pi + 10;
  52629. ps[3] = pi + 9;
  52630. cs[2] = ci + 1;
  52631. cs[3] = ci + 2;
  52632. cs[0] = ci;
  52633. cs[1] = ci + 3;
  52634. break;
  52635. case 1:
  52636. tmp1 = ps[12];
  52637. tmp2 = ps[13];
  52638. tmp3 = ps[14];
  52639. tmp4 = ps[15];
  52640. ps[12] = tmp4;
  52641. ps[13] = pi + 0;
  52642. ps[14] = pi + 1;
  52643. ps[15] = pi + 2;
  52644. ps[8] = tmp3;
  52645. ps[9] = pi + 9;
  52646. ps[10] = pi + 10;
  52647. ps[11] = pi + 3;
  52648. ps[4] = tmp2;
  52649. ps[5] = pi + 8;
  52650. ps[6] = pi + 11;
  52651. ps[7] = pi + 4;
  52652. ps[0] = tmp1;
  52653. ps[1] = pi + 7;
  52654. ps[2] = pi + 6;
  52655. ps[3] = pi + 5;
  52656. tmp1 = cs[2];
  52657. tmp2 = cs[3];
  52658. cs[2] = tmp2;
  52659. cs[3] = ci;
  52660. cs[0] = tmp1;
  52661. cs[1] = ci + 1;
  52662. break;
  52663. case 2:
  52664. tmp1 = ps[15];
  52665. tmp2 = ps[11];
  52666. ps[12] = ps[3];
  52667. ps[13] = pi + 0;
  52668. ps[14] = pi + 1;
  52669. ps[15] = pi + 2;
  52670. ps[8] = ps[7];
  52671. ps[9] = pi + 9;
  52672. ps[10] = pi + 10;
  52673. ps[11] = pi + 3;
  52674. ps[4] = tmp2;
  52675. ps[5] = pi + 8;
  52676. ps[6] = pi + 11;
  52677. ps[7] = pi + 4;
  52678. ps[0] = tmp1;
  52679. ps[1] = pi + 7;
  52680. ps[2] = pi + 6;
  52681. ps[3] = pi + 5;
  52682. tmp1 = cs[3];
  52683. cs[2] = cs[1];
  52684. cs[3] = ci;
  52685. cs[0] = tmp1;
  52686. cs[1] = ci + 1;
  52687. break;
  52688. case 3:
  52689. ps[12] = ps[0];
  52690. ps[13] = pi + 0;
  52691. ps[14] = pi + 1;
  52692. ps[15] = pi + 2;
  52693. ps[8] = ps[1];
  52694. ps[9] = pi + 9;
  52695. ps[10] = pi + 10;
  52696. ps[11] = pi + 3;
  52697. ps[4] = ps[2];
  52698. ps[5] = pi + 8;
  52699. ps[6] = pi + 11;
  52700. ps[7] = pi + 4;
  52701. ps[0] = ps[3];
  52702. ps[1] = pi + 7;
  52703. ps[2] = pi + 6;
  52704. ps[3] = pi + 5;
  52705. cs[2] = cs[0];
  52706. cs[3] = ci;
  52707. cs[0] = cs[1];
  52708. cs[1] = ci + 1;
  52709. break;
  52710. }
  52711. mesh.figures.push({
  52712. type: 'patch',
  52713. coords: new Int32Array(ps),
  52714. colors: new Int32Array(cs)
  52715. });
  52716. }
  52717. }
  52718. function updateBounds(mesh) {
  52719. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  52720. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  52721. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  52722. minX = minX > x ? x : minX;
  52723. minY = minY > y ? y : minY;
  52724. maxX = maxX < x ? x : maxX;
  52725. maxY = maxY < y ? y : maxY;
  52726. }
  52727. mesh.bounds = [
  52728. minX,
  52729. minY,
  52730. maxX,
  52731. maxY
  52732. ];
  52733. }
  52734. function packData(mesh) {
  52735. var i, ii, j, jj;
  52736. var coords = mesh.coords;
  52737. var coordsPacked = new Float32Array(coords.length * 2);
  52738. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  52739. var xy = coords[i];
  52740. coordsPacked[j++] = xy[0];
  52741. coordsPacked[j++] = xy[1];
  52742. }
  52743. mesh.coords = coordsPacked;
  52744. var colors = mesh.colors;
  52745. var colorsPacked = new Uint8Array(colors.length * 3);
  52746. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  52747. var c = colors[i];
  52748. colorsPacked[j++] = c[0];
  52749. colorsPacked[j++] = c[1];
  52750. colorsPacked[j++] = c[2];
  52751. }
  52752. mesh.colors = colorsPacked;
  52753. var figures = mesh.figures;
  52754. for (i = 0, ii = figures.length; i < ii; i++) {
  52755. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  52756. for (j = 0, jj = ps.length; j < jj; j++) {
  52757. ps[j] *= 2;
  52758. cs[j] *= 3;
  52759. }
  52760. }
  52761. }
  52762. function Mesh(stream, matrix, xref, res) {
  52763. assert(isStream(stream), 'Mesh data is not a stream');
  52764. var dict = stream.dict;
  52765. this.matrix = matrix;
  52766. this.shadingType = dict.get('ShadingType');
  52767. this.type = 'Pattern';
  52768. this.bbox = dict.getArray('BBox');
  52769. var cs = dict.get('ColorSpace', 'CS');
  52770. cs = ColorSpace.parse(cs, xref, res);
  52771. this.cs = cs;
  52772. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  52773. var fnObj = dict.get('Function');
  52774. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  52775. this.coords = [];
  52776. this.colors = [];
  52777. this.figures = [];
  52778. var decodeContext = {
  52779. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  52780. bitsPerComponent: dict.get('BitsPerComponent'),
  52781. bitsPerFlag: dict.get('BitsPerFlag'),
  52782. decode: dict.getArray('Decode'),
  52783. colorFn: fn,
  52784. colorSpace: cs,
  52785. numComps: fn ? 1 : cs.numComps
  52786. };
  52787. var reader = new MeshStreamReader(stream, decodeContext);
  52788. var patchMesh = false;
  52789. switch (this.shadingType) {
  52790. case ShadingType.FREE_FORM_MESH:
  52791. decodeType4Shading(this, reader);
  52792. break;
  52793. case ShadingType.LATTICE_FORM_MESH:
  52794. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  52795. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  52796. decodeType5Shading(this, reader, verticesPerRow);
  52797. break;
  52798. case ShadingType.COONS_PATCH_MESH:
  52799. decodeType6Shading(this, reader);
  52800. patchMesh = true;
  52801. break;
  52802. case ShadingType.TENSOR_PATCH_MESH:
  52803. decodeType7Shading(this, reader);
  52804. patchMesh = true;
  52805. break;
  52806. default:
  52807. error('Unsupported mesh type.');
  52808. break;
  52809. }
  52810. if (patchMesh) {
  52811. updateBounds(this);
  52812. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  52813. buildFigureFromPatch(this, i);
  52814. }
  52815. }
  52816. updateBounds(this);
  52817. packData(this);
  52818. }
  52819. Mesh.prototype = {
  52820. getIR: function Mesh_getIR() {
  52821. return [
  52822. 'Mesh',
  52823. this.shadingType,
  52824. this.coords,
  52825. this.colors,
  52826. this.figures,
  52827. this.bounds,
  52828. this.matrix,
  52829. this.bbox,
  52830. this.background
  52831. ];
  52832. }
  52833. };
  52834. return Mesh;
  52835. }();
  52836. Shadings.Dummy = function DummyClosure() {
  52837. function Dummy() {
  52838. this.type = 'Pattern';
  52839. }
  52840. Dummy.prototype = {
  52841. getIR: function Dummy_getIR() {
  52842. return ['Dummy'];
  52843. }
  52844. };
  52845. return Dummy;
  52846. }();
  52847. function getTilingPatternIR(operatorList, dict, args) {
  52848. var matrix = dict.getArray('Matrix');
  52849. var bbox = dict.getArray('BBox');
  52850. var xstep = dict.get('XStep');
  52851. var ystep = dict.get('YStep');
  52852. var paintType = dict.get('PaintType');
  52853. var tilingType = dict.get('TilingType');
  52854. return [
  52855. 'TilingPattern',
  52856. args,
  52857. operatorList,
  52858. matrix,
  52859. bbox,
  52860. xstep,
  52861. ystep,
  52862. paintType,
  52863. tilingType
  52864. ];
  52865. }
  52866. exports.Pattern = Pattern;
  52867. exports.getTilingPatternIR = getTilingPatternIR;
  52868. /***/ }),
  52869. /* 41 */
  52870. /***/ (function(module, exports, __w_pdfjs_require__) {
  52871. "use strict";
  52872. var sharedUtil = __w_pdfjs_require__(0);
  52873. var coreStream = __w_pdfjs_require__(2);
  52874. var coreChunkedStream = __w_pdfjs_require__(16);
  52875. var coreDocument = __w_pdfjs_require__(31);
  52876. var warn = sharedUtil.warn;
  52877. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  52878. var shadow = sharedUtil.shadow;
  52879. var NotImplementedException = sharedUtil.NotImplementedException;
  52880. var MissingDataException = sharedUtil.MissingDataException;
  52881. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52882. var Util = sharedUtil.Util;
  52883. var Stream = coreStream.Stream;
  52884. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  52885. var PDFDocument = coreDocument.PDFDocument;
  52886. var BasePdfManager = function BasePdfManagerClosure() {
  52887. function BasePdfManager() {
  52888. throw new Error('Cannot initialize BaseManagerManager');
  52889. }
  52890. BasePdfManager.prototype = {
  52891. get docId() {
  52892. return this._docId;
  52893. },
  52894. get password() {
  52895. return this._password;
  52896. },
  52897. get docBaseUrl() {
  52898. var docBaseUrl = null;
  52899. if (this._docBaseUrl) {
  52900. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  52901. if (absoluteUrl) {
  52902. docBaseUrl = absoluteUrl.href;
  52903. } else {
  52904. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  52905. }
  52906. }
  52907. return shadow(this, 'docBaseUrl', docBaseUrl);
  52908. },
  52909. onLoadedStream: function BasePdfManager_onLoadedStream() {
  52910. throw new NotImplementedException();
  52911. },
  52912. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  52913. return this.ensure(this.pdfDocument, prop, args);
  52914. },
  52915. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  52916. return this.ensure(this.pdfDocument.xref, prop, args);
  52917. },
  52918. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  52919. return this.ensure(this.pdfDocument.catalog, prop, args);
  52920. },
  52921. getPage: function BasePdfManager_getPage(pageIndex) {
  52922. return this.pdfDocument.getPage(pageIndex);
  52923. },
  52924. cleanup: function BasePdfManager_cleanup() {
  52925. return this.pdfDocument.cleanup();
  52926. },
  52927. ensure: function BasePdfManager_ensure(obj, prop, args) {
  52928. return new NotImplementedException();
  52929. },
  52930. requestRange: function BasePdfManager_requestRange(begin, end) {
  52931. return new NotImplementedException();
  52932. },
  52933. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  52934. return new NotImplementedException();
  52935. },
  52936. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  52937. return new NotImplementedException();
  52938. },
  52939. updatePassword: function BasePdfManager_updatePassword(password) {
  52940. this._password = password;
  52941. },
  52942. terminate: function BasePdfManager_terminate() {
  52943. return new NotImplementedException();
  52944. }
  52945. };
  52946. return BasePdfManager;
  52947. }();
  52948. var LocalPdfManager = function LocalPdfManagerClosure() {
  52949. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  52950. this._docId = docId;
  52951. this._password = password;
  52952. this._docBaseUrl = docBaseUrl;
  52953. this.evaluatorOptions = evaluatorOptions;
  52954. var stream = new Stream(data);
  52955. this.pdfDocument = new PDFDocument(this, stream);
  52956. this._loadedStreamCapability = createPromiseCapability();
  52957. this._loadedStreamCapability.resolve(stream);
  52958. }
  52959. Util.inherit(LocalPdfManager, BasePdfManager, {
  52960. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  52961. return new Promise(function (resolve, reject) {
  52962. try {
  52963. var value = obj[prop];
  52964. var result;
  52965. if (typeof value === 'function') {
  52966. result = value.apply(obj, args);
  52967. } else {
  52968. result = value;
  52969. }
  52970. resolve(result);
  52971. } catch (e) {
  52972. reject(e);
  52973. }
  52974. });
  52975. },
  52976. requestRange: function LocalPdfManager_requestRange(begin, end) {
  52977. return Promise.resolve();
  52978. },
  52979. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  52980. },
  52981. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  52982. return this._loadedStreamCapability.promise;
  52983. },
  52984. terminate: function LocalPdfManager_terminate() {
  52985. }
  52986. });
  52987. return LocalPdfManager;
  52988. }();
  52989. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  52990. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  52991. this._docId = docId;
  52992. this._password = args.password;
  52993. this._docBaseUrl = docBaseUrl;
  52994. this.msgHandler = args.msgHandler;
  52995. this.evaluatorOptions = evaluatorOptions;
  52996. var params = {
  52997. msgHandler: args.msgHandler,
  52998. url: args.url,
  52999. length: args.length,
  53000. disableAutoFetch: args.disableAutoFetch,
  53001. rangeChunkSize: args.rangeChunkSize
  53002. };
  53003. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53004. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53005. }
  53006. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53007. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53008. var pdfManager = this;
  53009. return new Promise(function (resolve, reject) {
  53010. function ensureHelper() {
  53011. try {
  53012. var result;
  53013. var value = obj[prop];
  53014. if (typeof value === 'function') {
  53015. result = value.apply(obj, args);
  53016. } else {
  53017. result = value;
  53018. }
  53019. resolve(result);
  53020. } catch (e) {
  53021. if (!(e instanceof MissingDataException)) {
  53022. reject(e);
  53023. return;
  53024. }
  53025. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53026. }
  53027. }
  53028. ensureHelper();
  53029. });
  53030. },
  53031. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53032. return this.streamManager.requestRange(begin, end);
  53033. },
  53034. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53035. this.streamManager.requestAllChunks();
  53036. },
  53037. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53038. this.streamManager.onReceiveData({ chunk: chunk });
  53039. },
  53040. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53041. return this.streamManager.onLoadedStream();
  53042. },
  53043. terminate: function NetworkPdfManager_terminate() {
  53044. this.streamManager.abort();
  53045. }
  53046. });
  53047. return NetworkPdfManager;
  53048. }();
  53049. exports.LocalPdfManager = LocalPdfManager;
  53050. exports.NetworkPdfManager = NetworkPdfManager;
  53051. /***/ }),
  53052. /* 42 */
  53053. /***/ (function(module, exports, __w_pdfjs_require__) {
  53054. "use strict";
  53055. var sharedUtil = __w_pdfjs_require__(0);
  53056. var corePrimitives = __w_pdfjs_require__(1);
  53057. var error = sharedUtil.error;
  53058. var isSpace = sharedUtil.isSpace;
  53059. var EOF = corePrimitives.EOF;
  53060. var PostScriptParser = function PostScriptParserClosure() {
  53061. function PostScriptParser(lexer) {
  53062. this.lexer = lexer;
  53063. this.operators = [];
  53064. this.token = null;
  53065. this.prev = null;
  53066. }
  53067. PostScriptParser.prototype = {
  53068. nextToken: function PostScriptParser_nextToken() {
  53069. this.prev = this.token;
  53070. this.token = this.lexer.getToken();
  53071. },
  53072. accept: function PostScriptParser_accept(type) {
  53073. if (this.token.type === type) {
  53074. this.nextToken();
  53075. return true;
  53076. }
  53077. return false;
  53078. },
  53079. expect: function PostScriptParser_expect(type) {
  53080. if (this.accept(type)) {
  53081. return true;
  53082. }
  53083. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53084. },
  53085. parse: function PostScriptParser_parse() {
  53086. this.nextToken();
  53087. this.expect(PostScriptTokenTypes.LBRACE);
  53088. this.parseBlock();
  53089. this.expect(PostScriptTokenTypes.RBRACE);
  53090. return this.operators;
  53091. },
  53092. parseBlock: function PostScriptParser_parseBlock() {
  53093. while (true) {
  53094. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53095. this.operators.push(this.prev.value);
  53096. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53097. this.operators.push(this.prev.value);
  53098. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53099. this.parseCondition();
  53100. } else {
  53101. return;
  53102. }
  53103. }
  53104. },
  53105. parseCondition: function PostScriptParser_parseCondition() {
  53106. var conditionLocation = this.operators.length;
  53107. this.operators.push(null, null);
  53108. this.parseBlock();
  53109. this.expect(PostScriptTokenTypes.RBRACE);
  53110. if (this.accept(PostScriptTokenTypes.IF)) {
  53111. this.operators[conditionLocation] = this.operators.length;
  53112. this.operators[conditionLocation + 1] = 'jz';
  53113. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53114. var jumpLocation = this.operators.length;
  53115. this.operators.push(null, null);
  53116. var endOfTrue = this.operators.length;
  53117. this.parseBlock();
  53118. this.expect(PostScriptTokenTypes.RBRACE);
  53119. this.expect(PostScriptTokenTypes.IFELSE);
  53120. this.operators[jumpLocation] = this.operators.length;
  53121. this.operators[jumpLocation + 1] = 'j';
  53122. this.operators[conditionLocation] = endOfTrue;
  53123. this.operators[conditionLocation + 1] = 'jz';
  53124. } else {
  53125. error('PS Function: error parsing conditional.');
  53126. }
  53127. }
  53128. };
  53129. return PostScriptParser;
  53130. }();
  53131. var PostScriptTokenTypes = {
  53132. LBRACE: 0,
  53133. RBRACE: 1,
  53134. NUMBER: 2,
  53135. OPERATOR: 3,
  53136. IF: 4,
  53137. IFELSE: 5
  53138. };
  53139. var PostScriptToken = function PostScriptTokenClosure() {
  53140. function PostScriptToken(type, value) {
  53141. this.type = type;
  53142. this.value = value;
  53143. }
  53144. var opCache = Object.create(null);
  53145. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53146. var opValue = opCache[op];
  53147. if (opValue) {
  53148. return opValue;
  53149. }
  53150. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53151. };
  53152. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53153. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53154. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53155. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53156. return PostScriptToken;
  53157. }();
  53158. var PostScriptLexer = function PostScriptLexerClosure() {
  53159. function PostScriptLexer(stream) {
  53160. this.stream = stream;
  53161. this.nextChar();
  53162. this.strBuf = [];
  53163. }
  53164. PostScriptLexer.prototype = {
  53165. nextChar: function PostScriptLexer_nextChar() {
  53166. return this.currentChar = this.stream.getByte();
  53167. },
  53168. getToken: function PostScriptLexer_getToken() {
  53169. var comment = false;
  53170. var ch = this.currentChar;
  53171. while (true) {
  53172. if (ch < 0) {
  53173. return EOF;
  53174. }
  53175. if (comment) {
  53176. if (ch === 0x0A || ch === 0x0D) {
  53177. comment = false;
  53178. }
  53179. } else if (ch === 0x25) {
  53180. comment = true;
  53181. } else if (!isSpace(ch)) {
  53182. break;
  53183. }
  53184. ch = this.nextChar();
  53185. }
  53186. switch (ch | 0) {
  53187. case 0x30:
  53188. case 0x31:
  53189. case 0x32:
  53190. case 0x33:
  53191. case 0x34:
  53192. case 0x35:
  53193. case 0x36:
  53194. case 0x37:
  53195. case 0x38:
  53196. case 0x39:
  53197. case 0x2B:
  53198. case 0x2D:
  53199. case 0x2E:
  53200. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53201. case 0x7B:
  53202. this.nextChar();
  53203. return PostScriptToken.LBRACE;
  53204. case 0x7D:
  53205. this.nextChar();
  53206. return PostScriptToken.RBRACE;
  53207. }
  53208. var strBuf = this.strBuf;
  53209. strBuf.length = 0;
  53210. strBuf[0] = String.fromCharCode(ch);
  53211. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53212. strBuf.push(String.fromCharCode(ch));
  53213. }
  53214. var str = strBuf.join('');
  53215. switch (str.toLowerCase()) {
  53216. case 'if':
  53217. return PostScriptToken.IF;
  53218. case 'ifelse':
  53219. return PostScriptToken.IFELSE;
  53220. default:
  53221. return PostScriptToken.getOperator(str);
  53222. }
  53223. },
  53224. getNumber: function PostScriptLexer_getNumber() {
  53225. var ch = this.currentChar;
  53226. var strBuf = this.strBuf;
  53227. strBuf.length = 0;
  53228. strBuf[0] = String.fromCharCode(ch);
  53229. while ((ch = this.nextChar()) >= 0) {
  53230. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  53231. strBuf.push(String.fromCharCode(ch));
  53232. } else {
  53233. break;
  53234. }
  53235. }
  53236. var value = parseFloat(strBuf.join(''));
  53237. if (isNaN(value)) {
  53238. error('Invalid floating point number: ' + value);
  53239. }
  53240. return value;
  53241. }
  53242. };
  53243. return PostScriptLexer;
  53244. }();
  53245. exports.PostScriptLexer = PostScriptLexer;
  53246. exports.PostScriptParser = PostScriptParser;
  53247. /***/ }),
  53248. /* 43 */
  53249. /***/ (function(module, exports, __w_pdfjs_require__) {
  53250. "use strict";
  53251. var sharedUtil = __w_pdfjs_require__(0);
  53252. var coreStream = __w_pdfjs_require__(2);
  53253. var coreEncodings = __w_pdfjs_require__(5);
  53254. var warn = sharedUtil.warn;
  53255. var isSpace = sharedUtil.isSpace;
  53256. var Stream = coreStream.Stream;
  53257. var getEncoding = coreEncodings.getEncoding;
  53258. var HINTING_ENABLED = false;
  53259. var Type1CharString = function Type1CharStringClosure() {
  53260. var COMMAND_MAP = {
  53261. 'hstem': [1],
  53262. 'vstem': [3],
  53263. 'vmoveto': [4],
  53264. 'rlineto': [5],
  53265. 'hlineto': [6],
  53266. 'vlineto': [7],
  53267. 'rrcurveto': [8],
  53268. 'callsubr': [10],
  53269. 'flex': [
  53270. 12,
  53271. 35
  53272. ],
  53273. 'drop': [
  53274. 12,
  53275. 18
  53276. ],
  53277. 'endchar': [14],
  53278. 'rmoveto': [21],
  53279. 'hmoveto': [22],
  53280. 'vhcurveto': [30],
  53281. 'hvcurveto': [31]
  53282. };
  53283. function Type1CharString() {
  53284. this.width = 0;
  53285. this.lsb = 0;
  53286. this.flexing = false;
  53287. this.output = [];
  53288. this.stack = [];
  53289. }
  53290. Type1CharString.prototype = {
  53291. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  53292. var count = encoded.length;
  53293. var error = false;
  53294. var wx, sbx, subrNumber;
  53295. for (var i = 0; i < count; i++) {
  53296. var value = encoded[i];
  53297. if (value < 32) {
  53298. if (value === 12) {
  53299. value = (value << 8) + encoded[++i];
  53300. }
  53301. switch (value) {
  53302. case 1:
  53303. if (!HINTING_ENABLED) {
  53304. this.stack = [];
  53305. break;
  53306. }
  53307. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53308. break;
  53309. case 3:
  53310. if (!HINTING_ENABLED) {
  53311. this.stack = [];
  53312. break;
  53313. }
  53314. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53315. break;
  53316. case 4:
  53317. if (this.flexing) {
  53318. if (this.stack.length < 1) {
  53319. error = true;
  53320. break;
  53321. }
  53322. var dy = this.stack.pop();
  53323. this.stack.push(0, dy);
  53324. break;
  53325. }
  53326. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  53327. break;
  53328. case 5:
  53329. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  53330. break;
  53331. case 6:
  53332. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  53333. break;
  53334. case 7:
  53335. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  53336. break;
  53337. case 8:
  53338. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  53339. break;
  53340. case 9:
  53341. this.stack = [];
  53342. break;
  53343. case 10:
  53344. if (this.stack.length < 1) {
  53345. error = true;
  53346. break;
  53347. }
  53348. subrNumber = this.stack.pop();
  53349. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  53350. break;
  53351. case 11:
  53352. return error;
  53353. case 13:
  53354. if (this.stack.length < 2) {
  53355. error = true;
  53356. break;
  53357. }
  53358. wx = this.stack.pop();
  53359. sbx = this.stack.pop();
  53360. this.lsb = sbx;
  53361. this.width = wx;
  53362. this.stack.push(wx, sbx);
  53363. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  53364. break;
  53365. case 14:
  53366. this.output.push(COMMAND_MAP.endchar[0]);
  53367. break;
  53368. case 21:
  53369. if (this.flexing) {
  53370. break;
  53371. }
  53372. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  53373. break;
  53374. case 22:
  53375. if (this.flexing) {
  53376. this.stack.push(0);
  53377. break;
  53378. }
  53379. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  53380. break;
  53381. case 30:
  53382. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  53383. break;
  53384. case 31:
  53385. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  53386. break;
  53387. case (12 << 8) + 0:
  53388. this.stack = [];
  53389. break;
  53390. case (12 << 8) + 1:
  53391. if (!HINTING_ENABLED) {
  53392. this.stack = [];
  53393. break;
  53394. }
  53395. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53396. break;
  53397. case (12 << 8) + 2:
  53398. if (!HINTING_ENABLED) {
  53399. this.stack = [];
  53400. break;
  53401. }
  53402. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53403. break;
  53404. case (12 << 8) + 6:
  53405. if (seacAnalysisEnabled) {
  53406. this.seac = this.stack.splice(-4, 4);
  53407. error = this.executeCommand(0, COMMAND_MAP.endchar);
  53408. } else {
  53409. error = this.executeCommand(4, COMMAND_MAP.endchar);
  53410. }
  53411. break;
  53412. case (12 << 8) + 7:
  53413. if (this.stack.length < 4) {
  53414. error = true;
  53415. break;
  53416. }
  53417. this.stack.pop();
  53418. wx = this.stack.pop();
  53419. var sby = this.stack.pop();
  53420. sbx = this.stack.pop();
  53421. this.lsb = sbx;
  53422. this.width = wx;
  53423. this.stack.push(wx, sbx, sby);
  53424. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  53425. break;
  53426. case (12 << 8) + 12:
  53427. if (this.stack.length < 2) {
  53428. error = true;
  53429. break;
  53430. }
  53431. var num2 = this.stack.pop();
  53432. var num1 = this.stack.pop();
  53433. this.stack.push(num1 / num2);
  53434. break;
  53435. case (12 << 8) + 16:
  53436. if (this.stack.length < 2) {
  53437. error = true;
  53438. break;
  53439. }
  53440. subrNumber = this.stack.pop();
  53441. var numArgs = this.stack.pop();
  53442. if (subrNumber === 0 && numArgs === 3) {
  53443. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  53444. 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]);
  53445. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  53446. this.flexing = false;
  53447. this.stack.push(flexArgs[15], flexArgs[16]);
  53448. } else if (subrNumber === 1 && numArgs === 0) {
  53449. this.flexing = true;
  53450. }
  53451. break;
  53452. case (12 << 8) + 17:
  53453. break;
  53454. case (12 << 8) + 33:
  53455. this.stack = [];
  53456. break;
  53457. default:
  53458. warn('Unknown type 1 charstring command of "' + value + '"');
  53459. break;
  53460. }
  53461. if (error) {
  53462. break;
  53463. }
  53464. continue;
  53465. } else if (value <= 246) {
  53466. value = value - 139;
  53467. } else if (value <= 250) {
  53468. value = (value - 247) * 256 + encoded[++i] + 108;
  53469. } else if (value <= 254) {
  53470. value = -((value - 251) * 256) - encoded[++i] - 108;
  53471. } else {
  53472. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  53473. }
  53474. this.stack.push(value);
  53475. }
  53476. return error;
  53477. },
  53478. executeCommand: function (howManyArgs, command, keepStack) {
  53479. var stackLength = this.stack.length;
  53480. if (howManyArgs > stackLength) {
  53481. return true;
  53482. }
  53483. var start = stackLength - howManyArgs;
  53484. for (var i = start; i < stackLength; i++) {
  53485. var value = this.stack[i];
  53486. if (value === (value | 0)) {
  53487. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  53488. } else {
  53489. value = 65536 * value | 0;
  53490. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  53491. }
  53492. }
  53493. this.output.push.apply(this.output, command);
  53494. if (keepStack) {
  53495. this.stack.splice(start, howManyArgs);
  53496. } else {
  53497. this.stack.length = 0;
  53498. }
  53499. return false;
  53500. }
  53501. };
  53502. return Type1CharString;
  53503. }();
  53504. var Type1Parser = function Type1ParserClosure() {
  53505. var EEXEC_ENCRYPT_KEY = 55665;
  53506. var CHAR_STRS_ENCRYPT_KEY = 4330;
  53507. function isHexDigit(code) {
  53508. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  53509. }
  53510. function decrypt(data, key, discardNumber) {
  53511. if (discardNumber >= data.length) {
  53512. return new Uint8Array(0);
  53513. }
  53514. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  53515. for (i = 0; i < discardNumber; i++) {
  53516. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  53517. }
  53518. var count = data.length - discardNumber;
  53519. var decrypted = new Uint8Array(count);
  53520. for (i = discardNumber, j = 0; j < count; i++, j++) {
  53521. var value = data[i];
  53522. decrypted[j] = value ^ r >> 8;
  53523. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53524. }
  53525. return decrypted;
  53526. }
  53527. function decryptAscii(data, key, discardNumber) {
  53528. var r = key | 0, c1 = 52845, c2 = 22719;
  53529. var count = data.length, maybeLength = count >>> 1;
  53530. var decrypted = new Uint8Array(maybeLength);
  53531. var i, j;
  53532. for (i = 0, j = 0; i < count; i++) {
  53533. var digit1 = data[i];
  53534. if (!isHexDigit(digit1)) {
  53535. continue;
  53536. }
  53537. i++;
  53538. var digit2;
  53539. while (i < count && !isHexDigit(digit2 = data[i])) {
  53540. i++;
  53541. }
  53542. if (i < count) {
  53543. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  53544. decrypted[j++] = value ^ r >> 8;
  53545. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53546. }
  53547. }
  53548. return Array.prototype.slice.call(decrypted, discardNumber, j);
  53549. }
  53550. function isSpecial(c) {
  53551. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  53552. }
  53553. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  53554. if (encrypted) {
  53555. var data = stream.getBytes();
  53556. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  53557. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  53558. }
  53559. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  53560. this.stream = stream;
  53561. this.nextChar();
  53562. }
  53563. Type1Parser.prototype = {
  53564. readNumberArray: function Type1Parser_readNumberArray() {
  53565. this.getToken();
  53566. var array = [];
  53567. while (true) {
  53568. var token = this.getToken();
  53569. if (token === null || token === ']' || token === '}') {
  53570. break;
  53571. }
  53572. array.push(parseFloat(token || 0));
  53573. }
  53574. return array;
  53575. },
  53576. readNumber: function Type1Parser_readNumber() {
  53577. var token = this.getToken();
  53578. return parseFloat(token || 0);
  53579. },
  53580. readInt: function Type1Parser_readInt() {
  53581. var token = this.getToken();
  53582. return parseInt(token || 0, 10) | 0;
  53583. },
  53584. readBoolean: function Type1Parser_readBoolean() {
  53585. var token = this.getToken();
  53586. return token === 'true' ? 1 : 0;
  53587. },
  53588. nextChar: function Type1_nextChar() {
  53589. return this.currentChar = this.stream.getByte();
  53590. },
  53591. getToken: function Type1Parser_getToken() {
  53592. var comment = false;
  53593. var ch = this.currentChar;
  53594. while (true) {
  53595. if (ch === -1) {
  53596. return null;
  53597. }
  53598. if (comment) {
  53599. if (ch === 0x0A || ch === 0x0D) {
  53600. comment = false;
  53601. }
  53602. } else if (ch === 0x25) {
  53603. comment = true;
  53604. } else if (!isSpace(ch)) {
  53605. break;
  53606. }
  53607. ch = this.nextChar();
  53608. }
  53609. if (isSpecial(ch)) {
  53610. this.nextChar();
  53611. return String.fromCharCode(ch);
  53612. }
  53613. var token = '';
  53614. do {
  53615. token += String.fromCharCode(ch);
  53616. ch = this.nextChar();
  53617. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  53618. return token;
  53619. },
  53620. extractFontProgram: function Type1Parser_extractFontProgram() {
  53621. var stream = this.stream;
  53622. var subrs = [], charstrings = [];
  53623. var privateData = Object.create(null);
  53624. privateData['lenIV'] = 4;
  53625. var program = {
  53626. subrs: [],
  53627. charstrings: [],
  53628. properties: { 'privateData': privateData }
  53629. };
  53630. var token, length, data, lenIV, encoded;
  53631. while ((token = this.getToken()) !== null) {
  53632. if (token !== '/') {
  53633. continue;
  53634. }
  53635. token = this.getToken();
  53636. switch (token) {
  53637. case 'CharStrings':
  53638. this.getToken();
  53639. this.getToken();
  53640. this.getToken();
  53641. this.getToken();
  53642. while (true) {
  53643. token = this.getToken();
  53644. if (token === null || token === 'end') {
  53645. break;
  53646. }
  53647. if (token !== '/') {
  53648. continue;
  53649. }
  53650. var glyph = this.getToken();
  53651. length = this.readInt();
  53652. this.getToken();
  53653. data = stream.makeSubStream(stream.pos, length);
  53654. lenIV = program.properties.privateData['lenIV'];
  53655. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53656. stream.skip(length);
  53657. this.nextChar();
  53658. token = this.getToken();
  53659. if (token === 'noaccess') {
  53660. this.getToken();
  53661. }
  53662. charstrings.push({
  53663. glyph: glyph,
  53664. encoded: encoded
  53665. });
  53666. }
  53667. break;
  53668. case 'Subrs':
  53669. this.readInt();
  53670. this.getToken();
  53671. while ((token = this.getToken()) === 'dup') {
  53672. var index = this.readInt();
  53673. length = this.readInt();
  53674. this.getToken();
  53675. data = stream.makeSubStream(stream.pos, length);
  53676. lenIV = program.properties.privateData['lenIV'];
  53677. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53678. stream.skip(length);
  53679. this.nextChar();
  53680. token = this.getToken();
  53681. if (token === 'noaccess') {
  53682. this.getToken();
  53683. }
  53684. subrs[index] = encoded;
  53685. }
  53686. break;
  53687. case 'BlueValues':
  53688. case 'OtherBlues':
  53689. case 'FamilyBlues':
  53690. case 'FamilyOtherBlues':
  53691. var blueArray = this.readNumberArray();
  53692. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  53693. program.properties.privateData[token] = blueArray;
  53694. }
  53695. break;
  53696. case 'StemSnapH':
  53697. case 'StemSnapV':
  53698. program.properties.privateData[token] = this.readNumberArray();
  53699. break;
  53700. case 'StdHW':
  53701. case 'StdVW':
  53702. program.properties.privateData[token] = this.readNumberArray()[0];
  53703. break;
  53704. case 'BlueShift':
  53705. case 'lenIV':
  53706. case 'BlueFuzz':
  53707. case 'BlueScale':
  53708. case 'LanguageGroup':
  53709. case 'ExpansionFactor':
  53710. program.properties.privateData[token] = this.readNumber();
  53711. break;
  53712. case 'ForceBold':
  53713. program.properties.privateData[token] = this.readBoolean();
  53714. break;
  53715. }
  53716. }
  53717. for (var i = 0; i < charstrings.length; i++) {
  53718. glyph = charstrings[i].glyph;
  53719. encoded = charstrings[i].encoded;
  53720. var charString = new Type1CharString();
  53721. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  53722. var output = charString.output;
  53723. if (error) {
  53724. output = [14];
  53725. }
  53726. program.charstrings.push({
  53727. glyphName: glyph,
  53728. charstring: output,
  53729. width: charString.width,
  53730. lsb: charString.lsb,
  53731. seac: charString.seac
  53732. });
  53733. }
  53734. return program;
  53735. },
  53736. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  53737. var token;
  53738. while ((token = this.getToken()) !== null) {
  53739. if (token !== '/') {
  53740. continue;
  53741. }
  53742. token = this.getToken();
  53743. switch (token) {
  53744. case 'FontMatrix':
  53745. var matrix = this.readNumberArray();
  53746. properties.fontMatrix = matrix;
  53747. break;
  53748. case 'Encoding':
  53749. var encodingArg = this.getToken();
  53750. var encoding;
  53751. if (!/^\d+$/.test(encodingArg)) {
  53752. encoding = getEncoding(encodingArg);
  53753. } else {
  53754. encoding = [];
  53755. var size = parseInt(encodingArg, 10) | 0;
  53756. this.getToken();
  53757. for (var j = 0; j < size; j++) {
  53758. token = this.getToken();
  53759. while (token !== 'dup' && token !== 'def') {
  53760. token = this.getToken();
  53761. if (token === null) {
  53762. return;
  53763. }
  53764. }
  53765. if (token === 'def') {
  53766. break;
  53767. }
  53768. var index = this.readInt();
  53769. this.getToken();
  53770. var glyph = this.getToken();
  53771. encoding[index] = glyph;
  53772. this.getToken();
  53773. }
  53774. }
  53775. properties.builtInEncoding = encoding;
  53776. break;
  53777. case 'FontBBox':
  53778. var fontBBox = this.readNumberArray();
  53779. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  53780. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  53781. properties.ascentScaled = true;
  53782. break;
  53783. }
  53784. }
  53785. }
  53786. };
  53787. return Type1Parser;
  53788. }();
  53789. exports.Type1Parser = Type1Parser;
  53790. /***/ }),
  53791. /* 44 */
  53792. /***/ (function(module, exports, __w_pdfjs_require__) {
  53793. "use strict";
  53794. var sharedUtil = __w_pdfjs_require__(0);
  53795. var displayDOMUtils = __w_pdfjs_require__(3);
  53796. var displayPatternHelper = __w_pdfjs_require__(46);
  53797. var displayWebGL = __w_pdfjs_require__(25);
  53798. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  53799. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  53800. var ImageKind = sharedUtil.ImageKind;
  53801. var OPS = sharedUtil.OPS;
  53802. var TextRenderingMode = sharedUtil.TextRenderingMode;
  53803. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  53804. var Util = sharedUtil.Util;
  53805. var assert = sharedUtil.assert;
  53806. var info = sharedUtil.info;
  53807. var isNum = sharedUtil.isNum;
  53808. var isArray = sharedUtil.isArray;
  53809. var isLittleEndian = sharedUtil.isLittleEndian;
  53810. var error = sharedUtil.error;
  53811. var shadow = sharedUtil.shadow;
  53812. var warn = sharedUtil.warn;
  53813. var TilingPattern = displayPatternHelper.TilingPattern;
  53814. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  53815. var WebGLUtils = displayWebGL.WebGLUtils;
  53816. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  53817. var MIN_FONT_SIZE = 16;
  53818. var MAX_FONT_SIZE = 100;
  53819. var MAX_GROUP_SIZE = 4096;
  53820. var MIN_WIDTH_FACTOR = 0.65;
  53821. var COMPILE_TYPE3_GLYPHS = true;
  53822. var MAX_SIZE_TO_COMPILE = 1000;
  53823. var FULL_CHUNK_HEIGHT = 16;
  53824. var HasCanvasTypedArraysCached = {
  53825. get value() {
  53826. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  53827. }
  53828. };
  53829. var IsLittleEndianCached = {
  53830. get value() {
  53831. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  53832. }
  53833. };
  53834. function addContextCurrentTransform(ctx) {
  53835. if (!ctx.mozCurrentTransform) {
  53836. ctx._originalSave = ctx.save;
  53837. ctx._originalRestore = ctx.restore;
  53838. ctx._originalRotate = ctx.rotate;
  53839. ctx._originalScale = ctx.scale;
  53840. ctx._originalTranslate = ctx.translate;
  53841. ctx._originalTransform = ctx.transform;
  53842. ctx._originalSetTransform = ctx.setTransform;
  53843. ctx._transformMatrix = ctx._transformMatrix || [
  53844. 1,
  53845. 0,
  53846. 0,
  53847. 1,
  53848. 0,
  53849. 0
  53850. ];
  53851. ctx._transformStack = [];
  53852. Object.defineProperty(ctx, 'mozCurrentTransform', {
  53853. get: function getCurrentTransform() {
  53854. return this._transformMatrix;
  53855. }
  53856. });
  53857. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  53858. get: function getCurrentTransformInverse() {
  53859. var m = this._transformMatrix;
  53860. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  53861. var ad_bc = a * d - b * c;
  53862. var bc_ad = b * c - a * d;
  53863. return [
  53864. d / ad_bc,
  53865. b / bc_ad,
  53866. c / bc_ad,
  53867. a / ad_bc,
  53868. (d * e - c * f) / bc_ad,
  53869. (b * e - a * f) / ad_bc
  53870. ];
  53871. }
  53872. });
  53873. ctx.save = function ctxSave() {
  53874. var old = this._transformMatrix;
  53875. this._transformStack.push(old);
  53876. this._transformMatrix = old.slice(0, 6);
  53877. this._originalSave();
  53878. };
  53879. ctx.restore = function ctxRestore() {
  53880. var prev = this._transformStack.pop();
  53881. if (prev) {
  53882. this._transformMatrix = prev;
  53883. this._originalRestore();
  53884. }
  53885. };
  53886. ctx.translate = function ctxTranslate(x, y) {
  53887. var m = this._transformMatrix;
  53888. m[4] = m[0] * x + m[2] * y + m[4];
  53889. m[5] = m[1] * x + m[3] * y + m[5];
  53890. this._originalTranslate(x, y);
  53891. };
  53892. ctx.scale = function ctxScale(x, y) {
  53893. var m = this._transformMatrix;
  53894. m[0] = m[0] * x;
  53895. m[1] = m[1] * x;
  53896. m[2] = m[2] * y;
  53897. m[3] = m[3] * y;
  53898. this._originalScale(x, y);
  53899. };
  53900. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  53901. var m = this._transformMatrix;
  53902. this._transformMatrix = [
  53903. m[0] * a + m[2] * b,
  53904. m[1] * a + m[3] * b,
  53905. m[0] * c + m[2] * d,
  53906. m[1] * c + m[3] * d,
  53907. m[0] * e + m[2] * f + m[4],
  53908. m[1] * e + m[3] * f + m[5]
  53909. ];
  53910. ctx._originalTransform(a, b, c, d, e, f);
  53911. };
  53912. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  53913. this._transformMatrix = [
  53914. a,
  53915. b,
  53916. c,
  53917. d,
  53918. e,
  53919. f
  53920. ];
  53921. ctx._originalSetTransform(a, b, c, d, e, f);
  53922. };
  53923. ctx.rotate = function ctxRotate(angle) {
  53924. var cosValue = Math.cos(angle);
  53925. var sinValue = Math.sin(angle);
  53926. var m = this._transformMatrix;
  53927. this._transformMatrix = [
  53928. m[0] * cosValue + m[2] * sinValue,
  53929. m[1] * cosValue + m[3] * sinValue,
  53930. m[0] * -sinValue + m[2] * cosValue,
  53931. m[1] * -sinValue + m[3] * cosValue,
  53932. m[4],
  53933. m[5]
  53934. ];
  53935. this._originalRotate(angle);
  53936. };
  53937. }
  53938. }
  53939. var CachedCanvases = function CachedCanvasesClosure() {
  53940. function CachedCanvases(canvasFactory) {
  53941. this.canvasFactory = canvasFactory;
  53942. this.cache = Object.create(null);
  53943. }
  53944. CachedCanvases.prototype = {
  53945. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  53946. var canvasEntry;
  53947. if (this.cache[id] !== undefined) {
  53948. canvasEntry = this.cache[id];
  53949. this.canvasFactory.reset(canvasEntry, width, height);
  53950. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  53951. } else {
  53952. canvasEntry = this.canvasFactory.create(width, height);
  53953. this.cache[id] = canvasEntry;
  53954. }
  53955. if (trackTransform) {
  53956. addContextCurrentTransform(canvasEntry.context);
  53957. }
  53958. return canvasEntry;
  53959. },
  53960. clear: function () {
  53961. for (var id in this.cache) {
  53962. var canvasEntry = this.cache[id];
  53963. this.canvasFactory.destroy(canvasEntry);
  53964. delete this.cache[id];
  53965. }
  53966. }
  53967. };
  53968. return CachedCanvases;
  53969. }();
  53970. function compileType3Glyph(imgData) {
  53971. var POINT_TO_PROCESS_LIMIT = 1000;
  53972. var width = imgData.width, height = imgData.height;
  53973. var i, j, j0, width1 = width + 1;
  53974. var points = new Uint8Array(width1 * (height + 1));
  53975. var POINT_TYPES = new Uint8Array([
  53976. 0,
  53977. 2,
  53978. 4,
  53979. 0,
  53980. 1,
  53981. 0,
  53982. 5,
  53983. 4,
  53984. 8,
  53985. 10,
  53986. 0,
  53987. 8,
  53988. 0,
  53989. 2,
  53990. 1,
  53991. 0
  53992. ]);
  53993. var lineSize = width + 7 & ~7, data0 = imgData.data;
  53994. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  53995. for (i = 0, ii = data0.length; i < ii; i++) {
  53996. var mask = 128, elem = data0[i];
  53997. while (mask > 0) {
  53998. data[pos++] = elem & mask ? 0 : 255;
  53999. mask >>= 1;
  54000. }
  54001. }
  54002. var count = 0;
  54003. pos = 0;
  54004. if (data[pos] !== 0) {
  54005. points[0] = 1;
  54006. ++count;
  54007. }
  54008. for (j = 1; j < width; j++) {
  54009. if (data[pos] !== data[pos + 1]) {
  54010. points[j] = data[pos] ? 2 : 1;
  54011. ++count;
  54012. }
  54013. pos++;
  54014. }
  54015. if (data[pos] !== 0) {
  54016. points[j] = 2;
  54017. ++count;
  54018. }
  54019. for (i = 1; i < height; i++) {
  54020. pos = i * lineSize;
  54021. j0 = i * width1;
  54022. if (data[pos - lineSize] !== data[pos]) {
  54023. points[j0] = data[pos] ? 1 : 8;
  54024. ++count;
  54025. }
  54026. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54027. for (j = 1; j < width; j++) {
  54028. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54029. if (POINT_TYPES[sum]) {
  54030. points[j0 + j] = POINT_TYPES[sum];
  54031. ++count;
  54032. }
  54033. pos++;
  54034. }
  54035. if (data[pos - lineSize] !== data[pos]) {
  54036. points[j0 + j] = data[pos] ? 2 : 4;
  54037. ++count;
  54038. }
  54039. if (count > POINT_TO_PROCESS_LIMIT) {
  54040. return null;
  54041. }
  54042. }
  54043. pos = lineSize * (height - 1);
  54044. j0 = i * width1;
  54045. if (data[pos] !== 0) {
  54046. points[j0] = 8;
  54047. ++count;
  54048. }
  54049. for (j = 1; j < width; j++) {
  54050. if (data[pos] !== data[pos + 1]) {
  54051. points[j0 + j] = data[pos] ? 4 : 8;
  54052. ++count;
  54053. }
  54054. pos++;
  54055. }
  54056. if (data[pos] !== 0) {
  54057. points[j0 + j] = 4;
  54058. ++count;
  54059. }
  54060. if (count > POINT_TO_PROCESS_LIMIT) {
  54061. return null;
  54062. }
  54063. var steps = new Int32Array([
  54064. 0,
  54065. width1,
  54066. -1,
  54067. 0,
  54068. -width1,
  54069. 0,
  54070. 0,
  54071. 0,
  54072. 1
  54073. ]);
  54074. var outlines = [];
  54075. for (i = 0; count && i <= height; i++) {
  54076. var p = i * width1;
  54077. var end = p + width;
  54078. while (p < end && !points[p]) {
  54079. p++;
  54080. }
  54081. if (p === end) {
  54082. continue;
  54083. }
  54084. var coords = [
  54085. p % width1,
  54086. i
  54087. ];
  54088. var type = points[p], p0 = p, pp;
  54089. do {
  54090. var step = steps[type];
  54091. do {
  54092. p += step;
  54093. } while (!points[p]);
  54094. pp = points[p];
  54095. if (pp !== 5 && pp !== 10) {
  54096. type = pp;
  54097. points[p] = 0;
  54098. } else {
  54099. type = pp & 0x33 * type >> 4;
  54100. points[p] &= type >> 2 | type << 2;
  54101. }
  54102. coords.push(p % width1);
  54103. coords.push(p / width1 | 0);
  54104. --count;
  54105. } while (p0 !== p);
  54106. outlines.push(coords);
  54107. --i;
  54108. }
  54109. var drawOutline = function (c) {
  54110. c.save();
  54111. c.scale(1 / width, -1 / height);
  54112. c.translate(0, -height);
  54113. c.beginPath();
  54114. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54115. var o = outlines[i];
  54116. c.moveTo(o[0], o[1]);
  54117. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54118. c.lineTo(o[j], o[j + 1]);
  54119. }
  54120. }
  54121. c.fill();
  54122. c.beginPath();
  54123. c.restore();
  54124. };
  54125. return drawOutline;
  54126. }
  54127. var CanvasExtraState = function CanvasExtraStateClosure() {
  54128. function CanvasExtraState(old) {
  54129. this.alphaIsShape = false;
  54130. this.fontSize = 0;
  54131. this.fontSizeScale = 1;
  54132. this.textMatrix = IDENTITY_MATRIX;
  54133. this.textMatrixScale = 1;
  54134. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54135. this.leading = 0;
  54136. this.x = 0;
  54137. this.y = 0;
  54138. this.lineX = 0;
  54139. this.lineY = 0;
  54140. this.charSpacing = 0;
  54141. this.wordSpacing = 0;
  54142. this.textHScale = 1;
  54143. this.textRenderingMode = TextRenderingMode.FILL;
  54144. this.textRise = 0;
  54145. this.fillColor = '#000000';
  54146. this.strokeColor = '#000000';
  54147. this.patternFill = false;
  54148. this.fillAlpha = 1;
  54149. this.strokeAlpha = 1;
  54150. this.lineWidth = 1;
  54151. this.activeSMask = null;
  54152. this.resumeSMaskCtx = null;
  54153. this.old = old;
  54154. }
  54155. CanvasExtraState.prototype = {
  54156. clone: function CanvasExtraState_clone() {
  54157. return Object.create(this);
  54158. },
  54159. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54160. this.x = x;
  54161. this.y = y;
  54162. }
  54163. };
  54164. return CanvasExtraState;
  54165. }();
  54166. var CanvasGraphics = function CanvasGraphicsClosure() {
  54167. var EXECUTION_TIME = 15;
  54168. var EXECUTION_STEPS = 10;
  54169. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54170. this.ctx = canvasCtx;
  54171. this.current = new CanvasExtraState();
  54172. this.stateStack = [];
  54173. this.pendingClip = null;
  54174. this.pendingEOFill = false;
  54175. this.res = null;
  54176. this.xobjs = null;
  54177. this.commonObjs = commonObjs;
  54178. this.objs = objs;
  54179. this.canvasFactory = canvasFactory;
  54180. this.imageLayer = imageLayer;
  54181. this.groupStack = [];
  54182. this.processingType3 = null;
  54183. this.baseTransform = null;
  54184. this.baseTransformStack = [];
  54185. this.groupLevel = 0;
  54186. this.smaskStack = [];
  54187. this.smaskCounter = 0;
  54188. this.tempSMask = null;
  54189. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54190. if (canvasCtx) {
  54191. addContextCurrentTransform(canvasCtx);
  54192. }
  54193. this.cachedGetSinglePixelWidth = null;
  54194. }
  54195. function putBinaryImageData(ctx, imgData) {
  54196. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54197. ctx.putImageData(imgData, 0, 0);
  54198. return;
  54199. }
  54200. var height = imgData.height, width = imgData.width;
  54201. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54202. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54203. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54204. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54205. var srcPos = 0, destPos;
  54206. var src = imgData.data;
  54207. var dest = chunkImgData.data;
  54208. var i, j, thisChunkHeight, elemsInThisChunk;
  54209. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54210. var srcLength = src.byteLength;
  54211. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54212. var dest32DataLength = dest32.length;
  54213. var fullSrcDiff = width + 7 >> 3;
  54214. var white = 0xFFFFFFFF;
  54215. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54216. for (i = 0; i < totalChunks; i++) {
  54217. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54218. destPos = 0;
  54219. for (j = 0; j < thisChunkHeight; j++) {
  54220. var srcDiff = srcLength - srcPos;
  54221. var k = 0;
  54222. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54223. var kEndUnrolled = kEnd & ~7;
  54224. var mask = 0;
  54225. var srcByte = 0;
  54226. for (; k < kEndUnrolled; k += 8) {
  54227. srcByte = src[srcPos++];
  54228. dest32[destPos++] = srcByte & 128 ? white : black;
  54229. dest32[destPos++] = srcByte & 64 ? white : black;
  54230. dest32[destPos++] = srcByte & 32 ? white : black;
  54231. dest32[destPos++] = srcByte & 16 ? white : black;
  54232. dest32[destPos++] = srcByte & 8 ? white : black;
  54233. dest32[destPos++] = srcByte & 4 ? white : black;
  54234. dest32[destPos++] = srcByte & 2 ? white : black;
  54235. dest32[destPos++] = srcByte & 1 ? white : black;
  54236. }
  54237. for (; k < kEnd; k++) {
  54238. if (mask === 0) {
  54239. srcByte = src[srcPos++];
  54240. mask = 128;
  54241. }
  54242. dest32[destPos++] = srcByte & mask ? white : black;
  54243. mask >>= 1;
  54244. }
  54245. }
  54246. while (destPos < dest32DataLength) {
  54247. dest32[destPos++] = 0;
  54248. }
  54249. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54250. }
  54251. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  54252. j = 0;
  54253. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  54254. for (i = 0; i < fullChunks; i++) {
  54255. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54256. srcPos += elemsInThisChunk;
  54257. ctx.putImageData(chunkImgData, 0, j);
  54258. j += FULL_CHUNK_HEIGHT;
  54259. }
  54260. if (i < totalChunks) {
  54261. elemsInThisChunk = width * partialChunkHeight * 4;
  54262. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54263. ctx.putImageData(chunkImgData, 0, j);
  54264. }
  54265. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  54266. thisChunkHeight = FULL_CHUNK_HEIGHT;
  54267. elemsInThisChunk = width * thisChunkHeight;
  54268. for (i = 0; i < totalChunks; i++) {
  54269. if (i >= fullChunks) {
  54270. thisChunkHeight = partialChunkHeight;
  54271. elemsInThisChunk = width * thisChunkHeight;
  54272. }
  54273. destPos = 0;
  54274. for (j = elemsInThisChunk; j--;) {
  54275. dest[destPos++] = src[srcPos++];
  54276. dest[destPos++] = src[srcPos++];
  54277. dest[destPos++] = src[srcPos++];
  54278. dest[destPos++] = 255;
  54279. }
  54280. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54281. }
  54282. } else {
  54283. error('bad image kind: ' + imgData.kind);
  54284. }
  54285. }
  54286. function putBinaryImageMask(ctx, imgData) {
  54287. var height = imgData.height, width = imgData.width;
  54288. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54289. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54290. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54291. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54292. var srcPos = 0;
  54293. var src = imgData.data;
  54294. var dest = chunkImgData.data;
  54295. for (var i = 0; i < totalChunks; i++) {
  54296. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54297. var destPos = 3;
  54298. for (var j = 0; j < thisChunkHeight; j++) {
  54299. var mask = 0;
  54300. for (var k = 0; k < width; k++) {
  54301. if (!mask) {
  54302. var elem = src[srcPos++];
  54303. mask = 128;
  54304. }
  54305. dest[destPos] = elem & mask ? 0 : 255;
  54306. destPos += 4;
  54307. mask >>= 1;
  54308. }
  54309. }
  54310. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54311. }
  54312. }
  54313. function copyCtxState(sourceCtx, destCtx) {
  54314. var properties = [
  54315. 'strokeStyle',
  54316. 'fillStyle',
  54317. 'fillRule',
  54318. 'globalAlpha',
  54319. 'lineWidth',
  54320. 'lineCap',
  54321. 'lineJoin',
  54322. 'miterLimit',
  54323. 'globalCompositeOperation',
  54324. 'font'
  54325. ];
  54326. for (var i = 0, ii = properties.length; i < ii; i++) {
  54327. var property = properties[i];
  54328. if (sourceCtx[property] !== undefined) {
  54329. destCtx[property] = sourceCtx[property];
  54330. }
  54331. }
  54332. if (sourceCtx.setLineDash !== undefined) {
  54333. destCtx.setLineDash(sourceCtx.getLineDash());
  54334. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  54335. }
  54336. }
  54337. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  54338. var length = bytes.length;
  54339. for (var i = 3; i < length; i += 4) {
  54340. var alpha = bytes[i];
  54341. if (alpha === 0) {
  54342. bytes[i - 3] = r0;
  54343. bytes[i - 2] = g0;
  54344. bytes[i - 1] = b0;
  54345. } else if (alpha < 255) {
  54346. var alpha_ = 255 - alpha;
  54347. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  54348. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  54349. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  54350. }
  54351. }
  54352. }
  54353. function composeSMaskAlpha(maskData, layerData, transferMap) {
  54354. var length = maskData.length;
  54355. var scale = 1 / 255;
  54356. for (var i = 3; i < length; i += 4) {
  54357. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  54358. layerData[i] = layerData[i] * alpha * scale | 0;
  54359. }
  54360. }
  54361. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  54362. var length = maskData.length;
  54363. for (var i = 3; i < length; i += 4) {
  54364. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  54365. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  54366. }
  54367. }
  54368. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  54369. var hasBackdrop = !!backdrop;
  54370. var r0 = hasBackdrop ? backdrop[0] : 0;
  54371. var g0 = hasBackdrop ? backdrop[1] : 0;
  54372. var b0 = hasBackdrop ? backdrop[2] : 0;
  54373. var composeFn;
  54374. if (subtype === 'Luminosity') {
  54375. composeFn = composeSMaskLuminosity;
  54376. } else {
  54377. composeFn = composeSMaskAlpha;
  54378. }
  54379. var PIXELS_TO_PROCESS = 1048576;
  54380. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  54381. for (var row = 0; row < height; row += chunkSize) {
  54382. var chunkHeight = Math.min(chunkSize, height - row);
  54383. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  54384. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  54385. if (hasBackdrop) {
  54386. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  54387. }
  54388. composeFn(maskData.data, layerData.data, transferMap);
  54389. maskCtx.putImageData(layerData, 0, row);
  54390. }
  54391. }
  54392. function composeSMask(ctx, smask, layerCtx) {
  54393. var mask = smask.canvas;
  54394. var maskCtx = smask.context;
  54395. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  54396. var backdrop = smask.backdrop || null;
  54397. if (!smask.transferMap && WebGLUtils.isEnabled) {
  54398. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  54399. subtype: smask.subtype,
  54400. backdrop: backdrop
  54401. });
  54402. ctx.setTransform(1, 0, 0, 1, 0, 0);
  54403. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  54404. return;
  54405. }
  54406. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  54407. ctx.drawImage(mask, 0, 0);
  54408. }
  54409. var LINE_CAP_STYLES = [
  54410. 'butt',
  54411. 'round',
  54412. 'square'
  54413. ];
  54414. var LINE_JOIN_STYLES = [
  54415. 'miter',
  54416. 'round',
  54417. 'bevel'
  54418. ];
  54419. var NORMAL_CLIP = {};
  54420. var EO_CLIP = {};
  54421. CanvasGraphics.prototype = {
  54422. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  54423. var width = this.ctx.canvas.width;
  54424. var height = this.ctx.canvas.height;
  54425. this.ctx.save();
  54426. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  54427. this.ctx.fillRect(0, 0, width, height);
  54428. this.ctx.restore();
  54429. if (transparency) {
  54430. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  54431. this.compositeCtx = this.ctx;
  54432. this.transparentCanvas = transparentCanvas.canvas;
  54433. this.ctx = transparentCanvas.context;
  54434. this.ctx.save();
  54435. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  54436. }
  54437. this.ctx.save();
  54438. if (transform) {
  54439. this.ctx.transform.apply(this.ctx, transform);
  54440. }
  54441. this.ctx.transform.apply(this.ctx, viewport.transform);
  54442. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  54443. if (this.imageLayer) {
  54444. this.imageLayer.beginLayout();
  54445. }
  54446. },
  54447. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  54448. var argsArray = operatorList.argsArray;
  54449. var fnArray = operatorList.fnArray;
  54450. var i = executionStartIdx || 0;
  54451. var argsArrayLen = argsArray.length;
  54452. if (argsArrayLen === i) {
  54453. return i;
  54454. }
  54455. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  54456. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  54457. var steps = 0;
  54458. var commonObjs = this.commonObjs;
  54459. var objs = this.objs;
  54460. var fnId;
  54461. while (true) {
  54462. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  54463. stepper.breakIt(i, continueCallback);
  54464. return i;
  54465. }
  54466. fnId = fnArray[i];
  54467. if (fnId !== OPS.dependency) {
  54468. this[fnId].apply(this, argsArray[i]);
  54469. } else {
  54470. var deps = argsArray[i];
  54471. for (var n = 0, nn = deps.length; n < nn; n++) {
  54472. var depObjId = deps[n];
  54473. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  54474. var objsPool = common ? commonObjs : objs;
  54475. if (!objsPool.isResolved(depObjId)) {
  54476. objsPool.get(depObjId, continueCallback);
  54477. return i;
  54478. }
  54479. }
  54480. }
  54481. i++;
  54482. if (i === argsArrayLen) {
  54483. return i;
  54484. }
  54485. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  54486. if (Date.now() > endTime) {
  54487. continueCallback();
  54488. return i;
  54489. }
  54490. steps = 0;
  54491. }
  54492. }
  54493. },
  54494. endDrawing: function CanvasGraphics_endDrawing() {
  54495. if (this.current.activeSMask !== null) {
  54496. this.endSMaskGroup();
  54497. }
  54498. this.ctx.restore();
  54499. if (this.transparentCanvas) {
  54500. this.ctx = this.compositeCtx;
  54501. this.ctx.save();
  54502. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  54503. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  54504. this.ctx.restore();
  54505. this.transparentCanvas = null;
  54506. }
  54507. this.cachedCanvases.clear();
  54508. WebGLUtils.clear();
  54509. if (this.imageLayer) {
  54510. this.imageLayer.endLayout();
  54511. }
  54512. },
  54513. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  54514. this.current.lineWidth = width;
  54515. this.ctx.lineWidth = width;
  54516. },
  54517. setLineCap: function CanvasGraphics_setLineCap(style) {
  54518. this.ctx.lineCap = LINE_CAP_STYLES[style];
  54519. },
  54520. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  54521. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  54522. },
  54523. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  54524. this.ctx.miterLimit = limit;
  54525. },
  54526. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  54527. var ctx = this.ctx;
  54528. if (ctx.setLineDash !== undefined) {
  54529. ctx.setLineDash(dashArray);
  54530. ctx.lineDashOffset = dashPhase;
  54531. }
  54532. },
  54533. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  54534. },
  54535. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  54536. },
  54537. setGState: function CanvasGraphics_setGState(states) {
  54538. for (var i = 0, ii = states.length; i < ii; i++) {
  54539. var state = states[i];
  54540. var key = state[0];
  54541. var value = state[1];
  54542. switch (key) {
  54543. case 'LW':
  54544. this.setLineWidth(value);
  54545. break;
  54546. case 'LC':
  54547. this.setLineCap(value);
  54548. break;
  54549. case 'LJ':
  54550. this.setLineJoin(value);
  54551. break;
  54552. case 'ML':
  54553. this.setMiterLimit(value);
  54554. break;
  54555. case 'D':
  54556. this.setDash(value[0], value[1]);
  54557. break;
  54558. case 'RI':
  54559. this.setRenderingIntent(value);
  54560. break;
  54561. case 'FL':
  54562. this.setFlatness(value);
  54563. break;
  54564. case 'Font':
  54565. this.setFont(value[0], value[1]);
  54566. break;
  54567. case 'CA':
  54568. this.current.strokeAlpha = state[1];
  54569. break;
  54570. case 'ca':
  54571. this.current.fillAlpha = state[1];
  54572. this.ctx.globalAlpha = state[1];
  54573. break;
  54574. case 'BM':
  54575. if (value && value.name && value.name !== 'Normal') {
  54576. var mode = value.name.replace(/([A-Z])/g, function (c) {
  54577. return '-' + c.toLowerCase();
  54578. }).substring(1);
  54579. this.ctx.globalCompositeOperation = mode;
  54580. if (this.ctx.globalCompositeOperation !== mode) {
  54581. warn('globalCompositeOperation "' + mode + '" is not supported');
  54582. }
  54583. } else {
  54584. this.ctx.globalCompositeOperation = 'source-over';
  54585. }
  54586. break;
  54587. case 'SMask':
  54588. if (this.current.activeSMask) {
  54589. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  54590. this.suspendSMaskGroup();
  54591. } else {
  54592. this.endSMaskGroup();
  54593. }
  54594. }
  54595. this.current.activeSMask = value ? this.tempSMask : null;
  54596. if (this.current.activeSMask) {
  54597. this.beginSMaskGroup();
  54598. }
  54599. this.tempSMask = null;
  54600. break;
  54601. }
  54602. }
  54603. },
  54604. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  54605. var activeSMask = this.current.activeSMask;
  54606. var drawnWidth = activeSMask.canvas.width;
  54607. var drawnHeight = activeSMask.canvas.height;
  54608. var cacheId = 'smaskGroupAt' + this.groupLevel;
  54609. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  54610. var currentCtx = this.ctx;
  54611. var currentTransform = currentCtx.mozCurrentTransform;
  54612. this.ctx.save();
  54613. var groupCtx = scratchCanvas.context;
  54614. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  54615. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  54616. groupCtx.transform.apply(groupCtx, currentTransform);
  54617. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  54618. copyCtxState(currentCtx, groupCtx);
  54619. this.ctx = groupCtx;
  54620. this.setGState([
  54621. [
  54622. 'BM',
  54623. 'Normal'
  54624. ],
  54625. [
  54626. 'ca',
  54627. 1
  54628. ],
  54629. [
  54630. 'CA',
  54631. 1
  54632. ]
  54633. ]);
  54634. this.groupStack.push(currentCtx);
  54635. this.groupLevel++;
  54636. },
  54637. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54638. var groupCtx = this.ctx;
  54639. this.groupLevel--;
  54640. this.ctx = this.groupStack.pop();
  54641. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54642. this.ctx.restore();
  54643. this.ctx.save();
  54644. copyCtxState(groupCtx, this.ctx);
  54645. this.current.resumeSMaskCtx = groupCtx;
  54646. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54647. this.ctx.transform.apply(this.ctx, deltaTransform);
  54648. groupCtx.save();
  54649. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  54650. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  54651. groupCtx.restore();
  54652. },
  54653. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54654. var groupCtx = this.current.resumeSMaskCtx;
  54655. var currentCtx = this.ctx;
  54656. this.ctx = groupCtx;
  54657. this.groupStack.push(currentCtx);
  54658. this.groupLevel++;
  54659. },
  54660. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54661. var groupCtx = this.ctx;
  54662. this.groupLevel--;
  54663. this.ctx = this.groupStack.pop();
  54664. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54665. this.ctx.restore();
  54666. copyCtxState(groupCtx, this.ctx);
  54667. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54668. this.ctx.transform.apply(this.ctx, deltaTransform);
  54669. },
  54670. save: function CanvasGraphics_save() {
  54671. this.ctx.save();
  54672. var old = this.current;
  54673. this.stateStack.push(old);
  54674. this.current = old.clone();
  54675. this.current.resumeSMaskCtx = null;
  54676. },
  54677. restore: function CanvasGraphics_restore() {
  54678. if (this.current.resumeSMaskCtx) {
  54679. this.resumeSMaskGroup();
  54680. }
  54681. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  54682. this.endSMaskGroup();
  54683. }
  54684. if (this.stateStack.length !== 0) {
  54685. this.current = this.stateStack.pop();
  54686. this.ctx.restore();
  54687. this.pendingClip = null;
  54688. this.cachedGetSinglePixelWidth = null;
  54689. }
  54690. },
  54691. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  54692. this.ctx.transform(a, b, c, d, e, f);
  54693. this.cachedGetSinglePixelWidth = null;
  54694. },
  54695. constructPath: function CanvasGraphics_constructPath(ops, args) {
  54696. var ctx = this.ctx;
  54697. var current = this.current;
  54698. var x = current.x, y = current.y;
  54699. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  54700. switch (ops[i] | 0) {
  54701. case OPS.rectangle:
  54702. x = args[j++];
  54703. y = args[j++];
  54704. var width = args[j++];
  54705. var height = args[j++];
  54706. if (width === 0) {
  54707. width = this.getSinglePixelWidth();
  54708. }
  54709. if (height === 0) {
  54710. height = this.getSinglePixelWidth();
  54711. }
  54712. var xw = x + width;
  54713. var yh = y + height;
  54714. this.ctx.moveTo(x, y);
  54715. this.ctx.lineTo(xw, y);
  54716. this.ctx.lineTo(xw, yh);
  54717. this.ctx.lineTo(x, yh);
  54718. this.ctx.lineTo(x, y);
  54719. this.ctx.closePath();
  54720. break;
  54721. case OPS.moveTo:
  54722. x = args[j++];
  54723. y = args[j++];
  54724. ctx.moveTo(x, y);
  54725. break;
  54726. case OPS.lineTo:
  54727. x = args[j++];
  54728. y = args[j++];
  54729. ctx.lineTo(x, y);
  54730. break;
  54731. case OPS.curveTo:
  54732. x = args[j + 4];
  54733. y = args[j + 5];
  54734. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  54735. j += 6;
  54736. break;
  54737. case OPS.curveTo2:
  54738. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  54739. x = args[j + 2];
  54740. y = args[j + 3];
  54741. j += 4;
  54742. break;
  54743. case OPS.curveTo3:
  54744. x = args[j + 2];
  54745. y = args[j + 3];
  54746. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  54747. j += 4;
  54748. break;
  54749. case OPS.closePath:
  54750. ctx.closePath();
  54751. break;
  54752. }
  54753. }
  54754. current.setCurrentPoint(x, y);
  54755. },
  54756. closePath: function CanvasGraphics_closePath() {
  54757. this.ctx.closePath();
  54758. },
  54759. stroke: function CanvasGraphics_stroke(consumePath) {
  54760. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54761. var ctx = this.ctx;
  54762. var strokeColor = this.current.strokeColor;
  54763. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  54764. ctx.globalAlpha = this.current.strokeAlpha;
  54765. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  54766. ctx.save();
  54767. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  54768. ctx.stroke();
  54769. ctx.restore();
  54770. } else {
  54771. ctx.stroke();
  54772. }
  54773. if (consumePath) {
  54774. this.consumePath();
  54775. }
  54776. ctx.globalAlpha = this.current.fillAlpha;
  54777. },
  54778. closeStroke: function CanvasGraphics_closeStroke() {
  54779. this.closePath();
  54780. this.stroke();
  54781. },
  54782. fill: function CanvasGraphics_fill(consumePath) {
  54783. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54784. var ctx = this.ctx;
  54785. var fillColor = this.current.fillColor;
  54786. var isPatternFill = this.current.patternFill;
  54787. var needRestore = false;
  54788. if (isPatternFill) {
  54789. ctx.save();
  54790. if (this.baseTransform) {
  54791. ctx.setTransform.apply(ctx, this.baseTransform);
  54792. }
  54793. ctx.fillStyle = fillColor.getPattern(ctx, this);
  54794. needRestore = true;
  54795. }
  54796. if (this.pendingEOFill) {
  54797. ctx.fill('evenodd');
  54798. this.pendingEOFill = false;
  54799. } else {
  54800. ctx.fill();
  54801. }
  54802. if (needRestore) {
  54803. ctx.restore();
  54804. }
  54805. if (consumePath) {
  54806. this.consumePath();
  54807. }
  54808. },
  54809. eoFill: function CanvasGraphics_eoFill() {
  54810. this.pendingEOFill = true;
  54811. this.fill();
  54812. },
  54813. fillStroke: function CanvasGraphics_fillStroke() {
  54814. this.fill(false);
  54815. this.stroke(false);
  54816. this.consumePath();
  54817. },
  54818. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  54819. this.pendingEOFill = true;
  54820. this.fillStroke();
  54821. },
  54822. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  54823. this.closePath();
  54824. this.fillStroke();
  54825. },
  54826. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  54827. this.pendingEOFill = true;
  54828. this.closePath();
  54829. this.fillStroke();
  54830. },
  54831. endPath: function CanvasGraphics_endPath() {
  54832. this.consumePath();
  54833. },
  54834. clip: function CanvasGraphics_clip() {
  54835. this.pendingClip = NORMAL_CLIP;
  54836. },
  54837. eoClip: function CanvasGraphics_eoClip() {
  54838. this.pendingClip = EO_CLIP;
  54839. },
  54840. beginText: function CanvasGraphics_beginText() {
  54841. this.current.textMatrix = IDENTITY_MATRIX;
  54842. this.current.textMatrixScale = 1;
  54843. this.current.x = this.current.lineX = 0;
  54844. this.current.y = this.current.lineY = 0;
  54845. },
  54846. endText: function CanvasGraphics_endText() {
  54847. var paths = this.pendingTextPaths;
  54848. var ctx = this.ctx;
  54849. if (paths === undefined) {
  54850. ctx.beginPath();
  54851. return;
  54852. }
  54853. ctx.save();
  54854. ctx.beginPath();
  54855. for (var i = 0; i < paths.length; i++) {
  54856. var path = paths[i];
  54857. ctx.setTransform.apply(ctx, path.transform);
  54858. ctx.translate(path.x, path.y);
  54859. path.addToPath(ctx, path.fontSize);
  54860. }
  54861. ctx.restore();
  54862. ctx.clip();
  54863. ctx.beginPath();
  54864. delete this.pendingTextPaths;
  54865. },
  54866. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  54867. this.current.charSpacing = spacing;
  54868. },
  54869. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  54870. this.current.wordSpacing = spacing;
  54871. },
  54872. setHScale: function CanvasGraphics_setHScale(scale) {
  54873. this.current.textHScale = scale / 100;
  54874. },
  54875. setLeading: function CanvasGraphics_setLeading(leading) {
  54876. this.current.leading = -leading;
  54877. },
  54878. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  54879. var fontObj = this.commonObjs.get(fontRefName);
  54880. var current = this.current;
  54881. if (!fontObj) {
  54882. error('Can\'t find font for ' + fontRefName);
  54883. }
  54884. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  54885. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  54886. warn('Invalid font matrix for font ' + fontRefName);
  54887. }
  54888. if (size < 0) {
  54889. size = -size;
  54890. current.fontDirection = -1;
  54891. } else {
  54892. current.fontDirection = 1;
  54893. }
  54894. this.current.font = fontObj;
  54895. this.current.fontSize = size;
  54896. if (fontObj.isType3Font) {
  54897. return;
  54898. }
  54899. var name = fontObj.loadedName || 'sans-serif';
  54900. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  54901. var italic = fontObj.italic ? 'italic' : 'normal';
  54902. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  54903. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  54904. this.current.fontSizeScale = size / browserFontSize;
  54905. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  54906. this.ctx.font = rule;
  54907. },
  54908. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  54909. this.current.textRenderingMode = mode;
  54910. },
  54911. setTextRise: function CanvasGraphics_setTextRise(rise) {
  54912. this.current.textRise = rise;
  54913. },
  54914. moveText: function CanvasGraphics_moveText(x, y) {
  54915. this.current.x = this.current.lineX += x;
  54916. this.current.y = this.current.lineY += y;
  54917. },
  54918. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  54919. this.setLeading(-y);
  54920. this.moveText(x, y);
  54921. },
  54922. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  54923. this.current.textMatrix = [
  54924. a,
  54925. b,
  54926. c,
  54927. d,
  54928. e,
  54929. f
  54930. ];
  54931. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  54932. this.current.x = this.current.lineX = 0;
  54933. this.current.y = this.current.lineY = 0;
  54934. },
  54935. nextLine: function CanvasGraphics_nextLine() {
  54936. this.moveText(0, this.current.leading);
  54937. },
  54938. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  54939. var ctx = this.ctx;
  54940. var current = this.current;
  54941. var font = current.font;
  54942. var textRenderingMode = current.textRenderingMode;
  54943. var fontSize = current.fontSize / current.fontSizeScale;
  54944. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54945. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  54946. var addToPath;
  54947. if (font.disableFontFace || isAddToPathSet) {
  54948. addToPath = font.getPathGenerator(this.commonObjs, character);
  54949. }
  54950. if (font.disableFontFace) {
  54951. ctx.save();
  54952. ctx.translate(x, y);
  54953. ctx.beginPath();
  54954. addToPath(ctx, fontSize);
  54955. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54956. ctx.fill();
  54957. }
  54958. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54959. ctx.stroke();
  54960. }
  54961. ctx.restore();
  54962. } else {
  54963. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54964. ctx.fillText(character, x, y);
  54965. }
  54966. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54967. ctx.strokeText(character, x, y);
  54968. }
  54969. }
  54970. if (isAddToPathSet) {
  54971. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  54972. paths.push({
  54973. transform: ctx.mozCurrentTransform,
  54974. x: x,
  54975. y: y,
  54976. fontSize: fontSize,
  54977. addToPath: addToPath
  54978. });
  54979. }
  54980. },
  54981. get isFontSubpixelAAEnabled() {
  54982. var ctx = this.canvasFactory.create(10, 10).context;
  54983. ctx.scale(1.5, 1);
  54984. ctx.fillText('I', 0, 10);
  54985. var data = ctx.getImageData(0, 0, 10, 10).data;
  54986. var enabled = false;
  54987. for (var i = 3; i < data.length; i += 4) {
  54988. if (data[i] > 0 && data[i] < 255) {
  54989. enabled = true;
  54990. break;
  54991. }
  54992. }
  54993. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  54994. },
  54995. showText: function CanvasGraphics_showText(glyphs) {
  54996. var current = this.current;
  54997. var font = current.font;
  54998. if (font.isType3Font) {
  54999. return this.showType3Text(glyphs);
  55000. }
  55001. var fontSize = current.fontSize;
  55002. if (fontSize === 0) {
  55003. return;
  55004. }
  55005. var ctx = this.ctx;
  55006. var fontSizeScale = current.fontSizeScale;
  55007. var charSpacing = current.charSpacing;
  55008. var wordSpacing = current.wordSpacing;
  55009. var fontDirection = current.fontDirection;
  55010. var textHScale = current.textHScale * fontDirection;
  55011. var glyphsLength = glyphs.length;
  55012. var vertical = font.vertical;
  55013. var spacingDir = vertical ? 1 : -1;
  55014. var defaultVMetrics = font.defaultVMetrics;
  55015. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55016. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55017. ctx.save();
  55018. ctx.transform.apply(ctx, current.textMatrix);
  55019. ctx.translate(current.x, current.y + current.textRise);
  55020. if (current.patternFill) {
  55021. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55022. }
  55023. if (fontDirection > 0) {
  55024. ctx.scale(textHScale, -1);
  55025. } else {
  55026. ctx.scale(textHScale, 1);
  55027. }
  55028. var lineWidth = current.lineWidth;
  55029. var scale = current.textMatrixScale;
  55030. if (scale === 0 || lineWidth === 0) {
  55031. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55032. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55033. this.cachedGetSinglePixelWidth = null;
  55034. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55035. }
  55036. } else {
  55037. lineWidth /= scale;
  55038. }
  55039. if (fontSizeScale !== 1.0) {
  55040. ctx.scale(fontSizeScale, fontSizeScale);
  55041. lineWidth /= fontSizeScale;
  55042. }
  55043. ctx.lineWidth = lineWidth;
  55044. var x = 0, i;
  55045. for (i = 0; i < glyphsLength; ++i) {
  55046. var glyph = glyphs[i];
  55047. if (isNum(glyph)) {
  55048. x += spacingDir * glyph * fontSize / 1000;
  55049. continue;
  55050. }
  55051. var restoreNeeded = false;
  55052. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55053. var character = glyph.fontChar;
  55054. var accent = glyph.accent;
  55055. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55056. var width = glyph.width;
  55057. if (vertical) {
  55058. var vmetric, vx, vy;
  55059. vmetric = glyph.vmetric || defaultVMetrics;
  55060. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55061. vx = -vx * widthAdvanceScale;
  55062. vy = vmetric[2] * widthAdvanceScale;
  55063. width = vmetric ? -vmetric[0] : width;
  55064. scaledX = vx / fontSizeScale;
  55065. scaledY = (x + vy) / fontSizeScale;
  55066. } else {
  55067. scaledX = x / fontSizeScale;
  55068. scaledY = 0;
  55069. }
  55070. if (font.remeasure && width > 0) {
  55071. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55072. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55073. var characterScaleX = width / measuredWidth;
  55074. restoreNeeded = true;
  55075. ctx.save();
  55076. ctx.scale(characterScaleX, 1);
  55077. scaledX /= characterScaleX;
  55078. } else if (width !== measuredWidth) {
  55079. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55080. }
  55081. }
  55082. if (glyph.isInFont || font.missingFile) {
  55083. if (simpleFillText && !accent) {
  55084. ctx.fillText(character, scaledX, scaledY);
  55085. } else {
  55086. this.paintChar(character, scaledX, scaledY);
  55087. if (accent) {
  55088. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55089. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55090. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55091. }
  55092. }
  55093. }
  55094. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55095. x += charWidth;
  55096. if (restoreNeeded) {
  55097. ctx.restore();
  55098. }
  55099. }
  55100. if (vertical) {
  55101. current.y -= x * textHScale;
  55102. } else {
  55103. current.x += x * textHScale;
  55104. }
  55105. ctx.restore();
  55106. },
  55107. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55108. var ctx = this.ctx;
  55109. var current = this.current;
  55110. var font = current.font;
  55111. var fontSize = current.fontSize;
  55112. var fontDirection = current.fontDirection;
  55113. var spacingDir = font.vertical ? 1 : -1;
  55114. var charSpacing = current.charSpacing;
  55115. var wordSpacing = current.wordSpacing;
  55116. var textHScale = current.textHScale * fontDirection;
  55117. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55118. var glyphsLength = glyphs.length;
  55119. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55120. var i, glyph, width, spacingLength;
  55121. if (isTextInvisible || fontSize === 0) {
  55122. return;
  55123. }
  55124. this.cachedGetSinglePixelWidth = null;
  55125. ctx.save();
  55126. ctx.transform.apply(ctx, current.textMatrix);
  55127. ctx.translate(current.x, current.y);
  55128. ctx.scale(textHScale, fontDirection);
  55129. for (i = 0; i < glyphsLength; ++i) {
  55130. glyph = glyphs[i];
  55131. if (isNum(glyph)) {
  55132. spacingLength = spacingDir * glyph * fontSize / 1000;
  55133. this.ctx.translate(spacingLength, 0);
  55134. current.x += spacingLength * textHScale;
  55135. continue;
  55136. }
  55137. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55138. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55139. if (!operatorList) {
  55140. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55141. continue;
  55142. }
  55143. this.processingType3 = glyph;
  55144. this.save();
  55145. ctx.scale(fontSize, fontSize);
  55146. ctx.transform.apply(ctx, fontMatrix);
  55147. this.executeOperatorList(operatorList);
  55148. this.restore();
  55149. var transformed = Util.applyTransform([
  55150. glyph.width,
  55151. 0
  55152. ], fontMatrix);
  55153. width = transformed[0] * fontSize + spacing;
  55154. ctx.translate(width, 0);
  55155. current.x += width * textHScale;
  55156. }
  55157. ctx.restore();
  55158. this.processingType3 = null;
  55159. },
  55160. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55161. },
  55162. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55163. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55164. this.clip();
  55165. this.endPath();
  55166. },
  55167. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55168. var pattern;
  55169. if (IR[0] === 'TilingPattern') {
  55170. var color = IR[1];
  55171. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55172. var self = this;
  55173. var canvasGraphicsFactory = {
  55174. createCanvasGraphics: function (ctx) {
  55175. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55176. }
  55177. };
  55178. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55179. } else {
  55180. pattern = getShadingPatternFromIR(IR);
  55181. }
  55182. return pattern;
  55183. },
  55184. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55185. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55186. },
  55187. setFillColorN: function CanvasGraphics_setFillColorN() {
  55188. this.current.fillColor = this.getColorN_Pattern(arguments);
  55189. this.current.patternFill = true;
  55190. },
  55191. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55192. var color = Util.makeCssRgb(r, g, b);
  55193. this.ctx.strokeStyle = color;
  55194. this.current.strokeColor = color;
  55195. },
  55196. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55197. var color = Util.makeCssRgb(r, g, b);
  55198. this.ctx.fillStyle = color;
  55199. this.current.fillColor = color;
  55200. this.current.patternFill = false;
  55201. },
  55202. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55203. var ctx = this.ctx;
  55204. this.save();
  55205. var pattern = getShadingPatternFromIR(patternIR);
  55206. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55207. var inv = ctx.mozCurrentTransformInverse;
  55208. if (inv) {
  55209. var canvas = ctx.canvas;
  55210. var width = canvas.width;
  55211. var height = canvas.height;
  55212. var bl = Util.applyTransform([
  55213. 0,
  55214. 0
  55215. ], inv);
  55216. var br = Util.applyTransform([
  55217. 0,
  55218. height
  55219. ], inv);
  55220. var ul = Util.applyTransform([
  55221. width,
  55222. 0
  55223. ], inv);
  55224. var ur = Util.applyTransform([
  55225. width,
  55226. height
  55227. ], inv);
  55228. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55229. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  55230. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  55231. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  55232. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  55233. } else {
  55234. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  55235. }
  55236. this.restore();
  55237. },
  55238. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  55239. error('Should not call beginInlineImage');
  55240. },
  55241. beginImageData: function CanvasGraphics_beginImageData() {
  55242. error('Should not call beginImageData');
  55243. },
  55244. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  55245. this.save();
  55246. this.baseTransformStack.push(this.baseTransform);
  55247. if (isArray(matrix) && matrix.length === 6) {
  55248. this.transform.apply(this, matrix);
  55249. }
  55250. this.baseTransform = this.ctx.mozCurrentTransform;
  55251. if (isArray(bbox) && bbox.length === 4) {
  55252. var width = bbox[2] - bbox[0];
  55253. var height = bbox[3] - bbox[1];
  55254. this.ctx.rect(bbox[0], bbox[1], width, height);
  55255. this.clip();
  55256. this.endPath();
  55257. }
  55258. },
  55259. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  55260. this.restore();
  55261. this.baseTransform = this.baseTransformStack.pop();
  55262. },
  55263. beginGroup: function CanvasGraphics_beginGroup(group) {
  55264. this.save();
  55265. var currentCtx = this.ctx;
  55266. if (!group.isolated) {
  55267. info('TODO: Support non-isolated groups.');
  55268. }
  55269. if (group.knockout) {
  55270. warn('Knockout groups not supported.');
  55271. }
  55272. var currentTransform = currentCtx.mozCurrentTransform;
  55273. if (group.matrix) {
  55274. currentCtx.transform.apply(currentCtx, group.matrix);
  55275. }
  55276. assert(group.bbox, 'Bounding box is required.');
  55277. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  55278. var canvasBounds = [
  55279. 0,
  55280. 0,
  55281. currentCtx.canvas.width,
  55282. currentCtx.canvas.height
  55283. ];
  55284. bounds = Util.intersect(bounds, canvasBounds) || [
  55285. 0,
  55286. 0,
  55287. 0,
  55288. 0
  55289. ];
  55290. var offsetX = Math.floor(bounds[0]);
  55291. var offsetY = Math.floor(bounds[1]);
  55292. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  55293. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  55294. var scaleX = 1, scaleY = 1;
  55295. if (drawnWidth > MAX_GROUP_SIZE) {
  55296. scaleX = drawnWidth / MAX_GROUP_SIZE;
  55297. drawnWidth = MAX_GROUP_SIZE;
  55298. }
  55299. if (drawnHeight > MAX_GROUP_SIZE) {
  55300. scaleY = drawnHeight / MAX_GROUP_SIZE;
  55301. drawnHeight = MAX_GROUP_SIZE;
  55302. }
  55303. var cacheId = 'groupAt' + this.groupLevel;
  55304. if (group.smask) {
  55305. cacheId += '_smask_' + this.smaskCounter++ % 2;
  55306. }
  55307. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55308. var groupCtx = scratchCanvas.context;
  55309. groupCtx.scale(1 / scaleX, 1 / scaleY);
  55310. groupCtx.translate(-offsetX, -offsetY);
  55311. groupCtx.transform.apply(groupCtx, currentTransform);
  55312. if (group.smask) {
  55313. this.smaskStack.push({
  55314. canvas: scratchCanvas.canvas,
  55315. context: groupCtx,
  55316. offsetX: offsetX,
  55317. offsetY: offsetY,
  55318. scaleX: scaleX,
  55319. scaleY: scaleY,
  55320. subtype: group.smask.subtype,
  55321. backdrop: group.smask.backdrop,
  55322. transferMap: group.smask.transferMap || null,
  55323. startTransformInverse: null
  55324. });
  55325. } else {
  55326. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  55327. currentCtx.translate(offsetX, offsetY);
  55328. currentCtx.scale(scaleX, scaleY);
  55329. }
  55330. copyCtxState(currentCtx, groupCtx);
  55331. this.ctx = groupCtx;
  55332. this.setGState([
  55333. [
  55334. 'BM',
  55335. 'Normal'
  55336. ],
  55337. [
  55338. 'ca',
  55339. 1
  55340. ],
  55341. [
  55342. 'CA',
  55343. 1
  55344. ]
  55345. ]);
  55346. this.groupStack.push(currentCtx);
  55347. this.groupLevel++;
  55348. this.current.activeSMask = null;
  55349. },
  55350. endGroup: function CanvasGraphics_endGroup(group) {
  55351. this.groupLevel--;
  55352. var groupCtx = this.ctx;
  55353. this.ctx = this.groupStack.pop();
  55354. if (this.ctx.imageSmoothingEnabled !== undefined) {
  55355. this.ctx.imageSmoothingEnabled = false;
  55356. } else {
  55357. this.ctx.mozImageSmoothingEnabled = false;
  55358. }
  55359. if (group.smask) {
  55360. this.tempSMask = this.smaskStack.pop();
  55361. } else {
  55362. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  55363. }
  55364. this.restore();
  55365. },
  55366. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  55367. this.save();
  55368. this.current = new CanvasExtraState();
  55369. if (this.baseTransform) {
  55370. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  55371. }
  55372. },
  55373. endAnnotations: function CanvasGraphics_endAnnotations() {
  55374. this.restore();
  55375. },
  55376. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  55377. this.save();
  55378. if (isArray(rect) && rect.length === 4) {
  55379. var width = rect[2] - rect[0];
  55380. var height = rect[3] - rect[1];
  55381. this.ctx.rect(rect[0], rect[1], width, height);
  55382. this.clip();
  55383. this.endPath();
  55384. }
  55385. this.transform.apply(this, transform);
  55386. this.transform.apply(this, matrix);
  55387. },
  55388. endAnnotation: function CanvasGraphics_endAnnotation() {
  55389. this.restore();
  55390. },
  55391. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  55392. var domImage = this.objs.get(objId);
  55393. if (!domImage) {
  55394. warn('Dependent image isn\'t ready yet');
  55395. return;
  55396. }
  55397. this.save();
  55398. var ctx = this.ctx;
  55399. ctx.scale(1 / w, -1 / h);
  55400. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  55401. if (this.imageLayer) {
  55402. var currentTransform = ctx.mozCurrentTransformInverse;
  55403. var position = this.getCanvasPosition(0, 0);
  55404. this.imageLayer.appendImage({
  55405. objId: objId,
  55406. left: position[0],
  55407. top: position[1],
  55408. width: w / currentTransform[0],
  55409. height: h / currentTransform[3]
  55410. });
  55411. }
  55412. this.restore();
  55413. },
  55414. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  55415. var ctx = this.ctx;
  55416. var width = img.width, height = img.height;
  55417. var fillColor = this.current.fillColor;
  55418. var isPatternFill = this.current.patternFill;
  55419. var glyph = this.processingType3;
  55420. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  55421. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  55422. glyph.compiled = compileType3Glyph({
  55423. data: img.data,
  55424. width: width,
  55425. height: height
  55426. });
  55427. } else {
  55428. glyph.compiled = null;
  55429. }
  55430. }
  55431. if (glyph && glyph.compiled) {
  55432. glyph.compiled(ctx);
  55433. return;
  55434. }
  55435. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55436. var maskCtx = maskCanvas.context;
  55437. maskCtx.save();
  55438. putBinaryImageMask(maskCtx, img);
  55439. maskCtx.globalCompositeOperation = 'source-in';
  55440. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55441. maskCtx.fillRect(0, 0, width, height);
  55442. maskCtx.restore();
  55443. this.paintInlineImageXObject(maskCanvas.canvas);
  55444. },
  55445. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  55446. var width = imgData.width;
  55447. var height = imgData.height;
  55448. var fillColor = this.current.fillColor;
  55449. var isPatternFill = this.current.patternFill;
  55450. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55451. var maskCtx = maskCanvas.context;
  55452. maskCtx.save();
  55453. putBinaryImageMask(maskCtx, imgData);
  55454. maskCtx.globalCompositeOperation = 'source-in';
  55455. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55456. maskCtx.fillRect(0, 0, width, height);
  55457. maskCtx.restore();
  55458. var ctx = this.ctx;
  55459. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55460. ctx.save();
  55461. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  55462. ctx.scale(1, -1);
  55463. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55464. ctx.restore();
  55465. }
  55466. },
  55467. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  55468. var ctx = this.ctx;
  55469. var fillColor = this.current.fillColor;
  55470. var isPatternFill = this.current.patternFill;
  55471. for (var i = 0, ii = images.length; i < ii; i++) {
  55472. var image = images[i];
  55473. var width = image.width, height = image.height;
  55474. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55475. var maskCtx = maskCanvas.context;
  55476. maskCtx.save();
  55477. putBinaryImageMask(maskCtx, image);
  55478. maskCtx.globalCompositeOperation = 'source-in';
  55479. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55480. maskCtx.fillRect(0, 0, width, height);
  55481. maskCtx.restore();
  55482. ctx.save();
  55483. ctx.transform.apply(ctx, image.transform);
  55484. ctx.scale(1, -1);
  55485. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55486. ctx.restore();
  55487. }
  55488. },
  55489. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  55490. var imgData = this.objs.get(objId);
  55491. if (!imgData) {
  55492. warn('Dependent image isn\'t ready yet');
  55493. return;
  55494. }
  55495. this.paintInlineImageXObject(imgData);
  55496. },
  55497. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  55498. var imgData = this.objs.get(objId);
  55499. if (!imgData) {
  55500. warn('Dependent image isn\'t ready yet');
  55501. return;
  55502. }
  55503. var width = imgData.width;
  55504. var height = imgData.height;
  55505. var map = [];
  55506. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55507. map.push({
  55508. transform: [
  55509. scaleX,
  55510. 0,
  55511. 0,
  55512. scaleY,
  55513. positions[i],
  55514. positions[i + 1]
  55515. ],
  55516. x: 0,
  55517. y: 0,
  55518. w: width,
  55519. h: height
  55520. });
  55521. }
  55522. this.paintInlineImageXObjectGroup(imgData, map);
  55523. },
  55524. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  55525. var width = imgData.width;
  55526. var height = imgData.height;
  55527. var ctx = this.ctx;
  55528. this.save();
  55529. ctx.scale(1 / width, -1 / height);
  55530. var currentTransform = ctx.mozCurrentTransformInverse;
  55531. var a = currentTransform[0], b = currentTransform[1];
  55532. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  55533. var c = currentTransform[2], d = currentTransform[3];
  55534. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  55535. var imgToPaint, tmpCanvas;
  55536. if (imgData instanceof HTMLElement || !imgData.data) {
  55537. imgToPaint = imgData;
  55538. } else {
  55539. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  55540. var tmpCtx = tmpCanvas.context;
  55541. putBinaryImageData(tmpCtx, imgData);
  55542. imgToPaint = tmpCanvas.canvas;
  55543. }
  55544. var paintWidth = width, paintHeight = height;
  55545. var tmpCanvasId = 'prescale1';
  55546. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  55547. var newWidth = paintWidth, newHeight = paintHeight;
  55548. if (widthScale > 2 && paintWidth > 1) {
  55549. newWidth = Math.ceil(paintWidth / 2);
  55550. widthScale /= paintWidth / newWidth;
  55551. }
  55552. if (heightScale > 2 && paintHeight > 1) {
  55553. newHeight = Math.ceil(paintHeight / 2);
  55554. heightScale /= paintHeight / newHeight;
  55555. }
  55556. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  55557. tmpCtx = tmpCanvas.context;
  55558. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  55559. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  55560. imgToPaint = tmpCanvas.canvas;
  55561. paintWidth = newWidth;
  55562. paintHeight = newHeight;
  55563. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  55564. }
  55565. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  55566. if (this.imageLayer) {
  55567. var position = this.getCanvasPosition(0, -height);
  55568. this.imageLayer.appendImage({
  55569. imgData: imgData,
  55570. left: position[0],
  55571. top: position[1],
  55572. width: width / currentTransform[0],
  55573. height: height / currentTransform[3]
  55574. });
  55575. }
  55576. this.restore();
  55577. },
  55578. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  55579. var ctx = this.ctx;
  55580. var w = imgData.width;
  55581. var h = imgData.height;
  55582. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  55583. var tmpCtx = tmpCanvas.context;
  55584. putBinaryImageData(tmpCtx, imgData);
  55585. for (var i = 0, ii = map.length; i < ii; i++) {
  55586. var entry = map[i];
  55587. ctx.save();
  55588. ctx.transform.apply(ctx, entry.transform);
  55589. ctx.scale(1, -1);
  55590. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  55591. if (this.imageLayer) {
  55592. var position = this.getCanvasPosition(entry.x, entry.y);
  55593. this.imageLayer.appendImage({
  55594. imgData: imgData,
  55595. left: position[0],
  55596. top: position[1],
  55597. width: w,
  55598. height: h
  55599. });
  55600. }
  55601. ctx.restore();
  55602. }
  55603. },
  55604. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  55605. this.ctx.fillRect(0, 0, 1, 1);
  55606. },
  55607. paintXObject: function CanvasGraphics_paintXObject() {
  55608. warn('Unsupported \'paintXObject\' command.');
  55609. },
  55610. markPoint: function CanvasGraphics_markPoint(tag) {
  55611. },
  55612. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  55613. },
  55614. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  55615. },
  55616. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  55617. },
  55618. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  55619. },
  55620. beginCompat: function CanvasGraphics_beginCompat() {
  55621. },
  55622. endCompat: function CanvasGraphics_endCompat() {
  55623. },
  55624. consumePath: function CanvasGraphics_consumePath() {
  55625. var ctx = this.ctx;
  55626. if (this.pendingClip) {
  55627. if (this.pendingClip === EO_CLIP) {
  55628. ctx.clip('evenodd');
  55629. } else {
  55630. ctx.clip();
  55631. }
  55632. this.pendingClip = null;
  55633. }
  55634. ctx.beginPath();
  55635. },
  55636. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  55637. if (this.cachedGetSinglePixelWidth === null) {
  55638. this.ctx.save();
  55639. var inverse = this.ctx.mozCurrentTransformInverse;
  55640. this.ctx.restore();
  55641. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  55642. }
  55643. return this.cachedGetSinglePixelWidth;
  55644. },
  55645. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  55646. var transform = this.ctx.mozCurrentTransform;
  55647. return [
  55648. transform[0] * x + transform[2] * y + transform[4],
  55649. transform[1] * x + transform[3] * y + transform[5]
  55650. ];
  55651. }
  55652. };
  55653. for (var op in OPS) {
  55654. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  55655. }
  55656. return CanvasGraphics;
  55657. }();
  55658. exports.CanvasGraphics = CanvasGraphics;
  55659. /***/ }),
  55660. /* 45 */
  55661. /***/ (function(module, exports, __w_pdfjs_require__) {
  55662. "use strict";
  55663. var sharedUtil = __w_pdfjs_require__(0);
  55664. var assert = sharedUtil.assert;
  55665. var bytesToString = sharedUtil.bytesToString;
  55666. var string32 = sharedUtil.string32;
  55667. var shadow = sharedUtil.shadow;
  55668. var warn = sharedUtil.warn;
  55669. function FontLoader(docId) {
  55670. this.docId = docId;
  55671. this.styleElement = null;
  55672. this.nativeFontFaces = [];
  55673. this.loadTestFontId = 0;
  55674. this.loadingContext = {
  55675. requests: [],
  55676. nextRequestId: 0
  55677. };
  55678. }
  55679. FontLoader.prototype = {
  55680. insertRule: function fontLoaderInsertRule(rule) {
  55681. var styleElement = this.styleElement;
  55682. if (!styleElement) {
  55683. styleElement = this.styleElement = document.createElement('style');
  55684. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  55685. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  55686. }
  55687. var styleSheet = styleElement.sheet;
  55688. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  55689. },
  55690. clear: function fontLoaderClear() {
  55691. if (this.styleElement) {
  55692. this.styleElement.remove();
  55693. this.styleElement = null;
  55694. }
  55695. this.nativeFontFaces.forEach(function (nativeFontFace) {
  55696. document.fonts.delete(nativeFontFace);
  55697. });
  55698. this.nativeFontFaces.length = 0;
  55699. }
  55700. };
  55701. var getLoadTestFont = function () {
  55702. 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==');
  55703. };
  55704. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  55705. get: function () {
  55706. return shadow(this, 'loadTestFont', getLoadTestFont());
  55707. },
  55708. configurable: true
  55709. });
  55710. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  55711. this.nativeFontFaces.push(nativeFontFace);
  55712. document.fonts.add(nativeFontFace);
  55713. };
  55714. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  55715. var rules = [];
  55716. var fontsToLoad = [];
  55717. var fontLoadPromises = [];
  55718. var getNativeFontPromise = function (nativeFontFace) {
  55719. return nativeFontFace.loaded.catch(function (e) {
  55720. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  55721. });
  55722. };
  55723. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  55724. for (var i = 0, ii = fonts.length; i < ii; i++) {
  55725. var font = fonts[i];
  55726. if (font.attached || font.loading === false) {
  55727. continue;
  55728. }
  55729. font.attached = true;
  55730. if (isFontLoadingAPISupported) {
  55731. var nativeFontFace = font.createNativeFontFace();
  55732. if (nativeFontFace) {
  55733. this.addNativeFontFace(nativeFontFace);
  55734. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  55735. }
  55736. } else {
  55737. var rule = font.createFontFaceRule();
  55738. if (rule) {
  55739. this.insertRule(rule);
  55740. rules.push(rule);
  55741. fontsToLoad.push(font);
  55742. }
  55743. }
  55744. }
  55745. var request = this.queueLoadingCallback(callback);
  55746. if (isFontLoadingAPISupported) {
  55747. Promise.all(fontLoadPromises).then(function () {
  55748. request.complete();
  55749. });
  55750. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  55751. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  55752. } else {
  55753. request.complete();
  55754. }
  55755. };
  55756. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  55757. function LoadLoader_completeRequest() {
  55758. assert(!request.end, 'completeRequest() cannot be called twice');
  55759. request.end = Date.now();
  55760. while (context.requests.length > 0 && context.requests[0].end) {
  55761. var otherRequest = context.requests.shift();
  55762. setTimeout(otherRequest.callback, 0);
  55763. }
  55764. }
  55765. var context = this.loadingContext;
  55766. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  55767. var request = {
  55768. id: requestId,
  55769. complete: LoadLoader_completeRequest,
  55770. callback: callback,
  55771. started: Date.now()
  55772. };
  55773. context.requests.push(request);
  55774. return request;
  55775. };
  55776. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  55777. function int32(data, offset) {
  55778. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  55779. }
  55780. function spliceString(s, offset, remove, insert) {
  55781. var chunk1 = s.substr(0, offset);
  55782. var chunk2 = s.substr(offset + remove);
  55783. return chunk1 + insert + chunk2;
  55784. }
  55785. var i, ii;
  55786. var canvas = document.createElement('canvas');
  55787. canvas.width = 1;
  55788. canvas.height = 1;
  55789. var ctx = canvas.getContext('2d');
  55790. var called = 0;
  55791. function isFontReady(name, callback) {
  55792. called++;
  55793. if (called > 30) {
  55794. warn('Load test font never loaded.');
  55795. callback();
  55796. return;
  55797. }
  55798. ctx.font = '30px ' + name;
  55799. ctx.fillText('.', 0, 20);
  55800. var imageData = ctx.getImageData(0, 0, 1, 1);
  55801. if (imageData.data[3] > 0) {
  55802. callback();
  55803. return;
  55804. }
  55805. setTimeout(isFontReady.bind(null, name, callback));
  55806. }
  55807. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  55808. var data = this.loadTestFont;
  55809. var COMMENT_OFFSET = 976;
  55810. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  55811. var CFF_CHECKSUM_OFFSET = 16;
  55812. var XXXX_VALUE = 0x58585858;
  55813. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  55814. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  55815. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  55816. }
  55817. if (i < loadTestFontId.length) {
  55818. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  55819. }
  55820. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  55821. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  55822. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  55823. this.insertRule(rule);
  55824. var names = [];
  55825. for (i = 0, ii = fonts.length; i < ii; i++) {
  55826. names.push(fonts[i].loadedName);
  55827. }
  55828. names.push(loadTestFontId);
  55829. var div = document.createElement('div');
  55830. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  55831. for (i = 0, ii = names.length; i < ii; ++i) {
  55832. var span = document.createElement('span');
  55833. span.textContent = 'Hi';
  55834. span.style.fontFamily = names[i];
  55835. div.appendChild(span);
  55836. }
  55837. document.body.appendChild(div);
  55838. isFontReady(loadTestFontId, function () {
  55839. document.body.removeChild(div);
  55840. request.complete();
  55841. });
  55842. };
  55843. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  55844. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  55845. if (typeof navigator === 'undefined') {
  55846. return true;
  55847. }
  55848. var supported = false;
  55849. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  55850. if (m && m[1] >= 14) {
  55851. supported = true;
  55852. }
  55853. return supported;
  55854. };
  55855. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  55856. get: function () {
  55857. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  55858. },
  55859. enumerable: true,
  55860. configurable: true
  55861. });
  55862. var IsEvalSupportedCached = {
  55863. get value() {
  55864. return shadow(this, 'value', sharedUtil.isEvalSupported());
  55865. }
  55866. };
  55867. var FontFaceObject = function FontFaceObjectClosure() {
  55868. function FontFaceObject(translatedData, options) {
  55869. this.compiledGlyphs = Object.create(null);
  55870. for (var i in translatedData) {
  55871. this[i] = translatedData[i];
  55872. }
  55873. this.options = options;
  55874. }
  55875. FontFaceObject.prototype = {
  55876. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  55877. if (!this.data) {
  55878. return null;
  55879. }
  55880. if (this.options.disableFontFace) {
  55881. this.disableFontFace = true;
  55882. return null;
  55883. }
  55884. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  55885. if (this.options.fontRegistry) {
  55886. this.options.fontRegistry.registerFont(this);
  55887. }
  55888. return nativeFontFace;
  55889. },
  55890. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  55891. if (!this.data) {
  55892. return null;
  55893. }
  55894. if (this.options.disableFontFace) {
  55895. this.disableFontFace = true;
  55896. return null;
  55897. }
  55898. var data = bytesToString(new Uint8Array(this.data));
  55899. var fontName = this.loadedName;
  55900. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  55901. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  55902. if (this.options.fontRegistry) {
  55903. this.options.fontRegistry.registerFont(this, url);
  55904. }
  55905. return rule;
  55906. },
  55907. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  55908. if (!(character in this.compiledGlyphs)) {
  55909. var cmds = objs.get(this.loadedName + '_path_' + character);
  55910. var current, i, len;
  55911. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  55912. var args, js = '';
  55913. for (i = 0, len = cmds.length; i < len; i++) {
  55914. current = cmds[i];
  55915. if (current.args !== undefined) {
  55916. args = current.args.join(',');
  55917. } else {
  55918. args = '';
  55919. }
  55920. js += 'c.' + current.cmd + '(' + args + ');\n';
  55921. }
  55922. this.compiledGlyphs[character] = new Function('c', 'size', js);
  55923. } else {
  55924. this.compiledGlyphs[character] = function (c, size) {
  55925. for (i = 0, len = cmds.length; i < len; i++) {
  55926. current = cmds[i];
  55927. if (current.cmd === 'scale') {
  55928. current.args = [
  55929. size,
  55930. -size
  55931. ];
  55932. }
  55933. c[current.cmd].apply(c, current.args);
  55934. }
  55935. };
  55936. }
  55937. }
  55938. return this.compiledGlyphs[character];
  55939. }
  55940. };
  55941. return FontFaceObject;
  55942. }();
  55943. exports.FontFaceObject = FontFaceObject;
  55944. exports.FontLoader = FontLoader;
  55945. /***/ }),
  55946. /* 46 */
  55947. /***/ (function(module, exports, __w_pdfjs_require__) {
  55948. "use strict";
  55949. var sharedUtil = __w_pdfjs_require__(0);
  55950. var displayWebGL = __w_pdfjs_require__(25);
  55951. var Util = sharedUtil.Util;
  55952. var info = sharedUtil.info;
  55953. var isArray = sharedUtil.isArray;
  55954. var error = sharedUtil.error;
  55955. var WebGLUtils = displayWebGL.WebGLUtils;
  55956. var ShadingIRs = {};
  55957. ShadingIRs.RadialAxial = {
  55958. fromIR: function RadialAxial_fromIR(raw) {
  55959. var type = raw[1];
  55960. var colorStops = raw[2];
  55961. var p0 = raw[3];
  55962. var p1 = raw[4];
  55963. var r0 = raw[5];
  55964. var r1 = raw[6];
  55965. return {
  55966. type: 'Pattern',
  55967. getPattern: function RadialAxial_getPattern(ctx) {
  55968. var grad;
  55969. if (type === 'axial') {
  55970. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  55971. } else if (type === 'radial') {
  55972. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  55973. }
  55974. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  55975. var c = colorStops[i];
  55976. grad.addColorStop(c[0], c[1]);
  55977. }
  55978. return grad;
  55979. }
  55980. };
  55981. }
  55982. };
  55983. var createMeshCanvas = function createMeshCanvasClosure() {
  55984. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  55985. var coords = context.coords, colors = context.colors;
  55986. var bytes = data.data, rowSize = data.width * 4;
  55987. var tmp;
  55988. if (coords[p1 + 1] > coords[p2 + 1]) {
  55989. tmp = p1;
  55990. p1 = p2;
  55991. p2 = tmp;
  55992. tmp = c1;
  55993. c1 = c2;
  55994. c2 = tmp;
  55995. }
  55996. if (coords[p2 + 1] > coords[p3 + 1]) {
  55997. tmp = p2;
  55998. p2 = p3;
  55999. p3 = tmp;
  56000. tmp = c2;
  56001. c2 = c3;
  56002. c3 = tmp;
  56003. }
  56004. if (coords[p1 + 1] > coords[p2 + 1]) {
  56005. tmp = p1;
  56006. p1 = p2;
  56007. p2 = tmp;
  56008. tmp = c1;
  56009. c1 = c2;
  56010. c2 = tmp;
  56011. }
  56012. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56013. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56014. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56015. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56016. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56017. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56018. if (y1 >= y3) {
  56019. return;
  56020. }
  56021. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56022. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56023. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56024. var minY = Math.round(y1), maxY = Math.round(y3);
  56025. var xa, car, cag, cab;
  56026. var xb, cbr, cbg, cbb;
  56027. var k;
  56028. for (var y = minY; y <= maxY; y++) {
  56029. if (y < y2) {
  56030. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56031. xa = x1 - (x1 - x2) * k;
  56032. car = c1r - (c1r - c2r) * k;
  56033. cag = c1g - (c1g - c2g) * k;
  56034. cab = c1b - (c1b - c2b) * k;
  56035. } else {
  56036. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56037. xa = x2 - (x2 - x3) * k;
  56038. car = c2r - (c2r - c3r) * k;
  56039. cag = c2g - (c2g - c3g) * k;
  56040. cab = c2b - (c2b - c3b) * k;
  56041. }
  56042. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56043. xb = x1 - (x1 - x3) * k;
  56044. cbr = c1r - (c1r - c3r) * k;
  56045. cbg = c1g - (c1g - c3g) * k;
  56046. cbb = c1b - (c1b - c3b) * k;
  56047. var x1_ = Math.round(Math.min(xa, xb));
  56048. var x2_ = Math.round(Math.max(xa, xb));
  56049. var j = rowSize * y + x1_ * 4;
  56050. for (var x = x1_; x <= x2_; x++) {
  56051. k = (xa - x) / (xa - xb);
  56052. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56053. bytes[j++] = car - (car - cbr) * k | 0;
  56054. bytes[j++] = cag - (cag - cbg) * k | 0;
  56055. bytes[j++] = cab - (cab - cbb) * k | 0;
  56056. bytes[j++] = 255;
  56057. }
  56058. }
  56059. }
  56060. function drawFigure(data, figure, context) {
  56061. var ps = figure.coords;
  56062. var cs = figure.colors;
  56063. var i, ii;
  56064. switch (figure.type) {
  56065. case 'lattice':
  56066. var verticesPerRow = figure.verticesPerRow;
  56067. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56068. var cols = verticesPerRow - 1;
  56069. for (i = 0; i < rows; i++) {
  56070. var q = i * verticesPerRow;
  56071. for (var j = 0; j < cols; j++, q++) {
  56072. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56073. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56074. }
  56075. }
  56076. break;
  56077. case 'triangles':
  56078. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56079. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56080. }
  56081. break;
  56082. default:
  56083. error('illigal figure');
  56084. break;
  56085. }
  56086. }
  56087. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56088. var EXPECTED_SCALE = 1.1;
  56089. var MAX_PATTERN_SIZE = 3000;
  56090. var BORDER_SIZE = 2;
  56091. var offsetX = Math.floor(bounds[0]);
  56092. var offsetY = Math.floor(bounds[1]);
  56093. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56094. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56095. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56096. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56097. var scaleX = boundsWidth / width;
  56098. var scaleY = boundsHeight / height;
  56099. var context = {
  56100. coords: coords,
  56101. colors: colors,
  56102. offsetX: -offsetX,
  56103. offsetY: -offsetY,
  56104. scaleX: 1 / scaleX,
  56105. scaleY: 1 / scaleY
  56106. };
  56107. var paddedWidth = width + BORDER_SIZE * 2;
  56108. var paddedHeight = height + BORDER_SIZE * 2;
  56109. var canvas, tmpCanvas, i, ii;
  56110. if (WebGLUtils.isEnabled) {
  56111. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56112. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56113. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56114. canvas = tmpCanvas.canvas;
  56115. } else {
  56116. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56117. var tmpCtx = tmpCanvas.context;
  56118. var data = tmpCtx.createImageData(width, height);
  56119. if (backgroundColor) {
  56120. var bytes = data.data;
  56121. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56122. bytes[i] = backgroundColor[0];
  56123. bytes[i + 1] = backgroundColor[1];
  56124. bytes[i + 2] = backgroundColor[2];
  56125. bytes[i + 3] = 255;
  56126. }
  56127. }
  56128. for (i = 0; i < figures.length; i++) {
  56129. drawFigure(data, figures[i], context);
  56130. }
  56131. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56132. canvas = tmpCanvas.canvas;
  56133. }
  56134. return {
  56135. canvas: canvas,
  56136. offsetX: offsetX - BORDER_SIZE * scaleX,
  56137. offsetY: offsetY - BORDER_SIZE * scaleY,
  56138. scaleX: scaleX,
  56139. scaleY: scaleY
  56140. };
  56141. }
  56142. return createMeshCanvas;
  56143. }();
  56144. ShadingIRs.Mesh = {
  56145. fromIR: function Mesh_fromIR(raw) {
  56146. var coords = raw[2];
  56147. var colors = raw[3];
  56148. var figures = raw[4];
  56149. var bounds = raw[5];
  56150. var matrix = raw[6];
  56151. var background = raw[8];
  56152. return {
  56153. type: 'Pattern',
  56154. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56155. var scale;
  56156. if (shadingFill) {
  56157. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56158. } else {
  56159. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56160. if (matrix) {
  56161. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56162. scale = [
  56163. scale[0] * matrixScale[0],
  56164. scale[1] * matrixScale[1]
  56165. ];
  56166. }
  56167. }
  56168. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56169. if (!shadingFill) {
  56170. ctx.setTransform.apply(ctx, owner.baseTransform);
  56171. if (matrix) {
  56172. ctx.transform.apply(ctx, matrix);
  56173. }
  56174. }
  56175. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56176. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56177. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56178. }
  56179. };
  56180. }
  56181. };
  56182. ShadingIRs.Dummy = {
  56183. fromIR: function Dummy_fromIR() {
  56184. return {
  56185. type: 'Pattern',
  56186. getPattern: function Dummy_fromIR_getPattern() {
  56187. return 'hotpink';
  56188. }
  56189. };
  56190. }
  56191. };
  56192. function getShadingPatternFromIR(raw) {
  56193. var shadingIR = ShadingIRs[raw[0]];
  56194. if (!shadingIR) {
  56195. error('Unknown IR type: ' + raw[0]);
  56196. }
  56197. return shadingIR.fromIR(raw);
  56198. }
  56199. var TilingPattern = function TilingPatternClosure() {
  56200. var PaintType = {
  56201. COLORED: 1,
  56202. UNCOLORED: 2
  56203. };
  56204. var MAX_PATTERN_SIZE = 3000;
  56205. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56206. this.operatorList = IR[2];
  56207. this.matrix = IR[3] || [
  56208. 1,
  56209. 0,
  56210. 0,
  56211. 1,
  56212. 0,
  56213. 0
  56214. ];
  56215. this.bbox = Util.normalizeRect(IR[4]);
  56216. this.xstep = IR[5];
  56217. this.ystep = IR[6];
  56218. this.paintType = IR[7];
  56219. this.tilingType = IR[8];
  56220. this.color = color;
  56221. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56222. this.baseTransform = baseTransform;
  56223. this.type = 'Pattern';
  56224. this.ctx = ctx;
  56225. }
  56226. TilingPattern.prototype = {
  56227. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56228. var operatorList = this.operatorList;
  56229. var bbox = this.bbox;
  56230. var xstep = this.xstep;
  56231. var ystep = this.ystep;
  56232. var paintType = this.paintType;
  56233. var tilingType = this.tilingType;
  56234. var color = this.color;
  56235. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  56236. info('TilingType: ' + tilingType);
  56237. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  56238. var topLeft = [
  56239. x0,
  56240. y0
  56241. ];
  56242. var botRight = [
  56243. x0 + xstep,
  56244. y0 + ystep
  56245. ];
  56246. var width = botRight[0] - topLeft[0];
  56247. var height = botRight[1] - topLeft[1];
  56248. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  56249. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  56250. var combinedScale = [
  56251. matrixScale[0] * curMatrixScale[0],
  56252. matrixScale[1] * curMatrixScale[1]
  56253. ];
  56254. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  56255. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  56256. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  56257. var tmpCtx = tmpCanvas.context;
  56258. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  56259. graphics.groupLevel = owner.groupLevel;
  56260. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  56261. this.setScale(width, height, xstep, ystep);
  56262. this.transformToScale(graphics);
  56263. var tmpTranslate = [
  56264. 1,
  56265. 0,
  56266. 0,
  56267. 1,
  56268. -topLeft[0],
  56269. -topLeft[1]
  56270. ];
  56271. graphics.transform.apply(graphics, tmpTranslate);
  56272. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  56273. graphics.executeOperatorList(operatorList);
  56274. return tmpCanvas.canvas;
  56275. },
  56276. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  56277. this.scale = [
  56278. width / xstep,
  56279. height / ystep
  56280. ];
  56281. },
  56282. transformToScale: function TilingPattern_transformToScale(graphics) {
  56283. var scale = this.scale;
  56284. var tmpScale = [
  56285. scale[0],
  56286. 0,
  56287. 0,
  56288. scale[1],
  56289. 0,
  56290. 0
  56291. ];
  56292. graphics.transform.apply(graphics, tmpScale);
  56293. },
  56294. scaleToContext: function TilingPattern_scaleToContext() {
  56295. var scale = this.scale;
  56296. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  56297. },
  56298. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  56299. if (isArray(bbox) && bbox.length === 4) {
  56300. var bboxWidth = x1 - x0;
  56301. var bboxHeight = y1 - y0;
  56302. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  56303. graphics.clip();
  56304. graphics.endPath();
  56305. }
  56306. },
  56307. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  56308. switch (paintType) {
  56309. case PaintType.COLORED:
  56310. var ctx = this.ctx;
  56311. context.fillStyle = ctx.fillStyle;
  56312. context.strokeStyle = ctx.strokeStyle;
  56313. break;
  56314. case PaintType.UNCOLORED:
  56315. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  56316. context.fillStyle = cssColor;
  56317. context.strokeStyle = cssColor;
  56318. break;
  56319. default:
  56320. error('Unsupported paint type: ' + paintType);
  56321. }
  56322. },
  56323. getPattern: function TilingPattern_getPattern(ctx, owner) {
  56324. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  56325. ctx = this.ctx;
  56326. ctx.setTransform.apply(ctx, this.baseTransform);
  56327. ctx.transform.apply(ctx, this.matrix);
  56328. this.scaleToContext();
  56329. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  56330. }
  56331. };
  56332. return TilingPattern;
  56333. }();
  56334. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  56335. exports.TilingPattern = TilingPattern;
  56336. /***/ }),
  56337. /* 47 */
  56338. /***/ (function(module, exports, __w_pdfjs_require__) {
  56339. "use strict";
  56340. var pdfjsVersion = '1.7.387';
  56341. var pdfjsBuild = 'b6bf1a3e';
  56342. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  56343. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  56344. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  56345. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  56346. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  56347. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  56348. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  56349. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  56350. exports.build = pdfjsDisplayAPI.build;
  56351. exports.version = pdfjsDisplayAPI.version;
  56352. exports.getDocument = pdfjsDisplayAPI.getDocument;
  56353. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  56354. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  56355. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  56356. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56357. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  56358. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  56359. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  56360. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  56361. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  56362. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  56363. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  56364. exports.OPS = pdfjsSharedUtil.OPS;
  56365. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56366. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  56367. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  56368. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  56369. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  56370. exports.shadow = pdfjsSharedUtil.shadow;
  56371. exports.createBlob = pdfjsSharedUtil.createBlob;
  56372. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56373. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  56374. /***/ }),
  56375. /* 48 */
  56376. /***/ (function(module, exports, __w_pdfjs_require__) {
  56377. "use strict";
  56378. /* WEBPACK VAR INJECTION */(function(global) {
  56379. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  56380. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  56381. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  56382. var isAndroid = /Android/.test(userAgent);
  56383. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  56384. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  56385. var isChrome = userAgent.indexOf('Chrom') >= 0;
  56386. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  56387. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  56388. var isIE = userAgent.indexOf('Trident') >= 0;
  56389. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  56390. var isOpera = userAgent.indexOf('Opera') >= 0;
  56391. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  56392. var hasDOM = typeof window === 'object' && typeof document === 'object';
  56393. if (typeof PDFJS === 'undefined') {
  56394. globalScope.PDFJS = {};
  56395. }
  56396. PDFJS.compatibilityChecked = true;
  56397. (function checkTypedArrayCompatibility() {
  56398. if (typeof Uint8Array !== 'undefined') {
  56399. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  56400. Uint8Array.prototype.subarray = function subarray(start, end) {
  56401. return new Uint8Array(this.slice(start, end));
  56402. };
  56403. Float32Array.prototype.subarray = function subarray(start, end) {
  56404. return new Float32Array(this.slice(start, end));
  56405. };
  56406. }
  56407. if (typeof Float64Array === 'undefined') {
  56408. globalScope.Float64Array = Float32Array;
  56409. }
  56410. return;
  56411. }
  56412. function subarray(start, end) {
  56413. return new TypedArray(this.slice(start, end));
  56414. }
  56415. function setArrayOffset(array, offset) {
  56416. if (arguments.length < 2) {
  56417. offset = 0;
  56418. }
  56419. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  56420. this[offset] = array[i] & 0xFF;
  56421. }
  56422. }
  56423. function TypedArray(arg1) {
  56424. var result, i, n;
  56425. if (typeof arg1 === 'number') {
  56426. result = [];
  56427. for (i = 0; i < arg1; ++i) {
  56428. result[i] = 0;
  56429. }
  56430. } else if ('slice' in arg1) {
  56431. result = arg1.slice(0);
  56432. } else {
  56433. result = [];
  56434. for (i = 0, n = arg1.length; i < n; ++i) {
  56435. result[i] = arg1[i];
  56436. }
  56437. }
  56438. result.subarray = subarray;
  56439. result.buffer = result;
  56440. result.byteLength = result.length;
  56441. result.set = setArrayOffset;
  56442. if (typeof arg1 === 'object' && arg1.buffer) {
  56443. result.buffer = arg1.buffer;
  56444. }
  56445. return result;
  56446. }
  56447. globalScope.Uint8Array = TypedArray;
  56448. globalScope.Int8Array = TypedArray;
  56449. globalScope.Uint32Array = TypedArray;
  56450. globalScope.Int32Array = TypedArray;
  56451. globalScope.Uint16Array = TypedArray;
  56452. globalScope.Float32Array = TypedArray;
  56453. globalScope.Float64Array = TypedArray;
  56454. }());
  56455. (function normalizeURLObject() {
  56456. if (!globalScope.URL) {
  56457. globalScope.URL = globalScope.webkitURL;
  56458. }
  56459. }());
  56460. (function checkObjectDefinePropertyCompatibility() {
  56461. if (typeof Object.defineProperty !== 'undefined') {
  56462. var definePropertyPossible = true;
  56463. try {
  56464. if (hasDOM) {
  56465. Object.defineProperty(new Image(), 'id', { value: 'test' });
  56466. }
  56467. var Test = function Test() {
  56468. };
  56469. Test.prototype = {
  56470. get id() {
  56471. }
  56472. };
  56473. Object.defineProperty(new Test(), 'id', {
  56474. value: '',
  56475. configurable: true,
  56476. enumerable: true,
  56477. writable: false
  56478. });
  56479. } catch (e) {
  56480. definePropertyPossible = false;
  56481. }
  56482. if (definePropertyPossible) {
  56483. return;
  56484. }
  56485. }
  56486. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  56487. delete obj[name];
  56488. if ('get' in def) {
  56489. obj.__defineGetter__(name, def['get']);
  56490. }
  56491. if ('set' in def) {
  56492. obj.__defineSetter__(name, def['set']);
  56493. }
  56494. if ('value' in def) {
  56495. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  56496. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  56497. return value;
  56498. });
  56499. return value;
  56500. });
  56501. obj[name] = def.value;
  56502. }
  56503. };
  56504. }());
  56505. (function checkXMLHttpRequestResponseCompatibility() {
  56506. if (typeof XMLHttpRequest === 'undefined') {
  56507. return;
  56508. }
  56509. var xhrPrototype = XMLHttpRequest.prototype;
  56510. var xhr = new XMLHttpRequest();
  56511. if (!('overrideMimeType' in xhr)) {
  56512. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  56513. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  56514. }
  56515. });
  56516. }
  56517. if ('responseType' in xhr) {
  56518. return;
  56519. }
  56520. Object.defineProperty(xhrPrototype, 'responseType', {
  56521. get: function xmlHttpRequestGetResponseType() {
  56522. return this._responseType || 'text';
  56523. },
  56524. set: function xmlHttpRequestSetResponseType(value) {
  56525. if (value === 'text' || value === 'arraybuffer') {
  56526. this._responseType = value;
  56527. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  56528. this.overrideMimeType('text/plain; charset=x-user-defined');
  56529. }
  56530. }
  56531. }
  56532. });
  56533. if (typeof VBArray !== 'undefined') {
  56534. Object.defineProperty(xhrPrototype, 'response', {
  56535. get: function xmlHttpRequestResponseGet() {
  56536. if (this.responseType === 'arraybuffer') {
  56537. return new Uint8Array(new VBArray(this.responseBody).toArray());
  56538. }
  56539. return this.responseText;
  56540. }
  56541. });
  56542. return;
  56543. }
  56544. Object.defineProperty(xhrPrototype, 'response', {
  56545. get: function xmlHttpRequestResponseGet() {
  56546. if (this.responseType !== 'arraybuffer') {
  56547. return this.responseText;
  56548. }
  56549. var text = this.responseText;
  56550. var i, n = text.length;
  56551. var result = new Uint8Array(n);
  56552. for (i = 0; i < n; ++i) {
  56553. result[i] = text.charCodeAt(i) & 0xFF;
  56554. }
  56555. return result.buffer;
  56556. }
  56557. });
  56558. }());
  56559. (function checkWindowBtoaCompatibility() {
  56560. if ('btoa' in globalScope) {
  56561. return;
  56562. }
  56563. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56564. globalScope.btoa = function (chars) {
  56565. var buffer = '';
  56566. var i, n;
  56567. for (i = 0, n = chars.length; i < n; i += 3) {
  56568. var b1 = chars.charCodeAt(i) & 0xFF;
  56569. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  56570. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  56571. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  56572. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  56573. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  56574. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  56575. }
  56576. return buffer;
  56577. };
  56578. }());
  56579. (function checkWindowAtobCompatibility() {
  56580. if ('atob' in globalScope) {
  56581. return;
  56582. }
  56583. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56584. globalScope.atob = function (input) {
  56585. input = input.replace(/=+$/, '');
  56586. if (input.length % 4 === 1) {
  56587. throw new Error('bad atob input');
  56588. }
  56589. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  56590. buffer = digits.indexOf(buffer);
  56591. }
  56592. return output;
  56593. };
  56594. }());
  56595. (function checkFunctionPrototypeBindCompatibility() {
  56596. if (typeof Function.prototype.bind !== 'undefined') {
  56597. return;
  56598. }
  56599. Function.prototype.bind = function functionPrototypeBind(obj) {
  56600. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  56601. var bound = function functionPrototypeBindBound() {
  56602. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  56603. return fn.apply(obj, args);
  56604. };
  56605. return bound;
  56606. };
  56607. }());
  56608. (function checkDatasetProperty() {
  56609. if (!hasDOM) {
  56610. return;
  56611. }
  56612. var div = document.createElement('div');
  56613. if ('dataset' in div) {
  56614. return;
  56615. }
  56616. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  56617. get: function () {
  56618. if (this._dataset) {
  56619. return this._dataset;
  56620. }
  56621. var dataset = {};
  56622. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  56623. var attribute = this.attributes[j];
  56624. if (attribute.name.substring(0, 5) !== 'data-') {
  56625. continue;
  56626. }
  56627. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  56628. return ch.toUpperCase();
  56629. });
  56630. dataset[key] = attribute.value;
  56631. }
  56632. Object.defineProperty(this, '_dataset', {
  56633. value: dataset,
  56634. writable: false,
  56635. enumerable: false
  56636. });
  56637. return dataset;
  56638. },
  56639. enumerable: true
  56640. });
  56641. }());
  56642. (function checkClassListProperty() {
  56643. function changeList(element, itemName, add, remove) {
  56644. var s = element.className || '';
  56645. var list = s.split(/\s+/g);
  56646. if (list[0] === '') {
  56647. list.shift();
  56648. }
  56649. var index = list.indexOf(itemName);
  56650. if (index < 0 && add) {
  56651. list.push(itemName);
  56652. }
  56653. if (index >= 0 && remove) {
  56654. list.splice(index, 1);
  56655. }
  56656. element.className = list.join(' ');
  56657. return index >= 0;
  56658. }
  56659. if (!hasDOM) {
  56660. return;
  56661. }
  56662. var div = document.createElement('div');
  56663. if ('classList' in div) {
  56664. return;
  56665. }
  56666. var classListPrototype = {
  56667. add: function (name) {
  56668. changeList(this.element, name, true, false);
  56669. },
  56670. contains: function (name) {
  56671. return changeList(this.element, name, false, false);
  56672. },
  56673. remove: function (name) {
  56674. changeList(this.element, name, false, true);
  56675. },
  56676. toggle: function (name) {
  56677. changeList(this.element, name, true, true);
  56678. }
  56679. };
  56680. Object.defineProperty(HTMLElement.prototype, 'classList', {
  56681. get: function () {
  56682. if (this._classList) {
  56683. return this._classList;
  56684. }
  56685. var classList = Object.create(classListPrototype, {
  56686. element: {
  56687. value: this,
  56688. writable: false,
  56689. enumerable: true
  56690. }
  56691. });
  56692. Object.defineProperty(this, '_classList', {
  56693. value: classList,
  56694. writable: false,
  56695. enumerable: false
  56696. });
  56697. return classList;
  56698. },
  56699. enumerable: true
  56700. });
  56701. }());
  56702. (function checkWorkerConsoleCompatibility() {
  56703. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  56704. return;
  56705. }
  56706. var consoleTimer = {};
  56707. var workerConsole = {
  56708. log: function log() {
  56709. var args = Array.prototype.slice.call(arguments);
  56710. globalScope.postMessage({
  56711. targetName: 'main',
  56712. action: 'console_log',
  56713. data: args
  56714. });
  56715. },
  56716. error: function error() {
  56717. var args = Array.prototype.slice.call(arguments);
  56718. globalScope.postMessage({
  56719. targetName: 'main',
  56720. action: 'console_error',
  56721. data: args
  56722. });
  56723. },
  56724. time: function time(name) {
  56725. consoleTimer[name] = Date.now();
  56726. },
  56727. timeEnd: function timeEnd(name) {
  56728. var time = consoleTimer[name];
  56729. if (!time) {
  56730. throw new Error('Unknown timer name ' + name);
  56731. }
  56732. this.log('Timer:', name, Date.now() - time);
  56733. }
  56734. };
  56735. globalScope.console = workerConsole;
  56736. }());
  56737. (function checkConsoleCompatibility() {
  56738. if (!hasDOM) {
  56739. return;
  56740. }
  56741. if (!('console' in window)) {
  56742. window.console = {
  56743. log: function () {
  56744. },
  56745. error: function () {
  56746. },
  56747. warn: function () {
  56748. }
  56749. };
  56750. return;
  56751. }
  56752. if (!('bind' in console.log)) {
  56753. console.log = function (fn) {
  56754. return function (msg) {
  56755. return fn(msg);
  56756. };
  56757. }(console.log);
  56758. console.error = function (fn) {
  56759. return function (msg) {
  56760. return fn(msg);
  56761. };
  56762. }(console.error);
  56763. console.warn = function (fn) {
  56764. return function (msg) {
  56765. return fn(msg);
  56766. };
  56767. }(console.warn);
  56768. return;
  56769. }
  56770. }());
  56771. (function checkOnClickCompatibility() {
  56772. function ignoreIfTargetDisabled(event) {
  56773. if (isDisabled(event.target)) {
  56774. event.stopPropagation();
  56775. }
  56776. }
  56777. function isDisabled(node) {
  56778. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  56779. }
  56780. if (isOpera) {
  56781. document.addEventListener('click', ignoreIfTargetDisabled, true);
  56782. }
  56783. }());
  56784. (function checkOnBlobSupport() {
  56785. if (isIE || isIOSChrome) {
  56786. PDFJS.disableCreateObjectURL = true;
  56787. }
  56788. }());
  56789. (function checkNavigatorLanguage() {
  56790. if (typeof navigator === 'undefined') {
  56791. return;
  56792. }
  56793. if ('language' in navigator) {
  56794. return;
  56795. }
  56796. PDFJS.locale = navigator.userLanguage || 'en-US';
  56797. }());
  56798. (function checkRangeRequests() {
  56799. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  56800. PDFJS.disableRange = true;
  56801. PDFJS.disableStream = true;
  56802. }
  56803. }());
  56804. (function checkHistoryManipulation() {
  56805. if (!hasDOM) {
  56806. return;
  56807. }
  56808. if (!history.pushState || isAndroidPre3) {
  56809. PDFJS.disableHistory = true;
  56810. }
  56811. }());
  56812. (function checkSetPresenceInImageData() {
  56813. if (!hasDOM) {
  56814. return;
  56815. }
  56816. if (window.CanvasPixelArray) {
  56817. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  56818. window.CanvasPixelArray.prototype.set = function (arr) {
  56819. for (var i = 0, ii = this.length; i < ii; i++) {
  56820. this[i] = arr[i];
  56821. }
  56822. };
  56823. }
  56824. } else {
  56825. var polyfill = false, versionMatch;
  56826. if (isChrome) {
  56827. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  56828. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  56829. } else if (isAndroid) {
  56830. polyfill = isAndroidPre5;
  56831. } else if (isSafari) {
  56832. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  56833. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  56834. }
  56835. if (polyfill) {
  56836. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  56837. var createImageData = contextPrototype.createImageData;
  56838. contextPrototype.createImageData = function (w, h) {
  56839. var imageData = createImageData.call(this, w, h);
  56840. imageData.data.set = function (arr) {
  56841. for (var i = 0, ii = this.length; i < ii; i++) {
  56842. this[i] = arr[i];
  56843. }
  56844. };
  56845. return imageData;
  56846. };
  56847. contextPrototype = null;
  56848. }
  56849. }
  56850. }());
  56851. (function checkRequestAnimationFrame() {
  56852. function fakeRequestAnimationFrame(callback) {
  56853. window.setTimeout(callback, 20);
  56854. }
  56855. if (!hasDOM) {
  56856. return;
  56857. }
  56858. if (isIOS) {
  56859. window.requestAnimationFrame = fakeRequestAnimationFrame;
  56860. return;
  56861. }
  56862. if ('requestAnimationFrame' in window) {
  56863. return;
  56864. }
  56865. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  56866. }());
  56867. (function checkCanvasSizeLimitation() {
  56868. if (isIOS || isAndroid) {
  56869. PDFJS.maxCanvasPixels = 5242880;
  56870. }
  56871. }());
  56872. (function checkFullscreenSupport() {
  56873. if (!hasDOM) {
  56874. return;
  56875. }
  56876. if (isIE && window.parent !== window) {
  56877. PDFJS.disableFullscreen = true;
  56878. }
  56879. }());
  56880. (function checkCurrentScript() {
  56881. if (!hasDOM) {
  56882. return;
  56883. }
  56884. if ('currentScript' in document) {
  56885. return;
  56886. }
  56887. Object.defineProperty(document, 'currentScript', {
  56888. get: function () {
  56889. var scripts = document.getElementsByTagName('script');
  56890. return scripts[scripts.length - 1];
  56891. },
  56892. enumerable: true,
  56893. configurable: true
  56894. });
  56895. }());
  56896. (function checkInputTypeNumberAssign() {
  56897. if (!hasDOM) {
  56898. return;
  56899. }
  56900. var el = document.createElement('input');
  56901. try {
  56902. el.type = 'number';
  56903. } catch (ex) {
  56904. var inputProto = el.constructor.prototype;
  56905. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  56906. Object.defineProperty(inputProto, 'type', {
  56907. get: function () {
  56908. return typeProperty.get.call(this);
  56909. },
  56910. set: function (value) {
  56911. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  56912. },
  56913. enumerable: true,
  56914. configurable: true
  56915. });
  56916. }
  56917. }());
  56918. (function checkDocumentReadyState() {
  56919. if (!hasDOM) {
  56920. return;
  56921. }
  56922. if (!document.attachEvent) {
  56923. return;
  56924. }
  56925. var documentProto = document.constructor.prototype;
  56926. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  56927. Object.defineProperty(documentProto, 'readyState', {
  56928. get: function () {
  56929. var value = readyStateProto.get.call(this);
  56930. return value === 'interactive' ? 'loading' : value;
  56931. },
  56932. set: function (value) {
  56933. readyStateProto.set.call(this, value);
  56934. },
  56935. enumerable: true,
  56936. configurable: true
  56937. });
  56938. }());
  56939. (function checkChildNodeRemove() {
  56940. if (!hasDOM) {
  56941. return;
  56942. }
  56943. if (typeof Element.prototype.remove !== 'undefined') {
  56944. return;
  56945. }
  56946. Element.prototype.remove = function () {
  56947. if (this.parentNode) {
  56948. this.parentNode.removeChild(this);
  56949. }
  56950. };
  56951. }());
  56952. (function checkPromise() {
  56953. if (globalScope.Promise) {
  56954. if (typeof globalScope.Promise.all !== 'function') {
  56955. globalScope.Promise.all = function (iterable) {
  56956. var count = 0, results = [], resolve, reject;
  56957. var promise = new globalScope.Promise(function (resolve_, reject_) {
  56958. resolve = resolve_;
  56959. reject = reject_;
  56960. });
  56961. iterable.forEach(function (p, i) {
  56962. count++;
  56963. p.then(function (result) {
  56964. results[i] = result;
  56965. count--;
  56966. if (count === 0) {
  56967. resolve(results);
  56968. }
  56969. }, reject);
  56970. });
  56971. if (count === 0) {
  56972. resolve(results);
  56973. }
  56974. return promise;
  56975. };
  56976. }
  56977. if (typeof globalScope.Promise.resolve !== 'function') {
  56978. globalScope.Promise.resolve = function (value) {
  56979. return new globalScope.Promise(function (resolve) {
  56980. resolve(value);
  56981. });
  56982. };
  56983. }
  56984. if (typeof globalScope.Promise.reject !== 'function') {
  56985. globalScope.Promise.reject = function (reason) {
  56986. return new globalScope.Promise(function (resolve, reject) {
  56987. reject(reason);
  56988. });
  56989. };
  56990. }
  56991. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  56992. globalScope.Promise.prototype.catch = function (onReject) {
  56993. return globalScope.Promise.prototype.then(undefined, onReject);
  56994. };
  56995. }
  56996. return;
  56997. }
  56998. var STATUS_PENDING = 0;
  56999. var STATUS_RESOLVED = 1;
  57000. var STATUS_REJECTED = 2;
  57001. var REJECTION_TIMEOUT = 500;
  57002. var HandlerManager = {
  57003. handlers: [],
  57004. running: false,
  57005. unhandledRejections: [],
  57006. pendingRejectionCheck: false,
  57007. scheduleHandlers: function scheduleHandlers(promise) {
  57008. if (promise._status === STATUS_PENDING) {
  57009. return;
  57010. }
  57011. this.handlers = this.handlers.concat(promise._handlers);
  57012. promise._handlers = [];
  57013. if (this.running) {
  57014. return;
  57015. }
  57016. this.running = true;
  57017. setTimeout(this.runHandlers.bind(this), 0);
  57018. },
  57019. runHandlers: function runHandlers() {
  57020. var RUN_TIMEOUT = 1;
  57021. var timeoutAt = Date.now() + RUN_TIMEOUT;
  57022. while (this.handlers.length > 0) {
  57023. var handler = this.handlers.shift();
  57024. var nextStatus = handler.thisPromise._status;
  57025. var nextValue = handler.thisPromise._value;
  57026. try {
  57027. if (nextStatus === STATUS_RESOLVED) {
  57028. if (typeof handler.onResolve === 'function') {
  57029. nextValue = handler.onResolve(nextValue);
  57030. }
  57031. } else if (typeof handler.onReject === 'function') {
  57032. nextValue = handler.onReject(nextValue);
  57033. nextStatus = STATUS_RESOLVED;
  57034. if (handler.thisPromise._unhandledRejection) {
  57035. this.removeUnhandeledRejection(handler.thisPromise);
  57036. }
  57037. }
  57038. } catch (ex) {
  57039. nextStatus = STATUS_REJECTED;
  57040. nextValue = ex;
  57041. }
  57042. handler.nextPromise._updateStatus(nextStatus, nextValue);
  57043. if (Date.now() >= timeoutAt) {
  57044. break;
  57045. }
  57046. }
  57047. if (this.handlers.length > 0) {
  57048. setTimeout(this.runHandlers.bind(this), 0);
  57049. return;
  57050. }
  57051. this.running = false;
  57052. },
  57053. addUnhandledRejection: function addUnhandledRejection(promise) {
  57054. this.unhandledRejections.push({
  57055. promise: promise,
  57056. time: Date.now()
  57057. });
  57058. this.scheduleRejectionCheck();
  57059. },
  57060. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  57061. promise._unhandledRejection = false;
  57062. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57063. if (this.unhandledRejections[i].promise === promise) {
  57064. this.unhandledRejections.splice(i);
  57065. i--;
  57066. }
  57067. }
  57068. },
  57069. scheduleRejectionCheck: function scheduleRejectionCheck() {
  57070. if (this.pendingRejectionCheck) {
  57071. return;
  57072. }
  57073. this.pendingRejectionCheck = true;
  57074. setTimeout(function rejectionCheck() {
  57075. this.pendingRejectionCheck = false;
  57076. var now = Date.now();
  57077. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57078. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  57079. var unhandled = this.unhandledRejections[i].promise._value;
  57080. var msg = 'Unhandled rejection: ' + unhandled;
  57081. if (unhandled.stack) {
  57082. msg += '\n' + unhandled.stack;
  57083. }
  57084. try {
  57085. throw new Error(msg);
  57086. } catch (_) {
  57087. console.warn(msg);
  57088. }
  57089. this.unhandledRejections.splice(i);
  57090. i--;
  57091. }
  57092. }
  57093. if (this.unhandledRejections.length) {
  57094. this.scheduleRejectionCheck();
  57095. }
  57096. }.bind(this), REJECTION_TIMEOUT);
  57097. }
  57098. };
  57099. var Promise = function Promise(resolver) {
  57100. this._status = STATUS_PENDING;
  57101. this._handlers = [];
  57102. try {
  57103. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  57104. } catch (e) {
  57105. this._reject(e);
  57106. }
  57107. };
  57108. Promise.all = function Promise_all(promises) {
  57109. var resolveAll, rejectAll;
  57110. var deferred = new Promise(function (resolve, reject) {
  57111. resolveAll = resolve;
  57112. rejectAll = reject;
  57113. });
  57114. var unresolved = promises.length;
  57115. var results = [];
  57116. if (unresolved === 0) {
  57117. resolveAll(results);
  57118. return deferred;
  57119. }
  57120. function reject(reason) {
  57121. if (deferred._status === STATUS_REJECTED) {
  57122. return;
  57123. }
  57124. results = [];
  57125. rejectAll(reason);
  57126. }
  57127. for (var i = 0, ii = promises.length; i < ii; ++i) {
  57128. var promise = promises[i];
  57129. var resolve = function (i) {
  57130. return function (value) {
  57131. if (deferred._status === STATUS_REJECTED) {
  57132. return;
  57133. }
  57134. results[i] = value;
  57135. unresolved--;
  57136. if (unresolved === 0) {
  57137. resolveAll(results);
  57138. }
  57139. };
  57140. }(i);
  57141. if (Promise.isPromise(promise)) {
  57142. promise.then(resolve, reject);
  57143. } else {
  57144. resolve(promise);
  57145. }
  57146. }
  57147. return deferred;
  57148. };
  57149. Promise.isPromise = function Promise_isPromise(value) {
  57150. return value && typeof value.then === 'function';
  57151. };
  57152. Promise.resolve = function Promise_resolve(value) {
  57153. return new Promise(function (resolve) {
  57154. resolve(value);
  57155. });
  57156. };
  57157. Promise.reject = function Promise_reject(reason) {
  57158. return new Promise(function (resolve, reject) {
  57159. reject(reason);
  57160. });
  57161. };
  57162. Promise.prototype = {
  57163. _status: null,
  57164. _value: null,
  57165. _handlers: null,
  57166. _unhandledRejection: null,
  57167. _updateStatus: function Promise__updateStatus(status, value) {
  57168. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  57169. return;
  57170. }
  57171. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  57172. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  57173. return;
  57174. }
  57175. this._status = status;
  57176. this._value = value;
  57177. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  57178. this._unhandledRejection = true;
  57179. HandlerManager.addUnhandledRejection(this);
  57180. }
  57181. HandlerManager.scheduleHandlers(this);
  57182. },
  57183. _resolve: function Promise_resolve(value) {
  57184. this._updateStatus(STATUS_RESOLVED, value);
  57185. },
  57186. _reject: function Promise_reject(reason) {
  57187. this._updateStatus(STATUS_REJECTED, reason);
  57188. },
  57189. then: function Promise_then(onResolve, onReject) {
  57190. var nextPromise = new Promise(function (resolve, reject) {
  57191. this.resolve = resolve;
  57192. this.reject = reject;
  57193. });
  57194. this._handlers.push({
  57195. thisPromise: this,
  57196. onResolve: onResolve,
  57197. onReject: onReject,
  57198. nextPromise: nextPromise
  57199. });
  57200. HandlerManager.scheduleHandlers(this);
  57201. return nextPromise;
  57202. },
  57203. catch: function Promise_catch(onReject) {
  57204. return this.then(undefined, onReject);
  57205. }
  57206. };
  57207. globalScope.Promise = Promise;
  57208. }());
  57209. (function checkWeakMap() {
  57210. if (globalScope.WeakMap) {
  57211. return;
  57212. }
  57213. var id = 0;
  57214. function WeakMap() {
  57215. this.id = '$weakmap' + id++;
  57216. }
  57217. WeakMap.prototype = {
  57218. has: function (obj) {
  57219. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  57220. },
  57221. get: function (obj, defaultValue) {
  57222. return this.has(obj) ? obj[this.id] : defaultValue;
  57223. },
  57224. set: function (obj, value) {
  57225. Object.defineProperty(obj, this.id, {
  57226. value: value,
  57227. enumerable: false,
  57228. configurable: true
  57229. });
  57230. },
  57231. delete: function (obj) {
  57232. delete obj[this.id];
  57233. }
  57234. };
  57235. globalScope.WeakMap = WeakMap;
  57236. }());
  57237. (function checkURLConstructor() {
  57238. var hasWorkingUrl = false;
  57239. try {
  57240. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  57241. var u = new URL('b', 'http://a');
  57242. u.pathname = 'c%20d';
  57243. hasWorkingUrl = u.href === 'http://a/c%20d';
  57244. }
  57245. } catch (e) {
  57246. }
  57247. if (hasWorkingUrl) {
  57248. return;
  57249. }
  57250. var relative = Object.create(null);
  57251. relative['ftp'] = 21;
  57252. relative['file'] = 0;
  57253. relative['gopher'] = 70;
  57254. relative['http'] = 80;
  57255. relative['https'] = 443;
  57256. relative['ws'] = 80;
  57257. relative['wss'] = 443;
  57258. var relativePathDotMapping = Object.create(null);
  57259. relativePathDotMapping['%2e'] = '.';
  57260. relativePathDotMapping['.%2e'] = '..';
  57261. relativePathDotMapping['%2e.'] = '..';
  57262. relativePathDotMapping['%2e%2e'] = '..';
  57263. function isRelativeScheme(scheme) {
  57264. return relative[scheme] !== undefined;
  57265. }
  57266. function invalid() {
  57267. clear.call(this);
  57268. this._isInvalid = true;
  57269. }
  57270. function IDNAToASCII(h) {
  57271. if (h === '') {
  57272. invalid.call(this);
  57273. }
  57274. return h.toLowerCase();
  57275. }
  57276. function percentEscape(c) {
  57277. var unicode = c.charCodeAt(0);
  57278. if (unicode > 0x20 && unicode < 0x7F && [
  57279. 0x22,
  57280. 0x23,
  57281. 0x3C,
  57282. 0x3E,
  57283. 0x3F,
  57284. 0x60
  57285. ].indexOf(unicode) === -1) {
  57286. return c;
  57287. }
  57288. return encodeURIComponent(c);
  57289. }
  57290. function percentEscapeQuery(c) {
  57291. var unicode = c.charCodeAt(0);
  57292. if (unicode > 0x20 && unicode < 0x7F && [
  57293. 0x22,
  57294. 0x23,
  57295. 0x3C,
  57296. 0x3E,
  57297. 0x60
  57298. ].indexOf(unicode) === -1) {
  57299. return c;
  57300. }
  57301. return encodeURIComponent(c);
  57302. }
  57303. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  57304. function parse(input, stateOverride, base) {
  57305. function err(message) {
  57306. errors.push(message);
  57307. }
  57308. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  57309. loop:
  57310. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  57311. var c = input[cursor];
  57312. switch (state) {
  57313. case 'scheme start':
  57314. if (c && ALPHA.test(c)) {
  57315. buffer += c.toLowerCase();
  57316. state = 'scheme';
  57317. } else if (!stateOverride) {
  57318. buffer = '';
  57319. state = 'no scheme';
  57320. continue;
  57321. } else {
  57322. err('Invalid scheme.');
  57323. break loop;
  57324. }
  57325. break;
  57326. case 'scheme':
  57327. if (c && ALPHANUMERIC.test(c)) {
  57328. buffer += c.toLowerCase();
  57329. } else if (c === ':') {
  57330. this._scheme = buffer;
  57331. buffer = '';
  57332. if (stateOverride) {
  57333. break loop;
  57334. }
  57335. if (isRelativeScheme(this._scheme)) {
  57336. this._isRelative = true;
  57337. }
  57338. if (this._scheme === 'file') {
  57339. state = 'relative';
  57340. } else if (this._isRelative && base && base._scheme === this._scheme) {
  57341. state = 'relative or authority';
  57342. } else if (this._isRelative) {
  57343. state = 'authority first slash';
  57344. } else {
  57345. state = 'scheme data';
  57346. }
  57347. } else if (!stateOverride) {
  57348. buffer = '';
  57349. cursor = 0;
  57350. state = 'no scheme';
  57351. continue;
  57352. } else if (c === EOF) {
  57353. break loop;
  57354. } else {
  57355. err('Code point not allowed in scheme: ' + c);
  57356. break loop;
  57357. }
  57358. break;
  57359. case 'scheme data':
  57360. if (c === '?') {
  57361. this._query = '?';
  57362. state = 'query';
  57363. } else if (c === '#') {
  57364. this._fragment = '#';
  57365. state = 'fragment';
  57366. } else {
  57367. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  57368. this._schemeData += percentEscape(c);
  57369. }
  57370. }
  57371. break;
  57372. case 'no scheme':
  57373. if (!base || !isRelativeScheme(base._scheme)) {
  57374. err('Missing scheme.');
  57375. invalid.call(this);
  57376. } else {
  57377. state = 'relative';
  57378. continue;
  57379. }
  57380. break;
  57381. case 'relative or authority':
  57382. if (c === '/' && input[cursor + 1] === '/') {
  57383. state = 'authority ignore slashes';
  57384. } else {
  57385. err('Expected /, got: ' + c);
  57386. state = 'relative';
  57387. continue;
  57388. }
  57389. break;
  57390. case 'relative':
  57391. this._isRelative = true;
  57392. if (this._scheme !== 'file') {
  57393. this._scheme = base._scheme;
  57394. }
  57395. if (c === EOF) {
  57396. this._host = base._host;
  57397. this._port = base._port;
  57398. this._path = base._path.slice();
  57399. this._query = base._query;
  57400. this._username = base._username;
  57401. this._password = base._password;
  57402. break loop;
  57403. } else if (c === '/' || c === '\\') {
  57404. if (c === '\\') {
  57405. err('\\ is an invalid code point.');
  57406. }
  57407. state = 'relative slash';
  57408. } else if (c === '?') {
  57409. this._host = base._host;
  57410. this._port = base._port;
  57411. this._path = base._path.slice();
  57412. this._query = '?';
  57413. this._username = base._username;
  57414. this._password = base._password;
  57415. state = 'query';
  57416. } else if (c === '#') {
  57417. this._host = base._host;
  57418. this._port = base._port;
  57419. this._path = base._path.slice();
  57420. this._query = base._query;
  57421. this._fragment = '#';
  57422. this._username = base._username;
  57423. this._password = base._password;
  57424. state = 'fragment';
  57425. } else {
  57426. var nextC = input[cursor + 1];
  57427. var nextNextC = input[cursor + 2];
  57428. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  57429. this._host = base._host;
  57430. this._port = base._port;
  57431. this._username = base._username;
  57432. this._password = base._password;
  57433. this._path = base._path.slice();
  57434. this._path.pop();
  57435. }
  57436. state = 'relative path';
  57437. continue;
  57438. }
  57439. break;
  57440. case 'relative slash':
  57441. if (c === '/' || c === '\\') {
  57442. if (c === '\\') {
  57443. err('\\ is an invalid code point.');
  57444. }
  57445. if (this._scheme === 'file') {
  57446. state = 'file host';
  57447. } else {
  57448. state = 'authority ignore slashes';
  57449. }
  57450. } else {
  57451. if (this._scheme !== 'file') {
  57452. this._host = base._host;
  57453. this._port = base._port;
  57454. this._username = base._username;
  57455. this._password = base._password;
  57456. }
  57457. state = 'relative path';
  57458. continue;
  57459. }
  57460. break;
  57461. case 'authority first slash':
  57462. if (c === '/') {
  57463. state = 'authority second slash';
  57464. } else {
  57465. err('Expected \'/\', got: ' + c);
  57466. state = 'authority ignore slashes';
  57467. continue;
  57468. }
  57469. break;
  57470. case 'authority second slash':
  57471. state = 'authority ignore slashes';
  57472. if (c !== '/') {
  57473. err('Expected \'/\', got: ' + c);
  57474. continue;
  57475. }
  57476. break;
  57477. case 'authority ignore slashes':
  57478. if (c !== '/' && c !== '\\') {
  57479. state = 'authority';
  57480. continue;
  57481. } else {
  57482. err('Expected authority, got: ' + c);
  57483. }
  57484. break;
  57485. case 'authority':
  57486. if (c === '@') {
  57487. if (seenAt) {
  57488. err('@ already seen.');
  57489. buffer += '%40';
  57490. }
  57491. seenAt = true;
  57492. for (var i = 0; i < buffer.length; i++) {
  57493. var cp = buffer[i];
  57494. if (cp === '\t' || cp === '\n' || cp === '\r') {
  57495. err('Invalid whitespace in authority.');
  57496. continue;
  57497. }
  57498. if (cp === ':' && this._password === null) {
  57499. this._password = '';
  57500. continue;
  57501. }
  57502. var tempC = percentEscape(cp);
  57503. if (this._password !== null) {
  57504. this._password += tempC;
  57505. } else {
  57506. this._username += tempC;
  57507. }
  57508. }
  57509. buffer = '';
  57510. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57511. cursor -= buffer.length;
  57512. buffer = '';
  57513. state = 'host';
  57514. continue;
  57515. } else {
  57516. buffer += c;
  57517. }
  57518. break;
  57519. case 'file host':
  57520. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57521. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  57522. state = 'relative path';
  57523. } else if (buffer.length === 0) {
  57524. state = 'relative path start';
  57525. } else {
  57526. this._host = IDNAToASCII.call(this, buffer);
  57527. buffer = '';
  57528. state = 'relative path start';
  57529. }
  57530. continue;
  57531. } else if (c === '\t' || c === '\n' || c === '\r') {
  57532. err('Invalid whitespace in file host.');
  57533. } else {
  57534. buffer += c;
  57535. }
  57536. break;
  57537. case 'host':
  57538. case 'hostname':
  57539. if (c === ':' && !seenBracket) {
  57540. this._host = IDNAToASCII.call(this, buffer);
  57541. buffer = '';
  57542. state = 'port';
  57543. if (stateOverride === 'hostname') {
  57544. break loop;
  57545. }
  57546. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57547. this._host = IDNAToASCII.call(this, buffer);
  57548. buffer = '';
  57549. state = 'relative path start';
  57550. if (stateOverride) {
  57551. break loop;
  57552. }
  57553. continue;
  57554. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  57555. if (c === '[') {
  57556. seenBracket = true;
  57557. } else if (c === ']') {
  57558. seenBracket = false;
  57559. }
  57560. buffer += c;
  57561. } else {
  57562. err('Invalid code point in host/hostname: ' + c);
  57563. }
  57564. break;
  57565. case 'port':
  57566. if (/[0-9]/.test(c)) {
  57567. buffer += c;
  57568. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  57569. if (buffer !== '') {
  57570. var temp = parseInt(buffer, 10);
  57571. if (temp !== relative[this._scheme]) {
  57572. this._port = temp + '';
  57573. }
  57574. buffer = '';
  57575. }
  57576. if (stateOverride) {
  57577. break loop;
  57578. }
  57579. state = 'relative path start';
  57580. continue;
  57581. } else if (c === '\t' || c === '\n' || c === '\r') {
  57582. err('Invalid code point in port: ' + c);
  57583. } else {
  57584. invalid.call(this);
  57585. }
  57586. break;
  57587. case 'relative path start':
  57588. if (c === '\\') {
  57589. err('\'\\\' not allowed in path.');
  57590. }
  57591. state = 'relative path';
  57592. if (c !== '/' && c !== '\\') {
  57593. continue;
  57594. }
  57595. break;
  57596. case 'relative path':
  57597. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  57598. if (c === '\\') {
  57599. err('\\ not allowed in relative path.');
  57600. }
  57601. var tmp;
  57602. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  57603. buffer = tmp;
  57604. }
  57605. if (buffer === '..') {
  57606. this._path.pop();
  57607. if (c !== '/' && c !== '\\') {
  57608. this._path.push('');
  57609. }
  57610. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  57611. this._path.push('');
  57612. } else if (buffer !== '.') {
  57613. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  57614. buffer = buffer[0] + ':';
  57615. }
  57616. this._path.push(buffer);
  57617. }
  57618. buffer = '';
  57619. if (c === '?') {
  57620. this._query = '?';
  57621. state = 'query';
  57622. } else if (c === '#') {
  57623. this._fragment = '#';
  57624. state = 'fragment';
  57625. }
  57626. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  57627. buffer += percentEscape(c);
  57628. }
  57629. break;
  57630. case 'query':
  57631. if (!stateOverride && c === '#') {
  57632. this._fragment = '#';
  57633. state = 'fragment';
  57634. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  57635. this._query += percentEscapeQuery(c);
  57636. }
  57637. break;
  57638. case 'fragment':
  57639. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  57640. this._fragment += c;
  57641. }
  57642. break;
  57643. }
  57644. cursor++;
  57645. }
  57646. }
  57647. function clear() {
  57648. this._scheme = '';
  57649. this._schemeData = '';
  57650. this._username = '';
  57651. this._password = null;
  57652. this._host = '';
  57653. this._port = '';
  57654. this._path = [];
  57655. this._query = '';
  57656. this._fragment = '';
  57657. this._isInvalid = false;
  57658. this._isRelative = false;
  57659. }
  57660. function JURL(url, base) {
  57661. if (base !== undefined && !(base instanceof JURL)) {
  57662. base = new JURL(String(base));
  57663. }
  57664. this._url = url;
  57665. clear.call(this);
  57666. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  57667. parse.call(this, input, null, base);
  57668. }
  57669. JURL.prototype = {
  57670. toString: function () {
  57671. return this.href;
  57672. },
  57673. get href() {
  57674. if (this._isInvalid) {
  57675. return this._url;
  57676. }
  57677. var authority = '';
  57678. if (this._username !== '' || this._password !== null) {
  57679. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  57680. }
  57681. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  57682. },
  57683. set href(href) {
  57684. clear.call(this);
  57685. parse.call(this, href);
  57686. },
  57687. get protocol() {
  57688. return this._scheme + ':';
  57689. },
  57690. set protocol(protocol) {
  57691. if (this._isInvalid) {
  57692. return;
  57693. }
  57694. parse.call(this, protocol + ':', 'scheme start');
  57695. },
  57696. get host() {
  57697. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  57698. },
  57699. set host(host) {
  57700. if (this._isInvalid || !this._isRelative) {
  57701. return;
  57702. }
  57703. parse.call(this, host, 'host');
  57704. },
  57705. get hostname() {
  57706. return this._host;
  57707. },
  57708. set hostname(hostname) {
  57709. if (this._isInvalid || !this._isRelative) {
  57710. return;
  57711. }
  57712. parse.call(this, hostname, 'hostname');
  57713. },
  57714. get port() {
  57715. return this._port;
  57716. },
  57717. set port(port) {
  57718. if (this._isInvalid || !this._isRelative) {
  57719. return;
  57720. }
  57721. parse.call(this, port, 'port');
  57722. },
  57723. get pathname() {
  57724. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  57725. },
  57726. set pathname(pathname) {
  57727. if (this._isInvalid || !this._isRelative) {
  57728. return;
  57729. }
  57730. this._path = [];
  57731. parse.call(this, pathname, 'relative path start');
  57732. },
  57733. get search() {
  57734. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  57735. },
  57736. set search(search) {
  57737. if (this._isInvalid || !this._isRelative) {
  57738. return;
  57739. }
  57740. this._query = '?';
  57741. if (search[0] === '?') {
  57742. search = search.slice(1);
  57743. }
  57744. parse.call(this, search, 'query');
  57745. },
  57746. get hash() {
  57747. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  57748. },
  57749. set hash(hash) {
  57750. if (this._isInvalid) {
  57751. return;
  57752. }
  57753. this._fragment = '#';
  57754. if (hash[0] === '#') {
  57755. hash = hash.slice(1);
  57756. }
  57757. parse.call(this, hash, 'fragment');
  57758. },
  57759. get origin() {
  57760. var host;
  57761. if (this._isInvalid || !this._scheme) {
  57762. return '';
  57763. }
  57764. switch (this._scheme) {
  57765. case 'data':
  57766. case 'file':
  57767. case 'javascript':
  57768. case 'mailto':
  57769. return 'null';
  57770. }
  57771. host = this.host;
  57772. if (!host) {
  57773. return '';
  57774. }
  57775. return this._scheme + '://' + host;
  57776. }
  57777. };
  57778. var OriginalURL = globalScope.URL;
  57779. if (OriginalURL) {
  57780. JURL.createObjectURL = function (blob) {
  57781. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  57782. };
  57783. JURL.revokeObjectURL = function (url) {
  57784. OriginalURL.revokeObjectURL(url);
  57785. };
  57786. }
  57787. globalScope.URL = JURL;
  57788. }());
  57789. }
  57790. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  57791. /***/ })
  57792. /******/ ]);
  57793. });